diff --git a/changes/9036.tweakreg.rst b/changes/9036.tweakreg.rst new file mode 100644 index 0000000000..0f9045e818 --- /dev/null +++ b/changes/9036.tweakreg.rst @@ -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. \ No newline at end of file diff --git a/docs/jwst/tweakreg/README.rst b/docs/jwst/tweakreg/README.rst index ea8069f0c0..7924c178e9 100644 --- a/docs/jwst/tweakreg/README.rst +++ b/docs/jwst/tweakreg/README.rst @@ -235,16 +235,16 @@ 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) @@ -252,6 +252,14 @@ The ``tweakreg`` step has the following optional arguments: * ``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 diff --git a/jwst/tweakreg/tests/test_tweakreg.py b/jwst/tweakreg/tests/test_tweakreg.py index 57db989e16..5ee7f138b1 100644 --- a/jwst/tweakreg/tests/test_tweakreg.py +++ b/jwst/tweakreg/tests/test_tweakreg.py @@ -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): @@ -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) @@ -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) @@ -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) @@ -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) diff --git a/jwst/tweakreg/tweakreg_step.py b/jwst/tweakreg/tweakreg_step.py index 1638189daf..bf1203aea9 100644 --- a/jwst/tweakreg/tweakreg_step.py +++ b/jwst/tweakreg/tweakreg_step.py @@ -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`` @@ -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 @@ -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