comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » how to list variable names from netCDF file?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
how to list variable names from netCDF file? [message #5351] Thu, 07 December 1995 00:00
f055 is currently offline  f055
Messages: 29
Registered: April 1995
Junior Member
Can anyone help me with the following problem?

I am trying to write some IDL code to read in a number of netCDF files, without
knowing in advance the names of the variables in the file. Is there a routine
which can return the variable name of the Nth variable in the file?

Once open, I can use ncdf_inquire to find the number of variables, but
ncdf_varinq says it can only return the name of a variable if you give it
the variable's id, which can be got from calling ncdf_varid. But ncdf_varid
requires the variables name! What I need is an equivalent of ncdf_attname,
which returns the name of the Nth attribute.

What's the solution?


......................... Dr Tim Osborn . t.osborn@uea.ac.uk
.... ___/.. __ /.. /.. /. Senior Research Associate . phone:01603 592089
... /..... /. /.. /.. /.. Climatic Research Unit . fax: 01603 507784
.. /..... __/.. /.. /... School of Environmental Sciences.
. /..... /\ ... /.. /.... University of East Anglia .
____/.._/..\_..____/..... Norwich NR4 7TJ .
......................... UK .
Re: how to list variable names from netCDF file? [message #5498 is a reply to message #5351] Thu, 07 December 1995 00:00 Go to previous message
Andy Loughe is currently offline  Andy Loughe
Messages: 174
Registered: November 1995
Senior Member
T.Osborn wrote:
>
> Can anyone help me with the following problem?
>
> I am trying to write some IDL code to read in a number of netCDF files, without
> knowing in advance the names of the variables in the file. Is there a routine
> which can return the variable name of the Nth variable in the file?
>
> Once open, I can use ncdf_inquire to find the number of variables, but
> ncdf_varinq says it can only return the name of a variable if you give it
> the variable's id, which can be got from calling ncdf_varid. But ncdf_varid
> requires the variables name! What I need is an equivalent of ncdf_attname,
> which returns the name of the Nth attribute.
>

Maybe the documentation is causing you trouble (imagine that!).
Here is a small example...

file = '/Datasets/nmc/uwnd.79.nc'
ncid = NCDF_OPEN( file )
result = NCDF_INQUIRE( ncid )
num_vars = result.NVARS
for i = 0, num_vars-1 do print, ncdf_varinq(ncid,i)

--------
Andrew F. Loughe (afl@cdc.noaa.gov)
University of Colorado, CIRES * Campus Box 449 * Boulder, CO 80309
phone: (303) 492-0707 fax: (303) 497-7013
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Saving animation images
Next Topic: Re: mbar and event handlers

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 05:19:12 PDT 2025

Total time taken to generate the page: 1.04093 seconds