;+NAME/ONE LINE DESCRIPTION OF ROUTINE: ; MKAERFILE_CROSS_SENSOR generates an MSl12 aerosol input file from an MSl12 output pro mkaerfile_cross_sensor,index,ifile,ofile,wl_in,wl_out intvals=0 if (n_elements(wl_in) ne 0 and n_elements(wl_out) ne 0) then begin intvals=1 endif ix = reform(index(0,*,*)) iy = reform(index(1,*,*)) sz = size(index) nx = sz(2) ny = sz(3) if (isHDF(ifile)) then begin taua = readl2hdf(ifile,'taua_') amin = rd_sds(ifile,'aer_model_min') amax = rd_sds(ifile,'aer_model_max') arat = rd_sds(ifile,'aer_model_ratio') endif else begin d = readl2(ifile) amin = d.aermodmin amax = d.aermodmax arat = d.aerratio sz = size(d.taua) taua = fltarr(sz(2),sz(3),sz(1)) for i=0,sz(1)-1 do begin taua(*,*,i) = reform(d.taua(i,*)) endfor endelse r = replicate( { amodmin:lonarr(nx), $ amodmax:lonarr(nx), $ amodrat:fltarr(nx), $ taua:fltarr(8,nx)}, ny) r.amodmin = amin(ix,iy) r.amodmax = amax(ix,iy) r.amodrat = arat(ix,iy) for i=0,7 do begin t = taua(*,*,i) & t = t(ix,iy) r.taua(i,*) = reform(t,1,nx,ny) endfor if (intvals) then begin print,'Interpolating AOT from: ',wl_in print,' to: ',wl_out for ix=0,nx-1 do for iy=0,ny-1 do begin v1 = reform(r(iy).taua(*,ix)) if (max(v1) gt 0.0) then begin v2 = spline(wl_in,v1,wl_out) r(iy).taua(*,ix) = v2 endif endfor endif len = str_len(r) hdr = {sensorID:0L,reclen:len,npix:nx,format:0L,nscans:ny, $ fill:bytarr(len-20)} openw,/get_lun,lun,ofile writeu,lun,hdr writeu,lun,r free_lun,lun return end