pint.observatory.clock_file.GlobalClockFile

class pint.observatory.clock_file.GlobalClockFile(filename, format='tempo', url_base=None, url_mirrors=None, **kwargs)[source]

Bases: ClockFile

Clock file obtained from a global repository.

These clock files are downloaded from a global repository; if a TOA is encountered past the end of the current version, the code will reach out to the global repository looking for a new version.

This supports both TEMPO- and TEMPO2-format files; just instantiate the object with appropriate arguments and it will call pint.observatory.ClockFile.read() with the right arguments.

Parameters:
  • filename (str) – The name of the file in the global repository

  • format (str) – The name of the format of the file, probably “tempo” or “tempo2”

  • url_base (str or None) – Location of the global repository (useful for testing)

  • url_mirrors (list of str or None) – Mirrors of the global repository (useful for testing)

Methods

evaluate(t[, limits])

Evaluate the clock corrections at the times t.

export(filename)

Write this clock correction file to the specified location.

last_correction_mjd()

Last MJD for which corrections are available.

merge(clocks, *[, trim])

Compute clock correction information for a combination of clocks.

read(filename[, format])

Read file, selecting an appropriate subclass based on format.

update()

Download a new version of a clock file if appropriate.

write_tempo2_clock_file(filename[, hdrline, ...])

Write clock corrections as a TEMPO2-format clock correction file.

write_tempo_clock_file(filename, obscode[, ...])

Write clock corrections as a TEMPO-format clock correction file.

Attributes

clock

An astropy.units.Quantity recording the amounts of clock correction.

comments

leading_comment

time

An astropy.time.Time recording the dates of clock corrections.

update()[source]

Download a new version of a clock file if appropriate.

An update is appropriate if the last-downloaded version is older than the update frequency specified in index.txt. This function should not be called unless data outside the range available in the already present clock file is requested, or if the user explicitly requests a new version.

evaluate(t, limits='warn')[source]

Evaluate the clock corrections at the times t.

By default, values are linearly interpolated but this could be overridden by derived classes if needed. The first/last values will be applied to times outside the data range. If limits==’warn’ this will also issue a warning. If limits==’error’ an exception will be raised.

Parameters:
  • t (astropy.time.Time) – An array-valued Time object specifying the times at which to evaluate the clock correction.

  • limits ("warn" or "error") – If “error”, raise an exception if times outside the range in the clock file are presented (or if the clock file is empty); if “warn”, extrapolate by returning the value at the nearest endpoint but emit a warning.

Returns:

corrections – The corrections in units of microseconds.

Return type:

astropy.units.Quantity

property time

An astropy.time.Time recording the dates of clock corrections.

property clock

An astropy.units.Quantity recording the amounts of clock correction.

export(filename)[source]

Write this clock correction file to the specified location.

last_correction_mjd()

Last MJD for which corrections are available.

static merge(clocks, *, trim=True)

Compute clock correction information for a combination of clocks.

This combines the clock correction files to produce a single file that produces clock corrections that are the sum of the original input files. For example, one could combine ao2gps.clk and gps2utc.clk to produce ao2utc.clk.

Note that clock correction files can specify discontinuities by repeating MJDs. This merged object should accurately propagate these discontinuities.

Parameters:

trim (bool) – Whether to trim the resulting clock file to the MJD range covered by both input clock files.

Returns:

A merged ClockFile object.

Return type:

ClockFile

classmethod read(filename, format='tempo', **kwargs)

Read file, selecting an appropriate subclass based on format.

Any additional keyword arguments are passed to the appropriate reader function.

write_tempo2_clock_file(filename, hdrline=None, extra_comment=None)

Write clock corrections as a TEMPO2-format clock correction file.

Parameters:
  • filename (str or pathlib.Path or file-like) – The destination

  • hdrline (str) – The first line of the file. Should start with # and consist of a pair of timescales, like UTC(AO) UTC(GPS) that this clock file transforms between. If no value is provided, the value of self.header is used.

  • extra_comment (str) – Additional comments to include. Lines should probably start with # so they will be interpreted as comments. This field frequently contains details of the origin of the file, or at least the commands used to convert it from its original format.

write_tempo_clock_file(filename, obscode, extra_comment=None)

Write clock corrections as a TEMPO-format clock correction file.

Parameters:
  • filename (str or pathlib.Path or file-like) – The destination

  • obscode (str) – The TEMPO observatory code. TEMPO effectively concatenates all its clock corrections and uses this field to determine which observatory the clock corrections are relevant to. TEMPO observatory codes are case-insensitive one-character values agreed upon by convention and occurring in tim files. PINT recognizes these as aliases of observatories for which they are agreed upon, and an Observatory object contains a field that can be used to retrieve this.

  • comments (str) – Additional comments to include. These will be included below the headings and each line should be prefaced with # to avoid conflicting with the clock corrections.