netcdF4 variables

S

Sudheer Joseph

Dear members,
I have been using python NetcdF for some time. I understand that we can get variables from a netcdf one by one by using
temp=ncf.variable['temp'][:]
but is there a way to get a list of variables with out the rest of the stuff as seen below?
some hing like a list
xx=nc,variables[:]
should get me all variable names with out other surrounding stuff??
with best regards.
Sudheer

In [4]: ncf.variables
Out[4]: OrderedDict([(u'LON', <netCDF4.Variable object at 0x254aad0>), (u'LAT', <netCDF4.Variable object at 0x254ab50>), (u'DEPTH1_1', <netCDF4.Variable object at 0x254abd0>), (u'TAX', <netCDF4.Variable object at 0x254ac50>),(u'DIF_FD1', <netCDF4.Variable object at 0x254acd0>), (u'DIF_FD2', <netCDF4.Variable object at 0x254ad50>), (u'DIF_FD3', <netCDF4.Variable object at 0x254add0>), (u'DIF_FD4', <netCDF4.Variable object at 0x254ae50>), (u'DIF_FD5', <netCDF4.Variable object at 0x254aed0>), (u'DEPTH', <netCDF4.Variable object at 0x254af50>), (u'DEPTH_bnds', <netCDF4.Variable object at 0x261b050>), (u'TIME', <netCDF4.Variable object at 0x261b0d0>), (u'TEMP_BIAS', <netCDF4.Variable object at 0x261b150>)])
 
A

Andreas Perstinger

some hing like a list
xx=nc,variables[:]
should get me all variable names with out other surrounding stuff??

In [4]: ncf.variables
Out[4]: OrderedDict([(u'LON', <netCDF4.Variable object at 0x254aad0>),
[SNIP]

It looks like "variables" is an OrderedDict. Thus

should return a view (or list, depending on your python version) of all
keys, i.e. all variable names.

Bye, Andreas
 
S

Sudheer Joseph

Thank you very much it works for me.
with best regards,
Sudheer
some hing like a list
xx=nc,variables[:]

should get me all variable names with out other surrounding stuff??
In [4]: ncf.variables
Out[4]: OrderedDict([(u'LON', <netCDF4.Variable object at 0x254aad0>),

[SNIP]



It looks like "variables" is an OrderedDict. Thus





should return a view (or list, depending on your python version) of all

keys, i.e. all variable names.



Bye, Andreas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top