Re: indexing over structure tags [message #24871 is a reply to message #24812] |
Tue, 24 April 2001 00:45   |
R.Bauer
Messages: 1424 Registered: November 1998
|
Senior Member |
|
|
Randall Skelton wrote:
>
> Thanks Tom... I did think of that. However, in this particular case there
> is some merit in having the name of the structure be a useful and human
> readable tag. Nobody would be happy trying to remember yet another
> arbitrary numbering scheme for molecules when they'd rather just type the
> name ;) My suspicion is that there isn't an easy way to do what I want...
>
> Randall
>
Dear Randall,
I will show you an easy way, how to access any level of a structure
by incrementing of a an array.
may be we have a structure like
pi={name:'p.mustermann'}
global={pi:pi}
n2o={param:fltarr(10),short_name:'N2O',long_name:'mixing
ratio',units:'ppb',flag:'NONE'}
time={param:fltarr(10),short_name:'time',long_name:'time
[UT]',units:'seconds since 2000-01-01 00:00:00 UTC', flag:'NONE'}
icgs={!global:global,time:time,n2o:n2o}
more attribute of this data structure are explained by my publication.
http://www.fz-juelich.de/zb/text/publikation/juel3786.html
The following routine creates an array of tagnames and an
array of pointers of any submitted structure
The return value of this function is n_elements(names)
and the keywords names and ptr_values
n=struct2names_and_ptrs(icgs,names=names,ptr_values=ptr_valu es)
PRINT,n
IDL> 11
IDL> PRINT,names
!GLOBAL.PI.NAME TIME.PARAM TIME.SHORT_NAME TIME.LONG_NAME TIME.UNITS
TIME.FLAG
N2O.PARAM N2O.SHORT_NAME N2O.LONG_NAME N2O.UNITS N2O.FLAG
IDL> FOR I=0,n-1 do help,*(ptr_values[i])
<PtrHeapVar1> STRING = 'p.mustermann'
<PtrHeapVar2> FLOAT = Array[10]
<PtrHeapVar3> STRING = 'time'
<PtrHeapVar4> STRING = 'time [UT]'
<PtrHeapVar5> STRING = 'seconds since 2000-01-01 00:00:00 UTC'
<PtrHeapVar6> STRING = 'NONE'
<PtrHeapVar7> FLOAT = Array[10]
<PtrHeapVar8> STRING = 'N2O'
<PtrHeapVar9> STRING = 'mixing ratio'
<PtrHeapVar10> STRING = 'ppb'
<PtrHeapVar11> STRING = 'NONE'
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_source/idl_ html/dbase/download/struct2names_and_ptrs.tar.gz
This routine was written to use by add_tag, delete_tag, replace_tagvalue
and rename_tag
on each level of a structure with the following routine you are able to
build any structure defined from names and ptr_values.
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_source/idl_ html/dbase/download/names_and_ptrs2struct.tar.gz
For further routines and licensing please look at
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.h tml
Is this the solution of your problem?
Reimar
--
Reimar Bauer
Institut fuer Stratosphaerische Chemie (ICG-1)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
http://www.fz-juelich.de/icg/icg1/
=============================================
a IDL library at ForschungsZentrum J�lich
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.h tml
http://www.fz-juelich.de/zb/text/publikation/juel3786.html
|
|
|