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

Home » Public Forums » archive » Structure of arrays or arrays of structures?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Structure of arrays or arrays of structures? [message #64848] Thu, 22 January 2009 12:52
Brian Larsen is currently offline  Brian Larsen
Messages: 270
Registered: June 2006
Senior Member
All,

this may be philosophy but I have fought with both today and I am
wondering if there are pros and cons to the different
implementations.

My example is that when I read in text files I build a structure of
arrays:
IDL> help, data
DATA STRUCT = -> <Anonymous> Array[1]
IDL> help, data, /str
** Structure <1a07a08>, 5 tags, length=212480, data length=212480,
refs=1:
JD DOUBLE Array[5312]
PAS0 DOUBLE Array[5312]
PAS90 DOUBLE Array[5312]
MEP0E3 DOUBLE Array[5312]
MEP90E3 DOUBLE Array[5312]

and when I read cdf data (at least from ACE) I get arrays of
structures
IDL> help, data
DATA STRUCT = -> <Anonymous> Array[36451]
IDL> help, data, /str
** Structure <19cf008>, 45 tags, length=200, data length=196, refs=1:
DNUM DOUBLE 0.0000000
YEAR LONG 2007
DAY LONG 165
HR LONG 0
MIN LONG 0
SEC FLOAT 8.98560

Are there memory issues with one way or the other? Other things I
haven't thought about?

I prefer the feel of the structure of arrays since I like typing
tmp = data.jd[0:10]
more than I like typing
tmp = data[0:10].jd


Cheers,

Brian

------------------------------------------------------------ --------------
Brian Larsen
Boston University
Center for Space Physics
http://people.bu.edu/balarsen/Home/IDL
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: BAR_PLOT with pairs of bars
Next Topic: Different sized pixels in pg_plotimage (is this a "feature")

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

Current Time: Wed Oct 08 11:36:39 PDT 2025

Total time taken to generate the page: 0.00492 seconds