[SciPy-user] Problem reading NetCDF File

Ludovic DROUINEAU ludovic.drouineau@ifremer...
Mon Feb 2 03:41:50 CST 2009

Scott Sinclair a écrit :
>> 2009/1/30 Ludovic DROUINEAU <ludovic.drouineau@ifremer.fr>:
>> Hi all,
>> When I try to open a NetCDF file, I have the following error:
>>  File "C:\Python25\lib\site-packages\scipy\io\netcdf.py", line 194, in
>> _read_values
>>   count = n * bytes[nc_type-1]
>> IndexError: list index out of range
>> My code is:
>> from scipy.io import netcdf
>> nc = netcdf.netcdf_file ('test.nc', 'r')
> I'm not sure if anyone is actively maintaining scipy.io.netcdf (you'll
> find out if there is a response to your query). In case there isn't,
> you might have better luck with one of the following:
> http://code.google.com/p/netcdf4-python/
> http://matplotlib.sourceforge.net/basemap/doc/html/api/basemap_api.html#mpl_toolkits.basemap.NetCDFFile
> http://www.pyngl.ucar.edu/Nio.shtml
> http://pypi.python.org/pypi/pupynere/1.0
> Cheers,
> Scott
> _______________________________________________
> SciPy-user mailing list
> SciPy-user@scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
Hi all,
I'm quite new to python and I had many problems installing netcdf4-python.

I have installed netcdf, hdf5, szlib, zlib
And I try to install netcdf4-python with:
python setup.py install
running install
running build
running config_cc
unifing config_cc, config, build_clib, build_ext, build commands 
--compiler options
running config_fc
unifing config_fc, config, build_clib, build_ext, build commands 
--fcompiler options
running build_src
building py_modules sources
building extension "netCDF4" sources
running build_py
running build_ext
No module named msvccompiler in numpy.distutils; trying from distutils
error: Python was built with Visual Studio 2003;
extensions must be built with a compiler than can generate compatible 
Visual Studio 2003 was not found on this system. If you have Cygwin 
you can try compiling with MingW32, by passing "-c mingw32" to setup.py.

Anyway, I have installed pupynere (with the tar.gz)
With the egg Do I just have to run "easy-install pupinere.egg" ?
And when I tried to test it with this line:

|>>> from pupynere import NetCDFFile
>>> f = nc('example.nc', 'w')

It failed with:
NameError: name 'nc' is not defined
May be the documentation in http://dealmeida.net/2008/07/14/pupynere is old

But when I tried:
f = netcdf_file('test.nc', 'r')
print f.history
time = f.variables['time'][:]
lat = f.variables['lat'][:]

Everything works fine

Ifremer Centre de Brest
BP 70 - 29280 Plouzané
tél. 33 (0)2 98 22 40 94
email  Ludovic.Drouineau@ifremer.fr

More information about the SciPy-user mailing list