astro py:docs

- Index
- Modules

### Navigation

- next »
- « previous |
- Astropy v0.3 »
- Time and Dates (`astropy.time`) »
- Time

# Time

class `astropy.time.core.``Time`(val, val2=None, format=None, scale=None, precision=None, in_subfmt=None, out_subfmt=None, lat=0.0, lon=0.0, copy=False)

  Bases: `object`

  Represent and manipulate times and dates for astronomy.

  A `Time` object is initialized with one or more times in the `val` argument. The input times in `val` must conform to the specified `format` and must correspond to the specified time `scale`. The optional `val2` time input should be supplied only for numeric input formats (e.g. JD) where very high precision (better than 64-bit precision) is required.

  Parameters:

  val : sequence, str, number, or `Time` object

  > Value(s) to initialize the time or times.

  val2 : sequence, str, or number; optional

  > Value(s) to initialize the time or times.

  format : str, optional

  > Format of input value(s)

  scale : str, optional

  > Time scale of input value(s)

  precision : int, optional

  > Digits of precision in string representation of time

  in_subfmt : str, optional

  > Subformat for inputting string times

  out_subfmt : str, optional

  > Subformat for outputting string times

  lat : float, optional

  > Earth latitude of observer (decimal degrees)

  lon : float, optional

  > Earth longitude of observer (decimal degrees)

  copy : bool, optional

  > Make a copy of the input values

  Attributes Summary

  `FORMATS` |
  `SCALES` | tuple() -> empty tuple
  `delta_tdb_tt` |
  `delta_ut1_utc` | Get ERFA DUT arg = UT1 - UTC.
  `format` | Time format
  `in_subfmt` | Unix wildcard pattern to select subformats for parsing string input
  `is_scalar` | Deprecated since version 0.3.
  `jd1` | First of the two doubles that internally store time value(s) in JD
  `jd2` | Second of the two doubles that internally store time value(s) in JD
  `out_subfmt` | Unix wildcard pattern to select subformats for outputting times
  `precision` | Decimal precision when outputting seconds as floating point (int value between 0 and 9 inclusive).
  `scale` | Time scale
  `val` | Deprecated since version 0.3.
  `vals` | Deprecated since version 0.3.
  `value` | Time value(s) in current format

  Methods Summary

  `copy`([format]) | Return a fully independent copy the Time object, optionally changing the format.
  `get_delta_ut1_utc`([iers_table, return_status]) | Find UT1 - UTC differences by interpolating in IERS Table.
  `now`() | Creates a new object corresponding to the instant in time this method is called.
  `replicate`([format, copy]) | Return a replica of the Time object, optionally changing the format.

  Attributes Documentation

  `FORMATS` = {u'mjd': <class 'astropy.time.core.TimeMJD'>, u'cxcsec': <class 'astropy.time.core.TimeCxcSec'>, u'jyear': <class 'astropy.time.core.TimeJulianEpoch'>, u'plot_date': <class 'astropy.time.core.TimePlotDate'>, u'astropy_time': <class 'astropy.time.core.TimeAstropyTime'>, u'byear': <class 'astropy.time.core.TimeBesselianEpoch'>, u'unix': <class 'astropy.time.core.TimeUnix'>, u'datetime': <class 'astropy.time.core.TimeDatetime'>, u'jd': <class 'astropy.time.core.TimeJD'>, u'byear_str': <class 'astropy.time.core.TimeBesselianEpochString'>, u'iso': <class 'astropy.time.core.TimeISO'>, u'isot': <class 'astropy.time.core.TimeISOT'>, u'jyear_str': <class 'astropy.time.core.TimeJulianEpochString'>, u'yday': <class 'astropy.time.core.TimeYearDayTime'>, u'gps': <class 'astropy.time.core.TimeGPS'>}

    Dict of time formats

  `SCALES` = (u'tai', u'tcb', u'tcg', u'tdb', u'tt', u'ut1', u'utc')

    List of time scales

  `delta_tdb_tt`

    TDB - TT time scale offset

  `delta_ut1_utc`

    UT1 - UTC time scale offset

  `format`

    Time format

  `in_subfmt`

    Unix wildcard pattern to select subformats for parsing string input times

  `is_scalar`

    Deprecated since version 0.3: The is_scalar attribute is deprecated and may be removed in a future version.

  `jd1`

    First of the two doubles that internally store time value(s) in JD

  `jd2`

    Second of the two doubles that internally store time value(s) in JD

  `out_subfmt`

    Unix wildcard pattern to select subformats for outputting times

  `precision`

    Decimal precision when outputting seconds as floating point (int value between 0 and 9 inclusive).

  `scale`

    Time scale

  `val`

    Deprecated since version 0.3: Use value instead.

  `vals`

    Deprecated since version 0.3: Use value instead.

    Time values in current format as a numpy array

  `value`

    Time value(s) in current format

  Methods Documentation

  `copy`(format=None)

    Return a fully independent copy the Time object, optionally changing the format.

    If `format` is supplied then the time format of the returned Time object will be set accordingly, otherwise it will be unchanged from the original.

    In this method a full copy of the internal time arrays will be made. The internal time arrays are normally not changeable by the user so in most cases the `replicate()` method should be used.

    Parameters:

    format : str, optional

    > Time format of the copy.

    Returns:

    tm: Time object :

    > Copy of this object

  `get_delta_ut1_utc`(iers_table=None, return_status=False)

    Find UT1 - UTC differences by interpolating in IERS Table.

    Parameters:

    iers_table : `IERS` table, optional

    > Table containing UT1-UTC differences from IERS Bulletins A and/or B If None, use default version (see `iers`)

    return_status : bool

    > Whether to return status values. If `False` (default), iers raises `IndexError` if any time is out of the range covered by the IERS table.

    Returns:

    ut1_utc: float or float array :

    > UT1-UTC, interpolated in IERS Table

    status: int or int array :

    > Status values (if `return_status`=`True`):: `FROM_IERS_B` `FROM_IERS_A` `FROM_IERS_A_PREDICTION` `TIME_BEFORE_IERS_RANGE` `TIME_BEYOND_IERS_RANGE`

    Notes

    In normal usage, UT1-UTC differences are calculated automatically on the first instance ut1 is needed.

    Examples

    To check in code whether any times are before the IERS table range:

        >>> from astropy.utils.iers import TIME_BEFORE_IERS_RANGE
        >>> t = Time(['1961-01-01', '2000-01-01'], scale='utc')
        >>> delta, status = t.get_delta_ut1_utc(return_status=True)
        >>> status == TIME_BEFORE_IERS_RANGE
        array([ True, False], dtype=bool)

    To use an updated IERS A bulletin to calculate UT1-UTC (see also `iers`):

        >>> from astropy.utils.iers import IERS_A, IERS_A_URL
        >>> from astropy.utils.data import download_file
        >>> iers_a_file = download_file(IERS_A_URL,
        ...                             cache=True)
        >>> iers_a = IERS_A.open(iers_a_file)
        >>> t.delta_ut1_utc = t.get_delta_ut1_utc(iers_a)

    The delta_ut1_utc property will be used to calculate t.ut1; raises IndexError if any of the times is out of range.

  classmethod `now`()

    Creates a new object corresponding to the instant in time this method is called.

    Note

    “Now” is determined using the `datetime.utcnow` function, so its accuracy and precision is determined by that function. Generally that means it is set by the accuracy of your system clock.

    Returns:

    nowtime :

    > A new `Time` object (or a subclass of `Time` if this is called from such a subclass) at the current time.

  `replicate`(format=None, copy=False)

    Return a replica of the Time object, optionally changing the format.

    If `format` is supplied then the time format of the returned Time object will be set accordingly, otherwise it will be unchanged from the original.

    If `copy` is set to True then a full copy of the internal time arrays will be made. By default the replica will use a reference to the original arrays when possible to save memory. The internal time arrays are normally not changeable by the user so in most cases it should not be necessary to set `copy` to True.

    The convenience method copy() is available in which `copy` is True by default.

    Parameters:

    format : str, optional

    > Time format of the replica.

    copy : bool, optional

    > Return a true copy instead of using references where possible.

    Returns:

    tm: Time object :

    > Replica of this object