PRO CREATE_WVNIR_HDF, MOD021KM, WVNIR_BIN, WVNIR_HDF ;+ ; Creates a fake near-infrared water vapor HDF file ; ; MOD021KM Name of input MOD021KM HDF file (from DAAC or IMAPP) ; WVNIR_BIN Name of input water vapor nir binary file (from DB software) ; WVNIR_HDF Name of output water vapor nir HDF file ; ;- ; Program originally written by Kathy Strabala 10/13/2004 ; ;- Check arguments if (n_elements(mod021km) eq 0) then message, 'Argument MOD021KM is undefined' if (n_elements(wvnir_bin) eq 0) then message, 'Argument input WVNIR_BIN is undefined' if (n_elements(wvnir_hdf) eq 0) then message, 'Argument output WVNIR_HDF 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, (wvnir_bin), /get_lun wvnir = fltarr(nx, ny) readu, lun, wvnir free_lun, lun ;------------------------------------------------------------------------------- ; WRITE OUTPUT ;------------------------------------------------------------------------------- ;- Open the output HDF file hdfid = hdf_sd_start(wvnir_hdf, /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 near infrared water vapor array varid = hdf_sd_create(hdfid, 'Water_Vapor_Direct_Broadcat_Near_Infrared', size(wvnir, /dimensions), /float) hdf_sd_adddata, varid, wvnir hdf_sd_attrset, varid, 'units', 'kg/m2' hdf_sd_attrset, varid, 'scale_factor', 1.0d0, /double hdf_sd_attrset, varid, 'add_offset', 0.0d0, /double hdf_sd_attrset, varid, '_FillValue', -1.0, /float hdf_sd_endaccess, varid ;- Close the output HDF file hdf_sd_end, hdfid END