Using Numeric 24.0b2 with Scientific.IO.NetCDF

bandw fred at ucar.edu
Tue Jul 5 21:06:33 CEST 2005


Robert,

Thanks for your reply.  However, I am still having problems.  Sometimes
I get a scalar return
and sometimes I get an array.  For example, using the netCDF file:

netcdf simple {
   dimensions:
           num = 3 ;
   variables:
           float temp0(num) ;
           int   temp1(num) ;
   data:

    temp0 = 1., 2., 3. ;
    temp1 = 1,  2,  3 ;
}

and running:

#
import Numeric
print Numeric.__version__
from Scientific.IO.NetCDF import NetCDFFile

cdf_file1 = NetCDFFile("simple.nc","r")

var1 = cdf_file1.variables["temp0"][:]
var2 = cdf_file1.variables["temp1"][:]
min1 = reduce(Numeric.minimum,var1)
min2 = reduce(Numeric.minimum,var2)

print "Types of var1, min(var1), min1:",type(var1), type(min(var1)),
type(min1)
print "Types of var2, min(var2), min2:",type(var2), type(min(var2)),
type(min2)

I get:

24.0b2
Types of var1, min(var1), min1: <type 'array'> <type 'array'> <type
'array'>
Types of var2, min(var2), min2: <type 'array'> <type 'int'> <type
'int'>

Even something like:


>>> import Numeric
>>> a = Numeric.array([1.,2.])
>>> print type(a),type(min(a))
<type 'array'> <type 'float'>

does not produce an array.

Any comments woud be appreciated.

Fred Clare




More information about the Python-list mailing list