Skip to content

Commit

Permalink
adjust tolerances for coron registration (#8717)
Browse files Browse the repository at this point in the history
  • Loading branch information
braingram authored Sep 18, 2024
2 parents 34517ec + 26f40c7 commit 2d1e350
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ badpix_selfcal
- Subtract pedestal dark when constructing min array across selfcal exposures
for MIRI MRS data. [#8771]

calwebb_coron3
--------------

- Tighten tolerance of psf alignment. [#8717]

calwebb_detector1
-----------------

Expand Down
14 changes: 8 additions & 6 deletions jwst/coron/imageregistration.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ def align_fourierLSQ(reference, target, mask=None):

init_pars = [0., 0., 1.]
results, _ = optimize.leastsq(shift_subtract, init_pars,
args=(reference, target, mask))
args=(reference, target, mask),
xtol=1E-15, ftol=1E-15,
)
return results


Expand Down Expand Up @@ -165,7 +167,7 @@ def align_array(reference, target, mask=None, return_aligned=True):

elif len(target.shape) == 3:
nslices = target.shape[0]
shifts = np.empty((nslices, 3), dtype=float)
shifts = np.empty((nslices, 3), dtype=np.float64)
if return_aligned:
aligned = np.empty_like(target)

Expand Down Expand Up @@ -221,19 +223,19 @@ def align_models(reference, target, mask):
# Compute the shifts of the PSF ("target") images relative to
# the science ("reference") image in the first integration
shifts = align_array(
reference.data[0].astype(np.float64),
target.data.astype(np.float64),
reference.data[0],
target.data,
mask=mask.data, return_aligned=False)

# Apply the shifts to the PSF images
output_model.data = fourier_imshift(
target.data.astype(np.float64),
target.data,
-shifts)

# Apply the same shifts to the PSF error arrays, if they exist
if target.err is not None:
output_model.err = fourier_imshift(
target.err.astype(np.float64),
target.err,
-shifts)

# TODO: in the future we need to add shifts and other info (such as
Expand Down
5 changes: 3 additions & 2 deletions jwst/regtest/test_miri_coron3.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_miri_coron3_sci_exp(run_pipeline, suffix, exposure, fitsdiff_default_kw
rtdata.output = output
rtdata.get_truth("truth/test_miri_coron3/" + output)

fitsdiff_default_kwargs["atol"] = 1e-5
fitsdiff_default_kwargs["atol"] = 1e-2
diff = FITSDiff(rtdata.output, rtdata.truth, **fitsdiff_default_kwargs)
assert diff.identical, diff.report()

Expand All @@ -45,6 +45,7 @@ def test_miri_coron3_product(run_pipeline, suffix, fitsdiff_default_kwargs):
rtdata.output = output
rtdata.get_truth("truth/test_miri_coron3/" + output)

fitsdiff_default_kwargs['atol'] = 1e-5
fitsdiff_default_kwargs['atol'] = 1e-4
fitsdiff_default_kwargs['rtol'] = 1e-4
diff = FITSDiff(rtdata.output, rtdata.truth, **fitsdiff_default_kwargs)
assert diff.identical, diff.report()
5 changes: 3 additions & 2 deletions jwst/regtest/test_nircam_coron3.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def test_nircam_coron3_sci_exp(run_pipeline, suffix, obs, fitsdiff_default_kwarg
rtdata.output = output
rtdata.get_truth("truth/test_nircam_coron3/" + output)

fitsdiff_default_kwargs["atol"] = 1e-5
fitsdiff_default_kwargs["atol"] = 1e-2
diff = FITSDiff(rtdata.output, rtdata.truth, **fitsdiff_default_kwargs)
assert diff.identical, diff.report()

Expand Down Expand Up @@ -63,6 +63,7 @@ def test_nircam_coron3_product(run_pipeline, suffix, fitsdiff_default_kwargs):
rtdata.output = output
rtdata.get_truth("truth/test_nircam_coron3/" + output)

fitsdiff_default_kwargs['atol'] = 1e-5
fitsdiff_default_kwargs['atol'] = 1e-4
fitsdiff_default_kwargs['rtol'] = 1e-4
diff = FITSDiff(rtdata.output, rtdata.truth, **fitsdiff_default_kwargs)
assert diff.identical, diff.report()

0 comments on commit 2d1e350

Please sign in to comment.