Skip to content

Commit 4ed8c8e

Browse files
committed
fix: raise for interpolated image init problems
1 parent aafb848 commit 4ed8c8e

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

jax_galsim/interpolatedimage.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import math
33
from functools import partial
44

5+
import equinox
56
import galsim as _galsim
67
import jax
78
import jax.numpy as jnp
@@ -118,6 +119,11 @@ def __init__(
118119
elif not isinstance(image, Image):
119120
raise TypeError("Supplied image must be an Image or file name")
120121

122+
if not (image.dtype == jnp.float32 or image.dtype == jnp.float64):
123+
raise GalSimValueError(
124+
"Interpolated images must use a float-type image.", image.dtype
125+
)
126+
121127
self._jax_children = (
122128
image,
123129
dict(
@@ -506,6 +512,14 @@ def __init__(
506512
image=self._jax_children[0],
507513
)
508514

515+
if calculate_stepk or calculate_maxk or flux is not None:
516+
image = equinox.error_if(
517+
image,
518+
image.array.sum() == 0.0,
519+
"This input image has zero total flux. It does not define a "
520+
"valid surface brightness profile.",
521+
)
522+
509523
@doc_inherit
510524
def withGSParams(self, gsparams=None, **kwargs):
511525
if gsparams == self.gsparams:

tests/GalSim

0 commit comments

Comments
 (0)