Skip to content

Epoch Class

The Epoch class is the foundational time representation in Brahe, providing comprehensive support for multiple time systems and high-precision time computations with nanosecond accuracy.

Epoch

Epoch()

Represents a specific instant in time.

Epoch is the primary and preferred mechanism for representing time in brahe. It accurately represents, tracks, and compares instants in time with nanosecond precision.

Internally, Epoch stores time in terms of days, seconds, and nanoseconds. This representation was chosen to enable accurate time system conversions using the IAU SOFA library (which operates in days and fractional days) while maintaining high precision for small time differences. The structure uses Kahan summation to accurately handle running sums over long periods without losing accuracy to floating-point rounding errors.

All arithmetic operations (addition, subtraction) use seconds as the default unit and return time differences in seconds.

The Epoch constructor accepts multiple input formats for convenience:

  • Date components: Epoch(year, month, day) - creates epoch at midnight
  • Full datetime: Epoch(year, month, day, hour, minute, second, nanosecond) - full precision
  • Partial datetime: Epoch(year, month, day, hour) or Epoch(year, month, day, hour, minute) etc.
  • ISO 8601 string: Epoch("2024-01-01T12:00:00Z") - parse from string
  • Python datetime: Epoch(datetime_obj) - convert from Python datetime
  • Copy constructor: Epoch(other_epoch) - create a copy
  • Time system: All constructors accept optional time_system= keyword argument (default: UTC)
Example
import brahe as bh
from datetime import datetime

# Multiple ways to create the same epoch
epc1 = bh.Epoch(2024, 1, 1, 12, 0, 0.0, 0.0)
epc2 = bh.Epoch("2024-01-01 12:00:00.000 UTC")
epc3 = bh.Epoch(datetime(2024, 1, 1, 12, 0, 0))
print(epc1)
# Output: 2024-01-01 12:00:00.000 UTC

# Create epoch at midnight
midnight = bh.Epoch(2024, 1, 1)
print(midnight)
# Output: 2024-01-01 00:00:00.000 UTC

# Use different time systems
gps_time = bh.Epoch(2024, 1, 1, 12, 0, 0.0, 0.0, time_system=bh.GPS)
print(gps_time)
# Output: 2024-01-01 12:00:00.000 GPS

# Perform arithmetic operations
epoch2 = epc1 + 3600.0  # Add one hour (in seconds)
diff = epoch2 - epc1     # Difference in seconds
print(f"Time difference: {diff} seconds")
# Output: Time difference: 3600.0 seconds

# Legacy constructors still available
epc4 = bh.Epoch.from_datetime(2024, 1, 1, 12, 0, 0.0, 0.0, bh.UTC)
epc5 = bh.Epoch.from_jd(2460310.0, bh.UTC)

Initialize instance.

__doc__ class-attribute

__doc__ = 'Represents a specific instant in time.\n\nEpoch is the primary and preferred mechanism for representing time in brahe.\nIt accurately represents, tracks, and compares instants in time with nanosecond precision.\n\nInternally, Epoch stores time in terms of days, seconds, and nanoseconds. This representation\nwas chosen to enable accurate time system conversions using the IAU SOFA library (which operates\nin days and fractional days) while maintaining high precision for small time differences.\nThe structure uses Kahan summation to accurately handle running sums over long periods without\nlosing accuracy to floating-point rounding errors.\n\nAll arithmetic operations (addition, subtraction) use seconds as the default unit and return\ntime differences in seconds.\n\nThe Epoch constructor accepts multiple input formats for convenience:\n\n- **Date components**: `Epoch(year, month, day)` - creates epoch at midnight\n- **Full datetime**: `Epoch(year, month, day, hour, minute, second, nanosecond)` - full precision\n- **Partial datetime**: `Epoch(year, month, day, hour)` or `Epoch(year, month, day, hour, minute)` etc.\n- **ISO 8601 string**: `Epoch("2024-01-01T12:00:00Z")` - parse from string\n- **Python datetime**: `Epoch(datetime_obj)` - convert from Python datetime\n- **Copy constructor**: `Epoch(other_epoch)` - create a copy\n- **Time system**: All constructors accept optional `time_system=` keyword argument (default: UTC)\n\nExample:\n    ```python\n    import brahe as bh\n    from datetime import datetime\n\n    # Multiple ways to create the same epoch\n    epc1 = bh.Epoch(2024, 1, 1, 12, 0, 0.0, 0.0)\n    epc2 = bh.Epoch("2024-01-01 12:00:00.000 UTC")\n    epc3 = bh.Epoch(datetime(2024, 1, 1, 12, 0, 0))\n    print(epc1)\n    # Output: 2024-01-01 12:00:00.000 UTC\n\n    # Create epoch at midnight\n    midnight = bh.Epoch(2024, 1, 1)\n    print(midnight)\n    # Output: 2024-01-01 00:00:00.000 UTC\n\n    # Use different time systems\n    gps_time = bh.Epoch(2024, 1, 1, 12, 0, 0.0, 0.0, time_system=bh.GPS)\n    print(gps_time)\n    # Output: 2024-01-01 12:00:00.000 GPS\n\n    # Perform arithmetic operations\n    epoch2 = epc1 + 3600.0  # Add one hour (in seconds)\n    diff = epoch2 - epc1     # Difference in seconds\n    print(f"Time difference: {diff} seconds")\n    # Output: Time difference: 3600.0 seconds\n\n    # Legacy constructors still available\n    epc4 = bh.Epoch.from_datetime(2024, 1, 1, 12, 0, 0.0, 0.0, bh.UTC)\n    epc5 = bh.Epoch.from_jd(2460310.0, bh.UTC)\n    ```'

str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to 'utf-8'. errors defaults to 'strict'.

__module__ class-attribute

__module__ = 'brahe._brahe'

str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to 'utf-8'. errors defaults to 'strict'.

time_system property

time_system: TimeSystem

Time system of the epoch.

Returns:

Name Type Description
TimeSystem TimeSystem

The time system used by this epoch

__add__ method descriptor

__add__(value)

Return self+value.

__eq__ method descriptor

__eq__(value)

Return self==value.

__ge__ method descriptor

__ge__(value)

Return self>=value.

__gt__ method descriptor

__gt__(value)

Return self>value.

__iadd__ method descriptor

__iadd__(value)

Return self+=value.

__isub__ method descriptor

__isub__(value)

Return self-=value.

__le__ method descriptor

__le__(value)

Return self<=value.

__lt__ method descriptor

__lt__(value)

Return self<value.

__ne__ method descriptor

__ne__(value)

Return self!=value.

__new__ builtin

__new__(*args, **kwargs)

Create and return a new object. See help(type) for accurate signature.

__radd__ method descriptor

__radd__(value)

Return value+self.

__repr__ method descriptor

__repr__() -> str

Return repr(self).

__rsub__ method descriptor

__rsub__(value)

Return value-self.

__str__ method descriptor

__str__() -> str

Return str(self).

__sub__ method descriptor

__sub__(value)

Return self-value.

day method descriptor

day() -> int

Returns the day component of the epoch in the epoch's time system.

Returns:

Name Type Description
int int

The day of the month as an integer from 1 to 31

day_of_year method descriptor

day_of_year() -> float

Returns the day of year as a floating-point number in the epoch's time system.

The day of year is computed such that January 1st at midnight is 1.0, January 1st at noon is 1.5, January 2nd at midnight is 2.0, etc.

Returns:

Name Type Description
float float

The day of year as a floating-point number (1.0 to 366.999...)

Example

epoch = brahe.Epoch.from_datetime(2023, 4, 10, 12, 0, 0.0, 0.0, "UTC") doy = epoch.day_of_year() print(f"Day of year: {doy}") Day of year: 100.5

day_of_year_as_time_system method descriptor

day_of_year_as_time_system(time_system: TimeSystem) -> float

Returns the day of year as a floating-point number in the specified time system.

The day of year is computed such that January 1st at midnight is 1.0, January 1st at noon is 1.5, January 2nd at midnight is 2.0, etc.

Parameters:

Name Type Description Default
time_system TimeSystem

The time system to use for the calculation

required

Returns:

Name Type Description
float float

The day of year as a floating-point number (1.0 to 366.999...)

Example

epoch = brahe.Epoch.from_datetime(2023, 4, 10, 12, 0, 0.0, 0.0, brahe.TimeSystem.UTC) doy_tai = epoch.day_of_year_as_time_system(brahe.TimeSystem.TAI) print(f"Day of year in TAI: {doy_tai}") Day of year in TAI: 100.50042824074075

from_date builtin

from_date(year: int, month: int, day: int, time_system: TimeSystem) -> Epoch

Create an Epoch from a calendar date at midnight.

Parameters:

Name Type Description Default
year int

Gregorian calendar year

required
month int

Month (1-12)

required
day int

Day of month (1-31)

required
time_system TimeSystem

Time system

required

Returns:

Name Type Description
Epoch Epoch

The epoch representing midnight on the specified date

Example
import brahe as bh

# Create an epoch at midnight on January 1, 2024 UTC
epc = bh.Epoch.from_date(2024, 1, 1, bh.TimeSystem.UTC)
print(epc)
# Output: 2024-01-01T00:00:00.000000000 UTC

# Create epoch in different time system
epc_tai = bh.Epoch.from_date(2024, 6, 15, bh.TimeSystem.TAI)
print(epc_tai)
# Output: 2024-06-15T00:00:00.000000000 TAI

from_datetime builtin

from_datetime(year: int, month: int, day: int, hour: int, minute: int, second: float, nanosecond: float, time_system: TimeSystem) -> Epoch

Create an Epoch from a complete Gregorian calendar date and time.

Parameters:

Name Type Description Default
year int

Gregorian calendar year

required
month int

Month (1-12)

required
day int

Day of month (1-31)

required
hour int

Hour (0-23)

required
minute int

Minute (0-59)

required
second float

Second with fractional part

required
nanosecond float

Nanosecond component

required
time_system TimeSystem

Time system

required

Returns:

Name Type Description
Epoch Epoch

The epoch representing the specified date and time

Example
import brahe as bh

# Create epoch for January 1, 2024 at 12:30:45.5 UTC
epc = bh.Epoch.from_datetime(2024, 1, 1, 12, 30, 45.5, 0.0, bh.TimeSystem.UTC)
print(epc)
# Output: 2024-01-01T12:30:45.500000000 UTC

# With nanosecond precision
epc_ns = bh.Epoch.from_datetime(2024, 6, 15, 14, 30, 0.0, 123456789.0, bh.TimeSystem.TAI)
print(epc_ns)
# Output: 2024-06-15T14:30:00.123456789 TAI

from_day_of_year builtin

from_day_of_year(year: int, day_of_year: float, time_system: TimeSystem) -> Epoch

Create an Epoch from a year and floating-point day-of-year.

Parameters:

Name Type Description Default
year int

Gregorian calendar year

required
day_of_year float

Day of year as a floating-point number (1.0 = January 1st, 1.5 = January 1st noon, etc.)

required
time_system TimeSystem

Time system

required

Returns:

Name Type Description
Epoch Epoch

The epoch representing the specified day of year

Example
import brahe as bh

# Create epoch for day 100 of 2024 at midnight
epc = bh.Epoch.from_day_of_year(2024, 100.0, bh.TimeSystem.UTC)
print(epc)
# Output: 2024-04-09T00:00:00.000000000 UTC

# Create epoch for day 100.5 (noon on day 100)
epc_noon = bh.Epoch.from_day_of_year(2024, 100.5, bh.TimeSystem.UTC)
year, month, day, hour, minute, second, ns = epc_noon.to_datetime()
print(f"{year}-{month:02d}-{day:02d} {hour:02d}:{minute:02d}:{second:06.3f}")
# Output: 2024-04-09 12:00:00.000

from_gps_date builtin

from_gps_date(week: int, seconds: float) -> Epoch

Create an Epoch from GPS week and seconds.

Parameters:

Name Type Description Default
week int

GPS week number since GPS epoch (January 6, 1980)

required
seconds float

Seconds into the GPS week

required

Returns:

Name Type Description
Epoch Epoch

The epoch in GPS time system

Example
import brahe as bh

# Create epoch from GPS week 2200, day 3, noon
week = 2200
seconds = 3 * 86400 + 12 * 3600  # 3 days + 12 hours
epc = bh.Epoch.from_gps_date(week, seconds)
print(epc)

# Verify GPS week extraction
week_out, sec_out = epc.gps_date()
print(f"GPS Week: {week_out}, Seconds: {sec_out}")

from_gps_nanoseconds builtin

from_gps_nanoseconds(gps_nanoseconds: int) -> Epoch

Create an Epoch from GPS nanoseconds since the GPS epoch.

Parameters:

Name Type Description Default
gps_nanoseconds int

Nanoseconds since GPS epoch (January 6, 1980, 00:00:00 UTC)

required

Returns:

Name Type Description
Epoch Epoch

The epoch in GPS time system

Example
import brahe as bh

# Create epoch from GPS nanoseconds with high precision
gps_ns = 1234567890123456789
epc = bh.Epoch.from_gps_nanoseconds(gps_ns)
print(f"Epoch: {epc}")

from_gps_seconds builtin

from_gps_seconds(gps_seconds: float) -> Epoch

Create an Epoch from GPS seconds since the GPS epoch.

Parameters:

Name Type Description Default
gps_seconds float

Seconds since GPS epoch (January 6, 1980, 00:00:00 UTC)

required

Returns:

Name Type Description
Epoch Epoch

The epoch in GPS time system

Example
import brahe as bh

# Create epoch from GPS seconds
gps_seconds = 1234567890.5
epc = bh.Epoch.from_gps_seconds(gps_seconds)
print(f"Epoch: {epc}")
print(f"GPS seconds: {epc.gps_seconds()}")

from_jd builtin

from_jd(jd: float, time_system: TimeSystem) -> Epoch

Create an Epoch from a Julian Date.

Parameters:

Name Type Description Default
jd float

Julian date

required
time_system TimeSystem

Time system

required

Returns:

Name Type Description
Epoch Epoch

The epoch representing the Julian date

Example
import brahe as bh

# Create epoch from Julian Date
jd = 2460000.0
epc = bh.Epoch.from_jd(jd, bh.TimeSystem.UTC)
print(epc)

# Verify round-trip conversion
jd_out = epc.jd()
print(f"JD: {jd_out:.10f}")
# Output: JD: 2460000.0000000000

from_mjd builtin

from_mjd(mjd: float, time_system: TimeSystem) -> Epoch

Create an Epoch from a Modified Julian Date.

Parameters:

Name Type Description Default
mjd float

Modified Julian date

required
time_system TimeSystem

Time system

required

Returns:

Name Type Description
Epoch Epoch

The epoch representing the Modified Julian date

Example
import brahe as bh

# Create epoch from Modified Julian Date
mjd = 60000.0
epc = bh.Epoch.from_mjd(mjd, bh.TimeSystem.UTC)
print(epc)

# MJD is commonly used in astronomy
mjd_j2000 = 51544.0  # J2000 epoch
epc_j2000 = bh.Epoch.from_mjd(mjd_j2000, bh.TimeSystem.TT)
print(f"J2000: {epc_j2000}")

from_string builtin

from_string(datestr: str) -> Epoch

Create an Epoch from an ISO 8601 formatted string.

Parameters:

Name Type Description Default
datestr str

ISO 8601 formatted date string (e.g., "2024-01-01T12:00:00.000000000 UTC")

required

Returns:

Name Type Description
Epoch Epoch

The epoch representing the parsed date and time

Example
import brahe as bh

# Parse ISO 8601 string with full precision
epc = bh.Epoch.from_string("2024-01-01T12:00:00.000000000 UTC")
print(epc)
# Output: 2024-01-01T12:00:00.000000000 UTC

# Parse different time systems
epc_tai = bh.Epoch.from_string("2024-06-15T14:30:45.123456789 TAI")
print(epc_tai.time_system)
# Output: TimeSystem.TAI

gast method descriptor

gast(angle_format: AngleFormat) -> float

Get the Greenwich Apparent Sidereal Time (GAST) for this epoch.

Parameters:

Name Type Description Default
angle_format AngleFormat

Format for the returned angle (radians or degrees)

required

Returns:

Name Type Description
float float

GAST angle

Example
import brahe as bh

epc = bh.Epoch.from_datetime(2024, 1, 1, 0, 0, 0.0, 0.0, bh.TimeSystem.UTC)
gast_rad = epc.gast(bh.AngleFormat.RADIANS)
gast_deg = epc.gast(bh.AngleFormat.DEGREES)
print(f"GAST: {gast_rad:.6f} rad = {gast_deg:.6f} deg")

gmst method descriptor

gmst(angle_format: AngleFormat) -> float

Get the Greenwich Mean Sidereal Time (GMST) for this epoch.

Parameters:

Name Type Description Default
angle_format AngleFormat

Format for the returned angle (radians or degrees)

required

Returns:

Name Type Description
float float

GMST angle

Example
import brahe as bh

epc = bh.Epoch.from_datetime(2024, 1, 1, 0, 0, 0.0, 0.0, bh.TimeSystem.UTC)
gmst_rad = epc.gmst(bh.AngleFormat.RADIANS)
gmst_deg = epc.gmst(bh.AngleFormat.DEGREES)
print(f"GMST: {gmst_rad:.6f} rad = {gmst_deg:.6f} deg")

gps_date method descriptor

gps_date() -> Tuple

Get the GPS week number and seconds into the week.

Returns:

Name Type Description
tuple Tuple

A tuple containing (week, seconds_into_week)

Example
import brahe as bh

epc = bh.Epoch.from_datetime(2024, 1, 1, 12, 0, 0.0, 0.0, bh.TimeSystem.GPS)
week, seconds = epc.gps_date()
print(f"GPS Week: {week}, Seconds: {seconds:.3f}")

gps_nanoseconds method descriptor

gps_nanoseconds() -> float

Get the nanoseconds since GPS epoch (January 6, 1980, 00:00:00 UTC).

Returns:

Name Type Description
float float

GPS nanoseconds

Example
import brahe as bh

epc = bh.Epoch.from_datetime(2024, 1, 1, 0, 0, 0.0, 123456789.0, bh.TimeSystem.GPS)
gps_ns = epc.gps_nanoseconds()
print(f"GPS nanoseconds: {gps_ns:.0f}")

gps_seconds method descriptor

gps_seconds() -> float

Get the seconds since GPS epoch (January 6, 1980, 00:00:00 UTC).

Returns:

Name Type Description
float float

GPS seconds

Example
import brahe as bh

epc = bh.Epoch.from_datetime(2024, 1, 1, 0, 0, 0.0, 0.0, bh.TimeSystem.GPS)
gps_sec = epc.gps_seconds()
print(f"GPS seconds: {gps_sec:.3f}")

hour method descriptor

hour() -> int

Returns the hour component of the epoch in the epoch's time system.

Returns:

Name Type Description
int int

The hour as an integer from 0 to 23

isostring method descriptor

isostring() -> str

Convert the epoch to an ISO 8601 formatted string.

Returns:

Name Type Description
str str

ISO 8601 formatted date string with full nanosecond precision

Example
import brahe as bh

epc = bh.Epoch.from_datetime(2024, 1, 1, 12, 30, 45.123456789, 0.0, bh.TimeSystem.UTC)
iso = epc.isostring()
print(iso)
# Output: 2024-01-01T12:30:45.123456789Z

isostring_with_decimals method descriptor

isostring_with_decimals(decimals: int) -> str

Convert the epoch to an ISO 8601 formatted string with specified decimal precision.

Parameters:

Name Type Description Default
decimals int

Number of decimal places for the seconds field

required

Returns:

Name Type Description
str str

ISO 8601 formatted date string

Example
import brahe as bh

epc = bh.Epoch.from_datetime(2024, 1, 1, 12, 30, 45.123456789, 0.0, bh.TimeSystem.UTC)
iso3 = epc.isostring_with_decimals(3)
iso6 = epc.isostring_with_decimals(6)
print(iso3)  # Output: 2024-01-01T12:30:45.123Z
print(iso6)  # Output: 2024-01-01T12:30:45.123457Z

jd method descriptor

jd() -> float

Get the Julian Date in the epoch's time system.

Returns:

Name Type Description
float float

Julian date

Example
import brahe as bh

epc = bh.Epoch.from_datetime(2024, 1, 1, 0, 0, 0.0, 0.0, bh.TimeSystem.UTC)
jd = epc.jd()
print(f"JD: {jd:.6f}")
# Output: JD: 2460310.500000

jd_as_time_system method descriptor

jd_as_time_system(time_system: TimeSystem) -> float

Get the Julian Date in a specified time system.

Parameters:

Name Type Description Default
time_system TimeSystem

Target time system for the conversion

required

Returns:

Name Type Description
float float

Julian date in the specified time system

Example
import brahe as bh

epc = bh.Epoch.from_datetime(2024, 1, 1, 12, 0, 0.0, 0.0, bh.TimeSystem.UTC)
jd_utc = epc.jd()
jd_tai = epc.jd_as_time_system(bh.TimeSystem.TAI)
print(f"JD UTC: {jd_utc:.10f}")
print(f"JD TAI: {jd_tai:.10f}")

minute method descriptor

minute() -> int

Returns the minute component of the epoch in the epoch's time system.

Returns:

Name Type Description
int int

The minute as an integer from 0 to 59

mjd method descriptor

mjd() -> float

Get the Modified Julian Date in the epoch's time system.

Returns:

Name Type Description
float float

Modified Julian date

Example
import brahe as bh

epc = bh.Epoch.from_datetime(2024, 1, 1, 0, 0, 0.0, 0.0, bh.TimeSystem.UTC)
mjd = epc.mjd()
print(f"MJD: {mjd:.6f}")
# Output: MJD: 60310.000000

mjd_as_time_system method descriptor

mjd_as_time_system(time_system: TimeSystem) -> float

Get the Modified Julian Date in a specified time system.

Parameters:

Name Type Description Default
time_system TimeSystem

Target time system for the conversion

required

Returns:

Name Type Description
float float

Modified Julian date in the specified time system

Example
import brahe as bh

epc = bh.Epoch.from_datetime(2024, 1, 1, 0, 0, 0.0, 0.0, bh.TimeSystem.UTC)
mjd_utc = epc.mjd()
mjd_gps = epc.mjd_as_time_system(bh.TimeSystem.GPS)
print(f"MJD UTC: {mjd_utc:.6f}")
print(f"MJD GPS: {mjd_gps:.6f}")

month method descriptor

month() -> int

Returns the month component of the epoch in the epoch's time system.

Returns:

Name Type Description
int int

The month as an integer from 1 to 12

nanosecond method descriptor

nanosecond() -> float

Returns the nanosecond component of the epoch in the epoch's time system.

Returns:

Name Type Description
float float

The nanosecond component as a floating-point number

now builtin

now() -> Epoch

Create an Epoch representing the current UTC instant.

This method uses the system clock to get the current time and creates an Epoch in the UTC time system.

Returns:

Name Type Description
Epoch Epoch

The epoch representing the current instant in time in UTC

Example
import brahe as bh

# Get current time as an Epoch
now = bh.Epoch.now()
print(f"Current time: {now}")
print(f"Time system: {now.time_system}")
# Output: Time system: TimeSystem.UTC

# Use in orbital calculations
import numpy as np
current_epoch = bh.Epoch.now()
oe = np.array([bh.R_EARTH + 500e3, 0.01, np.radians(97.8), 0.0, 0.0, 0.0])
state = bh.state_osculating_to_cartesian(oe, bh.AngleFormat.RADIANS)
propagator = bh.KeplerianPropagator.from_eci(current_epoch, state, 60.0)

second method descriptor

second() -> float

Returns the second component of the epoch in the epoch's time system.

Returns:

Name Type Description
float float

The second as a floating-point number from 0.0 to 59.999...

to_datetime method descriptor

to_datetime() -> Tuple

Convert the epoch to Gregorian calendar date and time in the epoch's time system.

Returns:

Name Type Description
tuple Tuple

A tuple containing (year, month, day, hour, minute, second, nanosecond)

Example
import brahe as bh

epc = bh.Epoch.from_datetime(2024, 6, 15, 14, 30, 45.5, 0.0, bh.TimeSystem.UTC)
year, month, day, hour, minute, second, ns = epc.to_datetime()
print(f"{year}-{month:02d}-{day:02d} {hour:02d}:{minute:02d}:{second:06.3f}")
# Output: 2024-06-15 14:30:45.500

to_datetime_as_time_system method descriptor

to_datetime_as_time_system(time_system: TimeSystem) -> Tuple

Convert the epoch to Gregorian calendar date and time in a specified time system.

Parameters:

Name Type Description Default
time_system TimeSystem

Target time system for the conversion

required

Returns:

Name Type Description
tuple Tuple

A tuple containing (year, month, day, hour, minute, second, nanosecond)

Example
import brahe as bh

# Create epoch in UTC and convert to TAI
epc = bh.Epoch.from_datetime(2024, 1, 1, 12, 0, 0.0, 0.0, bh.TimeSystem.UTC)
year, month, day, hour, minute, second, ns = epc.to_datetime_as_time_system(bh.TimeSystem.TAI)
print(f"TAI: {year}-{month:02d}-{day:02d} {hour:02d}:{minute:02d}:{second:06.3f}")
# Output: TAI: 2024-01-01 12:00:37.000

to_string_as_time_system method descriptor

to_string_as_time_system(time_system: TimeSystem) -> str

Convert the epoch to a string representation in a specified time system.

Parameters:

Name Type Description Default
time_system TimeSystem

Target time system for the conversion

required

Returns:

Name Type Description
str str

String representation of the epoch

Example
import brahe as bh

epc = bh.Epoch.from_datetime(2024, 1, 1, 12, 0, 0.0, 0.0, bh.TimeSystem.UTC)
print(epc.to_string_as_time_system(bh.TimeSystem.UTC))
print(epc.to_string_as_time_system(bh.TimeSystem.TAI))
# Shows same instant in different time systems

year method descriptor

year() -> int

Returns the year component of the epoch in the epoch's time system.

Returns:

Name Type Description
int int

The year as a 4-digit integer