Files
astronomy/demo/python/astro_demo_common.py
Don Cross bbaf5bf544 Added Python demo: solar_eclipse.py
This demo calculates the next 10 solar eclipses that are
visible from a given location on the Earth, after a given date.
2023-10-03 11:17:32 -04:00

23 lines
669 B
Python

#!/usr/bin/env python3
#
# astro_demo_common.py - Don Cross - 2019-07-26
#
# Utility functions shared by Python demo programs.
#
import sys
import astronomy
from typing import List, Tuple
def ParseArgs(args: List[str]) -> Tuple[astronomy.Observer, astronomy.Time]:
if len(args) not in [3, 4]:
print('USAGE: {} latitude longitude [yyyy-mm-ddThh:mm:ssZ]'.format(args[0]))
sys.exit(1)
latitude = float(args[1])
longitude = float(args[2])
if len(args) == 4:
time = astronomy.Time.Parse(args[3])
else:
time = astronomy.Time.Now()
observer = astronomy.Observer(latitude, longitude)
return (observer, time)