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

Home » Public Forums » archive » Array into binary array
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: Array into binary array [message #86540 is a reply to message #86538] Mon, 18 November 2013 00:57 Go to previous messageGo to previous message
lecacheux.alain is currently offline  lecacheux.alain
Messages: 325
Registered: January 2008
Senior Member
Le lundi 18 novembre 2013 08:51:09 UTC+1, Oliver Angelil a écrit :
> I have an array:
>
>
>
> A =MAKE_ARRAY(4000, 120, 60, 3, /FLOAT, VALUE =!VALUES.F_NaN)
>
>
>
> It consists of numbers between 0 and 1 as well as NaN values. I want to make a binary array from this, such that when an element is NaN, it'll be 0 in the binary array, and when it is a number between 0 and 1, it'll be 1 in the binary array.
>
>
>
> Perhaps there is a quick solution which I have not found yet?
>
>
>
> Thanks in advance,
>
>
>
> Oliver

This is the purpose of the FINITE function. From IDL documentation:

"Returns 1 (True) if its argument is finite. If the argument is infinite or not a defined number (NaN), the FINITE function returns 0 (False). The result is a byte expression of the same structure as the argument X."

Then, you can simply write:
IDL> A =MAKE_ARRAY(4000, 120, 60, 3, /FLOAT, VALUE =!VALUES.F_NaN)
... populate A ...
IDL> B = Finite(A)
use B ...

alx.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: reading in from multiple files, performing operations and printing them to multiple output file
Next Topic: How to access properties of multiple plots in a function graphics window?

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

Current Time: Sun Oct 12 14:47:50 PDT 2025

Total time taken to generate the page: 1.27922 seconds