[SciPy-User] about opening netcdf file

gary ruben gary.ruben at gmail.com
Thu May 29 02:19:30 EDT 2014


In my experience pupynere is faster than netcdf4. pupynere is also the
basis of the netcdf reader that is available in scipy, e.g.:

from scipy.io import netcdf_file

f = netcdf_file(path, 'r')
array_data = f.variables['array_data']

f.close()

I haven't checked recently, but from memory I think it doesn't support
contexts, so opening the file using "with open as f" doesn't work; you have
to open and close it explicitly as shown.

Gary



On 29 May 2014 00:45, mdekauwe <mdekauwe at gmail.com> wrote:

> Personally I use the https://code.google.com/p/netcdf4-python/
>
> I think at some point when I tested it was considerably quicker, but no
> idea
> if this is really true. Anyway...
>
> import netCDF4 as nc
>
> f = nc.Dataset(fname, 'r')
>
> # Extract data from NetCDF file
> lats = f.variables['latitude'][:]  # extract/copy the data
> lons = f.variables['longitude'][:]
> time = nc.num2date(f.variables['time'][:], f.variables['time'].units)
>
> temp = f.variables['Tair']
>
> HTH,
>
> Martin
>
>
>
> --
> View this message in context:
> http://scipy-user.10969.n7.nabble.com/SciPy-User-about-opening-netcdf-file-tp19445p19455.html
> Sent from the Scipy-User mailing list archive at Nabble.com.
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20140529/7515c1f5/attachment.html>


More information about the SciPy-User mailing list