8000 JP-3781: Use center=False for compute_s_region_imaging by emolter · Pull Request #8897 · spacetelescope/jwst · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

JP-3781: Use center=False for compute_s_region_imaging #8897

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/8897.assign_wcs.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use pixel vertices to define s_region instead of pixel centers."
29 changes: 29 additions & 0 deletions jwst/assign_wcs/tests/test_nircam.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"""
import numpy as np
import pytest
import re


from astropy.io import fits
Expand Down Expand Up @@ -244,3 +245,31 @@ def test_wfss_sip():
util.wfss_imaging_wcs(wfss_model, nircam.imaging, bbox=((1, 1024), (1, 1024)))
for key in ['a_order', 'b_order', 'crpix1', 'crpix2', 'crval1', 'crval2', 'cd1_1']:
assert key in wfss_model.meta.wcsinfo.instance


def _sregion_to_footprint(s_region):
"""
Parameters
----------
s_region : str
The S_REGION header keyword

Returns
-------
footprint : np.array
A 2D array of the footprint of the region, shape (N, 2)
"""
no_prefix = re.sub(r"[a-zA-Z]", "", s_region)
return np.array(no_prefix.split(), dtype=float).reshape(-1, 2)


def test_update_s_region_imaging():
"""Ensure the s_region keyword matches output of wcs.footprint()"""
model = ImageModel(create_hdul())
model.meta.wcs = create_imaging_wcs()
util.update_s_region_imaging(model)

s_region = model.meta.wcsinfo.s_region
footprint = model.meta.wcs.footprint().flatten()
footprint_sregion = _sregion_to_footprint(s_region).flatten()
assert np.allclose(footprint, footprint_sregion, rtol=1e-9)
2 changes: 1 addition & 1 deletion jwst/assign_wcs/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ def update_s_region_imaging(model):
"""
Update the ``S_REGION`` keyword using ``WCS.footprint``.
"""
s_region = compute_s_region_imaging(model.meta.wcs, shape=model.data.shape)
s_region = compute_s_region_imaging(model.meta.wcs, shape=model.data.shape, center=False)
if s_region is not None:
model.meta.wcsinfo.s_region = s_region

Expand Down
Loading
0