PRO VIIRS_SDR_READ, FILE, DATA, RAW=RAW ;- 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, '_', /extract) product = result[0] satname = result[1] date = result[2] time = result[3] help, product, satname, date, time ;- Get band number from product name (e.g., SVM16 = band 16) band = long(strmid(product, 3, 2)) help, band ;- Set the visible (0) / infrared (1) type for M bands m_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']) help, group_name ;- Get the HDF5 dataset name if (m_type[band - 1] eq 0) then begin dataset_name = 'Reflectance' endif else begin dataset_name = 'BrightnessTemperature' endelse help, dataset_name ;- Read the data data_path = strjoin([group_name, '/', dataset_name]) help, data_path data_id = h5d_open(file_id, data_path) data = h5d_read(data_id) help, data h5d_close, data_id ;- Read the scaling factors data_path = strjoin([data_path, 'Factors']) help, data_path data_id = h5d_open(file_id, data_path) scale = h5d_read(data_id) help, scale h5d_close, data_id ;- Apply the scaling factors if RAW keyword is not set if (keyword_set(raw) eq 0) then data = data * scale[0] + scale[1] help, data ;- Close the file h5f_close, file_id END