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

Home » Public Forums » archive » Re: overriding system functions.
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
Re: overriding system functions. [message #43828] Thu, 28 April 2005 18:59
Kenneth P. Bowman is currently offline  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
Re: overriding system functions. [message #43833 is a reply to message #43828] Thu, 28 April 2005 11:16 Go to previous message
Ken Mankoff is currently offline  Ken Mankoff
Messages: 158
Registered: February 2000
Senior Member
On Thu, 28 Apr 2005 jlamm2223443@yahoo.com wrote:
> 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.

You could tell your students to always check for the existence of a
"jlamm_X" function. If they want "max", they should try
IDL> .com jlamm_max
If there is an error message, use max(), if the compilation works,
use jlamm_max().

You can override any code that is written in IDL. You might be able
to do this by appending your library location to the beginning of
!PATH. I do it by explicitly compiling my own over-ridden routines
(map_set, write_gif, write_mpeg, etc.) in my IDL_STARTUP file.

-k.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: idlwave in XEmacs
Next Topic: Re: Plot Clipping Problems

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

Current Time: Wed Oct 08 15:37:23 PDT 2025

Total time taken to generate the page: 0.00590 seconds