[SciPy-User] scipy.io.netcdf question

Benjamin Root ben.root@ou....
Tue Aug 24 16:36:34 CDT 2010


On Tue, Aug 24, 2010 at 3:37 PM, Phil Morefield <philmorefield@yahoo.com>wrote:

>  A question for scipy experts:
>
> I'm trying to read in a very large three dimensional NetCDF file and
> failing. The code is simple:
>
> import numpy
> from scipy.io import netcdf
>
> ncFile = netcdf.netcdf_file(my_input_file,"r")
>
> Traceback (most recent call last):
>   File "<interactive input>", line 1, in <module>
>   File "C:\Python25\lib\site-packages\scipy\io\netcdf.py", line 43, in
> __init__
>     self._parse()
>   File "C:\Python25\lib\site-packages\scipy\io\netcdf.py", line 79, in
> _parse
>     self._var_array()
>   File "C:\Python25\lib\site-packages\scipy\io\netcdf.py", line 135, in
> _var_array
>     self.variables[name] = self._read_var()
>   File "C:\Python25\lib\site-packages\scipy\io\netcdf.py", line 180, in
> _read_var
>     attributes = self._att_array()
>   File "C:\Python25\lib\site-packages\scipy\io\netcdf.py", line 119, in
> _att_array
>     attributes[name] = self._read_values(n, nc_type)
>   File "C:\Python25\lib\site-packages\scipy\io\netcdf.py", line 193, in
> _read_values
>     count = n * bytes[nc_type-1]
> IndexError: list index out of range
>
> I went into the scipy code and determined that the variable 'nc_type' is
> being passed to _read_values with a value of 1333097057, while the list
> object 'bytes' only holds six items. That explains the "list index out of
> range". My suspicion is that some identifying information is wrong with my
> NetCDF file, but I can't figure out where the 'nc_type' variable comes from
> exactly, so I'm just guessing.
>
> I'd really appreciate some help with this. Any ideas?
>
> Thanks!
>
>

Phil,

Can you please do a ncdump -h on the file and post the output here.  That
might help explain things.  Also, how many megabytes is this file.  It might
be possible that the code is not properly detecting the newer mode (which
contains extra data at the beginning of the header) and therefore is reading
bad values in the wrong spots.

Ben Root
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20100824/5d885401/attachment.html 


More information about the SciPy-User mailing list