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

Home » Public Forums » archive » BYTSCL and NAN keyword
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
BYTSCL and NAN keyword [message #38282] Tue, 02 March 2004 08:54 Go to next message
K. Bowman is currently offline  K. Bowman
Messages: 330
Registered: May 2000
Senior Member
Has anyone else noticed this problem with BYTSCL and the NAN keyword?

The BYTSCL function scales integers and floats into bytes between 0 and
255 (or the value set by the TOP keyword). If the NAN keyword is set,
NANs in the input array are set to 0 in the output array. But 0 falls
into the valid range for good values (0 to TOP)!

Because it is not possible to set NANs to a value outside the valid
range (greater than TOP), it is not possible to distinguish missing from
valid data.

As best I can tell, the only solution is to not use the NAN keyword and
scale the valid data only by using WHERE to find all the valid values.
Am I missing something obvious? (Quite possible, I admit.)

Ken Bowman
Re: BYTSCL and NAN keyword [message #38339 is a reply to message #38282] Wed, 03 March 2004 13:35 Go to previous message
K. Bowman is currently offline  K. Bowman
Messages: 330
Registered: May 2000
Senior Member
In article <onfzcpublg.fsf@cow.physics.wisc.edu>,
Craig Markwardt <craigmnet@REMOVEcow.physics.wisc.edu> wrote:

> No I disagree. FINITE should (and does) return a BYTE, just like all
> the other conditional expressions in IDL.

My mistake.

Ken
Re: BYTSCL and NAN keyword [message #38348 is a reply to message #38282] Wed, 03 March 2004 08:41 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
Kenneth Bowman <k-bowman@null.tamu.edu> writes:

> In article <ond67vf8sb.fsf@cow.physics.wisc.edu>,
> Craig Markwardt <craigmnet@REMOVEcow.physics.wisc.edu> wrote:
>
>> How about this non-WHERE approach?
>> bb = bytscl(x, ...) + (finite(x) EQ 0)*255b
>
> Clever idea (JD also)! The logical not operator (~) will work as well
>
> bb = BYTSCL(x, ..., /NAN) + BYTE(255*(~FINITE(co)))
>
> While not mandatory, the BYTE function ensures that the result bb is
> type BYTE (since FINITE returns a LONG).

No I disagree. FINITE should (and does) return a BYTE, just like all
the other conditional expressions in IDL.

Logical negation ("~" operator) also keeps the byte-ness of the
operand.

I think where you are going askew is the multiplication by 255. You
really need the "B" after 255b in order to force it to be a byte.

Craig

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@REMOVEcow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
Re: BYTSCL and NAN keyword [message #38356 is a reply to message #38282] Wed, 03 March 2004 00:10 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
David Fanning <david@dfanning.com> writes:
>
> Let's just say when Craig responds to tell me how
> hopelessly I botched Turing's Theorem, I'm going to let
> *him* have the last word!

Nope, I am currently away on travel and a robot post messages in my
place. All of the messages the robot posts are false.

Craig

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@REMOVEcow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
Re: BYTSCL and NAN keyword [message #38361 is a reply to message #38282] Tue, 02 March 2004 18:18 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

> Here is the proof of Turing's theorem all over again.
> If I respond, the theorem is true, if I don't the
> theorem is false. But we can't decide the truth within
> the system of our own newsgroup! :-)

Let's just say when Craig responds to tell me how
hopelessly I botched Turing's Theorem, I'm going to let
*him* have the last word!

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: BYTSCL and NAN keyword [message #38362 is a reply to message #38282] Tue, 02 March 2004 18:15 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Kenneth P. Bowman writes:

> You can have the last word.

Here is the proof of Turing's theorem all over again.
If I respond, the theorem is true, if I don't the
theorem is false. But we can't decide the truth within
the system of our own newsgroup! :-)

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting
Coyote's Guide to IDL Programming: http://www.dfanning.com/
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Working with indices of WHERE
Next Topic: NR__SVDFIT issue

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

Current Time: Wed Oct 08 19:51:37 PDT 2025

Total time taken to generate the page: 0.00522 seconds