Skip to content

Commit

Permalink
Merge pull request #842 from lsst/tickets/DM-40781-v24
Browse files Browse the repository at this point in the history
DM-40781-v24: Add check for nans when computing grid psf quantities.
  • Loading branch information
mwittgen authored Oct 10, 2023
2 parents 8b9e223 + cc79fc8 commit 32a17f0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
4 changes: 2 additions & 2 deletions python/lsst/pipe/tasks/background.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,14 +612,14 @@ def __init__(self, config, dims, transform, values=None, numbers=None):
values.set(0.0)
else:
values = values.clone()
assert(values.getDimensions() == self.dims)
assert values.getDimensions() == self.dims
self._values = values
if numbers is None:
numbers = afwImage.ImageF(self.dims) # float for dynamic range and convenience
numbers.set(0.0)
else:
numbers = numbers.clone()
assert(numbers.getDimensions() == self.dims)
assert numbers.getDimensions() == self.dims
self._numbers = numbers

def __reduce__(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def _config(self) -> Config:
# Config Fields should never outlive their config class instance
# assert that as such here
value = self._config_()
assert(value is not None)
assert value is not None
return value

@property
Expand Down
13 changes: 9 additions & 4 deletions python/lsst/pipe/tasks/healSparseMappingProperties.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,18 @@ def compute_approx_psf_size_and_shape(ccd_row, ra, dec, nx=20, ny=20, orderx=2,
("psf_e2", "f8"),
("psf_area", "f8")])

cheb_size = ChebyshevBoundedField.fit(lsst.geom.Box2I(bbox), x, y, psf_size, ctrl)
# Protect against nans which can come in at the edges and masked regions.
good = np.isfinite(psf_size)
x = x[good]
y = y[good]

cheb_size = ChebyshevBoundedField.fit(lsst.geom.Box2I(bbox), x, y, psf_size[good], ctrl)
psf_array["psf_size"] = cheb_size.evaluate(pixel_x, pixel_y)
cheb_e1 = ChebyshevBoundedField.fit(lsst.geom.Box2I(bbox), x, y, psf_e1, ctrl)
cheb_e1 = ChebyshevBoundedField.fit(lsst.geom.Box2I(bbox), x, y, psf_e1[good], ctrl)
psf_array["psf_e1"] = cheb_e1.evaluate(pixel_x, pixel_y)
cheb_e2 = ChebyshevBoundedField.fit(lsst.geom.Box2I(bbox), x, y, psf_e2, ctrl)
cheb_e2 = ChebyshevBoundedField.fit(lsst.geom.Box2I(bbox), x, y, psf_e2[good], ctrl)
psf_array["psf_e2"] = cheb_e2.evaluate(pixel_x, pixel_y)
cheb_area = ChebyshevBoundedField.fit(lsst.geom.Box2I(bbox), x, y, psf_area, ctrl)
cheb_area = ChebyshevBoundedField.fit(lsst.geom.Box2I(bbox), x, y, psf_area[good], ctrl)
psf_array["psf_area"] = cheb_area.evaluate(pixel_x, pixel_y)

return psf_array
Expand Down
6 changes: 3 additions & 3 deletions tests/test_configurableActions.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def __call__(self):
return self.var

def validate(self):
assert(self.var is not None)
assert self.var is not None


class ActionTest2(ConfigurableAction):
Expand All @@ -46,7 +46,7 @@ def __call__(self):
return self.var

def validate(self):
assert(self.var is not None)
assert self.var is not None


class ActionTest3(ConfigurableAction):
Expand All @@ -56,7 +56,7 @@ def __call__(self):
return self.var

def validate(self):
assert(self.var is not None)
assert self.var is not None


class ConfigurableActionsTestCase(unittest.TestCase):
Expand Down

0 comments on commit 32a17f0

Please sign in to comment.