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

Home » Public Forums » archive » Re: Image division causes Floating illegal operand
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Image division causes Floating illegal operand [message #48765 is a reply to message #48764] Thu, 18 May 2006 11:13 Go to previous message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
elsueniero@gmail.com wrote:
> Hello,
>
> I am writing a small program to calculate NDVI from MODIS images. I
> got a mask of the valid pixels (no clouds or water) and two calibration
> coefficients. The code is
>
> partA = (b1*coef[0,1] - b0*coef[0,0])*mask
> partB = (b1*coef[0,1] + b0*coef[0,0])*mask
>
> ndviimg = partA / partB

Won't this always be 1.0 ?? :o)
>
> ind = Where(Finite(ndviimg, /NAN), count)
> IF count GT 0 THEN ndviimg[ind] = -1000.0
>
> But I allways get an "Program caused arithmetic error: Floating illegal
> operand" even if the resulting image looks good.
> The problem is in the division, because if I comment the line, it won't
> show.
>
> Any ideas how to avoid this?

You can try something like,

partA = (b1*coef[0,1] - b0*coef[0,0])*mask
ndviimg = (b1*coef[0,1] + b0*coef[0,0])*mask
Idx=WHERE(ABS(ndviimg) GT 0.0, Count, $
COMPLEMENT=ZeroIdx, NCOMPLEMENT=ZeroCount)
IF (Count GT 0) THEN ndviimg[Idx] = partA[Idx] / ndviimg[Idx]
IF (ZeroCount GT 0) THEN ndviimg[ZeroIdx] = -1000.0

I think there's a faster way to do this though. Probably using HISTOGRAM. :o)

paulv

--
Paul van Delst Ride lots.
CIMSS @ NOAA/NCEP/EMC Eddy Merckx
Ph: (301)763-8000 x7748
Fax:(301)763-8545
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: plot GRIB2 data as an image
Next Topic: Histogram saga

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

Current Time: Wed Oct 08 17:58:35 PDT 2025

Total time taken to generate the page: 0.00412 seconds