PRO READ_MODIS COMPILE_OPT IDL2 directory = 'G:/AOD MODIS/AQUA/products/' product = '*.hdf' sdsname = 'Optical_Depth_Land_And_Ocean' scale = 0.001 ;- Obtener una lista de los archivos de entrada list = file_search(directory + product) help, list ;- Establecer antigua fecha old_date = 'MYD04_L2.A9999273.1840' ;- Obtener la unidad del archivo de salida get_lun, lun ;- Bucle sobre los archivos de entrada for i = 0, n_elements(list) - 1 do begin ;- Obtener los nombres de los archivos input_file = list[i] print, input_file ;- Leer archivo de entrada hdfid = hdf_sd_start(input_file) hdf_sd_varread, hdfid, 'Latitude', lat hdf_sd_varread, hdfid, 'Longitude', lon hdf_sd_varread, hdfid, sdsname, data hdf_sd_end, hdfid ;- Aplicar el factor de escala data = data * scale ;- Obtener la fecha del archivo (ejm. 'MYD04_L2.A2015273') file_name = basename(input_file) date_length = strlen(old_date) new_date = strmid(file_name, 0, date_length) ;- Encontrar los datos validos loc = where(data gt 0.0, count) print, count ;- Guardar los datos validos if (count gt 0) then begin ;- Abrir un nuevo archivo de salida de ser necesario if (strmid(new_date,0,17) ne strmid(old_date,0,17)) then begin free_lun, lun output_file = 'G:/AOD MODIS/AQUA/out/'+new_date + '.dat' openw, lun, output_file, /get_lun old_date = new_date print, ' ' print, 'Abriendo nuevo archivo de salida', output_file endif ;- Guardar los datos validos en una tabla (lat, lon, data) table = fltarr(3, count) table[0, *] = lat[loc] table[1, *] = lon[loc] table[2, *] = data[loc] ;- Escribir el archivo de salida en formato binario print, 'Escribiendo data de ', input_file writeu, lun, table endif endfor END