Structure of arrays or arrays of structures? [message #64848] |
Thu, 22 January 2009 12:52 |
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
|
|
|