Skip to content

Commit

Permalink
Merge pull request #329 from spacetelescope/0.15.0x
Browse files Browse the repository at this point in the history
0.15.0x
  • Loading branch information
nden committed Nov 13, 2020
2 parents b1b08d4 + b650da3 commit d8acfe2
Show file tree
Hide file tree
Showing 11 changed files with 2,252 additions and 52 deletions.
16 changes: 15 additions & 1 deletion CHANGES.rst
@@ -1,3 +1,18 @@
0.15.0 (2020-11-13)
-------------------
New Features
^^^^^^^^^^^^

- Added ``insert_frame`` method to modify the pipeline of a ``WCS`` object. [#299]

- Added ``to_fits_tab`` method to generate FITS header and binary table
extension following FITS WCS ``-TAB`` convension. [#295]

- Added ``in_image`` function for testing whether a point in world coordinates
maps back to the domain of definition of the forward transformation. [#322]

- Implemented iterative inverse for some imaging WCS. [#324]

0.14.0 (2020-08-19)
-------------------
New Features
Expand All @@ -19,7 +34,6 @@ Bug Fixes

- Add an optional parameter ``input_frame`` to ``wcstools.wcs_from_fiducial`. [#312]
0.13.0 (2020-03-26)
-------------------
New Features
Expand Down
39 changes: 27 additions & 12 deletions gwcs/coordinate_frames.py
Expand Up @@ -270,7 +270,6 @@ def axes_type(self):

def coordinates(self, *args):
""" Create world coordinates object"""
args = [args[i] for i in self.axes_order]
coo = tuple([arg * un if not hasattr(arg, "to") else arg.to(un) for arg, un in zip(args, self.unit)])
return coo

Expand All @@ -279,19 +278,26 @@ def coordinate_to_quantity(self, *coords):
Given a rich coordinate object return an astropy quantity object.
"""
# NoOp leaves it to the model to handle
# If coords is a 1-tuple of quantity then return the element of the tuple
# This aligns the behavior with the other implementations
if not hasattr(coords, 'unit') and len(coords) == 1:
return coords[0]
return coords

@property
def axis_physical_types(self):
return self._axis_physical_types

@property
def _world_axis_object_components(self):
raise NotImplementedError(f"This method is not implemented for {type(self)}")
def _world_axis_object_classes(self):
return {self._axes_type[0]: (
u.Quantity,
(),
{'unit': self.unit[0]})}

@property
def _world_axis_object_classes(self):
raise NotImplementedError(f"This method is not implemented for {type(self)}")
def _world_axis_object_components(self):
return [(self._axes_type[0], 0, 'value')]


class CelestialFrame(CoordinateFrame):
Expand Down Expand Up @@ -501,7 +507,12 @@ def _world_axis_object_classes(self):

@property
def _world_axis_object_components(self):
return [('temporal', 0, 'value')]
if isinstance(self.reference_frame.value, np.ndarray):
return [('temporal', 0, 'value')]

def offset_from_time_and_reference(time):
return (time - self.reference_frame).sec
return [('temporal', 0, offset_from_time_and_reference)]

def coordinates(self, *args):
if np.isscalar(args):
Expand All @@ -512,14 +523,16 @@ def coordinates(self, *args):
return self._convert_to_time(dt, unit=self.unit[0], **self._attrs)

def _convert_to_time(self, dt, *, unit, **kwargs):
if not isinstance(self.reference_frame.value, np.ndarray):
if not hasattr(dt, 'unit'):
dt = dt * unit
return self.reference_frame + dt

else:
if (not isinstance(dt, time.TimeDelta) and
isinstance(dt, time.Time) or
isinstance(self.reference_frame.value, np.ndarray)):
return time.Time(dt, **kwargs)

if not hasattr(dt, 'unit'):
dt = dt * unit

return self.reference_frame + dt

def coordinate_to_quantity(self, *coords):
if isinstance(coords[0], time.Time):
ref_value = self.reference_frame.value
Expand All @@ -532,6 +545,8 @@ def coordinate_to_quantity(self, *coords):
# Is already a quantity
elif hasattr(coords[0], 'unit'):
return coords[0]
if isinstance(coords[0], np.ndarray):
return coords[0] * self.unit[0]
else:
raise ValueError("Can not convert {} to Quantity".format(coords[0]))

Expand Down
2 changes: 1 addition & 1 deletion gwcs/tests/conftest.py
Expand Up @@ -235,7 +235,7 @@ def sellmeier_zemax():
E_coef=E_coef)


@pytest.fixture
@pytest.fixture(scope="function")
def gwcs_3d_galactic_spectral():
"""
This fixture has the axes ordered as lat, spectral, lon.
Expand Down

0 comments on commit d8acfe2

Please sign in to comment.