Time – ephemerista.time¶
The time.py module.
This module contains the Time class which is Ephemerista’s representation for points in time (epochs).
- class ephemerista.time.ISOTimestamp(*, type='iso', value)¶
A timestamp modelled as an ISO8601 string in a continuous time scale.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'populate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class ephemerista.time.JulianDateTimestamp(*, type='jd', value)¶
A timestamp modelled as a Julian Day Number.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'populate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class ephemerista.time.SecondsTimestamp(*, type='seconds', seconds, subsecond)¶
A timestamp modelled as seconds and subsecond from the J2000 epoch.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'populate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class ephemerista.time.Time(time=None, *, scale='TAI', timestamp)¶
The
Timemodel.This class models an instant in a continuous time scale based on different timestamp formats.
- property datetime: datetime¶
Convert to a datetime.datetime object.
- property day: int¶
The day.
- Type:
int
- property day_of_year: int¶
The day of the year (1-366).
- Type:
int
- classmethod from_components(scale, year, month, day, hour=0, minute=0, seconds=0.0)¶
Instantiate a Time object from its components in the given time scale.
- Parameters:
year (
int) – The year of the timestampmonth (
int) – The month of the timestampday (
int) – The day of the timestamphour (
int) – The hour of the timestamp (default 0)minute (
int) – The minute of the timestamp (default 0)seconds (
float) – The seconds of the timestamp (default 0.0)scale (
Literal['TT','TAI','TDB','TCG','TCB','UT1']) – The time scale of the timestamp
- Return type:
Self
- classmethod from_day_of_year(scale, year, day, hour=0, minute=0, seconds=0.0)¶
Instantiate a Time object from its components in the given time scale.
- Parameters:
year (
int) – The year of the timestampmonth (int) – The month of the timestamp
day (
int) – The day of the timestamphour (
int) – The hour of the timestamp (default 0)minute (
int) – The minute of the timestamp (default 0)seconds (
float) – The seconds of the timestamp (default 0.0)scale (
Literal['TT','TAI','TDB','TCG','TCB','UT1']) – The time scale of the timestamp
- Return type:
Self
- classmethod from_iso(scale, iso)¶
Instantiate a Time object from an ISO8601-formatted string in the given time scale.
- Parameters:
scale (
Literal['TT','TAI','TDB','TCG','TCB','UT1']) – The time scale of the timestampiso (
str) – An ISO8601-formatted timestamp
- Return type:
Self
- classmethod from_j2000(scale, j2000)¶
Instantiate a Time object from a Julian Date based on the J2000 epoch in the given time scale.
- Parameters:
scale (
Literal['TT','TAI','TDB','TCG','TCB','UT1']) – The time scale of the timestampjd (float) – The Julian Date of the timestamp
- Return type:
Self
- classmethod from_julian_date(scale, jd)¶
Instantiate a Time object from a Julian Date in the given time scale.
- Parameters:
scale (
Literal['TT','TAI','TDB','TCG','TCB','UT1']) – The time scale of the timestampjd (
float) – The Julian Date of the timestamp
- Return type:
Self
- classmethod from_two_part_julian_date(scale, jd1, jd2)¶
Instantiate a Time object from a two-part Julian Date in the given time scale.
- Parameters:
scale (
Literal['TT','TAI','TDB','TCG','TCB','UT1']) – The time scale of the timestampjd1 (
float) – The first part of the Julian Datejd2 (
float) – The second part of the Julian Date
- Return type:
Self
- classmethod from_utc(utc)¶
Instantiate a Time object from an ISO8601-formatted string in the UTC scale.
The returned Time object will be in the TAI scale.
- Parameters:
scale (Scale) – The time scale of the timestamp
iso (str) – An ISO8601-formatted timestamp
- Return type:
Self
- property hour: int¶
The hour.
- Type:
int
- isclose(other, atol=1e-09, rtol=1e-08)¶
Check if two Time objects are equal within a given tolerance.
- Return type:
bool
- property j2000: float¶
The Julian Day number with epoch J2000.
- Type:
float
- property julian_date: float¶
The Julian Day number.
- Type:
float
- property minute: int¶
The minute.
- Type:
int
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'frozen': True, 'populate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- property month: int¶
The month.
- Type:
int
- property second: int¶
The second.
- Type:
int
- property seconds: float¶
Second and subsecond as a decimal number.
- Type:
float
- to_scale(scale)¶
Convert the Time object to a different time scale.
- Parameters:
scale (
Literal['TT','TAI','TDB','TCG','TCB','UT1']) – The time scale to convert the Time object to- Return type:
- to_utc()¶
Convert the Time object to a UTC-formatted string.
- Return type:
str
- trange(end, step=1)¶
Generate a range of Time objects between the current Time object and the end Time object.
- Parameters:
end (
Self) – The end of the rangestep (
float) – The step size in seconds
- Return type:
list[Time]
- trange_fast(end, step=1)¶
Generate a range of Time objects between the current Time object and the end Time object.
Optimized version that creates Time objects more efficiently.
- Parameters:
end (
Self) – The end of the rangestep (
float) – The step size in seconds
- Return type:
list[Time]
- property two_part_julian_date: tuple[float, float]¶
The Julian Day number split into two parts.
- Type:
tuple[float, float]
- property year: int¶
The year.
- Type:
int
- class ephemerista.time.UTCTimestamp(*, type='utc', value)¶
A timestamp modelled as an ISO8601 string in UTC.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'populate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].