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

Home » Public Forums » archive » Re: creating a variable from unknow name
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: creating a variable from unknow name [message #42101] Sun, 02 January 2005 17:21
war is currently offline  war
Messages: 21
Registered: December 2003
Junior Member
Thanks to all who have replied to my question. All the suggestions just
helped me in what I want to do.

Regards,

Andry
Re: creating a variable from unknow name [message #42108 is a reply to message #42101] Thu, 30 December 2004 05:32 Go to previous message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
Andry William wrote:

> Dear IDL user,
>
> I would to ask some advice on how I can create a variable with the name
> defined by some value in the memory. I mean: in unix/linux CSH, one can
> say
>
> set a = b1
> set $a = 4
> so that the value stored in the variable name b1 is 4
> echo $b1 (returns)
> 4
>
> I would like to be able to do the same in IDL. I first have to check which
> variable is present in a file (atcually they are NetCDF files), then
> assign the values to the name defined in the file.
>
> Something like if I see that the variable "lon" exists in a file, then
> assign its values to the name "lon".
>
> I am not sure if I need some pointer or object for that.
>
> Thanks in advance for your help.
>
> Best wishes for the new year for all of you.
>
> Andry

Dear Andry

probaly you could use our read_ncdf routine. The structure you got returned
looks similar to this one.

The short_name is the real netcdf name because the tagname has it's own
rules. Only characters which are able to use for variables could be used as
tagnames.

This data structure is used for several routines of the icg idl library.

; EXAMPLE:
; result=read_ncdf('ghost.nc')
; help,result,/str
; ** Structure <10b5508>, 7 tags, length=3072, refs=1:
; !FILENAME STRING 'ghost.nc'
; !GLOBAL STRUCT -> <Anonymous> Array[1]
; TIME STRUCT -> <Anonymous> Array[1]
; N2O STRUCT -> <Anonymous> Array[1]
; F12 STRUCT -> <Anonymous> Array[1]
;
;
; result=read_ncdf('ghost.nc','F12')
; ** Structure <10b25d4>, 6 tags, length=2256, refs=1:
; !FILENAME STRING 'ghost.nc'
; !GLOBAL STRUCT -> <Anonymous> Array[1]
; TIME STRUCT -> <Anonymous> Array[1]
; F12 STRUCT -> <Anonymous> Array[1]
;
; help,result.global,/str
; ** Structure <10b31b0>, 6 tags, length=268, refs=2:
; GPARAM STRUCT -> <Anonymous> Array[1]
; HISTORY STRING Array[1]
; PI STRUCT -> <Anonymous> Array[1]
; DATASET STRUCT -> <Anonymous> Array[1]
; PLATFORM STRUCT -> <Anonymous> Array[1]
; EXP STRUCT -> <Anonymous> Array[1]
;
; help,result.f12,/str
; ** Structure <10aa984>, 20 tags, length=808, refs=2:
; STATUS STRUCT -> <Anonymous> Array[1]
; SHORT_NAME STRING 'F12'
; FLAG STRING 'NONE'
; SAMPLE_INTERVAL FLOAT 0.000000
; ADD_OFFSET FLOAT 0.000000
; SCALE_FACTOR FLOAT 1.00000
; UNITS STRING 'pptv'
; FORTRAN_FORMAT STRING 'F6.2'
; LONG_NAME STRING 'CF!I2!NCl!I2!N'
; DE_LONG_NAME STRING 'CF!I2!NCl!I2!N'
; DESCRIPTION STRING 'Data Retrieval via smoothed chromatogram
(Gol'.
..
; DE_DESCRIPTION STRING 'DE_DESCRIPTION= Auswertung per geglᅵttetem
Ch'.
..
; FILL_VALUE FLOAT 999.900
; STDEV_REL DOUBLE 0.0065000000
; PARAM FLOAT Array[87]
; PLOT_MIN FLOAT 460.600
; PLOT_MAX FLOAT 541.000
; VALID LONG Array[84]
; FILLED LONG Array[3]



At the moment the server is down. If it is restarted then you could get it
from here

http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_lib_intro. html


cheers

Reimar

--
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
http://www.fz-juelich.de/icg/icg-i/
============================================================ ======
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_lib_intro. html
Re: creating a variable from unknow name [message #42109 is a reply to message #42108] Wed, 29 December 2004 19:43 Go to previous message
KM is currently offline  KM
Messages: 29
Registered: October 2004
Junior Member
On Wed, 29 Dec 2004, Andry William wrote:
> I would to ask some advice on how I can create a variable with the
> name defined by some value in the memory.
>
> I would like to be able to do the same in IDL. I first have to
> check which variable is present in a file (atcually they are
> NetCDF files), then assign the values to the name defined in the
> file.
>
> Something like if I see that the variable "lon" exists in a file,
> then assign its values to the name "lon".
>
> I am not sure if I need some pointer or object for that.

I think you could do it using a pointer (that is how the read_netcdf
procedure does it I tihnk). I don't think you need objects.

But I would do it without pointers like this:

r = EXECUTE( "a=2" )
help, a

Does this do what you want?

-k.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Unknown data type
Next Topic: Re: GUI builder limitations?

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

Current Time: Sat Oct 11 07:10:50 PDT 2025

Total time taken to generate the page: 0.87955 seconds