pymgp.crstrans.xyz2zas#

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

Cartesian XYZ coordinates to zenith angle, azimuth and distance.

Parameters:
xyzarray_like with shape (…,3)

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

refarray_like 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 xyz. 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 xyz.

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

Origin of the coordinates in xyz. If origin=’ref’ then the XYZ coordinates in xyz 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 necessarily 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 zenith angle and azimuth.

Returns:
zasndarray with shape similar to xyz.

Zenith angle (z), azimuth angle (a) and distance (s) from ref to xyz.

Examples

Define a test case

>>> ref = [52*np.pi/180, 4*np.pi/180 ]
>>> refxyz = plh2xyz([52, 4, 0],unit='deg')
>>> dxyz = [1, 1, 1]
>>> xyz = refxyz + np.array(dxyz)

The following examples have the same result

>>> zas = xyz2zas(dxyz, ref)
>>> zas = xyz2zas(dxyz, [52, 4], refunit='deg')
>>> zas = xyz2zas(dxyz, refxyz, mode='xyz')
>>> zas = xyz2zas(xyz , refxyz, mode='xyz', origin='ecef')
>>> zas = xyz2zas(xyz, [52, 4, 0], origin='ecef', refunit='deg')
>>> print(zas)
[0.58386231 1.80911628 1.73205081]

Check that the inverse function returns the original

>>> zas2xyz(zas,ref)
array([1., 1., 1.])

The following examples also have all the same result

>>> dxyz = [[ 1, 1, 1],[ 2, 2, 2],[ 3, 0, 0],[ 0, 4, 1]] 
>>> zas = xyz2zas(dxyz, ref)                    # ref is a single coordinate doublet
>>> zas = xyz2zas(dxyz, refxyz, mode='xyz')    
>>> zas = xyz2zas(dxyz, [ref ,ref, ref, ref])   # matching shapes (ref can be different for each point)
>>> zas = xyz2zas(dxyz, [ refxyz ,refxyz, refxyz, refxyz], mode='xyz')
>>> print(zas)
[[ 0.58386231  1.80911628  1.73205081]
 [ 0.58386231  1.80911628  3.46410162]
 [ 0.90947297 -3.05308608  3.        ]
 [ 1.33585617  1.47193157  4.12310563]]

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

>>> dxyz = [1, 1, 1]
>>> xyz2zas(dxyz, refxyz, mode='xyz')     # same result as z, a, s = xyz2zas(dxyz,ref)
array([0.58386231, 1.80911628, 1.73205081])
>>> xyz2zas(dxyz, refxyz, mode='normal')
array([0.58310003, 1.80431289, 1.73205081])