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

Home » Public Forums » archive » FINITE function
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
FINITE function [message #90049] Wed, 21 January 2015 04:00 Go to next message
g.nacarts is currently offline  g.nacarts
Messages: 148
Registered: November 2013
Senior Member
Hi I used the FINITE() function as suggested to find out whether there are nans or infinity numbers in my array. The problem is that I cannot understand the output of that function. I set the keyword SIGN = 1 but I got -1 inthe outcome.

Below is a part of the code:

DataArray ; contains the 3D data

for i = 0, 199 do begin
for j = 0, 199 do begin
Barray = DataArray[*,i,j] - Array[i,j]
print, where(finite(Barray), /INFINITY, SIGN=1))
endfor
endfor

I got the -1 value thousands of times maybe and I am not even able to figure out in which place of that array there are infinity or nans (if there are any)

Can anyone help with this?
Re: FINITE function [message #90050 is a reply to message #90049] Wed, 21 January 2015 04:14 Go to previous messageGo to next message
andeh is currently offline  andeh
Messages: 23
Registered: April 2011
Junior Member
On Wednesday, 21 January 2015 12:00:29 UTC, g.na...@gmail.com wrote:
> Hi I used the FINITE() function as suggested to find out whether there are nans or infinity numbers in my array. The problem is that I cannot understand the output of that function. I set the keyword SIGN = 1 but I got -1 inthe outcome.
>
> Below is a part of the code:
>
> DataArray ; contains the 3D data
>
> for i = 0, 199 do begin
> for j = 0, 199 do begin
> Barray = DataArray[*,i,j] - Array[i,j]
> print, where(finite(Barray), /INFINITY, SIGN=1))
> endfor
> endfor
>
> I got the -1 value thousands of times maybe and I am not even able to figure out in which place of that array there are infinity or nans (if there are any)
>
> Can anyone help with this?



Your test is only looking for positive infinity so all finite numbers, negative infinities, and NaNs will not be flagged. e.g.

IDL> PRINT, FINITE( 1.0, /INFINITY, SIGN=1), WHERE(FINITE( 1.0, /INFINITY, SIGN=1))

IDL> PRINT, FINITE( !VALUES.F_NAN , /INFINITY, SIGN=1), WHERE(FINITE( !VALUES.F_NAN , /INFINITY, SIGN=1))
0 -1

IDL> PRINT, FINITE( -!VALUES.F_NAN , /INFINITY, SIGN=1), WHERE(FINITE( -!VALUES.F_NAN , /INFINITY, SIGN=1))
0 -1

IDL> PRINT, FINITE( 1.0 / 0.0 , /INFINITY, SIGN=1), WHERE(FINITE( 1.0 / 0.0, /INFINITY, SIGN=1))
1 0

IDL> PRINT, FINITE( -1.0 / 0.0 , /INFINITY, SIGN=1), WHERE(FINITE( -1.0 / 0.0, /INFINITY, SIGN=1))
0 -1



You are getting -1 values from WHERE(). This means that there are no matching elements in FINITE(Barray).


To search for all non-finite numbers, make your search
WHERE( ~FINITE(Barray) )
Re: FINITE function [message #90051 is a reply to message #90050] Wed, 21 January 2015 04:20 Go to previous messageGo to next message
andeh is currently offline  andeh
Messages: 23
Registered: April 2011
Junior Member
On Wednesday, 21 January 2015 12:14:55 UTC, AJAS wrote:
> On Wednesday, 21 January 2015 12:00:29 UTC, g.na...@gmail.com wrote:
>> Hi I used the FINITE() function as suggested to find out whether there are nans or infinity numbers in my array. The problem is that I cannot understand the output of that function. I set the keyword SIGN = 1 but I got -1 inthe outcome.
>>
>> Below is a part of the code:
>>
>> DataArray ; contains the 3D data
>>
>> for i = 0, 199 do begin
>> for j = 0, 199 do begin
>> Barray = DataArray[*,i,j] - Array[i,j]
>> print, where(finite(Barray), /INFINITY, SIGN=1))
>> endfor
>> endfor
>>
>> I got the -1 value thousands of times maybe and I am not even able to figure out in which place of that array there are infinity or nans (if there are any)
>>
>> Can anyone help with this?


Ah. Just saw your previous posts.
You are looking for positive infinities?
You have not put the brackets in the correct place around your FINITE function and you could test to see if there are any valid elements using the COUNT keyword to WHERE.

How about:


for i = 0, 199 do begin
for j = 0, 199 do begin
Barray = DataArray[*,i,j] - Array[i,j]
w = where(finite(Barray, /INFINITY, SIGN=1), COUNT=count)
IF count GT 0 THEN PRINT, w
endfor
endfor
Re: FINITE function [message #90053 is a reply to message #90049] Wed, 21 January 2015 05:35 Go to previous messageGo to next message
g.nacarts is currently offline  g.nacarts
Messages: 148
Registered: November 2013
Senior Member
I've got a quite old version of IDL 6.4. And I got the error that Keyword COUNT not allowed in call to: WHERE
Re: FINITE function [message #90054 is a reply to message #90053] Wed, 21 January 2015 05:49 Go to previous messageGo to next message
andeh is currently offline  andeh
Messages: 23
Registered: April 2011
Junior Member
On Wednesday, 21 January 2015 13:35:13 UTC, g.na...@gmail.com wrote:
> I've got a quite old version of IDL 6.4. And I got the error that Keyword COUNT not allowed in call to: WHERE

Ok.

Then just test that the first element of the returned array w is not -1.

w = WHERE( FINITE(Barray,/INFINITY,SIGN=1) )
IF w[0] NE -1 THEN PRINT, w
Re: FINITE function [message #90055 is a reply to message #90054] Wed, 21 January 2015 05:52 Go to previous messageGo to next message
andeh is currently offline  andeh
Messages: 23
Registered: April 2011
Junior Member
On Wednesday, 21 January 2015 13:49:52 UTC, AJAS wrote:
> On Wednesday, 21 January 2015 13:35:13 UTC, g.na...@gmail.com wrote:
>> I've got a quite old version of IDL 6.4. And I got the error that Keyword COUNT not allowed in call to: WHERE
>
> Ok.
>
> Then just test that the first element of the returned array w is not -1.
>
> w = WHERE( FINITE(Barray,/INFINITY,SIGN=1) )
> IF w[0] NE -1 THEN PRINT, w

Oh, my bad. I misremembered the WHERE command. COUNT is a parameter, not a keyword.

Does,
w = WHERE( FINITE(Barray,/INFINITY, SIGN=1, count )
work?
Re: FINITE function [message #90056 is a reply to message #90054] Wed, 21 January 2015 05:53 Go to previous messageGo to next message
andeh is currently offline  andeh
Messages: 23
Registered: April 2011
Junior Member
On Wednesday, 21 January 2015 13:49:52 UTC, AJAS wrote:
> On Wednesday, 21 January 2015 13:35:13 UTC, g.na...@gmail.com wrote:
>> I've got a quite old version of IDL 6.4. And I got the error that Keyword COUNT not allowed in call to: WHERE
>
> Ok.
>
> Then just test that the first element of the returned array w is not -1.
>
> w = WHERE( FINITE(Barray,/INFINITY,SIGN=1) )
> IF w[0] NE -1 THEN PRINT, w

Oh, my bad. I misremembered the WHERE command. COUNT is a parameter, not a keyword.

Does,
w = WHERE( FINITE(Barray,/INFINITY, SIGN=1), count )
work?
Re: FINITE function [message #90058 is a reply to message #90049] Wed, 21 January 2015 07:22 Go to previous message
g.nacarts is currently offline  g.nacarts
Messages: 148
Registered: November 2013
Senior Member
Yes it works. Thanks a lot
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: FIGLIO DI PUTTANA, MANDANTE DI OMICIDI: PAOLO BARRAI DI CRIMINALI WMO, BSI ITALIA SRL, BLOG "MERDATO" LIBERO! MINACCIA DI MORTE CHI LO FOTOGRAFA E SE "COSTUI" INSISTE, L'OMICIDA PAOLO BARRAI FA UCCIDERE O "SUICIDARE" DAVVERO!
Next Topic: map function for astronomy

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

Current Time: Wed Oct 08 15:06:36 PDT 2025

Total time taken to generate the page: 0.00749 seconds