[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: indexing over structure tags
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_values)
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.html
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.html
http://www.fz-juelich.de/zb/text/publikation/juel3786.html