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

Home » Public Forums » archive » Re: RE trying to export pixel data from .dat files, based on coordinate loc
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: RE trying to export pixel data from .dat files, based on coordinate loc [message #71681 is a reply to message #71680] Tue, 13 July 2010 11:40 Go to previous message
Snow53 is currently offline  Snow53
Messages: 32
Registered: July 2010
Member
Ok, I modified the code to just run off IDL (not calling ENVI) to get
around the need for .hdr and everything is working, but with one
problem. It runs great with up to six files. but then runs out of
luns after that. I'm wondering if the problem lies in the file array
(since 1000 files are named in the array). Any advice for how to fix
this problem?

Thanks once again.


pro extractpixel_2


;define path
cd, 'X:\MERRA\HDF_Output_Lena\Surf_Pressure\'

;open first envi file, with associated .hdr, and gets pixel
coordinates based on user input geographic lat long coordinates.

envi_open_file, 'Surf_MERRA300.prod.assim.tavg1_2d_flx_Nx.
20030101.SUB.dat', r_fid=fid, /NO_REALIZE


;convert x,y map coordinates to corresponding pixel coordinates. note
that xmap and ymap can be single values or arrays if
;needed to extract info for multiple pixels.
XMap=[126.30]
YMap=[72.22]

ENVI_CONVERT_FILE_COORDINATES, fid,XF, YF, XMap, YMap

XF_out=Round(XF)
YF_out=Round(YF)
;print, 'x pix' ,XF_out ; use this to check output location
coordinates. remember that IDL starts at 0,0 for map coordinates,
while envi uses 1,1.
;print, 'y pix', YF_out
envi_file_mng, delete
;generates a list of the .dat files in the folder
file_array=file_search('*.dat', count=num_file)
file=file_array

print, num_file
;print, file

; loops through and extracts pixel data based on the above-determined
pixel location.
for i=0, num_file-1 do begin
data_array = fltarr(89, 56, 1)
openr, lun1, file[i], /get_lun
readu, lun1, data_array
close, lun1
free_lun, lun1


pixel = data_array[XF_out, YF_out, 0]

;open text file to write data to. modify this to use write_csv
(although this can only write 8 colums-decide if this might be
;problem for future application.
OPENU, U, 'Lena_surf_pressure.csv', /get_lun, /append
;write data
printf, U, pixel
;close LUN
close, U

endfor
end
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Selective Convolution
Next Topic: FITS IO Problem

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

Current Time: Sat Oct 11 06:44:35 PDT 2025

Total time taken to generate the page: 0.80166 seconds