Skip to content

Commit

Permalink
add changelog entry, rename flag from 'kind' to 'axis_type'
Browse files Browse the repository at this point in the history
  • Loading branch information
nden committed Jul 24, 2018
1 parent ae0ee8f commit f8105a0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
8 changes: 6 additions & 2 deletions CHANGES.rst
Expand Up @@ -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
Expand All @@ -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
^^^^^^^^^
Expand Down
10 changes: 5 additions & 5 deletions gwcs/tests/test_wcs.py
Expand Up @@ -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):
Expand Down
18 changes: 9 additions & 9 deletions gwcs/wcs.py
Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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):
Expand All @@ -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()
Expand Down

0 comments on commit f8105a0

Please sign in to comment.