Skip to content
Snippets Groups Projects
Commit ddf0b2bd authored by Raphael's avatar Raphael
Browse files

angular mean fixed

parent 750d79a2
No related branches found
No related tags found
1 merge request!6Develop
......@@ -18,13 +18,13 @@ def angular_mean(x):
theta = abs(np.arctan2(X, Y))
if Y > 0 and X > 0:
if Y > 0 and X > 0: # first Q
return theta
if Y > 0 >= X:
return np.pi/2 - theta
if Y > 0 >= X: # Second Q
return np.pi/2 + theta
if Y <= 0 < X:
return np.pi + theta
else:
return 2 * np.pi + theta
if Y <= 0 < X: # Fourth Q
return np.pi/2 - theta
else: #Third Q
return - theta
......@@ -34,9 +34,9 @@ class TestAngular(unittest.TestCase):
def test_angular_mean_third_quadrant(self):
x = np.radians(np.array([223, 224, 225, 226, 227]))
self.assertEqual(5*np.pi / 4, angular_mean(x))
self.assertEqual(-3*np.pi / 4, angular_mean(x))
def test_angular_mean_fourth_quadrant(self):
x = np.radians(np.array([313, 314, 315, 316, 317]))
self.assertEqual(7*np.pi / 4, angular_mean(x))
self.assertEqual(-np.pi / 4, angular_mean(x))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment