Skip to content

Commit

Permalink
Merge branch 'master' into fdjumplog-y
Browse files Browse the repository at this point in the history
  • Loading branch information
dlakaplan authored Aug 9, 2024
2 parents 5f9a09c + 3dd6f6c commit 25852ea
Show file tree
Hide file tree
Showing 46 changed files with 163 additions and 136 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG-unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ the released changes.
- Moved the events -> TOAs and photon weights code into the function `load_events_weights` within `event_optimize`.
- Updated the `maxMJD` argument in `event_optimize` to default to the current mjd
- Changed default value of `FDJUMPLOG` to `Y`
- Bumped `black` version to 24.x
### Added
- Type hints in `pint.derived_quantities`
- Type hints in `pint.derived_quantities` and `pint.residuals`
- Doing `model.par = something` will try to assign to `par.quantity` or `par.value` but will give warning
- `PLChromNoise` component to model chromatic red noise with a power law spectrum
### Fixed
Expand Down
12 changes: 6 additions & 6 deletions src/pint/binaryconvert.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,11 @@ def _from_ELL1(model):
(om.s * u.rad).to(u.deg) if om.s > 0 else None,
t02.s * u.d if t02.s > 0 else None,
edot.s * u.Hz if (edot is not None and edot.s > 0) else None,
(omdot.s * u.rad / u.s).to(u.deg / u.yr)
if (omdot is not None and omdot.s > 0)
else None,
(
(omdot.s * u.rad / u.s).to(u.deg / u.yr)
if (omdot is not None and omdot.s > 0)
else None
),
)


Expand Down Expand Up @@ -476,9 +478,7 @@ def _DDGR_to_PK(model):
)
if model.XOMDOT.quantity is not None:
omegadot += model.XOMDOT.as_ufloat(u.rad / u.s)
fe = (1 + (73.0 / 24) * ecc**2 + (37.0 / 96) * ecc**4) / (1 - ecc**2) ** (
7.0 / 2
)
fe = (1 + (73.0 / 24) * ecc**2 + (37.0 / 96) * ecc**4) / (1 - ecc**2) ** (7.0 / 2)
# units as s/s
pbdot = (
(-192 * np.pi / 5)
Expand Down
12 changes: 3 additions & 9 deletions src/pint/derived_quantities.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -534,17 +533,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)
Expand Down
1 change: 1 addition & 0 deletions src/pint/eventstats.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
author: M. Kerr <[email protected]>
"""

import numpy as np
from numpy import exp, arange, log
from scipy.special import erfc, gamma
Expand Down
4 changes: 1 addition & 3 deletions src/pint/fermi_toas.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ def calc_lat_weights(energies, angseps, logeref=4.1, logesig=0.5):
logE = np.log10(energies)

sigma = (
np.sqrt(
(psfpar0**2 * np.power(100.0 / energies, 2.0 * psfpar1) + psfpar2**2)
)
np.sqrt((psfpar0**2 * np.power(100.0 / energies, 2.0 * psfpar1) + psfpar2**2))
/ scalepsf
)

Expand Down
1 change: 1 addition & 0 deletions src/pint/gridutils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tools for building chi-squared grids."""

import concurrent.futures
import copy
import multiprocessing
Expand Down
1 change: 1 addition & 0 deletions src/pint/models/priors.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
such as total proper motion, 2-d sky location, etc.
"""

import numpy as np
from scipy.stats import rv_continuous, uniform

Expand Down
5 changes: 2 additions & 3 deletions src/pint/models/stand_alone_psr_binaries/DDGR_model.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""The DDGR model - Damour and Deruelle with GR assumed"""

import astropy.constants as c
import astropy.units as u
import numpy as np
Expand Down Expand Up @@ -504,9 +505,7 @@ def d_PBDOT_d_par(self, par):
# other derivatives
def d_E_d_MTOT(self):
"""Eccentric anomaly has MTOT dependence through PBDOT and Kepler's equation"""
d_M_d_MTOT = (
-2 * np.pi * self.tt0**2 / (2 * self.PB**2) * self.d_PBDOT_d_MTOT()
)
d_M_d_MTOT = -2 * np.pi * self.tt0**2 / (2 * self.PB**2) * self.d_PBDOT_d_MTOT()
return d_M_d_MTOT / (1.0 - np.cos(self.E()) * self.ecc())

def d_nu_d_MTOT(self):
Expand Down
6 changes: 2 additions & 4 deletions src/pint/models/stand_alone_psr_binaries/DDH_model.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""The DDS model - Damour and Deruelle with alternate Shapiro delay parametrization."""

import astropy.constants as c
import astropy.units as u
import numpy as np
Expand Down Expand Up @@ -144,10 +145,7 @@ def d_delayS_d_par(self, par):
-2
* TM2
/ logNum
* (
e * sE
- self.SINI * (np.sqrt(1 - e**2) * cE * cOmega - sE * sOmega)
)
* (e * sE - self.SINI * (np.sqrt(1 - e**2) * cE * cOmega - sE * sOmega))
)
domega_dpar = self.prtl_der("omega", par)
dsDelay_domega = (
Expand Down
4 changes: 1 addition & 3 deletions src/pint/models/stand_alone_psr_binaries/DDK_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,9 +518,7 @@ def d_delta_omega_parallax_d_T0(self):
PX_kpc = self.PX.to(u.kpc, equivalencies=u.parallax())
kom_projection = self.delta_I0() * self.cos_KOM + self.delta_J0() * self.sin_KOM
d_kin_d_T0 = self.d_kin_d_par("T0")
d_delta_omega_d_T0 = (
cos_kin / sin_kin**2 / PX_kpc * d_kin_d_T0 * kom_projection
)
d_delta_omega_d_T0 = cos_kin / sin_kin**2 / PX_kpc * d_kin_d_T0 * kom_projection
return d_delta_omega_d_T0.to(
self.OM.unit / self.T0.unit, equivalencies=u.dimensionless_angles()
)
Expand Down
1 change: 1 addition & 0 deletions src/pint/models/stand_alone_psr_binaries/DDS_model.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""The DDS model - Damour and Deruelle with alternate Shapiro delay parametrization."""

import astropy.constants as c
import astropy.units as u
import numpy as np
Expand Down
6 changes: 2 additions & 4 deletions src/pint/models/stand_alone_psr_binaries/DD_model.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Damour and Deruelle binary model."""

import astropy.constants as c
import astropy.units as u
import numpy as np
Expand Down Expand Up @@ -756,10 +757,7 @@ def d_delayS_d_par(self, par):
-2
* TM2
/ logNum
* (
e * sE
- self.SINI * (np.sqrt(1 - e**2) * cE * cOmega - sE * sOmega)
)
* (e * sE - self.SINI * (np.sqrt(1 - e**2) * cE * cOmega - sE * sOmega))
)
domega_dpar = self.prtl_der("omega", par)
dsDelay_domega = (
Expand Down
1 change: 1 addition & 0 deletions src/pint/models/stand_alone_psr_binaries/ELL1_model.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""The ELL1 model for approximately handling near-circular orbits."""

import astropy.constants as c
import astropy.units as u
import numpy as np
Expand Down
1 change: 1 addition & 0 deletions src/pint/models/stand_alone_psr_binaries/ELL1k_model.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""The ELL1k model for approximately handling near-circular orbits."""

import astropy.constants as c
import astropy.units as u
import numpy as np
Expand Down
1 change: 1 addition & 0 deletions src/pint/models/troposphere_delay.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Delay due to Earth's troposphere"""

import astropy.constants as const
import astropy.units as u
import numpy as np
Expand Down
1 change: 1 addition & 0 deletions src/pint/observatory/global_clock_corrections.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
to clear out old files you will want to do
``astropy.utils.data.clear_download_cache()``.
"""

import collections
import time
from pathlib import Path
Expand Down
7 changes: 2 additions & 5 deletions src/pint/orbital/kepler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
All times are in days, distances in light-seconds, and masses in solar masses.
"""

import collections

import numpy as np
Expand Down Expand Up @@ -246,11 +247,7 @@ def kepler_2d(params, t):

r = a * (1 - e**2) / (1 + e * np.cos(true_anomaly))
r_prime = (
a
* e
* (1 - e**2)
* np.sin(true_anomaly)
/ (1 + e * np.cos(true_anomaly)) ** 2
a * e * (1 - e**2) * np.sin(true_anomaly) / (1 + e * np.cos(true_anomaly)) ** 2
)
r_dot = r_prime * true_anomaly_dot
d_a = np.array([1, 0, 0, 0, 0, 0])
Expand Down
1 change: 1 addition & 0 deletions src/pint/output/publish.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Generate LaTeX summary of a timing model and TOAs."""

from pint.models import (
TimingModel,
DispersionDMX,
Expand Down
10 changes: 4 additions & 6 deletions src/pint/pint_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -861,9 +861,7 @@ def __call__(self, data, model):
"""
func = getattr(model, self.cov_func_name)
M = func(data)
label = [
{self.covariance_quantity: (0, M.shape[0], self.quantity_unit**2)}
] * 2
label = [{self.covariance_quantity: (0, M.shape[0], self.quantity_unit**2)}] * 2
return CovarianceMatrix(M, label)


Expand Down Expand Up @@ -907,9 +905,9 @@ def combine_covariance_matrix(covariance_matrices, crossterm={}, crossterm_paddi
for ii, lb1 in enumerate(new_label):
for jj, lb2 in enumerate(new_label):
if ii == jj:
new_cm[
lb1[1][0] : lb1[1][1], lb2[1][0] : lb2[1][1]
] = covariance_matrices[ii].matrix
new_cm[lb1[1][0] : lb1[1][1], lb2[1][0] : lb2[1][1]] = (
covariance_matrices[ii].matrix
)
else:
if crossterm != {}:
cross_m = crossterm.get((lb1, lb2), None)
Expand Down
7 changes: 4 additions & 3 deletions src/pint/pintk/colormodes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
""" Color modes for graphed pintk TOAs. """

import numpy as np
import matplotlib
import matplotlib.colors
Expand Down Expand Up @@ -297,9 +298,9 @@ def get_obs_mapping(self):
obs_name = "MeerKAT"
else:
obs_name = obs.upper()
obs_text[
obs
] = f" {obs_colors[obs].replace('xkcd:','').capitalize()} = {obs_name}"
obs_text[obs] = (
f" {obs_colors[obs].replace('xkcd:','').capitalize()} = {obs_name}"
)

def displayInfo(self):
outstr = '"Observatory" mode selected\n'
Expand Down
Loading

0 comments on commit 25852ea

Please sign in to comment.