open and save a set of image [message #51365] |
Thu, 16 November 2006 07:06  |
cecilia.devecchi
Messages: 6 Registered: November 2006
|
Junior Member |
|
|
Hi!
We're newbie in IDL programming and we have this problem:
We have a set (72) images to open, analize and save the output.
Do you know if exists a routine to automatize this process or if
anybody has already written this routine or similar?
Thanks in advance
Cecilia e Maria
Best regards
|
|
|
|
Re: open and save a set of image [message #51394 is a reply to message #51365] |
Tue, 21 November 2006 06:29   |
Paolo Grigis
Messages: 171 Registered: December 2003
|
Senior Member |
|
|
I don't understand how your first example below can write
more than one file?
Ciao,
Paolo
cecilia.devecchi@gmail.com wrote:
> We have a set of hdf files about wind field. We extract these data of
> an area on the Mediterranean Sea.
> We extract these data and we write them in a *.txt file with the
> following lines:
>
> fileout= 'C:\QS' + name + '.txt'
> print,' OUTPUT FILE: ',fileout
> openw,2,/get_lun, fileout
> printf, 2, 'ASCENDING PASS (DAYTIME)'
> printf, 2, ' LON LAT SPD U V SPD2 COUNT
> TIME
> etc....
> ....
> close, 2
>
> With these lines, we succed to pass every file, but we succed to write
> in txt only the first file :
>
> file_array=file_search('C:\QS\',$
> '*.200*', count=num_file)
> for i=0, num_file-1 do begin
> filename=file_array(i)
> print, filename
> openr, lun, /get_lun, filename
>
> ;read, analisys so the lines that we found above
> fileout= 'C:\QS' + name + '.txt'
> print,' OUTPUT FILE: ',fileout
> openw,2,/get_lun, fileout
> printf, 2, 'ASCENDING PASS (DAYTIME)'
> printf, 2, ' LON LAT SPD U V SPD2 COUNT
> TIME
> etc....
> ....
> close, 2
>
> free_lun, lun
> endfor
>
> How do we write (or we wrong) to write every files txt automatically?
> We hope to explain our problem.
> Thanks a lot
> Regards
>
>
> greg michael ha scritto:
>
>
>> Hold on - what's that *.200* about? That wouldn't match either of the
>> names you showed.
>>
>> Try beginning from something like:
>>
>> print,file_search('D:\mydocs\tmp\*.*')
>>
>> (or a path with just a * for unix) - see if it lists what you expect.
>>
>> many greetings,
>> Greg
>>
>>
>> cecilia.devecchi@gmail.com wrote:
>>
>>> No, sorry....We open, read, extract our data. We have written the
>>> following 'loop for' to open these data:
>>>
>>> file_array=file_search('filepath', '*.200*', count=num_file)
>>> for i=0, num_file-1 do begin
>>> filename=file_array(i)
>>> print, filename
>>> openr, lun, /get_lun, filename
>>>
>>> ;read
>>> free_lun, lun
>>> ;Analyze....
>>> ....
>>> ....
>>> endfor
>>>
>>> But analyze only the first file.....where do we wrong?
>>> We hope to explain our problem....
>>>
>>>
>>>
>>> Ben Tupper ha scritto:
>>>
>>>
>>>> cecilia.devecchi@gmail.com wrote:
>>>>
>>>> >Well, probably we're more newbie than others :).
>>>> >
>>>> >We agree with Paul, we have given few details. We know that we need of
>>>> >a FOR loop, but we have this problem: the name of image are
>>>> >01--1-960305-0941-D-24258, 02--1-960409-0941-D-24759, etc...How do we
>>>> >open (simply open) all the image with this kind of name? For the remain
>>>> >of homework (analisys etc), the script is already written.
>>>> >We need some advice about this "name problem" from programmers expert
>>>> >(like David that is a "IDL guru" ;)) or programmer that has already
>>>> >dealt this problem.
>>>>
>>>>
>>>> Hi,
>>>>
>>>> Is the concern is that your files don't have extensions? If so, then
>>>> rest easy if the images are standard format like TIFF, PNG, etc.
>>>>
>>>> I created a TIFF and saved it without an extension. IDL (6.3) read it
>>>> back in without a hitch.
>>>>
>>>> IDL> image = read_image('/Users/ben/12--345-67')
>>>> IDL> help, image
>>>> IMAGE BYTE = Array[406, 408]
>>>>
>>>> Does that help?
>>>>
>>>> cheers,
>>>> Ben
>
>
|
|
|
Re: open and save a set of image [message #51397 is a reply to message #51365] |
Tue, 21 November 2006 05:29   |
cecilia.devecchi
Messages: 6 Registered: November 2006
|
Junior Member |
|
|
We have a set of hdf files about wind field. We extract these data of
an area on the Mediterranean Sea.
We extract these data and we write them in a *.txt file with the
following lines:
fileout= 'C:\QS' + name + '.txt'
print,' OUTPUT FILE: ',fileout
openw,2,/get_lun, fileout
printf, 2, 'ASCENDING PASS (DAYTIME)'
printf, 2, ' LON LAT SPD U V SPD2 COUNT
TIME
etc....
....
close, 2
With these lines, we succed to pass every file, but we succed to write
in txt only the first file :
file_array=file_search('C:\QS\',$
'*.200*', count=num_file)
for i=0, num_file-1 do begin
filename=file_array(i)
print, filename
openr, lun, /get_lun, filename
;read, analisys so the lines that we found above
fileout= 'C:\QS' + name + '.txt'
print,' OUTPUT FILE: ',fileout
openw,2,/get_lun, fileout
printf, 2, 'ASCENDING PASS (DAYTIME)'
printf, 2, ' LON LAT SPD U V SPD2 COUNT
TIME
etc....
....
close, 2
free_lun, lun
endfor
How do we write (or we wrong) to write every files txt automatically?
We hope to explain our problem.
Thanks a lot
Regards
greg michael ha scritto:
> Hold on - what's that *.200* about? That wouldn't match either of the
> names you showed.
>
> Try beginning from something like:
>
> print,file_search('D:\mydocs\tmp\*.*')
>
> (or a path with just a * for unix) - see if it lists what you expect.
>
> many greetings,
> Greg
>
>
> cecilia.devecchi@gmail.com wrote:
>> No, sorry....We open, read, extract our data. We have written the
>> following 'loop for' to open these data:
>>
>> file_array=file_search('filepath', '*.200*', count=num_file)
>> for i=0, num_file-1 do begin
>> filename=file_array(i)
>> print, filename
>> openr, lun, /get_lun, filename
>>
>> ;read
>> free_lun, lun
>> ;Analyze....
>> ....
>> ....
>> endfor
>>
>> But analyze only the first file.....where do we wrong?
>> We hope to explain our problem....
>>
>>
>>
>> Ben Tupper ha scritto:
>>
>>> cecilia.devecchi@gmail.com wrote:
>>>> Well, probably we're more newbie than others :).
>>>>
>>>> We agree with Paul, we have given few details. We know that we need of
>>>> a FOR loop, but we have this problem: the name of image are
>>>> 01--1-960305-0941-D-24258, 02--1-960409-0941-D-24759, etc...How do we
>>>> open (simply open) all the image with this kind of name? For the remain
>>>> of homework (analisys etc), the script is already written.
>>>> We need some advice about this "name problem" from programmers expert
>>>> (like David that is a "IDL guru" ;)) or programmer that has already
>>>> dealt this problem.
>>>
>>>
>>> Hi,
>>>
>>> Is the concern is that your files don't have extensions? If so, then
>>> rest easy if the images are standard format like TIFF, PNG, etc.
>>>
>>> I created a TIFF and saved it without an extension. IDL (6.3) read it
>>> back in without a hitch.
>>>
>>> IDL> image = read_image('/Users/ben/12--345-67')
>>> IDL> help, image
>>> IMAGE BYTE = Array[406, 408]
>>>
>>> Does that help?
>>>
>>> cheers,
>>> Ben
|
|
|
Re: open and save a set of image [message #51411 is a reply to message #51365] |
Mon, 20 November 2006 09:04   |
greg michael
Messages: 163 Registered: January 2006
|
Senior Member |
|
|
Hold on - what's that *.200* about? That wouldn't match either of the
names you showed.
Try beginning from something like:
print,file_search('D:\mydocs\tmp\*.*')
(or a path with just a * for unix) - see if it lists what you expect.
many greetings,
Greg
cecilia.devecchi@gmail.com wrote:
> No, sorry....We open, read, extract our data. We have written the
> following 'loop for' to open these data:
>
> file_array=file_search('filepath', '*.200*', count=num_file)
> for i=0, num_file-1 do begin
> filename=file_array(i)
> print, filename
> openr, lun, /get_lun, filename
>
> ;read
> free_lun, lun
> ;Analyze....
> ....
> ....
> endfor
>
> But analyze only the first file.....where do we wrong?
> We hope to explain our problem....
>
>
>
> Ben Tupper ha scritto:
>
>> cecilia.devecchi@gmail.com wrote:
>>> Well, probably we're more newbie than others :).
>>>
>>> We agree with Paul, we have given few details. We know that we need of
>>> a FOR loop, but we have this problem: the name of image are
>>> 01--1-960305-0941-D-24258, 02--1-960409-0941-D-24759, etc...How do we
>>> open (simply open) all the image with this kind of name? For the remain
>>> of homework (analisys etc), the script is already written.
>>> We need some advice about this "name problem" from programmers expert
>>> (like David that is a "IDL guru" ;)) or programmer that has already
>>> dealt this problem.
>>
>>
>> Hi,
>>
>> Is the concern is that your files don't have extensions? If so, then
>> rest easy if the images are standard format like TIFF, PNG, etc.
>>
>> I created a TIFF and saved it without an extension. IDL (6.3) read it
>> back in without a hitch.
>>
>> IDL> image = read_image('/Users/ben/12--345-67')
>> IDL> help, image
>> IMAGE BYTE = Array[406, 408]
>>
>> Does that help?
>>
>> cheers,
>> Ben
|
|
|
Re: open and save a set of image [message #51418 is a reply to message #51365] |
Mon, 20 November 2006 06:35   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
cecilia.devecchi@gmail.com writes:
> No, sorry....We open, read, extract our data. We have written the
> following 'loop for' to open these data:
>
> file_array=file_search('filepath', '*.200*', count=num_file)
> for i=0, num_file-1 do begin
> filename=file_array(i)
> print, filename
> openr, lun, /get_lun, filename
>
> ;read
> free_lun, lun
> ;Analyze....
> ....
> ....
> endfor
>
> But analyze only the first file.....where do we wrong?
What makes you think so? Are you sure this is the
*first* file you analyzed, or the *last*? How would
you tell the difference? What are you doing in the
"analyze" step? Where are you storing the results of
each analysis?
I'm off on a radio assignment today, so I'll have to
leave it to Ben to sort this out. :-)
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: open and save a set of image [message #51419 is a reply to message #51365] |
Mon, 20 November 2006 06:23   |
cecilia.devecchi
Messages: 6 Registered: November 2006
|
Junior Member |
|
|
No, sorry....We open, read, extract our data. We have written the
following 'loop for' to open these data:
file_array=file_search('filepath', '*.200*', count=num_file)
for i=0, num_file-1 do begin
filename=file_array(i)
print, filename
openr, lun, /get_lun, filename
;read
free_lun, lun
;Analyze....
....
....
endfor
But analyze only the first file.....where do we wrong?
We hope to explain our problem....
Ben Tupper ha scritto:
> cecilia.devecchi@gmail.com wrote:
>> Well, probably we're more newbie than others :).
>>
>> We agree with Paul, we have given few details. We know that we need of
>> a FOR loop, but we have this problem: the name of image are
>> 01--1-960305-0941-D-24258, 02--1-960409-0941-D-24759, etc...How do we
>> open (simply open) all the image with this kind of name? For the remain
>> of homework (analisys etc), the script is already written.
>> We need some advice about this "name problem" from programmers expert
>> (like David that is a "IDL guru" ;)) or programmer that has already
>> dealt this problem.
>
>
> Hi,
>
> Is the concern is that your files don't have extensions? If so, then
> rest easy if the images are standard format like TIFF, PNG, etc.
>
> I created a TIFF and saved it without an extension. IDL (6.3) read it
> back in without a hitch.
>
> IDL> image = read_image('/Users/ben/12--345-67')
> IDL> help, image
> IMAGE BYTE = Array[406, 408]
>
> Does that help?
>
> cheers,
> Ben
|
|
|
Re: open and save a set of image [message #51420 is a reply to message #51365] |
Mon, 20 November 2006 06:12   |
btt
Messages: 345 Registered: December 2000
|
Senior Member |
|
|
cecilia.devecchi@gmail.com wrote:
> Well, probably we're more newbie than others :).
>
> We agree with Paul, we have given few details. We know that we need of
> a FOR loop, but we have this problem: the name of image are
> 01--1-960305-0941-D-24258, 02--1-960409-0941-D-24759, etc...How do we
> open (simply open) all the image with this kind of name? For the remain
> of homework (analisys etc), the script is already written.
> We need some advice about this "name problem" from programmers expert
> (like David that is a "IDL guru" ;)) or programmer that has already
> dealt this problem.
Hi,
Is the concern is that your files don't have extensions? If so, then
rest easy if the images are standard format like TIFF, PNG, etc.
I created a TIFF and saved it without an extension. IDL (6.3) read it
back in without a hitch.
IDL> image = read_image('/Users/ben/12--345-67')
IDL> help, image
IMAGE BYTE = Array[406, 408]
Does that help?
cheers,
Ben
|
|
|
Re: open and save a set of image [message #51541 is a reply to message #51397] |
Tue, 21 November 2006 07:36  |
Paul Van Delst[1]
Messages: 1157 Registered: April 2002
|
Senior Member |
|
|
cecilia.devecchi@gmail.com wrote:
> We have a set of hdf files about wind field. We extract these data of
> an area on the Mediterranean Sea.
> We extract these data and we write them in a *.txt file with the
> following lines:
>
> fileout= 'C:\QS' + name + '.txt'
> print,' OUTPUT FILE: ',fileout
> openw,2,/get_lun, fileout
> printf, 2, 'ASCENDING PASS (DAYTIME)'
> printf, 2, ' LON LAT SPD U V SPD2 COUNT
> TIME
> etc....
> ....
> close, 2
>
> With these lines, we succed to pass every file, but we succed to write
> in txt only the first file :
Only the first file? Or the last file?
>
> file_array=file_search('C:\QS\',$
> '*.200*', count=num_file)
> for i=0, num_file-1 do begin
> filename=file_array(i)
> print, filename
> openr, lun, /get_lun, filename
>
> ;read, analisys so the lines that we found above
> fileout= 'C:\QS' + name + '.txt'
> print,' OUTPUT FILE: ',fileout
> openw,2,/get_lun, fileout
From your snippet, the name of the output file is the same for each input file. If this
is actually what you want, then you should either:
a) open the output file before the loop and close it after the loop, or
b) open the output file in the loop with the /append specifier.
And, BTW, if you use /get_lun in OPENW, you don't want the 2 in there. That is,
openw, 2, /get_lun, fileout
should be something like
openw, outfileid, fileout, /get_lun
Same for the printf statements. I'm assuming this is a transcription error in your post
rather than your actual code.
A short working version of the code in question, rather than incomplete snippets, may
shine more light on the actual problem.
cheers,
paulv
--
Paul van Delst Ride lots.
CIMSS @ NOAA/NCEP/EMC Eddy Merckx
Ph: (301)763-8000 x7748
Fax:(301)763-8545
|
|
|