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

Home » Public Forums » archive » Re: creating multiple files
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: creating multiple files [message #47362] Tue, 07 February 2006 00:01
peter.albert@gmx.de is currently offline  peter.albert@gmx.de
Messages: 108
Registered: July 2005
Senior Member
Hi Eli,

if I get you right, you would like to create multiple files with one
call. Sorry, but this won't work. A call to OPENW just creates one
single file, that's it. No array operations on this command. If you
want multiple files, you have to go through a loop.

Then, from your code fragment, you probably got something wrong on the
PRINTF command:

printf, sun"j", index, format='(10i10)'

won't work, neither.

In general, it should read something like

PRINTF, lun, data, format = format

where lun is the logical unit number assigned to the file via the
previous call to OPENW (n.B. lun is _always_ a scalar and can't be an
array).

I regret to say this, but imho you can't avoid a for loop here. And I
doubt HISTOGRAM can help here...

Cheers,

Peter
Re: creating multiple files [message #47363 is a reply to message #47362] Mon, 06 February 2006 22:15 Go to previous message
bressert@gmail.com is currently offline  bressert@gmail.com
Messages: 8
Registered: February 2006
Junior Member
Hello Dave,

Thank you for your quick reply and suggestions. I tried what you posted
with no luck. I think what I explained was not detailed enough. Here is
the part of the script that I'm working with.

==========Script============
;read the columns of the sundata.dat file into program
readcol, dialog_pickfile(), it, sundata, dm, sm

;create matrix of imported data
array = transpose([[it],[sundata],[dm],[sm]])

;array that expresses the total number of rows in it
i = findgen(size(it,/n_elements))

;index values where it[i] gt it[i+1], meaning a new file should be
created
index = [0,where(it[i] gt it[i+1])]
index = transpose(index)

;array that expresses the total number of rows in index
j = findgen(size(index,/n_elements))

;array that is created multiple times to print multiple files of
sun#.txt
sun"j" =
transpose([[it[index[j]:index[j+1]]],[sundata[index[j]:index [j+1]]],$
[dm[index[j]:index[j+1]]],[sm[index[j]:index[j+1]]]])

;file creation and printing
openw, lun, 'C:\sun"j".dat', /get_lun

printf, sun"j", index, format='(10i10)'

free_lun, lun

==========End of Script============

I just need to enter the parameters as you suggested in a way that
would work. Your website is very well done and informative. I have gone
there many times with promising results, thanks.

All the best,

Eli
Re: creating multiple files [message #47364 is a reply to message #47363] Mon, 06 February 2006 20:55 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
bressert@gmail.com writes:

> I am currently writing a script in IDL where I'm trying to create
> multiple files. What is essentially being done is the following:
>
> 1) grabbing a large 4 by 400,000 matrix and then spliting it up by a
> specific criteria
>
> 2) splitting up the file will create about 12,000 different files
>
> 3) how do I routine a process where I can name a variable, i.e. sun'j'
> = ....
> where 'j' is an iterating number from 0 to 11,999.
>
> 4) afterwards, the script involves an openw and printf with file names
> of "sun'j'.dat".
>
> The last property that should be mentioned is that 'j' is a result of
> array processing. No loops are involved in the script.
>
> Thank you for regarding the inquiry and any advice would be greatly
> appreciated.

If "j" is any number between 0 and 11,999, and you want file
names like:

sun5.dat
sun195.dat
sun11493.dat

Then you simply create your filename like this:

filename = 'sun' + StrTrim(j,2) + '.dat'

If you want filenames like this:

sun00005.dat
sun00195.dat
sun11493.dat

Then you create your filename like this:

filename = 'sun' + String(j, Format='(I5.5)') + '.dat'

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: creating multiple files
Next Topic: Re: cannt disable widget timer event?

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

Current Time: Wed Oct 08 13:49:45 PDT 2025

Total time taken to generate the page: 0.00272 seconds