[SciPy-User] about opening netcdf file

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[SciPy-User] about opening netcdf file

lily li
Hi scipy users,

I want to ask that how to open a NetCDF file? I tried to import netCDF4, but it says no such module. So which module or package to install beforehand? Thanks very much.

_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

Re: about opening netcdf file

Oleksandr Huziy
You need to install netCDF4:


pip install netCDF4


You will have to install netcdf and hdf separately. On ubuntu those are installed using apt-get. And if you do not have pip yet you will also need to install it.



2014-05-21 14:28 GMT-04:00 lily li <[hidden email]>:
Hi scipy users,

I want to ask that how to open a NetCDF file? I tried to import netCDF4, but it says no such module. So which module or package to install beforehand? Thanks very much.

_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user




--
Sasha

_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

Re: about opening netcdf file

lily li
How to do in python in windows? I'm not working on ubuntu. Thanks again.


On Wed, May 21, 2014 at 12:31 PM, Oleksandr Huziy <[hidden email]> wrote:
You need to install netCDF4:


pip install netCDF4


You will have to install netcdf and hdf separately. On ubuntu those are installed using apt-get. And if you do not have pip yet you will also need to install it.



2014-05-21 14:28 GMT-04:00 lily li <[hidden email]>:
Hi scipy users,

I want to ask that how to open a NetCDF file? I tried to import netCDF4, but it says no such module. So which module or package to install beforehand? Thanks very much.

_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user




--
Sasha

_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user



_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

Re: about opening netcdf file

Oleksandr Huziy
Never done it for windows but suppose it is easier:


select the version you need download and double click
http://www.lfd.uci.edu/~gohlke/pythonlibs/#netcdf4


Cheers


2014-05-21 14:32 GMT-04:00 lily li <[hidden email]>:
How to do in python in windows? I'm not working on ubuntu. Thanks again.


On Wed, May 21, 2014 at 12:31 PM, Oleksandr Huziy <[hidden email]> wrote:
You need to install netCDF4:


pip install netCDF4


You will have to install netcdf and hdf separately. On ubuntu those are installed using apt-get. And if you do not have pip yet you will also need to install it.



2014-05-21 14:28 GMT-04:00 lily li <[hidden email]>:
Hi scipy users,

I want to ask that how to open a NetCDF file? I tried to import netCDF4, but it says no such module. So which module or package to install beforehand? Thanks very much.

_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user




--
Sasha

_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user



_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user




--
Sasha

_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

Re: [SciPy-User] about opening netcdf file

mdekauwe
In reply to this post by lily li
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
Reply | Threaded
Open this post in threaded view
|

Re: about opening netcdf file

Gary Ruben
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 <[hidden email]> 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
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user


_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user