Re: procedure within a procedure [message #7756] |
Thu, 16 January 1997 00:00 |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
Bobby Allen writes:
> I have a procedure which reads in a large amount of data(.25mb i think).
> It takes a while for idl to read in all the data. Then I have about 5
> lines of which I use to print selected data points using plot, and oplot
> from the large data set. The problem comes when I plot say 5 points out
> of 50. Then I stop. Then I want to plot a different 5 points out of the
> master data set, without having to read in all the data. Is there a way
> to make the procedure execute from the point where I just manipulate the
> data, or should I somehow make those lines say an auxilliary procedure,
> and somehow allow that to see the variables from the initial procedure?
> What it boils down to, is I want to be able to plot an infinite number
> of time, but read in the data only once.
Why don't you write an IDL function to read the data file, and then
another IDL procedure to do your graphics. Then you can use
array subscripting to pick out those portions of the data you
want to plot.
Your code might look like this:
FUNCTION READDATA
OPENR, lun, 'mydatafile.dat', /GET_LUN
data = FLTARR(10, 3000)
READU, lun, data
FREE_LUN, lun
RETURN, data
END
PRO PLOTIT, data
PLOT, data
END
If you wanted to plot the 3rd column of data, you can do this:
data = READDATA()
PLOTIT, data(4,*)
Now, if you want to plot the 8th column of data, but only the
first 1000 rows, you can type this:
PLOTIT, data(9,0:999)
Bobby, tell your advisor that you will not write one more IDL
program until he or she buys you the IDL Programming manual!
Tell him you are sure the $50 will repay itself several hundreds
of times!
David
-----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
2642 Bradbury Court, Fort Collins, CO 80521
Phone: 970-221-0438 Fax: 970-221-4762
E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com
-----------------------------------------------------------
|
|
|