Skip to content

Commit

Permalink
Merge pull request nanograv#382 from tcromartie/patch-1
Browse files Browse the repository at this point in the history
Change ssb_to_psb_xyz_ICRS to not pass PINT a quantity
  • Loading branch information
vhaasteren authored Apr 21, 2024
2 parents bcbedeb + c117fcf commit 6ab5d06
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions enterprise/pulsar.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import astropy.units as u
import numpy as np
from ephem import Ecliptic, Equatorial
from astropy.time import Time

import enterprise
from enterprise.signals import utils
Expand Down Expand Up @@ -108,7 +109,11 @@ def _get_radec_from_ecliptic(self, elong, elat):

def _get_pos(self):
return np.array(
[np.cos(self._raj) * np.cos(self._decj), np.sin(self._raj) * np.cos(self._decj), np.sin(self._decj)]
[
np.cos(self._raj) * np.cos(self._decj),
np.sin(self._raj) * np.cos(self._decj),
np.sin(self._decj),
]
)

def sort_data(self):
Expand Down Expand Up @@ -311,7 +316,6 @@ def telescope(self):

class PintPulsar(BasePulsar):
def __init__(self, toas, model, sort=True, drop_pintpsr=True, planets=True):

self._sort = sort
self.planets = planets
self.name = model.PSR.value
Expand Down Expand Up @@ -367,7 +371,11 @@ def __init__(self, toas, model, sort=True, drop_pintpsr=True, planets=True):
"AstrometryEquatorial" if "AstrometryEquatorial" in model.components else "AstrometryEcliptic"
)

self._pos_t = model.components[which_astrometry].ssb_to_psb_xyz_ICRS(model.get_barycentric_toas(toas)).value
self._pos_t = (
model.components[which_astrometry]
.ssb_to_psb_xyz_ICRS(Time(model.get_barycentric_toas(toas), format="mjd"))
.value
)

self.sort_data()

Expand Down Expand Up @@ -448,7 +456,6 @@ def _get_sunssb(self, toas, model):

class Tempo2Pulsar(BasePulsar):
def __init__(self, t2pulsar, sort=True, drop_t2pulsar=True, planets=True):

self._sort = sort
self.t2pulsar = t2pulsar
self.planets = planets
Expand Down Expand Up @@ -649,13 +656,16 @@ def Pulsar(*args, **kwargs):
if (clk is not None) and (bipm_version is None):
bipm_version = clk.split("(")[1][:-1]
model, toas = get_model_and_toas(
relparfile, reltimfile, ephem=ephem, bipm_version=bipm_version, planets=planets
relparfile,
reltimfile,
ephem=ephem,
bipm_version=bipm_version,
planets=planets,
)
os.chdir(cwd)
return PintPulsar(toas, model, sort=sort, drop_pintpsr=drop_pintpsr, planets=planets)

elif timing_package.lower() == "tempo2":

# hack to set maxobs
maxobs = get_maxobs(reltimfile) + 100
t2pulsar = t2.tempopulsar(relparfile, reltimfile, maxobs=maxobs, ephem=ephem, clk=clk)
Expand Down

0 comments on commit 6ab5d06

Please sign in to comment.