PRO WRITE_MODIS_RADIANCE, HDFID, BAND, DATA_TYPE, NCOL, NROW, DATA, RAW=RAW ;- Write a single band of MODIS L1B radiance data COMPILE_OPT IDL2 ;- Check arguments if (n_elements(hdfid) eq 0) then message, 'Argument HDFID is undefined' if (n_elements(band) eq 0) then message, 'Argument BAND is undefined' if (n_elements(data_type) eq 0) then message, 'Argument DATA_TYPE is undefined' if (n_elements(ncol) eq 0) then message, 'Argument NCOL is undefined' if (n_elements(nrow) eq 0) then message, 'Argument NROW is undefined' if (n_elements(data) eq 0) then message, 'Argument DATA is undefined' ;- Select the SDS sds_name = get_sds_name(band, data_type) varid = hdf_sd_select(hdfid, hdf_sd_nametoindex(hdfid, sds_name)) ;- Get the band index band_index = get_band_index(hdfid, sds_name, band) ;- Get the start and count vectors start = [0, 0, band_index] count = [ncol, nrow, 1] ;- Get the scales and offsets hdf_sd_attrinfo, varid, hdf_sd_attrfind(varid, 'radiance_scales'), data=scale hdf_sd_attrinfo, varid, hdf_sd_attrfind(varid, 'radiance_offsets'), data=offset ;- Convert radiances to scaled integers if (keyword_set(raw) eq 0) then begin scaled = uint((data / scale[band_index]) + offset[band_index] + 0.5) endif else begin scaled = data endelse ;- Write the scaled integers hdf_sd_adddata, varid, scaled, start=start, count=count ;- Deselect the SDS hdf_sd_endaccess, varid ;- If band 26, also write separate band 26 SDS if (band eq 26) then begin sds_name = 'EV_Band26' varid = hdf_sd_select(hdfid, hdf_sd_nametoindex(hdfid, sds_name)) start = [0, 0] count = [ncol, nrow] hdf_sd_adddata, varid, scaled, start=start, count=count hdf_sd_endaccess, varid endif END