GalSim-developers/GalSim — pull request #597 by jmeyers314 (2014-09-12 19:24:33+00:00)
Title: #596 SED.withFlux bug

This PR addresses two related bugs/issues in the `SED` class.

1. Previous SED transformations often used the pattern: `self._rest_photons = func(lambda w: self(w))`, i.e. replacing the rest frame spectrum (stored in the `_rest_photons` attribute) with some manipulation of the observed frame spectrum (accessed via the `__call__` method). This is generally wrong. Previous unit tests didn't catch this as they were often written assuming `redshift=0`.

The bugs have all been squashed, and the unit tests have been beefed up by generally not assuming that `redshift=0`, and a couple new SED unit tests have been added to check the `withFlux` and `withFluxDensity` methods. These new unit tests and new versions of old unit tests failed on the previous implementation of the `SED` class, but pass with the fixed `SED` class.

2. The `SED.__add__` function had some rather strange restrictions/effects in hindsight. One could add together SEDs of different redshifts, and the resulting SED would always have its redshift set to zero. The new version of `__add__` requires that the summands have the same redshift, and the resulting sum SED retains that redshift. Unit tests to check this enforcement have also been added.

-Josh