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

Home » Public Forums » archive » how to search if a variable exists in a 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 search if a variable exists in a file [message #92003 is a reply to message #92002] Mon, 28 September 2015 16:25 Go to previous messageGo to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Xiaohua Pan writes:

> I am dealing with a set of stations which unfortunately contain
different variables (netcdf formate). For example, Some stations have
the variables, say 'temperature' and 'pressure', while some stations
only have 'temperature'. When I read data with DO loop the stations, I
would like to search the variable first, so I can skip those variables
not existing to avoid the crash of program. I found a function of
file_search(), but can't find a similar function for a variable. Is
there anyone know how to do it? Thanks.
>
> DO i_station = 0, n-1 do begin
> DO i_var = 0, 1 do begin
> ; How to skip the variable if it doesn't exit ????
> ENDFOR
> ENDFOR

If you were to use the netCDF programs in the Coyote Library to work
with your netCDF files, you could use the method HasVar to tell you if a
file contains a variable with a particular name:

http://www.idlcoyote.com/fileio_tips/ncdf_browser.html

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: PLOT and LEGEND Function Graphic
Next Topic: Job Posting: Computer Research Specialist / Research Software Engineer / University of Florida

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

Current Time: Wed Oct 08 18:56:43 PDT 2025

Total time taken to generate the page: 0.00420 seconds