From f8105a042343f2d78762cf4230c29f57afe4ac0f Mon Sep 17 00:00:00 2001 From: Nadia Dencheva Date: Tue, 24 Jul 2018 15:43:07 -0400 Subject: [PATCH] add changelog entry, rename flag from 'kind' to 'axis_type' --- CHANGES.rst | 8 ++++++-- gwcs/tests/test_wcs.py | 10 +++++----- gwcs/wcs.py | 18 +++++++++--------- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index d76de6c0..dd89d801 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -26,8 +26,10 @@ New Features - Add a ``StokesFrame`` which converts from 'I', 'Q', 'U', 'V' to 0-3. [#133] -- Support serialising the base ``CoordinateFrame`` class to asdf, by making - a specific tag and schema for ``Frame2D`` [#150] +- Support serializing the base ``CoordinateFrame`` class to asdf, by making + a specific tag and schema for ``Frame2D``. [#150] + +- Generalized the footrpint calculation to all output axes. [#167] API Changes @@ -36,6 +38,8 @@ API Changes - The argument ``output="numerical_plus"`` was replaced by a bool argument ``with_units``. [#156] +- Added a new flag ``axis_type`` to the footprint method. It controls what + type of footprint to calculate. [#167] Bug Fixes ^^^^^^^^^ diff --git a/gwcs/tests/test_wcs.py b/gwcs/tests/test_wcs.py index 64c95383..a300b851 100644 --- a/gwcs/tests/test_wcs.py +++ b/gwcs/tests/test_wcs.py @@ -317,12 +317,12 @@ def test_footprint(): [15, 0, 12], [15, 2, 2], [15, 2, 12]])) - assert_equal(w.footprint(kind='spatial'), np.array([[ 11., 0.], - [ 11., 2.], - [ 15., 2.], - [ 15., 0.]])) + assert_equal(w.footprint(axis_type='spatial'), np.array([[ 11., 0.], + [ 11., 2.], + [ 15., 2.], + [ 15., 0.]])) - assert_equal(w.footprint(kind='spectral'), np.array([2, 12])) + assert_equal(w.footprint(axis_type='spectral'), np.array([2, 12])) class TestImaging(object): diff --git a/gwcs/wcs.py b/gwcs/wcs.py index 07bdd45b..64dabd57 100644 --- a/gwcs/wcs.py +++ b/gwcs/wcs.py @@ -519,7 +519,7 @@ def __repr__(self): self.output_frame, self.input_frame, self.forward_transform) return fmt - def footprint(self, bounding_box=None, center=False, kind="all"): + def footprint(self, bounding_box=None, center=False, axis_type="all"): """ Return the footprint in world coordinates. @@ -529,7 +529,7 @@ def footprint(self, bounding_box=None, center=False, kind="all"): `prop: bounding_box` center : bool If `True` use the center of the pixel, otherwise use the corner. - kind : str + axis_type : str A supported ``output_frame.axes_type`` or "all" (default). One of ['spatial', 'spectral', 'temporal'] or a custom type. @@ -538,7 +538,7 @@ def footprint(self, bounding_box=None, center=False, kind="all"): coord : ndarray Array of coordinates in the output_frame mapping corners to the output frame. For spatial coordinates the order - is clockwise. + is clockwise, starting from the bottom left corner. """ def _order_clockwise(v): @@ -564,17 +564,17 @@ def _order_clockwise(v): result = np.asarray(self.__call__(*vertices, **{'with_bounding_box': False})) - kind = kind.lower() - if kind == 'spatial' and all_spatial: + axis_type = axis_type.lower() + if axis_type == 'spatial' and all_spatial: return result.T - if kind != "all": - axtyp_ind = np.array([t.lower() for t in self.output_frame.axes_type]) == kind + if axis_type != "all": + axtyp_ind = np.array([t.lower() for t in self.output_frame.axes_type]) == axis_type if not axtyp_ind.any(): - raise ValueError('This WCS does not have axis of type "{}".'.format(kind)) + raise ValueError('This WCS does not have axis of type "{}".'.format(axis_type)) result = np.asarray([(r.min(), r.max()) for r in result[axtyp_ind]]) - if kind == "spatial": + if axis_type == "spatial": result = _order_clockwise(result) else: result.sort()