PRO CREATE_FAKE_MOD04, MOD021KM, MOD04, OUTFILE ;+ ; Creates a fake MOD04 HDF file that can fool the McIDAS ADDE server. ; The ADDE server reads only the following dimension sizes from the: ; 'Latitude', 'Longitude', SDS's ; ; MOD021KM Name of input MOD021KM HDF file (from DAAC or IMAPP) ; MOD04 Name of input MOD04 binary file (from DB version of aerosol code) ; OUTFILE Name of output MOD04 HDF file (fake version) ; ;- ; Program originally written by Kathy Strabala 12 August 2004 ; ;- Check arguments if (n_elements(mod021km) eq 0) then message, 'Argument MOD021KM is undefined' if (n_elements(mod04) eq 0) then message, 'Argument input MOD04 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 ;- Get the number of pixels and lines dims = size(lat, /dimensions) nx = 135 ny = dims[1] * 5L ny = ny/10 ;- Get the profiles data from the flat file openr, lun, mod04, /get_lun aerosol = fltarr(nx, 14, ny) readu, lun, aerosol free_lun, lun ;- Latitude array lat=fltarr(nx,1,ny) lat = aerosol(*,0,*) lat1 = reform(lat,nx,ny) loc=where(lat1 lt -300.0, count) if count gt 0 then lat1(loc) = -999.0 ;- Longitude array lon=fltarr(nx,1,ny) lon = aerosol(*,1,*) lon1 = reform(lon,nx,ny) loc=where(lon1 lt -300.0, count) if count gt 0 then lon1(loc) = -999.0 ;- Aerosol Optical Depth Array ao=intarr(nx,1,ny) ao = round(aerosol(*,2,*) * 1000.0 ) aot = reform(ao,nx,ny) loc=where(aot eq -327680, count) if count gt 0 then aot(loc) = -9999 ;- Optical Depth Ratio ad=intarr(nx,1,ny) ad = round(aerosol(*,3,*) * 1000.0 ) adr = reform(ad,nx,ny) loc=where(adr eq -327680, count) if count gt 0 then adr(loc) = -9999 ;- Corrected Optical Depth Over Land cod = intarr(nx,3,ny) for i = 0 , 2, 1 do begin j = 4 + i cod(*,i,*) = round(aerosol(*,j,*) ) endfor loc=where(cod eq -328, count) for i = 0 , 2, 1 do begin j = 4 + i cod(*,i,*) = round(aerosol(*,j,*) * 1000.0 ) endfor if count gt 0 then cod(loc) = -9999 ;- Rearrange Array cod_trans=transpose(cod,[0,2,1]) ;- Effective Optical Depth Ocean eod = intarr(nx,7,ny) for i = 0 , 6, 1 do begin j = 7 + i eod(*,i,*) = round(aerosol(*,j,*) ) endfor loc=where(eod eq -328, count) for i = 0 , 6, 1 do begin j = 7 + i eod(*,i,*) = round(aerosol(*,j,*) * 1000.0 ) endfor if count gt 0 then eod(loc) = -9999 ;- Rearrange Array eod_trans=transpose(eod,[0,2,1]) ;------------------------------------------------------------------------------- ; WRITE OUTPUT ;------------------------------------------------------------------------------- ;- Open the output HDF file hdfid = hdf_sd_start(outfile, /create) ;- Write the profiles SDS's varid = hdf_sd_create(hdfid, 'Latitude', [nx, ny], /float) hdf_sd_adddata, varid, lat1 hdf_sd_attrset, varid, 'units', 'Degrees_north' hdf_sd_attrset, varid, 'scale_factor', 1.0d, /double hdf_sd_attrset, varid, 'add_offset', 0.d0, /double hdf_sd_attrset, varid, 'valid_range', [-90.0, 90.0], /float hdf_sd_attrset, varid, '_FillValue', -999.0, /float hdf_sd_endaccess, varid ;- Write the profiles SDS's varid = hdf_sd_create(hdfid, 'Longitude', [nx, ny], /float) hdf_sd_adddata, varid, lon1 hdf_sd_attrset, varid, 'units', 'Degrees_east' hdf_sd_attrset, varid, 'scale_factor', 1.0d, /double hdf_sd_attrset, varid, 'add_offset', 0.d0, /double hdf_sd_attrset, varid, 'valid_range', [-180.0, 180.0], /float hdf_sd_attrset, varid, '_FillValue', -999.0, /float hdf_sd_endaccess, varid ;- Write the profiles SDS's varid = hdf_sd_create(hdfid, 'Optical_Depth_Land_And_Ocean', [nx, ny], /short) hdf_sd_adddata, varid, aot hdf_sd_attrset, varid, 'units', 'none' hdf_sd_attrset, varid, 'scale_factor', .001d0, /double hdf_sd_attrset, varid, 'add_offset', 0.d0, /double hdf_sd_attrset, varid, 'valid_range', [0, 5000], /short hdf_sd_attrset, varid, '_FillValue', -9999, /short hdf_sd_endaccess, varid ;- Write the profiles SDS's varid = hdf_sd_create(hdfid, 'Optical_Depth_Ratio_Small_Land_And_Ocean', [nx, ny], /short) hdf_sd_adddata, varid, adr hdf_sd_attrset, varid, 'units', 'none' hdf_sd_attrset, varid, 'scale_factor', .001d0, /double hdf_sd_attrset, varid, 'add_offset', 0.d0, /double hdf_sd_attrset, varid, 'valid_range', [0, 1000], /short hdf_sd_attrset, varid, '_FillValue', -9999, /short hdf_sd_endaccess, varid varid = hdf_sd_create(hdfid, 'Corrected_Optical_Depth_Land', size(cod_trans, /dimensions), /short) hdf_sd_adddata, varid, cod_trans hdf_sd_attrset, varid, 'units', 'none' hdf_sd_attrset, varid, 'scale_factor', .001d0, /double hdf_sd_attrset, varid, 'add_offset', 0.d0, /double hdf_sd_attrset, varid, 'valid_range', [0, 5000], /short hdf_sd_attrset, varid, '_FillValue', -9999, /short hdf_sd_endaccess, varid varid = hdf_sd_create(hdfid, 'Effective_Optical_Depth_Average_Ocean', size(eod_trans, /dimensions), /short) hdf_sd_adddata, varid, eod_trans hdf_sd_attrset, varid, 'units', 'none' hdf_sd_attrset, varid, 'scale_factor', .001d0, /double hdf_sd_attrset, varid, 'add_offset', 0.d0, /double hdf_sd_attrset, varid, 'valid_range', [0, 5000], /short hdf_sd_attrset, varid, '_FillValue', -9999, /short hdf_sd_endaccess, varid ;- Close the output HDF file hdf_sd_end, hdfid END