Re: Where() with multidimensional array? [message #30180] |
Thu, 11 April 2002 07:45 |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Olaf Stetzer (olaf.stetzer@imk.fzk.de) writes:
>>> What I want is the max and min values within data (twodimensional)
>>> but I want to exclude all values which are equal failvalue). Maybe there
>>> is an easy way to do this?
>>
>>
>> valid = Where( ( (data EQ Max(data)) OR (data EQ Min(data)) ) AND $
>> (data NE failvalue) )
>
> Uhmm, but that returns wrong values if failvalue is the max or min itself?
Yeah, I was trying to finish this before I had to get
my sons to school and I was trying to be WAY to clever.
You were doing the correct thing before.
>> Be aware that if you use these Boolean operators with floating point
>> data that you may not get what you expect. With floats we usually
>> look for values within some small delta value of the target.
>
> In my case its exactly the value defined in failvaue. I get my data from
> a mysql database and convert all NULL-values (=missing data) into a
> predefined value, in this case -99999. This is in all cases below the
> minimum of my data, but min(data) should return the minimum of the valid
> data only!
You will be fine once you get a better test case. :-)
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|
Re: Where() with multidimensional array? [message #30182 is a reply to message #30180] |
Thu, 11 April 2002 07:31  |
Olaf Stetzer
Messages: 39 Registered: September 2001
|
Member |
|
|
David Fanning wrote:
> Olaf Stetzer (olaf.stetzer@imk.fzk.de) writes:
>
>
>> I have a problem with the where() function in IDL. It seems,
>> that the function returns -1 when confronted with a multidimensional
>> array.
>
>
> Uh, I don't think so. A -1 is returned when there is nothing
> in the array that meets the criteria. You can obtain a count
> of how may matches there are with the COUNT parameter.
Yes, it seems that all data were failvalues in my testcase.
>> I am trying the following but get an error message:
>>
>> valid=where(data ne failvalue)
>> plot.yrange[0]=min(data[valid])
>> plot.yrange[1]=max(data[valid])
> To avoid this error, I would write the code like this:
>
> valid=where(data ne failvalue, count)
> IF count GT 0 THEN BEGIN
> plot.yrange[0]=min(data[valid])
> plot.yrange[1]=max(data[valid])
> ENDIF
Thanks, this should work!
>
>> What I want is the max and min values within data (twodimensional)
>> but I want to exclude all values which are equal failvalue). Maybe there
>> is an easy way to do this?
>
>
> valid = Where( ( (data EQ Max(data)) OR (data EQ Min(data)) ) AND $
> (data NE failvalue) )
Uhmm, but that returns wrong values if failvalue is the max or min itself?
> Be aware that if you use these Boolean operators with floating point
> data that you may not get what you expect. With floats we usually
> look for values within some small delta value of the target.
In my case its exactly the value defined in failvaue. I get my data from
a mysql database and convert all NULL-values (=missing data) into a
predefined value, in this case -99999. This is in all cases below the
minimum of my data, but min(data) should return the minimum of the valid
data only!
Thanks,
Olaf
--
Dr. Olaf Stetzer
Forschungszentrum Karlsruhe
Institut fᅵr Meterologie und Klimaforschung
Atmosphᅵrische Aerosole (IMK III) - http://imk-aida.fzk.de
Tel.: +49(0)7247-82-3249 (FAX: -4332)
|
|
|
Re: Where() with multidimensional array? [message #30184 is a reply to message #30182] |
Thu, 11 April 2002 07:04  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Olaf Stetzer (olaf.stetzer@imk.fzk.de) writes:
> I have a problem with the where() function in IDL. It seems,
> that the function returns -1 when confronted with a multidimensional
> array.
Uh, I don't think so. A -1 is returned when there is nothing
in the array that meets the criteria. You can obtain a count
of how may matches there are with the COUNT parameter.
> I am trying the following but get an error message:
>
> valid=where(data ne failvalue)
> plot.yrange[0]=min(data[valid])
> plot.yrange[1]=max(data[valid])
To avoid this error, I would write the code like this:
valid=where(data ne failvalue, count)
IF count GT 0 THEN BEGIN
plot.yrange[0]=min(data[valid])
plot.yrange[1]=max(data[valid])
ENDIF
> What I want is the max and min values within data (twodimensional)
> but I want to exclude all values which are equal failvalue). Maybe there
> is an easy way to do this?
valid = Where( ( (data EQ Max(data)) OR (data EQ Min(data)) ) AND $
(data NE failvalue) )
Be aware that if you use these Boolean operators with floating point
data that you may not get what you expect. With floats we usually
look for values within some small delta value of the target.
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|