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

Home » Public Forums » archive » Re: Removing and Replacing Nan values in IDL
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: Removing and Replacing Nan values in IDL [message #80874 is a reply to message #80873] Thu, 19 July 2012 07:15 Go to previous messageGo to previous message
adhdunn is currently offline  adhdunn
Messages: 11
Registered: July 2012
Junior Member
On Thursday, July 19, 2012 9:54:29 AM UTC-4, nata wrote:
> I think that the following code will work :
>
> mask1=WHERE(FINITE(image1) EQ 0,nn1)
> IF nn1 GT 0 THEN BEGIN
> mask2=WHERE(FINITE(image2[mask1]) EQ 1,nn2)
> IF nn2 GT 0 THEN image1[mask1[mask2]]=image2[mask1[mask2]]
> ENDIF
>
> Bernat

Hello Bernat,

Thank you for your reply. Right now I have the following lines of code:

create an image1-sized matrix of all NaNs (c)
; find where both image1 and image2 have valid values
; replace corresponding indices in c with the larger of image1 or image2
; all other values remain as NaNs

C = REPLICATE( !VALUES.F_NAN, N_ELEMENTS(image1) )

good = WHERE( FINITE(image1) and FINITE(image2), ngood )
IF ( ngood GT 0 ) THEN C[good] = (image1[good] + image2[good])/2

filter[i/2] = c

I believe that I need some of this to create my average between the two files. Will the statement you sent fit in here somewhere, or do I need to remove this and replace it completely? Overall I need to create an average between image1 and image2. If the value in image1 is NaN but not in image2 I want to replace image1 with image2, and vice versa, and then not take an average just leave that value as is. Of course an average of those would just yield the same value so I suppose that does not matter.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Rescaling byte (0-200) ndvi to -1 to 1 values
Next Topic: IDL 8.0.1 crashes

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

Current Time: Wed Oct 08 22:56:55 PDT 2025

Total time taken to generate the page: 0.55667 seconds