From 303a13f1318df9e76ee53fd024c32fc068770494 Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Thu, 30 Jun 2022 16:32:05 -0500 Subject: [PATCH 1/2] fix Parkes/Tempo2 parsing confusion --- src/pint/toa.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pint/toa.py b/src/pint/toa.py index 600536109..547f3e148 100644 --- a/src/pint/toa.py +++ b/src/pint/toa.py @@ -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" From c225f3d8ad22fb617a2d4ea32b8a1e87e8b4967a Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Fri, 1 Jul 2022 09:06:22 -0500 Subject: [PATCH 2/2] added test --- tests/test_toa_reader.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/test_toa_reader.py b/tests/test_toa_reader.py index c893af95c..d47acb989 100644 --- a/tests/test_toa_reader.py +++ b/tests/test_toa_reader.py @@ -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))