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

Home » Public Forums » archive » Subset of a structure?
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
Subset of a structure? [message #87246] Mon, 20 January 2014 14:36 Go to next message
troydporter13 is currently offline  troydporter13
Messages: 5
Registered: January 2014
Junior Member
Hi,

I am trying to get a subset from a structure. I have the following;

help, pm25_total, /struc

** Structure <358d280>, 11 tags, length=7160, data length=6566, refs=1:
STATION STRING 'Station1'
OBSERVABLE STRING 'Value1
UNITS STRING ' microg m-3'
RATE INT 600
REPORTS_GOOD STRUCT -> <Anonymous> Array[144]
REPORTS_BAD STRUCT -> <Anonymous> Array[1]
REPORTS_GEN STRUCT -> <Anonymous> Array[1]
GAPS STRUCT -> <Anonymous> Array[1]
JS_GAPS STRUCT -> <Anonymous> Array[1]
P_FILL STRUCT -> <Anonymous> Array[1]
STATS STRUCT -> <Anonymous> Array[1]

help, pm25_total.reports_good, /struc

** Structure <3504e50>, 4 tags, length=48, data length=44, refs=2:
TIME_GOOD STRING '2012/06/01 00:00:00'
TIME_JS_GOOD DOUBLE 3.9182400e+008
VALUE_GOOD FLOAT 13.7600
COMMENT_GOOD STRING ''

help, pm25_total.reports_good.time_js_good, /struc
<Expression> DOUBLE = Array[144, 5]

Time_JS_good is in julian seconds so if there is a zero value in my data I want to eliminate it.
I have tried;

good_val_pm25 = where(PM25_TOTAL.reports_GOOD.time_JS_GOOD gt 1, good_val_pm25_count)

and then tried to use PM25_TOTAL.reports_GOOD.time_JS_GOOD(good_val_pm25) but it does not work. Any ideas why?

Troy
Re: Subset of a structure? [message #87247 is a reply to message #87246] Mon, 20 January 2014 14:59 Go to previous messageGo to next message
Phillip Bitzer is currently offline  Phillip Bitzer
Messages: 223
Registered: June 2006
Senior Member
Hi Troy-

You need to be careful between an array of structures and a structure of arrays. Here's what I gather from your example:

1) pm25_total is a scalar structure (N_ELEMENTS(pm25total) =1)
2) pm25_total.reports_good is an array of structures. There are 144 elements in this array. Each element is a structure and has 4 tags. Each tag is a scalar.

So, we have

A) pm25_total.reports_good is a 144 element array of structures
B) pm25_total.reports_good[0], pm25_total.reports_good[1], etc is a structure, and pm25_total.reports_good[0].time_js_good is a scalar (as is pm25_total.reports_good[1].time_js_good, etc)

C) pm25_total.reports_good.time_js_good[1] is non-sensical. time_js_good (the tag) is not an array, but a scalar. You want to index the array, which in this case is pm25_total.reports_good.

TL;DNR: PM25_TOTAL.reports_GOOD[good_val_pm25].time_JS_GOOD should work.

(Notice the use of square brackets for indexing an array.)
Re: Subset of a structure? [message #87248 is a reply to message #87246] Mon, 20 January 2014 14:59 Go to previous messageGo to next message
Matthew Argall is currently offline  Matthew Argall
Messages: 286
Registered: October 2011
Senior Member
> and then tried to use PM25_TOTAL.reports_GOOD.time_JS_GOOD(good_val_pm25) but it does not work. Any ideas why?

Try this,

IDL> help, (PM25_TOTAL.reports_GOOD).time_JS_GOOD[good_val_pm25]


Sometimes the order of operations between "." and "()" can be tricky.

If that does not work, what is the error that you get?
Re: Subset of a structure? [message #87249 is a reply to message #87248] Mon, 20 January 2014 15:03 Go to previous messageGo to next message
Matthew Argall is currently offline  Matthew Argall
Messages: 286
Registered: October 2011
Senior Member
Ahh, yes. Phil payed more attention that I did :-p Use his answer...
Re: Subset of a structure? [message #87250 is a reply to message #87248] Mon, 20 January 2014 15:35 Go to previous messageGo to next message
troydporter13 is currently offline  troydporter13
Messages: 5
Registered: January 2014
Junior Member
Hi guys,

Thanks for your help, I appreciate it.

help, (PM25_TOTAL.reports_GOOD).time_JS_GOOD[good_val_pm25]
<Expression> DOUBLE = Array[719, 144, 5]

This seems to have multiplied the original array by all the good data points so I have 719 versions of it. What I wanted it to do was remove the bad data ponit. So instead of 720 points I should have 719 to now plot. This didn't do that.

Troy
Re: Subset of a structure? [message #87251 is a reply to message #87250] Mon, 20 January 2014 16:13 Go to previous messageGo to next message
Matthew Argall is currently offline  Matthew Argall
Messages: 286
Registered: October 2011
Senior Member
> help, (PM25_TOTAL.reports_GOOD).time_JS_GOOD[good_val_pm25]
>
> <Expression> DOUBLE = Array[719, 144, 5]

Yeah, this was wrong. See Phil's answer if you have not already.
Re: Subset of a structure? [message #87252 is a reply to message #87251] Mon, 20 January 2014 16:29 Go to previous messageGo to next message
troydporter13 is currently offline  troydporter13
Messages: 5
Registered: January 2014
Junior Member
help, PM25_TOTAL.reports_GOOD[good_val_pm25].time_JS_GOOD
<Expression> DOUBLE = Array[719, 5]

This is still not correct though. It was an array that had 144 measurements (one every 10 minutes - 24 x 6) for each of the 5 days of data. Now it has 719 measurements for each of the five days, when it should really have 719 over the whole 5 days combined.

Troy
Re: Subset of a structure? [message #87253 is a reply to message #87250] Mon, 20 January 2014 17:33 Go to previous messageGo to next message
Matthew Argall is currently offline  Matthew Argall
Messages: 286
Registered: October 2011
Senior Member
> help, (PM25_TOTAL.reports_GOOD).time_JS_GOOD[good_val_pm25]
>
> <Expression> DOUBLE = Array[719, 144, 5]

You posted my wrong solution twice... Phil's answer was the following:

PM25_TOTAL.reports_GOOD[good_val_pm25].time_JS_GOOD

--------
My solution (the one you posted) did not work because IDL truncates its indices, so basically you got the scalar value (PM25_TOTAL.reports_GOOD).time_JS_GOOD[0] 719 times for each of the good reports.
Re: Subset of a structure? [message #87254 is a reply to message #87253] Mon, 20 January 2014 17:36 Go to previous messageGo to next message
Matthew Argall is currently offline  Matthew Argall
Messages: 286
Registered: October 2011
Senior Member
Oh, my. I am messing this one up today :-p Forget my last message.

try

IDL> help, PM25_TOTAL.reports_GOOD[good_val_pm25[0]].time_JS_GOOD


IDL does not really like referencing a single tag in an array of structures. You may have to loop through them all
Re: Subset of a structure? [message #87255 is a reply to message #87252] Mon, 20 January 2014 17:50 Go to previous message
Matthew Argall is currently offline  Matthew Argall
Messages: 286
Registered: October 2011
Senior Member
Sorry for all the mix-ups. To make up for it, tell me if I am doing something differently from you...

IDL> reports_good = {time_good: '2012/06/01 00:00:00', time_js_good: 0D, value_good: 0.0, comment_good: ''}
IDL> help, reports_good
** Structure <28533d8>, 4 tags, length=48, data length=44, refs=1:
TIME_GOOD STRING '2012/06/01 00:00:00'
TIME_JS_GOOD DOUBLE 0.0000000
VALUE_GOOD FLOAT 0.00000
COMMENT_GOOD STRING ''
IDL> reports_good = replicate(reports_good, 144)
IDL> pm25_total = {reports_good: reports_good}
IDL> help, pm25_total
** Structure <2937008>, 1 tags, length=6912, data length=6336, refs=1:
REPORTS_GOOD STRUCT -> <Anonymous> Array[144]
IDL> index = indgen(50)


IDL> help, (pm25_total.reports_good)[index].time_good
<Expression> STRING = Array[50]
IDL> help, pm25_total.reports_good[index].time_good
<Expression> STRING = Array[50]
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: averaging w.r.t time resolution
Next Topic: Box and Whisker Plotting

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

Current Time: Wed Oct 08 13:31:52 PDT 2025

Total time taken to generate the page: 0.00689 seconds