def add_trajectory( self, positions, epochs, groundtrack_show=False, groundtrack_lead_time=None, groundtrack_trail_time=None, groundtrack_width=None, groundtrack_color=None, id_name=None, id_description=None, path_width=None, path_show=None, path_color=None, label_fill_color=None, label_outline_color=None, label_font=None, label_text=None, label_show=None, ): """ Adds trajectory. Parameters ---------- positions: ~astropy.coordinates.CartesianRepresentation Trajectory to plot. epochs: ~astropy.time.Time Epochs for positions. groundtrack_show: bool If set to true, the groundtrack is displayed. groundtrack_lead_time: float The time the animation is ahead of the real-time groundtrack groundtrack_trail_time: float The time the animation is behind the real-time groundtrack groundtrack_width: int Groundtrack width groundtrack_color: list (int) Rgba groundtrack color. By default, it is set to the path color id_name: str Set orbit name id_description: str Set orbit description path_width: int Path width path_show: bool Indicates whether the path is visible path_color: list (int) Rgba path color label_fill_color: list (int) Fill Color in rgba format label_outline_color: list (int) Outline Color in rgba format label_font: str Set label font style and size (CSS syntax) label_text: str Set label text label_show: bool Indicates whether the label is visible """ positions = (positions.represent_as(CartesianRepresentation).get_xyz( 1).to_value(u.m)) epochs = Time(epochs, format="isot") if len(epochs) != len(positions): raise ValueError("Number of Points and Epochs must be equal.") epochs = np.fromiter( map(lambda epoch: (epoch - epochs[0]).to_value(u.s), epochs), dtype=float, ) positions = np.around( np.concatenate([epochs[..., None], positions], axis=1).ravel(), 1).tolist() self.trajectories.append([positions, None, label_text, path_color]) start_epoch = Time(self.start_epoch, format="isot") pckt = Packet( id=self.i, name=id_name, description=id_description, availability=TimeInterval(start=self.start_epoch, end=self.end_epoch), position=Position( interpolationDegree=5, interpolationAlgorithm=InterpolationAlgorithms.LAGRANGE, referenceFrame=ReferenceFrames.INERTIAL, cartesian=positions, # Use explicit UTC timezone, rather than the default, which is a local timezone. epoch=start_epoch.datetime.replace(tzinfo=timezone.utc), ), path=Path( show=path_show, width=path_width, material=Material(solidColor=SolidColorMaterial( color=Color.from_list(path_color))) if path_color is not None else Material(solidColor=SolidColorMaterial( color=Color.from_list([255, 255, 0]))), resolution=120, ), label=Label( text=label_text, font=label_font if label_font is not None else "11pt Lucida Console", show=label_show, fillColor=Color(rgba=label_fill_color) if label_fill_color is not None else Color(rgba=[255, 255, 0, 255]), outlineColor=Color(rgba=label_outline_color) if label_outline_color is not None else Color( rgba=[255, 255, 0, 255]), ), billboard=Billboard(image=PIC_SATELLITE, show=True), ) self.packets.append(pckt) if groundtrack_show: raise NotImplementedError( "Ground tracking for trajectory not implemented yet") self.i += 1
def add_orbit( self, orbit, rtol=1e-10, N=None, id_name=None, id_description=None, path_width=None, path_show=None, path_color=None, label_fill_color=None, label_outline_color=None, label_font=None, label_text=None, label_show=None, ): """ Adds an orbit Parameters ---------- orbit: poliastro.Orbit Orbit to be added rtol: float Maximum relative error permitted N: int Number of sample points Id parameters: ------------- id_name: str Set orbit name id_description: str Set orbit description Path parameters --------------- path_width: int Path width path_show: bool Indicates whether the path is visible path_color: list (int) Rgba path color Label parameters ---------- label_fill_color: list (int) Fill Color in rgba format label_outline_color: list (int) Outline Color in rgba format label_font: str Set label font style and size (CSS syntax) label_text: str Set label text label_show: bool Indicates whether the label is visible """ if N is None: N = self.N if orbit.epoch < Time(self.start_epoch): orbit = orbit.propagate(self.start_epoch - orbit.epoch) elif orbit.epoch > Time(self.end_epoch): raise ValueError( "The orbit's epoch cannot exceed the constructor's ending epoch" ) if rtol <= 0 or rtol >= 1: raise ValueError( "The relative tolerance must be a value in the range (0, 1)") self.orbits.append([orbit, N, orbit.epoch]) cartesian_cords = self._init_orbit_packet_cords_(self.i, rtol=rtol) start_epoch = Time(min(self.orbits[self.i][2], self.start_epoch), format="isot") pckt = Packet( id=self.i, name=id_name, description=id_description, availability=TimeInterval(start=self.start_epoch.datetime, end=self.end_epoch.datetime), position=Position( interpolationDegree=5, interpolationAlgorithm=InterpolationAlgorithms.LAGRANGE, referenceFrame=ReferenceFrames.INERTIAL, cartesian=cartesian_cords, epoch=start_epoch.value, ), path=Path( show=path_show, width=path_width, material=Material(solidColor=SolidColorMaterial(color=Color( rgba=path_color))) if path_color is not None else Material( solidColor=SolidColorMaterial(color=Color( rgba=[255, 255, 0, 255]))), resolution=120, ), label=Label( text=label_text, font=label_font if label_font is not None else "11pt Lucida Console", show=label_show, fillColor=Color(rgba=label_fill_color) if label_fill_color is not None else Color(rgba=[255, 255, 0, 255]), outlineColor=Color(rgba=label_outline_color) if label_outline_color is not None else Color( rgba=[255, 255, 0, 255]), ), billboard=Billboard(image=PIC_SATELLITE, show=True), ) self.packets.append(pckt) self.i += 1
def add_orbit( self, orbit, rtol=1e-10, N=None, groundtrack_show=False, groundtrack_lead_time=None, groundtrack_trail_time=None, groundtrack_width=None, groundtrack_color=None, id_name=None, id_description=None, path_width=None, path_show=None, path_color=None, label_fill_color=None, label_outline_color=None, label_font=None, label_text=None, label_show=None, ): """ Adds an orbit Parameters ---------- orbit: poliastro.twobody.orbit.Orbit Orbit to be added rtol: float Maximum relative error permitted N: int Number of sample points groundtrack_show: bool If set to true, the groundtrack is displayed. groundtrack_lead_time: float The time the animation is ahead of the real-time groundtrack groundtrack_trail_time: float The time the animation is behind the real-time groundtrack groundtrack_width: int Groundtrack width groundtrack_color: list (int) Rgba groundtrack color. By default, it is set to the path color id_name: str Set orbit name id_description: str Set orbit description path_width: int Path width path_show: bool Indicates whether the path is visible path_color: list (int) Rgba path color label_fill_color: list (int) Fill Color in rgba format label_outline_color: list (int) Outline Color in rgba format label_font: str Set label font style and size (CSS syntax) label_text: str Set label text label_show: bool Indicates whether the label is visible """ if N is None: N = self.N if orbit.epoch < self.start_epoch: orbit = orbit.propagate(self.start_epoch - orbit.epoch) elif orbit.epoch > self.end_epoch: raise ValueError( "The orbit's epoch cannot exceed the constructor's ending epoch" ) if rtol <= 0 or rtol >= 1: raise ValueError( "The relative tolerance must be a value in the range (0, 1)") self.orbits.append([orbit, N, orbit.epoch]) cartesian_cords = self._init_orbit_packet_cords_(self.i, rtol=rtol) start_epoch = Time(min(self.orbits[self.i][2], self.start_epoch), format="isot") pckt = Packet( id=self.i, name=id_name, description=id_description, availability=TimeInterval(start=self.start_epoch, end=self.end_epoch), position=Position( interpolationDegree=5, interpolationAlgorithm=InterpolationAlgorithms.LAGRANGE, referenceFrame=ReferenceFrames.INERTIAL, cartesian=cartesian_cords, # Use explicit UTC timezone, rather than the default, which is a local timezone. epoch=start_epoch.datetime.replace(tzinfo=timezone.utc), ), path=Path( show=path_show, width=path_width, material=Material(solidColor=SolidColorMaterial( color=Color.from_list(path_color))) if path_color is not None else Material(solidColor=SolidColorMaterial( color=Color.from_list([255, 255, 0]))), resolution=120, ), label=Label( text=label_text, font=label_font if label_font is not None else "11pt Lucida Console", show=label_show, fillColor=Color(rgba=label_fill_color) if label_fill_color is not None else Color(rgba=[255, 255, 0, 255]), outlineColor=Color(rgba=label_outline_color) if label_outline_color is not None else Color( rgba=[255, 255, 0, 255]), ), billboard=Billboard(image=PIC_SATELLITE, show=True), ) self.packets.append(pckt) if groundtrack_show: groundtrack_color = path_color groundtrack_cords = self._init_groundtrack_packet_cords_(self.i, rtol=rtol) pckt = Packet( id="groundtrack" + str(self.i), availability=TimeInterval(start=self.start_epoch, end=self.end_epoch), position=Position( interpolationDegree=5, interpolationAlgorithm=InterpolationAlgorithms.LAGRANGE, referenceFrame=ReferenceFrames.INERTIAL, cartesian=groundtrack_cords, # Use explicit UTC timezone, rather than the default, which is a local timezone. epoch=start_epoch.datetime.replace(tzinfo=timezone.utc), ), path=Path( show=True, material=Material(solidColor=SolidColorMaterial( color=Color(rgba=groundtrack_color))) if groundtrack_color is not None else Material( solidColor=SolidColorMaterial(color=Color( rgba=[255, 255, 0, 255]))), resolution=60, width=groundtrack_width, leadTime=groundtrack_lead_time if groundtrack_lead_time else 100, trailTime=groundtrack_trail_time if groundtrack_trail_time else 100, ), ) self.packets.append(pckt) self.i += 1
verticalOrigin=VerticalOrigins.CENTER, ), label=Label( horizontalOrigin=HorizontalOrigins.LEFT, outlineWidth=2, show=True, font="11pt Lucida Console", style=LabelStyles.FILL_AND_OUTLINE, text="Geoeye 1", verticalOrigin=VerticalOrigins.CENTER, fillColor=Color.from_list([0, 255, 0]), outlineColor=Color.from_list([0, 0, 0]), ), path=Path( show=Sequence([IntervalValue(start=start, end=end, value=True)]), width=1, resolution=120, material=Material(solidColor=SolidColorMaterial.from_list([0, 255, 0])), ), position=Position( interpolationAlgorithm=InterpolationAlgorithms.LAGRANGE, interpolationDegree=5, referenceFrame=ReferenceFrames.INERTIAL, epoch=start, cartesian=[ 0, 4650397.56551457, -3390535.52275848, -4087729.48877329, 300, 3169722.12564676, -2787480.80604407,