Add MapCoord.match_unit() method
@@ -904,6 +904,36 @@ class MapCoord(object):
str_ += "\tcoordsys : {}\n".format(self.coordsys)
return str_
+ #TODO: this is a temporary solution until we have decided how to handle
+ # quantities uniformly. This should be called after any `MapCoord.create()`
+ # to support that users can pass quantities in any Map.xxx_by_coord() method.
+ def match_units(self, geom):
+ """Match the units of the non-spatial axes to a given map geometry.
+
+ Parameters
+ ----------
+ geom : `MapGeom`
+ Map geometry with specified units per axis.
+
+ Returns
+ -------
+ coords : `MapCoord`
+ Map coords with
+ """
+ coords = {}
+
+ for name, coord in self._data.items():
+ if name in ['lon', 'lat']:
+ coord = u.Quantity(coord, 'deg', copy=False).value
+ else:
+ ax = self.get_axis_by_name(name)
+ coord = u.Quantity(coord, ax.unit, copy=False).value
+ coords[name] = coords
+
+ return self.__class__(coords, coordssys=self.coordsys)
+
+
+
class MapGeomMeta(InheritDocstrings, abc.ABCMeta):
pass
