Closed sidneymau closed 11 months ago
I noticed that the original flux type is preserved as SED._flux_type
. Using this to reconstruct the SED in the above methods works:
>>> galsim.SED(galsim._LookupTable(disk_sed._spec.getArgs(), np.array(disk_sed._spec.getVals())), disk_sed.wave_type, disk_sed._flux_type, disk_sed.redshift).calculateFlux(lsst_g)
0.04530669166489878
Per the above, changing https://github.com/GalSim-developers/GalSim/blob/releases/2.5/galsim/sed.py#L530 from
flux_type = self.flux_type
to
flux_type = self._flux_type
fixes the particular problem I'm seeing. With the change,
>>> (disk_sed).calculateFlux(lsst_g)
0.04530669166489878
>>> (disk_sed * 1).calculateFlux(lsst_g)
0.04530669166489878
>>> (disk_sed * disk).calculateFlux(lsst_g)
0.04530669166489878
When constructing an SED with a custom flux type via astropy units, the flux type appears to get improperly converted to
fnu
such that multiplying this SED mangles the units (e.g., when calling anySED.__mul__
method).This results in wrong fluxes
We can see that the flux type of the remade SED (even without applying any multiplicative factors) is the cause of this
whereas forcing the original flux type produces the correct value
Tested in GalSim Version 2.5.0