Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Parkes/Tempo2 parsing confusion #1320

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/pint/toa.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,12 @@ def _toa_format(line, fmt="Unknown"):
return "Command"
elif re.match(r"^\s*$", line): # FIXME: what about empty lines?
return "Blank"
elif re.match(r"^ ", line) and len(line) > 41 and line[41] == ".":
elif (
re.match(r"^ ", line)
and len(line) > 41
and line[41] == "."
and not fmt == "Tempo2"
):
return "Parkes"
elif len(line) > 80 or fmt == "Tempo2":
return "Tempo2"
Expand Down
17 changes: 17 additions & 0 deletions tests/test_toa_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,3 +454,20 @@ def test_chained_include_directories(tmp_path):
)

assert len(toa.get_TOAs(str(t1))) == 3


def test_tempo2_lookslike_parkes():
# a fraction of a tim file that failed on the uwl_200830_103538.rf.noscl.paz2.pTF line
# because of the initial space and the "." in character 41
# it is actually in Tempo2 format but PINT thought it was Parkes
s = """FORMAT 1
MODE 1
uwl_200620_110732.0000_0000.rf.pTF 1102.00000000 59020.48454853458879299 13.68700 pks
uwl_200703_053144.calib.paz2.pTF 1193.45200000 59033.24748901219228969 16.68400 pks
uwl_200723_040744.calib.paz2.pTF 1194.39000000 59053.19164379733292591 17.46900 pks
uwl_200801_101324.calib.paz2.pTF 1194.65900000 59062.44204936713518350 18.06300 pks
C uwl_200817_060611.0000_0000.rf.pTF 1102.00000000 59078.27291615603383690 18.41200 pks
uwl_200830_103538.rf.noscl.paz2.pTF 1115.36200000 59091.46028405561133567 14.03300 pks
uwl_200914_031352.calib.paz2.pTF 1192.38600000 59106.15041719173595425 18.61600 pks
uwl_201020_230358_0.calib.paz2.pTF 1193.25000000 59142.98175923008920662 16.38500 pks"""
t = toa.get_TOAs(StringIO(s))