PRO VIIRS_SDR_READ, FILE, DATA, RAW=RAW, SCALE=SCALE ;- Read a VIIRS SDR HDF5 file (M band) ;- Check arguments if (n_elements(file) eq 0) then message, 'Argument FILE is undefined' ;- Open the file file_id = h5f_open(file) ;- Parse the filename result = strsplit(file_basename(file), '_', /extract) product = result[0] satname = result[1] date = result[2] begtime = result[3] endtime = result[4] ;- Get band number from product name (e.g., SVM16 = band 16) band = long(strmid(product, 3, 2)) ;- Set the band type for M bands (visible=0, infrared=1) band_type = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1] ;- Get the HDF5 group name group_name = strjoin(['/All_Data/VIIRS-M', strcompress(band, /remove_all), '-SDR_All']) ;- Get the HDF5 dataset name if (band_type[band - 1] eq 0) then begin dataset_name = 'Reflectance' endif else begin dataset_name = 'BrightnessTemperature' endelse ;- Read the data data_id = h5d_open(file_id, group_name + '/' + dataset_name) data = h5d_read(data_id) h5d_close, data_id ;- Read the scale factors data_id = h5d_open(file_id, group_name + '/' + dataset_name + 'Factors') scale = h5d_read(data_id) h5d_close, data_id ;- Apply the scaling factors if RAW keyword is not set if (keyword_set(raw) eq 0) then data = temporary(data) * scale[0] + scale[1] ;- Close the file h5f_close, file_id END