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

Home » Public Forums » archive » Re: read an irregularly structured ascii file.
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: read an irregularly structured ascii file. [message #81538 is a reply to message #81537] Tue, 25 September 2012 13:38 Go to previous message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
On Tuesday, September 25, 2012 2:35:44 PM UTC-4, (unknown) wrote:

>
> 221 0. 125893. 141254. 158489. 177828. 199527. 223873. 251189.
>
> 281839. 316229. 354815. 398109. 446686. 501190. 562344. 630961.

Ah, the joy of reading a raw Kurucz model atmosphere file. ( I am embarrassed to have recognized these numbers. More ammunition for my wife to call me a geek.)

I have an old program to read similar files which I give below. Unfortunately, my file format was not identical to yours, so you will need multiple changes. I'd work on it one step at a time. First try to read only the first array, and after you succeed go to the next portion of the file.

--Wayne

pro rdkur,file,teff,logg,flux,wave

close,1
openr,1,file
str = ' '
nmod = 221
teff = fltarr(nmod)
logg = fltarr(nmod)
wave = fltarr(1221)
f = fltarr(1221)
flux = fltarr(1221,nmod)
j = 0
test = ' '
while test ne "END" do begin
readf,1,str
test = strtrim(gettok(str,' '),2)
endwhile
readf,1,wave
while not eof(1) do begin
readf,1,str
dum = gettok(str,' ')
teff[j] = float(gettok(str,' '))
dum = gettok(str,' ')
logg[j] = float(gettok(str,' '))
readf,1,f
flux[0,j] = f
readf,1,f
j = j+1
endwhile
j = j-1
flux = flux[*,0:j]
teff= teff[0:j]
logg = logg[0:j]

return
end
[Message index]
 
Read Message
Read Message
Previous Topic: Re: kernel density estimator routine
Next Topic: Re: Escaped Characters in string output

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

Current Time: Fri Oct 10 10:24:17 PDT 2025

Total time taken to generate the page: 1.12030 seconds