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

Home » Public Forums » archive » Re: reading large multicolumn data file
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
Re: reading large multicolumn data file [message #72128] Fri, 06 August 2010 11:22
bio_amateur is currently offline  bio_amateur
Messages: 7
Registered: August 2010
Junior Member
On Aug 6, 11:17 am, David Fanning <n...@dfanning.com> wrote:
> David Fanning writes:
>> Free_Lun, data
>
> Whoops! That's not likely to work. :-(
>
> Try, "Free_Lun, lun"
>
> Cheers,
>
> David
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")

It works. Many thanks for this powerful package, David.

Tuan.
Re: reading large multicolumn data file [message #72132 is a reply to message #72128] Fri, 06 August 2010 08:17 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

> Free_Lun, data

Whoops! That's not likely to work. :-(

Try, "Free_Lun, lun"

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: reading large multicolumn data file [message #72133 is a reply to message #72132] Fri, 06 August 2010 07:46 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
bio_amateur writes:

> Now, plotting is pretty fast. However, data reading is still slow,
> compared to xmgrace. Is there a better way than using the 2 steps:
> read the data into a structure, and convert a structure to an array as
> the way I did.
>
> The second question is xmgrace autoamtically choose one color for each
> data field (Y1, Y2, ...). However, with direct graphics in IDL, I only
> get one single color. How could we resolve this in IDL.

I'd try something like this:

rows = File_Lines(filename)
data = FltArr(4, rows)
Openr, lun, filename, /Get_Lun
ReadF, lun, data
Free_Lun, data
data = Transpose(data)

colors = ['black', 'white', 'red', 'green', 'blue']
Plot, data[*,0], data[1,*], Background=FSC_Color(colors[1]), $
Color=FSC_Color(colors[0]), /NoData
FOR j=1,3 DO OPlot, data[*,0], data[*,j], COLOR=FSC_Color(colors[j+1])

You can find FSC_Color in the Coyote Library:

http://www.dfanning.com/documents/programs.html

Cheers,

David



--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: reading large multicolumn data file [message #72135 is a reply to message #72133] Fri, 06 August 2010 07:23 Go to previous message
bio_amateur is currently offline  bio_amateur
Messages: 7
Registered: August 2010
Junior Member
On Aug 5, 11:05 pm, Paulo Penteado <pp.pente...@gmail.com> wrote:
> On Aug 5, 8:54 pm, bio_amateur <hoangtrongminht...@gmail.com> wrote:
>
>
>
>> I have a data file (a few hundreds MB). This is a text file in the
>> format X Y1 Y2 Y3 (first column is the common x-axis data, next
>> columns are data). I can read the data and plot easily with xmgrace
>> using
>
>> xmgrace -nxy data.dat
>
>> which take a few seconds to plot. Now, I want to use IDL to read this
>> file and display using iTool. What I did was
>
>>  data = read_ascii(filename)
>>  myPlotData = data.(0)
>>  rows = (size(myPlotData, /dimension))[0]
>>  for ii=1, rows do begin
>>        iPlot, myPlotData[0,*], myPlotData[ii,*], /overplot
>>  end
>
>> This method takes so long. Could someone good at this can point out a
>> solution for me.
>
> The iTools, as any use of object graphics, can get heavy in memory
> when the number of vertices is large (typically, from several hundred
> thousand). This may be alleviated if change your IDL preferences to
> use hardware rendering, in case it is not already in hardware. Other
> than that, only using direct graphics will solve it, as in
>
> minx=min(myplotdata[0,*],max=maxx)
> miny=min(myplotdata[1:*,*],max=maxy)
>
> plot,[minx,maxx],[miny,maxy],/nodata
> for ii=1,rows-1 do oplot,myplotdata[0,*],myplotdata[ii,*]

Now, plotting is pretty fast. However, data reading is still slow,
compared to xmgrace. Is there a better way than using the 2 steps:
read the data into a structure, and convert a structure to an array as
the way I did.

The second question is xmgrace autoamtically choose one color for each
data field (Y1, Y2, ...). However, with direct graphics in IDL, I only
get one single color. How could we resolve this in IDL.

Thanks,
Tuan
Re: reading large multicolumn data file [message #72136 is a reply to message #72135] Fri, 06 August 2010 07:23 Go to previous message
bio_amateur is currently offline  bio_amateur
Messages: 7
Registered: August 2010
Junior Member
On Aug 5, 11:05 pm, Paulo Penteado <pp.pente...@gmail.com> wrote:
> On Aug 5, 8:54 pm, bio_amateur <hoangtrongminht...@gmail.com> wrote:
>
>
>
>> I have a data file (a few hundreds MB). This is a text file in the
>> format X Y1 Y2 Y3 (first column is the common x-axis data, next
>> columns are data). I can read the data and plot easily with xmgrace
>> using
>
>> xmgrace -nxy data.dat
>
>> which take a few seconds to plot. Now, I want to use IDL to read this
>> file and display using iTool. What I did was
>
>>  data = read_ascii(filename)
>>  myPlotData = data.(0)
>>  rows = (size(myPlotData, /dimension))[0]
>>  for ii=1, rows do begin
>>        iPlot, myPlotData[0,*], myPlotData[ii,*], /overplot
>>  end
>
>> This method takes so long. Could someone good at this can point out a
>> solution for me.
>
> The iTools, as any use of object graphics, can get heavy in memory
> when the number of vertices is large (typically, from several hundred
> thousand). This may be alleviated if change your IDL preferences to
> use hardware rendering, in case it is not already in hardware. Other
> than that, only using direct graphics will solve it, as in
>
> minx=min(myplotdata[0,*],max=maxx)
> miny=min(myplotdata[1:*,*],max=maxy)
>
> plot,[minx,maxx],[miny,maxy],/nodata
> for ii=1,rows-1 do oplot,myplotdata[0,*],myplotdata[ii,*]

Now, plotting is pretty fast. However, data reading is still slow,
compared to xmgrace. Is there a better way than using the 2 steps:
read the data into a structure, and convert a structure to an array as
the way I did.

The second question is xmgrace autoamtically choose one color for each
data field (Y1, Y2, ...). However, with direct graphics in IDL, I only
get one single color. How could we resolve this in IDL.

Thanks,
Tuan
Re: reading large multicolumn data file [message #72143 is a reply to message #72136] Thu, 05 August 2010 20:05 Go to previous message
penteado is currently offline  penteado
Messages: 866
Registered: February 2018
Senior Member
Administrator
On Aug 5, 8:54 pm, bio_amateur <hoangtrongminht...@gmail.com> wrote:
> I have a data file (a few hundreds MB). This is a text file in the
> format X Y1 Y2 Y3 (first column is the common x-axis data, next
> columns are data). I can read the data and plot easily with xmgrace
> using
>
> xmgrace -nxy data.dat
>
> which take a few seconds to plot. Now, I want to use IDL to read this
> file and display using iTool. What I did was
>
>  data = read_ascii(filename)
>  myPlotData = data.(0)
>  rows = (size(myPlotData, /dimension))[0]
>  for ii=1, rows do begin
>        iPlot, myPlotData[0,*], myPlotData[ii,*], /overplot
>  end
>
> This method takes so long. Could someone good at this can point out a
> solution for me.

The iTools, as any use of object graphics, can get heavy in memory
when the number of vertices is large (typically, from several hundred
thousand). This may be alleviated if change your IDL preferences to
use hardware rendering, in case it is not already in hardware. Other
than that, only using direct graphics will solve it, as in

minx=min(myplotdata[0,*],max=maxx)
miny=min(myplotdata[1:*,*],max=maxy)

plot,[minx,maxx],[miny,maxy],/nodata
for ii=1,rows-1 do oplot,myplotdata[0,*],myplotdata[ii,*]
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: quick question to get me started on mapping
Next Topic: concatenate by columns

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

Current Time: Wed Oct 08 17:40:59 PDT 2025

Total time taken to generate the page: 0.04255 seconds