[Numpy-discussion] Reading a big netcdf file
Gökhan Sever
gokhansever at gmail.com
Wed Aug 3 17:02:28 EDT 2011
I think these answer your questions.
In [3]: type f.variables['reflectivity']
------> type(f.variables['reflectivity'])
Out[3]: <type 'netCDF4.Variable'>
In [4]: type f.variables['reflectivity'][:]
------> type(f.variables['reflectivity'][:])
Out[4]: <type 'numpy.ndarray'>
In [5]: z = f.variables['reflectivity'][:]
In [6]: type z
------> type(z)
Out[6]: <type 'numpy.ndarray'>
In [10]: id f.variables['reflectivity'][:]
-------> id(f.variables['reflectivity'][:])
Out[10]: 37895488
In [11]: id z
-------> id(z)
Out[11]: 37901440
On Wed, Aug 3, 2011 at 12:40 PM, Christopher Barker
<Chris.Barker at noaa.gov>wrote:
> On 8/3/11 9:46 AM, Gökhan Sever wrote:
> > In [23]: from netCDF4 import Dataset
> >
> > In [24]: f = Dataset("test.nc <http://test.nc>")
> >
> > In [25]: f.variables['reflectivity'].shape
> > Out[25]: (6, 18909, 506)
> >
> > In [26]: f.variables['reflectivity'].size
> > Out[26]: 57407724
> >
> > In [27]: f.variables['reflectivity'][:].dtype
> > Out[27]: dtype('float32')
> >
> > In [28]: timeit z = f.variables['reflectivity'][:]
> > 1 loops, best of 3: 731 ms per loop
>
> that seems pretty fast, actually -- are you sure that [:] forces the
> full data read? It probably does, but I'm not totally sure.
>
> is "z" a numpy array object at that point?
>
> -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 at noaa.gov
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
--
Gökhan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20110803/9a0eee48/attachment.html>
More information about the NumPy-Discussion
mailing list