Skip to content

Commit

Permalink
Merge branch 'main' into bugfix/gwcs_spring_cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
nden authored Jan 3, 2025
2 parents 560b171 + b0c1ee5 commit 58f2677
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 11 deletions.
3 changes: 3 additions & 0 deletions changes/9036.tweakreg.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Changed the default values for ``sharplo``, ``sharphi``, ``roundlo``, and
``roundhi`` to the values appropriate for the current default algorith for
source finding in the ``tweakreg`` step.
16 changes: 12 additions & 4 deletions docs/jwst/tweakreg/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -235,23 +235,31 @@ The ``tweakreg`` step has the following optional arguments:
Gaussian kernel in units of number of FWHMs. (Default=2.5)

* ``sharplo``: A `float` value indicating The lower bound on sharpness
for object detection. (Default=0.2)
for object detection. (Default=0.5)

* ``sharphi``: A `float` value indicating the upper bound on sharpness
for object detection. (Default=1.0)
for object detection. (Default=2.0)

* ``roundlo``: A `float` value indicating the lower bound on roundness
for object detection. (Default=-1.0)
for object detection. (Default=0.0)

* ``roundhi``: A `float` value indicating the upper bound on roundness
for object detection. (Default=1.0)
for object detection. (Default=0.2)

* ``brightest``: A positive `int` value indicating the number of brightest
objects to keep. If None, keep all objects above the threshold. (Default=200)

* ``peakmax``: A `float` value used to filter out objects with pixel values
>= ``peakmax``. (Default=None)

.. warning::
Different source finding algorithms have different values for the
``sharplo``, ``sharphi``, ``roundlo`` and ``roundhi`` parameters. These
parameters should be adjusted to match the algorithm selected by the
``starfinder`` parameter. See documentation for
[IRAFStarFinder](https://photutils.readthedocs.io/en/stable/api/photutils.detection.IRAFStarFinder.html)
and [DAOStarFinder](https://photutils.readthedocs.io/en/stable/api/photutils.detection.DAOStarFinder.html).

**Additional source finding parameters for segmentation:**

* ``npixels``: An `int` value indicating the minimum number of
Expand Down
19 changes: 18 additions & 1 deletion jwst/tweakreg/tests/test_tweakreg.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ def test_is_wcs_correction_small(offset, is_good):
twcs.bounding_box = wcs.bounding_box

step = tweakreg_step.TweakRegStep()
# TODO: remove 'roundlo' once
# https://github.com/astropy/photutils/issues/1977 is fixed
step.roundlo=-1.0e-12

class FakeCorrector:
def __init__(self, wcs, original_skycoord):
Expand Down Expand Up @@ -191,6 +194,9 @@ def test_tweakreg_step(example_input, with_shift):

# make the step with default arguments
step = tweakreg_step.TweakRegStep()
# TODO: remove 'roundlo' once
# https://github.com/astropy/photutils/issues/1977 is fixed
step.roundlo=-1.0e-12

# run the step on the example input modified above
result = step.run(example_input)
Expand Down Expand Up @@ -225,6 +231,9 @@ def test_src_confusion_pars(example_input, alignment_type):
f"{alignment_type}separation": 1.0,
f"{alignment_type}tolerance": 1.0,
"abs_refcat": REFCAT,
# TODO: remove 'roundlo' once
# https://github.com/astropy/photutils/issues/1977 is fixed
"roundlo": -1.0e-12,
}
step = tweakreg_step.TweakRegStep(**pars)
result = step.run(example_input)
Expand Down Expand Up @@ -337,7 +346,12 @@ def test_custom_catalog(custom_catalog_path, example_input, catfile, asn, meta,
elif asn == "no_cat_in_asn" and meta == "cat_in_meta":
n_custom_sources = N_CUSTOM_SOURCES

kwargs = {'use_custom_catalogs': custom}
kwargs = {
'use_custom_catalogs': custom,
# TODO: remove 'roundlo' once
# https://github.com/astropy/photutils/issues/1977 is fixed
'roundlo': -1.0e-12,
}
if catfile != "no_catfile":
kwargs["catfile"] = str(catfile_path)

Expand Down Expand Up @@ -384,6 +398,9 @@ def test_sip_approx(example_input, with_shift):
step.sip_max_inv_pix_error = 0.1
step.sip_inv_degree = 3
step.sip_npoints = 12
# TODO: remove 'roundlo' once
# https://github.com/astropy/photutils/issues/1977 is fixed
step.roundlo=-1.0e-12

# run the step on the example input modified above
result = step.run(example_input)
Expand Down
12 changes: 6 additions & 6 deletions jwst/tweakreg/tweakreg_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ class TweakRegStep(Step):
kernel_fwhm = float(default=2.5) # Gaussian kernel FWHM in pixels
minsep_fwhm = float(default=0.0) # Minimum separation between detected objects in FWHM
sigma_radius = float(default=1.5) # Truncation radius of the Gaussian kernel in units of sigma
sharplo = float(default=0.2) # The lower bound on sharpness for object detection.
sharphi = float(default=1.0) # The upper bound on sharpness for object detection.
roundlo = float(default=-1.0) # The lower bound on roundness for object detection.
roundhi = float(default=1.0) # The upper bound on roundness for object detection.
sharplo = float(default=0.5) # The lower bound on sharpness for object detection.
sharphi = float(default=2.0) # The upper bound on sharpness for object detection.
roundlo = float(default=0.0) # The lower bound on roundness for object detection.
roundhi = float(default=0.2) # The upper bound on roundness for object detection.
brightest = integer(default=200) # Keep top ``brightest`` objects
peakmax = float(default=None) # Filter out objects with pixel values >= ``peakmax``
Expand Down Expand Up @@ -120,7 +120,7 @@ class TweakRegStep(Step):
sip_max_inv_pix_error = float(default=0.01) # max err for SIP fit, inverse.
sip_inv_degree = integer(max=6, default=None) # degree for inverse SIP fit, None to use best fit.
sip_npoints = integer(default=12) # number of points for SIP
# stpipe general options
output_use_model = boolean(default=True) # When saving use `DataModel.meta.filename`
in_memory = boolean(default=True) # If False, preserve memory using temporary files at expense of runtime
Expand Down Expand Up @@ -311,7 +311,7 @@ def process(self, input):
finally:
del ref_image

if local_align_failed and not align_to_abs_refcat:
if local_align_failed and not align_to_abs_refcat:
record_step_status(images, "tweakreg", success=False)
return images

Expand Down

0 comments on commit 58f2677

Please sign in to comment.