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

Home » Public Forums » archive » Bad data in structure (NaN HowTo?)
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
Bad data in structure (NaN HowTo?) [message #22593] Wed, 22 November 2000 00:00 Go to next message
Randall Skelton is currently offline  Randall Skelton
Messages: 169
Registered: October 2000
Senior Member
I have an array of large structures which occasionally is filled (via an
external C program) and passed into IDL with -12345 signifying the data
for that element is lost. I would like to convert the occurances of
-12345 to NaN's in IDL but I am a little perplexed on how to do this.

I had hoped that since this is technically an 'array' (albeit an array of
structures) I would just be able to use the 'where' command; alas, it
appears that structures are not allowed in the where command:

B = where(atrl eq -12345, count)
% Struct expression not allowed in this context: ATRL.

Each structure has about 450 elements in it and is comprised itself of
strings, ints, floats and doubles and arrays of each of the above. My
initial thought is to make an array of strings which represent the
elements of the structure and loop over that array, searching for '-12345'
in each element or array as I go. This seems rather inefficient. It
would be much nicer if I could directly assign the structure element to
NaN in C and pass it into IDL (and have IDL interpret the missing data as
as NaN)? Oh yes, it would be nice if I could use the same C code on
intel, PowerPC, and sparc architechures... Does anyone know how this
might be done?

Thanks for the help.

Randall
Re: Bad data in structure (NaN HowTo?) [message #22646 is a reply to message #22593] Wed, 29 November 2000 00:00 Go to previous message
Randall Skelton is currently offline  Randall Skelton
Messages: 169
Registered: October 2000
Senior Member
> Randall, is it true that you are filling the -12345 values within your
> CALL_EXTERNAL procedure? If so, then perhaps you can try the second
> thing I suggested. Namely, in IDL create whatever "null" variables
> you want, either NaN or whatever. Then pass those variables into the
> CALL_EXTERNAL procedure.

This is exactly what I ended up doing... Eventually I did learn that you
can also do 'A = 0.f/0.f' in C (works with gcc compiler) which gets
interpreted by IDL as NaN but this seemed somewhat inelegant and probably
wouldn't work on different machines/platforms/compilers. With regard to an
NaN for an 'int' number I re-read my first programming text to convince
myself that NaN was truly a floating point arithmetic concept. The moral
of the story being 'one should never throw away old textbooks...'

Thanks to all who offered help and advice!

Randall
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: LONG AND NARROW IMAGE
Next Topic: Re: IDLDE crash on printing!

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

Current Time: Sat Oct 11 16:39:11 PDT 2025

Total time taken to generate the page: 1.59770 seconds