Basic calendar functions for the classical Mayan calendar
Project description
mayacal
WORK IN PROGRESS - Implementation of some calendrical features for Classical Maya calendar
Requires Python 3.5+
Installation
pip install mayacal
Example Usage:
Import:
>>> import mayacal as mc
Basic conversions and additions:
>>> lc = mc.LongCount(9, 0, 0, 0, 0)
>>> lc.get_calendar_round()
8 Ajaw 13 Keh
>>> dist = mc.DistanceNumber(mc.LongCount(0, 0, 13, 2, 10), sign=1)
>>> new_lc = lc + dist
>>> new_lc
9.0.13.2.10
>>> new_lc.get_mayadate()
9.0.13.2.10 6 Ok 18 Sak
>>> print(new_lc.to_julian())
Nov 19, 448 CE
>>> print(new_lc.to_gregorian())
Nov 20, 448 CE
Get all Long Count dates corresponding to a given Calendar Round:
>>> cr = mc.CalendarRound(mc.Tzolkin(6, "Ok"), mc.Haab(18, "Sak"))
>>> min_lc = mc.LongCount(9,0,0,0,0)
>>> max_lc = mc.LongCount(10,0,0,0,0)
>>> cr.get_long_count_possibilities(min_lc, max_lc)
[9.0.13.2.10, 9.3.5.15.10, 9.5.18.10.10, 9.8.11.5.10, 9.11.4.0.10, 9.13.16.13.10, 9.16.9.8.10, 9.19.2.3.10]
Find the distance between two Long Count dates:
>>> lc_1 = mc.LongCount(9, 12, 13, 0, 5)
>>> lc_2 = mc.LongCount(8, 0, 0, 0, 0)
>>> diff = (lc_1 - lc_2)
>>> diff
1.12.13.0.5
>>> diff.get_total_kin()
235085
>>> diff.to_approx_years(pretty_print=True)
'643 years, 7 months, 16 days'
Infer missing date components:
>>> cr = mc.CalendarRound(mc.Tzolkin(4, "Ajaw"), mc.Haab(8, "Kumku"))
>>> lc = mc.LongCount(9, 4, None, 10, None)
>>> date = mc.Mayadate(lc, cr)
>>> date.infer_mayadates()
[9.4.10.10.0 4 Ajaw 8 Kumku]
>>> cr = mc.CalendarRound(mc.Tzolkin(4, "Ajaw"), mc.Haab(8, "Kumku"))
>>> lc = mc.LongCount(9,None,None,None,None)
>>> date = mc.Mayadate(lc, cr, glyph_g='G3')
>>> date.infer_mayadates()
[9.1.17.15.0 4 Ajaw 8 Kumku]
>>> cr = mc.CalendarRound(mc.Tzolkin(4, "Ajaw"), haab=None)
>>> lc = mc.LongCount(10,None,8,10,None)
>>> date = mc.Mayadate(lc, cr)
>>> date.infer_long_count_dates()
[10.1.8.10.0, 10.14.8.10.0]
Development
Dependencies
There are currently no external dependencies outside of the standard python library. Note the the package requires Python 3.5 or later.
Testing (WIP)
Testing is implemented via pytest.
After installing pytest, you can run all the tests in the package using the following command:
python -m py.test
To run tests in a specific file, use:
python -m py.test tests/...PATH_TO_TEST_FILE...
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file mayacal-0.2.6.tar.gz
.
File metadata
- Download URL: mayacal-0.2.6.tar.gz
- Upload date:
- Size: 15.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac9cf20f5983a7220a36ba44aad2a8339a60f73a4746b2bb841515d1e6dcaec7 |
|
MD5 | fbe1c0f2d921e3ea14e4f5377a5314f4 |
|
BLAKE2b-256 | 970c3135b97628e0d7250a9d66b64413d2f7f73cc1cd0d7cd24ce559f653ecc6 |