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

Home » Public Forums » archive » Re: Reading 32-bit complex numbers in IDL (16-bit real / 16-bit imaginary)
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: Reading 32-bit complex numbers in IDL (16-bit real / 16-bit imaginary) [message #77112] Sun, 07 August 2011 16:12 Go to previous message
Wout De Nolf is currently offline  Wout De Nolf
Messages: 194
Registered: October 2008
Senior Member
On Sun, 7 Aug 2011 05:01:34 -0700 (PDT), "Waqas A. Qazi"
<waqastro@yahoo.com> wrote:

> Hi,
>
> I couldn't find a discussion of this specific problem on the group, so
> I am posting it here in hope of a solution.
>
> I have complex data in a binary file, with each value comprising of 4
> bytes (32 bits), such that the 32-bit complex number consists of 16-
> bit real and 16-bit imaginary. I could use define a complex array in
> IDL and then read the data using the readu command, however the
> "complex" format in IDL is a 2*32-bit definition, i.e. 32-bit real and
> 32-bit imaginary. How can I read the 16-bit real - 16-bit imaginary
> complex number in IDL?
>
>
> Thanks,
> Waqas.

Have a look at these routines:
http://tinyurl.com/43ca8sk

I made them once to understand floating point numbers. They are not
optimized for speed. I added half precision for you and it is not hard
to add any other precision if you like (like quadruple). An example
for half precision:

integer='3555'x
float=BINARYTOFLOAT(integer,precision=0)

So you can use READU to read 16bit integers from your file, convert
them to 32bit float with BINARYTOFLOAT and then pair them up to 32bit
complex with COMPLEX.

If you have many numbers, this will be slow and BINARYTOFLOAT should
be vectorized.

Hope it helps,
Wox
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: map_set projection "from below"?
Next Topic: TITLE property using object graphics

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

Current Time: Wed Oct 08 17:00:28 PDT 2025

Total time taken to generate the page: 0.00415 seconds