Re: overriding system functions. [message #43828] |
Thu, 28 April 2005 18:59  |
Kenneth P. Bowman
Messages: 585 Registered: May 2000
|
Senior Member |
|
|
In article <1114696363.867468.129920@z14g2000cwz.googlegroups.com>,
jlamm2223443@yahoo.com wrote:
> I teach IDL for a small class here and me and my students have trouble
> with functions such as max and min. Like max expects an arry
> but if I say max(1,2) it runs and on some lists it runs with the
> wrong results. Fair enough I called it wrong but what I would love
> it to have my own preloaded max function that checks if the input
> is indeed an array and then if it is call the max function or otherwise
> post an error message and bomb. Also, we use -9999 for missing data
> but sin(-9999) turn it into a reasonable value. I would love my own
> sin that first check if in the range -20 to 20 radians is the input
> since if not then probably an error. Any suggestions how I do that?
>
> jlamm2223443@yahoo.com
>
If your variables are floating point (not integers), I recommend using
NaNs for missing data flags.
i = WHERE(x EQ -9999, count)
IF (count GT 0) THEN x[i] = !VALUES.F_NAN
This removes the possibility of inadvertently using missing data as
valid, and many functions have a NAN keyword (see the manual).
Ken Bowman
|
|
|