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

Home » Public Forums » archive » NetCDF Attribute Inquiry
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: NetCDF Attribute Inquiry [message #24317 is a reply to message #24243] Thu, 22 March 2001 07:09 Go to previous message
Liam E. Gumley is currently offline  Liam E. Gumley
Messages: 378
Registered: January 2000
Senior Member
Alex Schuster wrote:
>
> "Liam E. Gumley" wrote:
>
>> Alex Schuster wrote:
>
> [How to check for available attributes without using NCDF_ATTINQ(),
> which sometimes gives bad results]
>
>> Here is a function which returns a list of attribute names for a given
>> variable name. If the variable name is set to the null string '', a list
>> of global attribute names is returned.
>>
>> FUNCTION NCDF_ATTDIR, CDFID, VARNAME
> [...]
>
> Thanks! That's what I needed.
>
> As I also don't know for sure beforehand which variables are in the
> file, I modified your routine so it returns this info. I guess you also
> already have a NCDF_VARDIR() function, but here it is anyway:
>
> FUNCTION NCDF_VARDIR, CDFID
>
> ;- Check arguments
> if n_params() ne 1 then message, 'Usage: RESULT = NCDF_VARDIR(CDFID)'
> if n_elements(cdfid) eq 0 then message, 'CDFID is undefined'
>
> ;- Set default return value
> varnames = ''
>
> fileinfo = ncdf_inquire(cdfid)
> nvars = fileinfo.nvars
>
> ;- If variables were found, get attribute names
> if nvars gt 0 then begin
> varnames = strarr(nvars)
> for index = 0, nvars - 1 do $
> varnames[index] = (ncdf_varinq(cdfid,index)).name
> endif
>
> ;- Return the result
> return, varnames
>
> END

Alex, you just about read my mind. Here is my NCDF_VARDIR function:

FUNCTION NCDF_VARDIR, CDFID

;- Check arguments
if n_params() ne 1 then message, 'Usage: RESULT = NCDF_VARDIR(CDFID)'
if n_elements(cdfid) eq 0 then message, 'CDFID is undefined'

;- Set default return value
varnames = ''

;- Get file information
fileinfo = ncdf_inquire(cdfid)
nvars = fileinfo.nvars

;- If variables were found, get variable names
if nvars gt 0 then begin
varnames = strarr(nvars)
for index = 0, nvars - 1 do begin
varinfo = ncdf_varinq(cdfid, index)
varnames[index] = varinfo.name
endfor
endif

;- Return the result
return, varnames

END

Cheers,
Liam.
http://cimss.ssec.wisc.edu/~gumley
[Message index]
 
Read Message
Read Message
Previous Topic: Re: skips while reading tab delimited data
Next Topic: Re: Mac 32 bit color depth?

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

Current Time: Sat Oct 11 15:39:06 PDT 2025

Total time taken to generate the page: 1.28424 seconds