5.2.10. nvector.core.mean_horizontal_position

mean_horizontal_position(n_EB_E)[source]

Returns the n-vector of the horizontal mean position.

Parameters
n_EB_E: 3 x n array

n-vectors [no unit] of positions Bi, decomposed in E.

Returns
p_EM_E: 3 x 1 array

n-vector [no unit] of the mean positions of all Bi, decomposed in E.

Notes

The result for spherical Earth is returned.

Examples

Example 7: “Mean position”

https://raw.githubusercontent.com/pbrod/Nvector/master/docs/tutorials/images/ex7img.png

Three positions A, B, and C are given as n-vectors n_EA_E, n_EB_E, and n_EC_E. Find the mean position, M, given as n_EM_E. Note that the calculation is independent of the depths of the positions.

Solution:
>>> import numpy as np
>>> import nvector as nv
>>> from nvector import rad, deg
>>> n_EA_E = nv.lat_lon2n_E(rad(90), rad(0))
>>> n_EB_E = nv.lat_lon2n_E(rad(60), rad(10))
>>> n_EC_E = nv.lat_lon2n_E(rad(50), rad(-20))
>>> n_EM_E = nv.unit(n_EA_E + n_EB_E + n_EC_E)
or
>>> n_EM_E = nv.mean_horizontal_position(np.hstack((n_EA_E, n_EB_E, n_EC_E)))
>>> lat, lon = nv.n_E2lat_lon(n_EM_E)
>>> lat, lon = deg(lat), deg(lon)
>>> msg = 'Ex7: Pos M: lat, lon = {:4.4f}, {:4.4f} deg'
>>> msg.format(lat[0], lon[0])
'Ex7: Pos M: lat, lon = 67.2362, -6.9175 deg'