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 #80870 is a reply to message #80867] Thu, 19 July 2012 09:35 Go to previous messageGo to previous message
lecacheux.alain is currently offline  lecacheux.alain
Messages: 325
Registered: January 2008
Senior Member
Le jeudi 19 juillet 2012 15:47:39 UTC+2, adh...@gmail.com a écrit :
> Hello,
>
> I am working with MODIS Land Surface Temperature and need to clean my data to remove and replace the NaN values. I currently have a little code that I have written to scale the data, convert from Kelvin to Celsius, and average the night and day temp observations, but I am having trouble writing the (probably very simple) lines that will accomplish this last goal of NaN removal.
>
> What I would like to do is to set up some kind of statement where the program looks for any NaN values in 'image1' and checks if the corresponding location in 'image2' also has NaN values.
>
> The next step would be to say if image1 has NaN values, but image2 does not then replace that pixel in image1 with image2. Then you would also do this for image2 replacing with the image1 value. If they both have NaN values you do nothing.
>
> Does this make sense?
>
> If anyone would like to help me I can post my code and give more details.
> Any guidance would definitely be appreciated!!
>
> Thank you!
> Allisyn

You can use the IDL 'finite' function.
I assume that both images have same dimensions.
step1:
IDL> w=where(~finite(image1) and ~finite(image2))
'w' is the vector of indices where both images have NaN values.
step2:
IDL> w=where(~finite(image1) and finite(image2),/NULL)
IDL> image1[w]=image2[w]
'w' is the vector of indices where image1 has NaN while image2 has finite values.
Then same statement, but exchanging image1 and image2.
alain.
[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: Fri Oct 10 23:29:43 PDT 2025

Total time taken to generate the page: 1.44453 seconds