From e4740940fd2c2bb839c36b9cee9c47ea13de57b4 Mon Sep 17 00:00:00 2001 From: Abhimanyu Susobhanan Date: Mon, 7 Oct 2024 10:55:52 +0200 Subject: [PATCH 01/66] compare_parfiles --- src/pint/scripts/compare_parfiles.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pint/scripts/compare_parfiles.py b/src/pint/scripts/compare_parfiles.py index 0c4ca5da2..87eb005a0 100644 --- a/src/pint/scripts/compare_parfiles.py +++ b/src/pint/scripts/compare_parfiles.py @@ -89,8 +89,9 @@ def main(argv=None): level=pint.logging.get_level(args.loglevel, args.verbosity, args.quiet) ) - m1 = get_model(args.input1) - m2 = get_model(args.input2) + m1 = get_model(args.input1, allow_T2=True, allow_tcb=True) + m2 = get_model(args.input2, allow_T2=True, allow_tcb=True) + print( m1.compare( m2, From 5f7bc2dd431a0209bc29d41fc5f238f9cda11d5d Mon Sep 17 00:00:00 2001 From: Abhimanyu Susobhanan Date: Mon, 7 Oct 2024 10:56:50 +0200 Subject: [PATCH 02/66] convert_parfile --- src/pint/scripts/convert_parfile.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pint/scripts/convert_parfile.py b/src/pint/scripts/convert_parfile.py index 55b45415b..0612a46a8 100644 --- a/src/pint/scripts/convert_parfile.py +++ b/src/pint/scripts/convert_parfile.py @@ -83,7 +83,9 @@ def main(argv=None): return log.info(f"Reading '{args.input}'") - model = get_model(args.input) + + model = get_model(args.input, allow_T2=True, allow_tcb=True) + if hasattr(model, "BINARY") and args.binary is not None: log.info(f"Converting from {model.BINARY.value} to {args.binary}") if args.binary == "ELL1H": From f2abeb723c588d6d00333ed8430b541d78295359 Mon Sep 17 00:00:00 2001 From: Abhimanyu Susobhanan Date: Mon, 7 Oct 2024 11:01:53 +0200 Subject: [PATCH 03/66] scripts --- src/pint/pintk/pulsar.py | 8 ++++++-- src/pint/scripts/event_optimize.py | 2 +- src/pint/scripts/event_optimize_MCMCFitter.py | 2 +- src/pint/scripts/event_optimize_multiple.py | 2 +- src/pint/scripts/fermiphase.py | 3 ++- src/pint/scripts/photonphase.py | 3 ++- src/pint/scripts/pintbary.py | 2 +- src/pint/scripts/pintempo.py | 2 +- src/pint/scripts/pintpublish.py | 2 +- src/pint/scripts/tcb2tdb.py | 2 +- src/pint/scripts/zima.py | 2 +- 11 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/pint/pintk/pulsar.py b/src/pint/pintk/pulsar.py index 65d8048df..ce6aa8560 100644 --- a/src/pint/pintk/pulsar.py +++ b/src/pint/pintk/pulsar.py @@ -151,7 +151,9 @@ def __contains__(self, key): return key in self.prefit_model.params def reset_model(self): - self.prefit_model = pint.models.get_model(self.parfile) + self.prefit_model = pint.models.get_model( + self.parfile, allow_T2=True, allow_tcb=True + ) self.add_model_params() self.postfit_model = None self.postfit_resids = None @@ -172,7 +174,9 @@ def reset_TOAs(self): self.update_resids() def resetAll(self): - self.prefit_model = pint.models.get_model(self.parfile) + self.prefit_model = pint.models.get_model( + self.parfile, allow_T2=True, allow_tcb=True + ) self.postfit_model = None self.postfit_resids = None self.fitted = False diff --git a/src/pint/scripts/event_optimize.py b/src/pint/scripts/event_optimize.py index e4c9dd4ff..b79fb1c20 100755 --- a/src/pint/scripts/event_optimize.py +++ b/src/pint/scripts/event_optimize.py @@ -719,7 +719,7 @@ def main(argv=None): ncores = args.ncores # Read in initial model - modelin = pint.models.get_model(parfile) + modelin = pint.models.get_model(parfile, allow_T2=True, allow_tcb=True) # File name setup and clobber file check filepath = args.filepath or os.getcwd() diff --git a/src/pint/scripts/event_optimize_MCMCFitter.py b/src/pint/scripts/event_optimize_MCMCFitter.py index bbab8ccee..43bc89858 100755 --- a/src/pint/scripts/event_optimize_MCMCFitter.py +++ b/src/pint/scripts/event_optimize_MCMCFitter.py @@ -164,7 +164,7 @@ def main(argv=None): wgtexp = args.wgtexp # Read in initial model - modelin = pint.models.get_model(parfile) + modelin = pint.models.get_model(parfile, allow_T2=True, allow_tcb=True) # The custom_timing version below is to manually construct the TimingModel # class, which allows it to be pickled. This is needed for parallelizing diff --git a/src/pint/scripts/event_optimize_multiple.py b/src/pint/scripts/event_optimize_multiple.py index 41316a000..daa40a9e9 100755 --- a/src/pint/scripts/event_optimize_multiple.py +++ b/src/pint/scripts/event_optimize_multiple.py @@ -261,7 +261,7 @@ def main(argv=None): wgtexp = args.wgtexp # Read in initial model - modelin = pint.models.get_model(parfile) + modelin = pint.models.get_model(parfile, allow_T2=True, allow_tcb=True) # Set the target coords for automatic weighting if necessary if "ELONG" in modelin.params: diff --git a/src/pint/scripts/fermiphase.py b/src/pint/scripts/fermiphase.py index b1427e61f..6785bc156 100755 --- a/src/pint/scripts/fermiphase.py +++ b/src/pint/scripts/fermiphase.py @@ -88,7 +88,8 @@ def main(argv=None): args.addphase = True # Read in model - modelin = pint.models.get_model(args.parfile) + modelin = pint.models.get_model(args.parfile, allow_T2=True, allow_tcb=True) + if "ELONG" in modelin.params: tc = SkyCoord( modelin.ELONG.quantity, diff --git a/src/pint/scripts/photonphase.py b/src/pint/scripts/photonphase.py index 7d72eec18..38505c629 100755 --- a/src/pint/scripts/photonphase.py +++ b/src/pint/scripts/photonphase.py @@ -153,7 +153,8 @@ def main(argv=None): "Please barycenter the event file using the official mission tools before processing with PINT" ) # Read in model - modelin = pint.models.get_model(args.parfile) + modelin = pint.models.get_model(args.parfile, allow_T2=True, allow_tcb=True) + use_planets = False if "PLANET_SHAPIRO" in modelin.params: if modelin.PLANET_SHAPIRO.value: diff --git a/src/pint/scripts/pintbary.py b/src/pint/scripts/pintbary.py index 4876474d8..c29d42fbb 100755 --- a/src/pint/scripts/pintbary.py +++ b/src/pint/scripts/pintbary.py @@ -105,7 +105,7 @@ def main(argv=None): ) if args.parfile is not None: - m = pint.models.get_model(args.parfile) + m = pint.models.get_model(args.parfile, allow_T2=True, allow_tcb=True) else: # Construct model by hand m = pint.models.StandardTimingModel diff --git a/src/pint/scripts/pintempo.py b/src/pint/scripts/pintempo.py index d99c772ba..36e8ca509 100755 --- a/src/pint/scripts/pintempo.py +++ b/src/pint/scripts/pintempo.py @@ -69,7 +69,7 @@ def main(argv=None): ) log.info("Reading model from {0}".format(args.parfile)) - m = pint.models.get_model(args.parfile) + m = pint.models.get_model(args.parfile, allow_T2=True, allow_tcb=True) log.warning(m.params) diff --git a/src/pint/scripts/pintpublish.py b/src/pint/scripts/pintpublish.py index 6d5b0142f..36cc5786e 100644 --- a/src/pint/scripts/pintpublish.py +++ b/src/pint/scripts/pintpublish.py @@ -62,7 +62,7 @@ def main(argv=None): args = parser.parse_args(argv) - model, toas = get_model_and_toas(args.parfile, args.timfile) + model, toas = get_model_and_toas(args.parfile, args.timfile, allow_T2=True) output = publish( model, diff --git a/src/pint/scripts/tcb2tdb.py b/src/pint/scripts/tcb2tdb.py index 4c427d21a..5b15d56ae 100644 --- a/src/pint/scripts/tcb2tdb.py +++ b/src/pint/scripts/tcb2tdb.py @@ -34,7 +34,7 @@ def main(argv=None): args = parser.parse_args(argv) mb = ModelBuilder() - model = mb(args.input_par, allow_tcb=True) + model = mb(args.input_par, allow_tcb=True, allow_T2=True) model.write_parfile(args.output_par) log.info(f"Output written to {args.output_par}.") diff --git a/src/pint/scripts/zima.py b/src/pint/scripts/zima.py index 3305129f7..3485c6c5b 100755 --- a/src/pint/scripts/zima.py +++ b/src/pint/scripts/zima.py @@ -122,7 +122,7 @@ def main(argv=None): ) log.info("Reading model from {0}".format(args.parfile)) - m = pint.models.get_model(args.parfile) + m = pint.models.get_model(args.parfile, allow_T2=True, allow_tcb=True) out_format = args.format error = args.error * u.microsecond From f8bbeae61c7651341e82168b4f7cc9e075ac4c6d Mon Sep 17 00:00:00 2001 From: Abhimanyu Susobhanan Date: Mon, 7 Oct 2024 11:03:13 +0200 Subject: [PATCH 04/66] CHANGELOG --- CHANGELOG-unreleased.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG-unreleased.md b/CHANGELOG-unreleased.md index 2c7ea6521..2d433bfab 100644 --- a/CHANGELOG-unreleased.md +++ b/CHANGELOG-unreleased.md @@ -14,6 +14,7 @@ the released changes. - `maskParameter.__repr__()` output now includes the frozen attribute. - Changed default value of `FDJUMPLOG` to `Y` - Bumped `black` version to 24.x +- Command line scripts now automatically do `allow_tcb` and `allow_T2` while reading par files. ### Added - arXiv link of PINT noise paper in README - Type hints in `pint.derived_quantities`, `pint.modelutils`, `pint.binaryconvert`, `pint.config`, From 86c81408a803c29b7a03d6d2960b65f66bd8ea99 Mon Sep 17 00:00:00 2001 From: Deven Bhakta Date: Thu, 17 Oct 2024 13:17:06 -0400 Subject: [PATCH 05/66] Phases calculation using the Designmatrix feature --- src/pint/plot_utils.py | 6 +++-- src/pint/scripts/event_optimize.py | 35 ++++++++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/src/pint/plot_utils.py b/src/pint/plot_utils.py index 45eba3977..917412b71 100644 --- a/src/pint/plot_utils.py +++ b/src/pint/plot_utils.py @@ -279,11 +279,13 @@ def plot_priors( for i in range(len(keys[:-1])): values[i] = values[i][burnin:].flatten() x_range.append(np.linspace(values[i].min(), values[i].max(), num=bins)) - priors.append(getattr(model, keys[i]).prior.pdf(x_range[i])) + priors.append(getattr(model, keys[i]).prior.logpdf(x_range[i])) a, x = np.histogram(values[i], bins=bins, density=True) counts.append(a) - fig, axs = plt.subplots(len(keys), figsize=(8, 11), constrained_layout=True) + fig, axs = plt.subplots( + len(keys), figsize=(8, len(keys) * 1.5), constrained_layout=True + ) for i, p in enumerate(keys): if i != len(keys[:-1]): diff --git a/src/pint/scripts/event_optimize.py b/src/pint/scripts/event_optimize.py index e4c9dd4ff..1b66b2229 100755 --- a/src/pint/scripts/event_optimize.py +++ b/src/pint/scripts/event_optimize.py @@ -414,6 +414,16 @@ def __init__( self.model, phs, phserr ) self.n_fit_params = len(self.fitvals) + self.M, _, _ = self.model.designmatrix(self.toas) + self.M = self.M.transpose() * -self.model.F0.value + self.phases = self.get_event_phases() + self.calc_phase = False + + def calc_phase_matrix(self, theta): + d_phs = np.zeros(len(self.toas)) + for i in range(len(theta) - 1): + d_phs += self.M[i + 1] * (self.fitvals[i] - theta[i]) + return (self.phases - d_phs) % 1 def get_event_phases(self): """ @@ -446,7 +456,10 @@ def lnposterior(self, theta): return -np.inf, -np.inf, -np.inf # Call PINT to compute the phases - phases = self.get_event_phases() + if self.calc_phase: + phases = self.calc_phase_matrix(theta) + else: + phases = self.get_event_phases() lnlikelihood = profile_likelihood( theta[-1], self.xtemp, phases, self.template, self.weights ) @@ -686,6 +699,13 @@ def main(argv=None): action="store_true", dest="noautocorr", ) + parser.add_argument( + "--calc_phase", + help="Calculates the phase at each MCMC step using the designmatrix", + default=False, + action="store_true", + dest="calc_phase", + ) args = parser.parse_args(argv) pint.logging.setup( @@ -862,6 +882,9 @@ def main(argv=None): # This way, one walker should always be in a good position pos[0] = ftr.fitvals + # How phase will be calculated at each step (either with the designmatrix or ) + ftr.calc_phase = True if args.calc_phase else False + import emcee # Setting up a backend to save the chains into an h5 file @@ -925,7 +948,7 @@ def chains_to_dict(names, sampler): def plot_chains(chain_dict, file=False): npts = len(chain_dict) - fig, axes = plt.subplots(npts, 1, sharex=True, figsize=(8, 9)) + fig, axes = plt.subplots(npts, 1, sharex=True, figsize=(8, npts * 1.5)) for ii, name in enumerate(chain_dict.keys()): axes[ii].plot(chain_dict[name], color="k", alpha=0.3) axes[ii].set_ylabel(name) @@ -950,6 +973,7 @@ def plot_chains(chain_dict, file=False): lnprior_samps = blobs["lnprior"] lnlikelihood_samps = blobs["lnlikelihood"] lnpost_samps = lnprior_samps + lnlikelihood_samps + maxpost = lnpost_samps[:][burnin:].max() ind = np.unravel_index( np.argmax(lnpost_samps[:][burnin:]), lnpost_samps[:][burnin:].shape ) @@ -1000,8 +1024,15 @@ def plot_chains(chain_dict, file=False): ] ftr.set_param_uncertainties(dict(zip(ftr.fitkeys[:-1], errors[:-1]))) + # Calculating the AIC and BIC + n_params = len(ftr.model.free_params) + AIC = 2 * (n_params - maxpost) + BIC = n_params * np.log(len(ts)) - 2 * maxpost + ftr.model.NTOA.value = ts.ntoas f = open(filename + "_post.par", "w") f.write(ftr.model.as_parfile()) + f.write(f"\n#The AIC is {AIC}") + f.write(f"\n#The BIC is {BIC}") f.close() # Print the best MCMC values and ranges From 1d9b66e1ff70b4c439fe227209d42c96f3503665 Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Fri, 18 Oct 2024 15:22:02 -0500 Subject: [PATCH 06/66] moving from pkg_resources -> importlib --- src/pint/__init__.py | 1 - src/pint/config.py | 12 ++++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/pint/__init__.py b/src/pint/__init__.py index c0d511e7c..5706dff7e 100644 --- a/src/pint/__init__.py +++ b/src/pint/__init__.py @@ -16,7 +16,6 @@ import astropy.time as time import astropy.units as u import numpy as np -import pkg_resources from astropy.units import si from pathlib import Path diff --git a/src/pint/config.py b/src/pint/config.py index a24bec249..344bc71b1 100644 --- a/src/pint/config.py +++ b/src/pint/config.py @@ -1,7 +1,7 @@ """Functions related to PINT configuration.""" import os -import pkg_resources +import importlib.resources __all__ = ["datadir", "examplefile", "runtimefile"] @@ -15,7 +15,7 @@ def datadir() -> str: str Directory of PINT data files """ - return pkg_resources.resource_filename(__name__, "data/") + return os.path.join(importlib.resources.files("pint"), "data/") def examplefile(filename: str) -> str: @@ -35,9 +35,7 @@ def examplefile(filename: str) -> str: This is **not** for files needed at runtime. Those are located by :func:`pint.config.runtimefile`. This is for files needed for the example notebooks. """ - return pkg_resources.resource_filename( - __name__, os.path.join("data/examples/", filename) - ) + return os.path.join(importlib.resources.files("pint"), f"data/examples/{filename}") def runtimefile(filename: str) -> str: @@ -57,6 +55,4 @@ def runtimefile(filename: str) -> str: This **is** for files needed at runtime. Files needed for the example notebooks are found via :func:`pint.config.examplefile`. """ - return pkg_resources.resource_filename( - __name__, os.path.join("data/runtime/", filename) - ) + return os.path.join(importlib.resources.files("pint"), f"data/runtime/{filename}") From 44ff0c6f3b7ccff5a597a18a450136a7870b257b Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Fri, 18 Oct 2024 15:41:44 -0500 Subject: [PATCH 07/66] change function for compatibility --- src/pint/config.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pint/config.py b/src/pint/config.py index 344bc71b1..843dba08d 100644 --- a/src/pint/config.py +++ b/src/pint/config.py @@ -15,7 +15,7 @@ def datadir() -> str: str Directory of PINT data files """ - return os.path.join(importlib.resources.files("pint"), "data/") + return importlib.resources.path("pint", "data/") def examplefile(filename: str) -> str: @@ -35,7 +35,7 @@ def examplefile(filename: str) -> str: This is **not** for files needed at runtime. Those are located by :func:`pint.config.runtimefile`. This is for files needed for the example notebooks. """ - return os.path.join(importlib.resources.files("pint"), f"data/examples/{filename}") + return importlib.resources.path("pint", "data", "examples", filename) def runtimefile(filename: str) -> str: @@ -55,4 +55,4 @@ def runtimefile(filename: str) -> str: This **is** for files needed at runtime. Files needed for the example notebooks are found via :func:`pint.config.examplefile`. """ - return os.path.join(importlib.resources.files("pint"), f"data/runtime/{filename}") + return importlib.resources.path("pint", "data", "runtime", filename) From 3150b6dedf71254395747d6c0838970246c64c75 Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Fri, 18 Oct 2024 15:51:04 -0500 Subject: [PATCH 08/66] using resources.file --- src/pint/config.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pint/config.py b/src/pint/config.py index 843dba08d..344bc71b1 100644 --- a/src/pint/config.py +++ b/src/pint/config.py @@ -15,7 +15,7 @@ def datadir() -> str: str Directory of PINT data files """ - return importlib.resources.path("pint", "data/") + return os.path.join(importlib.resources.files("pint"), "data/") def examplefile(filename: str) -> str: @@ -35,7 +35,7 @@ def examplefile(filename: str) -> str: This is **not** for files needed at runtime. Those are located by :func:`pint.config.runtimefile`. This is for files needed for the example notebooks. """ - return importlib.resources.path("pint", "data", "examples", filename) + return os.path.join(importlib.resources.files("pint"), f"data/examples/{filename}") def runtimefile(filename: str) -> str: @@ -55,4 +55,4 @@ def runtimefile(filename: str) -> str: This **is** for files needed at runtime. Files needed for the example notebooks are found via :func:`pint.config.examplefile`. """ - return importlib.resources.path("pint", "data", "runtime", filename) + return os.path.join(importlib.resources.files("pint"), f"data/runtime/{filename}") From b087804f01c25d7038500a9ecfd018a3376434e1 Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Mon, 21 Oct 2024 09:11:38 -0500 Subject: [PATCH 09/66] bump oldest to 3.9 --- .github/workflows/ci_test.yml | 2 +- docs/installation.rst | 2 +- pyproject.toml | 3 +-- tox.ini | 6 +++--- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci_test.yml b/.github/workflows/ci_test.yml index c3a8af4c5..35d2c4e99 100644 --- a/.github/workflows/ci_test.yml +++ b/.github/workflows/ci_test.yml @@ -48,7 +48,7 @@ jobs: # python: '3.8' # tox_env: 'py38-test' - os: ubuntu-latest - python: '3.8' + python: '3.9' tox_env: 'oldestdeps' # - os: ubuntu-latest # python: '3.8' diff --git a/docs/installation.rst b/docs/installation.rst index eb780c9ea..c6e23b549 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -14,7 +14,7 @@ is more complicated (but not too much). Prerequisites ------------- -PINT requires Python 3.8+ [1]_ +PINT requires Python 3.9+ [1]_ Your Python must have the package installation tool pip_ installed. Also make sure your ``setuptools`` are up to date (e.g. ``pip install -U setuptools``). diff --git a/pyproject.toml b/pyproject.toml index 8b85722d9..d07fdc799 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,7 +19,6 @@ classifiers = [ "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", @@ -27,7 +26,7 @@ classifiers = [ "Topic :: Scientific/Engineering :: Astronomy", "Topic :: Software Development :: Libraries :: Python Modules", ] -requires-python = ">=3.8" +requires-python = ">=3.9" dependencies = [ "numpy>=1.18.5", "astropy>=4.0,!=4.0.1,!=4.0.1.post1", diff --git a/tox.ini b/tox.ini index 4b7f6b153..f48795c55 100644 --- a/tox.ini +++ b/tox.ini @@ -48,8 +48,8 @@ commands = cov: coverage xml -o {toxinidir}/coverage.xml depends = - {py38,py39,py310,py311,py312}: clean - report: py38,py39,py310,py312 + {py39,py310,py311,py312}: clean + report: py39,py310,py312 docs: notebooks [testenv:singletest] @@ -80,7 +80,7 @@ deps = [testenv:oldestdeps] description = Run tests on Python 3 with minimum supported versions of astropy, numpy -basepython = python3.8 +basepython = python3.9 deps = numpy==1.18.5 numdifftools==0.9.39 From c8fc8fc6398f1006de836c544b7df82cb348419b Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Mon, 21 Oct 2024 11:09:47 -0500 Subject: [PATCH 10/66] limit setuptools version --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index f48795c55..8ab080d35 100644 --- a/tox.ini +++ b/tox.ini @@ -82,6 +82,7 @@ description = Run tests on Python 3 with minimum supported versions of astropy, numpy basepython = python3.9 deps = + setuptools<65 numpy==1.18.5 numdifftools==0.9.39 astropy==4.0 From 3fd81c25e9a87358a74798eceb338a3fc6fda8c4 Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Mon, 21 Oct 2024 11:16:52 -0500 Subject: [PATCH 11/66] limit setuptools in pyproject --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index d07fdc799..e4c5d7463 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["setuptools>=61.2", "versioneer"] +requires = ["setuptools>=61.2,<65", "versioneer"] build-backend = "setuptools.build_meta" [project] From 8eaf91818587a62192a8d4c7f03ec255ef39e04f Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Mon, 21 Oct 2024 11:25:21 -0500 Subject: [PATCH 12/66] added printing of setuptools version --- .github/workflows/ci_test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci_test.yml b/.github/workflows/ci_test.yml index 35d2c4e99..3fba6841e 100644 --- a/.github/workflows/ci_test.yml +++ b/.github/workflows/ci_test.yml @@ -76,11 +76,12 @@ jobs: - name: Install pandoc dependency if: "endsWith(matrix.tox_env, 'docs')" run: sudo apt-get -y install pandoc - - name: Print Python, pip, and tox versions + - name: Print Python, pip, setuptools, and tox versions run: | python -c "import sys; print(f'Python {sys.version}')" python -c "import pip; print(f'pip {pip.__version__}')" python -c "import tox; print(f'tox {tox.__version__}')" + python -c "import setuptools; print(f'setuptools {setuptools.__version__}')" - name: Run tests run: tox -e ${{ matrix.tox_env }} - name: Upload coverage to codecov From 034ae0c82465cad28712502579307ba6b2d10b0c Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Mon, 21 Oct 2024 11:28:20 -0500 Subject: [PATCH 13/66] changing print of setuptools --- .github/workflows/ci_test.yml | 3 +-- tox.ini | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci_test.yml b/.github/workflows/ci_test.yml index 3fba6841e..35d2c4e99 100644 --- a/.github/workflows/ci_test.yml +++ b/.github/workflows/ci_test.yml @@ -76,12 +76,11 @@ jobs: - name: Install pandoc dependency if: "endsWith(matrix.tox_env, 'docs')" run: sudo apt-get -y install pandoc - - name: Print Python, pip, setuptools, and tox versions + - name: Print Python, pip, and tox versions run: | python -c "import sys; print(f'Python {sys.version}')" python -c "import pip; print(f'pip {pip.__version__}')" python -c "import tox; print(f'tox {tox.__version__}')" - python -c "import setuptools; print(f'setuptools {setuptools.__version__}')" - name: Run tests run: tox -e ${{ matrix.tox_env }} - name: Upload coverage to codecov diff --git a/tox.ini b/tox.ini index 8ab080d35..373cd1ed6 100644 --- a/tox.ini +++ b/tox.ini @@ -91,7 +91,9 @@ deps = pytest coverage hypothesis<=6.72.0 -commands = {posargs:pytest} +commands = + python -c "import setuptools; print(f'setuptools {setuptools.__version__}')" + {posargs:pytest} [testenv:report] skip_install = true From fd99107ce63990539eb46aeeeedca35214c106b4 Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Mon, 21 Oct 2024 11:29:39 -0500 Subject: [PATCH 14/66] remove print of setuptools --- tox.ini | 1 - 1 file changed, 1 deletion(-) diff --git a/tox.ini b/tox.ini index 373cd1ed6..7decdcabe 100644 --- a/tox.ini +++ b/tox.ini @@ -92,7 +92,6 @@ deps = coverage hypothesis<=6.72.0 commands = - python -c "import setuptools; print(f'setuptools {setuptools.__version__}')" {posargs:pytest} [testenv:report] From 08e93838cc0615ab39e54d52766e45c8bd103c35 Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Mon, 21 Oct 2024 11:38:28 -0500 Subject: [PATCH 15/66] Revert "remove print of setuptools" This reverts commit fd99107ce63990539eb46aeeeedca35214c106b4. --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index 7decdcabe..373cd1ed6 100644 --- a/tox.ini +++ b/tox.ini @@ -92,6 +92,7 @@ deps = coverage hypothesis<=6.72.0 commands = + python -c "import setuptools; print(f'setuptools {setuptools.__version__}')" {posargs:pytest} [testenv:report] From 17461d9faadcaa83a10df137858a2497c1493e9c Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Mon, 21 Oct 2024 11:38:31 -0500 Subject: [PATCH 16/66] Revert "changing print of setuptools" This reverts commit 034ae0c82465cad28712502579307ba6b2d10b0c. --- .github/workflows/ci_test.yml | 3 ++- tox.ini | 4 +--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci_test.yml b/.github/workflows/ci_test.yml index 35d2c4e99..3fba6841e 100644 --- a/.github/workflows/ci_test.yml +++ b/.github/workflows/ci_test.yml @@ -76,11 +76,12 @@ jobs: - name: Install pandoc dependency if: "endsWith(matrix.tox_env, 'docs')" run: sudo apt-get -y install pandoc - - name: Print Python, pip, and tox versions + - name: Print Python, pip, setuptools, and tox versions run: | python -c "import sys; print(f'Python {sys.version}')" python -c "import pip; print(f'pip {pip.__version__}')" python -c "import tox; print(f'tox {tox.__version__}')" + python -c "import setuptools; print(f'setuptools {setuptools.__version__}')" - name: Run tests run: tox -e ${{ matrix.tox_env }} - name: Upload coverage to codecov diff --git a/tox.ini b/tox.ini index 373cd1ed6..8ab080d35 100644 --- a/tox.ini +++ b/tox.ini @@ -91,9 +91,7 @@ deps = pytest coverage hypothesis<=6.72.0 -commands = - python -c "import setuptools; print(f'setuptools {setuptools.__version__}')" - {posargs:pytest} +commands = {posargs:pytest} [testenv:report] skip_install = true From d8de228a3fab221e2cc4f7c16a1ff6846d54181d Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Mon, 21 Oct 2024 11:38:33 -0500 Subject: [PATCH 17/66] Revert "added printing of setuptools version" This reverts commit 8eaf91818587a62192a8d4c7f03ec255ef39e04f. --- .github/workflows/ci_test.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci_test.yml b/.github/workflows/ci_test.yml index 3fba6841e..35d2c4e99 100644 --- a/.github/workflows/ci_test.yml +++ b/.github/workflows/ci_test.yml @@ -76,12 +76,11 @@ jobs: - name: Install pandoc dependency if: "endsWith(matrix.tox_env, 'docs')" run: sudo apt-get -y install pandoc - - name: Print Python, pip, setuptools, and tox versions + - name: Print Python, pip, and tox versions run: | python -c "import sys; print(f'Python {sys.version}')" python -c "import pip; print(f'pip {pip.__version__}')" python -c "import tox; print(f'tox {tox.__version__}')" - python -c "import setuptools; print(f'setuptools {setuptools.__version__}')" - name: Run tests run: tox -e ${{ matrix.tox_env }} - name: Upload coverage to codecov From c3e17b2f09a354bea26119225171f0e48754f3d9 Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Mon, 21 Oct 2024 11:42:29 -0500 Subject: [PATCH 18/66] trying to get things working --- pyproject.toml | 2 +- tox.ini | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index e4c5d7463..d07fdc799 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["setuptools>=61.2,<65", "versioneer"] +requires = ["setuptools>=61.2", "versioneer"] build-backend = "setuptools.build_meta" [project] diff --git a/tox.ini b/tox.ini index 8ab080d35..f48795c55 100644 --- a/tox.ini +++ b/tox.ini @@ -82,7 +82,6 @@ description = Run tests on Python 3 with minimum supported versions of astropy, numpy basepython = python3.9 deps = - setuptools<65 numpy==1.18.5 numdifftools==0.9.39 astropy==4.0 From 5ad772eb498df1c532ecca25f7538d4675ea7cab Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Mon, 21 Oct 2024 12:49:59 -0500 Subject: [PATCH 19/66] trying again to specify setuptools --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index d07fdc799..af3e0fdc9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["setuptools>=61.2", "versioneer"] +requires = ["setuptools>=61.2", "setuptools<65", "versioneer"] build-backend = "setuptools.build_meta" [project] From 8ec2226e6fceca30985881ddb77a65481cf32e61 Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Mon, 21 Oct 2024 12:51:47 -0500 Subject: [PATCH 20/66] cannot specify setuptools --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index af3e0fdc9..d07fdc799 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["setuptools>=61.2", "setuptools<65", "versioneer"] +requires = ["setuptools>=61.2", "versioneer"] build-backend = "setuptools.build_meta" [project] From 05ceea2b12b3a4f5b9957b242f10c2e45e3e8ed5 Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Mon, 21 Oct 2024 14:52:10 -0500 Subject: [PATCH 21/66] add setuptools --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index f48795c55..56b28d520 100644 --- a/tox.ini +++ b/tox.ini @@ -82,6 +82,7 @@ description = Run tests on Python 3 with minimum supported versions of astropy, numpy basepython = python3.9 deps = + setuptools numpy==1.18.5 numdifftools==0.9.39 astropy==4.0 From 1415bf76f189463ed8b1eb4c5f1adb6e22f9c376 Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Mon, 21 Oct 2024 14:54:04 -0500 Subject: [PATCH 22/66] add setuptools version --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 56b28d520..455a693c0 100644 --- a/tox.ini +++ b/tox.ini @@ -82,7 +82,7 @@ description = Run tests on Python 3 with minimum supported versions of astropy, numpy basepython = python3.9 deps = - setuptools + setuptools<=65 numpy==1.18.5 numdifftools==0.9.39 astropy==4.0 From 479f1c118b4a7b9e80cab8d334d91162710dd575 Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Mon, 21 Oct 2024 14:58:08 -0500 Subject: [PATCH 23/66] change numpy to 1.19.5 --- tox.ini | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index 455a693c0..629b2ef19 100644 --- a/tox.ini +++ b/tox.ini @@ -82,8 +82,7 @@ description = Run tests on Python 3 with minimum supported versions of astropy, numpy basepython = python3.9 deps = - setuptools<=65 - numpy==1.18.5 + numpy==1.19.5 numdifftools==0.9.39 astropy==4.0 matplotlib==3.2.0 From 30e64b46dc8ca2df00aaf17641c51d1f627e40d1 Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Mon, 21 Oct 2024 15:00:49 -0500 Subject: [PATCH 24/66] add distutils explicitly --- tox.ini | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 629b2ef19..084401f07 100644 --- a/tox.ini +++ b/tox.ini @@ -82,7 +82,7 @@ description = Run tests on Python 3 with minimum supported versions of astropy, numpy basepython = python3.9 deps = - numpy==1.19.5 + numpy==1.18.5 numdifftools==0.9.39 astropy==4.0 matplotlib==3.2.0 @@ -90,6 +90,7 @@ deps = pytest coverage hypothesis<=6.72.0 + distutils commands = {posargs:pytest} [testenv:report] From 9b075795723be66c974c8295f599ca6069aaba34 Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Mon, 21 Oct 2024 15:41:28 -0500 Subject: [PATCH 25/66] try 3.10 for oldest? --- .github/workflows/ci_test.yml | 2 +- tox.ini | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci_test.yml b/.github/workflows/ci_test.yml index 35d2c4e99..7823a60e0 100644 --- a/.github/workflows/ci_test.yml +++ b/.github/workflows/ci_test.yml @@ -48,7 +48,7 @@ jobs: # python: '3.8' # tox_env: 'py38-test' - os: ubuntu-latest - python: '3.9' + python: '3.10' tox_env: 'oldestdeps' # - os: ubuntu-latest # python: '3.8' diff --git a/tox.ini b/tox.ini index 084401f07..6c8cf11c4 100644 --- a/tox.ini +++ b/tox.ini @@ -80,7 +80,7 @@ deps = [testenv:oldestdeps] description = Run tests on Python 3 with minimum supported versions of astropy, numpy -basepython = python3.9 +basepython = python3.10 deps = numpy==1.18.5 numdifftools==0.9.39 @@ -90,7 +90,6 @@ deps = pytest coverage hypothesis<=6.72.0 - distutils commands = {posargs:pytest} [testenv:report] From 223e5153464bb06794a15b2bca770dbd5c64b68f Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Tue, 22 Oct 2024 09:20:19 -0500 Subject: [PATCH 26/66] back to 3.9; try other versions of packages --- .github/workflows/ci_test.yml | 2 +- pyproject.toml | 2 +- tox.ini | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci_test.yml b/.github/workflows/ci_test.yml index 7823a60e0..35d2c4e99 100644 --- a/.github/workflows/ci_test.yml +++ b/.github/workflows/ci_test.yml @@ -48,7 +48,7 @@ jobs: # python: '3.8' # tox_env: 'py38-test' - os: ubuntu-latest - python: '3.10' + python: '3.9' tox_env: 'oldestdeps' # - os: ubuntu-latest # python: '3.8' diff --git a/pyproject.toml b/pyproject.toml index d07fdc799..896bf40c6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["setuptools>=61.2", "versioneer"] +requires = ["setuptools>=62.1.0", "versioneer"] build-backend = "setuptools.build_meta" [project] diff --git a/tox.ini b/tox.ini index 6c8cf11c4..1b0900bd9 100644 --- a/tox.ini +++ b/tox.ini @@ -80,13 +80,13 @@ deps = [testenv:oldestdeps] description = Run tests on Python 3 with minimum supported versions of astropy, numpy -basepython = python3.10 +basepython = python3.9 deps = - numpy==1.18.5 + numpy==1.23.5 numdifftools==0.9.39 - astropy==4.0 - matplotlib==3.2.0 - scipy==1.4.1 + astropy==4.0.6 + matplotlib==3.4.3 + scipy==1.13.1 pytest coverage hypothesis<=6.72.0 From 4dcead63ea6ca54c0686d1a1c79cb1bf3100ed2d Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Tue, 22 Oct 2024 09:25:52 -0500 Subject: [PATCH 27/66] numpy to 1.16 to keep asscalar --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 1b0900bd9..f7befdd1b 100644 --- a/tox.ini +++ b/tox.ini @@ -82,7 +82,7 @@ description = Run tests on Python 3 with minimum supported versions of astropy, numpy basepython = python3.9 deps = - numpy==1.23.5 + numpy==1.26 numdifftools==0.9.39 astropy==4.0.6 matplotlib==3.4.3 From c17b5b357b486364e004f0bfc2338bc53259e019 Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Tue, 22 Oct 2024 09:28:50 -0500 Subject: [PATCH 28/66] numpy to 1.16 to keep asscalar --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index f7befdd1b..92defb727 100644 --- a/tox.ini +++ b/tox.ini @@ -82,7 +82,7 @@ description = Run tests on Python 3 with minimum supported versions of astropy, numpy basepython = python3.9 deps = - numpy==1.26 + numpy==1.16 numdifftools==0.9.39 astropy==4.0.6 matplotlib==3.4.3 From 91360927e11f0b1995434bba515840a20b3e69b3 Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Tue, 22 Oct 2024 09:38:39 -0500 Subject: [PATCH 29/66] moving to astropy 5 and related --- tox.ini | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tox.ini b/tox.ini index 92defb727..3bd6fa863 100644 --- a/tox.ini +++ b/tox.ini @@ -82,11 +82,11 @@ description = Run tests on Python 3 with minimum supported versions of astropy, numpy basepython = python3.9 deps = - numpy==1.16 + numpy==1.23.5 numdifftools==0.9.39 - astropy==4.0.6 + astropy==5.0.5 matplotlib==3.4.3 - scipy==1.13.1 + scipy==1.9.1 pytest coverage hypothesis<=6.72.0 From 0b00c719c10d5c1baad58bb88011b2abe55ba4fc Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Tue, 22 Oct 2024 09:53:34 -0500 Subject: [PATCH 30/66] try a little earlier --- tox.ini | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tox.ini b/tox.ini index 3bd6fa863..1bc8eb401 100644 --- a/tox.ini +++ b/tox.ini @@ -82,11 +82,11 @@ description = Run tests on Python 3 with minimum supported versions of astropy, numpy basepython = python3.9 deps = - numpy==1.23.5 + numpy==1.23.0 numdifftools==0.9.39 - astropy==5.0.5 + astropy==5.0 matplotlib==3.4.3 - scipy==1.9.1 + scipy==1.9.0 pytest coverage hypothesis<=6.72.0 From 3b10171e81861ceaccbf537549bae40a6603f1e7 Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Tue, 22 Oct 2024 09:56:21 -0500 Subject: [PATCH 31/66] astropy to 5.0.5 --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 1bc8eb401..0bf7e9816 100644 --- a/tox.ini +++ b/tox.ini @@ -84,7 +84,7 @@ basepython = python3.9 deps = numpy==1.23.0 numdifftools==0.9.39 - astropy==5.0 + astropy==5.0.5 matplotlib==3.4.3 scipy==1.9.0 pytest From 1f60fcb9fd326e5a5daa17b77f1c549859bc21c3 Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Tue, 22 Oct 2024 11:35:06 -0500 Subject: [PATCH 32/66] setuptools to 61.2? --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 896bf40c6..d07fdc799 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["setuptools>=62.1.0", "versioneer"] +requires = ["setuptools>=61.2", "versioneer"] build-backend = "setuptools.build_meta" [project] From 333049872fbcb44886546ed5d47140dc36baad4e Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Tue, 22 Oct 2024 14:03:06 -0500 Subject: [PATCH 33/66] update dependency versions --- pyproject.toml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index d07fdc799..448711d0e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,12 +28,12 @@ classifiers = [ ] requires-python = ">=3.9" dependencies = [ - "numpy>=1.18.5", - "astropy>=4.0,!=4.0.1,!=4.0.1.post1", + "numpy>=1.23.0", + "astropy>=5.0.5", "pyerfa", - "scipy>=1.4.1", + "scipy>=1.9.0", "jplephem>=2.6", - "matplotlib>=3.2.0", + "matplotlib>=3.4.3", "emcee>=3.0.1", "corner>=2.0.1", "uncertainties", From b3b90d0beaec211b73d4cc1d8914c8d49a3b9d5e Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Tue, 22 Oct 2024 14:04:48 -0500 Subject: [PATCH 34/66] changed in requirements*.txt --- requirements.txt | 8 ++++---- requirements_dev.txt | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/requirements.txt b/requirements.txt index 16f76401e..293e3d07a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,9 +1,9 @@ -numpy>=1.18.5 -astropy>=4.0,!=4.0.1,!=4.0.1.post1 +numpy>=1.23.0 +astropy>=5.0.5 pyerfa -scipy>=1.4.1 +scipy>=1.9.0 jplephem>=2.6 -matplotlib>=3.2.0 +matplotlib>=3.4.3 emcee>=3.0.1 corner>=2.0.1 uncertainties diff --git a/requirements_dev.txt b/requirements_dev.txt index a00511840..c4fba2da1 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -1,10 +1,9 @@ attrs>=19.2 pip>=9.0.1 -setuptools>=41.0 +setuptools>=61.2 coverage>=4.3.4 traitlets Sphinx==6.2.1 -astropy>=4.0,!=4.0.1,!=4.0.1.post1 #astropy-helpers>=1.3 sphinx-rtd-theme==1.2.2 coveralls>=1.1 From 30ef430f47558067ee680a220d73fb0287aa6011 Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Wed, 23 Oct 2024 11:40:26 -0500 Subject: [PATCH 35/66] try python 3.13 --- .github/workflows/ci_test.yml | 12 ++++++------ pyproject.toml | 1 + tox.ini | 10 +++++----- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci_test.yml b/.github/workflows/ci_test.yml index 35d2c4e99..a5f6c9756 100644 --- a/.github/workflows/ci_test.yml +++ b/.github/workflows/ci_test.yml @@ -24,16 +24,16 @@ jobs: matrix: include: - os: ubuntu-latest - python: '3.12' + python: '3.13' tox_env: 'ephemeris_connection' - os: ubuntu-latest - python: '3.12' + python: '3.13' tox_env: 'black' - os: ubuntu-latest - python: '3.12' + python: '3.13' tox_env: 'py312-test-cov' - os: ubuntu-latest - python: '3.12' + python: '3.13' tox_env: 'notebooks' # - os: ubuntu-latest # python: '3.8' @@ -42,8 +42,8 @@ jobs: # python: '3.10' # tox_env: 'py310-test-alldeps-cov' - os: macos-12 - python: '3.12' - tox_env: 'py312-test' + python: '3.13' + tox_env: 'py313-test' # - os: windows-latest # python: '3.8' # tox_env: 'py38-test' diff --git a/pyproject.toml b/pyproject.toml index 448711d0e..fa5ebdbe7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,6 +23,7 @@ classifiers = [ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Topic :: Scientific/Engineering :: Astronomy", "Topic :: Software Development :: Libraries :: Python Modules", ] diff --git a/tox.ini b/tox.ini index 0bf7e9816..efadd9b9c 100644 --- a/tox.ini +++ b/tox.ini @@ -14,7 +14,7 @@ envlist = codestyle black singletest - py{38,39,310,311,312}-test{,-alldeps,-devdeps}{,-cov} + py{38,39,310,311,312,313}-test{,-alldeps,-devdeps}{,-cov} skip_missing_interpreters = True @@ -48,8 +48,8 @@ commands = cov: coverage xml -o {toxinidir}/coverage.xml depends = - {py39,py310,py311,py312}: clean - report: py39,py310,py312 + {py39,py310,py311,py312,313}: clean + report: py39,py310,py312,py313 docs: notebooks [testenv:singletest] @@ -102,7 +102,7 @@ commands = [testenv:notebooks] description = update the notebooks -basepython = python3.12 +basepython = python3.13 deps = traitlets sphinx >= 2.2, != 5.1.0 @@ -130,7 +130,7 @@ commands = coverage erase [testenv:docs] changedir = {toxinidir}/docs description = invoke sphinx-build to build the HTML docs -basepython = python3.12 +basepython = python3.13 deps = traitlets sphinx >= 2.2, != 5.1.0 From 5dfc3490914f442550f28bd77318a10655c5184d Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Wed, 23 Oct 2024 11:44:45 -0500 Subject: [PATCH 36/66] fix 3.13 tests --- .github/workflows/ci_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_test.yml b/.github/workflows/ci_test.yml index a5f6c9756..79d3ca0a2 100644 --- a/.github/workflows/ci_test.yml +++ b/.github/workflows/ci_test.yml @@ -31,7 +31,7 @@ jobs: tox_env: 'black' - os: ubuntu-latest python: '3.13' - tox_env: 'py312-test-cov' + tox_env: 'py313-test-cov' - os: ubuntu-latest python: '3.13' tox_env: 'notebooks' From eb43e6c0e5a8a232060bc706c39b01b2f297142b Mon Sep 17 00:00:00 2001 From: Deven Bhakta Date: Thu, 24 Oct 2024 11:24:42 -0400 Subject: [PATCH 37/66] Renamed calc_phase option to linearize_model option within event_optimze --- CHANGELOG-unreleased.md | 2 ++ src/pint/scripts/event_optimize.py | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/CHANGELOG-unreleased.md b/CHANGELOG-unreleased.md index 2899b99f8..991f5caad 100644 --- a/CHANGELOG-unreleased.md +++ b/CHANGELOG-unreleased.md @@ -9,6 +9,8 @@ the released changes. ## Unreleased ### Changed +- Updated the `plot_priors` function in `plot_utils.py` and `plot_chains` function in `event_optimize` so that the subplots are a fixed size to prevent the subplots from being condensed in the case of many fit parameters. ### Added +- Added an option `linearize_model` to speed up the photon phases calculation within `event_optimize` through the designmatrix. ### Fixed ### Removed diff --git a/src/pint/scripts/event_optimize.py b/src/pint/scripts/event_optimize.py index 1b66b2229..071860a8d 100755 --- a/src/pint/scripts/event_optimize.py +++ b/src/pint/scripts/event_optimize.py @@ -417,7 +417,7 @@ def __init__( self.M, _, _ = self.model.designmatrix(self.toas) self.M = self.M.transpose() * -self.model.F0.value self.phases = self.get_event_phases() - self.calc_phase = False + self.linearize_model = False def calc_phase_matrix(self, theta): d_phs = np.zeros(len(self.toas)) @@ -456,7 +456,7 @@ def lnposterior(self, theta): return -np.inf, -np.inf, -np.inf # Call PINT to compute the phases - if self.calc_phase: + if self.linearize_model: phases = self.calc_phase_matrix(theta) else: phases = self.get_event_phases() @@ -700,11 +700,11 @@ def main(argv=None): dest="noautocorr", ) parser.add_argument( - "--calc_phase", + "--linearize_model", help="Calculates the phase at each MCMC step using the designmatrix", default=False, action="store_true", - dest="calc_phase", + dest="linearize_model", ) args = parser.parse_args(argv) @@ -882,8 +882,8 @@ def main(argv=None): # This way, one walker should always be in a good position pos[0] = ftr.fitvals - # How phase will be calculated at each step (either with the designmatrix or ) - ftr.calc_phase = True if args.calc_phase else False + # How phase will be calculated at each step (either with the designmatrix orthe exact phase calculation) + ftr.linearize_model = args.linearize_model import emcee From 827bcbbabe0b4977feecf8b1d14646f746ac2762 Mon Sep 17 00:00:00 2001 From: Deven Bhakta Date: Thu, 24 Oct 2024 11:26:55 -0400 Subject: [PATCH 38/66] Changelog entry update --- CHANGELOG-unreleased.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG-unreleased.md b/CHANGELOG-unreleased.md index 991f5caad..366c272e0 100644 --- a/CHANGELOG-unreleased.md +++ b/CHANGELOG-unreleased.md @@ -12,5 +12,6 @@ the released changes. - Updated the `plot_priors` function in `plot_utils.py` and `plot_chains` function in `event_optimize` so that the subplots are a fixed size to prevent the subplots from being condensed in the case of many fit parameters. ### Added - Added an option `linearize_model` to speed up the photon phases calculation within `event_optimize` through the designmatrix. +- Added AIC and BIC calculation to be written in the post fit parfile from `event_optimize` ### Fixed ### Removed From 5813090dc86bb0d6e3fa37857711d9528c648236 Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Thu, 24 Oct 2024 11:59:01 -0500 Subject: [PATCH 39/66] changelog --- CHANGELOG-unreleased.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG-unreleased.md b/CHANGELOG-unreleased.md index 2899b99f8..0a3db3563 100644 --- a/CHANGELOG-unreleased.md +++ b/CHANGELOG-unreleased.md @@ -9,6 +9,9 @@ the released changes. ## Unreleased ### Changed +* Bump oldest python to 3.9 +* Change oldest dependencies: `numpy` 1.18.5 to 1.23.0; `astropy` 4.0 to 5.0.5; `scipy` 1.4.1 to 1.9.0; `matplotlib` 3.2.0 to 3.4.3 +* Update CI testing to use python 3.13 ### Added ### Fixed ### Removed From 8c8b1269ea2b6cf5f4b9da8e744fc4742eeb90d7 Mon Sep 17 00:00:00 2001 From: Paul Ray Date: Tue, 5 Nov 2024 10:40:11 -0500 Subject: [PATCH 40/66] Update CHANGELOG for version 1.1 --- CHANGELOG-unreleased.md | 3 --- CHANGELOG.md | 6 ++++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG-unreleased.md b/CHANGELOG-unreleased.md index 0a3db3563..2899b99f8 100644 --- a/CHANGELOG-unreleased.md +++ b/CHANGELOG-unreleased.md @@ -9,9 +9,6 @@ the released changes. ## Unreleased ### Changed -* Bump oldest python to 3.9 -* Change oldest dependencies: `numpy` 1.18.5 to 1.23.0; `astropy` 4.0 to 5.0.5; `scipy` 1.4.1 to 1.9.0; `matplotlib` 3.2.0 to 3.4.3 -* Update CI testing to use python 3.13 ### Added ### Fixed ### Removed diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c905242f..3f24dffe3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ and this project, at least loosely, adheres to [Semantic Versioning](https://sem This file contains the released changes to the codebase. See CHANGELOG-unreleased.md for the unreleased changes. This file should only be changed while tagging a new version. +## [1.1] 2024-11-05 +### Changed +* Bump oldest python to 3.9 +* Change oldest dependencies: `numpy` 1.18.5 to 1.23.0; `astropy` 4.0 to 5.0.5; `scipy` 1.4.1 to 1.9.0; `matplotlib` 3.2.0 to 3.4.3 +* Update CI testing to use python 3.13 + ## [1.0.2] 2024-10-18 ### Changed - Moved the events -> TOAs and photon weights code into the function `load_events_weights` within `event_optimize`. From b88b28edbdce0fda8b8e3f6e3698b32e082c2cf8 Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Tue, 5 Nov 2024 14:03:45 -0600 Subject: [PATCH 41/66] add printing of parameters that need TCB->TDB scaling; make conversion from TNEQUAD to EQUAD free of scaling --- src/pint/models/noise_model.py | 1 + src/pint/models/parameter.py | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/pint/models/noise_model.py b/src/pint/models/noise_model.py index b53ebdb2d..b1af8e10f 100644 --- a/src/pint/models/noise_model.py +++ b/src/pint/models/noise_model.py @@ -122,6 +122,7 @@ def setup(self): index=tneq_par.index, aliases=["T2EQUAD"], description="An error term added in quadrature to the scaled (by EFAC) TOA uncertainty.", + convert_tcb2tdb=False, ) ) EQUAD_par = getattr(self, EQUAD_name) diff --git a/src/pint/models/parameter.py b/src/pint/models/parameter.py index ea92f4611..5e3d9e607 100644 --- a/src/pint/models/parameter.py +++ b/src/pint/models/parameter.py @@ -709,7 +709,7 @@ def __init__( assert ( not convert_tcb2tdb or tcb2tdb_scale_factor is not None - ), "Please specify the tcb2tdb_scale_factor explicitly." + ), f"Please specify the tcb2tdb_scale_factor explicitly for {name}." self.convert_tcb2tdb = convert_tcb2tdb self.tcb2tdb_scale_factor = tcb2tdb_scale_factor @@ -1133,7 +1133,7 @@ def __init__( assert ( not convert_tcb2tdb or tcb2tdb_scale_factor is not None - ), "Please specify the tcb2tdb_scale_factor explicitly." + ), f"Please specify the tcb2tdb_scale_factor explicitly for {name}." self.convert_tcb2tdb = convert_tcb2tdb self.tcb2tdb_scale_factor = tcb2tdb_scale_factor @@ -1334,7 +1334,7 @@ def __init__( assert ( not convert_tcb2tdb or tcb2tdb_scale_factor is not None - ), "Please specify the tcb2tdb_scale_factor explicitly." + ), f"Please specify the tcb2tdb_scale_factor explicitly for {name}." self.convert_tcb2tdb = convert_tcb2tdb self.tcb2tdb_scale_factor = tcb2tdb_scale_factor @@ -1554,7 +1554,7 @@ def __init__( # a function of the prefix. assert ( not convert_tcb2tdb or tcb2tdb_scale_factor is not None - ), "Please specify the tcb2tdb_scale_factor explicitly." + ), f"Please specify the tcb2tdb_scale_factor explicitly for {name}." tcb2tdb_scale_factor_val = ( tcb2tdb_scale_factor(self.prefix) if hasattr(tcb2tdb_scale_factor, "__call__") From d1c6b0be80e2375439774e5350ac1aa40d0dc120 Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Tue, 5 Nov 2024 14:08:45 -0600 Subject: [PATCH 42/66] Revert "add printing of parameters that need TCB->TDB scaling; make conversion from TNEQUAD to EQUAD free of scaling" This reverts commit b88b28edbdce0fda8b8e3f6e3698b32e082c2cf8. --- src/pint/models/noise_model.py | 1 - src/pint/models/parameter.py | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/pint/models/noise_model.py b/src/pint/models/noise_model.py index b1af8e10f..b53ebdb2d 100644 --- a/src/pint/models/noise_model.py +++ b/src/pint/models/noise_model.py @@ -122,7 +122,6 @@ def setup(self): index=tneq_par.index, aliases=["T2EQUAD"], description="An error term added in quadrature to the scaled (by EFAC) TOA uncertainty.", - convert_tcb2tdb=False, ) ) EQUAD_par = getattr(self, EQUAD_name) diff --git a/src/pint/models/parameter.py b/src/pint/models/parameter.py index 5e3d9e607..ea92f4611 100644 --- a/src/pint/models/parameter.py +++ b/src/pint/models/parameter.py @@ -709,7 +709,7 @@ def __init__( assert ( not convert_tcb2tdb or tcb2tdb_scale_factor is not None - ), f"Please specify the tcb2tdb_scale_factor explicitly for {name}." + ), "Please specify the tcb2tdb_scale_factor explicitly." self.convert_tcb2tdb = convert_tcb2tdb self.tcb2tdb_scale_factor = tcb2tdb_scale_factor @@ -1133,7 +1133,7 @@ def __init__( assert ( not convert_tcb2tdb or tcb2tdb_scale_factor is not None - ), f"Please specify the tcb2tdb_scale_factor explicitly for {name}." + ), "Please specify the tcb2tdb_scale_factor explicitly." self.convert_tcb2tdb = convert_tcb2tdb self.tcb2tdb_scale_factor = tcb2tdb_scale_factor @@ -1334,7 +1334,7 @@ def __init__( assert ( not convert_tcb2tdb or tcb2tdb_scale_factor is not None - ), f"Please specify the tcb2tdb_scale_factor explicitly for {name}." + ), "Please specify the tcb2tdb_scale_factor explicitly." self.convert_tcb2tdb = convert_tcb2tdb self.tcb2tdb_scale_factor = tcb2tdb_scale_factor @@ -1554,7 +1554,7 @@ def __init__( # a function of the prefix. assert ( not convert_tcb2tdb or tcb2tdb_scale_factor is not None - ), f"Please specify the tcb2tdb_scale_factor explicitly for {name}." + ), "Please specify the tcb2tdb_scale_factor explicitly." tcb2tdb_scale_factor_val = ( tcb2tdb_scale_factor(self.prefix) if hasattr(tcb2tdb_scale_factor, "__call__") From 71bd859152ebb5aaca19cb91668987f56b23aa2d Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Tue, 5 Nov 2024 14:10:55 -0600 Subject: [PATCH 43/66] add printing of parameters that need TCB->TDB scaling; make conversion from TNEQUAD to EQUAD free of scaling --- src/pint/models/noise_model.py | 1 + src/pint/models/parameter.py | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/pint/models/noise_model.py b/src/pint/models/noise_model.py index b53ebdb2d..b1af8e10f 100644 --- a/src/pint/models/noise_model.py +++ b/src/pint/models/noise_model.py @@ -122,6 +122,7 @@ def setup(self): index=tneq_par.index, aliases=["T2EQUAD"], description="An error term added in quadrature to the scaled (by EFAC) TOA uncertainty.", + convert_tcb2tdb=False, ) ) EQUAD_par = getattr(self, EQUAD_name) diff --git a/src/pint/models/parameter.py b/src/pint/models/parameter.py index ea92f4611..5e3d9e607 100644 --- a/src/pint/models/parameter.py +++ b/src/pint/models/parameter.py @@ -709,7 +709,7 @@ def __init__( assert ( not convert_tcb2tdb or tcb2tdb_scale_factor is not None - ), "Please specify the tcb2tdb_scale_factor explicitly." + ), f"Please specify the tcb2tdb_scale_factor explicitly for {name}." self.convert_tcb2tdb = convert_tcb2tdb self.tcb2tdb_scale_factor = tcb2tdb_scale_factor @@ -1133,7 +1133,7 @@ def __init__( assert ( not convert_tcb2tdb or tcb2tdb_scale_factor is not None - ), "Please specify the tcb2tdb_scale_factor explicitly." + ), f"Please specify the tcb2tdb_scale_factor explicitly for {name}." self.convert_tcb2tdb = convert_tcb2tdb self.tcb2tdb_scale_factor = tcb2tdb_scale_factor @@ -1334,7 +1334,7 @@ def __init__( assert ( not convert_tcb2tdb or tcb2tdb_scale_factor is not None - ), "Please specify the tcb2tdb_scale_factor explicitly." + ), f"Please specify the tcb2tdb_scale_factor explicitly for {name}." self.convert_tcb2tdb = convert_tcb2tdb self.tcb2tdb_scale_factor = tcb2tdb_scale_factor @@ -1554,7 +1554,7 @@ def __init__( # a function of the prefix. assert ( not convert_tcb2tdb or tcb2tdb_scale_factor is not None - ), "Please specify the tcb2tdb_scale_factor explicitly." + ), f"Please specify the tcb2tdb_scale_factor explicitly for {name}." tcb2tdb_scale_factor_val = ( tcb2tdb_scale_factor(self.prefix) if hasattr(tcb2tdb_scale_factor, "__call__") From a88f15ade5bd19549d26034f17ade32c6a2557aa Mon Sep 17 00:00:00 2001 From: Matthew Kerr Date: Wed, 6 Nov 2024 12:51:04 -0500 Subject: [PATCH 44/66] Provide physical formulas for magnetic field calculations. --- src/pint/derived_quantities.py | 70 +++++++++++++++++++++----------- tests/test_derived_quantities.py | 4 +- 2 files changed, 49 insertions(+), 25 deletions(-) diff --git a/src/pint/derived_quantities.py b/src/pint/derived_quantities.py index d5852ae4b..6cae3c39a 100644 --- a/src/pint/derived_quantities.py +++ b/src/pint/derived_quantities.py @@ -130,12 +130,22 @@ def pferrs( return [1.0 / porf, porferr / porf**2.0] forperr = porferr / porf**2.0 fdorpderr = np.sqrt( - (4.0 * pdorfd**2.0 * porferr**2.0) / porf**6.0 + pdorfderr**2.0 / porf**4.0 + (4.0 * pdorfd**2.0 * porferr**2.0) / porf**6.0 + + pdorfderr**2.0 / porf**4.0 ) [forp, fdorpd] = p_to_f(porf, pdorfd) return (forp, forperr, fdorpd, fdorpderr) +def _to_gauss(B: u.Quantity) -> u.G: + """Convert quantity with mass, length, and time units to Gauss. + + In cgs units, magnetic field is has units (mass/length)^(1/2) / time. + """ + eq = [u.Gauss, u.Hz * (u.g / u.cm) ** (1 / 2), lambda x: x, lambda x: x] + return B.to(u.Gauss, equivalencies=[eq]) + + @u.quantity_input(f=u.Hz, fdot=u.Hz / u.s, fo=u.Hz) def pulsar_age( f: u.Quantity, fdot: u.Quantity, n: int = 3, fo: u.Quantity = 1e99 * u.Hz @@ -219,12 +229,16 @@ def pulsar_edot( return (-4.0 * np.pi**2 * I * f * fdot).to(u.erg / u.s) -@u.quantity_input(f=u.Hz, fdot=u.Hz / u.s) -def pulsar_B(f: u.Quantity, fdot: u.Quantity) -> u.G: +@u.quantity_input(f=u.Hz, fdot=u.Hz / u.s, I=u.g * u.cm**2, R=u.km) +def pulsar_B( + f: u.Quantity, + fdot: u.Quantity, + I: u.Quantity = 1.0e45 * u.g * u.cm**2, + R: u.Quantity = 10 * u.km, +) -> u.G: r"""Compute pulsar surface magnetic field - Return the estimated pulsar surface magnetic field strength - given the spin frequency and frequency derivative. + Return the pulsar surface magnetic field strength given the spin frequency `f` and frequency derivative `fdot`. Parameters ---------- @@ -232,6 +246,10 @@ def pulsar_B(f: u.Quantity, fdot: u.Quantity) -> u.G: pulsar frequency fdot : astropy.units.Quantity frequency derivative :math:`\dot f` + I : astropy.units.Quantity, optional + pulsar moment of inertia, default of 1e45 g*cm**2 + R : astropy.units.Quantity, optional + pulsar radius, default of 10 km Returns ------- @@ -247,15 +265,19 @@ def pulsar_B(f: u.Quantity, fdot: u.Quantity) -> u.G: Notes ----- - Calculates :math:`B=3.2\times 10^{19}\,{\rm G}\sqrt{ f \dot f^{-3}}` + Calculates :math:`B=\sqrt{\frac{3\,I\,c^3}{8\pi^2\,R^6}\times\frac{-\dot{f}}{f^3}}` """ - # This is a hack to use the traditional formula by stripping the units. - # It would be nice to improve this to a proper formula with units - return 3.2e19 * u.G * np.sqrt(-fdot.to_value(u.Hz / u.s) / f.to_value(u.Hz) ** 3.0) + factor = (3.0 * I * const.c**3) / (8.0 * np.pi**2 * R**6) + return _to_gauss((factor * (-fdot) / f**3) ** 0.5) -@u.quantity_input(f=u.Hz, fdot=u.Hz / u.s) -def pulsar_B_lightcyl(f: u.Quantity, fdot: u.Quantity) -> u.G: +@u.quantity_input(f=u.Hz, fdot=u.Hz / u.s, I=u.g * u.cm**2, R=u.km) +def pulsar_B_lightcyl( + f: u.Quantity, + fdot: u.Quantity, + I: u.Quantity = 1.0e45 * u.g * u.cm**2, + R=10 * u.km, +) -> u.G: r"""Compute pulsar magnetic field at the light cylinder Return the estimated pulsar magnetic field strength at the @@ -268,6 +290,10 @@ def pulsar_B_lightcyl(f: u.Quantity, fdot: u.Quantity) -> u.G: pulsar frequency fdot : astropy.units.Quantity frequency derivative :math:`\dot f` + I : astropy.units.Quantity, optional + pulsar moment of inertia, default of 1e45 g*cm**2 + R : astropy.units.Quantity, optional + pulsar radius, default of 10 km Returns ------- @@ -283,17 +309,10 @@ def pulsar_B_lightcyl(f: u.Quantity, fdot: u.Quantity) -> u.G: Notes ----- - Calculates :math:`B_{LC} = 2.9\times 10^8\,{\rm G} P^{-5/2} \dot P^{1/2}` + Calculates :math:`B_{LC} = \sqrt{\frac{-24\pi^4\,I}{c^3}\dot{f}f^3}` """ - p, pd = p_to_f(f, fdot) - # This is a hack to use the traditional formula by stripping the units. - # It would be nice to improve this to a proper formula with units - return ( - 2.9e8 - * u.G - * p.to_value(u.s) ** (-5.0 / 2.0) - * np.sqrt(pd.to(u.dimensionless_unscaled).value) - ) + factor = 24.0 * np.pi**4.0 * I / const.c**3.0 + return _to_gauss((factor * (-fdot) * f**3.0) ** 0.5) @u.quantity_input(pb=u.d, x=u.cm) @@ -533,12 +552,17 @@ def companion_mass( # delta1 is always <0 # delta1 = 2 * b ** 3 - 9 * a * b * c + 27 * a ** 2 * d delta1 = ( - -2 * massfunct**3 - 18 * a * mp * massfunct**2 - 27 * a**2 * massfunct * mp**2 + -2 * massfunct**3 + - 18 * a * mp * massfunct**2 + - 27 * a**2 * massfunct * mp**2 ) # Q**2 is always > 0, so this is never a problem # in terms of complex numbers # Q = np.sqrt(delta1**2 - 4*delta0**3) - Q = np.sqrt(108 * a**3 * mp**3 * massfunct**3 + 729 * a**4 * mp**4 * massfunct**2) + Q = np.sqrt( + 108 * a**3 * mp**3 * massfunct**3 + + 729 * a**4 * mp**4 * massfunct**2 + ) # this could be + or - Q # pick the - branch since delta1 is <0 so that delta1 - Q is never near 0 Ccubed = 0.5 * (delta1 + Q) diff --git a/tests/test_derived_quantities.py b/tests/test_derived_quantities.py index cf5e845b0..833e98a86 100644 --- a/tests/test_derived_quantities.py +++ b/tests/test_derived_quantities.py @@ -67,7 +67,7 @@ def test_Edot(): def test_Bfield(): # B assert np.isclose( - pulsar_B(0.033 * u.Hz, -2.0e-15 * u.Hz / u.s), 238722891596281.66 * u.G + pulsar_B(0.033 * u.Hz, -2.0e-15 * u.Hz / u.s), 238693670891966.22 * u.G ) @@ -75,7 +75,7 @@ def test_Blc(): # B_lc assert np.isclose( pulsar_B_lightcyl(0.033 * u.Hz, -2.0e-15 * u.Hz / u.s), - 0.07774704753236616 * u.G, + 0.07896965114785195 * u.G, ) From bc3873d2fc85f6462bbf19beb9fc44ad9e939874 Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Wed, 6 Nov 2024 12:17:57 -0600 Subject: [PATCH 45/66] changelog --- CHANGELOG-unreleased.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG-unreleased.md b/CHANGELOG-unreleased.md index 2899b99f8..175886dcc 100644 --- a/CHANGELOG-unreleased.md +++ b/CHANGELOG-unreleased.md @@ -10,5 +10,7 @@ the released changes. ## Unreleased ### Changed ### Added +* When TCB->TDB conversion info is missing, will print parameter name ### Fixed +* When EQUAD is created from TNEQ, has proper TCB->TDB conversion info ### Removed From 75eb2c8f9470d06ebc71974b33a4d32bc9d33b6a Mon Sep 17 00:00:00 2001 From: Abhimanyu Susobhanan Date: Mon, 11 Nov 2024 14:33:56 +0100 Subject: [PATCH 46/66] update black --- .pre-commit-config.yaml | 2 +- requirements_dev.txt | 3 +-- tox.ini | 6 +++--- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6c2c4b8cc..82fcce346 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,6 +6,6 @@ repos: - id: check-merge-conflict - id: check-symlinks - repo: https://github.com/psf/black - rev: 24.2.0 + rev: 24.10.0 hooks: - id: black diff --git a/requirements_dev.txt b/requirements_dev.txt index c4fba2da1..f5dfff94b 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -28,8 +28,7 @@ pdbpp tox pre-commit typed-ast>=1.5.0 -#black>=19.0a0,<20.0a0 -black~=23.0 +black~=24.0 pygments ipython pathlib2 diff --git a/tox.ini b/tox.ini index efadd9b9c..1fcb0003b 100644 --- a/tox.ini +++ b/tox.ini @@ -12,7 +12,7 @@ envlist = docs report codestyle - black + black~=24.0 singletest py{38,39,310,311,312,313}-test{,-alldeps,-devdeps}{,-cov} @@ -114,7 +114,7 @@ deps = nbconvert pytest jupytext - black + black~=24.0 setuptools commands = jupytext --sync examples/*.py @@ -141,7 +141,7 @@ deps = nbconvert pytest jupytext - black + black~=24.0 setuptools commands = sphinx-build -d "{toxworkdir}/docs_doctree" . "{toxworkdir}/docs_out" --color -bhtml {posargs} python -c 'import pathlib; print("documentation available under file://\{0\}".format(pathlib.Path(r"{toxworkdir}") / "docs_out" / "index.html"))' From ac14c917600bbbc5c170add84a46ca30aeecd32c Mon Sep 17 00:00:00 2001 From: Abhimanyu Susobhanan Date: Mon, 11 Nov 2024 14:36:30 +0100 Subject: [PATCH 47/66] tox.ini --- tox.ini | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tox.ini b/tox.ini index 1fcb0003b..d00727885 100644 --- a/tox.ini +++ b/tox.ini @@ -12,7 +12,7 @@ envlist = docs report codestyle - black~=24.0 + black singletest py{38,39,310,311,312,313}-test{,-alldeps,-devdeps}{,-cov} @@ -114,7 +114,7 @@ deps = nbconvert pytest jupytext - black~=24.0 + black setuptools commands = jupytext --sync examples/*.py @@ -141,7 +141,7 @@ deps = nbconvert pytest jupytext - black~=24.0 + black setuptools commands = sphinx-build -d "{toxworkdir}/docs_doctree" . "{toxworkdir}/docs_out" --color -bhtml {posargs} python -c 'import pathlib; print("documentation available under file://\{0\}".format(pathlib.Path(r"{toxworkdir}") / "docs_out" / "index.html"))' @@ -151,7 +151,7 @@ skip_install = true changedir = . description = use black deps = - black~=24.0 + black commands = black --check src tests examples From 2487924e0b4dee89cf38f2ea2c7d309221a1273b Mon Sep 17 00:00:00 2001 From: Abhimanyu Susobhanan Date: Mon, 11 Nov 2024 14:38:29 +0100 Subject: [PATCH 48/66] tox.ini --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index d00727885..efadd9b9c 100644 --- a/tox.ini +++ b/tox.ini @@ -151,7 +151,7 @@ skip_install = true changedir = . description = use black deps = - black + black~=24.0 commands = black --check src tests examples From e55903551c397c9fe1bc7a01ffc3edd05747ded7 Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Mon, 11 Nov 2024 09:11:48 -0600 Subject: [PATCH 49/66] fixed changelog --- CHANGELOG-unreleased.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG-unreleased.md b/CHANGELOG-unreleased.md index 175886dcc..d15e5e781 100644 --- a/CHANGELOG-unreleased.md +++ b/CHANGELOG-unreleased.md @@ -10,7 +10,7 @@ the released changes. ## Unreleased ### Changed ### Added -* When TCB->TDB conversion info is missing, will print parameter name +- When TCB->TDB conversion info is missing, will print parameter name ### Fixed -* When EQUAD is created from TNEQ, has proper TCB->TDB conversion info +- When EQUAD is created from TNEQ, has proper TCB->TDB conversion info ### Removed From 85b27a22fab1584099361b74f57828058fa44be8 Mon Sep 17 00:00:00 2001 From: Deven Bhakta Date: Thu, 14 Nov 2024 10:39:34 -0500 Subject: [PATCH 50/66] Revert plot_priors change --- CHANGELOG-unreleased.md | 2 +- src/pint/plot_utils.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG-unreleased.md b/CHANGELOG-unreleased.md index f5892a3f9..09561bfca 100644 --- a/CHANGELOG-unreleased.md +++ b/CHANGELOG-unreleased.md @@ -9,7 +9,7 @@ the released changes. ## Unreleased ### Changed -- Updated the `plot_priors` function in `plot_utils.py` and `plot_chains` function in `event_optimize` so that the subplots are a fixed size to prevent the subplots from being condensed in the case of many fit parameters. +- Updated the `plot_chains` function in `event_optimize` so that the subplots are a fixed size to prevent the subplots from being condensed in the case of many fit parameters. ### Added - Added an option `linearize_model` to speed up the photon phases calculation within `event_optimize` through the designmatrix. - Added AIC and BIC calculation to be written in the post fit parfile from `event_optimize` diff --git a/src/pint/plot_utils.py b/src/pint/plot_utils.py index 917412b71..289655f6d 100644 --- a/src/pint/plot_utils.py +++ b/src/pint/plot_utils.py @@ -279,7 +279,7 @@ def plot_priors( for i in range(len(keys[:-1])): values[i] = values[i][burnin:].flatten() x_range.append(np.linspace(values[i].min(), values[i].max(), num=bins)) - priors.append(getattr(model, keys[i]).prior.logpdf(x_range[i])) + priors.append(getattr(model, keys[i]).prior.pdf(x_range[i])) a, x = np.histogram(values[i], bins=bins, density=True) counts.append(a) From dbdef6d25a54e932281f0edd7862120d1e19b9ed Mon Sep 17 00:00:00 2001 From: Matthew Kerr Date: Thu, 14 Nov 2024 10:45:49 -0500 Subject: [PATCH 51/66] Fix units on WAVE_OM. --- src/pint/models/wave.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/pint/models/wave.py b/src/pint/models/wave.py index 8a902a5ca..64e6da264 100644 --- a/src/pint/models/wave.py +++ b/src/pint/models/wave.py @@ -15,9 +15,8 @@ class Wave(PhaseComponent): sine/cosine components. For consistency with the implementation in tempo2, this signal is treated - as a time series, but trivially converted into phase by multiplication by - F0, which could makes changes to PEPOCH fragile if there is strong spin - frequency evolution. + as a time series and trivially converted into phase by multiplication by + F0. Parameters supported: @@ -42,7 +41,7 @@ def __init__(self): floatParameter( name="WAVE_OM", description="Base frequency of wave solution", - units="1/d", + units="rad/d", convert_tcb2tdb=False, ) ) From e5ce925376eeef08e3054047724bedf18321ae70 Mon Sep 17 00:00:00 2001 From: Matthew Kerr Date: Thu, 14 Nov 2024 10:46:08 -0500 Subject: [PATCH 52/66] Add explicit test for WAVE calculation. --- tests/test_model_wave.py | 85 ++++++++++++++++++++++++++++++++-------- 1 file changed, 69 insertions(+), 16 deletions(-) diff --git a/tests/test_model_wave.py b/tests/test_model_wave.py index 1e57d640f..ab1707088 100644 --- a/tests/test_model_wave.py +++ b/tests/test_model_wave.py @@ -1,28 +1,81 @@ +from io import StringIO import os import pytest import astropy.units as u +import numpy as np -import pint.fitter -import pint.models +from pint.models import get_model +from pint import toa import pint.residuals -import pint.toa from pinttestdata import datadir -# Not included in the test here, but as a sanity check I used this same -# ephemeris to phase up Fermi data, and it looks good. +par_nowave = """ + PSRJ J0835-4510 + RAJ 08:35:20.61149 + DECJ -45:10:34.8751 + F0 11.18965156782 + PEPOCH 55305 + DM 67.99 + UNITS TDB +""" -parfile = os.path.join(datadir, "vela_wave.par") -timfile = os.path.join(datadir, "vela_wave.tim") +wave_terms = """ + WAVEEPOCH 55305 + WAVE_OM 0.0015182579855022 + WAVE1 -0.21573979911255 -0.049063841960712 + WAVE2 0.62795320246729 -0.11984954655989 + WAVE3 0.099618608456845 0.28530756908788 + WAVE4 -0.21537340649058 0.18849486610628 + WAVE5 0.021980474493165 -0.23566696662127 +""" -class TestWave: - @classmethod - def setup_class(cls): - cls.m = pint.models.get_model(parfile) - cls.t = pint.toa.get_TOAs(timfile, ephem="DE405", include_bipm=False) +def test_wave_ephem(): + parfile = os.path.join(datadir, "vela_wave.par") + timfile = os.path.join(datadir, "vela_wave.tim") + m = get_model(parfile) + t = toa.get_TOAs(timfile, ephem="DE405", include_bipm=False) + rs = pint.residuals.Residuals(t, m).time_resids + assert rs.std() < 350.0 * u.us - def test_vela_rms_is_small_enough(self): - rs = pint.residuals.Residuals(self.t, self.m).time_resids - rms = rs.to(u.us).std() - assert rms < 350.0 * u.us + +def test_wave_construction(): + m = get_model(StringIO(par_nowave + wave_terms)) + assert np.allclose(m.WAVE_OM.quantity, 0.0015182579855022 * u.rad / u.day) + assert np.allclose(m.WAVE1.quantity[0], -0.21573979911255 * u.s) + assert np.allclose(m.WAVE2.quantity[1], -0.1198495465598 * u.s) + + +def test_wave_computation(): + m0 = get_model(StringIO(par_nowave)) + m1 = get_model(StringIO(par_nowave + wave_terms)) + # make some barycentric TOAs + tdbs = np.linspace(54500, 60000, 10) + ts = toa.TOAs( + toalist=[ + toa.TOA(t, obs="@", freq=np.inf, error=1 * u.ms, scale="tdb") for t in tdbs + ] + ) + ts.compute_TDBs(ephem="DE421") + ts.compute_posvels(ephem="DE421") + ph0 = m0.phase(ts) + ph1 = m1.phase(ts) + dphi = (ph1.int - ph0.int) + (ph1.frac - ph0.frac) + test_phase = np.zeros(len(tdbs)) + WAVEEPOCH = 55305 + WAVE_OM = 0.0015182579855022 + WAVE = [ + [-0.21573979911255, -0.049063841960712], + [0.62795320246729, -0.11984954655989], + [0.099618608456845, 0.28530756908788], + [-0.21537340649058, 0.18849486610628], + [0.021980474493165, -0.23566696662127], + ] + ph = (tdbs - WAVEEPOCH) * WAVE_OM + for i in range(5): + test_phase += WAVE[i][0] * np.sin((i + 1) * ph) + WAVE[i][1] * np.cos( + (i + 1) * ph + ) + test_phase *= m0.F0.quantity.to(u.Hz).value + assert np.allclose(test_phase, dphi) From 4b2c184a3c0e44eaf05dc7003f3262ae3e27e2b3 Mon Sep 17 00:00:00 2001 From: Matthew Kerr Date: Thu, 14 Nov 2024 10:46:27 -0500 Subject: [PATCH 53/66] Remove extraneous JUMPs from test .par file. --- tests/datafile/vela_wave.par | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/tests/datafile/vela_wave.par b/tests/datafile/vela_wave.par index e8aba5a4c..889361b01 100644 --- a/tests/datafile/vela_wave.par +++ b/tests/datafile/vela_wave.par @@ -28,45 +28,18 @@ TZRMJD 55896.55312516020475 TZRFRQ 1370.2919919999999365 TZRSITE pks TRES 310.453 -EPHVER 2 CLK TT(TAI) MODE 1 UNITS TDB TIMEEPH FB90 DILATEFREQ N PLANET_SHAPIRO N -T2CMETHOD TEMPO NE_SW 9.961 CORRECT_TROPOSPHERE N EPHEM DE405 NITS 1 NTOA 339 CHI2R 328088.1294 298 -JUMP -B 20CM 0 0 -JUMP -B 40CM 0 0 -JUMP -B 50CM 0 0 -JUMP -dfb3_J0437_55319_56160 1 2.2e-07 0 -JUMP -dfb3_J0437_56160_60000 1 4.5e-07 0 -JUMP -pdfb1_128_ch 1 -3.5547e-06 0 -JUMP -pdfb1_2048_ch 1 -4.68829e-05 0 -JUMP -pdfb1_512_ch 1 -1.22813e-05 0 -JUMP -pdfb1_post_2006 1 -1.3e-07 0 -JUMP -pdfb1_pre_2006 1 -1.13e-06 0 -JUMP -pdfb2_1024_MHz 1 -5.435e-06 0 -JUMP -pdfb2_256MHz_1024_ch 1 -1.1395e-05 0 -JUMP -pdfb2_256MHz_512ch 1 -4.75e-06 0 -JUMP -pdfb3_1024_256_512 1 2.45e-06 0 -JUMP -pdfb3_1024_MHz 1 1.03e-06 0 -JUMP -pdfb3_256MHz_1024ch 1 4.295e-06 0 -JUMP -pdfb3_64MHz_1024ch 1 1.494e-05 0 -JUMP -pdfb3_64MHz_512ch 1 8.9e-06 0 -JUMP -pdfb4.*_1024_[1,2]... 1 2.23e-06 0 -JUMP -pdfb4_256MHz_1024ch 1 5.05e-06 0 -JUMP -pdfb4_55319_56055_cals 1 9.27e-07 0 -JUMP -pdfb4_56110_56160_cals 1 5.41e-07 0 -JUMP -pdfb4_56160_60000_cals 1 4.25e-07 0 -JUMP -wbb256_512_128_3p_b 1 -6.2e-07 0 -JUMP -wbb_c_config 1 3.8e-07 0 WAVEEPOCH 55305 WAVE_OM 0.0015182579855022 0 WAVE1 -0.21573979911255 -0.049063841960712 From 87939cd468d00cc8760080d6742e19d07f8270ce Mon Sep 17 00:00:00 2001 From: Matthew Kerr Date: Thu, 14 Nov 2024 12:44:48 -0500 Subject: [PATCH 54/66] Fix WAVE<-->WAVEX conversion. --- src/pint/utils.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pint/utils.py b/src/pint/utils.py index da23092fc..4f6523455 100644 --- a/src/pint/utils.py +++ b/src/pint/utils.py @@ -1746,10 +1746,10 @@ def _translate_wave_freqs(om: Union[float, u.Quantity], k: int) -> u.Quantity: WXFREQ_ quantity in units 1/d that can be used in WaveX model """ if isinstance(om, u.quantity.Quantity): - om.to(u.d**-1) + om.to(u.rad*u.d**-1) else: - om *= u.d**-1 - return (om * (k + 1)) / (2.0 * np.pi) + om *= u.rad*u.d**-1 + return (om * (k + 1)) / (2.0 * np.pi * u.rad) def _translate_wavex_freqs(wxfreq: Union[float, u.Quantity], k: int) -> u.Quantity: @@ -1774,8 +1774,8 @@ def _translate_wavex_freqs(wxfreq: Union[float, u.Quantity], k: int) -> u.Quanti else: wxfreq *= u.d**-1 if len(wxfreq) == 1: - return (2.0 * np.pi * wxfreq) / (k + 1.0) - wave_om = [((2.0 * np.pi * wxfreq[i]) / (k[i] + 1.0)) for i in range(len(wxfreq))] + return (2.0 * np.pi * u.rad * wxfreq) / (k + 1.0) + wave_om = [((2.0 * np.pi * u.rad * wxfreq[i]) / (k[i] + 1.0)) for i in range(len(wxfreq))] return ( sum(wave_om) / len(wave_om) if np.allclose(wave_om, wave_om[0], atol=1e-3) From 53ae031e946af0e75c27ecdbbec8f0411487f0df Mon Sep 17 00:00:00 2001 From: Matthew Kerr Date: Thu, 14 Nov 2024 12:45:51 -0500 Subject: [PATCH 55/66] Re-black with v24. --- src/pint/derived_quantities.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/pint/derived_quantities.py b/src/pint/derived_quantities.py index 6cae3c39a..8f3373cf6 100644 --- a/src/pint/derived_quantities.py +++ b/src/pint/derived_quantities.py @@ -130,8 +130,7 @@ def pferrs( return [1.0 / porf, porferr / porf**2.0] forperr = porferr / porf**2.0 fdorpderr = np.sqrt( - (4.0 * pdorfd**2.0 * porferr**2.0) / porf**6.0 - + pdorfderr**2.0 / porf**4.0 + (4.0 * pdorfd**2.0 * porferr**2.0) / porf**6.0 + pdorfderr**2.0 / porf**4.0 ) [forp, fdorpd] = p_to_f(porf, pdorfd) return (forp, forperr, fdorpd, fdorpderr) @@ -552,17 +551,12 @@ def companion_mass( # delta1 is always <0 # delta1 = 2 * b ** 3 - 9 * a * b * c + 27 * a ** 2 * d delta1 = ( - -2 * massfunct**3 - - 18 * a * mp * massfunct**2 - - 27 * a**2 * massfunct * mp**2 + -2 * massfunct**3 - 18 * a * mp * massfunct**2 - 27 * a**2 * massfunct * mp**2 ) # Q**2 is always > 0, so this is never a problem # in terms of complex numbers # Q = np.sqrt(delta1**2 - 4*delta0**3) - Q = np.sqrt( - 108 * a**3 * mp**3 * massfunct**3 - + 729 * a**4 * mp**4 * massfunct**2 - ) + Q = np.sqrt(108 * a**3 * mp**3 * massfunct**3 + 729 * a**4 * mp**4 * massfunct**2) # this could be + or - Q # pick the - branch since delta1 is <0 so that delta1 - Q is never near 0 Ccubed = 0.5 * (delta1 + Q) From 4219a9b6294b8af91b4c4e838bc4440df287e598 Mon Sep 17 00:00:00 2001 From: Matthew Kerr Date: Thu, 14 Nov 2024 12:54:09 -0500 Subject: [PATCH 56/66] Simply astropy units syntax. --- src/pint/utils.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/pint/utils.py b/src/pint/utils.py index 4f6523455..27af72c85 100644 --- a/src/pint/utils.py +++ b/src/pint/utils.py @@ -1745,10 +1745,7 @@ def _translate_wave_freqs(om: Union[float, u.Quantity], k: int) -> u.Quantity: astropy.units.Quantity WXFREQ_ quantity in units 1/d that can be used in WaveX model """ - if isinstance(om, u.quantity.Quantity): - om.to(u.rad*u.d**-1) - else: - om *= u.rad*u.d**-1 + om <<= u.rad/u.d return (om * (k + 1)) / (2.0 * np.pi * u.rad) @@ -1769,10 +1766,7 @@ def _translate_wavex_freqs(wxfreq: Union[float, u.Quantity], k: int) -> u.Quanti astropy.units.Quantity WAVEOM quantity in units 1/d that can be used in Wave model """ - if isinstance(wxfreq, u.quantity.Quantity): - wxfreq.to(u.d**-1) - else: - wxfreq *= u.d**-1 + wxfreq <<= u.d**-1 if len(wxfreq) == 1: return (2.0 * np.pi * u.rad * wxfreq) / (k + 1.0) wave_om = [((2.0 * np.pi * u.rad * wxfreq[i]) / (k[i] + 1.0)) for i in range(len(wxfreq))] From 3ad5f9b39f0e81f5c7e7e67f879bea35b5d82092 Mon Sep 17 00:00:00 2001 From: Matthew Kerr Date: Thu, 14 Nov 2024 13:28:31 -0500 Subject: [PATCH 57/66] Move gauss equivalency to pint __init__ file. --- src/pint/__init__.py | 3 +++ src/pint/derived_quantities.py | 3 +-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pint/__init__.py b/src/pint/__init__.py index 5706dff7e..7906be01f 100644 --- a/src/pint/__init__.py +++ b/src/pint/__init__.py @@ -105,6 +105,9 @@ "hourangle_second": hourangle_second, } +# define a units equivalency for gauss in cgs +gauss_equiv = [u.Gauss, u.Hz * (u.g / u.cm) ** (1 / 2), lambda x: x, lambda x: x] + import astropy.version if astropy.version.major < 4: diff --git a/src/pint/derived_quantities.py b/src/pint/derived_quantities.py index 8f3373cf6..24dcb1934 100644 --- a/src/pint/derived_quantities.py +++ b/src/pint/derived_quantities.py @@ -141,8 +141,7 @@ def _to_gauss(B: u.Quantity) -> u.G: In cgs units, magnetic field is has units (mass/length)^(1/2) / time. """ - eq = [u.Gauss, u.Hz * (u.g / u.cm) ** (1 / 2), lambda x: x, lambda x: x] - return B.to(u.Gauss, equivalencies=[eq]) + return B.to(u.Gauss, equivalencies=[pint.gauss_equiv]) @u.quantity_input(f=u.Hz, fdot=u.Hz / u.s, fo=u.Hz) From ba48280d2a0f20e10cd7e6bb13f8f6c35f49401a Mon Sep 17 00:00:00 2001 From: Matthew Kerr Date: Thu, 14 Nov 2024 15:10:11 -0500 Subject: [PATCH 58/66] black is going to make me run screaming into the night --- src/pint/utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pint/utils.py b/src/pint/utils.py index 27af72c85..59f0d3076 100644 --- a/src/pint/utils.py +++ b/src/pint/utils.py @@ -1745,7 +1745,7 @@ def _translate_wave_freqs(om: Union[float, u.Quantity], k: int) -> u.Quantity: astropy.units.Quantity WXFREQ_ quantity in units 1/d that can be used in WaveX model """ - om <<= u.rad/u.d + om <<= u.rad / u.d return (om * (k + 1)) / (2.0 * np.pi * u.rad) @@ -1769,7 +1769,9 @@ def _translate_wavex_freqs(wxfreq: Union[float, u.Quantity], k: int) -> u.Quanti wxfreq <<= u.d**-1 if len(wxfreq) == 1: return (2.0 * np.pi * u.rad * wxfreq) / (k + 1.0) - wave_om = [((2.0 * np.pi * u.rad * wxfreq[i]) / (k[i] + 1.0)) for i in range(len(wxfreq))] + wave_om = [ + ((2.0 * np.pi * u.rad * wxfreq[i]) / (k[i] + 1.0)) for i in range(len(wxfreq)) + ] return ( sum(wave_om) / len(wave_om) if np.allclose(wave_om, wave_om[0], atol=1e-3) From ffc5a2d1cf2a5c1650fa4f0775508d307ca7685c Mon Sep 17 00:00:00 2001 From: Matthew Kerr Date: Fri, 15 Nov 2024 07:57:34 -0500 Subject: [PATCH 59/66] Add changelog entry. --- CHANGELOG-unreleased.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG-unreleased.md b/CHANGELOG-unreleased.md index 2899b99f8..8f6c7f411 100644 --- a/CHANGELOG-unreleased.md +++ b/CHANGELOG-unreleased.md @@ -11,4 +11,5 @@ the released changes. ### Changed ### Added ### Fixed +- Changed WAVE\_OM units from 1/d to rad/d. ### Removed From ab4a22e923bdf2aadcdc1600a7d93bdeefdae7d5 Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Fri, 15 Nov 2024 16:39:55 -0600 Subject: [PATCH 60/66] return name of added param, helpful when adding maskParameter --- src/pint/models/timing_model.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pint/models/timing_model.py b/src/pint/models/timing_model.py index a0b27b090..68fe886bf 100644 --- a/src/pint/models/timing_model.py +++ b/src/pint/models/timing_model.py @@ -3425,6 +3425,7 @@ def add_param(self, param, deriv_func=None, setup=False): if deriv_func is not None: self.register_deriv_funcs(deriv_func, param.name) param._parent = self + return param.name def remove_param(self, param): """Remove a parameter from the Component. From 7c2bf806bff01136fb7e7df298539932b1ad0325 Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Fri, 15 Nov 2024 16:40:16 -0600 Subject: [PATCH 61/66] fix logic when selection mask is array([0]) --- src/pint/models/noise_model.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pint/models/noise_model.py b/src/pint/models/noise_model.py index b1af8e10f..299787fe5 100644 --- a/src/pint/models/noise_model.py +++ b/src/pint/models/noise_model.py @@ -164,14 +164,14 @@ def scale_toa_sigma(self, toas, warn=True): if equad.quantity is None: continue mask = equad.select_toa_mask(toas) - if np.any(mask): + if len(mask) > 0: sigma_scaled[mask] = np.hypot(sigma_scaled[mask], equad.quantity) elif warn: warnings.warn(f"EQUAD {equad} has no TOAs") for efac_name in self.EFACs: efac = getattr(self, efac_name) mask = efac.select_toa_mask(toas) - if np.any(mask): + if len(mask) > 0: sigma_scaled[mask] *= efac.quantity elif warn: warnings.warn(f"EFAC {efac} has no TOAs") From a17f4aabce38b60502d1c0f350980d884cfa9d9c Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Mon, 18 Nov 2024 12:36:53 -0600 Subject: [PATCH 62/66] changelog --- CHANGELOG-unreleased.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG-unreleased.md b/CHANGELOG-unreleased.md index d15e5e781..8e7b884e3 100644 --- a/CHANGELOG-unreleased.md +++ b/CHANGELOG-unreleased.md @@ -11,6 +11,8 @@ the released changes. ### Changed ### Added - When TCB->TDB conversion info is missing, will print parameter name +- `add_param` returns the name of the parameter (useful for numbered parameters) ### Fixed - When EQUAD is created from TNEQ, has proper TCB->TDB conversion info +- TOA selection masks will work when only TOA is the first one ### Removed From b9d1e7109c40dbcb89c432a6ee90b7fd2adcb74c Mon Sep 17 00:00:00 2001 From: Matteo Bachetti Date: Tue, 19 Nov 2024 13:21:25 +0100 Subject: [PATCH 63/66] Add an nbin option to photonphase Allow photonphase to plot a pulse profile with a custom number of bins, while maintaining the current value as default --- src/pint/scripts/photonphase.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pint/scripts/photonphase.py b/src/pint/scripts/photonphase.py index 7d72eec18..d21679138 100755 --- a/src/pint/scripts/photonphase.py +++ b/src/pint/scripts/photonphase.py @@ -106,6 +106,9 @@ def main(argv=None): help="Logging level", dest="loglevel", ) + parser.add_argument( + "--nbin", help="Number of phase bins in the phaseogram", default=100, type=int + ) parser.add_argument( "-v", "--verbosity", default=0, action="count", help="Increase output verbosity" ) @@ -254,7 +257,7 @@ def main(argv=None): print("Htest : {0:.2f} ({1:.2f} sigma)".format(h, h2sig(h))) if args.plot: - phaseogram_binned(mjds, phases, bins=100, plotfile=args.plotfile) + phaseogram_binned(mjds, phases, bins=args.nbin, plotfile=args.plotfile) # Compute orbital phases for each photon TOA if args.addorbphase: From cbf1e57f8cb5ef5d96092cc8e14df280ea6dd2e9 Mon Sep 17 00:00:00 2001 From: Abhimanyu Susobhanan Date: Wed, 20 Nov 2024 09:36:09 +0100 Subject: [PATCH 64/66] allow_tcb and allow_T2 are false by default --- src/pint/scripts/compare_parfiles.py | 14 ++++++++++++-- src/pint/scripts/convert_parfile.py | 12 +++++++++++- src/pint/scripts/event_optimize.py | 14 +++++++++++++- src/pint/scripts/event_optimize_MCMCFitter.py | 15 ++++++++++++++- src/pint/scripts/event_optimize_multiple.py | 14 +++++++++++++- src/pint/scripts/fermiphase.py | 14 +++++++++++++- 6 files changed, 76 insertions(+), 7 deletions(-) diff --git a/src/pint/scripts/compare_parfiles.py b/src/pint/scripts/compare_parfiles.py index 87eb005a0..d65785041 100644 --- a/src/pint/scripts/compare_parfiles.py +++ b/src/pint/scripts/compare_parfiles.py @@ -83,14 +83,24 @@ def main(argv=None): parser.add_argument( "-q", "--quiet", default=0, action="count", help="Decrease output verbosity" ) + parser.add_argument( + "--allow_tcb", + action="store_true", + help="Convert TCB par files to TDB automatically", + ) + parser.add_argument( + "--allow_T2", + action="store_true", + help="Guess the underlying binary model when T2 is given", + ) args = parser.parse_args(argv) pint.logging.setup( level=pint.logging.get_level(args.loglevel, args.verbosity, args.quiet) ) - m1 = get_model(args.input1, allow_T2=True, allow_tcb=True) - m2 = get_model(args.input2, allow_T2=True, allow_tcb=True) + m1 = get_model(args.input1, allow_T2=args.allow_T2, allow_tcb=args.allow_tcb) + m2 = get_model(args.input2, allow_T2=args.allow_T2, allow_tcb=args.allow_tcb) print( m1.compare( diff --git a/src/pint/scripts/convert_parfile.py b/src/pint/scripts/convert_parfile.py index 0612a46a8..2975d5acc 100644 --- a/src/pint/scripts/convert_parfile.py +++ b/src/pint/scripts/convert_parfile.py @@ -73,6 +73,16 @@ def main(argv=None): parser.add_argument( "-q", "--quiet", default=0, action="count", help="Decrease output verbosity" ) + parser.add_argument( + "--allow_tcb", + action="store_true", + help="Convert TCB par files to TDB automatically", + ) + parser.add_argument( + "--allow_T2", + action="store_true", + help="Guess the underlying binary model when T2 is given", + ) args = parser.parse_args(argv) pint.logging.setup( @@ -84,7 +94,7 @@ def main(argv=None): log.info(f"Reading '{args.input}'") - model = get_model(args.input, allow_T2=True, allow_tcb=True) + model = get_model(args.input, allow_T2=args.allow_T2, allow_tcb=args.allow_tcb) if hasattr(model, "BINARY") and args.binary is not None: log.info(f"Converting from {model.BINARY.value} to {args.binary}") diff --git a/src/pint/scripts/event_optimize.py b/src/pint/scripts/event_optimize.py index b91c30a04..6e26ba784 100755 --- a/src/pint/scripts/event_optimize.py +++ b/src/pint/scripts/event_optimize.py @@ -706,6 +706,16 @@ def main(argv=None): action="store_true", dest="linearize_model", ) + parser.add_argument( + "--allow_tcb", + action="store_true", + help="Convert TCB par files to TDB automatically", + ) + parser.add_argument( + "--allow_T2", + action="store_true", + help="Guess the underlying binary model when T2 is given", + ) args = parser.parse_args(argv) pint.logging.setup( @@ -739,7 +749,9 @@ def main(argv=None): ncores = args.ncores # Read in initial model - modelin = pint.models.get_model(parfile, allow_T2=True, allow_tcb=True) + modelin = pint.models.get_model( + parfile, allow_T2=args.allow_T2, allow_tcb=args.allow_tcb + ) # File name setup and clobber file check filepath = args.filepath or os.getcwd() diff --git a/src/pint/scripts/event_optimize_MCMCFitter.py b/src/pint/scripts/event_optimize_MCMCFitter.py index 43bc89858..7357b1028 100755 --- a/src/pint/scripts/event_optimize_MCMCFitter.py +++ b/src/pint/scripts/event_optimize_MCMCFitter.py @@ -128,6 +128,17 @@ def main(argv=None): help="Logging level", dest="loglevel", ) + parser.add_argument( + "--allow_tcb", + action="store_true", + help="Convert TCB par files to TDB automatically", + ) + parser.add_argument( + "--allow_T2", + action="store_true", + help="Guess the underlying binary model when T2 is given", + ) + global nwalkers, nsteps, ftr args = parser.parse_args(argv) @@ -164,7 +175,9 @@ def main(argv=None): wgtexp = args.wgtexp # Read in initial model - modelin = pint.models.get_model(parfile, allow_T2=True, allow_tcb=True) + modelin = pint.models.get_model( + parfile, allow_T2=args.allow_T2, allow_tcb=args.allow_tcb + ) # The custom_timing version below is to manually construct the TimingModel # class, which allows it to be pickled. This is needed for parallelizing diff --git a/src/pint/scripts/event_optimize_multiple.py b/src/pint/scripts/event_optimize_multiple.py index daa40a9e9..0a3dc7336 100755 --- a/src/pint/scripts/event_optimize_multiple.py +++ b/src/pint/scripts/event_optimize_multiple.py @@ -228,6 +228,16 @@ def main(argv=None): help="Logging level", dest="loglevel", ) + parser.add_argument( + "--allow_tcb", + action="store_true", + help="Convert TCB par files to TDB automatically", + ) + parser.add_argument( + "--allow_T2", + action="store_true", + help="Guess the underlying binary model when T2 is given", + ) global nwalkers, nsteps, ftr @@ -261,7 +271,9 @@ def main(argv=None): wgtexp = args.wgtexp # Read in initial model - modelin = pint.models.get_model(parfile, allow_T2=True, allow_tcb=True) + modelin = pint.models.get_model( + parfile, allow_T2=args.allow_T2, allow_tcb=args.allow_tcb + ) # Set the target coords for automatic weighting if necessary if "ELONG" in modelin.params: diff --git a/src/pint/scripts/fermiphase.py b/src/pint/scripts/fermiphase.py index 6785bc156..c5e43bb93 100755 --- a/src/pint/scripts/fermiphase.py +++ b/src/pint/scripts/fermiphase.py @@ -77,6 +77,16 @@ def main(argv=None): parser.add_argument( "-q", "--quiet", default=0, action="count", help="Decrease output verbosity" ) + parser.add_argument( + "--allow_tcb", + action="store_true", + help="Convert TCB par files to TDB automatically", + ) + parser.add_argument( + "--allow_T2", + action="store_true", + help="Guess the underlying binary model when T2 is given", + ) args = parser.parse_args(argv) pint.logging.setup( @@ -88,7 +98,9 @@ def main(argv=None): args.addphase = True # Read in model - modelin = pint.models.get_model(args.parfile, allow_T2=True, allow_tcb=True) + modelin = pint.models.get_model( + args.parfile, allow_T2=args.allow_T2, allow_tcb=args.allow_tcb + ) if "ELONG" in modelin.params: tc = SkyCoord( From 706f041098be6b14f862d7c0d569de4ffb7daf2d Mon Sep 17 00:00:00 2001 From: Abhimanyu Susobhanan Date: Wed, 20 Nov 2024 09:55:25 +0100 Subject: [PATCH 65/66] no default tcb t2 --- src/pint/scripts/photonphase.py | 14 +++++++++++++- src/pint/scripts/pintbary.py | 14 +++++++++++++- src/pint/scripts/pintempo.py | 14 +++++++++++++- src/pint/scripts/pintpublish.py | 14 +++++++++++++- src/pint/scripts/t2binary2pint.py | 7 ++++++- src/pint/scripts/tcb2tdb.py | 7 ++++++- src/pint/scripts/zima.py | 14 +++++++++++++- 7 files changed, 77 insertions(+), 7 deletions(-) diff --git a/src/pint/scripts/photonphase.py b/src/pint/scripts/photonphase.py index 38505c629..85a80907f 100755 --- a/src/pint/scripts/photonphase.py +++ b/src/pint/scripts/photonphase.py @@ -112,6 +112,16 @@ def main(argv=None): parser.add_argument( "-q", "--quiet", default=0, action="count", help="Decrease output verbosity" ) + parser.add_argument( + "--allow_tcb", + action="store_true", + help="Convert TCB par files to TDB automatically", + ) + parser.add_argument( + "--allow_T2", + action="store_true", + help="Guess the underlying binary model when T2 is given", + ) args = parser.parse_args(argv) pint.logging.setup( @@ -153,7 +163,9 @@ def main(argv=None): "Please barycenter the event file using the official mission tools before processing with PINT" ) # Read in model - modelin = pint.models.get_model(args.parfile, allow_T2=True, allow_tcb=True) + modelin = pint.models.get_model( + args.parfile, allow_T2=args.allow_T2, allow_tcb=args.allow_tcb + ) use_planets = False if "PLANET_SHAPIRO" in modelin.params: diff --git a/src/pint/scripts/pintbary.py b/src/pint/scripts/pintbary.py index c29d42fbb..61cdcd0a0 100755 --- a/src/pint/scripts/pintbary.py +++ b/src/pint/scripts/pintbary.py @@ -74,6 +74,16 @@ def main(argv=None): parser.add_argument( "-q", "--quiet", default=0, action="count", help="Decrease output verbosity" ) + parser.add_argument( + "--allow_tcb", + action="store_true", + help="Convert TCB par files to TDB automatically", + ) + parser.add_argument( + "--allow_T2", + action="store_true", + help="Guess the underlying binary model when T2 is given", + ) args = parser.parse_args(argv) pint.logging.setup( @@ -105,7 +115,9 @@ def main(argv=None): ) if args.parfile is not None: - m = pint.models.get_model(args.parfile, allow_T2=True, allow_tcb=True) + m = pint.models.get_model( + args.parfile, allow_T2=args.allow_T2, allow_tcb=args.allow_tcb + ) else: # Construct model by hand m = pint.models.StandardTimingModel diff --git a/src/pint/scripts/pintempo.py b/src/pint/scripts/pintempo.py index 36e8ca509..ac9099008 100755 --- a/src/pint/scripts/pintempo.py +++ b/src/pint/scripts/pintempo.py @@ -62,6 +62,16 @@ def main(argv=None): parser.add_argument( "-q", "--quiet", default=0, action="count", help="Decrease output verbosity" ) + parser.add_argument( + "--allow_tcb", + action="store_true", + help="Convert TCB par files to TDB automatically", + ) + parser.add_argument( + "--allow_T2", + action="store_true", + help="Guess the underlying binary model when T2 is given", + ) args = parser.parse_args(argv) pint.logging.setup( @@ -69,7 +79,9 @@ def main(argv=None): ) log.info("Reading model from {0}".format(args.parfile)) - m = pint.models.get_model(args.parfile, allow_T2=True, allow_tcb=True) + m = pint.models.get_model( + args.parfile, allow_T2=args.allow_T2, allow_tcb=args.allow_tcb + ) log.warning(m.params) diff --git a/src/pint/scripts/pintpublish.py b/src/pint/scripts/pintpublish.py index 36cc5786e..1828a05c6 100644 --- a/src/pint/scripts/pintpublish.py +++ b/src/pint/scripts/pintpublish.py @@ -59,10 +59,22 @@ def main(argv=None): action="store_true", default=False, ) + parser.add_argument( + "--allow_tcb", + action="store_true", + help="Convert TCB par files to TDB automatically", + ) + parser.add_argument( + "--allow_T2", + action="store_true", + help="Guess the underlying binary model when T2 is given", + ) args = parser.parse_args(argv) - model, toas = get_model_and_toas(args.parfile, args.timfile, allow_T2=True) + model, toas = get_model_and_toas( + args.parfile, args.timfile, allow_T2=args.allow_T2, allow_tcb=args.allow_tcb + ) output = publish( model, diff --git a/src/pint/scripts/t2binary2pint.py b/src/pint/scripts/t2binary2pint.py index 42d70f89a..bab43eef4 100644 --- a/src/pint/scripts/t2binary2pint.py +++ b/src/pint/scripts/t2binary2pint.py @@ -45,12 +45,17 @@ def main(argv=None): default=True, help="Whether to drop SINI if the model is DDK (True)", ) + parser.add_argument( + "--allow_tcb", + action="store_true", + help="Convert TCB par files to TDB automatically", + ) args = parser.parse_args(argv) mb = ModelBuilder() - model = mb(args.input_par, allow_T2=True, allow_tcb=True) + model = mb(args.input_par, allow_T2=True, allow_tcb=args.allow_tcb) model.write_parfile(args.output_par) print(f"Output written to {args.output_par}") diff --git a/src/pint/scripts/tcb2tdb.py b/src/pint/scripts/tcb2tdb.py index 5b15d56ae..02a485d3c 100644 --- a/src/pint/scripts/tcb2tdb.py +++ b/src/pint/scripts/tcb2tdb.py @@ -30,11 +30,16 @@ def main(argv=None): ) parser.add_argument("input_par", help="Input par file name (TCB)") parser.add_argument("output_par", help="Output par file name (TDB)") + parser.add_argument( + "--allow_T2", + action="store_true", + help="Guess the underlying binary model when T2 is given", + ) args = parser.parse_args(argv) mb = ModelBuilder() - model = mb(args.input_par, allow_tcb=True, allow_T2=True) + model = mb(args.input_par, allow_tcb=True, allow_T2=args.allow_T2) model.write_parfile(args.output_par) log.info(f"Output written to {args.output_par}.") diff --git a/src/pint/scripts/zima.py b/src/pint/scripts/zima.py index 3485c6c5b..29b3e354c 100755 --- a/src/pint/scripts/zima.py +++ b/src/pint/scripts/zima.py @@ -115,6 +115,16 @@ def main(argv=None): parser.add_argument( "-q", "--quiet", default=0, action="count", help="Decrease output verbosity" ) + parser.add_argument( + "--allow_tcb", + action="store_true", + help="Convert TCB par files to TDB automatically", + ) + parser.add_argument( + "--allow_T2", + action="store_true", + help="Guess the underlying binary model when T2 is given", + ) args = parser.parse_args(argv) pint.logging.setup( @@ -122,7 +132,9 @@ def main(argv=None): ) log.info("Reading model from {0}".format(args.parfile)) - m = pint.models.get_model(args.parfile, allow_T2=True, allow_tcb=True) + m = pint.models.get_model( + args.parfile, allow_T2=args.allow_T2, allow_tcb=args.allow_tcb + ) out_format = args.format error = args.error * u.microsecond From f608d8b6118c6f8f45dc8f78f9ebd904934b2e14 Mon Sep 17 00:00:00 2001 From: Matteo Bachetti Date: Thu, 21 Nov 2024 19:42:00 +0100 Subject: [PATCH 66/66] Add changelog --- CHANGELOG-unreleased.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG-unreleased.md b/CHANGELOG-unreleased.md index fc3962080..03eabf590 100644 --- a/CHANGELOG-unreleased.md +++ b/CHANGELOG-unreleased.md @@ -11,6 +11,7 @@ the released changes. ### Changed - Updated the `plot_chains` function in `event_optimize` so that the subplots are a fixed size to prevent the subplots from being condensed in the case of many fit parameters. ### Added +- Added an option `nbin` to `photonphase` to decide how many phase bins to use for the phaseogram - Added an option `linearize_model` to speed up the photon phases calculation within `event_optimize` through the designmatrix. - Added AIC and BIC calculation to be written in the post fit parfile from `event_optimize` - When TCB->TDB conversion info is missing, will print parameter name