Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setUpClass(cls):
os.chdir(datadir)
cls.parfileB1855 = "B1855+09_NANOGrav_dfg+12_modified_DD.par"
cls.timB1855 = "B1855+09_NANOGrav_dfg+12.tim"
cls.toasB1855 = toa.get_TOAs(
cls.timB1855, ephem="DE405", planets=False, include_bipm=False
)
cls.modelB1855 = mb.get_model(cls.parfileB1855)
# libstempo result
cls.ltres, cls.ltbindelay = np.genfromtxt(
cls.parfileB1855 + ".tempo_test", unpack=True
)
#!/usr/bin/env python
import pint.toa
import pint.models
import pint.fitter
import numpy as np
import pint.residuals
import pint.models.model_builder as mb
import astropy.units as u
import os, sys
from pinttestdata import testdir, datadir
os.chdir(datadir)
# This par file has a very simple model in it
m = mb.get_model('slug.par')
# This .tim file has TOAs at the barycenter, and at infinite frequency
t = pint.toa.get_TOAs('slug.tim')
rs = pint.residuals.Residuals(t, m).time_resids
# Residuals should be less than 2.0 ms
assert rs.std() < 2.0*u.ms
def setUpClass(cls):
os.chdir(datadir)
cls.parfileB1855 = "B1855+09_NANOGrav_dfg+12_TAI_FB90.par"
cls.timB1855 = "B1855+09_NANOGrav_dfg+12.tim"
try:
cls.toasB1855 = toa.get_TOAs(
cls.timB1855, ephem="DE405", planets=False, include_bipm=False
)
except IOError:
pytest.skip("Unable to fetch ephemeris")
cls.modelB1855 = mb.get_model(cls.parfileB1855)
logging.debug("%s" % cls.modelB1855.components)
logging.debug("%s" % cls.modelB1855.params)
# tempo result
cls.ltres = np.genfromtxt(
cls.parfileB1855 + ".tempo2_test", skip_header=1, unpack=True
)
def setUpClass(self):
os.chdir(datadir)
self.parfileB1855 = 'B1855+09_polycos.par'
self.timB1855 = 'B1855_polyco.tim'
self.toasB1855 = toa.get_TOAs(self.timB1855, ephem="DE405",
planets=False, include_bipm=False)
self.modelB1855 = mb.get_model(self.parfileB1855)
# Read tempo style polycos.
self.plc = Polycos()
self.plc.read_polyco_file('B1855_polyco.dat', 'tempo')
def TestD_phase_d_toa(self):
def setUpClass(self):
# This uses ELONG and ELAT
self.m1 = mb.get_model('B1855+09_NANOGrav_9yv1.gls.par')
# This uses RA and DEC
self.m2 = mb.get_model('B1855+09_NANOGrav_dfg+12_TAI_FB90.par')
self.t = 5000 * np.random.randn(100) + 49453.0
def setUpClass(cls):
os.chdir(datadir)
cls.parf = "B1855+09_NANOGrav_dfg+12_TAI.par"
cls.timf = "B1855+09_NANOGrav_dfg+12.tim"
cls.JUMPm = mb.get_model(cls.parf)
cls.toas = toa.get_TOAs(
cls.timf, ephem="DE405", planets=False, include_bipm=False
)
# libstempo calculation
cls.ltres = np.genfromtxt(
cls.parf + ".tempo_test", unpack=True, names=True, dtype=np.longdouble
)
def setUpClass(cls):
os.chdir(datadir)
cls.m = get_model("B1855+09_NANOGrav_dfg+12_modified.par")
cls.mp = get_model("prefixtest.par")
def setUpClass(cls):
os.chdir(datadir)
cls.parfileB1855 = "B1855+09_NANOGrav_9yv1.gls.par"
cls.timB1855 = "B1855+09_NANOGrav_9yv1.tim"
cls.toasB1855 = toa.get_TOAs(
cls.timB1855, ephem="DE421", planets=False, include_bipm=False
)
cls.modelB1855 = mb.get_model(cls.parfileB1855)
# tempo result
cls.ltres = np.genfromtxt(
cls.parfileB1855 + ".tempo2_test", skip_header=1, unpack=True
)
def setUpClass(cls):
os.chdir(datadir)
cls.par = "B1855+09_NANOGrav_9yv1.gls.par"
cls.tim = "B1855+09_NANOGrav_9yv1.tim"
cls.m = mb.get_model(cls.par)
cls.t = toa.get_TOAs(cls.tim, ephem="DE436")
cls.f = GLSFitter(cls.t, cls.m)
# get tempo2 parameter dict
with open("B1855+09_tempo2_gls_pars.json", "r") as fp:
cls.t2d = json.load(fp)
log.error(
"This example requires tempo_utils, download from: https://github.com/demorest/tempo_utils and 'pip install .'"
)
raise
# Using Nanograv data B1855
datadir = "../../tests/datafile"
parfile = os.path.join(datadir, "B1855+09_NANOGrav_dfg+12_TAI_FB90.par")
timfile = os.path.join(datadir, "B1855+09_NANOGrav_dfg+12.tim")
# libstempo calculation
print("tempo2 calculation")
tempo2_vals = tempo2_utils.general2(parfile, timfile, ["pre"])
# Build PINT model
print("PINT calculation")
mdd = mb.get_model(parfile)
# Get toas to pint
toas = toa.get_TOAs(timfile, planets=False, ephem="DE405", include_bipm=False)
# Get residuals
t2_resids = tempo2_vals["pre"]
presids_us = resids(toas, mdd).time_resids.to(u.us)
# Plot residuals
plt.errorbar(toas.get_mjds().value, presids_us.value, toas.get_errors().value, fmt="x")
print(toas.get_errors().value)
print(toas.get_mjds())
print(presids_us.value)
plt.title("%s Pre-Fit Timing Residuals" % mdd.PSR.value)
plt.xlabel("MJD")
plt.ylabel("Residual (us)")
plt.grid()
plt.show()