From 1ad04594fa7c2cac7b73ba15e4cd9c8e5814af2c Mon Sep 17 00:00:00 2001 From: Mihai Cara Date: Thu, 24 Oct 2024 10:19:39 -0400 Subject: [PATCH] Use astropy pixel_to_pixel in calc_pixmap --- CHANGES.rst | 4 +++- drizzle/utils.py | 6 +++--- pyproject.toml | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index fdfc8c6..457dc16 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,9 +4,11 @@ Release Notes ============= -2.0.1 (Unreleased) +2.0.1 (unreleased) ================== +- Use ``astropy``'s ``pixel_to_pixel()`` in ``utils.calc_pixmap()``. [#161] + - Update ``utils.calc_pixmap`` code to be ready for upcoming changes in GWCS due to which inverse WCS transformations will respect bounding box by allowing the caller of ``utils.calc_pixmap`` to disable the bounding box(es) diff --git a/drizzle/utils.py b/drizzle/utils.py index 93535eb..ed7ed2f 100644 --- a/drizzle/utils.py +++ b/drizzle/utils.py @@ -2,6 +2,8 @@ import numpy as np +from astropy.wcs.utils import pixel_to_pixel + __all__ = ["calc_pixmap", "decode_context", "estimate_pixel_scale_ratio"] _DEG2RAD = math.pi / 180.0 @@ -112,9 +114,7 @@ def calc_pixmap(wcs_from, wcs_to, shape=None, disable_bbox="to"): if disable_bbox in ["to", "both"] and bbox_to is not None: wcs_to.bounding_box = None try: - x, y = wcs_to.world_to_pixel_values( - *wcs_from.pixel_to_world_values(x, y) - ) + x, y = pixel_to_pixel(wcs_from, wcs_to, x, y) finally: if bbox_from is not None: wcs_from.bounding_box = bbox_from diff --git a/pyproject.toml b/pyproject.toml index 361e495..8899445 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,6 +7,7 @@ authors = [ ] dependencies = [ "numpy", + "astropy>=5.0", ] dynamic = [ "version",