Re: on reading NCDF files [message #37669] |
Tue, 20 January 2004 05:57 |
R.Bauer
Messages: 1424 Registered: November 1998
|
Senior Member |
|
|
Sangwoo wrote:
> Hi everyone!
>
> I'm gonna read a NCDF file. It may contain several variables within
> itself. When I extract a variable named "image", the procedure is as
> follows:
>
> cid=ncdf_open('test.nc')
> vid=ncdf_varid(cid,'image')
> ncdf_varget,cid,vid,image
>
> But suppose I don't know the name of each variable unfortunately. Is
> there any way to figure out the details of the included
> variables(name, dimension, etc.)? The second command fails when I put
> a wrong variable. And is there any way to read the included variables
> all at once? (something like /all keyword)
>
> I wonder if there's any way to figure out all details of the included
> variables from an NCDF file directly.
Dear Sangwoo
you could try our read_ncdf function.
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_source/idl _html/dbase/read_ncdf_dbase.pro.html
This routine reads all international defined attributes and some more.
The attributes has to be defined in a definition routine, e.g. def_icg.
A different diffinition could be given with a keyword: def_struct
you could call it this way
x=read_ncdf(file) reads everything of parameters
x=read_ncdf(file,[var1,var2]) var1 ... short_name of parameter,
all coordination parameters are readed too
x=read_ncdf(file, /raw,/as_pointer) result is a structure all values are
pointer, no valid index vectors are creaeted no scale_factor no
add_offset is used.
x=read_ncdf(file,/status) additional info about definition of varibales
is added
There are more keywords available. And there are lots of routines for
the ICG-DATA-STRUCTURE in our libray at
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_lib_intro. html
regards
Reimar
|
|
|
Re: on reading NCDF files [message #37672 is a reply to message #37669] |
Tue, 20 January 2004 01:35  |
Chris Lee
Messages: 101 Registered: August 2003
|
Senior Member |
|
|
In article <3ee6ff80.0401192300.534dc5b1@posting.google.com>, "Sangwoo"
<leesw@astro.snu.ac.kr> wrote:
> Hi everyone!<snip>...
> I wonder if there's any way to figure out
> all details of the included variables from an NCDF file directly.
NetCDF wouldn't be terribly useful if you needed to know what was in
there before using it :)
result=ncdf_inquire(cdfid)
; result is a struct containing the number of variables, dimensions and
attributes
var=ncdf_varinq(cdfid, varid)
;where 0 <= varid < result.nvars
;var is a struct containing the variable name, datatype, dimensions, etc.
ncdf_varget, cdfid, varid, data
;gets the data, as ever.
There's also NCDF_DIMINQ which does similar things for the dimensions in
the file.
Chris.
|
|
|