-
Notifications
You must be signed in to change notification settings - Fork 167
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
Switch resample to the new drizzle package API #8866
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Updated resample code to support the new ``drizzle`` API, see https://github.com/spacetelescope/drizzle/pull/134 for more details. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
|
||
import numpy as np | ||
from astropy import units as u | ||
import gwcs | ||
from drizzle.utils import calc_pixmap | ||
|
||
from stdatamodels.dqflags import interpret_bit_flags | ||
from stdatamodels.jwst.datamodels.dqflags import pixel | ||
|
@@ -124,17 +124,11 @@ def shape_from_bounding_box(bounding_box): | |
def calc_gwcs_pixmap(in_wcs, out_wcs, shape=None): | ||
""" Return a pixel grid map from input frame to output frame. | ||
""" | ||
if shape: | ||
bb = wcs_bbox_from_shape(shape) | ||
log.debug("Bounding box from data shape: {}".format(bb)) | ||
emolter marked this conversation as resolved.
Show resolved
Hide resolved
|
||
else: | ||
bb = in_wcs.bounding_box | ||
log.debug("Bounding box from WCS: {}".format(in_wcs.bounding_box)) | ||
|
||
grid = gwcs.wcstools.grid_from_bounding_box(bb) | ||
pixmap = np.dstack(reproject(in_wcs, out_wcs)(grid[0], grid[1])) | ||
if shape is not None and not np.array_equiv(shape, in_wcs.array_shape): | ||
in_wcs = deepcopy(in_wcs) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure. It felt to be a safer way because this method sets |
||
in_wcs.array_shape = shape | ||
|
||
return pixmap | ||
return calc_pixmap(wcs_from=in_wcs, wcs_to=out_wcs) | ||
|
||
|
||
def reproject(wcs1, wcs2): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ dependencies = [ | |
"astropy>=5.3", | ||
"BayesicFitting>=3.0.1", | ||
"crds>=11.17.14", | ||
"drizzle>=1.15.0", | ||
"drizzle @ git+https://github.com/mcara/drizzle.git@redesign-api", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remember to change to @main before merge |
||
"gwcs>=0.21.0,<0.23.0", | ||
"numpy>=1.22,<2.0", | ||
"opencv-python-headless>=4.6.0.66", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does this line do? does it break anything to remove it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea. It is a strange line but in Python, sometimes things are magical. Seems to be related to SlitModel and also used (set) in the
photom
step (multi-slit). Maybe @melanieclarke knows more.