Using Numeric 24.0b2 with Scientific.IO.NetCDF

bandw fred at ucar.edu
Fri Jul 1 01:22:20 CEST 2005


I am having a problem using Numeric-24.0b2 in conjunction with
the NetCDF module from ScientificPython (version 2.4.9).
This problem does not surface using Numeric-23.8. The problem
arises in using the "min" function on a NetCDF floating array.
In 23.8, the "min" function returns a floating scalar, while in
24.0b2 it returns an *array* of length "1". Below I list a
simple NetCDF file and a Python script that illustrate the
problem. When I run the script using 23.8, I get the result:

1.0 <type 'float'>

whereas using 24.0b2 I get:

1.0 <type 'array'>

This creates a backward incompatibility that breaks several of
my codes.

NetCDF file simple.cdl (used to create simple.nc with "ncgen")
--------------------------------------------------------------

netcdf simple {
dimensions:
num = 3 ;
variables:
float temp(num) ;
data:

temp = 1, 2, 3 ;
}


Python script
-------------

import Numeric
from Scientific.IO.NetCDF import NetCDFFile

cdf_file1 = NetCDFFile("simple.nc","r")
temp = cdf_file1.variables["temp"][:]
 
print min(temp), type(min(temp))




More information about the Python-list mailing list