0

I need to process MODIS ocean level 2 data and I obtained an external plugin for ENVI https://github.com/dawhite/EPOC/releases. Now, I want to batch process hundreds of images for which I modified the code like the following code. The code is running fine, but I have to select the input file every time. Can anyone please help me to make the program fully automatic? I really appreciate and thanks a lot for your help!

Pro OCL2convert

dir = 'C:\MODIS\'

CD, dir

; batch processing of level 2 ocean chlorophyll data


files=file_search('*.L2_LAC_OC.x.hdf', count=numfiles)

; this command will search for all files in the directory which end with 
; the specified one

counter=0 

; this is a counter that tells IDL which file is being read-starts at 0

While (counter LT numfiles) Do begin

; this command tells IDL to start a loop and to only finish when the counter 
; is equal to the number of files with the name specified

   name=files(counter)
   openr, 1, name

   proj = envi_proj_create(/utm, zone=40, datum='WGS-84')
   ps = [1000.0d,1000.0d]
   no_bowtie = 0 ;same as not setting the keyword
   no_msg = 1 ;same as setting the keyword

   ;OUTPUT CHOICES
   ;0 -> standard product only
   ;1 -> georeferenced product only
   ;2 -> standard and georeferenced products

   output_choice = 2

   ;RETURNED VALUES
   ;r_fid -> ENVI FID for the standard product, if requested
   ;georef_fid -> ENVI FID for the georeferenced product, if requested

   convert_oc_l2_data, fname=fname, output_path=output_path, $
      proj=proj, ps=ps, output_choice=output_choice, r_fid=r_fid, $
      georef_fid=georef_fid, no_bowtie=no_bowtie, no_msg=no_msg   

   print,'done!'
   close, 1
   counter=counter+1
Endwhile

End

veda905
  • 782
  • 2
  • 12
  • 32

1 Answers1

0

Not knowing what convert_oc_l2_data does (it appears to be a program you created, there is no public documentation for it), I would say that the problem might be that the out_path variable is not defined in the rest of your program.

veda905
  • 782
  • 2
  • 12
  • 32