|
|
Re: Structure reforming [message #31053 is a reply to message #31050] |
Tue, 04 June 2002 07:51  |
R.Bauer
Messages: 1424 Registered: November 1998
|
Senior Member |
|
|
Ivan Valtchanov wrote:
>
> Hi all,
>
> I have an IDL structure variable like this:
>
> help, ccc
> CCC STRUCT = -> <Anonymous> Array[1]
>
> help, ccc, /struct
> NAME STRING Array[133]
> RA DOUBLE Array[133]
>
> and I would like to reform it like this
> help,ccc
> CCC STRUCT = -> <Anonymous> Array[133]
> help,ccc,/struct
> NAME STRING g01
> RA DOUBLE 316.022
>
> Is there any fast way to do it?
>
> Thanks a lot.
>
> Ivan
You can use my reform_struct.
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_source/idl _html/dbase/download/reform_struct.tar.gz
regards
Reimar
; NAME:
; reform_struct
;
; PURPOSE:
; This function is used to reform a structure as tag array or struct
array
;
; CATEGORY:
; PROG_TOOLS/STRUCTURES
;
; CALLING SEQUENCE:
;
result=reform_struct(structure,dim1,[dim2],[dim3],[dim4],[di m5],[dim6],[dim7],[dim8],[/struct_array],[/tag_array]
;
; INPUTS:
; structure: a structures
; dim1: the new dimension of the input structure (1D to 8D)
;
; OPTIONAL INPUTS:
; dim2 to dim8: additional dimensions if not declared in dim1
;
; KEYWORD PARAMETERS:
; struct_array: if is set output structure is an array
; tag_array: if is set output structure is 1D and tags are arrays
; You have to set one of these keywords
;
; EXAMPLE:
; data=create_struct('A',FINDGEN(15),'B',SIN(FINDGEN(15)))
; result=reform_struct(data,15,/struct_array)
; HELP,result
; RESULT STRUCT = -> <Anonymous> Array[15]
--
Reimar Bauer
Institut fuer Stratosphaerische Chemie (ICG-I)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
------------------------------------------------------------ -------
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.h tml
============================================================ =======
|
|
|
Re: Structure reforming [message #31057 is a reply to message #31053] |
Tue, 04 June 2002 04:45  |
Jaco van Gorkom
Messages: 97 Registered: November 2000
|
Member |
|
|
"Ivan Valtchanov" <ivanv@discovery.saclay.cea.fr> wrote in message
news:20020604114425.31eda9c4.ivanv@discovery.saclay.cea.fr.. .
> On Tue, 4 Jun 2002 11:30:14 +0200
> "Jaco van Gorkom" <j.c.van.gorkom@fz-juelich.de> wrote:
>> how about:
>> ddd = replicate({name:'', ra:0.d}, 133)
>> ddd.name = ccc.name
>> ddd.ra = ccc.ra
>
> That's the way I am doing it now. But I have some 50-60 tags and they
> are sometimes different from structure to structure...
In that case you might want to create a single-element structure d at
the time you create the ccc array structure. Then you could do
something like
ddd = replicate(d, 133)
for i=0L, n_tags(ccc)-1 do ddd.(i) = ccc.(i)
Alternatively, create the single-element structure d from ccc in a
FOR-loop using TAG_NAMES() and repeated structure concatenation by
CREATE_STRUCT(). Or create the d structure in an EXECUTE() call.
Jaco
|
|
|
Re: Structure reforming [message #31058 is a reply to message #31057] |
Tue, 04 June 2002 02:44  |
Ivan Valtchanov
Messages: 8 Registered: April 2002
|
Junior Member |
|
|
On Tue, 4 Jun 2002 11:30:14 +0200
"Jaco van Gorkom" <j.c.van.gorkom@fz-juelich.de> wrote:
> how about:
> ddd = replicate({name:'', ra:0.d}, 133)
> ddd.name = ccc.name
> ddd.ra = ccc.ra
>
> cheers,
> Jaco
Thanks Jaco,
That's the way I am doing it now. But I have some 50-60 tags and they
are sometimes different from structure to structure...
B+,
Ivan
|
|
|
Re: Structure reforming [message #31059 is a reply to message #31058] |
Tue, 04 June 2002 02:30  |
Jaco van Gorkom
Messages: 97 Registered: November 2000
|
Member |
|
|
"Ivan Valtchanov" <ivanv@discovery.saclay.cea.fr> wrote in message
news:20020604105617.671832ff.ivanv@discovery.saclay.cea.fr.. .
> I have an IDL structure variable like this:
> help, ccc
> CCC STRUCT = -> <Anonymous> Array[1]
> help, ccc, /struct
> NAME STRING Array[133]
> RA DOUBLE Array[133]
>
> and I would like to reform it like this
> help,ccc
> CCC STRUCT = -> <Anonymous> Array[133]
> help,ccc,/struct
> NAME STRING g01
> RA DOUBLE 316.022
>
> Is there any fast way to do it?
how about:
ddd = replicate({name:'', ra:0.d}, 133)
ddd.name = ccc.name
ddd.ra = ccc.ra
cheers,
Jaco
|
|
|