Exemplo n.º 1
0
 def to_cartesian(self):
     """
     Converts WGS84 geodetic coordinates to 3D rectangular (geocentric)
     cartesian coordinates.
     """
     xyz = erfa.gd2gc(getattr(erfa, self._ellipsoid), self.lon, self.lat,
                      self.height)
     return CartesianRepresentation(xyz, xyz_axis=-1, copy=False)
Exemplo n.º 2
0
 def __init__(self, longitude, latitude, altitude):
     # site terrestrial coordinates (WGS84)
     self.latnd, self.latnm, self.slatn = map(int, latitude.split(':'))
     self.lonwd, self.lonwm, self.slonw = map(int, longitude.split(':'))
     self.hm = altitude
     # transform to geocentric
     self.phi = erfa.af2a(self.latnd, self.latnm, self.slatn)
     self.elon = erfa.af2a(self.lonwd, self.lonwm, self.slonw)
     self.xyz = erfa.gd2gc(1, self.elon, self.phi, self.hm)
     self.u = math.hypot(self.xyz[0], self.xyz[1])
     self.v = self.xyz[2]
Exemplo n.º 3
0
    def from_geodetic(cls, lon, lat, height=0., ellipsoid=None):
        """
        Location on Earth, initialized from geodetic coordinates.

        Parameters
        ----------
        lon : `~astropy.coordinates.Longitude` or float
            Earth East longitude.  Can be anything that initialises an
            `~astropy.coordinates.Angle` object (if float, in degrees).
        lat : `~astropy.coordinates.Latitude` or float
            Earth 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 : str, optional
            Name of the reference ellipsoid to use (default: 'WGS84').
            Available ellipsoids are:  'WGS84', 'GRS80', 'WGS72'.

        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, or
            if ``ellipsoid`` is not recognized as among the ones implemented.

        Notes
        -----
        For the conversion to geocentric coordinates, the ERFA routine
        ``gd2gc`` is used.  See https://github.com/liberfa/erfa
        """
        ellipsoid = _check_ellipsoid(ellipsoid, default=cls._ellipsoid)
        # We use Angle here since there is no need to wrap the longitude -
        # gd2gc 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.gd2gc(getattr(erfa, ellipsoid),
                         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.meter
        self._ellipsoid = ellipsoid
        return self.to(height.unit)
Exemplo n.º 4
0
at sea level, on 2006 January 15 at 21:24:37.5 UTC
requires the time in all other supported time scales''')

# site terrestrial coordinates (WGS84)
latnd = +19
latnm = 28
slatn = 52.5
lonwd = -155
lonwm = 55
slonw = 59.6
hm = 0.

# transform to geocentric
phi = erfa.af2a(np.array([[latnd, latnm, slatn]]))
elon = erfa.af2a(np.array([[lonwd, lonwm, slonw]]))
xyz = erfa.gd2gc(1, elon, phi, np.array([hm]))[0]
u = np.array([math.hypot(xyz[0], xyz[1])])
v = np.array([xyz[2]])

# UTC date and time
iy = np.array([2006])
mo = np.array([1])
d = np.array([15])
ih = np.array([21])
im = np.array([24])
sec = np.array([37.5])

# transform into intenal format
utc1, utc2 = erfa.dtf2d("UTC", iy,mo,d,ih,im,sec)

# UT1-UTC from IERS
Exemplo n.º 5
0
at sea level, on 2006 January 15 at 21:24:37.5 UTC
requires the time in all other supported time scales''')

# site terrestrial coordinates (WGS84)
latnd = +19
latnm = 28
slatn = 52.5
lonwd = -155
lonwm = 55
slonw = 59.6
hm = 0.

# transform to geocentric
phi = erfa.af2a(latnd, latnm, slatn)
elon = erfa.af2a(lonwd, lonwm, slonw)
xyz = erfa.gd2gc(1, elon, phi, hm)
u = math.hypot(xyz[0], xyz[1])
v = xyz[2]

# UTC date and time
iy = 2006
mo = 1
d = 15
ih = 21
im = 24
sec = 37.5

# transform into intenal format
utc1, utc2 = erfa.dtf2d(iy, mo, d, ih, im, sec, "UTC")

# UT1-UTC from IERS
Exemplo n.º 6
0
at sea level, on 2006 January 15 at 21:24:37.5 UTC
requires the time in all other supported time scales''')

# site terrestrial coordinates (WGS84)
latnd = +19
latnm = 28
slatn = 52.5
lonwd = -155
lonwm = 55
slonw = 59.6
hm = 0.

# transform to geocentric
phi = erfa.af2a(latnd, latnm, slatn)
elon = erfa.af2a(lonwd, lonwm, slonw)
xyz = erfa.gd2gc(1, elon, phi, hm)
u = math.hypot(xyz[0], xyz[1])
v = xyz[2]

# UTC date and time
iy = 2006
mo = 1
d = 15
ih = 21
im = 24
sec = 37.5

# transform into intenal format
utc1, utc2 = erfa.dtf2d(iy,mo,d,ih,im,sec, "UTC")

# UT1-UTC from IERS