PRO CREATE_FAKE_MOD28, MOD021KM, MOD28, OUTFILE ;+ ; Creates a fake MOD28 HDF file (SST) ; ; MOD021KM Name of input MOD021KM HDF file (from DAAC or IMAPP) ; MOD28 Name of input MOD28 binary SST file (from DB version of SST) ; OUTFILE Name of output MOD28 HDF file (fake version) ; ;- ; Program originally written by Kathy Strabala 1/15/2003 ; ;- Check arguments if (n_elements(mod021km) eq 0) then message, 'Argument MOD021KM is undefined' if (n_elements(mod28) eq 0) then message, 'Argument input MOD28 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 data from the flat file openr, lun, mod28, /get_lun sst = fltarr(nx, 12, ny) readu, lun, sst free_lun, lun ;- Sea Surface Temperature (11-12) sst1=intarr(nx,1,ny) sst1=round(sst(*,0,*) * 100.) sst11=reform(sst1,nx,ny) ;- Sea Surface Temperature (4 micron) sst2=intarr(nx,1,ny) sst2=round(sst(*,1,*) * 100.) sst4=reform(sst2,nx,ny) ;------------------------------------------------------------------------------- ; 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 remaining SDS's varid = hdf_sd_create(hdfid, 'Sea_Surface_Temperature', size(sst11, /dimensions), /int) hdf_sd_adddata, varid, sst11 hdf_sd_attrset, varid, 'units', 'C' hdf_sd_attrset, varid, 'scale_factor', .01d0, /double hdf_sd_attrset, varid, 'add_offset', 0.0d0, /double hdf_sd_attrset, varid, 'valid_range', [-5000, 5000], /short hdf_sd_attrset, varid, '_FillValue', -32768, /short hdf_sd_endaccess, varid varid = hdf_sd_create(hdfid, 'Sea_Surface_Temperature4', size(sst4, /dimensions), /int) hdf_sd_adddata, varid, sst4 hdf_sd_attrset, varid, 'units', 'C' hdf_sd_attrset, varid, 'scale_factor', .01d0, /double hdf_sd_attrset, varid, 'add_offset', 0.0d0, /double hdf_sd_attrset, varid, 'valid_range', [-5000, 5000], /short hdf_sd_attrset, varid, '_FillValue', -32768, /short hdf_sd_endaccess, varid ;- Close the output HDF file hdf_sd_end, hdfid END