Skip to content

Commit

Permalink
Merge pull request #1703 from abhisrkckl/compare_models_binary
Browse files Browse the repository at this point in the history
`change_binary_epoch` in `TimingModel.compare()`
  • Loading branch information
dlakaplan authored Dec 29, 2023
2 parents 4025e32 + 87c0e18 commit 216e7e6
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ the released changes.
### Changed
- Moved `get_derived_params` to `timing_model`
- `check_ephemeris_connection` CI test no longer requires access to static NANOGrav site
- `TimingModel.compare()` now calls `change_binary_epoch()`.
### Added
- Added numdifftools to setup.cfg to match requirements.txt
- Documentation: Added `convert_parfile` to list of command-line tools in RTD
Expand Down
29 changes: 29 additions & 0 deletions src/pint/models/timing_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2251,6 +2251,7 @@ def compare(
"Updating POSEPOCH in %s to match %s" % (other_model_name, model_name)
)
othermodel.change_posepoch(self.POSEPOCH.value)

if (
"PEPOCH" in self.params
and "PEPOCH" in othermodel.params
Expand All @@ -2261,6 +2262,7 @@ def compare(
"Updating PEPOCH in %s to match %s" % (other_model_name, model_name)
)
othermodel.change_pepoch(self.PEPOCH.value)

if (
"DMEPOCH" in self.params
and "DMEPOCH" in othermodel.params
Expand All @@ -2271,6 +2273,33 @@ def compare(
"Updating DMEPOCH in %s to match %s" % (other_model_name, model_name)
)
othermodel.change_dmepoch(self.DMEPOCH.value)

if (
self.BINARY.value is not None
and othermodel.BINARY.value is not None
and self.BINARY.value == othermodel.BINARY.value
):
log.info(
"Updating binary epoch (T0 or TASC) in %s to match %s"
% (other_model_name, model_name)
)
if (
"T0" in self
and "T0" in othermodel
and self.T0.value is not None
and othermodel.T0.value is not None
and self.T0.value != othermodel.T0.value
):
othermodel.change_binary_epoch(self.T0.quantity)
elif (
"TASC" in self
and "TASC" in othermodel
and self.TASC.value is not None
and othermodel.TASC.value is not None
and self.TASC.value != othermodel.TASC.value
):
othermodel.change_binary_epoch(self.TASC.quantity)

if (
"AstrometryEquatorial" in self.components
and "AstrometryEcliptic" in othermodel.components
Expand Down
11 changes: 11 additions & 0 deletions tests/test_compare_model.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from io import StringIO
from copy import deepcopy

import pytest

Expand Down Expand Up @@ -112,3 +113,13 @@ def test_compare_parfile_script():

argv = f"{args} {parfile1} {parfile2}".split()
compare_parfiles.main(argv)


def test_compare_model_binary():
m1 = get_model(StringIO(par_bin))

m2 = deepcopy(m1)
m2.TASC.value = 57001

m1.compare(m2)
m2.compare(m1)

0 comments on commit 216e7e6

Please sign in to comment.