Tim Class

The Tim class handles pulsar times-of-arrival (TOAs) files

class Tim(filename[, numwrap=float, usedecimal=False])
Parameters
  • filename (str) – Path to a .tim 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:

t = Tim(FILENAME) #automatically parses each TOA with the TOA() class
print(t.toas[0].getMJD()) #prints the MJD of the first TOA as a python Decimal
print(t.toas[0].get('snr')) #prints the value of the -snr flag of the TOA if it is available

Methods

load(filename)

Loads a .tim file.

param str filename

Path to .tim file

save(filename)

Save a .tim file.

Parameters

filename (str) – Path to .tim file

getFreqs()

Return the frequencies of each pulse profile the TOAs were generated from. Loops over getFreq() in TOA.

Return type

numpy.ndarray

getMJDs()

Return the MJD of each pulse profile the TOAs were generated from. Loops over getMJD() in TOA.

Return type

numpy.ndarray

getErrors()

Return the TOA uncertainties of each pulse profile the TOAs were generated from. Loops over getError() in TOA.

Return type

numpy.ndarray

get()

Return the value of a flag in each TOA line. Loops over get() in TOA.

Return type

numpy.ndarray

getTspan([years=False])

Return the total time span covered by the TOAs.

Parameters

years (bool) – Divide the total time span in days by 365.25.

Return type

float

TOA Class

The TOA class handles individual pulsar times-of-arrival (TOAs).

class TOA(filename[, freq=None, MJD=None, err=None, siteID=None, numwrap=Decimal, **kwargs])

Stores the five basic values of a TOA and any additional flags.

Parameters
  • filename (str) – If only the filename parameter is specified, then the parameter is the entire TOA string and will be parsed.

  • freq (str) – TOA frequency. Can be supplied a numeric value that will be wrapped as a float.

  • MJD (str) – TOA MJD. Can be supplied a numeric value that will be wrapped with the type numwrap.

  • err (str) – TOA error in microseconds. Can be supplied a numeric value that will be wrapped as a float.

  • siteID (str) – TOA observatory site ID.

  • 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.

  • **kwargs

    Additional flags. If the five base parameters are provided, each argument is a tuple of the form (flag, value). Otherwise, this is a string of all of the flags and values that must be parsed.

Methods

getFilename()

Return the filename the TOA was generated from.

Return type

str

getFrequency()

Return the frequency of the pulse profile the TOA was generated from.

Return type

float

getFreq()

Same as getFrequency().

getMJD()

Return the MJD of the TOA.

Return type

float

getError()

Return the TOA error in microseconds.

Return type

float

getSiteID()

Return the observatory site ID of the pulse profiles.

Return type

str

get(flag)

For any flags stored with the TOA, return the value.

Parameters

flag (str) – Name of the flag.

Return type

str

comment()

Comment out the TOA (the TOA string is appended to “C “). Useful when saving out a .tim file.

setFilename(filename)

Set the filename of the TOA to a value.

Parameters

filename (str) – Filename to set in the TOA.

setFrequency(freq)

Set the frequency of the TOA to a value.

Parameters

freq (float) – Frequency to set in the TOA.

setFreq(freq)

Same as setFrequency().

setMJD(MJD)

Set the MJD of the TOA to a value.

Parameters

MJD (float) – MJD to set in the TOA.

setError(err)

Set the error of the TOA to a value.

Parameters

err (float) – Error to set in the TOA.

setSiteID(siteID)

Set the observatory site ID of the TOA to a value.

Parameters

siteID (str) – Site ID to set in the TOA.

set(flag, value)

If the flag exists, set the value of an associated flag.

Parameters
  • flag (str) – Name of the flag.

  • value (str) – Value to set.

add(flag, value)

If the flag does not exist, add the flag with associated value to the TOA.

Parameters
  • flag (str) – Name of the flag.

  • value (str) – Value to set.