Skip to content

Commit

Permalink
Fix #1302
Browse files Browse the repository at this point in the history
  • Loading branch information
rmjarvis committed Jul 25, 2024
1 parent a11226c commit b437a40
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions galsim/gsobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ def spectral(self): return False
def dimensionless(self): return True
@property
def wave_list(self): return np.array([], dtype=float)
def _fiducial_profile(self, bandpass): return bandpass.effective_wavelength, self

# Also need these methods to duck-type as a ChromaticObject
def evaluateAtWavelength(self, wave):
Expand Down
34 changes: 34 additions & 0 deletions tests/test_chromatic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2518,6 +2518,40 @@ def test_chromatic_fiducial_wavelength():
with assert_raises(galsim.GalSimError):
gal3.drawImage(bp)

@timer
def test_convolve_pixel():
"""Check that convolving a chromatic object with a Pixel works
"""
# In response to issue #1302
# The problem here had been that if some of the components of the convolution were
# inseparable, then when separating out the separable and inseparable components,
# the code called `obj._fiducual_profile(bandpass)` on the separable ones.
# However, if any of these were simple GSObjects, this gave an error, since we didn't have
# that method for GSObject. The fix was to add a trivial version of that for GSObject.

bandpass = galsim.Bandpass("LSST_r.dat", wave_type="nm").thin(rel_err=1.e-2)
sed = galsim.SED('vega.txt', 'nm', 'flambda').thin(rel_err=1.e-2)
insep_psf = galsim.ChromaticAiry(lam=550, diam=0.1)
sep_psf = galsim.Kolmogorov(fwhm=0.65) * galsim.SED('(wave/500)**-0.2', 'nm', '1')
scale = 0.2
pixel = galsim.Pixel(scale)

for psf in [sep_psf, insep_psf]:
star = galsim.DeltaFunction() * sed
star = star.withFlux(1000., bandpass)
eff_psf = galsim.Convolve(psf, pixel)

im1 = galsim.Convolve(star, psf).drawImage(bandpass, scale=scale, nx=32, ny=32)
im2 = galsim.Convolve(star, eff_psf).drawImage(bandpass, scale=scale, nx=32, ny=32,
method='no_pixel')
np.testing.assert_allclose(im1.array, im2.array, atol=1.e-5)

galaxy = galsim.Exponential(half_light_radius=1.3) * sed
galaxy = galaxy.withFlux(1000., bandpass)
im3 = galsim.Convolve(galaxy, psf).drawImage(bandpass, scale=scale, nx=32, ny=32)
im4 = galsim.Convolve(galaxy, eff_psf).drawImage(bandpass, scale=scale, nx=32, ny=32,
method='no_pixel')
np.testing.assert_allclose(im3.array, im4.array, atol=1.e-5)

@timer
def test_chromatic_image_setup():
Expand Down

0 comments on commit b437a40

Please sign in to comment.