irfpy.mars.mars_calendar

Martian calendar.

https://en.wikipedia.org/wiki/Timekeeping_on_Mars

See also https://irfpy.irf.se/projects/spice/api/api_irfpy.spice.spicetools.html

Tip

To get the Ls (solar longitude), you can use SPICE function lspcn.

import datetime, spiceypy as spice, numpy as np
### Kernels should be loaded.
spice.furnsh('...')   # Needed kernels should be loaded

### Or maybe for Mars, it is easier to install ``irfpy.aspera`` and
# from irfpy.mexpvat import mexspice as ms
# ms.init()
t = datetime.datetime(2019, 2, 26, 0, 0, 0)
et = spice.utc2et(t.strftime('%FT%T'))
ls = np.rad2deg(spice.lspcn('MARS', et, 'NONE'))
print('t:', t)
print('et:', et)
print('Ls:', kls)
irfpy.mars.mars_calendar.jdtt2msd(jd_tt)[source]

Convert Julian Day in Terrestrial Time to MSD (Mars Sol Date)

https://en.wikipedia.org/wiki/Timekeeping_on_Mars#Formulas_to_compute_MSD_and_MTC

Parameters:

jd_tt – Julian day in Terrestrial Time. You may get the JD_TT from SPICE.

\[MSD = \frac{JD_{TT} - 2405522.0028779}{1.0274912517}\]

Note

To convert the UTC to TT, the following SPICE functions are used.

> import spiceypy as spice
> spice.furnsh('NAIF0012.TLS')    # Furnsh the latest TLS.
> t = datetime.datetime(2019, 2, 24, 15, 9, 12)
> et = spice.str2et(t.strftime('%FT%T'))
> jd_tt = spice.unitim(et, 'ET', 'JDTDT')    # TDT is approximately the same as TT
> print(jd_tt)
2458539.1321896296
>>> jd_tt = 2458539.1321896296
>>> msd = jdtt2msd(jd_tt)
>>> print('{:.8f}'.format(msd))
51598.61869774
irfpy.mars.mars_calendar.msd2jdtt(msd)[source]

Convert MSD to Juliand Day (Terrestrial Time)

Parameters:

msd – Mars Sol Date (floating point)

Returns:

Julian day (TT)

>>> msd = 51598.618697737846
>>> jd_tt = msd2jdtt(msd)
>>> print('{:.8f}'.format(jd_tt))
2458539.13218963
irfpy.mars.mars_calendar.jdtt2mtc(jd_tt)[source]

Convert Julian Day in Terrestrial Time to MSD + MTC.

Parameters:

jd_tt – Julian day in Terrestrial Time. You may get the JD_TT from SPICE.

Returns:

A tuple, (MSD, MTC_hr, MTC-min, MTC-sec)

\[\begin{split}MSD &= \frac{JD_{TT} - 2405522.0028779}{1.0274912517} \\ MTC &= (MSD % 1) \times 24 hr\end{split}\]

Note

Please find jdtt2msd() to convert the UTC time to TT time.

>>> jd_tt = 2458539.1321896296       # UTC 2019-02-24T15:09:12
>>> msd, hr, mn, se = jdtt2mtc(jd_tt)
>>> print('{:d} {:d} {:d} {:.6f}'.format(msd, hr, mn, se))
51598 14 50 55.484550