def normalize_spectrum(spectrum):
''' Normalizes a spectrum to have unit peak within the visible band.
Args:
spectrum (`Spectrum`): object with iterable wavelength, value fields.
Returns:
`Spectrum`: new spectrum object.
'''
wvl, vals = spectrum['wvl'], spectrum['values']
low, high = np.searchsorted(wvl, 400), np.searchsorted(wvl, 700)
vis_values_max = vals[low:high].max()
return {
'wvl': wvl,
'values': vals / vis_values_max,
}
评论列表
文章目录