Skip to content

Commit

Permalink
Merge pull request nanograv#1722 from scottransom/old_princeton
Browse files Browse the repository at this point in the history
Allow very old Princeton format TOAs
  • Loading branch information
aarchiba authored Feb 22, 2024
2 parents eb1f48b + 327d92e commit bf9e15b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/pint/toa.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,11 @@ def _parse_TOA_line(line, fmt="Unknown"):
d["freq"] = float(line[15:24])
d["error"] = float(line[44:53])
ii, ff = line[24:44].split(".")
MJD = (int(ii), float(f"0.{ff}"))
ii = int(ii)
# For very old TOAs, see https://tempo.sourceforge.net/ref_man_sections/toa.txt
if ii < 40000:
ii += 39126
MJD = (ii, float(f"0.{ff}"))
try:
d["ddm"] = str(float(line[68:78]))
except ValueError:
Expand Down
19 changes: 19 additions & 0 deletions tests/test_toa_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,25 @@ def test_read_parkes(self):
assert "barycenter" in ts.observatories
assert ts.ntoas == 8

def test_read_princeton(self):
toaline = "6 11 1744-24 1666.0000 50852.5886574493316 25.6 8-FEB-98 0.0 1 1"
mjd, d = toa._parse_TOA_line(toaline)
assert np.isclose(mjd[0] + mjd[1], 50852.5886574493316)
assert d["format"] == "Princeton"
assert d["obs"] == "vla"
assert d["freq"] == 1666.0
assert d["error"] == 25.6

def test_read_princeton_offset1(self):
toaline = "6 26 1744-24 1667.0000 9064.9010416342947 6.2 26-OCT-90 0.1 1 1"
mjd, d = toa._parse_TOA_line(toaline)
assert np.isclose(mjd[0] + mjd[1], 48190.9010416342947)

def test_read_princeton_offset2(self):
toaline = "6 37 1744-24 1666.000010062.1379629521572 7.8 20-JUL-93 64.6 1 1"
mjd, d = toa._parse_TOA_line(toaline)
assert np.isclose(mjd[0] + mjd[1], 49188.1379629521572)

def test_read_parkes_phaseoffset(self):
# Fourth column contains non-zero phase offset
toaline = " PUPPI_J2044+28_58852_652 432.3420 58852.7590686063892 1.00 120.75 @"
Expand Down

0 comments on commit bf9e15b

Please sign in to comment.