pint.polycos.Polycos

class pint.polycos.Polycos(filename=None, format='tempo')[source]

Bases: object

A class for polycos model.

Polyco is a fast phase calculator. It fits a set of data using polynomials and can predict phases at points in between.

Initialize polycos from a file

Parameters:
  • filename (str or Path or file-like) – The name of the input polyco file.

  • format (str, optional) – The format of the file. Default is ‘tempo’.

Methods

add_polyco_file_format(formatName, methodMood)

Add a polyco file format and its reading/writing method to the class.

eval_abs_phase(t)

Polyco evaluate absolute phase for a time array.

eval_phase(t)

Polyco evaluation of fractional phase

eval_spin_freq(t)

Polyco evaluate spin frequency for a time array.

eval_spin_freq_derivative(t)

Polyco evaluate spin frequency derivative for a time array.

find_entry(t)

Find the right entry for the input time.

generate_polycos(model, mjdStart, mjdEnd, ...)

Generate the polyco data.

read(filename[, format])

Read polyco file to a table.

read_polyco_file(filename[, format])

Read polyco file to a table.

write_polyco_file([filename, format])

Write Polyco table to a file.

Attributes

polycoFormats

classmethod read(filename, format='tempo')[source]

Read polyco file to a table.

Parameters:
  • filename (str or Path or file-like) – The name of the input polyco file.

  • format (str, optional) – The format of the file. Default is ‘tempo’.

Return type:

Polycos

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

Add a polyco file format and its reading/writing method to the class. Then register it to the table reading.

Parameters:
  • formatName (str) – The name for the format.

  • methodMood (str) – One of [‘r’, ‘w’, ‘rw’].

  • readMethod (function) – The method for reading the file format.

  • writeMethod (function) – The method for writting the file to disk.

Notes

The read/write methods should correspond to what are needed by astropy.io.registry.register_reader() and astropy.io.registry.register_writer(), respectively

read_polyco_file(filename, format='tempo')[source]

Read polyco file to a table.

Included for backward compatibility. It is better to use pint.polycos.Polycos.read().

Parameters:
  • filename (str or Path or file-like) – The name of the input polyco file.

  • format (str, optional) – The format of the file. Default is ‘tempo’.

Return type:

Polycos

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

Generate the polyco data.

Parameters:
  • model (TimingModel) – TimingModel to generate the Polycos

  • mjdStart (float, np.longdouble) – Start time of polycos in mjd

  • mjdEnd (float, np.longdouble) – Ending time of polycos in mjd

  • obs (str) – Observatory code

  • segLength (int) – Length of polyco segement [minutes]

  • ncoeff (int) – Number of coefficents

  • obsFreq (float) – Observing frequency [MHz]

  • maxha (float, optional.) – Maximum hour angle. Default 12.0. Only 12.0 is supported for now.

  • method (str, optional) – Method to generate polycos. Only the TEMPO method is supported for now.

  • numNodes (int, optional) – Number of nodes for fitting. It cannot be less then the number of coefficents. Default: 20

  • progress (bool, optional) – Whether or not to show the progress bar during calculation

Return type:

Polycos

write_polyco_file(filename='polyco.dat', format='tempo')[source]

Write Polyco table to a file.

Parameters:
  • filename (str) – The name of the polyco file. Default is ‘polyco.dat’.

  • format (str) – The format of the file. Default is ‘tempo’.

find_entry(t)[source]

Find the right entry for the input time.

Parameters:

t (numpy.ndarray or float) – A time array in MJD.

Returns:

Indices corresponding to the desired time(s)

Return type:

numpy.ndarray

Raises:

ValueError – If the input time(s) are not covered by the polycos

eval_phase(t)[source]

Polyco evaluation of fractional phase

Parameters:

t (numpy.ndarray or float) – An time array in MJD. Time sample should be in order

Returns:

Fractional phase

Return type:

numpy.ndarray

Notes

Returns fractional part of pint.polycos.Polycos.eval_abs_phase()

eval_abs_phase(t)[source]

Polyco evaluate absolute phase for a time array.

Parameters:

t (numpy.ndarray or float) – An time array in MJD. Time sample should be in order

Returns:

Polyco evaluated absolute phase for t.

Return type:

pint.phase.Phase

Notes

Calculates phase according to:

\[\phi = \phi_0 + 60 \Delta T f_0 + COEFF[1] + COEFF[2] \Delta T + COEFF[3] \Delta T^2 + \ldots\]

Calculation done using pint.polycos.PolycoEntry.evalabsphase()

eval_spin_freq(t)[source]

Polyco evaluate spin frequency for a time array.

Parameters:

t (numpy.ndarray or float) – An time array in MJD. Time samples should be in order

Returns:

Polyco evaluated spin frequency [Hz] at time t.

Return type:

numpy.ndarray

Notes

Calculates frequency according to:

\[f({\rm Hz}) = f_0 + \frac{1}{60}\left(COEFF[2] + 2 \Delta T COEFF[3] + 3 \Delta T^2 COEFF[4] + \ldots\right)\]

Calculation done using pint.polycos.PolycoEntry.evalfreq()

eval_spin_freq_derivative(t)[source]

Polyco evaluate spin frequency derivative for a time array.

Parameters:

t (numpy.ndarray or float) – An time array in MJD. Time samples should be in order

Returns:

Polyco evaluated spin frequency derivative [Hz/s] at time t.

Return type:

numpy.ndarray

Notes

Calculation done using pint.polycos.PolycoEntry.evalfreqderiv()