예제 #1
0
    def to_geodetic(self, ellipsoid=None):
        """Convert to geodetic coordinates.

        Parameters
        ----------
        ellipsoid : str, optional
            Reference ellipsoid to use.  Default is the one the coordinates
            were initialized with.  Available are: 'WGS84', 'GRS80', 'WGS72'

        Returns
        -------
        (lon, lat, height) : tuple
            The tuple contains instances of `~astropy.coordinates.Longitude`,
            `~astropy.coordinates.Latitude`, and `~astropy.units.Quantity`

        Raises
        ------
        ValueError
            if ``ellipsoid`` is not recognized as among the ones implemented.

        Notes
        -----
        For the conversion to geodetic coordinates, the ERFA routine
        ``gc2gd`` is used.  See https://github.com/liberfa/erfa
        """
        ellipsoid = _check_ellipsoid(ellipsoid, default=self.ellipsoid)
        self_array = self.to(u.meter).view(self._array_dtype, np.ndarray)
        lon, lat, height = erfa.gc2gd(getattr(erfa, ellipsoid), self_array)
        return GeodeticLocation(
            Longitude(lon * u.radian,
                      u.degree,
                      wrap_angle=180. * u.degree,
                      copy=False),
            Latitude(lat * u.radian, u.degree, copy=False),
            u.Quantity(height * u.meter, self.unit, copy=False))
예제 #2
0
파일: earth.py 프로젝트: maxnoe/astropy
 def from_cartesian(cls, cart):
     """
     Converts 3D rectangular cartesian coordinates (assumed geocentric) to
     WGS84 geodetic coordinates.
     """
     lon, lat, height = erfa.gc2gd(getattr(erfa, cls._ellipsoid),
                                   cart.get_xyz(xyz_axis=-1))
     return cls(lon, lat, height, copy=False)