def test_s2pv(self): theta, phi, r, td, pd, rd = erfa_ufunc.pv2s(self.pv) # On purpose change some of the units away from expected by s2pv. pv = erfa_ufunc.s2pv(theta.to(u.deg), phi, r.to(u.m), td.to(u.deg/u.day), pd, rd.to(u.m/u.s)) assert pv.unit == u.StructuredUnit('m, m/s', names=('p', 'v')) assert_quantity_allclose(pv['p'], self.pv['p'], atol=1*u.m, rtol=0) assert_quantity_allclose(pv['v'], self.pv['v'], atol=1*u.mm/u.s, rtol=0)
def test_pv2s(self): theta, phi, r, td, pd, rd = erfa_ufunc.pv2s(self.pv) assert theta.unit == u.radian assert_quantity_allclose(theta, [0, 90] * u.deg) # longitude assert phi.unit == u.radian assert_array_equal(phi.value, np.zeros(self.pv.shape)) # latitude assert r.unit == u.AU assert_array_equal(r.value, np.ones(self.pv.shape)) assert td.unit == u.radian/u.day assert_array_equal(td.value, np.array([0.0125]*2)) assert pd.unit == u.radian/u.day assert_array_equal(pd.value, np.zeros(self.pv.shape)) assert rd.unit == u.AU/u.day assert_array_equal(rd.value, np.zeros(self.pv.shape))
def test_pv2s_non_standard_units(self): pv = self.pv_value << u.Unit('Pa,Pa/m') theta, phi, r, td, pd, rd = erfa_ufunc.pv2s(pv) assert theta.unit == u.radian assert_quantity_allclose(theta, [0, 90] * u.deg) # longitude assert phi.unit == u.radian assert_array_equal(phi.value, np.zeros(pv.shape)) # latitude assert r.unit == u.Pa assert_array_equal(r.value, np.ones(pv.shape)) assert td.unit == u.radian/u.m assert_array_equal(td.value, np.array([0.0125]*2)) assert pd.unit == u.radian/u.m assert_array_equal(pd.value, np.zeros(pv.shape)) assert rd.unit == u.Pa/u.m assert_array_equal(rd.value, np.zeros(pv.shape))