開発版ドキュメント · 0.2.3 30c2f8ba · 入門例の検証対象 0.2.3 · 版情報 · 既知の制限

Time (gwexpy.time)#

gwexpy.time.from_gps(gps, *args, **kwargs)

Convert a given GPS time or array of GPS times to datetime objects.

This is a vectorized extension of gwpy.time.from_gps. It supports single scalar GPS times as well as arrays, pandas Series, and lists.

パラメータ:
  • gps (float, int, astropy.time.Time, or array-like) -- The input GPS time(s) to convert.

  • *args -- Additional positional arguments passed to gwpy.time.from_gps.

  • **kwargs -- Additional keyword arguments passed to gwpy.time.from_gps.

戻り値:

The equivalent UTC datetime object. Returns a datetime for scalar inputs and a numpy.ndarray of datetime objects for array-like inputs.

戻り値の型:

datetime.datetime or numpy.ndarray

gwexpy.time.tconvert(gpsordate: SupportsToGps = 'now', *args, t=<omitted>, **kwargs)

Convert a time between GPS seconds and UTC datetime.

This function automatically detects the type of the input. If it is numeric (or an array of numbers), it is assumed to be a GPS time and is converted to a datetime (like from_gps). If the input is a string, datetime, or an array of those types, it is converted to GPS seconds (like to_gps).

パラメータ:
  • gpsordate (numeric, str, datetime.datetime, array-like, optional) -- The input time(s) to convert. Defaults to "now".

  • *args -- Additional positional arguments passed to the underlying converter.

  • t (numeric, str, datetime.datetime, array-like, optional) -- GWexpy compatibility alias for gpsordate. Supplying both names is an error.

  • **kwargs -- Additional keyword arguments passed to the underlying converter.

戻り値:

The converted time. The return type depends on the input type.

戻り値の型:

float, datetime.datetime, or numpy.ndarray

gwexpy.time.to_gps(t, *args, dtype=None, **kwargs)

Convert a given time or array of times to GPS seconds.

This is a vectorized extension of gwpy.time.to_gps. It supports single values (strings, datetime, etc.) as well as arrays, pandas Series, and lists.

パラメータ:
  • t (str, datetime.datetime, astropy.time.Time, or array-like) -- The input time(s) to convert. Supported formats include UTC strings, datetime objects, pandas Timestamps, or arrays of these types.

  • *args -- Additional positional arguments passed to gwpy.time.to_gps.

  • dtype ({None, float, "float", "quantity"}, optional) -- Output mode for the converted GPS seconds. None preserves exact LIGOTimeGPS elements for NumPy datetime64 inputs; other inputs preserve the existing GWpy-compatible behavior. float or "float" returns Python float for scalar inputs and numpy.ndarray for array-like inputs. "quantity" returns an astropy.units.Quantity in seconds, which can be compared with GWpy/GWExpy time axes.

  • **kwargs -- Additional keyword arguments passed to gwpy.time.to_gps.

戻り値:

The equivalent time in GPS seconds. With dtype=None, NumPy datetime64 scalars return LIGOTimeGPS and arrays return object arrays of exact LIGOTimeGPS elements. With dtype=float or dtype="float", returns numeric seconds. With dtype="quantity", returns seconds as an astropy.units.Quantity.

戻り値の型:

object

class gwexpy.time.LIGOTimeGPS

ベースクラス: SwigPyObject

::tagLIGOTimeGPS

asutcstr(LIGOTimeGPS self) char *
gpsNanoSeconds

INT4

Type:

gpsNanoSeconds

gpsSeconds

INT4

Type:

gpsSeconds

ns(LIGOTimeGPS self) INT8
this
thisown
class gwexpy.time.LIGOTimeGPSLike(new: float | LIGOTimeGPS | str)

ベースクラス: Protocol

Protocol for types that are implementations of LIGOTimeGPS.

This is used for type hinting functions that can accept lal.LIGOTimeGPS, or ligotimegps.LIGOTimeGPS, or any other implementation of the LIGOTimeGPS standard.

This can also be used at runtime with isinstance to check if an object is a LIGOTimeGPS-like object, but cannot be used with issubclass.

gpsSeconds: int
gpsNanoSeconds: int
class gwexpy.time.Time(val, val2=None, format=None, scale=None, precision=None, in_subfmt=None, out_subfmt=None, location=None, copy=False)

ベースクラス: TimeBase

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.

The allowed values for format can be listed with:

>>> list(Time.FORMATS)
['jd', 'mjd', 'decimalyear', 'unix', 'unix_tai', 'cxcsec', 'galexsec', 'gps',
 'plot_date', 'stardate', 'datetime', 'ymdhms', 'iso', 'isot', 'yday', 'datetime64',
 'fits', 'byear', 'jyear', 'byear_str', 'jyear_str']

See also: http://docs.astropy.org/en/stable/time/

パラメータ:
  • val (sequence, ndarray, number, str, bytes, or ~astropy.time.Time object) -- Value(s) to initialize the time or times. Bytes are decoded as ascii.

  • val2 (sequence, ndarray, or number; optional) -- Value(s) to initialize the time or times. Only used for numerical input, to help preserve precision.

  • format (str, optional) -- Format of input value(s), specifying how to interpret them (e.g., ISO, JD, or Unix time). By default, the same format will be used for output representation.

  • scale (str, optional) -- Time scale of input value(s), must be one of the following: ('tai', 'tcb', 'tcg', 'tdb', 'tt', 'ut1', 'utc')

  • precision (int, optional) -- Digits of precision in string representation of time

  • in_subfmt (str, optional) -- Unix glob to select subformats for parsing input times

  • out_subfmt (str, optional) -- Unix glob to select subformat for outputting times

  • location (~astropy.coordinates.EarthLocation or tuple, optional) -- If given as an tuple, it should be able to initialize an an EarthLocation instance, i.e., either contain 3 items with units of length for geocentric coordinates, or contain a longitude, latitude, and an optional height for geodetic coordinates. Can be a single location, or one for each input time. If not given, assumed to be the center of the Earth for time scale transformations to and from the solar-system barycenter.

  • copy (bool, optional) -- Make a copy of the input values

FORMATS = {'byear': <class 'astropy.time.formats.TimeBesselianEpoch'>, 'byear_str': <class 'astropy.time.formats.TimeBesselianEpochString'>, 'cxcsec': <class 'astropy.time.formats.TimeCxcSec'>, 'datetime': <class 'astropy.time.formats.TimeDatetime'>, 'datetime64': <class 'astropy.time.formats.TimeDatetime64'>, 'decimalyear': <class 'astropy.time.formats.TimeDecimalYear'>, 'fits': <class 'astropy.time.formats.TimeFITS'>, 'galexsec': <class 'astropy.time.formats.TimeGalexSec'>, 'gps': <class 'astropy.time.formats.TimeGPS'>, 'iso': <class 'astropy.time.formats.TimeISO'>, 'isot': <class 'astropy.time.formats.TimeISOT'>, 'jd': <class 'astropy.time.formats.TimeJD'>, 'jyear': <class 'astropy.time.formats.TimeJulianEpoch'>, 'jyear_str': <class 'astropy.time.formats.TimeJulianEpochString'>, 'mjd': <class 'astropy.time.formats.TimeMJD'>, 'plot_date': <class 'astropy.time.formats.TimePlotDate'>, 'stardate': <class 'astropy.time.formats.TimeStardate'>, 'unix': <class 'astropy.time.formats.TimeUnix'>, 'unix_tai': <class 'astropy.time.formats.TimeUnixTai'>, 'yday': <class 'astropy.time.formats.TimeYearDayTime'>, 'ymdhms': <class 'astropy.time.formats.TimeYMDHMS'>}

Dict of time formats

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

List of time scales

property delta_tdb_tt
property delta_ut1_utc

Get ERFA DUT arg = UT1 - UTC. This getter takes optional jd1 and jd2 args because it gets called that way when converting time scales. If delta_ut1_utc is not yet set, this will interpolate them from the the IERS table.

earth_rotation_angle(longitude=None)

Calculate local Earth rotation angle.

パラメータ:

longitude (~astropy.units.Quantity, ~astropy.coordinates.EarthLocation, str, or None; optional) -- The longitude on the Earth at which to compute the Earth rotation angle (taken from a location as needed). If None (default), taken from the location attribute of the Time instance. If the special string 'tio', the result will be relative to the Terrestrial Intermediate Origin (TIO) (i.e., the output of ~erfa.era00).

戻り値:

Local Earth rotation angle with units of hourangle.

戻り値の型:

~astropy.coordinates.Longitude

参照

IAU 2006 NFA Glossary (currently located at: https://syrte.obspm.fr/iauWGnfa/NFA_Glossary.html)

メモ

The difference between apparent sidereal time and Earth rotation angle is the equation of the origins, which is the angle between the Celestial Intermediate Origin (CIO) and the equinox. Applying apparent sidereal time to the hour angle yields the true apparent Right Ascension with respect to the equinox, while applying the Earth rotation angle yields the intermediate (CIRS) Right Ascension with respect to the CIO.

The result includes the TIO locator (s'), which positions the Terrestrial Intermediate Origin on the equator of the Celestial Intermediate Pole (CIP) and is rigorously corrected for polar motion. (except when longitude='tio').

get_delta_ut1_utc(iers_table=None, return_status=False)

Find UT1 - UTC differences by interpolating in IERS Table.

パラメータ:
  • iers_table (~astropy.utils.iers.IERS, optional) -- Table containing UT1-UTC differences from IERS Bulletins A and/or B. Default: ~astropy.utils.iers.earth_orientation_table (which in turn defaults to the combined version provided by ~astropy.utils.iers.IERS_Auto).

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

戻り値:

  • ut1_utc (float or float array) -- UT1-UTC, interpolated in IERS Table

  • status (int or int array) --

    Status values (if return_status=`True`)::

    astropy.utils.iers.FROM_IERS_B astropy.utils.iers.FROM_IERS_A astropy.utils.iers.FROM_IERS_A_PREDICTION astropy.utils.iers.TIME_BEFORE_IERS_RANGE astropy.utils.iers.TIME_BEYOND_IERS_RANGE

メモ

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

サンプル

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]...)
info

Container for meta information like name, description, format. This is required when the object is used as a mixin column within a table, but can be used as a general way to store meta information.

light_travel_time(skycoord, kind='barycentric', location=None, ephemeris=None)

Light travel time correction to the barycentre or heliocentre.

The frame transformations used to calculate the location of the solar system barycentre and the heliocentre rely on the erfa routine epv00, which is consistent with the JPL DE405 ephemeris to an accuracy of 11.2 km, corresponding to a light travel time of 4 microseconds.

The routine assumes the source(s) are at large distance, i.e., neglects finite-distance effects.

パラメータ:
  • skycoord (~astropy.coordinates.SkyCoord) -- The sky location(s) to calculate the correction for.

  • kind (str, optional) -- 'barycentric' (default) or 'heliocentric'

  • location (~astropy.coordinates.EarthLocation, optional) -- The location(s) of the observatory to calculate the correction for. If no location is given, the location attribute of the Time object is used

  • ephemeris (str, optional) -- Solar system ephemeris to use (e.g., 'builtin', 'jpl'). By default, use the one set with astropy.coordinates.solar_system_ephemeris.set. For more information, see ~astropy.coordinates.solar_system_ephemeris.

戻り値:

time_offset -- The time offset between the barycentre or Heliocentre and Earth, in TDB seconds. Should be added to the original time to get the time in the Solar system barycentre or the Heliocentre. Also, the time conversion to BJD will then include the relativistic correction as well. The shape will be the broadcast shape of skycoord and location.

戻り値の型:

~astropy.time.TimeDelta

mean(axis=None, dtype=None, out=None, keepdims=False, *, where=True)
classmethod now()

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

注釈

"Now" is determined using the ~datetime.datetime.now function, so its accuracy and precision is determined by that function. Generally that means it is set by the accuracy of your system clock. The timezone is set to UTC.

戻り値:

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

戻り値の型:

Time

sidereal_time(kind, longitude=None, model=None)

Calculate sidereal time.

パラメータ:
  • kind (str) -- 'mean' or 'apparent', i.e., accounting for precession only, or also for nutation.

  • longitude (~astropy.units.Quantity, ~astropy.coordinates.EarthLocation, str, or None; optional) -- The longitude on the Earth at which to compute the Earth rotation angle (taken from a location as needed). If None (default), taken from the location attribute of the Time instance. If the special string 'greenwich' or 'tio', the result will be relative to longitude 0 for models before 2000, and relative to the Terrestrial Intermediate Origin (TIO) for later ones (i.e., the output of the relevant ERFA function that calculates greenwich sidereal time).

  • model (str or None; optional) -- Precession (and nutation) model to use. The available ones are: - apparent: ['IAU1994', 'IAU2000A', 'IAU2000B', 'IAU2006A'] - mean: ['IAU1982', 'IAU2000', 'IAU2006'] If None (default), the last (most recent) one from the appropriate list above is used.

戻り値:

Local sidereal time, with units of hourangle.

戻り値の型:

~astropy.coordinates.Longitude

参照

IAU 2006 NFA Glossary (currently located at: https://syrte.obspm.fr/iauWGnfa/NFA_Glossary.html)

メモ

The difference between apparent sidereal time and Earth rotation angle is the equation of the origins, which is the angle between the Celestial Intermediate Origin (CIO) and the equinox. Applying apparent sidereal time to the hour angle yields the true apparent Right Ascension with respect to the equinox, while applying the Earth rotation angle yields the intermediate (CIRS) Right Ascension with respect to the CIO.

For the IAU precession models from 2000 onwards, the result includes the TIO locator (s'), which positions the Terrestrial Intermediate Origin on the equator of the Celestial Intermediate Pole (CIP) and is rigorously corrected for polar motion (except when longitude='tio' or 'greenwich').

strftime(format_spec)

Convert Time to a string or a numpy.array of strings according to a format specification. See time.strftime documentation for format specification.

パラメータ:

format_spec (str) -- Format definition of return string.

戻り値:

formatted -- String or numpy.array of strings formatted according to the given format string.

戻り値の型:

str or numpy.array

classmethod strptime(time_string, format_string, **kwargs)

Parse a string to a Time according to a format specification. See time.strptime documentation for format specification.

>>> Time.strptime('2012-Jun-30 23:59:60', '%Y-%b-%d %H:%M:%S')
<Time object: scale='utc' format='isot' value=2012-06-30T23:59:60.000>
パラメータ:
  • time_string (str, sequence, or ndarray) -- Objects containing time data of type string

  • format_string (str) -- String specifying format of time_string.

  • kwargs (dict) -- Any keyword arguments for Time. If the format keyword argument is present, this will be used as the Time format.

戻り値:

time_obj -- A new ~astropy.time.Time object corresponding to the input time_string.

戻り値の型:

~astropy.time.Time

to_datetime(timezone=None, leap_second_strict='raise')

Convert to (potentially timezone-aware) ~datetime.datetime object.

If timezone is not None, return a timezone-aware datetime object.

Since the ~datetime.datetime class does not natively handle leap seconds, the behavior when converting a time within a leap second is controlled by the leap_second_strict argument. For example:

>>> from astropy.time import Time
>>> t = Time("2015-06-30 23:59:60.500")
>>> print(t.to_datetime(leap_second_strict='silent'))
2015-07-01 00:00:00.500000
パラメータ:
  • timezone ({~datetime.tzinfo, None}, optional) -- If not None, return timezone-aware datetime.

  • leap_second_strict (str, optional) -- If raise (default), raise an exception if the time is within a leap second. If warn then issue a warning. If silent then silently handle the leap second.

戻り値:

If timezone is not None, output will be timezone-aware.

戻り値の型:

~datetime.datetime

Classes#

Time(val[, val2, format, scale, precision, ...])

Represent and manipulate times and dates for astronomy.

LIGOTimeGPS

::tagLIGOTimeGPS

Functions#

to_gps(t, *args[, dtype])

Convert a given time or array of times to GPS seconds.

from_gps(gps, *args, **kwargs)

Convert a given GPS time or array of GPS times to datetime objects.

tconvert([gpsordate, t])

Convert a time between GPS seconds and UTC datetime.