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 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: RE trying to export pixel data from .dat files, based on coordinate loc [message #71678] Tue, 13 July 2010 12:06
Snow53 is currently offline  Snow53
Messages: 32
Registered: July 2010
Member
On Jul 13, 12:53 pm, Paulo Penteado <pp.pente...@gmail.com> wrote:
> On Jul 13, 3:50 pm, Paulo Penteado <pp.pente...@gmail.com> wrote:
>
>> On Jul 13, 3:40 pm, Snow53 <jennifer_wa...@hotmail.com> wrote:
>
>>> 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?
>
>> The pool of luns is small. As your code is, you are getting a new lun
>> from the pool at every file open, but not giving it back when done.
>> Just replace the "close,u" with a "free_lun,u".
>
> To be more clear: close only closes the file, it does not release the
> lun. Free_lun does both (so it is redundant to call both close and
> free_lun).

thanks. it's working great now.
Re: RE trying to export pixel data from .dat files, based on coordinate loc [message #71679 is a reply to message #71678] Tue, 13 July 2010 11:53 Go to previous message
penteado is currently offline  penteado
Messages: 866
Registered: February 2018
Senior Member
Administrator
On Jul 13, 3:50 pm, Paulo Penteado <pp.pente...@gmail.com> wrote:
> On Jul 13, 3:40 pm, Snow53 <jennifer_wa...@hotmail.com> wrote:
>
>> 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?
>
> The pool of luns is small. As your code is, you are getting a new lun
> from the pool at every file open, but not giving it back when done.
> Just replace the "close,u" with a "free_lun,u".

To be more clear: close only closes the file, it does not release the
lun. Free_lun does both (so it is redundant to call both close and
free_lun).
Re: RE trying to export pixel data from .dat files, based on coordinate loc [message #71680 is a reply to message #71679] Tue, 13 July 2010 11:50 Go to previous message
penteado is currently offline  penteado
Messages: 866
Registered: February 2018
Senior Member
Administrator
On Jul 13, 3:40 pm, Snow53 <jennifer_wa...@hotmail.com> wrote:
> 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?

The pool of luns is small. As your code is, you are getting a new lun
from the pool at every file open, but not giving it back when done.
Just replace the "close,u" with a "free_lun,u".
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
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Selective Convolution
Next Topic: FITS IO Problem

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

Current Time: Wed Oct 08 11:43:39 PDT 2025

Total time taken to generate the page: 0.00584 seconds