FUNCTION GET_BAND_INDEX, HDFID, SDS_NAME, BAND ;- Get the index of the requested band in the corresponding MODIS 1 km SDS ;- Get the list of band numbers for this SDS array att_info = hdf_sd_attinfo(hdfid, sds_name, 'band_names') if (att_info.name eq '') then message, 'Attribute not found: band_names' band_list = str_sep(att_info.data, ',') ;- Convert the requested band number to a string band_name = strcompress(string(band), /remove_all) ;- Get the index of the band band_index = (where(band_name eq band_list))[0] if (band_index lt 0) then message, 'Requested band number was not found' ;- Return band index to caller return, band_index END