Ah, good question. I think you’re referring to cell 17 from solar_system_object_colors
# Limit the wavelength range for the sun, just to reduce warning messages
sun_limited = phot_utils.Sed()
idx = np.where((sun.wavelen > 299) & (sun.wavelen < 1105))
sun_limited.set_sed(wavelen=sun.wavelen[idx], flambda=sun.flambda[idx])
sun_limited.resample_sed(wavelen_match=lsst['g'].wavelen)
wavelen_step = np.unique(np.diff(lsst['g'].wavelen)).min()
obs_smass = {}
for k in smass:
smass[k].resample_sed(wavelen_match=lsst['g'].wavelen)
obs_smass[k] = smass[k].multiply_sed(sun_limited, wavelen_step=wavelen_step)
whereas in the PR I sent to you I just did this between cell 5 and 6 in CenColors
# read in solar spectrum and MATCH wavelengths for pholus sed
sun = phot_utils.Sed()
sun.read_sed_flambda(os.path.join(get_data_dir(), 'movingObjects', 'kurucz_sun.gz'))
# don't need to sub-select sun idxes, this will do fine.
sun.resample_sed(wavelen_match=phol_sed.wavelen)
# turn reflectance into sed and plot
# Looks like we have a bug, so set wavelen_step to side-step that .. sorry
phol_obs_sed = phol_sed.multiply_sed(sun, wavelen_step=0.1)
So … to be honest, I see warning messages in my notebook solar_system_object_colors after that cell … which are new and I didn’t notice when I reran it recently. (these errors could in fact be giving ME nans except that in a later cell I shortened the filter wavelength range which covered this problem!) and are the result of updates in Bandpass that changed how we read things in by default (compared to when I wrote the notebook in the first place). And if I wrote it now, I don’t think I’d do the subselect at all … I’d do this:
sun.resample_sed(wavelen_match=lsst['g'].wavelen)
obs_smass = {}
for k in smass:
smass[k].resample_sed(wavelen_match=lsst['g'].wavelen)
obs_smass[k] = smass[k].multiply_sed(sun_limited, wavelen_step=0.1)
which looks pretty similar to what’s in CenColors, right? (I should go update that notebook).
There is a slight difference that’s worth noting in terms of what is being used to define the resampled wavelengths. The version in CenColors is likely easier to read and more logical (resample the sun to match the reflectance spectra, then multiply them). You can then multiply the resulting spectra by whatever bandpass objects you have, even if they don’t have exactly the same wavelength range (as long as your SED completely overlaps all of them … J band colors, for example, if your SED goes into IR?)
The version in solar_system_object colors resampled both the sun and the reflectance spectra onto a third wavelength grid, the Bandpass and is a bit more specialized in that
you have to know that your Bandpass objects (if you’re calculating in multiple filters) will cover the same wavelength range and have the same wavelength gridding, and you need to know that these bandpasses are well sampled at a tight wavelength range. However, if you do know those things, it will be faster for use with multiple reflectance spectra, because you only resample the solar spectra once, only resample the reflectance spectra once per object, and since they all match the bandpass grid, there is no further resampling for calculating magnitudes.