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 
Switch to threaded view of this topic Create a new topic Submit Reply
readcol problems [message #49493] Wed, 02 August 2006 07:07 Go to next message
Amanda is currently offline  Amanda
Messages: 12
Registered: August 2006
Junior Member
I'm pretty new to IDL and don't know much about it.

I'm trying to use the readcol function but I keep getting errors
"variable
is undefined", "attempt to call undefined procedure/function:
'NUMLINES'"
and sometimes it can't seem to find my .dat file. I'm guessing I must
be
missing some horribly obvious line to get the "variable undefined"
error
but I don't know why I keep getting the Numlines error. I don't need it
to count the number of lines, I just want to plot x against y.

I'm using a windows version and this is the code I'm using:

PRO test, x, y

readcol, 'test.dat', x, y, f='f,f,'

plot, x, y, psym=2

END

Any help would be greatly appreciated. :)
Re: readcol problems [message #49562 is a reply to message #49493] Thu, 03 August 2006 05:27 Go 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!
>>
>>
Re: readcol problems [message #49568 is a reply to message #49493] Thu, 03 August 2006 01:43 Go to previous message
Amanda is currently offline  Amanda
Messages: 12
Registered: August 2006
Junior Member
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!
>
>
Re: readcol problems [message #49577 is a reply to message #49493] Wed, 02 August 2006 10:52 Go to previous message
Haje Korth is currently offline  Haje Korth
Messages: 651
Registered: May 1997
Senior Member
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!


Amanda wrote:
> And also, do I need to edit anything in my code? Like put in some sort
> of numlines command or should it just work if i download the other?
Re: readcol problems [message #49578 is a reply to message #49493] Wed, 02 August 2006 10:37 Go to previous message
Amanda is currently offline  Amanda
Messages: 12
Registered: August 2006
Junior Member
And also, do I need to edit anything in my code? Like put in some sort
of numlines command or should it just work if i download the other?
Re: readcol problems [message #49579 is a reply to message #49493] Wed, 02 August 2006 10:07 Go to previous message
Amanda is currently offline  Amanda
Messages: 12
Registered: August 2006
Junior Member
Well I did download numlines.pro but didn't download those other ones.
Didn't realise I needed them.
Re: readcol problems [message #49591 is a reply to message #49493] Wed, 02 August 2006 07:53 Go to previous message
news.verizon.net is currently offline  news.verizon.net
Messages: 47
Registered: August 2003
Member
The readcol.pro procedure is part of the IDL Astronomy
http://idlastro.gsfc.nasa.gov/ and requires the following other
procedures from the Library to be present in your !PATH

PROCEDURES CALLED
GETTOK(), NUMLINES(), STRNUMBER()

You can either download the entire library or grab the procedures you
need from the search page
http://idlastro.gsfc.nasa.gov/idllibsrch.html

Or as Haje said, there are many other ways to read an ASCII file,
including the READ_ASCII() function that comes with IDL.

Amanda wrote:
> I'm pretty new to IDL and don't know much about it.
>
> I'm trying to use the readcol function but I keep getting errors
> "variable
> is undefined", "attempt to call undefined procedure/function:
> 'NUMLINES'"
  Switch to threaded view of this topic Create a new topic Submit Reply
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: Wed Oct 08 14:52:57 PDT 2025

Total time taken to generate the page: 0.00725 seconds