Skip to content

Commit

Permalink
Replace crdizzle.tdriz calls with new Drizzle class
Browse files Browse the repository at this point in the history
  • Loading branch information
mcara committed Oct 17, 2024
1 parent b5711dc commit d323fee
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 212 deletions.
32 changes: 19 additions & 13 deletions jwst/resample/gwcs_drizzle.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import numpy as np

from drizzle.resample import Drizzle
from . import resample_utils
Expand Down Expand Up @@ -33,6 +32,9 @@ def __init__(self, product, outwcs=None, wt_scl=None,
provided, the WCS is taken from product.
wt_scl : str, optional
.. note::
This parameter is no longer used.
How each input image should be scaled. The choices are `exptime`,
which scales each image by its exposure time, or `expsq`, which scales
each image by the exposure time squared. If not set, then each
Expand All @@ -55,8 +57,6 @@ def __init__(self, product, outwcs=None, wt_scl=None,
The value a pixel is set to in the output if the input image does
not overlap it. The default value of NAN sets NaN values.
"""


# Initialize the object fields
self._product = product

Expand Down Expand Up @@ -100,17 +100,18 @@ def __init__(self, product, outwcs=None, wt_scl=None,
disable_ctx=disable_ctx
)

# Since the context array is dynamic, it must be re-assigned
# back to the product's `con` attribute.
product.con = self.out_ctx

# Since the context array is dynamic, it must be re-assigned
# back to the product's `con` attribute.
@property
def outcon(self):
"""Return the context array"""
return self.out_ctx

Check warning on line 110 in jwst/resample/gwcs_drizzle.py

View check run for this annotation

Codecov / codecov/patch

jwst/resample/gwcs_drizzle.py#L110

Added line #L110 was not covered by tests

def add_image(self, insci, inwcs, inwht=None, xmin=0, xmax=0, ymin=0, ymax=0,
expin=1.0, in_units="cps", wt_scl=1.0, iscale=1.0):
def add_image(self, insci, inwcs, pixmap=None, inwht=None,
xmin=0, xmax=0, ymin=0, ymax=0,
expin=1.0, in_units="cps", iscale=1.0):
"""
Combine an input image with the output drizzled image.
Expand All @@ -134,6 +135,10 @@ def add_image(self, insci, inwcs, inwht=None, xmin=0, xmax=0, ymin=0, ymax=0,
Must have the same dimensions as insci. If none is supplied,
the weighting is set to one.
pixmap : array, optional
A 3D array that maps input image coordinates onto the output
array. If provided, it can improve performance.
xmin : int, optional
This and the following three parameters set a bounding rectangle
on the input image. Only pixels on the input image inside this
Expand Down Expand Up @@ -176,11 +181,12 @@ def add_image(self, insci, inwcs, inwht=None, xmin=0, xmax=0, ymin=0, ymax=0,
"""
# Compute the mapping between the input and output pixel coordinates
# for use in drizzle.cdrizzle.tdriz
pixmap = resample_utils.calc_gwcs_pixmap(
inwcs,
self.outwcs,
insci.shape
)
if pixmap is None:
pixmap = resample_utils.calc_gwcs_pixmap(
inwcs,
self.outwcs,
insci.shape
)

log.debug(f"Pixmap shape: {pixmap[:,:,0].shape}")
log.debug(f"Input Sci shape: {insci.shape}")
Expand All @@ -195,7 +201,7 @@ def add_image(self, insci, inwcs, inwht=None, xmin=0, xmax=0, ymin=0, ymax=0,
pixmap=pixmap,
scale=iscale,
weight_map=inwht,
wht_scale=wt_scl, # hard-coded for JWST count-rate data
wht_scale=1.0, # hard-coded for JWST count-rate data
pixfrac=self.pixfrac,
in_units=in_units,
xmin=xmin,
Expand Down
Loading

0 comments on commit d323fee

Please sign in to comment.