to_gps#
- gwpy.time.to_gps(
- t: LIGOTimeGPSLike | SupportsFloat | date | Time | str,
- *,
- tzinfo: tzinfo = datetime.timezone.utc,
Convert any input date/time into a
LIGOTimeGPS.Any input object that can be cast as a
Time(withstrgoing through thedatetime.datetime) are acceptable.- Parameters:
- t
float,datetime,Time,str The input time, any object that can be converted into a
LIGOTimeGPS,Time, ordatetime, is acceptable.- tzinfo
datetime.tzinfo, Timezone information to attach to
tupleinputs that becomedatetime.datetimeobjects. Defaults todatetime.UTC.
- t
- Returns:
- gps
LIGOTimeGPS The number of GPS seconds (non-integer) since the start of the epoch (January 6 1980).
- gps
- Raises:
TypeErrorIf a
strinput cannot be parsed as adatetime.datetime.ValueErrorIf the input cannot be cast as a
TimeorLIGOTimeGPS.
Examples
>>> to_gps("Jan 1 2017") LIGOTimeGPS(1167264018, 0) >>> to_gps("Sep 14 2015 09:50:45.391") LIGOTimeGPS(1126259462, 391000000)
>>> import datetime >>> to_gps(datetime.datetime(2017, 1, 1)) LIGOTimeGPS(1167264018, 0)
>>> from astropy.time import Time >>> to_gps(Time(57754, format="mjd")) LIGOTimeGPS(1167264018, 0)