Structure Creation with Execute [message #3992] |
Tue, 11 April 1995 00:00  |
msreeve
Messages: 3 Registered: June 1994
|
Junior Member |
|
|
I am reading in an HDF file containing 30-40 Scientific Data Sets of
varying size and rank. The sizes are not known ahead of time.
I would like to read each data set into an element of an anonymous
structure and output that from the function. Currently I construct
a structure definition string by going through the HDF file and
collecting the dimensions of each SDS. I then execute it, to define
the structure (with tag names HDF0, HDF1, ...), and then make another
pass through the file to read the data into the structure.
This works well if there are only a few data sets in the file, but
if the structure definition string exceeds 131 characters (IDL's
ridiculously-low maximum for an EXECUTE), the EXECUTE fails.
Is there a way around this somehow? Is it possible to append one
structure to another (I thought not)? Any suggestions?
Mark Reeve, Ph.D.
msreeve@netcom.com OR mreeve@xti.com
|
|
|
Re: Structure Creation with Execute [message #4029 is a reply to message #3992] |
Wed, 19 April 1995 00:00   |
Greening C M
Messages: 5 Registered: April 1995
|
Junior Member |
|
|
Hi,
If I understand correctly what you are trying to do you may be
able to nest structures within structures to create a sort of
linked list. If you need to make modifications to list (inserting,
or deleting items then it get a bit more complicated.
Chris
greec@essex.ac.uk
; place a new structure onto the front of the list
FUNCTION My_struct, x, r
RETURN, {, data:x, rest:r}
END
; test the list
PRO Test
list = 0
; set up the list to contain a set of different length arrays
FOR i = 1, 11 DO BEGIN
; create some junk data to store in the list
j = indgen(i)
; add the data to the list
list = my_struct(j, list)
ENDFOR
; print the contents of the list
tmp = list
FOR i = 0, 10 DO BEGIN
print, tmp.data
tmp = tmp.rest
ENDFOR
END
|
|
|
|
Re: Structure creation [message #80534 is a reply to message #3992] |
Wed, 20 June 2012 09:11  |
Michael Galloy
Messages: 1114 Registered: April 2006
|
Senior Member |
|
|
On 6/20/12 8:06 AM, alx wrote:
> On 20 juin, 13:01, John Coxon<john.co...@gmail.com> wrote:
>>
>> I see, that would make sense. Is there any way to clear a structure, for
>> instance, between two runs of a program?
>
> If your structure has only numeric fields:
>
> for i=0,N_Tags(your_struct)-1 do your_struct.(i) = 0
This will clear the values, but the definition of avg1. You need to do a
.reset or restart IDL to do that.
Mike
--
Michael Galloy
www.michaelgalloy.com
Modern IDL: A Guide to IDL Programming (http://modernidl.idldev.com)
Research Mathematician
Tech-X Corporation
|
|
|
Re: Structure creation [message #80536 is a reply to message #3992] |
Wed, 20 June 2012 07:06  |
lecacheux.alain
Messages: 325 Registered: January 2008
|
Senior Member |
|
|
On 20 juin, 13:01, John Coxon <john.co...@gmail.com> wrote:
> On 20/06/2012 11:21, Carsten Lechte wrote:
>
>
>
>
>
>> On 20/06/12 12:07, John Coxon wrote:
>>> Hi there,
>
>>> Having an odd issue with creating structures.
>
>>> idl > med = {avg1, dawnR1:0.0, duskR1:0.0, dawnR2:0.0, duskR2:0.0}
>>> idl > print,med.dawnR1
>>> 0
>>> idl > help,med.dawnR1
>>> <Expression> INT = 0
>
>> I would guess that you previously defined a structure with name avg1
>> that had dawnR1 as an integer. dawnR1's type is determined by the
>> initialisiation value from the very first use of the structure. A naked
>> "40" or "0" is interpreted by IDL as an integer constant.
>
>> Either change to using unnamed structures, or be extra careful when
>> specifying values, e.g. always do 1.0 when you want float, 1d0 when you
>> want double, 40L for long etc.
>
> I see, that would make sense. Is there any way to clear a structure, for
> instance, between two runs of a program?
>
> --
> John Coxonhttp://www.chickensinenvelopes.net/
>
>
If your structure has only numeric fields:
for i=0,N_Tags(your_struct)-1 do your_struct.(i) = 0
alx.
|
|
|
Re: Structure creation [message #80537 is a reply to message #3992] |
Wed, 20 June 2012 04:01  |
John Coxon
Messages: 15 Registered: February 2012
|
Junior Member |
|
|
On 20/06/2012 11:21, Carsten Lechte wrote:
> On 20/06/12 12:07, John Coxon wrote:
>> Hi there,
>>
>> Having an odd issue with creating structures.
>>
>> idl > med = {avg1, dawnR1:0.0, duskR1:0.0, dawnR2:0.0, duskR2:0.0}
>> idl > print,med.dawnR1
>> 0
>> idl > help,med.dawnR1
>> <Expression> INT = 0
>
> I would guess that you previously defined a structure with name avg1
> that had dawnR1 as an integer. dawnR1's type is determined by the
> initialisiation value from the very first use of the structure. A naked
> "40" or "0" is interpreted by IDL as an integer constant.
>
> Either change to using unnamed structures, or be extra careful when
> specifying values, e.g. always do 1.0 when you want float, 1d0 when you
> want double, 40L for long etc.
I see, that would make sense. Is there any way to clear a structure, for
instance, between two runs of a program?
--
John Coxon
http://www.chickensinenvelopes.net/
|
|
|
Re: Structure creation [message #80538 is a reply to message #3992] |
Wed, 20 June 2012 03:21  |
Carsten Lechte
Messages: 124 Registered: August 2006
|
Senior Member |
|
|
On 20/06/12 12:07, John Coxon wrote:
> Hi there,
>
> Having an odd issue with creating structures.
>
> idl > med = {avg1, dawnR1:0.0, duskR1:0.0, dawnR2:0.0, duskR2:0.0}
> idl > print,med.dawnR1
> 0
> idl > help,med.dawnR1
> <Expression> INT = 0
I would guess that you previously defined a structure with name avg1
that had dawnR1 as an integer. dawnR1's type is determined by the
initialisiation value from the very first use of the structure. A
naked "40" or "0" is interpreted by IDL as an integer constant.
Either change to using unnamed structures, or be extra careful when
specifying values, e.g. always do 1.0 when you want float, 1d0 when
you want double, 40L for long etc.
chl
|
|
|