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

Home » Public Forums » archive » Removing unwanted data from a structure
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: Removing unwanted data from a structure [message #84250 is a reply to message #84137] Fri, 10 May 2013 15:10 Go to previous messageGo to previous message
Jeremy Bailin is currently offline  Jeremy Bailin
Messages: 618
Registered: April 2008
Senior Member
On 5/10/13 12:41, cab581 wrote:
> OK, I'll back track and try to explain more clearly.
> I have a structure called STRUCT, it is made from thousands of files, each of these has a measurement at a particular location. The first six tags STRUCT.(0) to STRUCT.(5) are identifiers, STRUCT.(6) is the data. First, I put the data in to 18 latitudinal bins;
>
> FOR I = 0,17 DO BEGIN
> A = 0.0
> A = WHERE(STRUCT.LAT GT LAT[I] AND STRUCT.LAT LE LAT[I]+10)
>
> STRUCT[A].(6) is therefore the data that I want to analyze in each of the 18 bins.
>
> I found the medians by using;
>
> FOR J = 0,99 DO BEGIN
>
> MEDIAN[I,J] = MEDIAN(STRUCT[A].(6)[J], /double, /even)
>
> Where I is the latitude (0,17) and J is the altitude (0,99), so I get an array of the median measurement at each of my 18x100 points.
>
> What I want to do is sift through the data from which I calculated the median and then compare those to the median to exclude erroneous values, so I thought that I could use the following;
>
> ind = where(STRUCT[A].(6)[J] GT (MEDIAN+1000))
> IF ind[0] GT 0 then STRUCT[A].(6)[ind] = !values.F_Nan
>
> but it doesn't work, I end up with NaNs all over the place where they shouldn't be.
>

Aha! I think I understand. I was missing the part about binning in latitude.

The three problems I see with the code as you've written it are:
1. You're using the names of language elements ("median", "struct")
as variable names. While this is not forbidden and won't cause errors,
it is very confusing and will almost certainly lead you into writing
buggy code. So I'm going to pretend that your "median" variable is
actually called "med".

2. In this comparison:
ind = where(STRUCT[A].(6)[J] GT (MEDIAN+1000))
you want med[i,j].

3. You're indexing the wrong part of the struct here:
IF ind[0] GT 0 then STRUCT[A].(6)[ind] = !values.F_Nan
I think you actually want:
if ind[0] gt 0 then struct[ind].(6)[j] = !values.f_nan


-Jeremy.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Q: project_vol
Next Topic: MPFIT and bestnorm

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

Current Time: Thu Oct 09 21:42:11 PDT 2025

Total time taken to generate the page: 1.04152 seconds