Python numpy.core.umath.degrees() Examples

The following are code examples for showing how to use numpy.core.umath.degrees(). They are from open source Python projects. You can vote up the examples you like or vote down the ones you don't like.

Example 1
Project: LaserTOF   Author: kyleuckert   File: test_umath.py    MIT License 5 votes vote down vote up
def test_degrees(self):
        assert_almost_equal(ncu.degrees(np.pi), 180.0)
        assert_almost_equal(ncu.degrees(-0.5*np.pi), -90.0) 
Example 2
Project: FX-RER-Value-Extraction   Author: tsKenneth   File: test_umath.py    MIT License 5 votes vote down vote up
def test_degrees(self):
        assert_almost_equal(ncu.degrees(np.pi), 180.0)
        assert_almost_equal(ncu.degrees(-0.5*np.pi), -90.0) 
Example 3
Project: recruit   Author: Frank-qlu   File: test_umath.py    Apache License 2.0 5 votes vote down vote up
def test_degrees(self):
        assert_almost_equal(ncu.degrees(np.pi), 180.0)
        assert_almost_equal(ncu.degrees(-0.5*np.pi), -90.0) 
Example 4
Project: att   Author: Centre-Alt-Rendiment-Esportiu   File: test_umath.py    GNU General Public License v3.0 5 votes vote down vote up
def test_degrees(self):
        assert_almost_equal(ncu.degrees(np.pi), 180.0)
        assert_almost_equal(ncu.degrees(-0.5*np.pi), -90.0) 
Example 5
Project: FUTU_Stop_Loss   Author: BigtoC   File: test_umath.py    MIT License 5 votes vote down vote up
def test_degrees(self):
        assert_almost_equal(ncu.degrees(np.pi), 180.0)
        assert_almost_equal(ncu.degrees(-0.5*np.pi), -90.0) 
Example 6
Project: MARRtino-2.0   Author: DaniAffCH   File: test_umath.py    GNU General Public License v3.0 5 votes vote down vote up
def test_degrees(self):
        assert_almost_equal(ncu.degrees(np.pi), 180.0)
        assert_almost_equal(ncu.degrees(-0.5*np.pi), -90.0) 
Example 7
Project: auto-alt-text-lambda-api   Author: abhisuri97   File: test_umath.py    MIT License 5 votes vote down vote up
def test_degrees(self):
        assert_almost_equal(ncu.degrees(np.pi), 180.0)
        assert_almost_equal(ncu.degrees(-0.5*np.pi), -90.0) 
Example 8
Project: vnpy_crypto   Author: birforce   File: test_umath.py    MIT License 5 votes vote down vote up
def test_degrees(self):
        assert_almost_equal(ncu.degrees(np.pi), 180.0)
        assert_almost_equal(ncu.degrees(-0.5*np.pi), -90.0) 
Example 9
Project: ble5-nrf52-mac   Author: tomasero   File: test_umath.py    MIT License 5 votes vote down vote up
def test_degrees(self):
        assert_almost_equal(ncu.degrees(np.pi), 180.0)
        assert_almost_equal(ncu.degrees(-0.5*np.pi), -90.0) 
Example 10
Project: Computable   Author: ktraunmueller   File: test_umath.py    MIT License 5 votes vote down vote up
def test_degrees(self):
        assert_almost_equal(ncu.degrees(np.pi), 180.0)
        assert_almost_equal(ncu.degrees(-0.5*np.pi), -90.0) 
Example 11
Project: poker   Author: surgebiswas   File: test_umath.py    MIT License 5 votes vote down vote up
def test_degrees(self):
        assert_almost_equal(ncu.degrees(np.pi), 180.0)
        assert_almost_equal(ncu.degrees(-0.5*np.pi), -90.0) 
Example 12
Project: P3_image_processing   Author: latedude2   File: test_umath.py    MIT License 5 votes vote down vote up
def test_degrees(self):
        assert_almost_equal(ncu.degrees(np.pi), 180.0)
        assert_almost_equal(ncu.degrees(-0.5*np.pi), -90.0) 
Example 13
Project: GraphicDesignPatternByPython   Author: Relph1119   File: test_umath.py    MIT License 5 votes vote down vote up
def test_degrees(self):
        assert_almost_equal(ncu.degrees(np.pi), 180.0)
        assert_almost_equal(ncu.degrees(-0.5*np.pi), -90.0) 
Example 14
Project: pylgrim   Author: kirienko   File: ecef.py    GNU General Public License v3.0 5 votes vote down vote up
def ecef_to_lat_lon_alt(R, deg=True):
    """
    Fukushima implementation of the Bowring algorithm,
    see [3] -- equations (C7) - (C12)
    :param R: (X,Y,Z) -- coordinates in ECEF (numpy array)
    :param deg: if True then lat and lon are returned in degrees (rad otherwise)
    :return:  (φ,θ,h) -- lat [deg], lon [deg], alt in WGS84 (numpy array)
    """
    # WGS 84 constants
    a = 6378137.0  # Equatorial Radius [m]
    b = 6356752.314245  # Polar Radius [m]
    e = 0.08181919092890624  # e = sqrt(1-b²/a²)
    # e1 = sqrt(1 - e ** 2)  # e' = sqrt(1 - e²)
    e1 = 0.99664718932816898
    # c = a * e ** 2  # (6)
    c = 42697.67279723605
    if isinstance(R, list):
        R = np.array(R)
    p = sqrt(R[0] ** 2 + R[1] ** 2)  # (1) - sqrt(X² + Y²)
    T = R[2] / (e1 * p) or 1.  # (C8) - zero approximation
    for i in range(10):
        C = np.power(1 + T ** 2, -0.5)  # (C9)
        S = C * T  # (C9)
        T_new = (e1 * R[2] + c * S ** 3) / (p - c * C ** 3)  # (C7)
        delta = T_new - T
        T = T_new
        if abs(delta) / T < 1e-9:
            break
    theta = np.math.atan2(R[1], R[0])
    phi = np.math.atan2(T, e1)  # (C10)
    T1 = 1 + T ** 2
    if p > R[2]:  # (C11)
        h = sqrt(T1 - e ** 2) / e1 * (p - a / sqrt(T1))
    else:  # (C12)
        h = sqrt(T1 - e ** 2) * (R[2] / T - b / sqrt(T1))
    if deg:
        out = np.array([np.degrees(phi), np.degrees(theta), h])
    else:
        out = np.array([phi, theta, h])
    return out 
Example 15
Project: pylgrim   Author: kirienko   File: ecef.py    GNU General Public License v3.0 5 votes vote down vote up
def ecef_to_spherical(R, deg=True):
    """
    Fukushima implementation of the Bowring algorithm,
    see [3] -- equations (C7) - (C12)
    :param R: (X,Y,Z) -- coordinates in ECEF (numpy array)
    :param deg: if True then lat and lon are returned in degrees (rad otherwise)
    :return:  (φ,θ,h) -- lat [deg], lon [deg], alt in WGS84 (numpy array)
    """
    # WGS 84 constants
    a = 6366255.89  # Equatorial Radius [m]
    b = 6366255.89  # Polar Radius [m]
    e = 0.0  # e = sqrt(1-b²/a²)
    # e1 = sqrt(1 - e ** 2)  # e' = sqrt(1 - e²)
    e1 = 1.
    # c = a * e ** 2  # (6)
    c = 0.
    if isinstance(R, list):
        R = np.array(R)
    p = sqrt(R[0] ** 2 + R[1] ** 2)  # (1) - sqrt(X² + Y²)
    T = R[2] / (e1 * p) or 1.  # (C8) - zero approximation
    for i in range(10):
        C = np.power(1 + T ** 2, -0.5)  # (C9)
        S = C * T  # (C9)
        T_new = (e1 * R[2] + c * S ** 3) / (p - c * C ** 3)  # (C7)
        delta = T_new - T
        T = T_new
        if abs(delta) / T < 1e-9:
            break
    theta = np.math.atan2(R[1], R[0])
    phi = np.math.atan2(T, e1)  # (C10)
    T1 = 1 + T ** 2
    if p > R[2]:  # (C11)
        h = sqrt(T1 - e ** 2) / e1 * (p - a / sqrt(T1))
    else:  # (C12)
        h = sqrt(T1 - e ** 2) * (R[2] / T - b / sqrt(T1))
    if deg:
        out = np.array([np.degrees(phi), np.degrees(theta), h])
    else:
        out = np.array([phi, theta, h])
    return out 
Example 16
Project: pylgrim   Author: kirienko   File: ecef.py    GNU General Public License v3.0 5 votes vote down vote up
def sat_elev(R_u, R_sat, deg=True):
    """
    Zenith angle of some certain sat. relative to the user's position
    :param R_u:   (X,Y,Z) -- user's coordinates in ECEF (numpy array)
    :param R_sat: (X,Y,Z) -- satellite's coordinates in ECEF (numpy array)
    :param deg: whether to return angle in degrees
    :return: elevation angle of the satellite
    """
    elev = arcsin(sat_in_enu(R_u, R_sat)[2])
    # print "Elev angle = %.1f deg" % elev
    if deg:
        return degrees(elev)
    else:
        return elev 
Example 17
Project: pylgrim   Author: kirienko   File: ecef.py    GNU General Public License v3.0 5 votes vote down vote up
def sat_az(R_u, R_sat, deg=True):
    """
    Azimuth of some certain sat. relative to the user's position
    :param R_u:   (X,Y,Z) -- user's coordinates in ECEF (numpy array)
    :param R_sat: (X,Y,Z) -- satellite's coordinates in ECEF (numpy array)
    :param deg: whether to return angle in degrees
    :return: azimuth of the satellite
    """
    enu = sat_in_enu(R_u, R_sat)
    az = atan2(enu[0], enu[1])
    if deg:
        return degrees(az)
    else:
        return az 
Example 18
Project: 3dprinteros-client   Author: panasevychol   File: test_umath.py    GNU Affero General Public License v3.0 5 votes vote down vote up
def test_degrees(self):
        assert_almost_equal(ncu.degrees(np.pi), 180.0)
        assert_almost_equal(ncu.degrees(-0.5*np.pi), -90.0) 
Example 19
Project: 3dprinteros-client   Author: panasevychol   File: test_umath.py    GNU Affero General Public License v3.0 5 votes vote down vote up
def test_degrees(self):
        assert_almost_equal(ncu.degrees(np.pi), 180.0)
        assert_almost_equal(ncu.degrees(-0.5*np.pi), -90.0) 
Example 20
Project: predictive-maintenance-using-machine-learning   Author: awslabs   File: test_umath.py    Apache License 2.0 5 votes vote down vote up
def test_degrees(self):
        assert_almost_equal(ncu.degrees(np.pi), 180.0)
        assert_almost_equal(ncu.degrees(-0.5*np.pi), -90.0) 
Example 21
Project: fund   Author: Frank-qlu   File: test_umath.py    Apache License 2.0 5 votes vote down vote up
def test_degrees(self):
        assert_almost_equal(ncu.degrees(np.pi), 180.0)
        assert_almost_equal(ncu.degrees(-0.5*np.pi), -90.0) 
Example 22
Project: pySINDy   Author: luckystarufo   File: test_umath.py    MIT License 5 votes vote down vote up
def test_degrees(self):
        assert_almost_equal(ncu.degrees(np.pi), 180.0)
        assert_almost_equal(ncu.degrees(-0.5*np.pi), -90.0) 
Example 23
Project: linear_neuron   Author: uglyboxer   File: test_umath.py    MIT License 5 votes vote down vote up
def test_degrees(self):
        assert_almost_equal(ncu.degrees(np.pi), 180.0)
        assert_almost_equal(ncu.degrees(-0.5*np.pi), -90.0) 
Example 24
Project: facethin   Author: ParkerGod   File: test_umath.py    GNU General Public License v3.0 5 votes vote down vote up
def test_degrees(self):
        assert_almost_equal(ncu.degrees(np.pi), 180.0)
        assert_almost_equal(ncu.degrees(-0.5*np.pi), -90.0) 
Example 25
Project: islam-buddy   Author: hamir   File: test_umath.py    MIT License 5 votes vote down vote up
def test_degrees(self):
        assert_almost_equal(ncu.degrees(np.pi), 180.0)
        assert_almost_equal(ncu.degrees(-0.5*np.pi), -90.0) 
Example 26
Project: mxnet-lambda   Author: awslabs   File: test_umath.py    Apache License 2.0 5 votes vote down vote up
def test_degrees(self):
        assert_almost_equal(ncu.degrees(np.pi), 180.0)
        assert_almost_equal(ncu.degrees(-0.5*np.pi), -90.0) 
Example 27
Project: Deribit_funding_rate_indicator   Author: Dimasik007   File: test_umath.py    MIT License 5 votes vote down vote up
def test_degrees(self):
        assert_almost_equal(ncu.degrees(np.pi), 180.0)
        assert_almost_equal(ncu.degrees(-0.5*np.pi), -90.0) 
Example 28
Project: psychrometric-chart-makeover   Author: buds-lab   File: test_umath.py    MIT License 5 votes vote down vote up
def test_degrees(self):
        assert_almost_equal(ncu.degrees(np.pi), 180.0)
        assert_almost_equal(ncu.degrees(-0.5*np.pi), -90.0) 
Example 29
Project: wine-ml-on-aws-lambda   Author: pierreant   File: test_umath.py    Apache License 2.0 5 votes vote down vote up
def test_degrees(self):
        assert_almost_equal(ncu.degrees(np.pi), 180.0)
        assert_almost_equal(ncu.degrees(-0.5*np.pi), -90.0) 
Example 30
Project: linux-cross-gcc   Author: nmercier   File: test_umath.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_degrees(self):
        assert_almost_equal(ncu.degrees(np.pi), 180.0)
        assert_almost_equal(ncu.degrees(-0.5*np.pi), -90.0) 
Example 31
Project: SignLanguage_ML   Author: mareep-raljodid   File: test_umath.py    MIT License 5 votes vote down vote up
def test_degrees(self):
        assert_almost_equal(ncu.degrees(np.pi), 180.0)
        assert_almost_equal(ncu.degrees(-0.5*np.pi), -90.0) 
Example 32
Project: ImageFusion   Author: pfchai   File: test_umath.py    MIT License 5 votes vote down vote up
def test_degrees(self):
        assert_almost_equal(ncu.degrees(np.pi), 180.0)
        assert_almost_equal(ncu.degrees(-0.5*np.pi), -90.0) 
Example 33
Project: sarah   Author: ChonchoFronto   File: test_umath.py    MIT License 5 votes vote down vote up
def test_degrees(self):
        assert_almost_equal(ncu.degrees(np.pi), 180.0)
        assert_almost_equal(ncu.degrees(-0.5*np.pi), -90.0) 
Example 34
Project: honours_project   Author: JFriel   File: test_umath.py    GNU General Public License v3.0 5 votes vote down vote up
def test_degrees(self):
        assert_almost_equal(ncu.degrees(np.pi), 180.0)
        assert_almost_equal(ncu.degrees(-0.5*np.pi), -90.0) 
Example 35
Project: honours_project   Author: JFriel   File: test_umath.py    GNU General Public License v3.0 5 votes vote down vote up
def test_degrees(self):
        assert_almost_equal(ncu.degrees(np.pi), 180.0)
        assert_almost_equal(ncu.degrees(-0.5*np.pi), -90.0) 
Example 36
Project: Blackjack-Tracker   Author: martinabeleda   File: test_umath.py    MIT License 5 votes vote down vote up
def test_degrees(self):
        assert_almost_equal(ncu.degrees(np.pi), 180.0)
        assert_almost_equal(ncu.degrees(-0.5*np.pi), -90.0) 
Example 37
Project: PYPIC   Author: max614   File: test_umath.py    BSD 2-Clause "Simplified" License 5 votes vote down vote up
def test_degrees(self):
        assert_almost_equal(ncu.degrees(np.pi), 180.0)
        assert_almost_equal(ncu.degrees(-0.5*np.pi), -90.0) 
Example 38
Project: PYPIC   Author: max614   File: test_umath.py    BSD 2-Clause "Simplified" License 5 votes vote down vote up
def test_degrees(self):
        assert_almost_equal(ncu.degrees(np.pi), 180.0)
        assert_almost_equal(ncu.degrees(-0.5*np.pi), -90.0) 
Example 39
Project: PYPIC   Author: max614   File: test_umath.py    BSD 2-Clause "Simplified" License 5 votes vote down vote up
def test_degrees(self):
        assert_almost_equal(ncu.degrees(np.pi), 180.0)
        assert_almost_equal(ncu.degrees(-0.5*np.pi), -90.0) 
Example 40
Project: senior-design   Author: james-tate   File: test_umath.py    GNU General Public License v2.0 5 votes vote down vote up
def test_degrees(self):
        assert_almost_equal(ncu.degrees(np.pi), 180.0)
        assert_almost_equal(ncu.degrees(-0.5*np.pi), -90.0) 
Example 41
Project: offlow   Author: satwikkansal   File: test_umath.py    GNU General Public License v3.0 5 votes vote down vote up
def test_degrees(self):
        assert_almost_equal(ncu.degrees(np.pi), 180.0)
        assert_almost_equal(ncu.degrees(-0.5*np.pi), -90.0) 
Example 42
Project: lambda-tensorflow-object-detection   Author: mikylucky   File: test_umath.py    GNU General Public License v3.0 5 votes vote down vote up
def test_degrees(self):
        assert_almost_equal(ncu.degrees(np.pi), 180.0)
        assert_almost_equal(ncu.degrees(-0.5*np.pi), -90.0) 
Example 43
Project: elasticintel   Author: securityclippy   File: test_umath.py    GNU General Public License v3.0 5 votes vote down vote up
def test_degrees(self):
        assert_almost_equal(ncu.degrees(np.pi), 180.0)
        assert_almost_equal(ncu.degrees(-0.5*np.pi), -90.0) 
Example 44
Project: cnidaria   Author: sauloal   File: test_umath.py    MIT License 5 votes vote down vote up
def test_degrees(self):
        assert_almost_equal(ncu.degrees(np.pi), 180.0)
        assert_almost_equal(ncu.degrees(-0.5*np.pi), -90.0) 
Example 45
Project: AutoDraw   Author: yemi-Jump   File: test_umath.py    MIT License 5 votes vote down vote up
def test_degrees(self):
        assert_almost_equal(ncu.degrees(np.pi), 180.0)
        assert_almost_equal(ncu.degrees(-0.5*np.pi), -90.0) 
Example 46
Project: fund-rank-dashboard   Author: 1pani   File: test_umath.py    Apache License 2.0 5 votes vote down vote up
def test_degrees(self):
        assert_almost_equal(ncu.degrees(np.pi), 180.0)
        assert_almost_equal(ncu.degrees(-0.5*np.pi), -90.0) 
Example 47
Project: pylgrim   Author: kirienko   File: ecef.py    GNU General Public License v3.0 4 votes vote down vote up
def ecef_to_lat_lon_alt1(R, deg=True):
    """
    Fukushima implementation of the Bowring algorithm (2006),
    see [4] --
    :param R: (X,Y,Z) -- coordinates in ECEF (numpy array)
    :param deg: if True then lat and lon are returned in degrees (rad otherwise)
    :return:  (φ,θ,h) -- lat [deg], lon [deg], alt in WGS84 (numpy array)
    """
    # WGS 84 constants
    a = 6378137.0  # Equatorial Radius [m]
    b = 6356752.314245  # Polar Radius [m]
    e = 0.08181919092890624  # e = sqrt(1-b²/a²)
    E = e ** 2
    e1 = sqrt(1 - e ** 2)  # e' = sqrt(1 - e²)
    if isinstance(R, list): R = np.array(R)
    p = sqrt(R[0] ** 2 + R[1] ** 2)  # (1) - sqrt(X² + Y²)
    az = abs(R[2])
    Z = e1 * az / a
    P = p / a
    S, C = Z or 1, e1 * P or 1  # (C8) - zero approximation
    max_iter = 5
    for i in range(max_iter):
        A = sqrt(S ** 2 + C ** 2)
        Cn = P * A ** 3 - E * C ** 3
        Sn = Z * A ** 3 + E * S ** 3
        delta = abs(Sn / Cn - S / C) * C / S
        if isnan(delta):
            return ecef_to_lat_lon_alt1(R)
        if abs(delta) < 1e-10 or i == max_iter - 1:
            break
        S, C = Sn, Cn
    theta = np.math.atan2(R[1], R[0])
    Cc = e1 * Cn
    phi = np.sign(R[2]) * np.math.atan2(Sn, Cc)
    h = (p * Cc + az * Sn - b * sqrt(Sn ** 2 + Cn ** 2)) / sqrt(Cc ** 2 + Sn ** 2)
    if deg:
        out = np.array([np.degrees(phi), np.degrees(theta), h])
    else:
        out = np.array([phi, theta, h])
    # if filter(isnan, out):
    #     return ecef_to_lat_lon_alt1(R)
    return out