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

Home » Public Forums » archive » Re: how read a file of complex?
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
Re: how read a file of complex? [message #10628] Sat, 03 January 1998 00:00
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Nando Iavarone (iavarone@axpba0.ba.infn.it) writes:

> David Fanning ha scritto:
>
>> OpenR, lun, filename, /Get_Lun
>> ReadU, lun, data
>> Free_Lun, data
> Free_Lun, data ??
> Free_Lun, lun

I took a few days off to ski and try to forget that I had
ever heard of IDL. I was apparently successful. :-)

Cheers,

David

-----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
E-Mail: davidf@dfanning.com
Phone: 970-221-0438
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: how read a file of complex? [message #10629 is a reply to message #10628] Sat, 03 January 1998 00:00 Go to previous message
Ferdinando Iavarone is currently offline  Ferdinando Iavarone
Messages: 10
Registered: October 1997
Junior Member
David Fanning ha scritto:

> OpenR, lun, filename, /Get_Lun
> ReadU, lun, data
> Free_Lun, data
>

Thank's David.
Free_Lun, data ??
Free_Lun, lun

Cheers,
Nando

--
Nando Iavarone
Laureando Gruppo Telerilevamento
Dipartimento Interateneo di Fisica
Via Amendola, 173
70126 BARI
ITALY
Tel.: +39 80 5443166
Fax.: +39 80 5443165
e_mail: iavarone@axpba0.ba.infn.it
Re: how read a file of complex? [message #10630 is a reply to message #10628] Fri, 02 January 1998 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Nando Iavarone (iavarone@axpba0.ba.infn.it) provides the
first interesting problem of the New Year when he writes:

> I have a data-file containing a matrix. Each element of matrix has the
> form(real part, imaginary part)[1] with each one LONG.
>
> 1) How create a matrix with structure [1] to read in a single pass the
> file?

> [Slow code clipped.]

For an m-by-n matrix of real-imaginary pairs of long integers,
how about something like this:

FUNCTION Read_It, filename, m, n

; Read the data all at once.

data = LonArr(m*n*2)
OpenR, lun, filename, /Get_Lun
ReadU, lun, data
Free_Lun, data

; Reform to align real data in column next to imaginary data.

colData = Reform(data, 2, m*n)

; Create vectors of real and imaginary values.

real = Reform(colData[0,*])
imag = Reform(colData[1,*])

; Make complex numbers out of real and imaginary parts.

complexData = Complex(real, imag)

; Reformat the complex data into a matrix and return.

RETURN, Reform(complexData, m, n)
END

Call this function like this:

myData = Read_It('mydata.dat', 300, 500)

I've taken more steps then necessary here (as someone is
sure to point out), but I tried to give you the sense of
how this might be done by taking advantage of IDL's array
operations instead of loops.

Cheers,

David

-----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
E-Mail: davidf@dfanning.com
Phone: 970-221-0438
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: how read a file of complex?
Next Topic: IDL Colors on 24-Bit Displays

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

Current Time: Sun Nov 29 01:49:56 PST 2020

Total time taken to generate the page: 0.00639 seconds