From f29d44aa434af71e49ccb7f975985368ca1b9e1d Mon Sep 17 00:00:00 2001 From: Don Cross Date: Sat, 22 Jun 2019 21:33:48 -0400 Subject: [PATCH] Python: Implemented MakeTime function. --- generate/template/astronomy.py | 13 +++++++++++++ source/python/astronomy.py | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/generate/template/astronomy.py b/generate/template/astronomy.py index 2ad565c5..605a5b1e 100644 --- a/generate/template/astronomy.py +++ b/generate/template/astronomy.py @@ -167,3 +167,16 @@ def CurrentTime(): dt = now - _EPOCH ut = dt.total_seconds() / 86400.0 return astro_time_t(ut) + +def MakeTime(year, month, day, hour, minute, second): + # This formula is adapted from NOVAS C 3.1 function julian_date(). + jd12h = ( + day - 32075 + 1461 * (year + 4800 + + (month - 14) / 12) / 4 + + 367 * (month - 2 - (month - 14) / 12 * 12) + / 12 - 3 * ((year + 4900 + (month - 14) / 12) + / 100) / 4) + y2000 = jd12h - 2451545 + ut = y2000 - 0.5 + (hour / 24.0) + (minute / (24.0 * 60.0)) + (second / (24.0 * 3600.0)) + return astro_time_t(ut) + diff --git a/source/python/astronomy.py b/source/python/astronomy.py index 2c92bee6..cc774c49 100644 --- a/source/python/astronomy.py +++ b/source/python/astronomy.py @@ -258,3 +258,16 @@ def CurrentTime(): dt = now - _EPOCH ut = dt.total_seconds() / 86400.0 return astro_time_t(ut) + +def MakeTime(year, month, day, hour, minute, second): + # This formula is adapted from NOVAS C 3.1 function julian_date(). + jd12h = ( + day - 32075 + 1461 * (year + 4800 + + (month - 14) / 12) / 4 + + 367 * (month - 2 - (month - 14) / 12 * 12) + / 12 - 3 * ((year + 4900 + (month - 14) / 12) + / 100) / 4) + y2000 = jd12h - 2451545 + ut = y2000 - 0.5 + (hour / 24.0) + (minute / (24.0 * 60.0)) + (second / (24.0 * 3600.0)) + return astro_time_t(ut) +