PRO CREATE_FAKE_MOD35, MOD021KM, MOD35, MOD35QA, OUTFILE ;+ ; Creates a fake MOD35 HDF file that can fool the McIDAS MOD35 ADDE server. ; The ADDE server reads only the following SDS arrays from a MOD35 HDF file: ; 'Latitude', 'Longitude', 'Cloud_Mask', 'Quality_Assurance' ; ; MOD021KM Name of input MOD021KM HDF file (from DAAC or IMAPP) ; MOD35 Name of input MOD35 binary file (from DB version of cloud mask) ; MOD35QA Name of input MOD35QA binary file (from DB version of cloud mask) ; OUTFILE Name of output MOD35 HDF file (fake version) ;- ;- Check arguments if (n_elements(mod021km) eq 0) then message, 'Argument MOD021KM is undefined' if (n_elements(mod35) eq 0) then message, 'Argument MOD35 is undefined' if (n_elements(mod35qa) eq 0) then message, 'Argument MOD35QA 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 cloud mask data from the MOD35 image file openr, lun, mod35, /get_lun mask = bytarr(nx, ny, 6) readu, lun, mask free_lun, lun ;- Get the quality assurance data from the MOD35QA image file openr, lun, mod35qa, /get_lun maskqa = bytarr(nx, ny, 10) readu, lun, maskqa free_lun, lun ;- Rearrange the quality assurance data in the required order maskqa = transpose(maskqa, [2, 0, 1]) ;------------------------------------------------------------------------------- ; 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 cloud mask varid = hdf_sd_create(hdfid, 'Cloud_Mask', size(mask, /dimensions), /byte) hdf_sd_adddata, varid, mask hdf_sd_attrset, varid, 'units', 'none' hdf_sd_attrset, varid, 'scale_factor', 1.0d0, /double hdf_sd_attrset, varid, 'add_offset',0.0d0, /double hdf_sd_attrset, varid, 'valid_range', [0, 377], /byte hdf_sd_attrset, varid, '_FillValue', 0, /byte hdf_sd_endaccess, varid ;- Write the quality assurance varid = hdf_sd_create(hdfid, 'Quality_Assurance', size(maskqa, /dimensions), /byte) hdf_sd_attrset, varid, 'units', 'none' hdf_sd_attrset, varid, 'scale_factor', 1.0d0, /double hdf_sd_attrset, varid, 'add_offset',0.0d0, /double hdf_sd_attrset, varid, 'valid_range', [0, 377], /byte hdf_sd_attrset, varid, '_FillValue', 0, /byte hdf_sd_adddata, varid, maskqa hdf_sd_endaccess, varid ;- Close the output HDF file hdf_sd_end, hdfid END