mars_time.MarsTime#
- class mars_time.MarsTime(year: int, sol: float)[source]#
A
MarsTime
represents the year and sol on Mars.In many ways, a
MarsTime
is analogous to adatetime.datetime
. As withdatetime.datetime
, instances of this class may be most useful for attribute extraction.- Parameters:
year (int) – The Martian year. Must be between -99 and 99.
sol (float) – The sol (day of the Martian year). Must be between 0 and ~668 (it varies by Martian year).
- Raises:
TypeError – Raised if either of the inputs are a type that cannot be cast to a numeric data type.
ValueError – Raised if either of the inputs are a value that cannot be cast to a numeric data type or if
sol
is outside its valid range for the input year.
See also
MarsTimeDelta
For adding time differences to this class.
Notes
Objects of this type are immutable.
Examples
Create an instance of this class from a given Mars year and sol.
>>> import mars_time >>> mt = mars_time.MarsTime(30, 0) >>> mt MarsTime(year=30, sol=0.00)
Alternatively, you can create an instance of this class from a Mars year and solar longitude.
>>> mars_time.MarsTime.from_solar_longitude(year=33, solar_longitude=180) MarsTime(year=33, sol=371.92)
You can add a
MarsTimeDelta
to this object. Note that the resultant sol is “ugly” because I assume there aren’t an integer number of sols per year.>>> dt = mars_time.MarsTimeDelta(sol=700) >>> mt + dt MarsTime(year=31, sol=31.41)
You can also subtract a
MarsTimeDelta
from this object.>>> mt - dt MarsTime(year=28, sol=637.19)
The difference between two
MarsTime
objects is aMarsTimeDelta
.>>> MarsTime(33, 0) - MarsTime(32, 400) MarsTimeDelta(year=1, sol=-400.00)
You can extract the input year and sol from this object via its properties. You can also extract the solar longitude corresponding to the input sol.
>>> mt = MarsTime(33, 200) >>> mt.year, mt.sol, f'{mt.solar_longitude:.1f}' (33, 200.0, '93.1')
Methods
__init__
(year, sol)from_solar_longitude
(year, solar_longitude)Create an instance of this class from a solar longitude instead of a sol.
Attributes
sol
Get the input sol.
solar_longitude
Get the solar longitude corresponding to the input Mars time.
year
Get the input Mars year.