Example #1
0
    def add_ground_station(
        self,
        pos,
        id_description=None,
        label_fill_color=None,
        label_font=None,
        label_outline_color=None,
        label_text=None,
        label_show=True,
    ):
        """
        Adds a ground station

        Parameters
        ----------
        pos: list [~astropy.units.Quantity]
            Coordinates of ground station,
            list of geodetic latitude and longitude [lon, lat] (0 elevation)
        id_description: str
            Set ground station description
        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 (len(pos) == 2 and isinstance(pos[0], u.quantity.Quantity)
                and isinstance(pos[0], u.quantity.Quantity)):
            u0, v0 = pos

            if self.cust_prop[0]:
                a, b = (
                    self.cust_prop[0][0],
                    self.cust_prop[0][2],
                )  # Get semi-major and semi-minor axises
            else:
                a, b = Earth.R.to_value(u.m), Earth.R_polar.to_value(u.m)

            f = 1 - (b / a)  # Flattenning

            pos = list(gd2gce(a, f, u0.to_value(u.rad), v0.to_value(u.rad), 0))

        else:
            raise TypeError(
                "Invalid coordinates. Coordinates must be of the form [u, v] where u, v are astropy units"
            )

        pckt = Packet(
            id="GS" + str(self.gs_n),
            description=id_description,
            availability=TimeInterval(start=self.start_epoch,
                                      end=self.end_epoch),
            position=Position(cartesian=pos),
            label=Label(
                show=label_show,
                text=label_text,
                font=label_font
                if label_font is not None else "11pt Lucida Console",
                fillColor=Color(rgba=label_fill_color)
                if label_fill_color is not None else None,
                outlineColor=Color(rgba=label_outline_color)
                if label_outline_color is not None else None,
            ),
            billboard=Billboard(image=PIC_GROUNDSTATION, show=True),
        )

        self.packets.append(pckt)
        self.gs_n += 1
Example #2
0
 def pd2pcf(longitude, latitude, altitude):
     return np.array(erfa.gd2gce(a, f, longitude, latitude, altitude))
Example #3
0
def _(src: Geodetic, tgt: Geocentric, data: Array2D) -> Array2D:
    lon, lat, h = data.T
    lon = np.deg2rad(lon)
    lat = np.deg2rad(lat)
    a, f = tgt.ellipsoid.parameters
    return erfa.gd2gce(a, f, lon, lat, h)
Example #4
0
    def from_geodetic(cls,
                      lon,
                      lat,
                      height=0.0,
                      ellipsoid=EARTH_ELLIPSOID_GRS80):
        """
        Location on Central Body (e.g. Earth or Moon), initialized from
        Central Body detic (e.g. geodetic for the Earth) coordinates.

        This is the same as `from_cb_detic` method. It is kept for compatibility with
        :class:`astropy.coordinates.EarthLocation` class.

        Parameters
        ----------
        lon : `~astropy.coordinates.Longitude` or float
            East longitude.  Can be anything that initialises an
            `~astropy.coordinates.Angle` object (if float, in degrees).
        lat : `~astropy.coordinates.Latitude` or float
            latitude.  Can be anything that initialises an
            `~astropy.coordinates.Latitude` object (if float, in degrees).
        height : `~astropy.units.Quantity` or float, optional
            Height above reference ellipsoid (if float, in meters; default: 0).
        ellipsoid : CelestialBodyEllipsoid, optional
            Definition of the reference ellipsoid to use
            (default: 'EARTH_ELLIPSOID_GRS80').


        Raises
        ------
        astropy.units.UnitsError
            If the units on ``lon`` and ``lat`` are inconsistent with angular
            ones, or that on ``height`` with a length.
        ValueError
            If ``lon``, ``lat``, and ``height`` do not have the same shape

        Notes
        -----
        For the conversion to geocentric coordinates, the ERFA routine
        ``gd2gce`` is used.  See https://github.com/liberfa/erfa
        """
        # We use Angle here since there is no need to wrap the longitude -
        # gd2gce will just take cos/sin anyway.  And wrapping might fail
        # on readonly input.
        lon = Angle(lon, u.degree, copy=False)
        lat = Latitude(lat, u.degree, copy=False)
        # don't convert to m by default, so we can use the height unit below.
        if not isinstance(height, u.Quantity):
            height = u.Quantity(height, u.m, copy=False)
        # get geocentric coordinates. Have to give one-dimensional array.
        xyz = erfa.gd2gce(
            ellipsoid.re.to_value(u.m),
            1 / ellipsoid.inv_f.to_value(),
            lon.to_value(u.radian),
            lat.to_value(u.radian),
            height.to_value(u.m),
        )
        self = xyz.ravel().view(cls._location_dtype,
                                cls).reshape(xyz.shape[:-1])
        self._unit = u.m
        self._ellipsoid = ellipsoid
        return self