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

Home » Public Forums » archive » Reading binary files made by Python
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 binary files [message #54497 is a reply to message #49280] Tue, 19 June 2007 08:06 Go to previous messageGo to previous message
Vince Oliver is currently offline  Vince Oliver
Messages: 8
Registered: June 2007
Junior Member
paul, when I do

spectra = ASSOC(lun,{RecBegin:0L, Data:FLTARR(2,n), RecEnd:0L})
spectrum = spectra[0]
print, spectrum

I endeed have:

SPECTRUM STRUCT = -> <Anonymous> Array[1]
{ 58584 91.0000 2.04773e-023
94.0000 5.73142e-023
96.0000 1.12218e-022
98.0000 2.17056e-022
100.000 4.00652e-022
...}


How to get these elements?









On Jun 19, 4:47 pm, Paul van Delst <Paul.vanDe...@noaa.gov> wrote:
> Vince Oliver wrote:
>> we are maybe on the good way. I wrote this
>
>> OpenR, lun, data, /Get_Lun, /F77_UNFORMATTED
>
>> specnr=2
>> nlen=7323
>> n=2*nlen
>> specoff=(n+1)*specnr*4l ; this is letter L not number 1
>> spectra = Assoc(lun, Fltarr(n),specoff)
>
> what about something like,
>
> spectra = ASSOC(lun,{RecBegin:0L, Data:FLTARR(2,n), RecEnd:0L})
> spectrum = spectra[0]
>
> ?
>
> Do the spectrum.data contain the correct info? Additionally, are the values of
> spectrum.recbegin and spectrum.recend the same as 2*n*4?
>
> Remember that *each* output record (for Fortran sequential access, unformatted) has a
> marker both at the beginning *and* the end specifying the record length (hopefully in
> bytes, not "words").
>
> ASSOC is most often used for direct access, unformatted; but there's no reason you can't
> use it here also.
>
>>> I assume here that the data is: DWORD|fltarr(n)|DWORD|fltarr(n)...
>
> Nope, it should be
>
> RECLEN1|fltarr(2,n)|RECLEN1|RECLEN2|fltarr(2,n)|RECLEN2....
>
> One of the reasons for the terminating record length marker (what I called "RecEnd" in the
> structure above) is so that the Fortran BACKSPACE command works for sequential access files.
>
> cheers,
>
> paulv
>
> --
> Paul van Delst Ride lots.
> CIMSS @ NOAA/NCEP/EMC Eddy Merckx
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: extracting specific substrings from a text-file
Next Topic: Re: Error: X does not support locale C.

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

Current Time: Fri Oct 10 13:37:32 PDT 2025

Total time taken to generate the page: 0.87860 seconds