Skip to content

Commit

Permalink
address reviewer comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mcara committed Feb 6, 2024
1 parent 4a3b48f commit dea4d9d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 3 additions & 1 deletion drizzle/resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ def __init__(self, n_images=1, kernel="square",
"'out_shape' cannot be None when all output arrays are None."
)

# shapes will collect user specified 'out_shape' and shapes of
# out_* arrays (if provided) in order to check all shapes are the same.
shapes = set()

Check warning on line 110 in drizzle/resample.py

View check run for this annotation

Codecov / codecov/patch

drizzle/resample.py#L110

Added line #L110 was not covered by tests

if out_sci is not None:
Expand All @@ -128,7 +130,7 @@ def __init__(self, n_images=1, kernel="square",
"'out_shape' cannot be None when all output arrays are "
"None."
)
out_shape = shapes[0]
out_shape = shapes.pop()

Check warning on line 133 in drizzle/resample.py

View check run for this annotation

Codecov / codecov/patch

drizzle/resample.py#L133

Added line #L133 was not covered by tests
else:
shapes.add(out_shape)

Check warning on line 135 in drizzle/resample.py

View check run for this annotation

Codecov / codecov/patch

drizzle/resample.py#L135

Added line #L135 was not covered by tests

Expand Down
14 changes: 13 additions & 1 deletion drizzle/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ def calc_pixmap(wcs_from, wcs_to, estimate_pixel_scale_ratio=False,
estimate_pixel_scale_ratio : bool, optional
Estimate the ratio of "to" to "from" WCS pixel scales.
.. note::
Pixel scale is estimated as the square root of pixel's area
(i.e., pixels are assumed to have a square shape) at the reference
pixel position which is taken as the center of the bounding box
if ``wcs_*`` has a bounding box defined, or as the center of the box
defined by the ``pixel_shape`` attribute of the input WCS if
``pixel_shape`` is defined (not `None`), or at pixel coordinates
``(0, 0)``.
refpix_from : numpy.ndarray, tuple, list
Image coordinates of the reference pixel near which pixel scale should
be computed in the "from" image. In FITS WCS this could be, for example,
Expand Down Expand Up @@ -72,7 +81,10 @@ def _estimate_pixel_scale(wcs, refpix):
# from https://trs.jpl.nasa.gov/handle/2014/40409
if refpix is None:
if wcs.bounding_box is None:
refpix = np.ones(wcs.pixel_n_dim)
if wcs.pixel_shape:
refpix = np.array([(i - 1) // 2 for i in wcs.pixel_shape])

Check warning on line 85 in drizzle/utils.py

View check run for this annotation

Codecov / codecov/patch

drizzle/utils.py#L82-L85

Added lines #L82 - L85 were not covered by tests
else:
refpix = np.zeros(wcs.pixel_n_dim)

Check warning on line 87 in drizzle/utils.py

View check run for this annotation

Codecov / codecov/patch

drizzle/utils.py#L87

Added line #L87 was not covered by tests
else:
refpix = np.mean(wcs.bounding_box, axis=-1)

Check warning on line 89 in drizzle/utils.py

View check run for this annotation

Codecov / codecov/patch

drizzle/utils.py#L89

Added line #L89 was not covered by tests
else:
Expand Down

0 comments on commit dea4d9d

Please sign in to comment.