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 #1853 #1888

Open
wants to merge 5 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
4 changes: 3 additions & 1 deletion CHANGELOG-unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ the released changes.
- Simulate correlated DM noise for wideband TOAs
- Type hints in `pint.models.timing_model`
### Fixed
- Made `TimingModel.is_binary()` more robust.
- Made `TimingModel.is_binary()` more robust
- Added missing newline in `tempo_polyco_table_writer()`
- Proper warning in `read_polyco_file()`
### Removed
- Definition of `@cached_property` to support Python<=3.7
- The broken `data.nanograv.org` URL from the list of solar system ephemeris mirrors
Expand Down
31 changes: 19 additions & 12 deletions src/pint/polycos.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

\\Delta T = 1440(T-T_{\\rm mid})

\\phi = \\phi_0 + 60 \Delta T f_0 + COEFF[1] + COEFF[2] \\Delta T + COEFF[3] \\Delta T^2 + \\ldots
\\phi = \\phi_0 + 60 \\Delta T f_0 + COEFF[1] + COEFF[2] \\Delta T + COEFF[3] \\Delta T^2 + \\ldots

f({\\rm Hz}) = f_0 + \\frac{1}{60}\\left( COEFF[2] + 2 COEFF[3] \Delta T + 3 COEFF[4] \Delta T^2 + \\ldots \\right)
f({\\rm Hz}) = f_0 + \\frac{1}{60}\\left( COEFF[2] + 2 COEFF[3] \\Delta T + 3 COEFF[4] \\Delta T^2 + \\ldots \\right)

Examples
--------
Expand All @@ -34,6 +34,7 @@
"""

from collections import OrderedDict
from warnings import warn

import astropy.table as table
import astropy.units as u
Expand Down Expand Up @@ -265,9 +266,9 @@ def tempo_polyco_table_reader(filename):

\\Delta T = 1440(T-T_{\\rm mid})

\\phi = \\phi_0 + 60 \Delta T f_0 + COEFF[1] + COEFF[2] \\Delta T + COEFF[3] \\Delta T^2 + \\ldots
\\phi = \\phi_0 + 60 \\Delta T f_0 + COEFF[1] + COEFF[2] \\Delta T + COEFF[3] \\Delta T^2 + \\ldots

f({\\rm Hz}) = f_0 + \\frac{1}{60}\\left( COEFF[2] + 2 COEFF[3] \Delta T + 3 COEFF[4] \Delta T^2 + \\ldots \\right)
f({\\rm Hz}) = f_0 + \\frac{1}{60}\\left( COEFF[2] + 2 COEFF[3] \\Delta T + 3 COEFF[4] \\Delta T^2 + \\ldots \\right)

Parameters
----------
Expand Down Expand Up @@ -392,9 +393,9 @@ def tempo_polyco_table_writer(polycoTable, filename="polyco.dat"):

\\Delta T = 1440(T-T_{\\rm mid})

\\phi = \\phi_0 + 60 \Delta T f_0 + COEFF[1] + COEFF[2] \\Delta T + COEFF[3] \\Delta T^2 + \\ldots
\\phi = \\phi_0 + 60 \\Delta T f_0 + COEFF[1] + COEFF[2] \\Delta T + COEFF[3] \\Delta T^2 + \\ldots

f({\\rm Hz}) = f_0 + \\frac{1}{60}\\left( COEFF[2] + 2 COEFF[3] \Delta T + 3 COEFF[4] \Delta T^2 + \\ldots \\right)
f({\\rm Hz}) = f_0 + \\frac{1}{60}\\left( COEFF[2] + 2 COEFF[3] \\Delta T + 3 COEFF[4] \\Delta T^2 + \\ldots \\right)

Parameters
----------
Expand Down Expand Up @@ -463,6 +464,9 @@ def tempo_polyco_table_writer(polycoTable, filename="polyco.dat"):
if (i + 1) % 3 == 0:
coeff_block += "\n"

if not coeff_block.endswith("\n"):
coeff_block += "\n"

f.write(line1 + line2 + coeff_block)


Expand Down Expand Up @@ -649,17 +653,20 @@ def read_polyco_file(self, filename, format="tempo"):
Polycos

"""
raise DeprecationWarning(
"Use `p=pint.polycos.Polycos.read()` rather than `p.read_polyco_file()`"
warn(
"Use `p=pint.polycos.Polycos.read()` rather than `p.read_polyco_file()`",
DeprecationWarning,
)

self.fileName = filename

if format not in [f["format"] for f in self.polycoFormats]:
raise ValueError(
"Unknown polyco file format '" + format + "'\n"
"Please use function 'Polyco.add_polyco_file_format()'"
" to register the format\n"
(
f"Unknown polyco file format '{format}'\n"
f"Please use function 'Polyco.add_polyco_file_format()'"
f" to register the format\n"
)
)
else:
self.fileFormat = format
Expand Down Expand Up @@ -938,7 +945,7 @@ def eval_abs_phase(self, t):

.. math::

\\phi = \\phi_0 + 60 \\Delta T f_0 + COEFF[1] + COEFF[2] \Delta T + COEFF[3] \Delta T^2 + \\ldots
\\phi = \\phi_0 + 60 \\Delta T f_0 + COEFF[1] + COEFF[2] \\Delta T + COEFF[3] \\Delta T^2 + \\ldots

Calculation done using :meth:`pint.polycos.PolycoEntry.evalabsphase`
"""
Expand Down