From e9b452b69e8c7f14cb7ee6551388c7f1e3c188e1 Mon Sep 17 00:00:00 2001 From: Rutger van Haasteren Date: Thu, 30 Nov 2023 09:27:45 +0100 Subject: [PATCH 1/4] Properly address units in PintPulsar position --- enterprise/pulsar.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/enterprise/pulsar.py b/enterprise/pulsar.py index bb1f35a3..e7c26950 100644 --- a/enterprise/pulsar.py +++ b/enterprise/pulsar.py @@ -399,12 +399,13 @@ def _set_dm(self, model): def _get_radec(self, model): if hasattr(model, "RAJ") and hasattr(model, "DECJ"): - return (model.RAJ.value, model.DECJ.value) + raj = model.RAJ.quantity.to(u.rad).value + decj = model.DECJ.quantity.to(u.rad).value + return raj, decj else: - # TODO: better way of dealing with units - d2r = np.pi / 180 - elong, elat = model.ELONG.value, model.ELAT.value - return self._get_radec_from_ecliptic(elong * d2r, elat * d2r) + elong = model.ELONG.quantity.to(u.rad).value + elat = model.ELAT.quantity.to(u.rad).value + return self._radec_from_ecliptic(elong, elat) def _get_ssb_lsec(self, toas, obs_planet): """Get the planet to SSB vector in lightseconds from Pint table""" From c58f8405ff5ebd83d0ef23adbbe3b6bce7809de7 Mon Sep 17 00:00:00 2001 From: Rutger van Haasteren Date: Thu, 30 Nov 2023 09:47:09 +0100 Subject: [PATCH 2/4] Fix typo --- enterprise/pulsar.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/enterprise/pulsar.py b/enterprise/pulsar.py index e7c26950..257041a7 100644 --- a/enterprise/pulsar.py +++ b/enterprise/pulsar.py @@ -405,7 +405,7 @@ def _get_radec(self, model): else: elong = model.ELONG.quantity.to(u.rad).value elat = model.ELAT.quantity.to(u.rad).value - return self._radec_from_ecliptic(elong, elat) + return self._get_radec_from_ecliptic(elong, elat) def _get_ssb_lsec(self, toas, obs_planet): """Get the planet to SSB vector in lightseconds from Pint table""" From e54c3d203f5a5218a541d21a38e7796a5b03d137 Mon Sep 17 00:00:00 2001 From: Rutger van Haasteren Date: Fri, 19 Apr 2024 09:48:55 +0200 Subject: [PATCH 3/4] Added test for PINT pulsar with RAJ/DECJ --- tests/test_pulsar.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/test_pulsar.py b/tests/test_pulsar.py index 6ab617e3..6177db6b 100644 --- a/tests/test_pulsar.py +++ b/tests/test_pulsar.py @@ -218,6 +218,20 @@ def test_load_radec_psr(self): timing_package="pint", ) + def test_load_radec_psr_mdc(self): + """Setup the Pulsar object.""" + + # initialize Pulsar class with RAJ DECJ so _get_radec can be covered + Pulsar( + datadir + "/mdc1/J0030+0451.par", + datadir + "/mdc1/J0030+0451.tim", + ephem="DE430", + drop_pintpsr=False, + timing_package="pint", + ) + + assert self.psr.Mmat.shape == (130, 8), msg + def test_no_planet(self): """Test exception when incorrect par(tim) file given.""" From 7b7eb229aca032463b3152f7e1d8dff079b51e75 Mon Sep 17 00:00:00 2001 From: Rutger van Haasteren Date: Sun, 21 Apr 2024 18:09:20 +0200 Subject: [PATCH 4/4] Fixed extra pulsar test --- tests/test_pulsar.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test_pulsar.py b/tests/test_pulsar.py index 6177db6b..cbbfb369 100644 --- a/tests/test_pulsar.py +++ b/tests/test_pulsar.py @@ -222,7 +222,7 @@ def test_load_radec_psr_mdc(self): """Setup the Pulsar object.""" # initialize Pulsar class with RAJ DECJ so _get_radec can be covered - Pulsar( + psr = Pulsar( datadir + "/mdc1/J0030+0451.par", datadir + "/mdc1/J0030+0451.tim", ephem="DE430", @@ -230,7 +230,8 @@ def test_load_radec_psr_mdc(self): timing_package="pint", ) - assert self.psr.Mmat.shape == (130, 8), msg + msg = f"Pulsar not loaded properly {self.psr.Mmat.shape}" + assert psr.Mmat.shape == (130, 8), msg def test_no_planet(self): """Test exception when incorrect par(tim) file given."""