#!/usr/bin/python3 ## Compute Zao Keng bus stop sunrises azimuths ## https://www.jidanni.org/astro/rise_set/mountain/zaokeng/programs/p ## ## Here we use https://github.com/brandon-rhodes/pyephem ## via the Debian python3-ephem package. ## ## Warning: I (jidanni) am a python nincompoop, so don't use these as code examples! ## ## Copyright : https://www.gnu.org/licenses/gpl.html ## Author : https://www.jidanni.org/ ## Created On : Sat Apr 10 04:17:04 2021 ## Last Modified By: Dan Jacobson ## Last Modified On: Tue Apr 13 23:46:57 2021 ## Update Count : 148 # /usr/lib/python3/dist-packages/ephem/doc/quick.rst import ephem, math, os tf = False p = ephem.Observer() p.lon = os.environ["lon"] p.lat = os.environ["lat"] p.elevation = float(os.environ["ASL"]) # Doesn't do much. def pr(k): v = ephem.Sun(k) print( "%.19s %.1f %.1f" % (ephem.localtime(k.date), v.az * 180 / math.pi, v.alt * 180 / math.pi) ) def nuclear_photo(m): # First show us the facts for our nuclear photo. Then prove that # sunrises occur at the same spot, every year, within a few seconds # of each other. year = 2020 doy = [6, 17, 6, 3, 4] m.date = ephem.Date(tuple([year] + doy)) - 8 * ephem.hour date2 = m.date + 365 * 22 while m.date <= date2: pr(m) year += 1 m.date = ephem.Date(tuple([year] + doy)) - 8 * ephem.hour f = ephem.Sun(m) m.date = m.previous_rising(f, use_center=tf) def dongmao(m): m.date = str(ephem.now().tuple()[0]) # Beginning of current year (UTC). date2 = m.date + 365 f = ephem.Sun(m) while m.date <= date2: for m.horizon in "0", os.environ["elevation"]: m.date = m.next_rising(f, use_center=tf) pr(p) print() eval(os.environ["func"]) # My poor python knowledge