Skip to content

Conversation

@yalsayyad
Copy link
Contributor

  • Change AlgorithmError metadata to floats. Only ints floats and bools are allowed.
  • Raise AlgorithmError from transform exception, so that it is directly caused by the transform exception instead of raising while handling the transform exception.
  • Wrap computing WarpedPsf's BBox in a similar try-block because it requires evaluating the PSF which can trigger WCS transform exceptions.

Copy link
Contributor

@fred3m fred3m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few minor comments. I'll post a consideration for a slightly different design in JIRA.

Comment on lines -178 to -182
except pexExceptions.RangeError:
raise WarpedPsfTransformTooBigError(
f"Unable to compute the FWHM of the science Psf at {sciAvgPos}"
"due to an unexpectedly large transform."
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't seem to be catching this exception anymore. Is there a reason that we don't need to worry about this? Is pexExcepetions.RangeError a subset of pexExceptions.Exception?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pexExceptions.Exception IS a catch all:

>>> import lsst.pex.exceptions as pexExceptions
>>> 
>>> try:
...     raise pexExceptions.RangeError("blah")
... except pexExceptions.Exception as err:
...     print("caught it")
... 
caught it

One of the reasons I sent this to you to review is I was wondering if you were attached to WarpedPsfTransformTooBigError specifically.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's used in MakePsfMatchedWarpTask to catch errors and make them annotated errors (part of DM-50702). That's a ticket that I completed but without a lot of background. Your PR catches PsfComputeShapeError too so the same failure modes should still return an annotated error, the question is do we want to persist a more informative error about why it failed or not. I have no opinion on this.

Comment on lines 77 to 92
def safeEstimateRoughShape(psf, position, jitter=2.0, maxTries=5, logger=None):
"""
Try to compute the shape of `psf` at `position`.

If it fails, perturb the position until success or maxTries.

Parameters
----------
psf : lsst.afw.detection.Psf
The PSF object.
position : lsst.geom.Point2D
The nominal positionition.
jitter : float
Size of random offset in pixels to try when retrying.
maxTries : int
Maximum number of attempts (including the original).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logger needs a docstring. Also, it might be helpful to add type hints.

- Change AlgorithmError metadata to floats. Only ints
  floats and bools are allowed.
- Raise AlgorithmError from transform exception, so that it
  is directly caused by the transform exception
  instead of raising while handling the transform exception.
- Wrap computing WarpedPsf's BBox in a similar try-block because
  it requires evaluating the PSF which can trigger WCS
  transform exceptions.
@yalsayyad yalsayyad force-pushed the tickets/DM-52537 branch 2 times, most recently from b3601da to 8ea1ddd Compare September 24, 2025 21:48
for initial rough PSF size estimate
@yalsayyad yalsayyad merged commit 1c7ccd2 into main Sep 24, 2025
2 checks passed
@yalsayyad yalsayyad deleted the tickets/DM-52537 branch September 24, 2025 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants