def _at(self, time): """Propagate the KeplerOrbit to the given Time object The Time object can contain one time, or an array of times """ pos, vel = propagate( self.position_at_epoch.au, self.velocity_at_epoch.au_per_d, self.epoch.tt, time.tt, self.mu_au3_d2, ) if self._rotation is not None: pos = mxv(self._rotation, pos) vel = mxv(self._rotation, vel) return pos, vel, None, None
def test_velocity_in_ITRF_to_GCRS2(): # TODO: Get test working with these vectors too, showing it works # with a non-zero velocity vector, but in that case the test will # have to be fancier in how it corrects. # r = np.array([(1, 0, 0), (1, 1 / DAY_S, 0)]).T # v = np.array([(0, 1, 0), (0, 1, 0)]).T ts = api.load.timescale() t = ts.utc(2020, 7, 17, 8, 51, [0, 1]) r = np.array([(1, 0, 0), (1, 0, 0)]).T v = np.array([(0, 0, 0), (0, 0, 0)]).T r, v = ITRF_to_GCRS2(t, r, v, True) # Rotate back to equinox-of-date before applying correction. r = mxv(t.M, r) v = mxv(t.M, v) r0, r1 = r.T v0 = v[:,0] # Apply a correction: the instantaneous velocity does not in fact # carry the position in a straight line, but in an arc around the # origin; so use trigonometry to move the destination point to where # linear motion would have carried it. angvel = (t.gast[1] - t.gast[0]) / 24.0 * tau r1 = mxv(rot_z(np.arctan(angvel) - angvel), r1) r1 *= np.sqrt(1 + angvel*angvel) actual_motion = r1 - r0 predicted_motion = v0 / DAY_S relative_error = (length_of(actual_motion - predicted_motion) / length_of(actual_motion)) acceptable_error = 4e-12 assert relative_error < acceptable_error