pint.models package

This module contains implementations of pulsar timing models.

Submodules

pint.models.astrometry module

class pint.models.astrometry.Astrometry[source]

Bases: pint.models.timing_model.TimingModel

barycentric_radio_freq(*args, **kwargs)[source]

Return radio frequencies (MHz) of the toas corrected for Earth motion

d_delay_astrometry_d_POSEPOCH(toas)[source]

Calculate the derivative wrt POSEPOCH

d_delay_astrometry_d_PX(*args, **kwargs)[source]

Calculate the derivative wrt PX

Roughly following Smart, 1977, chapter 9.

px_r: Extra distance to Earth, wrt SSB, from pulsar r_e: Position of earth (vector) wrt SSB u_p: Unit vector from SSB pointing to pulsar t_d: Parallax delay c: Speed of light delta: Parallax

The parallax delay is due to a distance orthogonal to the line of sight to the pulsar from the SSB:

px_r = sqrt( r_e**2 - (r_e.u_p)**2 ),

with delay

t_d = 0.5 * px_r * delta’/ c, and delta = delta’ * px_r / (1 AU)

get_d_delay_quantities(toas)[source]

Calculate values needed for many d_delay_d_param functions

setup()[source]
solar_system_geometric_delay(toas)[source]

Returns geometric delay (in sec) due to position of site in solar system. This includes Roemer delay and parallax.

NOTE: currently assumes XYZ location of TOA relative to SSB is available as 3-vector toa.xyz, in units of light-seconds.

ssb_to_psb_xyz(*args, **kwargs)[source]

Returns unit vector(s) from SSB to pulsar system barycenter.

If epochs (MJD) are given, proper motion is included in the calculation.

class pint.models.astrometry.AstrometryEcliptic[source]

Bases: pint.models.astrometry.Astrometry

coords_as_ICRS(*args, **kwargs)[source]

Returns pulsar sky coordinates as an astropy ICRS object instance. Pulsar coordinates will be transform from ecliptic coordinates to ICRS If epoch (MJD) is specified, proper motion is included to return the position at the given epoch.

If the ecliptic coordinates are provided,

d_delay_astrometry_d_ELAT(toas)[source]

Calculate the derivative wrt DECJ

Definitions as in d_delay_d_RAJ

d_delay_astrometry_d_ELONG(toas)[source]

Calculate the derivative wrt RAJ

For the RAJ and DEC derivatives, use the following approximate model for the pulse delay. (Inner-product between two Cartesian vectors)

de = Earth declination (wrt SSB) ae = Earth right ascension dp = pulsar declination aa = pulsar right ascension r = distance from SSB to Earh c = speed of light

delay = r*[cos(de)*cos(dp)*cos(ae-aa)+sin(de)*sin(dp)]/c

elate = Earth elat (wrt SSB) elonge = Earth elong elatp = pulsar elat elongp = pulsar elong r = distance from SSB to Earh c = speed of light

delay = r*[cos(elate)*cos(elatp)*cos(elonge-elongp)+sin(elate)*sin(elatp)]/c

d_delay_astrometry_d_PMELAT(toas)[source]

Calculate the derivative wrt PMDEC

Definitions as in d_delay_d_RAJ. Now we have a derivative in mas/yr for the pulsar DEC

d_delay_astrometry_d_PMELONG(toas)[source]

Calculate the derivative wrt PMRA

Definitions as in d_delay_d_RAJ. Now we have a derivative in mas/yr for the pulsar RA

get_d_delay_quantities_ecliptical(toas)[source]

Calculate values needed for many d_delay_d_param functions

setup()[source]
class pint.models.astrometry.AstrometryEquatorial[source]

Bases: pint.models.astrometry.Astrometry

coords_as_ICRS(epoch=None)[source]

Returns pulsar sky coordinates as an astropy ICRS object instance.

If epoch (MJD) is specified, proper motion is included to return the position at the given epoch.

If the ecliptic coordinates are provided,

d_delay_astrometry_d_DECJ(toas)[source]

Calculate the derivative wrt DECJ

Definitions as in d_delay_d_RAJ

d_delay_astrometry_d_PMDEC(toas)[source]

Calculate the derivative wrt PMDEC

Definitions as in d_delay_d_RAJ. Now we have a derivative in mas/yr for the pulsar DEC

d_delay_astrometry_d_PMRA(toas)[source]

Calculate the derivative wrt PMRA

Definitions as in d_delay_d_RAJ. Now we have a derivative in mas/yr for the pulsar RA

d_delay_astrometry_d_RAJ(toas)[source]

Calculate the derivative wrt RAJ

For the RAJ and DEC derivatives, use the following approximate model for the pulse delay. (Inner-product between two Cartesian vectors)

de = Earth declination (wrt SSB) ae = Earth right ascension dp = pulsar declination aa = pulsar right ascension r = distance from SSB to Earh c = speed of light

delay = r*[cos(de)*cos(dp)*cos(ae-aa)+sin(de)*sin(dp)]/c

setup()[source]

pint.models.binary_bt module

This model provides the BT (Blandford & Teukolsky 1976, ApJ, 205, 580) model.

class pint.models.binary_bt.BinaryBT[source]

Bases: pint.models.pulsar_binary.PulsarBinary

This is a PINT pulsar binary BT model class a subclass of PulsarBinary. It is a wrapper for stand alone BTmodel class defined in ./stand_alone_psr_binary/BT_model.py All the detailed calculations are in the stand alone BTmodel. The aim for this class is to connect the stand alone binary model with PINT platform BTmodel special parameters: GAMMA Binary Einsten delay coeeficient

setup()[source]

pint.models.binary_dd module

class pint.models.binary_dd.BinaryDD[source]

Bases: pint.models.pulsar_binary.PulsarBinary

This is a PINT pulsar binary dd model class a subclass of PulsarBinary. It is a wrapper for independent DDmodel class defined in ./stand_alone_psr_binary/DD_model.py All the detailed calculations are in the independent DDmodel. The aim for this class is to connect the independent binary model with PINT platform DDmodel special parameters: A0 Aberration B0 Aberration GAMMA Binary Einsten delay coeeficient DR Relativistic deformation of the orbit DTH Relativistic deformation of the orbit

setup()[source]

Check out parameters setup.

pint.models.binary_ell1 module

class pint.models.binary_ell1.BinaryELL1[source]

Bases: pint.models.pulsar_binary.PulsarBinary

This is a PINT pulsar binary ELL1 model class a subclass of PulsarBinary. It is a wrapper for stand alone ELL1model class defined in ./pulsar_binary/ELL1_model.py All the detailed calculations are in the stand alone ELL1model. The aim for this class is to connect the stand alone binary model with PINT platform ELL1model special parameters: TASC Epoch of ascending node EPS1 First Laplace-Lagrange parameter, ECC x sin(OM) for ELL1 model EPS2 Second Laplace-Lagrange parameter, ECC x cos(OM) for ELL1 model EPS1DOT First derivative of first Laplace-Lagrange parameter EPS2DOT Second derivative of second Laplace-Lagrange parameter

setup()[source]

Check out parameters setup.

pint.models.dispersion_model module

This module implements a simple model of a constant dispersion measure. And DMX dispersion

class pint.models.dispersion_model.Dispersion[source]

Bases: pint.models.timing_model.TimingModel

This class provides a base dispersion timing model. The dm varience will be treated linearly.

constant_dm(toas)[source]
d_delay_d_DM(toas)[source]

Derivatives for constant DM

dispersion_delay(toas)[source]
dispersion_time_delay(DM, freq)[source]

Return the dispersion time delay for a set of frequency. This equation if cited from Duncan Lorimer, Michael Kramer, Handbook of Pulsar Astronomy, Second edition, Page 86, Equation [4.7] Here we assume the reference frequency is at infinity and the EM wave frequency is much larger than plasma frequency.

setup()[source]
class pint.models.dispersion_model.DispersionDMX[source]

Bases: pint.models.dispersion_model.Dispersion

This class provides a DMX model based on the class of Dispersion.

d_delay_d_DMX(toas, param_name)[source]
dmx_dm(toas)[source]
setup()[source]

pint.models.frequency_dependent module

This module implements a frequency evolution of pulsar profiles model

class pint.models.frequency_dependent.FD[source]

Bases: pint.models.timing_model.TimingModel

This class provides a timing model for frequency evolution of pulsar profiles model.

FD_delay(toas)[source]

This is a function for calculation of frequency dependent delay. Z. Arzoumanian, The NANOGrav Nine-year Data Set: Observations, Arrival Time Measurements, and Analysis of 37 Millisecond Pulsars, The Astrophysical Journal, Volume 813, Issue 1, article id. 65, 31 pp.(2015). Eq.(2): FDdelay = sum(c_i * (log(obs_freq/1GHz))^i)

d_delay_FD_d_FDX(toas, param)[source]

This is a derivative function for FD parameter

make_delay_FD_deriv_funcs(param)[source]
setup()[source]

pint.models.glitch module

This module implements pulsar timing glitches.

class pint.models.glitch.Glitch[source]

Bases: pint.models.timing_model.TimingModel

This class provides glitches.

d_phase_d_GLEP_1(toas)[source]

Calculate the derivative wrt GLEP_1

d_phase_d_GLF0_1(toas)[source]

Calculate the derivative wrt GLF0_1

d_phase_d_GLPH_1(toas)[source]

Calculate the derivative wrt GLPH_1

glitch_phase(toas, delay)[source]

Glitch phase function. delay is the time delay from the TOA to time of pulse emission at the pulsar, in seconds. returns an array of phases in long double

setup()[source]

pint.models.jump module

This module implements phase jumps.

class pint.models.jump.JumpDelay[source]

Bases: pint.models.timing_model.TimingModel

This is a class to implement phase jumps

d_delay_d_jump(toas, jump_param)[source]
jump_delay(toas)[source]

This method returns the jump delays for each toas section collected by jump parameters. The delay value is determined by jump parameter value in the unit of seconds.

setup()[source]

pint.models.model_builder module

class pint.models.model_builder.model_builder(name, parfile=None)[source]

Bases: object

A class for model construction interface. Parameters ——— name : str

Name for the model.
parfile : str optional
The .par file input for select components. If the parfile is provided the self.model_instance will be put model instance with .par file read in. If it is not provided, self.model_instance will return as None.

A class contains the result model instance if parfile is provided and method to build the model.

Read model from parfile : [1] mb = model_builder(“PulsarJ1955”, parfile =”J1955.par” ) [2] psrJ1955 = mb.model_instance

Build model from sketch and read parfile: [1] from .bt import BT [2] mb = model_builder(“BT_model”) [3] mb.add_components(BT) [4] psrJ1955 = mb.get_model_instance(‘J1955.par’)

Build model instance without reading parfile: [1] mb = model_builder(“BT_model”) [2] mb.add_components(BT) [3] myModel = mb.get_model_instance()

add_components(components)[source]

Add new components to constructing model.

build_model()[source]

Return a model with all components listed in the self.components list.

get_comp_from_parfile(parfile)[source]

Check all the components if it is needed from parfile Put the needed on in the selected components list

get_model_instance(parfile=None)[source]

Read parfile using the model_instance attribute. Parameters ——— parfile : str optional

The parfile name
preprocess_parfile(parfile)[source]

Preprocess the par file. Return ——— A dictionary with all the parfile parameters with values in string

search_prefix_param(paramList, prefix_inModel)[source]

Check if the Unrecognized parameter has prefix parameter

pint.models.model_builder.get_componets()[source]
pint.models.model_builder.get_model(parfile)[source]

A one step function to build model from a parfile Parameters ——— name : str

Name for the model.
parfile : str
The parfile name

Model instance get from parfile.

pint.models.parameter module

class pint.models.parameter.AngleParameter(name=None, value=None, description=None, units='rad', uncertainty=None, frozen=True, continuous=True, aliases=[], **kwargs)[source]

Bases: pint.models.parameter.Parameter

This is a Parameter type that is specific to Angle values. .quantity stores current parameter information in an astropy Angle type. .value returns the pure angle value associate with default unit. .units currently can accept angle format {‘h:m:s’: u.hourangle, ‘d:m:s’: u.deg, ‘rad’: u.rad, ‘deg’: u.deg}

name : str
The name of the parameter.
value : angle string, float, astropy angle object
The input parameter angle value.
description : str, optional
A short description of what this parameter means.
uncertainty : number
Current uncertainty of the value.
frozen : bool, optional
A flag specifying whether “fitters” should adjust the value of this parameter or leave it fixed.
continuous : bool, optional, default True
A flag specifying whether phase derivatives with respect to this parameter exist.
aliases : list, optional
An optional list of strings specifying alternate names that can also be accepted for this parameter.
Example::
>>> from parameter import AngleParameter
>>> test = AngleParameter(name='test1', value='12:20:10', units='H:M:S')
>>> print test
test1 (hourangle) 12:20:10.00000000
set_quantity_angle(val)[source]

This function is to set value to angle parameters. Accepted format: 1. Astropy angle object 2. float 3. number string

set_uncertainty_angle(val)[source]

This function is to set the uncertainty for an angle parameter.

class pint.models.parameter.MJDParameter(name=None, value=None, description=None, uncertainty=None, frozen=True, continuous=True, aliases=[], time_scale='utc', **kwargs)[source]

Bases: pint.models.parameter.Parameter

This is a Parameter type that is specific to MJD values. .quantity stores current parameter information in an astropy.Time type in the format of MJD. .value returns the pure MJD value. .units is in day as default unit.

name : str
The name of the parameter.
value : astropy Time, str, float in mjd, str in mjd.
The input parameter MJD value.
description : str, optional
A short description of what this parameter means.
uncertainty : number
Current uncertainty of the value.
frozen : bool, optional
A flag specifying whether “fitters” should adjust the value of this parameter or leave it fixed.
continuous : bool, optional, default True
A flag specifying whether phase derivatives with respect to this parameter exist.
aliases : list, optional
An optional list of strings specifying alternate names that can also be accepted for this parameter.
time_scale : str, optional, default ‘utc’
MJD parameter time scale.
Example::
>>> from parameter import MJDParameter
>>> test = MJDParameter(name='test1', value='54000', time_scale='utc')
>>> print test
test1 (d) 54000.000000000000000
print_uncertainty(uncertainty)[source]
set_quantity_mjd(val)[source]

Value setter for MJD parameter, Accepted format: Astropy time object mjd float mjd string

set_uncertainty_mjd(val)[source]
uncertainty_value

Return a pure value from .uncertainty. The unit will associate with .units

class pint.models.parameter.Parameter(name=None, value=None, units=None, description=None, uncertainty=None, frozen=True, aliases=None, continuous=True, print_quantity=<type 'str'>, set_quantity=<function <lambda>>, get_value=<function <lambda>>, prior=<pint.models.priors.Prior object>, set_uncertainty=<function fortran_float>)[source]

Bases: object

A base PINT class describing a single timing model parameter. PINT Parameter class will have

A Parameter object can be created with one of the subclasses provided by PINT depending on the parameter usage. Current Parameter type: [floatParameter, strParameter, boolParameter, MDJParameter,

AngleParameter, prefixParameter, maskParameter]

Parameter Mechanism Parameter current value information will be stored at .quantity property which can be a flexible format, for example astropy.quantity in floatParameter and string in strParameter, (For more detail see Parameter subclasses docstrings). If applicable, Parameter default unit is stored at`.units` property which is an astropy.unit object. Property .value always returns a pure value associate with .units from .quantity. .uncertainty provides the storage for parameter uncertainty and .uncertainty_value for pure uncertainty value. Like .value, .uncertainty_value always associate with default unit.

name : str, optional
The name of the parameter.
value : number, str, Astropy.units.Quantity object, or other data type or
object

The input parameter value.

units : str or Astropy.units, optional
Parameter default unit. Parameter .value and .uncertainty_value attribute will associate with the default units.
description : str, optional
A short description of what this parameter means.
uncertainty : number
Current uncertainty of the value.
frozen : bool, optional
A flag specifying whether “fitters” should adjust the value of this parameter or leave it fixed.
aliases : list, optional
An optional list of strings specifying alternate names that can also be accepted for this parameter.
continuous : bool, optional
A flag specifying whether phase derivatives with respect to this parameter exist.
print_quantity : method, optional
A function that converts the internal value to a string for output.
set_quantity : method, optional
A function that sets the quantity property
get_value:
A function that get purely value from quantity attribute
quantity: Type depends on the parameter subclass, it can be anything
An internal storage for parameter value and units
add_alias(alias)[source]

Add a name to the list of aliases for this parameter.

as_parfile_line()[source]

Return a parfile line giving the current state of the parameter.

from_parfile_line_regular(line)[source]

Parse a parfile line into the current state of the parameter. Returns True if line was successfully parsed, False otherwise. Notes —– The accepted format:

NAME value NAME value fit_flag NAME value fit_flag uncertainty NAME value uncertainty
help_line()[source]

Return a help line containing parameter name, description and units.

name_matches(name)[source]

Whether or not the parameter name matches the provided name

print_uncertainty(uncertainty)[source]
prior_pdf(value=None, logpdf=False)[source]

Return the prior probability, evaluated at the current value of the parameter, or at a proposed value.

value : array_like or float_like

Probabilities are evaluated using the value attribute

set(value)[source]

Parses a string ‘value’ into the appropriate internal representation of the parameter.

prior
quantity

Return the internal stored parameter value and units.

uncertainty

Return the internal stored parameter uncertainty value and units.

uncertainty_value

Return a pure value from .uncertainty. The unit will associate with .units

units
value

Return the pure value of a parameter. This value will associate with parameter default value, which is .units attribute.

class pint.models.parameter.boolParameter(name=None, value=None, description=None, frozen=True, aliases=[], **kwargs)[source]

Bases: pint.models.parameter.Parameter

This is a Parameter type that is specific to boolean values. .quantity stores current parameter information in boolean type. .value returns the same with .quantity. .units is not applicable. boolParameter is not fitable.

name : str
The name of the parameter.
value : str, bool, [0,1]
The input parameter boolean value.
description : str, optional
A short description of what this parameter means.
aliases : list, optional
An optional list of strings specifying alternate names that can also be accepted for this parameter.
Example::
>>> from parameter import boolParameter
>>> test = boolParameter(name='test1', value='N')
>>> print test
test1 N
set_quantity_bool(val)[source]

This function is to get boolean value for boolParameter class

class pint.models.parameter.floatParameter(name=None, value=None, units=None, description=None, uncertainty=None, frozen=True, aliases=[], continuous=True, long_double=False, **kwargs)[source]

Bases: pint.models.parameter.Parameter

This is a Parameter type that is specific to the parameters has a float/ float128 quantity as its value.

.quantity stores current parameter value and its unit in an astropy.units.quantity class. The unit of .quantity can be any unit that convertible to default unit.

name : str
The name of the parameter.
value : number, str, Astropy.units.Quantity object,
The input parameter float value.
units : str or Astropy.units
Parameter default unit. Parameter .value and .uncertainty_value attribute will associate with the default units. If unit is dimensionless, use “’‘” as its unit.
description : str, optional
A short description of what this parameter means.
uncertainty : number
Current uncertainty of the value.
frozen : bool, optional
A flag specifying whether “fitters” should adjust the value of this parameter or leave it fixed.
aliases : list, optional
An optional list of strings specifying alternate names that can also be accepted for this parameter.
continuous : bool, optional, default True
A flag specifying whether phase derivatives with respect to this parameter exist.
long_double : bool, optional, default False
A flag specifying whether value is float or float128/longdouble.
Example::
>>> from parameter import floatParameter
>>> test = floatParameter(name='test1', value=100.0, units='second')
>>> print test
test1 (s) 100.0
get_value_float(quan)[source]
print_quantity_float(quan)[source]

A function gives print quantity string.

set_quantity_float(val)[source]

Set value method specific for float parameter accept format 1. Astropy quantity 2. float 3. string

long_double
class pint.models.parameter.maskParameter(name=None, index=1, key=None, key_value=None, value=None, long_double=False, units=None, description=None, uncertainty=None, frozen=True, continuous=False, aliases=[])[source]

Bases: pint.models.parameter.floatParameter

This is a Parameter type for mask parameters which is to select a certain subset of TOAs and apply changes on the subset of TOAs, for example JUMP. This type of parameter does not require index input. But eventrully an index part will be added, for the purpose of parsing the right value from the parfile. For example, >>> p = maskParameter(name=’JUMP’, index=2) >>> p.name ‘JUMP2’ Parameter ——— name : str optional

The name of the parameter.
index : int optional [default 1]
The index number for the prefixed parameter.
key : str optional
The key words/flag for the selecting TOAs
key_value : list/single value optional
The value for key words/flags. Value can take one value as a flag value. or two value as a range. e.g. JUMP freq 430.0 1440.0. or JUMP -fe G430
value : float or long_double optinal
Toas/phase adjust value
long_double : bool, optional default ‘double’
Set float type quantity and value in numpy float128
units : str optional
Unit for the offset value
description : str optional
Description for the parameter
uncertainty: float/longdouble
uncertainty of the parameter.
frozen : bool, optional
A flag specifying whether “fitters” should adjust the value of this parameter or leave it fixed.

continuous : bool optional aliases : list optional

List of aliases for parameter name.

TODO: Is mask parameter provide some other type of parameters other then floatParameter?

as_parfile_line_mask()[source]
from_parfile_line_mask(line)[source]

This is a method to read mask parameter line (e.g. JUMP) Notes —– The accepted format:

NAME key key_value parameter_value NAME key key_value parameter_value fit_flag NAME key key_value parameter_value fit_flag uncertainty NAME key key_value parameter_value uncertainty NAME key key_value1 key_value2 parameter_value NAME key key_value1 key_value2 parameter_value fit_flag NAME key key_value1 key_value2 parameter_value fit_flag uncertainty NAME key key_value1 key_value2 parameter_value uncertainty
new_param(index)[source]

Create a new but same style mask parameter

select_toa_mask(toas)[source]

Select the toas. Parameter ———- toas : toas table Return ———- A mask array. the select toas are masked as True.

class pint.models.parameter.prefixParameter(parameter_type='float', name=None, value=None, units=None, unitTplt=None, description=None, descriptionTplt=None, uncertainty=None, frozen=True, continuous=True, prefix_aliases=[], long_double=False, time_scale='utc', **kwargs)[source]

Bases: object

This is a Parameter type for prefix parameters, for example DMX_ Create a prefix parameter, is like create a normal parameter. But the name should be in the format of prefix and index. For example DMX_0001 or F22. To create a prefix parameter with the same prefix but different index, just use the .new_param method. It will return a new prefix parameter with the same setup but the index. Some parameters’ unit and description will be changed once the index has been changed. In order to get the right units and description, .unitTplt and .descriptionTplt should be provided. If not the new prefix parameter will use the same units and description with the old one. A typical description and units template is like: >>> descritionTplt = lambda x: ‘This is the description of parameter %d’%x >>> unitTplt = lambda x: ‘second^%d’%x Parameter ——— name : str optional

The name of the parameter. It has to be in the format of prefix + index.
units : str optional
The unit of parameter
unitTplt : lambda method
The unit template for prefixed parameter
description : str optional
Description for the parameter
descriptionTplt : lambda method optional
Description template for prefixed parameters
prefix_aliases : list of str optional
Alias for the prefix
frozen : bool, optional
A flag specifying whether “fitters” should adjust the value of this parameter or leave it fixed.

continuous : bool parameter_type : str, optional, default ‘float’

Example parameter class template for quantity and value setter
long_double : bool, optional default ‘double’
Set float type quantity and value in numpy float128
time_scale : str, optional default ‘utc’
Time scale for MJDParameter class.
as_parfile_line()[source]
from_parfile_line(line)[source]
help_line()[source]
name_matches(name)[source]
new_param(index)[source]

Get one prefix parameter with the same type. Parameter ———- index : int

index of prefixed parameter.

A prefixed parameter with the same type of instance.

prefix_matches(prefix)[source]
print_quantity(quantity)[source]
prior_pdf(value=None, logpdf=False)[source]
aliases
continuous
description
frozen
prior
quantity
special_arg
uncertainty
uncertainty_value
units
value
class pint.models.parameter.strParameter(name=None, value=None, description=None, aliases=[], **kwargs)[source]

Bases: pint.models.parameter.Parameter

This is a Parameter type that is specific to string values. .quantity stores current parameter information in a string. .value returns the same with .quantity. .units is not applicable. strParameter is not fitable.

name : str
The name of the parameter.
value : str
The input parameter string value.
description : str, optional
A short description of what this parameter means.
aliases : list, optional
An optional list of strings specifying alternate names that can also be accepted for this parameter.
Example::
>>> from parameter import strParameter
>>> test = strParameter(name='test1', value='This is a test',)
>>> print test
test1 This is a test

pint.models.polycos module

class pint.models.polycos.Polycos[source]

Bases: object

A class for polycos model. Ployco is a fast phase calculator. It fits a set of data using polynomials.

add_polyco_file_format(formatName, methodMood, readMethod=None, writeMethod=None)[source]

Add a polyco file format and its reading/writting method to the class. Then register it to the table reading. Parameters ——— formatName : str

The name for the format.
methodMood : str
[‘r’,’w’,’rw’]. ‘r’ represent as reading
‘w’ represent as writting ‘rw’ represent as reading and writting
readMethod : method
The method for reading the file format.
writeMethod : method
The method for writting the file to disk.
eval_abs_phase(t)[source]

Polyco evalate absolute phase for a time array. Parameters ——— t: numpy.ndarray or a single number.

An time array in MJD. Time sample should be in order
out: PINT Phase class
Polyco evaluated absolute phase for t.
eval_phase(t)[source]
eval_spin_freq(t)[source]

FREQ(Hz) = F0 + (1/60)*(COEFF(2) + 2*DT*COEFF(3) + 3*DT^2*COEFF(4) + ....)

find_entry(t)[source]

Find the right entry for the input time.

generate_polycos(model, mjdStart, mjdEnd, obs, segLength, ncoeff, obsFreq, maxha, method='TEMPO', numNodes=20)[source]

Generate the polyco file data file.

model : TimingModel
TimingModel for generate the Polycos with parameters setup.
mjdStart : float / nump longdouble
Start time of polycos in mjd
mjdEnd : float / nump longdouble
Ending time of polycos in mjd
obs : str
Observatory code
segLength :
Length of polyco segement [unit: minutes]
ncoeff :
number of coefficents
obsFreq :
observing frequency
maxha :
Maximum hour angle
method : sting optional [‘TEMPO’,’TEMPO2’,...] Default TEMPO
Method to generate polycos. Now it is only support the TEMPO method.
numNodes : int optional. Default 20
Number of nodes for fitting. It can not be less then the number of coefficents.

A polyco table.

read_polyco_file(filename, format)[source]

Read polyco file from one type of format to a table.

filename : str
The name of the polyco file.
format : str
The format of the file.

Polycos Table with read_in data.

write_polyco_file(format, filename=None)[source]

Write Polyco table to a file.

class pint.models.polycos.polycoEntry(tmid, mjdspan, rphaseInt, rphaseFrac, f0, ncoeff, coeffs, obs)[source]

Polyco Entry class: A Class for one Polyco entry. Referenced from polyco.py authored by

Paul S. Ray <paul.ray@nrl.navy.mil> Matthew Kerr <matthew.kerr@gmail.com>
tmid : float
Middle point of the time span in mjd
mjdspan : float
Time span in mjd
rphase : float
Reference phase
f0 : float
Reference spin frequency
ncoeff : int
Number of coefficients
obs : str
Observatory code
evalabsphase(t)[source]

Return the phase at time t, computed with this polyco entry

evalfreq(t)[source]

Return the freq at time t, computed with this polyco entry

evalfreqderiv(t)[source]

Return the frequency derivative at time t.

evalphase(t)[source]

Return the phase at time t, computed with this polyco entry

valid(t)[source]

Return True if this polyco entry is valid for the time given (MJD)

pint.models.polycos.tempo_polyco_table_reader(filename)[source]

Read tempo style polyco file to an astropy table

filename : str
Name of the input poloco file.

Tempo style: The polynomial ephemerides are written to file ‘polyco.dat’. Entries are listed sequentially within the file. The file format is:

Line Columns Item —- ——- ———————————–

1 1-10 Pulsar Name
11-19 Date (dd-mmm-yy) 20-31 UTC (hhmmss.ss) 32-51 TMID (MJD) 52-72 DM 74-79 Doppler shift due to earth motion (10^-4) 80-86 Log_10 of fit rms residual in periods
2 1-20 Reference Phase (RPHASE)
21-38 Reference rotation frequency (F0) 39-43 Observatory number 44-49 Data span (minutes) 50-54 Number of coefficients 55-75 Observing frequency (MHz) 76-80 Binary phase
3* 1-25 Coefficient 1 (COEFF(1))
26-50 Coefficient 2 (COEFF(2)) 51-75 Coefficient 3 (COEFF(3))
  • Subsequent lines have three coefficients each, up to NCOEFF

One polyco file could include more then one entrie

The pulse phase and frequency at time T are then calculated as: DT = (T-TMID)*1440 PHASE = RPHASE + DT*60*F0 + COEFF(1) + DT*COEFF(2) + DT^2*COEFF(3) + .... FREQ(Hz) = F0 + (1/60)*(COEFF(2) + 2*DT*COEFF(3) + 3*DT^2*COEFF(4) + ....)

Reference:
http://tempo.sourceforge.net/ref_man_sections/tz-polyco.txt
pint.models.polycos.tempo_polyco_table_writer(polycoTable, filename='polyco.dat')[source]

Write tempo style polyco file from an astropy table

polycoTalbe: astropy table
Polycos style table
filename : str
Name of the output poloco file.

Tempo style polyco file: The polynomial ephemerides are written to file ‘polyco.dat’. Entries are listed sequentially within the file. The file format is:

Line Columns Item —- ——- ———————————–

1 1-10 Pulsar Name
11-19 Date (dd-mmm-yy) 20-31 UTC (hhmmss.ss) 32-51 TMID (MJD) 52-72 DM 74-79 Doppler shift due to earth motion (10^-4) 80-86 Log_10 of fit rms residual in periods
2 1-20 Reference Phase (RPHASE)
21-38 Reference rotation frequency (F0) 39-43 Observatory number 44-49 Data span (minutes) 50-54 Number of coefficients 55-75 Observing frequency (MHz) 76-80 Binary phase
3* 1-25 Coefficient 1 (COEFF(1))
26-50 Coefficient 2 (COEFF(2)) 51-75 Coefficient 3 (COEFF(3))
  • Subsequent lines have three coefficients each, up to NCOEFF

One polyco file could include more then one entrie

The pulse phase and frequency at time T are then calculated as: DT = (T-TMID)*1440 PHASE = RPHASE + DT*60*F0 + COEFF(1) + DT*COEFF(2) + DT^2*COEFF(3) + .... FREQ(Hz) = F0 + (1/60)*(COEFF(2) + 2*DT*COEFF(3) + 3*DT^2*COEFF(4) + ....)

Reference:
http://tempo.sourceforge.net/ref_man_sections/tz-polyco.txt

pint.models.priors module

priors.py Defines classes used for evaluation prior probabilities

Initially this handles priors on single parameters that don’t depend on any other parameters. This will need to be supplemented with a mechanism, probably in the model class, that implements priors on combinations of parameters, such as total proper motion, 2-d sky location, etc.

class pint.models.priors.GaussianRV_gen(momtype=1, a=None, b=None, xtol=1e-14, badvalue=None, name=None, longname=None, shapes=None, extradoc=None, seed=None)[source]

Bases: scipy.stats._distn_infrastructure.rv_continuous

A Gaussian prior between two bounds. If you just want a gaussian, use scipy.stats.norm This version is for generating bounded gaussians

loc : number
Mode of the gaussian (default=0.0)
scale : number
Standard deviation of the gaussian (default=1.0)
class pint.models.priors.Prior(rv)[source]

Bases: object

Class for evaluation of prior probability densities

Any Prior object returns the probability density using

the pdf() and logpdf() methods. For generality, these are written so that they work on a scalar value or a numpy array of values.

_rv : rv_frozen
Private member that holds an instance of rv_frozen used to evaluate the prior. It must be a ‘frozen distribution’, with all location and shape parameters set. See <http://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.rv_continuous.html#scipy.stats.rv_continuous>

Priors are evaluated at values corresponding to the num_value of the parameter and don’t currently use units (the num_unit is the assumed unit)

# A uniform prior of F0, with no bounds (any value is acceptable) model.F0.prior = Prior(UniformUnboundedRV())

# A uniform prior on F0 between 50 and 60 Hz (because num_unit is Hz) model.F0.prior = Prior(UniformBoundedRV(50.0,60.0))

# A Gaussian prior on PB with mean 32 days and std dev 1.0 day model.PB.prior = Prior(scipy.stats.norm(loc=32.0,scale=1.0))

# A bounded gaussian prior that ensure that eccentrity never gets > 1.0 model.ECC.prior = Prior(GaussianBoundedRV(loc=0.9,scale=0.1,

lower_bound=0.0,upper_bound=1.0))
logpdf(value)[source]
pdf(value)[source]
class pint.models.priors.UniformUnboundedRV(momtype=1, a=None, b=None, xtol=1e-14, badvalue=None, name=None, longname=None, shapes=None, extradoc=None, seed=None)[source]

Bases: scipy.stats._distn_infrastructure.rv_continuous

A uniform prior distribution (equivalent to no prior)

pint.models.priors.GaussianBoundedRV(loc=0.0, scale=1.0, lower_bound=-inf, upper_bound=inf)[source]

A gaussian prior between two bounds

lower_bound : number
Lower bound of allowed parameter range
upper_bound : number
Upper bound of allowed parameter range

Returns a frozen rv_continuous instance with a gaussian probability inside the range lower_bound to upper_bound and 0.0 outside

pint.models.priors.UniformBoundedRV(lower_bound, upper_bound)[source]

A uniform prior between two bounds

lower_bound : number
Lower bound of allowed parameter range
upper_bound : number
Upper bound of allowed parameter range

Returns a frozen rv_continuous instance with a uniform probability inside the range lower_bound to upper_bound and 0.0 outside

pint.models.pulsar_binary module

class pint.models.pulsar_binary.PulsarBinary[source]

Bases: pint.models.timing_model.TimingModel

A wapper class for independent pulsar binary model interact with PINT platform. The calculations are done by the classes located at pint/models/stand_alone_psr_binary Binary variables naming: Eccentric Anomaly E (not parameter ECC) Mean Anomaly M True Anomaly nu Eccentric ecc Longitude of periastron omega projected semi-major axis of orbit a1

apply_units()[source]

Apply units to parameter value.

binarymodel_delay(toas)[source]

Return the binary model independent delay call

d_binary_delay_d_xxxx(toas, param)[source]

Return the bianry model delay derivtives

make_delay_binary_deriv_funcs(param)[source]

This is a funcion to make binary derivative functions to the formate of d_binary_delay_d_paramName(toas)

setup()[source]
update_binary_object(toas)[source]

Update binary object instance for this set of parameters/toas

pint.models.solar_system_shapiro module

class pint.models.solar_system_shapiro.SolarSystemShapiro[source]

Bases: pint.models.timing_model.TimingModel

setup()[source]
solar_system_shapiro_delay(toas)[source]

Returns total shapiro delay to due solar system objects. If the PLANET_SHAPIRO model param is set to True then planets are included, otherwise only the value for the Sun is calculated.

Requires Astrometry or similar model that provides the ssb_to_psb_xyz method for direction to pulsar.

If planets are to be included, TOAs.compute_posvels() must have been called with the planets=True argument.

static ss_obj_shapiro_delay(obj_pos, psr_dir, T_obj)[source]

returns Shapiro delay in seconds for a solar system object.

Inputs:
obj_pos : position vector from Earth to SS object, with Units psr_dir : unit vector in direction of pulsar T_obj : mass of object in seconds (GM/c^3)

pint.models.spindown module

This module implements polynomial pulsar spindown.

class pint.models.spindown.Spindown[source]

Bases: pint.models.timing_model.TimingModel

This class provides a simple timing model for an isolated pulsar.

F_description(n)[source]

Template function for description

F_unit(n)[source]

Template function for unit

d_phase_d_F(toas, param, delay)[source]

Calculate the derivative wrt to an spin term.

d_spindown_phase_d_delay(toas, delay)[source]
get_dt(toas, delay)[source]
get_spin_terms()[source]

Return a list of the spin term values in the model: [F0, F1, ..., FN]

setup()[source]
spindown_phase(toas, delay)[source]

Spindown phase function.

delay is the time delay from the TOA to time of pulse emission
at the pulsar, in seconds.

This routine should implement Eq 120 of the Tempo2 Paper II (2006, MNRAS 372, 1549)

returns an array of phases in long double

pint.models.timing_model module

exception pint.models.timing_model.MissingParameter(module, param, msg=None)[source]

Bases: pint.models.timing_model.TimingModelError

A required model parameter was not included.

Attributes:
module = name of the model class that raised the error param = name of the missing parameter msg = additional message
exception pint.models.timing_model.TimingModelError[source]

Bases: exceptions.Exception

Generic base class for timing model errors.

class pint.models.timing_model.Cache[source]

Bases: object

Temporarily cache timing model internal computation results.

The Cache class defines two decorators, use_cache and cache_result.

classmethod cache_result(function)[source]

Caching decorator for functions.

This can be applied as a decorator to any timing model method for which it might be useful to store the value, once computed for a given TOA. Note that the cache must be manually enabled and cleared when appropriate, so this functionality should be used with care.

classmethod use_cache(function)[source]

Caching decorator for functions.

This can be applied as a decorator to a function that should internally use caching of function return values. The cache will be deleted when the function exits. If the top-level function calls other functions that have caching enabled they will share the cache, and it will only be deleted when the top-level function exits.

the_cache = 'cache'
class pint.models.timing_model.TimingModel[source]

Bases: object

Base-level object provides an interface for implementing pulsar timing models. It contains several over all wrapper methods.

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.

All timing model component classes should subclass this timing model base class. 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 pint.model.parameter delay or phase and its derivatives are implemented as TimingModel Methods.

params : list
A list of all the parameter names.
prefix_params : list
A list of prefixed parameter names.
delay_funcs : dict
All the delay functions implemented in timing model. The delays do not need barycentric toas are placed under the ‘L1’ keys as a list of methods, the ones needs barycentric toas are under the ‘L2’ delay. This will be improved in the future. One a delay method is defined in model component, it should get registered in this dictionary.
phase_funcs : list
All the phase functions implemented in timing model. Once a phase method is defined in model component, it should get registered in this list.
delay_derivs : list
All the delay derivatives respect to timing parameters. Once a delay derivative method is defined in model component, it should get registered in this list.
phase_derivs : list
All the phase derivatives respect to timing parameters. Once a phase derivative method is defined in model component, it should get registered in this list.
phase_derivs_wrt_delay : list
All the phase derivatives respect to delay.
add_param(param, binary_param=False)[source]

Add a parameter to the timing model. If it is a prefixe parameter, it will add prefix information to the prefix information attributes.

as_parfile()[source]

Returns a parfile representation of the entire model as a string.

d_delay_d_param(toas, param)[source]

Return the derivative of delay with respect to the parameter.

d_delay_d_param_num(toas, param, step=0.01)[source]

Return the derivative of phase with respect to the parameter.

d_phase_d_param(toas, delay, param)[source]

Return the derivative of phase with respect to the parameter.

d_phase_d_param_num(toas, param, step=0.01)[source]

Return the derivative of phase with respect to the parameter.

d_phase_d_toa(toas, sample_step=None)[source]

Return the derivative of phase wrt TOA Parameter ——— toas : PINT TOAs class

The toas when the derivative of phase will be evaluated at.
sample_step : float optional
Finite difference steps. If not specified, it will take 1/10 of the spin period.
d_phase_d_tpulsar(toas)[source]

Return the derivative of phase wrt time at the pulsar.

NOT implemented yet.

delay(toas)[source]

Total delay for the TOAs.

Return the total delay which will be subtracted from the given TOA to get time of emission at the pulsar.

designmatrix(toas, scale_by_F0=True, incfrozen=False, incoffset=True)[source]

Return the design matrix: the matrix with columns of d_phase_d_param/F0 or d_toa_d_param

get_barycentric_toas(toas)[source]
get_params_of_type(param_type)[source]

Get all the parameters in timing model for one specific type

get_prefix_mapping(prefix)[source]

Get the index mapping for the prefix parameters. Parameter ———- prefix : str

Name of prefix.

A dictionary with prefix pararameter real index as key and parameter name as value.

is_in_parfile(para_dict)[source]

Check if this subclass inclulded in parfile. Parameters ———— para_dict : dictionary

A dictionary contain all the parameters with values in string from one parfile
True : bool
The subclass is inculded in the parfile.
False : bool
The subclass is not inculded in the parfile.
match_param_aliases(alias)[source]
param_help()[source]

Print help lines for all available parameters in model.

phase(toas)[source]

Return the model-predicted pulse phase for the given TOAs.

read_parfile(filename)[source]

Read values from the specified parfile into the model parameters.

register_deriv_funcs(func, deriv_type, param='')[source]

This is a function to register the derivative function in to the deriv_func dictionaries. Parameter ——— func: method

The method calculates the derivative
deriv_type: str [‘delay’, ‘phase’, ‘d_phase_d_delay’]
Flag for different type of derivatives. It only accepts the three above.
param: str, if for d_phase_d_delay it is optional
Name of parameter the derivative respect to
remove_param(param)[source]
set_special_params(spcl_params)[source]
setup()[source]

This is a abstract class for setting up timing model class. It is designed for reading .par file and check parameters.

pint.models.timing_model.generate_timing_model(name, components, attributes={})[source]

Build a timing model from components.

Returns a timing model class generated from the specifiied sub-components. The return value is a class type, not an instance, so needs to be called to generate a usable instance. For example:

MyModel = generate_timing_model(“MyModel”,(Astrometry,Spindown),{}) my_model = MyModel() my_model.read_parfile(“J1234+1234.par”)