Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion galsim/sed.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ def _mul_sed(self, other):
def _mul_bandpass(self, other):
"""Equivalent to self * other when other is a Bandpass"""
wave_list, blue_limit, red_limit = utilities.combine_wave_list(self, other)
zfactor = (1.0+self.redshift) / other.wave_factor
zfactor = (1.0+self.redshift) * other.wave_factor
if self.fast:
if (isinstance(self._fast_spec, LookupTable)
and not self._fast_spec.x_log
Expand Down
23 changes: 23 additions & 0 deletions tests/test_sed.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,29 @@ def test_SED_mul():
np.testing.assert_almost_equal((sed2*sed4)(10), 8.0, 10, "Found wrong value in SED.__mul__")
np.testing.assert_almost_equal((sed3*sed4)(30), 12.0, 10, "Found wrong value in SED.__mul__")

@timer
def test_SED_mul_bandpass():
"""Check wavelength units when filtering an SED. (Issue #1365.)
"""
waves = np.array([400., 500., 600.])
spec_waves = np.arange(100., 1001., 50.)
for fast in [True, False]:
for spec in [lambda w: w / 500.,
galsim.LookupTable(spec_waves, spec_waves / 500., interpolant='linear')]:
for z in [0., 1.]:
sed = galsim.SED(spec, 'nm', 'fphotons', fast=fast).atRedshift(z)
for wave_type, factor in [('nm', 1.), ('Angstrom', 10.), (units.um, 0.001)]:
for throughput in [
lambda w: w / (1000. * factor),
galsim.LookupTable(waves * factor, waves / 1000., interpolant='linear')
]:
bp = galsim.Bandpass(throughput, wave_type,
blue_limit=400. * factor, red_limit=600. * factor)
for filtered in [sed * bp, bp * sed]:
np.testing.assert_allclose(filtered(500.), sed(500.) * bp(500.))
np.testing.assert_allclose(filtered(waves), sed(waves) * bp(waves))


@timer
def test_SED_div():
"""Check that SEDs divide like I think they should...
Expand Down