pymgp.crstrans.zas2xyz#

pymgp.crstrans.zas2xyz(zas, ref, origin='ref', mode='plh', refunit='rad', zasunit='rad/m')[source]#

Zenith angle, azimuth and distance to cartesian XYZ coordinates.

Parameters:
zasarray_like with shape (…,3)

Zenith angle, azimuth angle and distance from ref to xyz.

refarray_like with shape (…,3) or (…,2)

Reference position(s) on the ellipsoid. The type of coordinates are specified by mode. ref can be a vector with a single coordinate triplet/doublet or have a similar shape to neu. The North, East, Up coordinates for the(se) point(s) are (0, 0, 0). In case ref is a single coordinate triplet/doublet then the same reference points is used for all the points in neu.

origin{‘ref’, ‘ecef’}, default=’ref’

Origin of the coordinates in the output XYZ coordinates. If origin=’ref’ then the XYZ coordinates in the output are with respect to the point(s) given in ref. The other possibility is coordinates in the ECEF reference frame with the origin at the center of the Earth.

mode{‘plh’, ‘xyz’,’normal’}, default = ‘plh’

Coordinate type for ref. Possible values are:

  • ‘plh’ : ref contains the geographic latitude and longitude with the unit specified by unit. A third coordinate with the height is optional.

  • ‘xyz’ : ref contains cartesian XYZ coordinates in the ECEF of a point (close) to the ellipsoid. The normal vector is computed for a point on the ellipsoid above or below ref.

  • ‘normal’ : ref contains a normal vector with Cartesian coordinates. It does not necessaraly have to be a unit vector (the function returns the unit vector).

refunit{‘rad’, ‘deg’}, default = ‘rad’

Units for latitude and longitude, only useful in case the ‘plh’ options is used.

zasunit{‘rad/m’, ‘deg/m’}, default = ‘rad/m’

Units for latitude and longitude, only useful in case the ‘plh’ options is used.

Returns:
xyzndarray with shape (…,3)

Cartesian XYZ coordinates. The origin is either in the center of the Earth or at the position given by ref.

Examples

Define a test case

>>> ref = [52*np.pi/180, 4*np.pi/180, 0 ]
>>> refxyz = plh2xyz([52, 4, 0],unit='deg')
>>> zas = [0.1, np.pi/2, 1000]

The following examples have the same result

>>> dxyz = zas2xyz(zas, ref)
>>> dxyz = zas2xyz(zas, [52, 4, 0], refunit='deg')
>>> dxyz = zas2xyz(zas, refxyz, mode='xyz')
>>> print(dxyz)
[604.12947719 142.32204802 784.07398212]

Same, but with ref coordinates added

>>> xyz = zas2xyz(zas, refxyz, origin='ecef', mode='xyz')
>>> print(np.round(xyz,4))
[3925979.2303  274631.2885 5003587.4194]

The following two examples do not give the same results because the up-direction is different (geodetic versus astronomic)

>>> zas2xyz(zas, refxyz, mode='xyz')   # same result as dxyz=zas2xyz(zas,ref)
array([604.12947719, 142.32204802, 784.07398212])
>>> zas2xyz(zas, refxyz, mode='normal')
array([606.67710196, 142.50019529, 782.07198409])

Multi dimensional examples with all the same result

>>> zas = xyz2zas([[ 1, 1, 1],[ 2, 2, 2],[ 3, 0, 0],[ 0, 4, 1]],ref)
>>> dxyz = zas2xyz(zas, ref)                    # ref is a single coordinate doublet
>>> dxyz = zas2xyz(zas, refxyz, mode='xyz')    
>>> dxyz = zas2xyz(zas, [ref ,ref, ref, ref])   # matching shapes (ref can be different for each point)
>>> print(np.round(dxyz,14))
[[1. 1. 1.]
 [2. 2. 2.]
 [3. 0. 0.]
 [0. 4. 1.]]