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

Home » Public Forums » archive » Re: Retrieving variables from a subroutine
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
Re: Retrieving variables from a subroutine [message #52612] Wed, 21 February 2007 05:48
Andy Heaps is currently offline  Andy Heaps
Messages: 22
Registered: March 2006
Junior Member
Two votes for using structures wins the day. I'm sure the students
will be able to cope!

Cheers
Andy
Re: Retrieving variables from a subroutine [message #52615 is a reply to message #52612] Tue, 20 February 2007 08:51 Go to previous message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
Andy Heaps wrote:
>
> I've written some IDL code to retrieve all the variables from a NetCDF
> file. This takes the form of:
> ncopen, 'file.nc'
> @ncread
>
> where the ncopen routine opens up the NetCDF file and writes all the
> variable information into a set of system strings in a !variable. The
> batch file statement @ncread then accesses these strings to read the
> data so all the variables are available from within the calling routine.
>
> This process is the only way I could think of to get the variables to
> appear in the calling procedure without having the NetCDF code directly
> in the user's program. Although this works, I cannot help thinking this
> is not the most elegant way of doing the job. I'd certainly like to
> just have one command to do the job, rather than two, if at all possible.
>
> As this program is for the use of undergrad students I don't want to use
> structures as they'll think IDL is very complicated and we all know that
> that isn't the case ;-) One of the ideas I had was to somehow get the
> returning ncopen procedure to call @ncread but I cannot think of a way
> to do that.
>
> Does anyone know of any IDL magic that could be used to have a single
> procedural (or other) call, and then somehow end up with the NetCDF
> variables extracted back in the the calling procedure?

I have a function to read netcdf files. See:

http://tinyurl.com/3apa9f

cheers,

paulv

--
Paul van Delst Ride lots.
CIMSS @ NOAA/NCEP/EMC Eddy Merckx
Re: Retrieving variables from a subroutine [message #52629 is a reply to message #52615] Mon, 19 February 2007 07:22 Go to previous message
Kenneth P. Bowman is currently offline  Kenneth P. Bowman
Messages: 585
Registered: May 2000
Senior Member
In article <ercbpk$res$1@south.jnrs.ja.net>,
Andy Heaps <a.j.heaps@reading.ac.uk> wrote:

> Does anyone know of any IDL magic that could be used to have a single
> procedural (or other) call, and then somehow end up with the NetCDF
> variables extracted back in the the calling procedure?

I think structures really are the best way to do this. I generally
use a function rather than a procedure, so it is called like this

data = READ_SAT_DAT(input)

where input is a file name or date, depending on the application.

READ_SAT_DATA packages all of the info from the file into an
anonymous structure.

It is not too difficult to get undergrads to understand, for example,
that

data.longitude

contains the longitudes of the satellite fields of view,

data.values

contains the radiances or retrieved quantities, etc.

The structure makes it easy to include the data and all of the
ancillary information (units, long names, etc.) in a single package.

Ken Bowman
Re: Retrieving variables from a subroutine [message #52631 is a reply to message #52629] Mon, 19 February 2007 07:23 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Andy Heaps writes:

> Does anyone know of any IDL magic that could be used to have a single
> procedural (or other) call, and then somehow end up with the NetCDF
> variables extracted back in the the calling procedure?

Well, SCOPE_VARFETCH is always magic if you can figure
out the crappy documentation. :-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: import vrml in idl
Next Topic: Re: import vrml in idl

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

Current Time: Wed Oct 08 19:53:36 PDT 2025

Total time taken to generate the page: 0.00603 seconds