Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1302 #1306

Merged
merged 1 commit into from
Jul 25, 2024
Merged
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
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
Loading