Par Class

The Par class handles pulsar parameter files.

class Par(filename[, numwrap=float, usedecimal=False])
Parameters
  • filename (str) – Path to a .par file

  • numwrap (type) – Type to wrap numeric values by. Float is used by default for ease but Decimal can be is used to keep numeric precision if needed, e.g., for spin period/frequency. Can set numwrap=DECIMAL or usedecimal=True.

  • usedecimal (bool) – See above.

Usage:

p = Par(FILENAME)
print(p.getPeriod()) #prints the period in the par file (does not calculate for a specific MJD for now)
t,dmx,dmxerr = p.getDMseries() #returns the DM parameters in a nice time-series. Note that errors are those given in the par file, which may not be the "correct" ones (more info to be provided later)
print(p.get("PX")) #prints the parallax
print(p.get("PX",error=True)) #prints the error on the parallax

Methods

get(tag[, flag=None, error=False])

Return the value of a given parameter.

Parameters
  • flag (str) – Return the value of a parameter with a flag provided. For example, noise parameters can be given a backend as a flag, e.g., for parameter “JUMP -fe L-wide 0.0 1 0.0”, the flag would be “L-wide”.

  • error (bool) – Return the value of the error associated with a parameter.

Returns

value

getPeriod()

Return the pulsar spin period.

Return type

float

getPeriodDot([shklovskii=False])

Return the pulsar spin period derivative.

Parameters

shklovskii (bool) – Attempt to correct for the Shklovskii effect if proper motion and parallax information is provided.

Return type

float

getFrequency()

Return the pulsar spin frequency.

Return type

float

getFrequencyDot([shklovskii=False])

Return the pulsar spin frequency derivative.

Parameters

shklovskii (bool) – Attempt to correct for the Shklovskii effect if proper motion and parallax information is provided.

Return type

float

getPM([error=False])

Calculate the proper motion in mas/yr. If only one of the two basis parameters is provided, return that value.

Parameters

error (bool) – If true, return the error on the proper motion.

Return type

float

getPX([error=False])

Return the parallax in mas.

Parameters

error (bool) – If true, return the error on the parallax.

Return type

float

getDIST([error=False])

Return the distance in kpc.

Parameters

error (bool) – If true, return the error on the distance.

Return type

float

getVpperp()

Calculate the transverse velocity in km/s.

Return type

float

getDM()

Return the DM parameter.

Return type

float

getDMX([full_output=False])

Return a tuple of the DMX time series (times, DMXs, DMX errors).

Parameters

full_output (bool) – Return a tuple of the times, DMXs, DMX errors, DMXR1s, DMXR2s, DMXF1s, DMXF2s

Returns

times (numpy.ndarray), DM (numpy.ndarray), DM errors (numpy.ndarray), unless full_output=True.

getXMX()

Return a tuple of the XMX values.

Returns

xmxs (numpy.ndarray), errs (numpy.ndarray), R1s (numpy.ndarray), R2s (numpy.ndarray), EXPs (numpy.ndarray),

Warning

This function is under construction.

getDMseries()

Return a tuple of the DM time series (times, DMs, DM errors). DMs are calculated as the DMX model plus the DM parameter (the fiducial value).

Returns

times (numpy.ndarray), DM (numpy.ndarray), DM errors (numpy.ndarray)

getFD()

Return the coefficients associated with the FD parameters, in order (i.e., FD1, FD2, …).

Return type

numpy.ndarray

getFDfunc()

Return a Python function (lambda) that provides the timing delays as a function of observing frequency. The function takes one parameter, the observing frequency (in GHz), and returns timing delays in microseconds.

Return type

function

getName()

Return the pulsar name given by either PSR or PSRJ.

Return type

str

getTspan([years=False])

Return the timespan given by the START and FINISH flags in days.

Parameters

years (bool) – Divide the timespan by 365.25.

Return type

float

Parameter Class

The Parameter class handles individual pulsar parameters.

class Parameter(name[, value=None, fit=None, error=None, flag=None, flagvalue=None, numwrap=d.Decimal])

Stores the basic values of a Parameter in a par file.

Parameters
  • name (str) – If only the name parameter is specified, then this is the entire parameter string and will be parsed. Otherwise, this is the parameter name (e.g. PSR, P0/F0, etc.)

  • value (str) – Parameter value. Can be supplied a numeric value that will be wrapped with the type numwrap is set to.

  • fit (str) – Parameter fit value, i.e. whether or not the parameter is to be fit in the timing model. Can be supplied a numeric value that will be wrapped with an int

  • error (str) – Parameter error. Can be supplied a numeric value that will be wrapped with the type numwrap is set to.

  • flag (str) – If there is a flag associated with the parameter

  • flagvalue (str) – The vale the flag is set to.

  • numwrap (type) – Type to wrap numeric values by. Decimal is used by default to keep numeric precision but becomes difficult to use with other packages. If precision is unneeded, set to float.

Methods

getName()

Return the name of the parameter.

Return type

str

getValue()

Return the value of the parameter.

Return type

numwrap

getError()

Return the value of the parameter error.

Return type

numwrap

getFit()

Return the value of the fit flag.

Return type

int

getFlag()

Return the value of the flag.

Return type

str

getFlagValue()

Return the value of the flag value

Return type

str