diff --git a/lunarsky/moon.py b/lunarsky/moon.py index f3df176..a299d05 100644 --- a/lunarsky/moon.py +++ b/lunarsky/moon.py @@ -9,6 +9,7 @@ CartesianRepresentation, ) from astropy.coordinates.attributes import Attribute +from astropy.utils.compat import COPY_IF_NEEDED from .spice_utils import remove_topo @@ -134,7 +135,7 @@ def new_like(self, cols, length, metadata_conflicts="warn", name=None): # selenodetic coordinates. shape = (length,) + attrs.pop("shape") data = u.Quantity( - np.zeros(shape=shape, dtype=cols[0].dtype), unit=cols[0].unit, copy=False + np.zeros(shape=shape, dtype=cols[0].dtype), unit=cols[0].unit, copy=COPY_IF_NEEDED ) # Get arguments needed to reconstruct class map = { @@ -303,9 +304,9 @@ def from_selenocentric(cls, x, y, z, unit=None): ) try: - x = u.Quantity(x, unit, copy=False) - y = u.Quantity(y, unit, copy=False) - z = u.Quantity(z, unit, copy=False) + x = u.Quantity(x, unit, copy=COPY_IF_NEEDED) + y = u.Quantity(y, unit, copy=COPY_IF_NEEDED) + z = u.Quantity(z, unit, copy=COPY_IF_NEEDED) except u.UnitsError: raise u.UnitsError( "Selenocentric coordinate units should all be " "consistent." @@ -314,7 +315,7 @@ def from_selenocentric(cls, x, y, z, unit=None): x, y, z = np.broadcast_arrays(x, y, z) struc = np.empty(x.shape, cls._location_dtype) struc["x"], struc["y"], struc["z"] = x, y, z - inst = super().__new__(cls, struc, unit, copy=False) + inst = super().__new__(cls, struc, unit, copy=COPY_IF_NEEDED) return inst @@ -361,11 +362,11 @@ def from_selenodetic(cls, lon, lat, height=0.0, ellipsoid=None): """ ellipsoid = _check_ellipsoid(ellipsoid, default=cls._ellipsoid) - lon = Longitude(lon, u.degree, copy=False).wrap_at(180 * u.degree) - lat = Latitude(lat, u.degree, copy=False) + lon = Longitude(lon, u.degree, copy=COPY_IF_NEEDED).wrap_at(180 * u.degree) + lat = Latitude(lat, u.degree, copy=COPY_IF_NEEDED) # don't convert to m by default, so we can use the height unit below. if not isinstance(height, u.Quantity): - height = u.Quantity(height, u.m, copy=False) + height = u.Quantity(height, u.m, copy=COPY_IF_NEEDED) if not lon.shape == lat.shape: raise ValueError( @@ -376,7 +377,7 @@ def from_selenodetic(cls, lon, lat, height=0.0, ellipsoid=None): # get selenocentric coordinates. Have to give one-dimensional array. - selenodetic = SELENOIDS[ellipsoid](lon, lat, height, copy=False) + selenodetic = SELENOIDS[ellipsoid](lon, lat, height, copy=COPY_IF_NEEDED) xyz = selenodetic.to_cartesian().get_xyz(xyz_axis=-1) << height.unit self = xyz.view(cls._location_dtype, cls).reshape(selenodetic.shape) self.ellipsoid = ellipsoid @@ -444,13 +445,13 @@ def to_selenodetic(self, ellipsoid=None): """ ellipsoid = _check_ellipsoid(ellipsoid, default=self.ellipsoid) xyz = self.view(self._array_dtype, u.Quantity) - llh = CartesianRepresentation(xyz, xyz_axis=-1, copy=False).represent_as( + llh = CartesianRepresentation(xyz, xyz_axis=-1, copy=COPY_IF_NEEDED).represent_as( SELENOIDS[ellipsoid], ) return SelenodeticLocation( - Longitude(llh.lon, u.degree, wrap_angle=180.0 * u.degree, copy=False), - Latitude(llh.lat, u.degree, copy=False), - u.Quantity(llh.height, self.unit, copy=False), + Longitude(llh.lon, u.degree, wrap_angle=180.0 * u.degree, copy=COPY_IF_NEEDED), + Latitude(llh.lat, u.degree, copy=COPY_IF_NEEDED), + u.Quantity(llh.height, self.unit, copy=COPY_IF_NEEDED), ) @property diff --git a/lunarsky/time.py b/lunarsky/time.py index 57b93e5..4b6aa55 100644 --- a/lunarsky/time.py +++ b/lunarsky/time.py @@ -3,6 +3,7 @@ import numpy as np import astropy from astropy import version +from astropy.utils.compat import COPY_IF_NEEDED from astropy.coordinates import EarthLocation, Longitude from .moon import MoonLocation @@ -30,7 +31,7 @@ def __init__( in_subfmt=None, out_subfmt=None, location=None, - copy=False, + copy=COPY_IF_NEEDED, ): super_loc = None