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

Home » Public Forums » archive » readcol problems
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: readcol problems [message #49562 is a reply to message #49493] Thu, 03 August 2006 05:27 Go to previous messageGo to previous message
Haje Korth is currently offline  Haje Korth
Messages: 651
Registered: May 1997
Senior Member
Alright, let me explain a little more. the routine i wrote above is
just the read routine for the data, i.e., an alternative to readcol.
There are a million ways to do the job. I prefer the one in my example.
it uses structures (that's what the "." is indicating), whioch makes it
look more complex, but it really isn't. The advantage is that you can
keep all properties of one data point neatly together with accessing
separate arrays like x and y and z, etc. Everything in my example will
be in one structure array called data, which happens to only contain
two coordinates x and y in this case.

pro readfile,fname,data
ndat=file_lines(fname)
data_struct={x:0.0,y:0.0}
data=replicate(data_struct,ndat)
openr,runit,fname,/get_lun
readf,runit,data
close,runit
free_lun,runit
return
end

What was missing in my example is the driver routine, which can look as
simple as this:

pro test
fname='testdata.txt' ; this should be the name of your data file
readfile, fname, data ; this calls the read routine to read
testdata.txt
plot,data.x,data.y ; this plots the data passed back by
readfile
return
end

Hope this was more clear. Looks like you have some catching up to do.
For this I recommend David Fannings Book "IDL Programming Techniques",
which helps you get up to speed with hands-on examples.

Cheers,
Haje





Amanda wrote:
> I tried that code and really don't have a clue how to use it.
>
> And I downloaded those other 2 programs but I keep getting the same
> errors on my original code.
>
>
> Haje Korth wrote:
>> IMHO, the readcol rotuines sound like complete overkill to me. If you
>> stick with the few lines I wrote above you'll be done in 5 minutes!
>>
>>
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: question about readf
Next Topic: Reading ASCII data from multiple files into one array?

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

Current Time: Sat Oct 11 06:41:35 PDT 2025

Total time taken to generate the page: 2.23435 seconds