From 1342efe1d8e833ad4f2f131f5969fb818cb16b18 Mon Sep 17 00:00:00 2001 From: dyahalomi Date: Wed, 8 Sep 2021 18:55:29 -0400 Subject: [PATCH 01/16] add get_star_relative_angles --- src/exoplanet/orbits/keplerian.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/exoplanet/orbits/keplerian.py b/src/exoplanet/orbits/keplerian.py index 4ec2aa04..c2ff4916 100644 --- a/src/exoplanet/orbits/keplerian.py +++ b/src/exoplanet/orbits/keplerian.py @@ -566,6 +566,34 @@ def get_relative_angles(self, t, parallax=None, light_delay=False): theta = tt.squeeze(tt.arctan2(Y, X)) # radians between [-pi, pi] return (rho, theta) + + + + def get_star_relative_angles(self, t, parallax=None, light_delay=False): + """The stars' relative position to the star in the sky plane, in + separation, position angle coordinates. + .. note:: This treats each planet independently and does not take the + other planets into account when computing the position of the + star. This is fine as long as the planet masses are small. + Args: + t: The times where the position should be evaluated. + light_delay: account for the light travel time delay? Default is + False. + Returns: + The separation (arcseconds) and position angle (radians, + measured east of north) of the planet relative to the star. + """ + X, Y, Z = self._get_star_position( + -self.a, t, parallax, light_delay=light_delay + ) + + # calculate rho and theta + rho = tt.squeeze(tt.sqrt(X ** 2 + Y ** 2)) # arcsec + theta = tt.squeeze(tt.arctan2(Y, X)) # radians between [-pi, pi] + + return (rho, theta) + + def _get_velocity(self, m, t): """Get the velocity vector of a body in the observer frame""" From a1795caecd13b3d53b2ee70daaac7d89b953625f Mon Sep 17 00:00:00 2001 From: dyahalomi Date: Wed, 8 Sep 2021 18:57:17 -0400 Subject: [PATCH 02/16] add tests for get relative angle functions --- tests/orbits/keplerian_test.py | 75 ++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/tests/orbits/keplerian_test.py b/tests/orbits/keplerian_test.py index 8e8dba91..dce8c0fd 100644 --- a/tests/orbits/keplerian_test.py +++ b/tests/orbits/keplerian_test.py @@ -703,3 +703,78 @@ def test_jacobians(): orbit.jacobians["b"]["cos_incl"].eval(), theano.grad(orbit.cos_incl, bv).eval(), ) + + +def test_relative_angles(): + #test seperation and position angle with Earth and Sun + p_earth=365.256 + t = np.linspace(0, 1000, 1000) + m_earth = 1.*3.00273e-6 #units m_sun + orbit_earth = xo.orbits.KeplerianOrbit( + m_star=1., + r_star=1., + t0=0.5, + period=p_earth, + ecc=0.0167, + omega=np.radians(102.9), + Omega=np.radians(0.0), + incl=np.radians(45.0), + m_planet=m_earth, + ) + + + rho_star_earth, theta_star_earth = theano.function([], orbit_earth._get_star_relative_angles(t, parallax=0.1))() + rho_earth, theta_earth = theano.function([], orbit_earth._get_relative_angles(t, parallax=0.1))() + + rho_star_earth_diff = np.max(rho_star_earth) - np.min(rho_star_earth) + rho_earth_diff = np.max(rho_earth)- np.min(rho_earth) + + + #make sure amplitude of separation is correct for star and planet motion + assert np.isclose(rho_earth_diff, 3.0813126e-02) + assert np.isclose(rho_star_earth_diff, 9.2523221e-08) + + + #make sure planet and star position angle closely mirrors each other + assert np.allclose(theta_earth[:int(p_earth/2)], theta_star_earth[int(p_earth/2):int(p_earth)-1], atol=0.2) + + + + #test seperation with Jupiter and Sun + p_jup=4327.631 + t = np.linspace(0, 10000, 10000) + m_jup = 317.83*3.00273e-6 #units m_sun + orbit_jup = KeplerianOrbit( + m_star=1., + r_star=1., + t0=2000, + period=p_jup, + ecc=0.0484, + omega=np.radians(274.3) - 2*np.pi, + Omega=np.radians(100.4), + incl=np.radians(45.0), + m_planet=m_jup, + ) + + + rho_star_jup, theta_star_jup = theano.function([], orbit_jup._get_star_relative_angles(t, parallax=0.1))() + rho_jup, theta_jup = theano.function([], orbit_jup._get_relative_angles(t, parallax=0.1))() + + rho_star_earth_diff = np.max(rho_star_jup) - np.min(rho_star_jup) + rho_earth_diff = np.max(rho_jup)- np.min(rho_jup) + + + #make sure amplitude of separation is correct for star and planet motion + assert np.isclose(rho_jup_diff, 1.7190731e-01) + assert np.isclose(rho_star_jup_diff, 1.6390463e-04) + + + #make sure planet and star position angle closely mirrors each other + assert np.allclose(theta_jup[:int(p_jup/2)], theta_star_jup[int(p_jup/2):int(p_jup)-1], atol=0.2) + + + + + + + From 33fbb624756d9819f9be1e6d780b6f2b706050ed Mon Sep 17 00:00:00 2001 From: dyahalomi Date: Wed, 8 Sep 2021 19:00:12 -0400 Subject: [PATCH 03/16] add tests of get relative angle functions --- tests/orbits/keplerian_test.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/orbits/keplerian_test.py b/tests/orbits/keplerian_test.py index dce8c0fd..1d27a991 100644 --- a/tests/orbits/keplerian_test.py +++ b/tests/orbits/keplerian_test.py @@ -706,7 +706,8 @@ def test_jacobians(): def test_relative_angles(): - #test seperation and position angle with Earth and Sun + + #test separation and position angle with Earth and Sun p_earth=365.256 t = np.linspace(0, 1000, 1000) m_earth = 1.*3.00273e-6 #units m_sun @@ -739,8 +740,9 @@ def test_relative_angles(): assert np.allclose(theta_earth[:int(p_earth/2)], theta_star_earth[int(p_earth/2):int(p_earth)-1], atol=0.2) - - #test seperation with Jupiter and Sun + ######################################## + ######################################## + #test separation with Jupiter and Sun p_jup=4327.631 t = np.linspace(0, 10000, 10000) m_jup = 317.83*3.00273e-6 #units m_sun From 991313c6c2ae9971d53e0ad0871260f909cf7af5 Mon Sep 17 00:00:00 2001 From: dyahalomi Date: Wed, 8 Sep 2021 19:01:19 -0400 Subject: [PATCH 04/16] add tests for relative angle functions --- tests/orbits/keplerian_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/orbits/keplerian_test.py b/tests/orbits/keplerian_test.py index 1d27a991..fd76bdc1 100644 --- a/tests/orbits/keplerian_test.py +++ b/tests/orbits/keplerian_test.py @@ -742,7 +742,7 @@ def test_relative_angles(): ######################################## ######################################## - #test separation with Jupiter and Sun + #test separation and position angle with Jupiter and Sun p_jup=4327.631 t = np.linspace(0, 10000, 10000) m_jup = 317.83*3.00273e-6 #units m_sun From 2f4a179a5afffd4e9af7ed2a563ebbe3ec250446 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 8 Sep 2021 23:07:04 +0000 Subject: [PATCH 05/16] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/exoplanet/orbits/keplerian.py | 6 +-- tests/orbits/keplerian_test.py | 82 ++++++++++++++++--------------- 2 files changed, 45 insertions(+), 43 deletions(-) diff --git a/src/exoplanet/orbits/keplerian.py b/src/exoplanet/orbits/keplerian.py index c2ff4916..a0d93030 100644 --- a/src/exoplanet/orbits/keplerian.py +++ b/src/exoplanet/orbits/keplerian.py @@ -566,9 +566,9 @@ def get_relative_angles(self, t, parallax=None, light_delay=False): theta = tt.squeeze(tt.arctan2(Y, X)) # radians between [-pi, pi] return (rho, theta) - - - + + + def get_star_relative_angles(self, t, parallax=None, light_delay=False): """The stars' relative position to the star in the sky plane, in separation, position angle coordinates. diff --git a/tests/orbits/keplerian_test.py b/tests/orbits/keplerian_test.py index fd76bdc1..b8197db4 100644 --- a/tests/orbits/keplerian_test.py +++ b/tests/orbits/keplerian_test.py @@ -703,17 +703,17 @@ def test_jacobians(): orbit.jacobians["b"]["cos_incl"].eval(), theano.grad(orbit.cos_incl, bv).eval(), ) - - + + def test_relative_angles(): - - #test separation and position angle with Earth and Sun - p_earth=365.256 + + # test separation and position angle with Earth and Sun + p_earth = 365.256 t = np.linspace(0, 1000, 1000) - m_earth = 1.*3.00273e-6 #units m_sun + m_earth = 1.0 * 3.00273e-6 # units m_sun orbit_earth = xo.orbits.KeplerianOrbit( - m_star=1., - r_star=1., + m_star=1.0, + r_star=1.0, t0=0.5, period=p_earth, ecc=0.0167, @@ -723,60 +723,62 @@ def test_relative_angles(): m_planet=m_earth, ) - - rho_star_earth, theta_star_earth = theano.function([], orbit_earth._get_star_relative_angles(t, parallax=0.1))() - rho_earth, theta_earth = theano.function([], orbit_earth._get_relative_angles(t, parallax=0.1))() + rho_star_earth, theta_star_earth = theano.function( + [], orbit_earth._get_star_relative_angles(t, parallax=0.1) + )() + rho_earth, theta_earth = theano.function( + [], orbit_earth._get_relative_angles(t, parallax=0.1) + )() rho_star_earth_diff = np.max(rho_star_earth) - np.min(rho_star_earth) - rho_earth_diff = np.max(rho_earth)- np.min(rho_earth) - + rho_earth_diff = np.max(rho_earth) - np.min(rho_earth) - #make sure amplitude of separation is correct for star and planet motion + # make sure amplitude of separation is correct for star and planet motion assert np.isclose(rho_earth_diff, 3.0813126e-02) assert np.isclose(rho_star_earth_diff, 9.2523221e-08) - - #make sure planet and star position angle closely mirrors each other - assert np.allclose(theta_earth[:int(p_earth/2)], theta_star_earth[int(p_earth/2):int(p_earth)-1], atol=0.2) - + # make sure planet and star position angle closely mirrors each other + assert np.allclose( + theta_earth[: int(p_earth / 2)], + theta_star_earth[int(p_earth / 2) : int(p_earth) - 1], + atol=0.2, + ) ######################################## ######################################## - #test separation and position angle with Jupiter and Sun - p_jup=4327.631 + # test separation and position angle with Jupiter and Sun + p_jup = 4327.631 t = np.linspace(0, 10000, 10000) - m_jup = 317.83*3.00273e-6 #units m_sun + m_jup = 317.83 * 3.00273e-6 # units m_sun orbit_jup = KeplerianOrbit( - m_star=1., - r_star=1., + m_star=1.0, + r_star=1.0, t0=2000, period=p_jup, ecc=0.0484, - omega=np.radians(274.3) - 2*np.pi, + omega=np.radians(274.3) - 2 * np.pi, Omega=np.radians(100.4), incl=np.radians(45.0), m_planet=m_jup, ) - - rho_star_jup, theta_star_jup = theano.function([], orbit_jup._get_star_relative_angles(t, parallax=0.1))() - rho_jup, theta_jup = theano.function([], orbit_jup._get_relative_angles(t, parallax=0.1))() + rho_star_jup, theta_star_jup = theano.function( + [], orbit_jup._get_star_relative_angles(t, parallax=0.1) + )() + rho_jup, theta_jup = theano.function( + [], orbit_jup._get_relative_angles(t, parallax=0.1) + )() rho_star_earth_diff = np.max(rho_star_jup) - np.min(rho_star_jup) - rho_earth_diff = np.max(rho_jup)- np.min(rho_jup) + rho_earth_diff = np.max(rho_jup) - np.min(rho_jup) - - #make sure amplitude of separation is correct for star and planet motion + # make sure amplitude of separation is correct for star and planet motion assert np.isclose(rho_jup_diff, 1.7190731e-01) assert np.isclose(rho_star_jup_diff, 1.6390463e-04) - - #make sure planet and star position angle closely mirrors each other - assert np.allclose(theta_jup[:int(p_jup/2)], theta_star_jup[int(p_jup/2):int(p_jup)-1], atol=0.2) - - - - - - - + # make sure planet and star position angle closely mirrors each other + assert np.allclose( + theta_jup[: int(p_jup / 2)], + theta_star_jup[int(p_jup / 2) : int(p_jup) - 1], + atol=0.2, + ) From 50c7ad00da602ddfd00d598f711e2a329048ca7a Mon Sep 17 00:00:00 2001 From: dyahalomi Date: Thu, 9 Sep 2021 15:55:19 -0400 Subject: [PATCH 06/16] fix syntax issues --- tests/orbits/keplerian_test.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/orbits/keplerian_test.py b/tests/orbits/keplerian_test.py index b8197db4..9c727bd3 100644 --- a/tests/orbits/keplerian_test.py +++ b/tests/orbits/keplerian_test.py @@ -711,7 +711,7 @@ def test_relative_angles(): p_earth = 365.256 t = np.linspace(0, 1000, 1000) m_earth = 1.0 * 3.00273e-6 # units m_sun - orbit_earth = xo.orbits.KeplerianOrbit( + orbit_earth = KeplerianOrbit( m_star=1.0, r_star=1.0, t0=0.5, @@ -720,7 +720,7 @@ def test_relative_angles(): omega=np.radians(102.9), Omega=np.radians(0.0), incl=np.radians(45.0), - m_planet=m_earth, + m_planet=m_earth ) rho_star_earth, theta_star_earth = theano.function( @@ -741,7 +741,7 @@ def test_relative_angles(): assert np.allclose( theta_earth[: int(p_earth / 2)], theta_star_earth[int(p_earth / 2) : int(p_earth) - 1], - atol=0.2, + atol=0.2 ) ######################################## @@ -759,7 +759,7 @@ def test_relative_angles(): omega=np.radians(274.3) - 2 * np.pi, Omega=np.radians(100.4), incl=np.radians(45.0), - m_planet=m_jup, + m_planet=m_jup ) rho_star_jup, theta_star_jup = theano.function( @@ -780,5 +780,5 @@ def test_relative_angles(): assert np.allclose( theta_jup[: int(p_jup / 2)], theta_star_jup[int(p_jup / 2) : int(p_jup) - 1], - atol=0.2, + atol=0.2 ) From 9b206b8cdca664647ff29534a544084e2722a0da Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 9 Sep 2021 19:55:30 +0000 Subject: [PATCH 07/16] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/orbits/keplerian_test.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/orbits/keplerian_test.py b/tests/orbits/keplerian_test.py index 9c727bd3..a3ac0c23 100644 --- a/tests/orbits/keplerian_test.py +++ b/tests/orbits/keplerian_test.py @@ -720,7 +720,7 @@ def test_relative_angles(): omega=np.radians(102.9), Omega=np.radians(0.0), incl=np.radians(45.0), - m_planet=m_earth + m_planet=m_earth, ) rho_star_earth, theta_star_earth = theano.function( @@ -741,7 +741,7 @@ def test_relative_angles(): assert np.allclose( theta_earth[: int(p_earth / 2)], theta_star_earth[int(p_earth / 2) : int(p_earth) - 1], - atol=0.2 + atol=0.2, ) ######################################## @@ -759,7 +759,7 @@ def test_relative_angles(): omega=np.radians(274.3) - 2 * np.pi, Omega=np.radians(100.4), incl=np.radians(45.0), - m_planet=m_jup + m_planet=m_jup, ) rho_star_jup, theta_star_jup = theano.function( @@ -780,5 +780,5 @@ def test_relative_angles(): assert np.allclose( theta_jup[: int(p_jup / 2)], theta_star_jup[int(p_jup / 2) : int(p_jup) - 1], - atol=0.2 + atol=0.2, ) From a6e860128ac14ea0e1d003d4e9a17e9711aa45e4 Mon Sep 17 00:00:00 2001 From: dyahalomi Date: Thu, 9 Sep 2021 16:01:21 -0400 Subject: [PATCH 08/16] fix syntax issues --- src/exoplanet/orbits/keplerian.py | 40 +++++++++++++++---------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/exoplanet/orbits/keplerian.py b/src/exoplanet/orbits/keplerian.py index a0d93030..ca727988 100644 --- a/src/exoplanet/orbits/keplerian.py +++ b/src/exoplanet/orbits/keplerian.py @@ -570,28 +570,28 @@ def get_relative_angles(self, t, parallax=None, light_delay=False): def get_star_relative_angles(self, t, parallax=None, light_delay=False): - """The stars' relative position to the star in the sky plane, in - separation, position angle coordinates. - .. note:: This treats each planet independently and does not take the - other planets into account when computing the position of the - star. This is fine as long as the planet masses are small. - Args: - t: The times where the position should be evaluated. - light_delay: account for the light travel time delay? Default is - False. - Returns: - The separation (arcseconds) and position angle (radians, - measured east of north) of the planet relative to the star. - """ - X, Y, Z = self._get_star_position( - -self.a, t, parallax, light_delay=light_delay - ) + """The stars' relative position to the star in the sky plane, in + separation, position angle coordinates. + .. note:: This treats each planet independently and does not take the + other planets into account when computing the position of the + star. This is fine as long as the planet masses are small. + Args: + t: The times where the position should be evaluated. + light_delay: account for the light travel time delay? Default is + False. + Returns: + The separation (arcseconds) and position angle (radians, + measured east of north) of the planet relative to the star. + """ + X, Y, Z = self.get_star_position( + -self.a, t, parallax, light_delay=light_delay + ) - # calculate rho and theta - rho = tt.squeeze(tt.sqrt(X ** 2 + Y ** 2)) # arcsec - theta = tt.squeeze(tt.arctan2(Y, X)) # radians between [-pi, pi] + # calculate rho and theta + rho = tt.squeeze(tt.sqrt(X ** 2 + Y ** 2)) # arcsec + theta = tt.squeeze(tt.arctan2(Y, X)) # radians between [-pi, pi] - return (rho, theta) + return (rho, theta) From ac18ee40be0a4bdd120c2753629358c2ef96306a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 9 Sep 2021 20:01:32 +0000 Subject: [PATCH 09/16] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/exoplanet/orbits/keplerian.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/exoplanet/orbits/keplerian.py b/src/exoplanet/orbits/keplerian.py index ca727988..8bcf5ddd 100644 --- a/src/exoplanet/orbits/keplerian.py +++ b/src/exoplanet/orbits/keplerian.py @@ -567,8 +567,6 @@ def get_relative_angles(self, t, parallax=None, light_delay=False): return (rho, theta) - - def get_star_relative_angles(self, t, parallax=None, light_delay=False): """The stars' relative position to the star in the sky plane, in separation, position angle coordinates. @@ -593,8 +591,6 @@ def get_star_relative_angles(self, t, parallax=None, light_delay=False): return (rho, theta) - - def _get_velocity(self, m, t): """Get the velocity vector of a body in the observer frame""" sinf, cosf = self._get_true_anomaly(t) From b99283931da938095a7ca7be7fa6e66f5fd82928 Mon Sep 17 00:00:00 2001 From: dyahalomi Date: Thu, 9 Sep 2021 16:22:13 -0400 Subject: [PATCH 10/16] fix syntax issues --- tests/orbits/keplerian_test.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/orbits/keplerian_test.py b/tests/orbits/keplerian_test.py index a3ac0c23..661a939e 100644 --- a/tests/orbits/keplerian_test.py +++ b/tests/orbits/keplerian_test.py @@ -724,10 +724,10 @@ def test_relative_angles(): ) rho_star_earth, theta_star_earth = theano.function( - [], orbit_earth._get_star_relative_angles(t, parallax=0.1) + [], orbit_earth.get_star_relative_angles(t, parallax=0.1) )() rho_earth, theta_earth = theano.function( - [], orbit_earth._get_relative_angles(t, parallax=0.1) + [], orbit_earth.get_relative_angles(t, parallax=0.1) )() rho_star_earth_diff = np.max(rho_star_earth) - np.min(rho_star_earth) @@ -763,10 +763,10 @@ def test_relative_angles(): ) rho_star_jup, theta_star_jup = theano.function( - [], orbit_jup._get_star_relative_angles(t, parallax=0.1) + [], orbit_jup.get_star_relative_angles(t, parallax=0.1) )() rho_jup, theta_jup = theano.function( - [], orbit_jup._get_relative_angles(t, parallax=0.1) + [], orbit_jup.get_relative_angles(t, parallax=0.1) )() rho_star_earth_diff = np.max(rho_star_jup) - np.min(rho_star_jup) From 1620ae0856ca0cdc289b7201c22e4bdf34adbb4c Mon Sep 17 00:00:00 2001 From: dyahalomi Date: Thu, 9 Sep 2021 17:13:37 -0400 Subject: [PATCH 11/16] change get_star_position(self.a, ...) to get_position(self.a_star, ...) for get_star_relative_angles() --- src/exoplanet/orbits/keplerian.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/exoplanet/orbits/keplerian.py b/src/exoplanet/orbits/keplerian.py index 8bcf5ddd..f0fe168d 100644 --- a/src/exoplanet/orbits/keplerian.py +++ b/src/exoplanet/orbits/keplerian.py @@ -581,8 +581,8 @@ def get_star_relative_angles(self, t, parallax=None, light_delay=False): The separation (arcseconds) and position angle (radians, measured east of north) of the planet relative to the star. """ - X, Y, Z = self.get_star_position( - -self.a, t, parallax, light_delay=light_delay + X, Y, Z = self._get_position( + -self.a_star, t, parallax, light_delay=light_delay ) # calculate rho and theta From 8923e556ca143166b84e04146acad614b02e0cb4 Mon Sep 17 00:00:00 2001 From: dyahalomi Date: Thu, 9 Sep 2021 19:09:24 -0400 Subject: [PATCH 12/16] fix test_relative_angles() --- tests/orbits/keplerian_test.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/tests/orbits/keplerian_test.py b/tests/orbits/keplerian_test.py index 661a939e..613ac3ad 100644 --- a/tests/orbits/keplerian_test.py +++ b/tests/orbits/keplerian_test.py @@ -737,13 +737,15 @@ def test_relative_angles(): assert np.isclose(rho_earth_diff, 3.0813126e-02) assert np.isclose(rho_star_earth_diff, 9.2523221e-08) - # make sure planet and star position angle closely mirrors each other + + # make sure planet and star position angle are the same relative to each other assert np.allclose( - theta_earth[: int(p_earth / 2)], - theta_star_earth[int(p_earth / 2) : int(p_earth) - 1], - atol=0.2, + theta_earth, + theta_star_earth ) + + ######################################## ######################################## # test separation and position angle with Jupiter and Sun @@ -753,7 +755,7 @@ def test_relative_angles(): orbit_jup = KeplerianOrbit( m_star=1.0, r_star=1.0, - t0=2000, + t0=0.5, period=p_jup, ecc=0.0484, omega=np.radians(274.3) - 2 * np.pi, @@ -769,16 +771,15 @@ def test_relative_angles(): [], orbit_jup.get_relative_angles(t, parallax=0.1) )() - rho_star_earth_diff = np.max(rho_star_jup) - np.min(rho_star_jup) - rho_earth_diff = np.max(rho_jup) - np.min(rho_jup) + rho_star_jup_diff = np.max(rho_star_jup) - np.min(rho_star_jup) + rho_jup_diff = np.max(rho_jup) - np.min(rho_jup) # make sure amplitude of separation is correct for star and planet motion assert np.isclose(rho_jup_diff, 1.7190731e-01) assert np.isclose(rho_star_jup_diff, 1.6390463e-04) - # make sure planet and star position angle closely mirrors each other + # make sure planet and star position angle are the same relative to each other assert np.allclose( - theta_jup[: int(p_jup / 2)], - theta_star_jup[int(p_jup / 2) : int(p_jup) - 1], - atol=0.2, + theta_jup, + theta_star_jup ) From 80cc61270375be19bbc69558d2cabaef435fc611 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 9 Sep 2021 23:09:35 +0000 Subject: [PATCH 13/16] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/orbits/keplerian_test.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/tests/orbits/keplerian_test.py b/tests/orbits/keplerian_test.py index 613ac3ad..bf60cccf 100644 --- a/tests/orbits/keplerian_test.py +++ b/tests/orbits/keplerian_test.py @@ -737,14 +737,8 @@ def test_relative_angles(): assert np.isclose(rho_earth_diff, 3.0813126e-02) assert np.isclose(rho_star_earth_diff, 9.2523221e-08) - # make sure planet and star position angle are the same relative to each other - assert np.allclose( - theta_earth, - theta_star_earth - ) - - + assert np.allclose(theta_earth, theta_star_earth) ######################################## ######################################## @@ -779,7 +773,4 @@ def test_relative_angles(): assert np.isclose(rho_star_jup_diff, 1.6390463e-04) # make sure planet and star position angle are the same relative to each other - assert np.allclose( - theta_jup, - theta_star_jup - ) + assert np.allclose(theta_jup, theta_star_jup) From 24efb24acc16a1c374c1e9ab903d069ef178ccbf Mon Sep 17 00:00:00 2001 From: dyahalomi Date: Thu, 9 Sep 2021 19:28:15 -0400 Subject: [PATCH 14/16] fix comment on get_star_relative_angles() function --- src/exoplanet/orbits/keplerian.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/exoplanet/orbits/keplerian.py b/src/exoplanet/orbits/keplerian.py index f0fe168d..6d9ea213 100644 --- a/src/exoplanet/orbits/keplerian.py +++ b/src/exoplanet/orbits/keplerian.py @@ -579,7 +579,7 @@ def get_star_relative_angles(self, t, parallax=None, light_delay=False): False. Returns: The separation (arcseconds) and position angle (radians, - measured east of north) of the planet relative to the star. + measured east of north) of the star relative to the planet. """ X, Y, Z = self._get_position( -self.a_star, t, parallax, light_delay=light_delay From dbf68424187a4d0dd4ab254a5c3fb86cd1f8e6da Mon Sep 17 00:00:00 2001 From: dyahalomi Date: Thu, 9 Sep 2021 20:07:01 -0400 Subject: [PATCH 15/16] update get_star_relative_angles() description --- src/exoplanet/orbits/keplerian.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/exoplanet/orbits/keplerian.py b/src/exoplanet/orbits/keplerian.py index 6d9ea213..c74ada6e 100644 --- a/src/exoplanet/orbits/keplerian.py +++ b/src/exoplanet/orbits/keplerian.py @@ -579,7 +579,7 @@ def get_star_relative_angles(self, t, parallax=None, light_delay=False): False. Returns: The separation (arcseconds) and position angle (radians, - measured east of north) of the star relative to the planet. + measured east of north) of the star relative to the barycentric frame. """ X, Y, Z = self._get_position( -self.a_star, t, parallax, light_delay=light_delay From 1527881f27a2d7a0a1f5260443584b2e2b1af438 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 17 Feb 2022 16:52:54 +0000 Subject: [PATCH 16/16] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/exoplanet/orbits/keplerian.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/exoplanet/orbits/keplerian.py b/src/exoplanet/orbits/keplerian.py index aa549e12..25626a13 100644 --- a/src/exoplanet/orbits/keplerian.py +++ b/src/exoplanet/orbits/keplerian.py @@ -586,7 +586,7 @@ def get_star_relative_angles(self, t, parallax=None, light_delay=False): ) # calculate rho and theta - rho = tt.squeeze(tt.sqrt(X ** 2 + Y ** 2)) # arcsec + rho = tt.squeeze(tt.sqrt(X**2 + Y**2)) # arcsec theta = tt.squeeze(tt.arctan2(Y, X)) # radians between [-pi, pi] return (rho, theta)