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

Home » Public Forums » archive » Re: How to locate a "NaN"?
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: How to locate a "NaN"? [message #56266 is a reply to message #56265] Tue, 09 October 2007 00:36 Go to previous message
fanxing_gis is currently offline  fanxing_gis
Messages: 8
Registered: August 2007
Junior Member
On 10 9 , 2 12 , mystea <idllear...@gmail.com> wrote:
> Hello All,
>
> I have a array of length 100. A significant portion of them is
> recorded as NaN. Now I want to figure out what is the largest index of
> the element that contains a valid number, then assign its value to
> these NaN entries.
>
> I thought it would be easy and tried:
>
> IDL> k=max(where(myarray[*] ne !VALUES.D_NAN))
>
> but it does not work! k equals to 99 in this case. what's really
> strange is the following:
>
> IDL> help, myarray[50]
> <Expression> DOUBLE = NaN
>
> IDL>print, (myarray[50] eq !VALUES.D_NAN)
> 0
> (so I think this means myarray[50] is double, is NAN, yet is not !
> VALUES.D_NAN)
>
> In short, the problem is, how to locate array elements whose values
> are NaN?

you could use finite() to do it, and try this:
IDL> k=max(where(finite(myarray) eq 0))
k is the largest index of elements whose values are valid.
By the way, !VALUES.D_NAN in not equal to !VALUES.F_NAN,your data type
is long or float?

best wishes

fanxing
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Get unlimited visitors to your website
Next Topic: y axis tickmarks and box_plot

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

Current Time: Sat Oct 11 13:23:20 PDT 2025

Total time taken to generate the page: 1.75790 seconds