PRO CREATE_FAKE_MOD07, MOD021KM, MOD07, OUTFILE ;+ ; Creates a fake MOD07 HDF file that can fool the McIDAS ADDE server. ; The ADDE server reads only the following SDS arrays from a MOD07 HDF file: ; 'Latitude', 'Longitude', 'PARAMETER' ; ; MOD021KM Name of input MOD021KM HDF file (from DAAC or IMAPP) ; MOD07 Name of input MOD07 binary file (from DB version of profiles) ; OUTFILE Name of output MOD07 HDF file (fake version) ; ;- ; Program originally written by Kathy Strabala 8/30/2002 ; ;- Check arguments if (n_elements(mod021km) eq 0) then message, 'Argument MOD021KM is undefined' if (n_elements(mod07) eq 0) then message, 'Argument input MOD07 is undefined' if (n_elements(outfile) eq 0) then message, 'Argument OUTFILE is undefined' ;------------------------------------------------------------------------------- ; READ INPUT ;------------------------------------------------------------------------------- ;- Read the lat/lon data from the MOD021KM file hdfid = hdf_sd_start(mod021km) hdf_sd_varread, hdfid, 'Latitude', lat hdf_sd_varread, hdfid, 'Longitude', lon hdf_sd_end, hdfid ;- Remove the last value from each row lat = lat[0:269, *] lon = lon[0:269, *] ;- Get the number of pixels and lines dims = size(lat, /dimensions) nx = 1354 ny = dims[1] * 5L ;- Get the profiles data from the flat file openr, lun, mod07, /get_lun ctp = fltarr(nx/5, 83, ny/5) readu, lun, ctp free_lun, lun bt=intarr(nx/5,12,ny/5) for i = 0 , 11, 1 do begin bt(*,i,*) = round(ctp(*,i,*) * 100. - 15000. ) endfor ;- Rearrange Brightness Temperature array loc=where(bt eq 17768, count) if count gt 0 then bt(loc) = -32768 brite=transpose(bt,[0,2,1]) ;- Surface Temperature sfctemp=intarr(nx/5,1,ny/5) sfctemp=round(ctp(*,12,*) * 100. - 15000. ) sfct=reform(sfctemp,nx/5,ny/5) loc=where(sfct eq -47768, count) if count gt 0 then sfct(loc) = -32768 ;- Surface Pressure sfcpres=intarr(nx/5,1,ny/5) sfcpres=round(ctp(*,13,*) * 10.) sfcp=reform(sfcpres,nx/5,ny/5) loc=where(sfcp lt 0, count) if count gt 0 then sfcp(loc) = -32768 ;- Surface Elevation ;- Note: you will have a fill value in place of the actual ;- value if the elevation turns out to be -328 m. This ;- should be the only time there is a problem. sfcelev=intarr(nx/5,1,ny/5) sfcelev=round(ctp(*,14,*)) sfc_elev=reform(sfcelev,nx/5,ny/5) loc=where(sfc_elev eq -328, count) if count gt 0 then sfc_elev(loc) = -32768 ;- Retrieved Temperature Profile rett=intarr(nx/5,20,ny/5) for i = 0 , 19, 1 do begin j = 15 + i rett(*,i,*) = round(ctp(*,j,*) * 100. - 15000. ) endfor loc=where(rett eq 17768, count) if count gt 0 then rett(loc) = -32768 ;- Rearrange Array ret_temp=transpose(rett,[0,2,1]) ;- Retrieved Moisture Profile retm=intarr(nx/5,20,ny/5) for i = 0 , 19, 1 do begin j = 35 + i retm(*,i,*) = round(ctp(*,j,*) * 100. - 15000. ) endfor loc=where(retm eq 17768, count) if count gt 0 then retm(loc) = -32768 ;- Rearrange Array ret_mois=transpose(retm,[0,2,1]) ;- Retrieved Height Profile reth=intarr(nx/5,20,ny/5) for i = 0 , 19, 1 do begin j = 55 + i reth(*,i,*) = round(ctp(*,j,*) - 32500. ) endfor loc=where(reth eq 32708, count) if count gt 0 then reth(loc) = -32768 ;- Rearrange Array ret_height=transpose(reth,[0,2,1]) ;- Total Ozone toz=intarr(nx/5,1,ny/5) toz=round(ctp(*,75,*) * 10. ) tot_oz=reform(toz,nx/5,ny/5) loc=where(tot_oz lt 0, count) if count gt 0 then tot_oz(loc) = -32768 ;- Total Totals tt=intarr(nx/5,1,ny/5) tt=round(ctp(*,76,*) * 100. ) totals=reform(tt,nx/5,ny/5) loc=where(totals lt 0, count) if count gt 0 then totals(loc) = -32768 ;- Lifted Index li=intarr(nx/5,1,ny/5) li=round(ctp(*,77,*) * 100. ) lift=reform(li,nx/5,ny/5) loc=where(lift lt -2000, count) if count gt 0 then lift(loc) = -32768 ;- K Index ki=intarr(nx/5,1,ny/5) ki=round(ctp(*,78,*) * 100. ) kindex=reform(ki,nx/5,ny/5) loc=where(kindex lt 0, count) if count gt 0 then kindex(loc) = -32768 ;- Total column WV twv=intarr(nx/5,1,ny/5) twv=round(ctp(*,79,*) * 1000. ) totwv=reform(twv,nx/5,ny/5) loc=where(totwv lt 0, count) if count gt 0 then totwv(loc) = -9999 ;- Direct WV dwv=intarr(nx/5,1,ny/5) dwv=round(ctp(*,80,*) * 1000. ) dirwv=reform(dwv,nx/5,ny/5) loc=where(dirwv lt 0, count) if count gt 0 then dirwv(loc) = -9999 ;- Water Vapor Low lwv=intarr(nx/5,1,ny/5) lwv=round(ctp(*,81,*) * 1000. ) wv_low=reform(lwv,nx/5,ny/5) loc=where(wv_low lt 0, count) if count gt 0 then wv_low(loc) = -9999 ;- Water Vapor Low hwv=intarr(nx/5,1,ny/5) hwv=round(ctp(*,82,*) * 1000. ) wv_high=reform(hwv,nx/5,ny/5) loc=where(wv_high lt 0, count) if count gt 0 then wv_high(loc) = -9999 ;------------------------------------------------------------------------------- ; WRITE OUTPUT ;------------------------------------------------------------------------------- ;- Open the output HDF file hdfid = hdf_sd_start(outfile, /create) ;- Write the latitude varid = hdf_sd_create(hdfid, 'Latitude', size(lat, /dimensions), /float) hdf_sd_adddata, varid, lat hdf_sd_endaccess, varid ;- Write the longitude varid = hdf_sd_create(hdfid, 'Longitude', size(lon, /dimensions), /float) hdf_sd_adddata, varid, lon hdf_sd_endaccess, varid ;- Write the profiles SDS's varid = hdf_sd_create(hdfid, 'Brightness_Temperature', size(brite, /dimensions), /int) hdf_sd_adddata, varid, brite hdf_sd_attrset, varid, 'units', 'K' hdf_sd_attrset, varid, 'scale_factor', .01d0, /double hdf_sd_attrset, varid, 'add_offset', -15000., /double hdf_sd_attrset, varid, 'valid_range', [0, 20000], /short hdf_sd_attrset, varid, '_FillValue', -32768, /short hdf_sd_endaccess, varid varid = hdf_sd_create(hdfid, 'Surface_Temperature', size(sfct, /dimensions), /int) hdf_sd_adddata, varid, sfct hdf_sd_attrset, varid, 'units', 'K' hdf_sd_attrset, varid, 'scale_factor', .01d0, /double hdf_sd_attrset, varid, 'add_offset', -15000., /double hdf_sd_attrset, varid, 'valid_range', [0, 20000], /short hdf_sd_attrset, varid, '_FillValue', -32768, /short hdf_sd_endaccess, varid varid = hdf_sd_create(hdfid, 'Surface_Pressure', size(sfcp, /dimensions), /int) hdf_sd_adddata, varid, sfcp hdf_sd_attrset, varid, 'units', 'hPa' hdf_sd_attrset, varid, 'scale_factor', .1d0, /double hdf_sd_attrset, varid, 'add_offset', 0.0, /double hdf_sd_attrset, varid, 'valid_range', [8000, 11000], /short hdf_sd_attrset, varid, '_FillValue', -32768, /short hdf_sd_endaccess, varid varid = hdf_sd_create(hdfid, 'Surface_Elevation', size(sfc_elev, /dimensions), /int) hdf_sd_adddata, varid, sfc_elev hdf_sd_attrset, varid, 'units', 'm' hdf_sd_attrset, varid, 'scale_factor', 1.0d0, /double hdf_sd_attrset, varid, 'add_offset', 0.0, /double hdf_sd_attrset, varid, 'valid_range', [-400, 8840], /short hdf_sd_attrset, varid, '_FillValue', -32768, /short hdf_sd_endaccess, varid varid = hdf_sd_create(hdfid, 'Retrieved_Temperature_Profile', size(ret_temp, /dimensions), /int) hdf_sd_adddata, varid, ret_temp hdf_sd_attrset, varid, 'units', 'K' hdf_sd_attrset, varid, 'scale_factor', 0.01d0, /double hdf_sd_attrset, varid, 'add_offset', -15000.0, /double hdf_sd_attrset, varid, 'valid_range', [0, 20000], /short hdf_sd_attrset, varid, '_FillValue', -32768, /short hdf_sd_endaccess, varid varid = hdf_sd_create(hdfid, 'Retrieved_Moisture_Profile', size(ret_mois, /dimensions), /int) hdf_sd_adddata, varid, ret_mois hdf_sd_attrset, varid, 'units', 'K' hdf_sd_attrset, varid, 'scale_factor', 0.01d0, /double hdf_sd_attrset, varid, 'add_offset', -15000.0, /double hdf_sd_attrset, varid, 'valid_range', [0, 20000], /short hdf_sd_attrset, varid, '_FillValue', -32768, /short hdf_sd_endaccess, varid varid = hdf_sd_create(hdfid, 'Retrieved_Height_Profile', size(ret_height, /dimensions), /int) hdf_sd_adddata, varid, ret_height hdf_sd_attrset, varid, 'units', 'm' hdf_sd_attrset, varid, 'scale_factor', 1.0d0, /double hdf_sd_attrset, varid, 'add_offset', -32500.0, /double hdf_sd_attrset, varid, 'valid_range', [-32500, 32500], /short hdf_sd_attrset, varid, '_FillValue', -32768, /short hdf_sd_endaccess, varid varid = hdf_sd_create(hdfid, 'Total_Ozone', size(tot_oz, /dimensions), /int) hdf_sd_adddata, varid, tot_oz hdf_sd_attrset, varid, 'units', 'Dobson' hdf_sd_attrset, varid, 'scale_factor', 0.1d0, /double hdf_sd_attrset, varid, 'add_offset', 0.0, /double hdf_sd_attrset, varid, 'valid_range', [0, 5000], /short hdf_sd_attrset, varid, '_FillValue', -32768, /short hdf_sd_endaccess, varid varid = hdf_sd_create(hdfid, 'Total_Totals', size(totals, /dimensions), /int) hdf_sd_adddata, varid, totals hdf_sd_attrset, varid, 'units', 'K' hdf_sd_attrset, varid, 'scale_factor', 0.01d0, /double hdf_sd_attrset, varid, 'add_offset', 0.d0, /double hdf_sd_attrset, varid, 'valid_range', [0, 8000], /short hdf_sd_attrset, varid, '_FillValue', -32768, /short hdf_sd_endaccess, varid varid = hdf_sd_create(hdfid, 'Lifted_Index', size(lift, /dimensions), /int) hdf_sd_adddata, varid, lift hdf_sd_attrset, varid, 'units', 'K' hdf_sd_attrset, varid, 'scale_factor', 0.01d0, /double hdf_sd_attrset, varid, 'add_offset', 0.0d0, /double hdf_sd_attrset, varid, 'valid_range', [-2000, 4000], /short hdf_sd_attrset, varid, '_FillValue', -32768, /short hdf_sd_endaccess, varid varid = hdf_sd_create(hdfid, 'K_Index', size(kindex, /dimensions), /int) hdf_sd_adddata, varid, kindex hdf_sd_attrset, varid, 'units', 'K' hdf_sd_attrset, varid, 'scale_factor', 0.01d0, /double hdf_sd_attrset, varid, 'add_offset', 0.0d0, /double hdf_sd_attrset, varid, 'valid_range', [-500, 6500], /short hdf_sd_attrset, varid, '_FillValue', -32768, /short hdf_sd_endaccess, varid varid = hdf_sd_create(hdfid, 'Water_Vapor', size(totwv, /dimensions), /int) hdf_sd_adddata, varid, totwv hdf_sd_attrset, varid, 'units', 'cm' hdf_sd_attrset, varid, 'scale_factor', 0.001d0, /double hdf_sd_attrset, varid, 'add_offset', 0.0d0, /double hdf_sd_attrset, varid, 'valid_range', [0, 20000], /short hdf_sd_attrset, varid, '_FillValue', -9999, /short hdf_sd_endaccess, varid varid = hdf_sd_create(hdfid, 'Water_Vapor_Direct', size(dirwv, /dimensions), /int) hdf_sd_adddata, varid, dirwv hdf_sd_attrset, varid, 'units', 'cm' hdf_sd_attrset, varid, 'scale_factor', 0.001d0, /double hdf_sd_attrset, varid, 'add_offset', 0.0d0, /double hdf_sd_attrset, varid, 'valid_range', [0, 20000], /short hdf_sd_attrset, varid, '_FillValue', -9999, /short hdf_sd_endaccess, varid varid = hdf_sd_create(hdfid, 'Water_Vapor_Low', size(wv_low, /dimensions), /int) hdf_sd_adddata, varid, wv_low hdf_sd_attrset, varid, 'units', 'cm' hdf_sd_attrset, varid, 'scale_factor', 0.001d0, /double hdf_sd_attrset, varid, 'add_offset', 0.0d0, /double hdf_sd_attrset, varid, 'valid_range', [0, 20000], /short hdf_sd_attrset, varid, '_FillValue', -9999, /short hdf_sd_endaccess, varid varid = hdf_sd_create(hdfid, 'Water_Vapor_High', size(wv_high, /dimensions), /int) hdf_sd_adddata, varid, wv_high hdf_sd_attrset, varid, 'units', 'cm' hdf_sd_attrset, varid, 'scale_factor', 0.001d0, /double hdf_sd_attrset, varid, 'add_offset', 0.0d0, /double hdf_sd_attrset, varid, 'valid_range', [0, 20000], /short hdf_sd_attrset, varid, '_FillValue', -9999, /short hdf_sd_endaccess, varid ;- Close the output HDF file hdf_sd_end, hdfid END