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

Home » Public Forums » archive » Re: How to check if a file is indeed a NetCDF file?
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: How to check if a file is indeed a NetCDF file? [message #15032] Mon, 19 April 1999 00:00 Go to previous message
Liam Gumley is currently offline  Liam Gumley
Messages: 473
Registered: November 1994
Senior Member
Paul van Delst wrote:
> In trying to read NetCDF data files in IDL, I've discovered that the
> NCDF_OPEN crashes on me if the file I ask it to open is not a nCDF file.
> It crashes somewhat gracefully in that it tells me that NCDF_OPEN
> couldn't open the file and the error # is 19. Does anyone out there know
> how to use the IDL NCDF library to determine whether or not a file is in
> NetCDF format? The fact that the most obvious solution (i.e. NCDF_OPEN
> *returns* an error # rather than falling in a heap) doesn't work like I
> would expect doesn't make me too hopeful.

How about this (styled along the lines of HDF_ISHDF)?

FUNCTION NCDF_ISNCDF, FILENAME

;- Set return values

false = 0B
true = 1B

;- Establish error handler

catch, error_status
if error_status ne 0 then begin
catch, /cancel
return, false
endif

;- Try opening the file

cdfid = ncdf_open( filename )

;- If we get this far, open must have worked

ncdf_close, cdfid
catch, /cancel
return, true

END

Then it's just a matter of:

if not ncdf_isncdf( filename ) then begin
help, filename
message, 'FILENAME is not in NetCDF format'
endif
cdfid = ncdf_open( filename )

Cheers,
Liam.

---
Liam E. Gumley
Space Science and Engineering Center, UW-Madison
http://cimss.ssec.wisc.edu/~gumley
[Message index]
 
Read Message
Read Message
Previous Topic: Re: Help: Retrieve the state of radio button
Next Topic: How to check if a file is indeed a NetCDF file?

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

Current Time: Sat Oct 11 08:02:53 PDT 2025

Total time taken to generate the page: 1.04154 seconds