comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » HASH question
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: HASH question [message #75456 is a reply to message #75367] Mon, 07 March 2011 12:32 Go to previous messageGo to previous message
pgrigis is currently offline  pgrigis
Messages: 436
Registered: September 2007
Senior Member
On Mar 5, 8:41 am, Gray <grayliketheco...@gmail.com> wrote:
> Hi all,
>
> I have a bunch of information which I'd like to store in an organized
> fashion:
> ~IDs of some stars
> ~Stellar types
> ~Magnitudes and fluxes in different images
>
> One way I could store the information would be as an array of
> structures, with each element being a single star, but I don't a
> priori know how many stars I have, and to find a particular star I'd
> have to search on the ID element.  So, I could use a HASH of
> structures so I could index by ID, which would be ideal, but then
> assigning values to the individual tags of the structures is much more
> complicated. I could instead have a bunch of hashes, one for each type
> of information, but that would get pretty unwieldy.
>
> So, IDL gurus, anyone have a suggestion for how to organize this most
> efficiently and elegantly?  Thanks!
>
> --Gray


Well since I don;t have IDL 8.0 yet. I can't really comment
on the hashes method, but what's wrong with an array of structures?

allstars=replicate({starID:'',spectralType:'',magnitude:0.0} ,
100)
allstars[0].starID='Sirius' & allstars[0].spectralType='A1' &
allstars[0].magnitude=-1.46
allstars[1].starID='Delta Pavonis' & allstars[1].spectralType='G8' &
allstars[1].magnitude=3.56
etc.


Single stars can easily be located with where:

ind=where(allstars.starID EQ 'Delta Pavonis',count)
if count EQ 1 then print,'The magnitude of '+allstars[ind].starID+' is
'+strtrim(allstars[ind].magnitude,2)

Ciao,
Paolo
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: IDL 8.0 image() scaling
Next Topic: Floating illegal operand error when reach end of for loop

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 16:03:35 PDT 2025

Total time taken to generate the page: 0.00193 seconds