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

Home » Public Forums » archive » divide by zero problems
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
divide by zero problems [message #15362] Tue, 11 May 1999 00:00 Go to next message
Mark Rehbein is currently offline  Mark Rehbein
Messages: 8
Registered: January 1999
Junior Member
Hi,

I'm having problems with floating point divide by zero's. The
application I'm using IDL for is image composition and masking.
Basically, my images have cloud pixels that I have changed to a zero
value. I also have a mask of the image that has values 1 for good pixel
and 0 for bad pixels (cloud). I then add all my images together to get
a "sum image" and add all my masks together to get a "sum mask".

Now to composite or average the images I do the following:

composite=sum image/ sum mask.

sometimes my images are very cloudy and as such my "sum mask" has zero's
in it and likewise for my "sum image". So I get divide by zero's and
NaN's in my resultant composite image. In fact I get whole image of
NaN's in my composite even though my sum image and sum mask have decent
values in them.

I'm using IDL 5.2 on UNIX box running solaris 2.6. Can anyone help?

please email me

mrehbein@aims.gov.au

Thanks in advance

Mark
Re: divide by zero problems [message #15392 is a reply to message #15362] Sat, 15 May 1999 00:00 Go to previous messageGo to next message
korpela is currently offline  korpela
Messages: 59
Registered: September 1993
Member
In article <bowman-1405991756240001@tl6-218-141.tca.net>,
Kenneth P. Bowman <bowman@null.tamu.edu> wrote:
>> IDL> PRINT, !VALUES.F_NAN EQ !VALUES.F_NAN
>> 1
>> % Program caused arithmetic error: Floating illegal operand
>
> I thought that by definition NaNs are not a number and hence not equal to
> *anything* else. Thus the FINITE function.

That's the point. In IEEE math there is no need for a FINITE function.
X eq X is enough to test for NaN. X EQ !Values.F_NAN should always return
0. Even if X is NaN. Period. Excamation point!

If RSI thinks it's not important that IDL be IEEE compliant, they're wrong.
I may consider that bit of non-portability/non-compliance a good reason not
to code for IDL under ANY platform.

Eric

--
Eric Korpela | An object at rest can never be
korpela@ssl.berkeley.edu | stopped.
<a href="http://setiathome.ssl.berkeley.edu/~korpela">Click for home page.</a>
Re: divide by zero problems [message #15394 is a reply to message #15362] Fri, 14 May 1999 00:00 Go to previous messageGo to next message
bowman is currently offline  bowman
Messages: 121
Registered: September 1991
Senior Member
> IDL> PRINT, !VALUES.F_NAN EQ !VALUES.F_NAN
> 1
> % Program caused arithmetic error: Floating illegal operand

I thought that by definition NaNs are not a number and hence not equal to
*anything* else. Thus the FINITE function.

Ken Bowman
Re: divide by zero problems [message #15398 is a reply to message #15362] Fri, 14 May 1999 00:00 Go to previous messageGo to next message
mallors is currently offline  mallors
Messages: 76
Registered: November 1997
Member
In article <7hfhke$gn7$1@clam.niwa.cri.nz>,
"Mark Hadfield" <m.hadfield@niwa.cri.nz> writes:
>> .... Apparently the IDL on some platforms
>> is not IEEE compliant. On those platforms (!values.f_NaN eq
> !values.f_NaN)
>> can be true. I would consider this to be a major bug and would not use
>> IDL on such a platform.
>
> IDL 5.2 on Windows NT gives:
>
> IDL> print, !values.f_NaN eq !values.f_NaN
> 1
> % Program caused arithmetic error: Floating illegal operand
>
> ...Sigh, I guess I'll have to switch to Matlab!
>


Naw, just switch to Linux :-)

IDL> PRINT, !VALUES.F_NAN EQ !VALUES.F_NAN
0



--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~
Robert S. Mallozzi 256-544-0887
Mail Code ES 84
Work: http://gammaray.msfc.nasa.gov/ Marshall Space Flight Center
Play: http://cspar.uah.edu/~mallozzir/ Huntsville, AL 35812
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~
Re: divide by zero problems [message #15409 is a reply to message #15362] Fri, 14 May 1999 00:00 Go to previous messageGo to next message
Mark Hadfield is currently offline  Mark Hadfield
Messages: 783
Registered: May 1995
Senior Member
> .... Apparently the IDL on some platforms
> is not IEEE compliant. On those platforms (!values.f_NaN eq
!values.f_NaN)
> can be true. I would consider this to be a major bug and would not use
> IDL on such a platform.

IDL 5.2 on Windows NT gives:

IDL> print, !values.f_NaN eq !values.f_NaN
1
% Program caused arithmetic error: Floating illegal operand

...Sigh, I guess I'll have to switch to Matlab!

---
Mark Hadfield m.hadfield@niwa.cri.nz
National Institute for Water and Atmospheric Research
PO Box 14-901, Wellington, New Zealand
Re: divide by zero problems [message #15412 is a reply to message #15362] Thu, 13 May 1999 00:00 Go to previous messageGo to next message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Mark Hadfield (m.hadfield@niwa.cri.nz) writes:

> ...Sigh, I guess I'll have to switch to Matlab!

Humm. No objects, though. :-(

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
Re: divide by zero problems [message #15426 is a reply to message #15362] Thu, 13 May 1999 00:00 Go to previous messageGo to next message
korpela is currently offline  korpela
Messages: 59
Registered: September 1993
Member
In article <7he06l$m68$1@news5.svr.pol.co.uk>,
<asowter@synopticsga.freeserve.co.uk> wrote:
> I also had a similar problem but I used the FINITE function to test the
> result.

Yes, this is probably the best way. Apparently the IDL on some platforms
is not IEEE compliant. On those platforms (!values.f_NaN eq !values.f_NaN)
can be true. I would consider this to be a major bug and would not use
IDL on such a platform.

Eric

--
Eric Korpela | An object at rest can never be
korpela@ssl.berkeley.edu | stopped.
<a href="http://setiathome.ssl.berkeley.edu/~korpela">Click for home page.</a>
Re: divide by zero problems [message #15450 is a reply to message #15362] Tue, 18 May 1999 00:00 Go to previous message
Frank Monaldo is currently offline  Frank Monaldo
Messages: 2
Registered: September 1997
Junior Member
Mark Rehbein wrote:
>
Mark,

Try

w= where(total(mask) gt 0 )

composite= sum_image(w) / sum_mask(w)

Regards,
Frank Monaldo


Frank Monaldo Work: Frank_Monaldo@jhuapl.edu
The Johns Hopkins University Personal: fmm@us.net
Applied Physics Laboratory Voice: 240-228-8648
Johns Hopkins Rd FAX: 240-228-5548
Laurel, MD 20723-6099
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Variable stride in array indices
Next Topic: graphic formats

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

Current Time: Wed Oct 08 15:16:02 PDT 2025

Total time taken to generate the page: 0.00639 seconds