This object is the primary object to represent a timing model in PINT. It
is normally constructed with get_model(),
and it contains a variety of Component
objects, each representing a
physical process that either introduces delays in the pulse arrival time or
introduces shifts in the pulse arrival phase. These components have
parameters, described by Parameter objects,
and methods. Both the parameters and the methods are accessible through
this object using attribute access, for example as model.F0 or
model.coords_as_GAL().
Components in a TimingModel objects are accessible through the
model.components property, using their class name to index the
TimingModel, as model.components["Spindown"]. They can be added and
removed with methods on this object, and for many of them additional
parameters in families (DMXEP_1234) can be added.
Parameters in a TimingModel object are listed in the model.params object.
Each Parameter can be set as free or frozen using its .frozen attribute,
and a list of the free parameters is available through the model.free_params
property; this can also be used to set which parameters are free. Several methods
are available to get and set some or all parameters in the forms of dictionaries.
TimingModel objects also support a number of functions for computing
various things like orbital phase, and barycentric versions of TOAs,
as well as the various derivatives and matrices needed to support fitting.
TimingModel objects forward attribute lookups to their components, so
that you can access any method or attribute (in particular Parameters)
of any Component directly on the TimingModel object, for example as
model.F0.
PINT Parameters supported (here, rather than in any Component):
Name / Aliases
Description
Kind
PSR / PSRJ, PSRB
Source name
string
TRACK
Tracking Information
string
EPHEM
Ephemeris to use
string
CLOCK / CLK
Timescale to use
string
UNITS
Units (TDB assumed)
string
START
Start MJD for fitting
d
FINISH
End MJD for fitting
d
RM
Rotation measure
rad / m2
INFO
Tells TEMPO to write some extra information about frontend/backend combinations; -f is recommended
string
TIMEEPH
Time ephemeris to use for TDB conversion; for PINT, always FB90
string
T2CMETHOD
Method for transforming from terrestrial to celestial frame (IAU2000B/TEMPO; PINT only supports ????)
string
BINARY
Pulsar System/Binary model
string
DILATEFREQ
Whether or not TEMPO2 should apply gravitational redshift and time dilation to observing frequency (Y/N; PINT only supports N)
boolean
DMDATA
Was the fit done using per-TOA DM information?
boolean
NTOA
Number of TOAs used in the fitting
integer
CHI2
Chi-squared value obtained during fitting
number
CHI2R
Reduced chi-squared value obtained during fitting
number
TRES
TOA residual after fitting
us
DMRES
DM residual after fitting (wideband only)
pc / cm3
Parameters:
name (str, optional) – The name of the timing model.
components (list of Component, optional) – The model components for timing model.
Notes
PINT models pulsar pulse time of arrival at observer from its emission process and
propagation to observer. Emission generally modeled as pulse ‘Phase’ and propagation.
‘time delay’. In pulsar timing different astrophysics phenomenons are separated to
time model components for handling a specific emission or propagation effect.
Each timing model component generally requires the following parts:
Timing Parameters
Delay/Phase functions which implements the time delay and phase.
Derivatives of delay and phase respect to parameter for fitting toas.
Each timing parameters are stored as TimingModel attribute in the type of
Parameter delay or phase and its derivatives
are implemented as TimingModel Methods.
List of parameters that are fittable, i.e., the parameters
which have a derivative implemented. These derivatives are usually
accessed via the d_delay_d_param and d_phase_d_param methods.
Return orbital phase (in radians) at barycentric MJD times.
Parameters:
barytimes (Time, TOAs, array-like, or float) – MJD barycentric time(s). The times to compute the
orbital phases. Needs to be a barycentric time in TDB.
If a TOAs instance is passed, the barycentering will happen
automatically. If an astropy Time object is passed, it must
be in scale=’tdb’. If an array-like object is passed or
a simple float, the time must be in MJD format.
anom (str, optional) – Type of phase/anomaly. Defaults to “mean”.
Other options are “eccentric” or “true”
radians (bool, optional) – Units to return. Defaults to True.
If False, will return unitless phases in cycles (i.e. 0-1).
Raises:
ValueError – If anom.lower() is not “mean”, “ecc*”, or “true”,
or if an astropy Time object is passed with scale!=”tdb”.
Returns:
The specified anomaly in radians (with unit), unless
radians=False, which return unitless cycles (0-1).
Return line-of-sight velocity of the pulsar relative to the system barycenter at barycentric MJD times.
Parameters:
barytimes (Time, TOAs, array-like, or float) – MJD barycentric time(s). The times to compute the
orbital phases. Needs to be a barycentric time in TDB.
If a TOAs instance is passed, the barycentering will happen
automatically. If an astropy Time object is passed, it must
be in scale=’tdb’. If an array-like object is passed or
a simple float, the time must be in MJD format.
Raises:
ValueError – If an astropy Time object is passed with scale!=”tdb”.
Return line-of-sight velocity of the companion relative to the system barycenter at barycentric MJD times.
Parameters:
barytimes (Time, TOAs, array-like, or float) – MJD barycentric time(s). The times to compute the
orbital phases. Needs to be a barycentric time in TDB.
If a TOAs instance is passed, the barycentering will happen
automatically. If an astropy Time object is passed, it must
be in scale=’tdb’. If an array-like object is passed or
a simple float, the time must be in MJD format.
massratio (float) – Ratio of pulsar mass to companion mass
Raises:
ValueError – If an astropy Time object is passed with scale!=”tdb”.
component (component instance) – The component object need to be inspected.
Note
Since a component can be an inheritance from other component We inspect
all the component object bases. “inspect getmro” method returns the
base classes (including ‘object’) in method resolution order. The
third level of inheritance class name is what we want.
Object –> component –> TypeComponent. (i.e. DelayComponent)
This class type is in the third to the last of the getmro returned
result.
ValueError – If any prefix parameters exist outside the sequence that would be returned
(for example if there are DM1 and DM3 but not DM2, or F0 exists but start_index
was given as 1).
Number of basis functions for each noise model component.
Returns a dictionary of correlated-noise components in the noise
model. Each entry contains a tuple (offset, size) where size is the
number of basis functions for the component, and offset is their
starting location in the design matrix and weights vector.
Add JUMP parameters corresponding to tim_jump flags.
When a .tim file contains pairs of JUMP lines, the user’s expectation
is that the TOAs between each pair of flags will be affected by a JUMP, even
if that JUMP does not appear in the .par file. (This is how TEMPO works.)
In PINT, those TOAs have a flag attached, -tim_jump N, where N is a
number that is different for each JUMPed set of TOAs. The goal of this function
is to add JUMP parameters to the model corresponding to these.
Some complexities arise: TOAs may also have -tim_jump flags associated
with them, just as flags, for example if such a .tim file were exported
in PINT-native format and then reloaded. And models may already have JUMPs
associated with some or all tim_jump values.
This function looks at all the tim_jump values and adds JUMP parameters
for any that do not have any. It does not change the TOAs object it is passed.
Delete jump object from PhaseJump and remove its flags from TOA table.
This is a helper function for pintk.
Parameters:
toa_table (list or None) – The TOA table which must be modified. In pintk (pulsar.py), for the
prefit model, this will be all_toas.table[“flags”].
For the postfit model, it will be None (one set of TOA tables for both
models).
jump_num (int) – Specifies the index of the jump to be deleted.
toas (TOAs object) – The TOAs the barycentric corrections are applied on
cutoff_delay (str, optional) – The cutoff delay component name. If it is not provided, it will
search for binary delay and apply all the delay before binary.
Return the derivative of phase with respect to the parameter.
This is the derivative of the phase observed at each TOA with
respect to each parameter. This is closely related to the derivative
of residuals with respect to each parameter, differing only by a
factor of the spin frequency and possibly a minus sign. See
pint.models.timing_model.TimingModel.designmatrix() for a way
of evaluating many derivatives at once.
The calculation is done by combining the analytical derivatives
reported by all the components in the model.
Parameters:
toas (pint.toa.TOAs) – The TOAs at which the derivative should be evaluated.
delay (astropy.units.Quantity or None) – The delay at the TOAs where the derivatives should be evaluated.
This permits certain optimizations in the derivative calculations;
the value should be self.delay(toas).
param (str) – The name of the parameter to differentiate with respect to.
Returns:
The derivative of observed phase with respect to the model parameter.
The design matrix is the matrix with columns of d_phase_d_param/F0
or d_toa_d_param; it is used in fitting and calculating parameter
covariances.
The value of F0 used here is the parameter value in the model.
The order of parameters that are included is that returned by
self.params.
Parameters:
toas (pint.toa.TOAs) – The TOAs at which to compute the design matrix.
acc_delay –
???
incfrozen (bool) – Whether to include frozen parameters in the design matrix
incoffset (bool) – Whether to include the constant offset in the design matrix
This option is ignored if a PhaseOffset component is present.
Returns:
M (array) – The design matrix, with shape (len(toas), len(self.free_params)+1)
names (list of str) – The names of parameters in the corresponding parts of the design matrix
units (astropy.units.Unit) – The units of the corresponding parts of the design matrix
Notes
1. We have negative sign here. Since the residuals are calculated as
(Phase - int(Phase)) in pulsar timing, which is different from the conventional
definition of least square definition (Data - model), we have decided to add
a minus sign here in the design matrix so that the fitter keeps the conventional
sign.
2. Design matrix entries can be computed only for parameters for which the
derivatives are implemented. If a parameter without a derivative is unfrozen
while calling this method, it will raise an informative error, except in the
case of unfrozen noise parameters, which are simply ignored.
nodmx (bool, optional) – If True, don’t print the DMX parameters in
the comparison
convertcoordinates (bool, optional) – Convert coordinates from ICRS<->ECL to make models consistent
threshold_sigma (float, optional) – Pulsar parameters for which diff_sigma > threshold will be printed
with an exclamation point at the end of the line
unc_rat_threshold (float, optional) – Pulsar parameters for which the uncertainty has increased by a
factor of unc_rat_threshold will be printed with an asterisk at
the end of the line
verbosity (string, optional) –
Dictates amount of information returned. Options include “max”,
“med”, and “min”, which have the following results:
”max” - print all lines from both models whether they are fit or not (note that nodmx will override this); DEFAULT
“med” - only print lines for parameters that are fit
“min” - only print lines for fit parameters for which diff_sigma > threshold
“check” - only print significant changes with logging.warning, not as string (note that all other modes will still print this)
usecolor (bool, optional) – Use colors on the output to complement use of “!” and “*”
format (string, optional) – One of “text” or “markdown”
Returns:
Human readable comparison, for printing.
Formatted as a five column table with titles of
PARAMETERNAME|Model1|Model2|Diff_Sigma1|Diff_Sigma2
where ModelX refer to self and othermodel Timing Model objects,
and Diff_SigmaX is the difference in a given parameter as reported by the two models,
normalized by the uncertainty in model X. If model X has no reported uncertainty,
nothing will be printed.
If format="text", when either Diff_SigmaX value is greater than threshold_sigma,
an exclamation point (!) will be appended to the line and color will be added if usecolor=True. If the uncertainty in the first model
if smaller than the second, an asterisk (*) will be appended to the line and color will be added if usecolor=True.
If format="markdown" then will be formatted as a markdown table with bold, colored, and highlighted text as appropriate.
For both output formats, warnings and info statements will be printed.
Set the parameters to use aliases as specified upon writing.
Parameters:
reset_to_default (bool) – If True, forget what name was used for each parameter in the input par file.
alias_translation (dict or None) – If not None, use this to map PINT parameter names to output names. This overrides
input names even if they are not otherwise being reset to default.
This is to allow compatibility with TEMPO/TEMPO2. The dictionary
pint.toa.tempo_aliases should provide a reasonable selection.
Sanity check to verify that this model is compatible with these toas.
This checks that where this model needs TOAs to constrain parameters,
that there is at least one TOA. This includes checking that every DMX
range for with the DMX is free has at least one TOA, and it verifies
that each “mask parameter” (for example JUMP) corresponds to at least one
TOA.
Individual components can implement a validate_toas method; this
method will automatically call such a method on each component that has
one.
If some TOAs are missing, this method will raise a MissingTOAError that
lists some (at least one) of the problem parameters.