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

Home » Public Forums » archive » basic array-structure understanding 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: basic array-structure understanding question [message #63799 is a reply to message #63682] Wed, 19 November 2008 07:10 Go to previous messageGo to previous message
Kenneth P. Bowman is currently offline  Kenneth P. Bowman
Messages: 585
Registered: May 2000
Senior Member
In article
<68a3f7b5-1c15-4dbb-bf83-b019eb7dd204@g17g2000prg.googlegroups.com>,
julia.walterspiel@gmail.com wrote:

> hi everybody
>
> This is what does not get into my head:
>
> I have one array containing my data.
> I have a second array containing the times when the data was
> collected.
> They have the same lenght.
>
> I put them into one structure because we all like structures and I
> learned about their advantages.
>
> now:
>
> IN SHORT are those arrays linked somehow? in other words: when working
> with a structure, does IDL know which value matches the corresponding
> date, given the data and the date array have the same length. Are
> those arrays somehow connected or are they completely independent from
> each other?
>
>
> IN LONG: if I want to get e.g. all the data from all Januarys from
> 2000 to 2007, can I do it somehow like
>
> all_jan = structure.data (where(structure.time EQ 200?01??????) )..
> then it would automatically "select" only the right values. (and then
> I would have to make a separate array of the corresponding dates, make
> those two new arrays a structure so that I can plot data vs. date all
> in one?)
>
> or do I have to do it via some indexing, like:
> all_jan = where (structure.time EQ 200?01??????) )
>
> and then apply the index to my array of data?
>
>
> jeez, i'm real slow on the uptake here.. sorry for bothering you with
> such simple questions, but can anybody help me undo this big knot in
> my brain?
> cheers,
> juls

An IDL structure is just a container, into which you can put a
collection of (related) variables. Then you can pass the
structure around, instead of having to pass all of the variables
individually.

IDL> x = findgen(10)^3
IDL> i = lindgen(10)
IDL> str = {x:x, i:i}
IDL> help, str, /str
** Structure <1db1314>, 2 tags, length=80, data length=80, refs=1:
X FLOAT Array[10]
I LONG Array[10]
IDL> help, str.x
<Expression> FLOAT = Array[10]
IDL> help, str.i
<Expression> LONG = Array[10]
IDL> plot, str.i, str.x
IDL> even = where((str.i MOD 2) eq 0) ;Find even indices
IDL> print, even
0 2 4 6 8
IDL> oplot, str.i[even], str.x[even], psym = -1 ;Plot even indices only


Ken Bowman
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Too Many Posts
Next Topic: Re: A Simple IDL Manifesto

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

Current Time: Fri Oct 10 01:35:34 PDT 2025

Total time taken to generate the page: 0.39695 seconds