diff --git a/lunarsky/moon.py b/lunarsky/moon.py index 8c9cdf0..f3df176 100644 --- a/lunarsky/moon.py +++ b/lunarsky/moon.py @@ -379,7 +379,7 @@ def from_selenodetic(cls, lon, lat, height=0.0, ellipsoid=None): selenodetic = SELENOIDS[ellipsoid](lon, lat, height, copy=False) xyz = selenodetic.to_cartesian().get_xyz(xyz_axis=-1) << height.unit self = xyz.view(cls._location_dtype, cls).reshape(selenodetic.shape) - self._ellipsoid = ellipsoid + self.ellipsoid = ellipsoid return self def __str__(self): diff --git a/lunarsky/tests/test_moon.py b/lunarsky/tests/test_moon.py index bb5dc12..dd267e1 100644 --- a/lunarsky/tests/test_moon.py +++ b/lunarsky/tests/test_moon.py @@ -2,10 +2,11 @@ import copy import numpy as np import astropy.units as unit -from astropy.coordinates import Longitude, Latitude +from astropy.coordinates import Longitude, Latitude, SphericalRepresentation, SphericalDifferential from astropy.tests.helper import quantity_allclose +from astropy.coordinates.tests.test_representation import representation_equal from lunarsky import MoonLocation, MoonLocationAttribute, MCMF -from lunarsky.moon import SELENOIDS +from lunarsky.moon import SELENOIDS, MoonLocationInfo class TestsWithObject: @@ -21,7 +22,7 @@ def setup_method(self): self.lat = Latitude([+0.0, 30.0, 60.0, +90.0, -90.0, -60.0, -30.0, 0.0], unit.deg) self.h = unit.Quantity([0.1, 0.5, 1.0, -0.5, -1.0, +4.2, -11.0, -0.1], unit.m) self.location = MoonLocation.from_selenodetic(self.lon, self.lat, self.h) - self.x, self.y, self.z = self.location.to_selenocentric() + self.x, self.y, self.z = self.location.selenocentric def test_input(self): cartesian = MoonLocation(self.x, self.y, self.z) @@ -68,6 +69,10 @@ def test_invalid(self): with pytest.raises(ValueError): MoonLocation.from_selenodetic(self.lon, self.lat, self.h[:5]) + # invalid ellipsoid + with pytest.raises(ValueError): + loc = MoonLocation.from_selenodetic(self.lon, self.lat, self.h, ellipsoid="INVALID") + def test_attributes(self): assert np.allclose(self.location.height, self.h) assert np.allclose(self.location.lon, self.lon)