Python interface to the TPM C library

PyTPM is a Python interface to the Telescope Pointing Machine (TPM) library. TPM is a C library written by Jeffrey W. Percival, for performing coordinate conversions between several astronomical coordinate systems.

Python interface to TPM C code is written using Cython.

TPM was designed with the aim of incorporating it into telescope control systems. To meet this design goal, TPM offers control over calculations carried out during coordinate conversions. Some of these calculations must be performed frequently, for example time related calculations. Others need to be performed only once per night, for example nutation and precession matrices. In general, the former class of quantities are easier to calculate than the latter. TPM allows the user to select the exact calculations to be performed, for a given coordinate conversion. This enables the user to control the computational load, which is important in telescope control systems. TPM C library is used by the KPNO WIYN observatory and the WHAM projects.

TPM is also useful outside telescope control system. It can be very useful for converting a large catalog of coordinates. In such cases, the “star independent” quantities, which tend to be computational expensive to calculate, can be calculated just once for the entire catalog. This will make coordinate conversions faster.

PyTPM is not a complete astrometry package. The aim is to provide access to the TPM C code from Python. TPM machinery can be directly accessed using the pytpm.tpm sub-module. The sub-module pytpm.convert has several convenience functions that can be used for performing coordinate conversions. The latter is sufficient for most, but not all, calculations.

Users must read the TPM manual before attempting to use the pytpm.tpm module.

PyTPM has been tested on Python versions 2.6, 2.7 and 3.2. Distribute is required for installing PyTPM. Cython is not required, unless the Cython code is modified and needs to be re-compiled. Nose is required for running tests. Sphinx and the numpydoc Sphinx extension are required for building documentation from ReST source.

PyTPM can be downloaded from the pypi page for the project. Documentation in HTML format can also be downloaded from the above page. HTML documentation can be viewed at

PyTPM can also be installed using pip or easy_install. Use

$ pip install pytpm

See Installation for detailed instructions on installing PyTPM.

The source code repository for PyTPM is at The repository can be cloned using git, or a copy can be downloaded using the Download button on the above website.

Important notes

  1. The file src/tpm/delta_AT.c must be updated when Delta AT (DAT = TAI - UTC) is changed by the IERS, and PyTPM Cython code must re-compiled. See Time scales and calendars, for ways to get updated values for this quantity. A new version of PyTPM will be released when this change occurs.
  2. TPM uses built-in ephemerides for the Earth and Sun, and a built-in model for calculating dynamic and rotational time.


Information on installing PyTPM can be found in Installation.

For examples of converting positions and velocities see Coordinate conversions using TPM and PyTPM. Please read the TPM manual before using the advanced facilities of PyTPM.

For a detailed list of functions and constants defined in PyTPM, see the section on Functions and constants in PyTPM. For detailed information on the data structures defined in PyTPM, see the section on Data Structures.

See Comparison of PyTPM with SLALIB for a comparison of results obtained using PyTPM, with that obtained using SLALIB (pyslalib).

The document Astrometry Resources presents links to astrometry resources.

Credits and license

Jeffrey W. Percival wrote the TPM C library. See src/tpm/TPM_LICENSE.txt for TPM license.

The version used here was obtained from the coords package (version 0.36) of the astrolib library. Some C source files missing from the above source were provided by Jeff Percival.

Python and Cython code for PyTPM is released under the BSD license; see LICENSE.txt.

Please send email to prasanthhn, at the domain, for reporting errors, and for comments and suggestions.

Indices and tables

Table Of Contents

Next topic


This Page