X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 21 Apr 2016 09:32 AM by  anon
HELP: Nested arrays
 2 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
21 Apr 2016 09:32 AM
    Hi, I'm brand new to IDL but I've been banging my head off this all day: I'm reading in a set of 55 structures from fits files and I'd like to consolidate them into a single structure that I can call without having to redo the read in every time. Unfortunately IDL's need to define everything prior to use has made it rather more difficult than other programs to do this. The code below is roughly what I would like to do. (Although obviously it doesn't work like this) for i=2,55 do begin Spiredata[1,i]=mrdfits('/home/path/to/file.fits',i) Spiredata[2,i]='textstring' endfor I notice that entries in a structure can be named so having the textstring as a name for the corresponding entry would be even better. Sorry if I've not explained it very well and thanks for any help. :)

    Deleted User



    Basic Member


    Posts:143
    Basic Member


    --
    21 Apr 2016 11:12 AM
    IDL has data structures called LIST and HASH. These data structures do not have to be predefined. and therefore may be useful to you. An example how they can be used is shown below: IDL> l = list() IDL> l.add, findgen(10) IDL> l.add, "hello" IDL> print, l 0.00000000 1.0000000 2.0000000 3.0000000 4.0000000 5.0000000 6.0000000 7.0000000 8.0000000 9.0000000 hello IDL> h = hash() IDL> h['key1']=findgen(10) IDL> h['key2']= 'Hello' IDL> h['key3']= lindgen(10) IDL> print, h key2: Hello key1: 0.00000000 1.0000000 2.0000000 3.0000000 4.0000000 ... key3: 0 1 2 3 4 5 ... David Starbuck Harris Geospatial Solutions

    Deleted User



    New Member


    Posts:
    New Member


    --
    22 Apr 2016 03:48 AM
    Thanks! That's a life-saver.
    You are not authorized to post a reply.