Skip to content

Commit

Permalink
Merge pull request #370 from vhaasteren/fix_posunits
Browse files Browse the repository at this point in the history
Properly address units in PintPulsar position
  • Loading branch information
vhaasteren authored May 9, 2024
2 parents 37e24d2 + 7b7eb22 commit 0f85dcc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
11 changes: 6 additions & 5 deletions enterprise/pulsar.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,12 +424,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._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"""
Expand Down
15 changes: 15 additions & 0 deletions tests/test_pulsar.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,21 @@ 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
psr = Pulsar(
datadir + "/mdc1/J0030+0451.par",
datadir + "/mdc1/J0030+0451.tim",
ephem="DE430",
drop_pintpsr=False,
timing_package="pint",
)

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."""

Expand Down

0 comments on commit 0f85dcc

Please sign in to comment.