[Numpy-discussion] Reading a big netcdf file

Christopher Barker Chris.Barker@noaa....
Thu Aug 4 14:26:29 CDT 2011


On 8/4/11 10:02 AM, Christopher Barker wrote:
> On 8/4/11 8:53 AM, Jeff Whitaker wrote:
>> Kiko: I think the difference may be that when you read the data with
>> netcdf4-python, it tries to unpack the short integers to a float32
>> array.
>
> Jeff, why is that? is it an netcdf4 convention? I always thought that
> the netcdf data model matched numpy's quite well, including the clear
> choice and specification of data type. I guess I've mostly used float
> data anyway, so hadn't noticed this, but ti comes as a surprise to me!
>
>   >  gebco4.set_automaskandscale(False)

OK -- looked at this a bit more, and see in the OP's ncdump:

variables:
         short z(xysize) ;
                 z:scale_factor = 1. ;
                 z:add_offset = 0. ;
                 z:node_offset = 0 ;

so I presume netCDF4 is seeing the scale_factor and offsets, and thus 
converting to float.

In this case, the scale factor is 1.0, and the offsets are 0.0, so there 
isn't any need to convert, but that may be too smart!

-Chris



-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker@noaa.gov


More information about the NumPy-Discussion mailing list