#!/usr/bin/env python3 """Addenda G7 and G8 of RULES_photo_geometry.txt: the Chiefland frame of March 2023 solved from its own stars, the magnetic latitudes of the night's other records, and where a red arc would stand. Fact-Checked Science, "Our analysis". Standard library only. Run: python3 -I -X utf8 photo_stars.py RULES_photo_geometry.txt POINTS_TSV TREELINE_TSV OUT_FOLDER POINTS_TSV and TREELINE_TSV are our own measurements of the photograph (gallery entry 194634 of Spaceweather.com, which we link and do not host): the star images found by star_points.py, brightest first, and the tree line found by tree_line.py. It writes OUT_FOLDER/photo_stars.json and .log. The helpers come from photo_geometry.py and photo_geometry_others.py, beside this file. """ import datetime as dt import hashlib import json import math import os import sys HERE = os.path.dirname(os.path.abspath(__file__)) sys.path.insert(0, HERE) import photo_geometry as PG # noqa: E402 import photo_geometry_others as PO # noqa: E402 rad, deg = math.radians, math.degrees W, H = 730, 493 NPOINTS = 500 # the brightest points only, so that a chance match within 3 pixels stays rare # named by eye in the photograph, with rough pixel positions; each is moved to the nearest measured point STARTERS = {"Sirius": (477.5, 286.5), "Betelgeuse": (585.0, 171.5), "Rigel": (613.0, 287.0)} def hms(h, m, s): return h + m / 60 + s / 3600 def dms(sign, d, m, s=0): return sign * (d + m / 60 + s / 3600) STARS = { # J2000 right ascension (hours), declination (degrees) "Sirius": (hms(6, 45, 8.9), dms(-1, 16, 42, 58)), "Adhara": (hms(6, 58, 37.5), dms(-1, 28, 58, 20)), "Wezen": (hms(7, 8, 23.5), dms(-1, 26, 23, 36)), "Mirzam": (hms(6, 22, 42.0), dms(-1, 17, 57, 21)), "Aludra": (hms(7, 24, 5.7), dms(-1, 29, 18, 11)), "omicron2 CMa": (hms(7, 3, 1.5), dms(-1, 23, 50, 0)), "Furud": (hms(6, 20, 18.8), dms(-1, 30, 3, 48)), "gamma CMa": (hms(7, 3, 45.5), dms(-1, 15, 38, 0)), "Betelgeuse": (hms(5, 55, 10.3), dms(1, 7, 24, 25)), "Rigel": (hms(5, 14, 32.3), dms(-1, 8, 12, 6)), "Bellatrix": (hms(5, 25, 7.9), dms(1, 6, 20, 59)), "Saiph": (hms(5, 47, 45.4), dms(-1, 9, 40, 11)), "Alnitak": (hms(5, 40, 45.5), dms(-1, 1, 56, 34)), "Alnilam": (hms(5, 36, 12.8), dms(-1, 1, 12, 7)), "Mintaka": (hms(5, 32, 0.4), dms(-1, 0, 17, 57)), "Meissa": (hms(5, 35, 8.3), dms(1, 9, 56, 3)), "iota Ori": (hms(5, 35, 26.0), dms(-1, 5, 54, 36)), "pi3 Ori": (hms(4, 49, 50.4), dms(1, 6, 57, 41)), "eta Ori": (hms(5, 24, 28.6), dms(-1, 2, 23, 50)), "tau Ori": (hms(5, 17, 36.4), dms(-1, 6, 50, 40)), "Procyon": (hms(7, 39, 18.1), dms(1, 5, 13, 30)), "Gomeisa": (hms(7, 27, 9.0), dms(1, 8, 17, 22)), "Arneb": (hms(5, 32, 43.8), dms(-1, 17, 49, 20)), "Nihal": (hms(5, 28, 14.7), dms(-1, 20, 45, 34)), "mu Lep": (hms(5, 12, 55.9), dms(-1, 16, 12, 20)), "epsilon Lep": (hms(5, 5, 27.7), dms(-1, 22, 22, 16)), "gamma Lep": (hms(5, 44, 27.8), dms(-1, 22, 26, 54)), "delta Lep": (hms(5, 51, 19.3), dms(-1, 20, 52, 45)), "zeta Lep": (hms(5, 46, 57.3), dms(-1, 14, 49, 19)), "eta Lep": (hms(5, 56, 24.3), dms(-1, 14, 10, 4)), "Cursa": (hms(5, 7, 51.0), dms(-1, 5, 5, 11)), "mu Eri": (hms(4, 45, 30.2), dms(-1, 3, 15, 17)), "nu Eri": (hms(4, 36, 19.1), dms(-1, 3, 21, 9)), "Aldebaran": (hms(4, 35, 55.2), dms(1, 16, 30, 33)), "Elnath": (hms(5, 26, 17.5), dms(1, 28, 36, 27)), "zeta Tau": (hms(5, 37, 38.7), dms(1, 21, 8, 33)), "Pollux": (hms(7, 45, 18.9), dms(1, 28, 1, 34)), "Castor": (hms(7, 34, 35.9), dms(1, 31, 53, 18)), "Alhena": (hms(6, 37, 42.7), dms(1, 16, 23, 57)), "mu Gem": (hms(6, 22, 57.6), dms(1, 22, 30, 49)), "Mebsuta": (hms(6, 43, 55.9), dms(1, 25, 7, 52)), "xi Gem": (hms(6, 45, 17.4), dms(1, 12, 53, 44)), "Wasat": (hms(7, 20, 7.4), dms(1, 21, 58, 56)), "eta Gem": (hms(6, 14, 52.7), dms(1, 22, 30, 24)), "Naos": (hms(8, 3, 35.0), dms(-1, 40, 0, 12)), "pi Pup": (hms(7, 17, 8.6), dms(-1, 37, 5, 51)), "rho Pup": (hms(8, 7, 32.6), dms(-1, 24, 18, 15)), "nu Pup": (hms(6, 37, 45.7), dms(-1, 43, 11, 45)), "sigma Pup": (hms(7, 29, 13.8), dms(-1, 43, 18, 5)), "xi Pup": (hms(7, 49, 17.7), dms(-1, 24, 51, 35)), "gamma Vel": (hms(8, 9, 32.0), dms(-1, 47, 20, 12)), "lambda Vel": (hms(9, 7, 59.8), dms(-1, 43, 25, 57)), "delta Vel": (hms(8, 44, 42.2), dms(-1, 54, 42, 32)), "Alphard": (hms(9, 27, 35.2), dms(-1, 8, 39, 31)), "zeta Hya": (hms(8, 55, 23.6), dms(1, 5, 56, 44)), "epsilon Hya": (hms(8, 46, 46.5), dms(1, 6, 25, 8)), "nu Hya": (hms(10, 49, 37.5), dms(-1, 16, 11, 37)), "lambda Hya": (hms(10, 10, 35.3), dms(-1, 12, 21, 15)), "mu Hya": (hms(10, 26, 5.4), dms(-1, 16, 50, 11)), "upsilon1 Hya": (hms(9, 51, 28.7), dms(-1, 14, 50, 48)), "iota Hya": (hms(9, 39, 51.4), dms(-1, 1, 8, 34)), "theta Hya": (hms(9, 14, 21.9), dms(1, 2, 18, 51)), "xi Hya": (hms(11, 33, 0.1), dms(-1, 31, 51, 27)), "gamma Hya": (hms(13, 18, 55.3), dms(-1, 23, 10, 18)), "Regulus": (hms(10, 8, 22.3), dms(1, 11, 58, 2)), "Denebola": (hms(11, 49, 3.6), dms(1, 14, 34, 19)), "Algieba": (hms(10, 19, 58.4), dms(1, 19, 50, 30)), "Zosma": (hms(11, 14, 6.5), dms(1, 20, 31, 25)), "Chertan": (hms(11, 14, 14.4), dms(1, 15, 25, 46)), "epsilon Leo": (hms(9, 45, 51.1), dms(1, 23, 46, 27)), "eta Leo": (hms(10, 7, 20.0), dms(1, 16, 45, 46)), "omicron Leo": (hms(9, 41, 9.0), dms(1, 9, 53, 32)), "rho Leo": (hms(10, 32, 48.7), dms(1, 9, 18, 24)), "iota Leo": (hms(11, 23, 55.5), dms(1, 10, 31, 45)), "sigma Leo": (hms(11, 21, 8.2), dms(1, 6, 1, 46)), "Gienah": (hms(12, 15, 48.4), dms(-1, 17, 32, 31)), "Kraz": (hms(12, 34, 23.2), dms(-1, 23, 23, 48)), "Algorab": (hms(12, 29, 51.9), dms(-1, 16, 30, 56)), "epsilon Crv": (hms(12, 10, 7.5), dms(-1, 22, 37, 11)), "alpha Crv": (hms(12, 8, 24.8), dms(-1, 24, 43, 44)), "delta Crt": (hms(11, 19, 20.4), dms(-1, 14, 46, 43)), "alpha Crt": (hms(10, 59, 46.5), dms(-1, 18, 17, 56)), "gamma Crt": (hms(11, 24, 52.9), dms(-1, 17, 41, 2)), "Spica": (hms(13, 25, 11.6), dms(-1, 11, 9, 41)), "Porrima": (hms(12, 41, 39.6), dms(-1, 1, 26, 58)), "Phact": (hms(5, 39, 38.9), dms(-1, 34, 4, 27)), "Wazn": (hms(5, 50, 57.6), dms(-1, 35, 46, 6)), "beta Cnc": (hms(8, 16, 30.9), dms(1, 9, 11, 8)), "delta Cnc": (hms(8, 44, 41.1), dms(1, 18, 9, 15)), "alpha Cnc": (hms(8, 58, 29.2), dms(1, 11, 51, 28)), "alpha Mon": (hms(7, 41, 14.8), dms(-1, 9, 33, 4)), "gamma Mon": (hms(6, 14, 51.3), dms(-1, 6, 16, 29)), "beta Mon": (hms(6, 28, 49.1), dms(-1, 7, 1, 59)), "delta Mon": (hms(7, 11, 51.9), dms(-1, 0, 29, 34)), "zeta Mon": (hms(8, 8, 35.6), dms(-1, 2, 59, 2)), "alpha Pyx": (hms(8, 43, 35.5), dms(-1, 33, 11, 11)), "alpha Ant": (hms(10, 27, 9.1), dms(-1, 31, 4, 4)), "alpha Sex": (hms(10, 7, 56.3), dms(-1, 0, 22, 18)), } BRIGHT = ["Sirius", "Procyon", "Betelgeuse", "Rigel", "Aldebaran", "Pollux", "Castor", "Regulus", "Alphard", "Adhara", "Wezen", "Mirzam", "Aludra", "Bellatrix", "Saiph", "Alnitak", "Alnilam", "Mintaka", "Alhena", "Elnath", "Naos", "gamma Vel", "lambda Vel", "Denebola", "Algieba", "Spica", "Gienah", "Kraz", "Algorab", "Phact", "Arneb", "Nihal", "Cursa", "Gomeisa"] YEARS = 23.22 # from J2000 to the night of the photograph, for precession LABELLED = {"Sirius": STARS["Sirius"], "Orion's Belt (Alnilam), for Barnard's Loop": STARS["Alnilam"], "Rosette Nebula": (6 + 32 / 60, 5 + 3 / 60), "Beehive (M44)": (8 + 40 / 60, 19 + 40 / 60), "Vela supernova remnant": (8 + 35 / 60, -(45 + 10 / 60))} PLACES = [("Hope, New Mexico", 32.81, -104.73), ("southern Oklahoma, as taken", 34.0, -97.0), ("Prescott, Arizona", 34.54, -112.47), ("Boone, North Carolina", 36.22, -81.67), ("Keeler, California", 36.49, -117.87), ("Beatty, Nevada", 36.91, -116.76)] def sha(path): with open(path, "rb") as f: return hashlib.sha256(f.read()).hexdigest() def vec(ra_h, dec_d): a, d = rad(ra_h * 15.0), rad(dec_d) return (math.cos(d) * math.cos(a), math.cos(d) * math.sin(a), math.sin(d)) def cross(a, b): return (a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]) def dot(a, b): return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] def norm(a): n = math.sqrt(dot(a, a)) return (a[0] / n, a[1] / n, a[2] / n) def axes(p, parity): """Axis, right and up of a camera pointed at right ascension p[0], declination p[1] (degrees), rolled by p[2] degrees.""" a = vec(p[0] / 15.0, p[1]) north = (0.0, 0.0, 1.0) u0 = norm(tuple(north[i] - dot(north, a) * a[i] for i in range(3))) r0 = cross(u0, a) r0 = tuple(parity * c for c in r0) c, s = math.cos(rad(p[2])), math.sin(rad(p[2])) return a, tuple(c * x + s * y for x, y in zip(r0, u0)), tuple(-s * x + c * y for x, y in zip(r0, u0)) def project(p, parity, ra_h, dec_d): """Fisheye: distance from the centre f * (theta + k * theta**3), theta the angle from the axis.""" a, r, u = axes(p, parity) v = vec(ra_h, dec_d) xr, yu, z = dot(v, r), dot(v, u), dot(v, a) s = math.hypot(xr, yu) th = math.atan2(s, z) rp = p[3] * (th + p[4] * th ** 3) if s < 1e-12: return p[5], p[6] return p[5] + rp * xr / s, p[6] - rp * yu / s def unproject(p, parity, x, y): a, r, u = axes(p, parity) dx, dy = x - p[5], -(y - p[6]) rp = math.hypot(dx, dy) th = rp / p[3] for _ in range(30): th -= (p[3] * (th + p[4] * th ** 3) - rp) / (p[3] * (1 + 3 * p[4] * th * th)) if rp < 1e-9: v = a else: v = tuple(math.cos(th) * a[i] + math.sin(th) * (dx / rp * r[i] + dy / rp * u[i]) for i in range(3)) return (deg(math.atan2(v[1], v[0])) % 360.0) / 15.0, deg(math.asin(max(-1.0, min(1.0, v[2])))) def main(): rules, points_path, tree_path, outdir = sys.argv[1:5] log = [] def say(*a): s = " ".join(str(x) for x in a) print(s) log.append(s) say("photo_stars.py run at", dt.datetime.now(dt.timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")) say("rules ", sha(rules), os.path.basename(rules)) say("points ", sha(points_path), os.path.basename(points_path)) say("trees ", sha(tree_path), os.path.basename(tree_path)) pts = [] for line in open(points_path, encoding="utf-8"): if not line.startswith("#"): f = line.split("\t") pts.append((float(f[0]), float(f[1]))) pts = pts[:NPOINTS] tree = [] for line in open(tree_path, encoding="utf-8"): if not line.startswith("#"): f = line.split("\t") if f[1]: tree.append((float(f[0]), float(f[1]))) def nearest(x, y): best = min(pts, key=lambda q: (q[0] - x) ** 2 + (q[1] - y) ** 2) return best, math.hypot(best[0] - x, best[1] - y) start = {} for n, (x, y) in STARTERS.items(): q, d = nearest(x, y) start[n] = q say(f" starter {n}: by eye ({x}, {y}); nearest point ({q[0]}, {q[1]}), {d:.1f} px away") # a coarse search for the camera, then refinement def cost4(p4, parity, pairs): p = [p4[0], p4[1], p4[2], p4[3], 0.0, W / 2, H / 2] return sum((project(p, parity, *STARS[n])[0] - x) ** 2 + (project(p, parity, *STARS[n])[1] - y) ** 2 for n, (x, y) in pairs.items()) cands = [] for parity in (1, -1): for ra0 in range(60, 201, 10): for dec0 in range(-70, 41, 10): for roll in range(0, 360, 15): for f in (220, 270, 320, 370): cands.append((cost4([ra0, dec0, roll, f], parity, start), parity, [ra0, dec0, roll, f])) cands.sort(key=lambda c: c[0]) best = None for c0, parity, p4 in cands[:12]: q, v = PO.nelder_mead(lambda z: cost4(z, parity, start), p4, [5.0, 5.0, 5.0, 20.0]) p = [q[0], q[1], q[2], q[3], 0.0, W / 2, H / 2] n_ok = 0 for n, (ra, dec) in STARS.items(): x, y = project(p, parity, ra, dec) if 0 <= x < W and 0 <= y < H and nearest(x, y)[1] <= 6.0: n_ok += 1 if best is None or n_ok > best[0]: best = (n_ok, parity, p) n_ok, parity, p = best say(f" first camera: parity {parity}, {n_ok} listed stars within 6 px of a point; axis RA {p[0] / 15:.2f} h, Dec {p[1]:.1f}, roll {p[2]:.1f}, f {p[3]:.1f} px per radian") def match(p, tol, names=None, npts=NPOINTS): m = {} for n in (names or STARS): x, y = project(p, parity, *STARS[n]) if 0 <= x < W and 0 <= y < H: q = min(pts[:npts], key=lambda z: (z[0] - x) ** 2 + (z[1] - y) ** 2) if math.hypot(q[0] - x, q[1] - y) <= tol: m[n] = q return m def cost7(p, pairs): s = 0.0 for n, (x, y) in pairs.items(): px, py = project(p, parity, *STARS[n]) s += (px - x) ** 2 + (py - y) ** 2 return s # first the bright stars against the 120 brightest points, at a wide reach; then every listed star within 3 pixels for tol, names, npts in ((10.0, BRIGHT, 120), (7.0, BRIGHT, 120), (5.0, BRIGHT, 120), (4.0, None, NPOINTS), (3.0, None, NPOINTS), (3.0, None, NPOINTS), (3.0, None, NPOINTS)): m = match(p, tol, names, npts) p, v = PO.nelder_mead(lambda z: cost7(z, m), p, [0.5, 0.5, 0.5, 3.0, 0.01, 3.0, 3.0], iters=8000) p, v = PO.nelder_mead(lambda z: cost7(z, m), p, [0.1, 0.1, 0.1, 1.0, 0.003, 1.0, 1.0], iters=8000) m = match(p, 3.0) res = {n: math.hypot(project(p, parity, *STARS[n])[0] - q[0], project(p, parity, *STARS[n])[1] - q[1]) for n, q in m.items()} rms = math.sqrt(sum(d * d for d in res.values()) / len(res)) scale = p[3] * rad(1.0) say(f"\nG7 the frame from its stars: {len(m)} matched within 3 px; rms {rms:.2f} px, largest {max(res.values()):.1f} px; {scale:.2f} px per degree at the centre") say(f" camera: axis RA {p[0] / 15:.3f} h, Dec {p[1]:.2f}; roll {p[2]:.1f}; f {p[3]:.1f}; radial term {p[4]:.4f}; centre ({p[5]:.1f}, {p[6]:.1f}); parity {parity}") density = NPOINTS / (W * H) say(f" chance that a point lies within 3 px of a random place: {100 * density * math.pi * 9:.1f}%") out = {"what": "The Chiefland frame solved from its stars (factchecked.science, Our analysis; RULES_photo_geometry.txt, addenda G7 and G8)", "G7": {"matched": len(m), "rms_px": round(rms, 2), "largest_px": round(max(res.values()), 1), "px_per_degree": round(scale, 2), "camera": {"axis_ra_h": round(p[0] / 15, 3), "axis_dec": round(p[1], 2), "roll": round(p[2], 1), "f_px_per_rad": round(p[3], 1), "radial_term": round(p[4], 4), "centre": [round(p[5], 1), round(p[6], 1)], "parity": parity}, "chance_match_pct": round(100 * density * math.pi * 9, 1)}} g7 = out["G7"] def aa(ra, dec, t): return PG.altaz(*PG.precess(ra, dec, YEARS), t) def altaz_px(x, y, t): ra, dec = unproject(p, parity, x, y) return aa(ra, dec, t) T1, T2 = dt.datetime(2023, 3, 24, 4, 12), dt.datetime(2023, 3, 24, 4, 34) minutes = [dt.datetime(2023, 3, 24, 2, 30) + dt.timedelta(minutes=i) for i in range(0, 131)] # (1) the matched stars at the stamped times, and when each reaches the horizon rows, latest_geo, latest_refr = [], None, None for n, q in sorted(m.items(), key=lambda kv: aa(*STARS[kv[0]], T1)[0]): a1, a2 = aa(*STARS[n], T1)[0], aa(*STARS[n], T2)[0] sets = next((t for t in minutes if aa(*STARS[n], t)[0] < 0.0), None) sets_r = next((t for t in minutes if aa(*STARS[n], t)[0] < -0.6), None) rows.append({"star": n, "x": q[0], "y": q[1], "px_off": round(res[n], 1), "alt_0412": round(a1, 1), "alt_0434": round(a2, 1), "below_horizon_from_UT": None if sets is None else f"{sets:%H:%M}"}) if sets and (latest_geo is None or sets < latest_geo): latest_geo = sets if sets_r and (latest_refr is None or sets_r < latest_refr): latest_refr = sets_r g7["stars"] = rows below = [r for r in rows if r["alt_0412"] < 0] below_end = [r for r in rows if r["alt_0434"] < 0] say(f" (1) matched stars below the horizon at 04:12 UT: {len(below)}: " + ", ".join(f"{r['star']} {r['alt_0412']}" for r in below)) say(f" below it at 04:34 UT: {len(below_end)}: " + ", ".join(f"{r['star']} {r['alt_0434']}" for r in below_end)) say(f" every matched star above the horizon only before {latest_geo:%H:%M} UT; with 0.6 degrees of refraction, before {latest_refr:%H:%M} UT") g7["stars_below_horizon_at_0412"] = [r["star"] for r in below] g7["stars_below_horizon_at_0434"] = [r["star"] for r in below_end] g7["all_matched_stars_up_until_UT"] = {"no_refraction": f"{latest_geo:%H:%M}", "refraction_0.6": f"{latest_refr:%H:%M}"} # (2) the tree line def tree_min(t, lift=0.0): return min(altaz_px(x, y, t)[0] + lift for x, y in tree) last_ok = max((t for t in minutes if tree_min(t) >= 0.0), default=None) last_ok_r = max((t for t in minutes if tree_min(t, 0.6) >= 0.0), default=None) g7["tree_line"] = {"columns": len(tree), "lowest_altitude_at_0412": round(tree_min(T1), 1), "lowest_altitude_at_0434": round(tree_min(T2), 1), "at_or_above_horizon_until_UT": {"no_refraction": None if last_ok is None else f"{last_ok:%H:%M}", "refraction_0.6": None if last_ok_r is None else f"{last_ok_r:%H:%M}"}} say(f" (2) tree line, {len(tree)} columns: lowest point {tree_min(T1):.1f} degrees at 04:12 UT, {tree_min(T2):.1f} at 04:34; all of it at or above the horizon " f"until {last_ok:%H:%M} UT ({last_ok_r:%H:%M} with refraction)") # (3) the frame, from 03:00 UT to the latest start the stars and the trees allow, and at the stamped times for comparison t_latest = min(x for x in (latest_refr, last_ok_r) if x is not None) t_first = dt.datetime(2023, 3, 24, 3, 0) frames = {} t_end = t_latest + dt.timedelta(minutes=26) # the end of a 26-minute exposure begun at the latest start (note after the second check) for label, t in (("03:00", t_first), (f"{t_latest:%H:%M}", t_latest), (f"{t_end:%H:%M} (26 minutes on)", t_end), ("04:12 (stamp)", T1), ("04:34 (stamp)", T2)): tl, tr = altaz_px(*tree[0], t), altaz_px(*tree[-1], t) corners = {k: altaz_px(x, y, t) for k, (x, y) in {"top_left": (0, 0), "top_right": (W - 1, 0), "left_mid": (0, H / 2), "right_mid": (W - 1, H / 2)}.items()} # the most northerly sky: the largest azimuth west of south and the smallest east of south, over the sky above the tree line west, east = [], [] for x in range(0, W, 5): ytree = min(tree, key=lambda q: abs(q[0] - x))[1] for y in range(0, int(ytree) + 1, 5): alt, az = altaz_px(x, y, t) if alt > 0: (west if az >= 180 else east).append((az, alt, x, y)) wmax = max(west) if west else None emin = min(east) if east else None frames[label] = {"tree_line_left_az": round(tl[1], 1), "tree_line_right_az": round(tr[1], 1), "tree_line_right_alt": round(tr[0], 1), "corners_alt_az": {k: [round(v[0], 1), round(v[1], 1)] for k, v in corners.items()}, "most_northerly_sky_west": None if wmax is None else {"az": round(wmax[0], 1), "alt": round(wmax[1], 1), "x": wmax[2], "y": wmax[3]}, "most_easterly_sky": None if emin is None else {"az": round(emin[0], 1), "alt": round(emin[1], 1), "x": emin[2], "y": emin[3]}} say(f" (3) at {label} UT: tree line from azimuth {tl[1]:.0f} to {tr[1]:.0f}; top corners (alt, az) {corners['top_left'][0]:.0f}, {corners['top_left'][1]:.0f} and " f"{corners['top_right'][0]:.0f}, {corners['top_right'][1]:.0f}; most northerly sky in the west at azimuth {wmax[0]:.0f} ({wmax[1]:.0f} up)") g7["frame"] = frames # the outline of the sky the frame holds, for the compass chart: along the top, down the right side, back along the tree # line and up the left side, as azimuth and altitude at 03:00 UT and at the latest start border = [(x, 0) for x in range(0, W, 15)] + [(W - 1, y) for y in range(0, int(tree[-1][1]), 15)] + list(reversed(tree)) + [(0, y) for y in range(int(tree[0][1]), -1, -15)] g7["frame_outline_az_alt"] = {label: [[round(altaz_px(x, y, t)[1], 1), round(altaz_px(x, y, t)[0], 1)] for x, y in border] for label, t in (("03:00", t_first), (f"{t_latest:%H:%M}", t_latest))} g7["tree_line_az_alt"] = {label: [[round(altaz_px(x, y, t)[1], 1), round(altaz_px(x, y, t)[0], 1)] for x, y in tree] for label, t in (("03:00", t_first), (f"{t_latest:%H:%M}", t_latest))} g7["hours_allowed_UT"] = ["03:00", f"{t_latest:%H:%M}"] g7["exposure_end_if_begun_at_latest_start_UT"] = f"{t_end:%H:%M}" # (4) the labelled objects over those hours lab = {} for n, (ra, dec) in LABELLED.items(): a, b = aa(ra, dec, t_first), aa(ra, dec, t_latest) xy = project(p, parity, ra, dec) lab[n] = {"alt": [round(a[0]), round(b[0])], "az": [round(a[1]), round(b[1])], "falls_at_pixel": [round(xy[0]), round(xy[1])]} for t, key in ((t_first, 0), (t_latest, 1)): ra_s, dec_s = PG.sun_radec(t) a = PG.altaz((ra_s + 12.0) % 24.0, -dec_s, t) lab.setdefault("Antisolar point (Gegenschein)", {"alt": [None, None], "az": [None, None]}) lab["Antisolar point (Gegenschein)"]["alt"][key] = round(a[0]) lab["Antisolar point (Gegenschein)"]["az"][key] = round(a[1]) g7["labelled_objects_0300_to_latest"] = lab say(" (4) labelled objects, altitude and azimuth at 03:00 UT and at the latest start:", json.dumps(lab)) # the direction test put to the solved frame: the published edges of G2 and G4 against the frame's most northerly sky test = {} for label in ("03:00", f"{t_latest:%H:%M}"): wm = frames[label]["most_northerly_sky_west"]["az"] test[label] = {"most_northerly_azimuth": wm, "G2_widest_span_starts_at": 309, "G4_span_starts_at": 288, "degrees_short_of_G2": round(309 - wm, 1), "degrees_inside_G4": round(max(0.0, wm - 288), 1)} g7["against_the_edges"] = test say(" the frame against the edges:", json.dumps(test)) # ------------------------------------------------------------------------------------------ G8 glat = {n: PG.cd_lat(PG.geocentric(la), lo) for n, la, lo in PLACES} chief = PG.cd_lat(PG.geocentric(PG.LAT), PG.LON) g8 = {"cd_lat": {n: round(v, 1) for n, v in glat.items()}, "Chiefland": round(chief, 1), "arc_400km": {}} say("\nG8 (a) centred-dipole latitudes:", json.dumps(g8["cd_lat"]), "Chiefland", round(chief, 1)) for edge in (44.0, 46.0): best = PO.edge_light(PG.LAT, PG.LON, PG.POLE, edge, 400) up = [a for a, e in best.items() if e is not None and e > 0] emax = max(e for e in best.values() if e is not None) g8["arc_400km"][f"{edge:g}"] = {"above_horizon_azimuths": PO.span(up), "highest": round(emax, 1)} say(f" (b) an arc at {edge:g} degrees, 400 km up: above the horizon over {PO.span(up)}, at most {emax:.1f} degrees high") out["G8"] = g8 with open(os.path.join(outdir, "photo_stars.json"), "w", encoding="utf-8", newline="\n") as f: json.dump(out, f, indent=1, ensure_ascii=False) f.write("\n") with open(os.path.join(outdir, "photo_stars.log"), "w", encoding="utf-8", newline="\n") as f: f.write("\n".join(log) + "\n") if __name__ == "__main__": main()