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

Home » Public Forums » archive » ASCII import
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: ASCII import [message #48186 is a reply to message #48095] Wed, 29 March 2006 07:16 Go to previous messageGo to previous message
lbusett@yahoo.it is currently offline  lbusett@yahoo.it
Messages: 30
Registered: February 2006
Member
Hi Marco,

What about something like this ?

pro multiple_conversion

; Define image dimensions

n_col = 2400L
n_row = 2400L
arr_dim = n_col*n_row
tmp_array = fltarr (arr_dim)

; Select Input Files

file_list = dialog_pickfile ( title = 'Select files to convert',
/multiple_files)

; Begin the for loop to convert each file

for file = 0, n_elements(file_list-1) do begin

openr, in_lun, file_list [file], /get_lun ; Open the file
readf, in_lun, tmp_array ; Store data in a temporary array

;"Create" a square image from tmp_array

tmp_image = reform (tmp_array, n_col,n_row)
out_filename = file_list[file] + '_envi' ; Define output file

; Write envi output file
ENVI_WRITE_ENVI_FILE, tmp_image, out_name=out_filename free_lun,
in_lun
endfor
end

I didn't test it, so it's possible that it doesn't work, but I think
that this is a possible approach: Just select the files that you need
to convert, then read one file at a time with a simple READF
instruction, "reform" the data into a square matrix and write an output
with the ENVI dedicated write function (ENVI_WRITE_ENVI_FILE). You just
have to be sure that there is no header in your .txt files: otherwise,
you have to skip the header lines before you read "tmp_array".

Hope this helps,

Lorenzo



none wrote:
> well jeff, thanks for your patience...
> the file is made of 5,760,000 numbers, resulting in an image of 2400
> columns * 2400 rows. the second number should be the pixel [0,1] and so
> on, till the number #2401 that becomes the pixel [1,1].
> thanks
> marco
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: map_set, !map, !x, !p.position (and behind this curtain, !x.*)
Next Topic: A New error msg, for me: % Variable is undefined: <UNDEFINED>

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

Current Time: Thu Oct 09 20:55:42 PDT 2025

Total time taken to generate the page: 0.88025 seconds