Open In Colab

18b27e3e7eb8464e8af228fe20345a45

Time: Basic time functionalities

This notebook illustrates the usage of the montu.Time class in MontuPython.

If you are running this script in Google Colab you need first to install the package and create a directory for saving plots:

[1]:
try:
    from google.colab import drive
    %pip install -Uq montu
except ImportError:
    print("Not running in Colab, skipping installation")
    import plotly.io as pio
    pio.renderers.default = "notebook_connected"
    %load_ext autoreload
    %autoreload 2
# Create folders for figures and temporal files
!mkdir -p ./gallery/ ./montu_dem/
Not running in Colab, skipping installation
[2]:
%matplotlib inline
import montu as mn

MontuPython version 0.50.0. π“‡π“‡‹π“‡‹π“π“…“π“Š΅ π“Ž›π“Ž‘π“„Ώπ“€­π“Ž›π“ˆ–π“‚π“Ž‘ (ii-ti m Htp, HkAx Hn'-k)

2. Definition of time and conversion to other scales

Convert dates:

  1. From Gregorian Proleptic to other scales:

[3]:
mtime = mn.Time('-2500-01-01 12:00:00.00',format='iso',scale='utc',calendar='proleptic')
print(mtime)

2501 B.C. 01-01 12:00:00.00 / [hrw 280] I shemu 17:
    Date in ISO format: 2501 B.C. 01-01 12:00:00.00
    Date in proleptic UTC: -2500-01-01 12:00:00.000000
    Date in mixed UTC: -2500-01-22 12:00:00
    Weekday: 2 (monday)
    Date in sothic format: [hrw 280] I shemu 17
    Terrestrial time: tt [seconds]: -142006202700.3
    UTC time: jed [days]: 807954.0
    Delta-t = TT - UTC [seconds]: 59699.7

  1. From Gregorian Mixed to other scales:

[4]:
mtime = mn.Time('-2500-01-22 12:00:00.00',format='iso',scale='utc',calendar='mixed')
print(mtime)

2501 B.C. 01-23 04:34:59.700000 / [hrw 280] I shemu 17:
    Date in ISO format: 2501 B.C. 01-23 04:34:59.700000
    Date in proleptic UTC: -2500-01-23 04:34:59.7
    Date in mixed UTC: -2500-01-22 12:00:00
    Weekday: 2 (monday)
    Date in sothic format: [hrw 280] I shemu 17
    Terrestrial time: tt [seconds]: -142006202700.3
    UTC time: jed [days]: 807954.0
    Delta-t = TT - UTC [seconds]: 59699.7

  1. From Julian day (UTC) to other scales:

[5]:
mtime = mn.Time(807954,format='jd',scale='utc')
print(mtime)

2501 B.C. 01-01 12:00:00.00 / [hrw 280] I shemu 17:
    Date in ISO format: 2501 B.C. 01-01 12:00:00.00
    Date in proleptic UTC: -2500-01-01 12:00:00.000000
    Date in mixed UTC: -2500-01-22 12:00:00
    Weekday: 2 (monday)
    Date in sothic format: [hrw 280] I shemu 17
    Terrestrial time: tt [seconds]: -142006202700.3
    UTC time: jed [days]: 807954.0
    Delta-t = TT - UTC [seconds]: 59699.7

  1. From terrestrial time (TT) to other scales:

[6]:
mtime = mn.Time(0,format='tt',scale='utc')
print(mtime)

2000-01-01 12:00:00.000000 / [hrw 4783] I shemu 13:
    Date in ISO format: 2000-01-01 12:00:00.000000
    Date in proleptic UTC: 2000-01-01 12:00:00.000000
    Date in mixed UTC: 2000-01-01 12:00:00
    Weekday: 7 (saturday)
    Date in sothic format: [hrw 4783] I shemu 13
    Terrestrial time: tt [seconds]: 63.9
    UTC time: jed [days]: 2451545.0
    Delta-t = TT - UTC [seconds]: 63.9

Detailed attributes

The Time objects has many attributes related to the epoch defined.

You may access different attributes using:

[7]:
(mtime.readable.datepro, # Date in gregorian proleptic
 mtime.readable.datemix, # Date in gregorian mixed
 mtime.jed, #Β Date in Julian Day (utc scale)
 mtime.tt, # Date in ephemerides time (tt scale)
 mtime.et, # Date in ephemerides time (utc scale)
)

[7]:
('2000-01-01 12:00:00.000000', '2000-01-01 12:00:00', 2451545.0, 63.9, 0.0)

A list of attributes are:

[8]:
mtime.__dict__.keys()

[8]:
dict_keys(['readable', 'calendar', 'isjulian', 'deltat', 'bce', 'jed', 'et', 'jtd', 'tt', 'obj_pyephem', 'obj_pyplanet', 'hed', 'htd'])

Here is a detailed explanation of each attribute:

Strings:

  • readable.datepro: Date in proleptic gregorian (extrapolates gregorian calendar before 1582-10-15).

  • readable.datemix: Date in mixed calendar (gregorian from 1582-10-15) and julian before.

  • readable.datespice: Date in SPICE format.

  • readable.datecan: Egyptian civil (sothic) date, e.g. [hrw 280] I *shemu* 17.

Boolean:

  • bce: Is date before christ (before current era).

  • isjulian: Is date a Julian date, i.e. it is a date from before 1582-10-04.

Uniform time-scales:

  • deltat: Delta-t = TT - UTC.

  • jtd: Julian day in terrestrial time scale.

  • tt: Ephemerides time.

  • jed: Julian day in UTC.

  • et: Uniform time.

Calendar:

  • readable.components: Components of date.

  • readable.year, readable.month, readable.day, readable.hour, readable.minute, readable.second, readable.usecond: Self explanatory.

3. Operations with with objects

You may perform operations between time objects:

[9]:
t1 = mn.Time('[hrw 0] I akhet 1', calendar='sothic')
ts = t1 + 1*mn.YEAR

t1, ts
[9]:
(Time('-2781-07-20 18:48:41.4'/'-2781-07-20 00:00:00'/'[hrw 0] I akhet 1'/JED 705497.5/JTD 705498.2838125),
 Time('-2780-06-26 06:00:29.401952'/'-2780-07-19 06:00:00'/'[hrw 1] I akhet 1'/JED 705862.7503403/JTD 705863.5338125))
[10]:
t2 = mn.Time('[hrw 0] I akhet 2', calendar='sothic')
ts = t2.jed - t1.jed
ts
[10]:
1.0

4. Search dates

[11]:
t = mn.Time('[hrw 0] I akhet 1', calendar='sothic')
t
[11]:
Time('-2781-07-20 18:48:41.4'/'-2781-07-20 00:00:00'/'[hrw 0] I akhet 1'/JED 705497.5/JTD 705498.2838125)
[12]:
t = mn.Time('[-2781] I akhet 1', calendar='sothic')
t
[12]:
Time('-2781-07-20 18:48:41.4'/'-2781-07-20 00:00:00'/'[hrw 0] I akhet 1'/JED 705497.5/JTD 705498.2838125)
[13]:
t = mn.Time('[bce2782] I akhet 1', calendar='sothic')
t
[13]:
Time('-2781-07-20 18:48:41.4'/'-2781-07-20 00:00:00'/'[hrw 0] I akhet 1'/JED 705497.5/JTD 705498.2838125)
[14]:
# t2 = mn.Time('[hrw 0] I akhet 2', calendar='sothic')
# t2 = mn.Time('[bce 2026] I akhet 2', calendar='sothic')
# t2 = mn.Time('[-2025] I akhet 2', calendar='sothic')

[15]:
mn.Time('2026-01-01')
[15]:
Time('2026-01-01 00:00:00.000000'/'2026-01-01 00:00:00'/'[hrw 4809] I shemu 20'/JED 2461041.5/JTD 2461041.5008692)
[16]:
t = mn.Time('[bce 1341] I akhet 1', calendar='sothic')
t
[16]:
Time('-1340-07-24 08:52:13.9'/'-1340-07-24 00:00:00'/'[hrw 1442] I akhet 1'/JED 1231827.5/JTD 1231827.8696053)
[17]:
t = mn.Time('[hrw 1442] I akhet 1', calendar='sothic')
t
[17]:
Time('-1340-07-24 08:52:13.9'/'-1340-07-24 00:00:00'/'[hrw 1442] I akhet 1'/JED 1231827.5/JTD 1231827.8696053)
[18]:
t = mn.Time('[hrw 1442] II peret 12', calendar='sothic')
t
[18]:
Time('-1339-01-01 08:51:53.7'/'-1339-01-01 00:00:00'/'[hrw 1442] II peret 12'/JED 1231988.5/JTD 1231988.8693715)

Powered by MontuPython. For more examples see MontuPython GitHub repo.

Jorge I. Zuluaga Β© 2023-present