pymgp.crstrans.ellrotmatrix#

pymgp.crstrans.ellrotmatrix(ref, mode='plh', unit='rad')[source]#

Rotation matrix for ECEF to topocentric coordinates.

Compute rotation matrix/matrices to transform coordinate differences alligned to an ECEF frame into a topocentric reference frame with North, East, Up coordinates.

Parameters:
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 more than one coordinate triplet/doublet.

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, but not used.

  • ‘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.

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

Units for latitude and longitude, only useful in case the mode=’plh’ option is used.

Returns:
Rndarray with shape (…,3,3)

Rotation matrix(es) to transform dxyz into neu, with neu = dxyz @ R. In case ref is a vector, R becomes a 3-by-3 matrix , in case ref is a multidimensional array, R will have one more dimension than ref with shape (…,3,3).

Notes

The parameters are passed to ellnormal to compute the unit normal vector from which the rotation matrix is computed.

The rotation is defined as:

neu = dxyz @  R     or    neu = R.T @ dxyz.T   , and    Qneu =  R.T @ Qxyz @ R     
dxyz =  neu @ R.T   or    dxyz = R @ neu.T     , and    Qxyz =  R @ Qneu @ R.T

For a rotation matrix with more than two dimensions, Einstein multiplication should be used:

neu = np.einsum('...ji,...j',R,dxyz)   or  neu = np.einsum('...j,...ji',dxyz,R)
dxyz = np.einsum('...ij,...j',R,neu)   or  dxyz = np.einsum('...ij,...j',R,neu)

Einstein multiplication also works for two dimensions. For coordinate transformations the results are identical to the more efficient and powerful functions xyz2neu and neu2xyz.

The rotation matrix is used by covtransform to convert covariance matrices.

Examples

>>> R = ellrotmatrix([52, 4], unit='deg')  
>>> print(R)
[[-0.7860912  -0.06975647  0.61416175]
 [-0.05496885  0.99756405  0.04294637]
 [ 0.61566148  0.          0.78801075]]
>>> dxyz=np.array([[1, 1, 1],[2, 1, 3]])
>>> neu = dxyz @ R
>>> print(neu)
[[-0.22539858  0.92780758  1.44511888]
 [ 0.21983318  0.8580511   3.63530214]]
>>> np.einsum('...ji,...j',R,dxyz)
array([[-0.22539858,  0.92780758,  1.44511888],
       [ 0.21983318,  0.8580511 ,  3.63530214]])
>>> np.einsum('...ij,...j',R,neu)
array([[1., 1., 1.],
       [2., 1., 3.]])
>>> R = ellrotmatrix([[52, 4],[52, -34]], unit='deg')  
>>> print(R.shape)
(2, 3, 3)
>>> dxyz=np.array([[1, 1, 1],[2, 1, 3]])
>>> np.einsum('...ji,...j',R,dxyz)
array([[-0.22539858,  0.92780758,  1.44511888],
       [ 0.9810534 ,  1.94742338,  3.04057172]])