Skip to content
Open
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
349 changes: 238 additions & 111 deletions galsim/chromatic.py

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions galsim/gsobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,12 @@ def deinterpolated(self): return self
@property
def sed(self):
return sed.SED(self.flux, 'nm', '1')
@lazy_property
def ref_sed(self):
return sed.SED(1., 'nm', '1')
@property
def ref_flux(self):
return self.flux
@property
def SED(self):
from .deprecated import depr
Expand Down
4 changes: 4 additions & 0 deletions galsim/interpolatedimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,10 @@ def __init__(self, image, x_interpolant=None, k_interpolant=None, normalization=
self._buildRealImage(pad_factor, pad_image, noise_pad_size, noise_pad, rng, use_cache)
self._image_flux = np.sum(self._image.array, dtype=np.float64)

# If forcing stepk/maxk, we don't calculate them.
if _force_stepk > 0: calculate_stepk = False
if _force_maxk > 0: calculate_maxk = False

# I think the only things that will mess up if flux == 0 are the
# calculateStepK and calculateMaxK functions, and rescaling the flux to some value.
if (calculate_stepk or calculate_maxk or flux is not None) and self._image_flux == 0.:
Expand Down
1 change: 1 addition & 0 deletions tests/chromatic_reference_images/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
r_exact.fits
Binary file removed tests/chromatic_reference_images/r_exact.fits
Binary file not shown.
225 changes: 203 additions & 22 deletions tests/test_chromatic.py

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions tests/test_config_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -1699,6 +1699,8 @@ def test_timeout():
# Check that it behaves sensibly if it hits timeout limit.
# This time, it will continue on after each error, but report the error in the log.
config2 = galsim.config.CleanConfig(config2)
# Use a different seed so it doesn't use the cached Sersic Hankel transforms.
config2['image']['random_seed'] = 1235
config2['image']['timeout'] = 0.001
with CaptureLog() as cl:
galsim.config.Process(config2, logger=cl.logger)
Expand All @@ -1710,6 +1712,7 @@ def test_timeout():

# If you want this to abort, use except_abort=True
config2 = galsim.config.CleanConfig(config2)
config2['image']['random_seed'] = 1236
with CaptureLog() as cl:
with assert_raises(galsim.GalSimError):
galsim.config.Process(config2, logger=cl.logger, except_abort=True)
Expand Down
8 changes: 7 additions & 1 deletion tests/test_interpolatedimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,10 +518,16 @@ def test_exceptions():
with assert_raises(galsim.GalSimValueError):
galsim.InterpolatedImage(image=galsim.ImageI(5, 5, scale=1))

# Image must have non-zero flux
# Image must have non-zero flux if not providing stepk, maxk.
with assert_raises(galsim.GalSimValueError):
galsim.InterpolatedImage(image=galsim.ImageF(5, 5, scale=1, init_value=0.))

# It's fine if we don't ask InterpolatedImage to figure out stepk, maxk though.
galsim.InterpolatedImage(image=galsim.ImageF(5, 5, scale=1, init_value=0.),
calculate_stepk=False, calculate_maxk=False)
galsim.InterpolatedImage(image=galsim.ImageF(5, 5, scale=1, init_value=0.),
_force_stepk=0.05, _force_maxk=10)

# Can't shoot II with SincInterpolant
ii = galsim.InterpolatedImage(image=galsim.ImageF(5, 5, scale=1, init_value=1.),
x_interpolant='sinc',
Expand Down