def test_last_time_dependent_frame_between(): """ Test frame tree structure: 1 / \ / \ 2 4 / \ / \ 3 5 The rotations from 3 to 2 and 1 to 4 are time dependent. All other rotations are constant. """ frame_chain = FrameChain() rotations = [ ConstantRotation(np.array([1, 0, 0, 0]), 2, 1), TimeDependentRotation( np.array([1.0 / np.sqrt(2), 0, 0, 1.0 / np.sqrt(2)]), np.array([1]), 3, 2), TimeDependentRotation( np.array([1.0 / np.sqrt(2), 0, 0, 1.0 / np.sqrt(2)]), np.array([1]), 4, 1), ConstantRotation(np.array([1.0 / np.sqrt(2), 0, 0, 1.0 / np.sqrt(2)]), 5, 4) ] frame_chain.add_edge(rotation=rotations[0]) frame_chain.add_edge(rotation=rotations[1]) frame_chain.add_edge(rotation=rotations[2]) frame_chain.add_edge(rotation=rotations[3]) # last frame from node 1 to node 3 s31, d31, _ = frame_chain.last_time_dependent_frame_between(1, 3) assert s31 == 2 assert d31 == 3 # last frame from node 3 to node 1 s13, d13, _ = frame_chain.last_time_dependent_frame_between(3, 1) assert s13 == 3 assert d13 == 2 # last frame from node 3 to node 5 s35, d35, _ = frame_chain.last_time_dependent_frame_between(3, 5) assert s35 == 1 assert d35 == 4 # last frame from node 5 to node 3 s53, d53, _ = frame_chain.last_time_dependent_frame_between(5, 3) assert s53 == 2 assert d53 == 3
def frame_chain(self): """ Construct the initial frame chain using the original sensor_frame_id obtained from the ikid. Then tack on the ISIS iak rotation. Returns ------- : Object Custom Cassini ALE Frame Chain object for rotation computation and application """ if not hasattr(self, '_frame_chain'): try: # Call frinfo to check if the ISIS iak has been loaded with the # additional reference frame. Otherwise, Fail and add it manually spice.frinfo(self.sensor_frame_id) self._frame_chain = super().frame_chain except spice.utils.exceptions.NotFoundError as e: self._frame_chain = FrameChain.from_spice(sensor_frame=self._original_naif_sensor_frame_id, target_frame=self.target_frame_id, center_ephemeris_time=self.center_ephemeris_time, ephemeris_times=self.ephemeris_time,) rotation = ConstantRotation([[0, 0, 1, 0]], self.sensor_frame_id, self._original_naif_sensor_frame_id) self._frame_chain.add_edge(rotation=rotation) return self._frame_chain
def frame_chain(self): if not hasattr(self, '_frame_chain'): self._frame_chain = FrameChain.from_spice( sensor_frame=self.sensor_frame_id, target_frame=self.target_frame_id, center_ephemeris_time=self.center_ephemeris_time, ephemeris_times=self.ephemeris_time) return self._frame_chain
def frame_chain(self): frame_chain = FrameChain() body_rotation = TimeDependentRotation( np.array([[0, 0, 0, 1], [0, 0, 0, 1]]), np.array([0, 1]), 100, 1) frame_chain.add_edge(rotation=body_rotation) spacecraft_rotation = TimeDependentRotation( np.array([[0, 0, 0, 1], [0, 0, 0, 1]]), np.array([0, 1]), 1000, 1) frame_chain.add_edge(rotation=spacecraft_rotation) sensor_rotation = ConstantRotation(np.array([0, 0, 0, 1]), 1010, 1000) frame_chain.add_edge(rotation=sensor_rotation) return frame_chain
def frame_tree(request): """ Test frame tree structure: 1 / \ / \ 2 4 / / 3 """ frame_chain = FrameChain() rotations = [ ConstantRotation(np.array([1, 0, 0, 0]), 2, 1), ConstantRotation(np.array([1.0 / np.sqrt(2), 0, 0, 1.0 / np.sqrt(2)]), 3, 2), ConstantRotation(np.array([1.0 / np.sqrt(2), 0, 0, 1.0 / np.sqrt(2)]), 4, 1) ] frame_chain.add_edge(rotation=rotations[0]) frame_chain.add_edge(rotation=rotations[1]) frame_chain.add_edge(rotation=rotations[2]) return frame_chain, rotations
def frame_chain(self): """ Return the root node of the rotation frame tree/chain. The root node is the J2000 reference frame. The other nodes in the tree can be accessed via the methods in the FrameNode class. Returns ------- FrameNode The root node of the frame tree. This will always be the J2000 reference frame. """ if not hasattr(self, '_frame_chain'): self._frame_chain = FrameChain.from_isis_tables( inst_pointing=self.inst_pointing_table, body_orientation=self.body_orientation_table) return self._frame_chain
def frame_chain(self): if not hasattr(self, '_frame_chain'): nadir = self._props.get('nadir', False) self._frame_chain = FrameChain.from_spice( sensor_frame=self.sensor_frame_id, target_frame=self.target_frame_id, center_ephemeris_time=self.center_ephemeris_time, ephemeris_times=self.ephemeris_time, nadir=nadir) if nadir: # Logic for nadir calculation was taken from ISIS3 # SpiceRotation::setEphemerisTimeNadir rotation = self._frame_chain.compute_rotation( self.target_frame_id, 1) p_vec, v_vec, times = self.sensor_position rotated_positions = rotation.apply_at(p_vec, times) rotated_velocities = rotation.rotate_velocity_at( p_vec, v_vec, times) p_vec = rotated_positions v_vec = rotated_velocities velocity_axis = 2 # Get the default line translation with no potential flipping # from the driver trans_x = np.array( list(spice.gdpool('INS{}_ITRANSL'.format(self.ikid), 0, 3))) if (trans_x[0] < trans_x[1]): velocity_axis = 1 quats = [ spice.m2q( spice.twovec(-p_vec[i], 3, v_vec[i], velocity_axis)) for i, time in enumerate(times) ] quats = np.array(quats)[:, [1, 2, 3, 0]] rotation = TimeDependentRotation(quats, times, 1, self.sensor_frame_id) self._frame_chain.add_edge(rotation) return self._frame_chain