From 6665ea7dcdecb2537fd6ab9c16fb32c6f8f2de32 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Thu, 14 Aug 2025 19:40:32 -0700 Subject: [PATCH] moon refactor --- modules/space.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/modules/space.py b/modules/space.py index 6777661..f996a86 100644 --- a/modules/space.py +++ b/modules/space.py @@ -125,7 +125,25 @@ def get_moon(lat=0, lon=0): obs.date = datetime.now(timezone.utc) moon.compute(obs) moon_table = {} - moon_phase = ['NewMoon', 'Waxing Crescent', 'First Quarter', 'Waxing Gibbous', 'FullMoon', 'Waning Gibbous', 'Last Quarter', 'Waning Crescent'][round(moon.phase / (2 * ephem.pi) * 8) % 8] + illum = moon.phase # 0 = new, 50 = first/last quarter, 100 = full + + if illum < 1.0: + moon_phase = 'New Moon' + elif illum < 49: + moon_phase = 'Waxing Crescent' + elif 49 <= illum < 51: + moon_phase = 'First Quarter' + elif illum < 99: + moon_phase = 'Waxing Gibbous' + elif illum >= 99: + moon_phase = 'Full Moon' + elif illum > 51: + moon_phase = 'Waning Gibbous' + elif 51 >= illum > 49: + moon_phase = 'Last Quarter' + else: + moon_phase = 'Waning Crescent' + moon_table['phase'] = moon_phase moon_table['illumination'] = moon.phase moon_table['azimuth'] = moon.az