95 lines
2.2 KiB
Python
95 lines
2.2 KiB
Python
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
from enum import Enum
|
||
|
|
|
||
|
|
from planetarytime.moon import (
|
||
|
|
ARIEL,
|
||
|
|
CALLISTO,
|
||
|
|
DEIMOS,
|
||
|
|
ENCELADUS,
|
||
|
|
EUROPA,
|
||
|
|
GANYMEDE,
|
||
|
|
IO,
|
||
|
|
MIRANDA,
|
||
|
|
Moon,
|
||
|
|
OBERON,
|
||
|
|
PHOBOS,
|
||
|
|
TITAN,
|
||
|
|
TITANIA,
|
||
|
|
TRITON,
|
||
|
|
UMBRIEL,
|
||
|
|
)
|
||
|
|
|
||
|
|
|
||
|
|
class Body(Enum):
|
||
|
|
"""Planetary body in the Solar System."""
|
||
|
|
|
||
|
|
MERCURY = "Mercury"
|
||
|
|
VENUS = "Venus"
|
||
|
|
MARS = "Mars"
|
||
|
|
JUPITER = "Jupiter"
|
||
|
|
SATURN = "Saturn"
|
||
|
|
URANUS = "Uranus"
|
||
|
|
NEPTUNE = "Neptune"
|
||
|
|
|
||
|
|
@property
|
||
|
|
def rotation_hours(self) -> float:
|
||
|
|
"""Sidereal rotation period in Earth hours."""
|
||
|
|
return _ROTATION_HOURS[self]
|
||
|
|
|
||
|
|
@property
|
||
|
|
def orbital_hours(self) -> float:
|
||
|
|
"""Orbital period around the Sun in Earth hours."""
|
||
|
|
return _ORBITAL_HOURS[self]
|
||
|
|
|
||
|
|
@property
|
||
|
|
def hours_per_sol(self) -> int:
|
||
|
|
"""Number of hours in one sol (rotation period rounded to nearest hour)."""
|
||
|
|
return round(self.rotation_hours)
|
||
|
|
|
||
|
|
@property
|
||
|
|
def sols_per_year(self) -> int:
|
||
|
|
"""Number of sols in one planetary year (orbital period / rotation period, rounded)."""
|
||
|
|
return round(self.orbital_hours / self.rotation_hours)
|
||
|
|
|
||
|
|
@property
|
||
|
|
def display_name(self) -> str:
|
||
|
|
return self.value
|
||
|
|
|
||
|
|
def __getitem__(self, index: int) -> Moon:
|
||
|
|
"""Return the moon at the given index for this body."""
|
||
|
|
return _MOONS[self][index]
|
||
|
|
|
||
|
|
|
||
|
|
_ROTATION_HOURS: dict[Body, float] = {
|
||
|
|
Body.MERCURY: 1407.6,
|
||
|
|
Body.VENUS: 5832.5,
|
||
|
|
Body.MARS: 24.6,
|
||
|
|
Body.JUPITER: 9.9,
|
||
|
|
Body.SATURN: 10.7,
|
||
|
|
Body.URANUS: 17.2,
|
||
|
|
Body.NEPTUNE: 16.1,
|
||
|
|
}
|
||
|
|
|
||
|
|
# Orbital periods in Earth hours
|
||
|
|
_ORBITAL_HOURS: dict[Body, float] = {
|
||
|
|
Body.MERCURY: 87.97 * 24,
|
||
|
|
Body.VENUS: 224.70 * 24,
|
||
|
|
Body.MARS: 686.97 * 24,
|
||
|
|
Body.JUPITER: 4332.59 * 24,
|
||
|
|
Body.SATURN: 10759.22 * 24,
|
||
|
|
Body.URANUS: 30688.50 * 24,
|
||
|
|
Body.NEPTUNE: 60182.00 * 24,
|
||
|
|
}
|
||
|
|
|
||
|
|
# Moons per body, ordered by orbital distance from the planet
|
||
|
|
_MOONS: dict[Body, list[Moon]] = {
|
||
|
|
Body.MERCURY: [],
|
||
|
|
Body.VENUS: [],
|
||
|
|
Body.MARS: [PHOBOS, DEIMOS],
|
||
|
|
Body.JUPITER: [IO, EUROPA, GANYMEDE, CALLISTO],
|
||
|
|
Body.SATURN: [TITAN, ENCELADUS],
|
||
|
|
Body.URANUS: [MIRANDA, ARIEL, UMBRIEL, TITANIA, OBERON],
|
||
|
|
Body.NEPTUNE: [TRITON],
|
||
|
|
}
|