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

angular mean fixed

parent 750d79a2
Branches
Tags
1 merge request!6Develop
...@@ -18,13 +18,13 @@ def angular_mean(x): ...@@ -18,13 +18,13 @@ def angular_mean(x):
theta = abs(np.arctan2(X, Y)) theta = abs(np.arctan2(X, Y))
if Y > 0 and X > 0: if Y > 0 and X > 0: # first Q
return theta return theta
if Y > 0 >= X: if Y > 0 >= X: # Second Q
return np.pi/2 - theta return np.pi/2 + theta
if Y <= 0 < X: if Y <= 0 < X: # Fourth Q
return np.pi + theta return np.pi/2 - theta
else: else: #Third Q
return 2 * np.pi + theta return - theta
...@@ -34,9 +34,9 @@ class TestAngular(unittest.TestCase): ...@@ -34,9 +34,9 @@ class TestAngular(unittest.TestCase):
def test_angular_mean_third_quadrant(self): def test_angular_mean_third_quadrant(self):
x = np.radians(np.array([223, 224, 225, 226, 227])) 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): def test_angular_mean_fourth_quadrant(self):
x = np.radians(np.array([313, 314, 315, 316, 317])) 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