[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Filtering data in multidimensional arrays



Simon de Vet (simon@mathstat.dal.ca) writes:

> I have a 3 dimensional array, of size (20,40,13). This represents
> (Flight Number, Point Number, Data Type). The flights range from 3-19.
> Each flight has between 10 and 40 points. They all have the same number
> of data types. Using the replicate command, I have filled the empty
> array locations with -1111.
> 
> Now, I want to plot this data, with all the negative values in the first
> two dimensions ('Bad Data') removed entirely. I have fooled around a bit
> with WHERE, but I can only understand it when it's applied to one
> dimensional arrays.
> 
> How can I use it in my particular case? Is there another solution?

Oh, the WHERE function applies equally well to multidimensional
arrays. And the beauty of it is, you don't have to understand
it. You just have to use it. :-)

The secret is that you can use one-dimensional subscripts
to subset multi-dimensional arrays. If you really do want
to know how this works (and I wouldn't bother, probably)
here is an article on my web page that shows you how to
convert 1D subscripts of the type returned by WHERE to
multidimensional coordinates:

  http://www.dfanning.com/tips/where_to_2d.html

Cheers,

David

-- 
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155