Hi, I am trying to develop a script which will obtain AVHRR sensor viewing angle. In ENVI this would be the AVHRR Geometry tool. Unfortunately I run into error messages when I try to automate this in IDL using the envi_avhrr_geometry_doit command. Specifically the error states: 'Variable is undefined: WL' however the 'WL variable is not explained within the tool documentation.
I am fairly new to IDL scripting so I am sure I am making a simple mistake somewhere but any advice you can offer would be great!
pro Test_geometry
envi, /restore_base_save_files
; create ENVI map projection structure
;
forward_function envi_proj_units_translate, $
envi_proj_create
; define in/output folder location ;
; ;
;---------------------------------------------------------;
in_folder = 'C:\Users\ajh13\Documents\Newcastle\_AVHRR_xfer\M2_day\'
file_mkdir, in_folder + 'IDL_Processed\'
out_folder = in_folder + 'IDL_Processed\'
; initialise envi batch
;
envi_batch_init, batch_lun = batch_unit, $
log_file= out_folder+ 'IDL_processed_files.txt'
;use file_search to list available files in the input directory
;
print, 'Search for files...'
files = file_search(in_folder + '*.*', count=count)
printf, batch_unit, 'Number of files found: ',count
for i=0, count-1 do begin
print, 'Initiate batch...'
;print a message to the batch log file
printf, batch_unit, 'Processing file ' + files[i] + ' at ' + systime()
; ---------------------------------------------------------------------------------------------
; Open the origninal avhrr file, variable labelled as fid_avhrr
;----------------------------------------------------------------------------------------------
print, 'Open image...'
envi_open_data_file, files[i], r_fid=fid_avhrr, /avhrr
; Set the keywords using fid_avhrr including filename for setting output name
; for eventual calibrated and warped image set output to be calibrated
;
envi_file_query, fid_avhrr, dims=dims, nb=nb, sname = avhrr_filename
pos = lindgen(nb)
; define output name
out_name = out_folder + 'test_geo'
print, 'Derive sensor viewing angle...'
; execute tool for deriving sensor viewing angle
envi_doit, 'envi_avhrr_geometry_doit', $
dims=dims, fid=fid_avhrr, method=3, out_dt=4, $
out_name=out_name, wl=1, r_fid=fid_geometry
; -----------------------------------------------------------------------------------------------
; now warp the viewing angle image
;
out_name = out_folder + avhrr_filename
data_type = strmid(avhrr_filename, 4,4)
proj = envi_proj_create(/geographic)
if (data_type eq 'LHRR') or (data_type eq 'HRPT')or (data_type eq 'FRAC') then begin
ps=[0.01183037,0.00991774] ; 1.1 km
endif else begin
ps=[0.04743667,0.03966959] ; 4.4 km
endelse
;
;repeat the warp for the sensor angle image
;with a background value of 999 (i.e. above 40)
;
print, 'Warp viewing angle image...'
envi_doit, 'envi_avhrr_warp_doit', $
avhrr_fid=fid_avhrr, background=-999, dims=dims, fid=fid_geometry, $
grid=[50,50], method=6, out_name=out_name, pixel_size=ps, pos=[0], $
proj=proj, r_fid=r_fid_geometry_warp
endfor
print, 'Finish script.'
;print finished message to batch log
printf, batch_unit, 'Finished batch process at '+systime()
; exit envi/idl to ensure messages are written to log
envi_batch_exit
end
Many thanks.
|