#!/usr/bin/env python3 """Analysis (c2) for march-2023-storm: which way does the Chiefland photograph look, and could auroral light have stood above the horizon there? Fact-Checked Science, "Our analysis". Standard library only. Follows RULES_photo_geometry.txt. No file is read except the rules (for its hash). Run: python3 -I -X utf8 photo_geometry.py RULES_photo_geometry.txt OUT_FOLDER """ import datetime as dt import hashlib import json import math import os import sys R = 6371.2 LAT, LON = 29.41, -82.86 # Chiefland Astronomy Village, about POLE = (80.717, -72.695) # dipole-axis north pole, CHAOS-8.7 at 2023.22 (out/dipole_pace.json) OCALA = (29.19, -82.14) OBJECTS = { # J2000 right ascension (hours), declination (degrees) "Sirius": (6 + 45 / 60 + 9 / 3600, -(16 + 43 / 60)), "Orion's Belt (Alnilam), for Barnard's Loop": (5 + 36 / 60 + 13 / 3600, -(1 + 12 / 60)), "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)), } rad, deg = math.radians, math.degrees def gmst_hours(t): """Greenwich mean sidereal time (hours) for a UTC datetime (IAU 1982 linear form; good to seconds).""" jd = (t - dt.datetime(2000, 1, 1, 12)).total_seconds() / 86400.0 return (18.697374558 + 24.06570982441908 * jd) % 24.0 def sun_radec(t): """Low-precision solar position (Astronomical Almanac): RA hours, Dec degrees.""" n = (t - dt.datetime(2000, 1, 1, 12)).total_seconds() / 86400.0 L = (280.460 + 0.9856474 * n) % 360.0 g = rad((357.528 + 0.9856003 * n) % 360.0) lam = rad(L + 1.915 * math.sin(g) + 0.020 * math.sin(2 * g)) eps = rad(23.439 - 0.0000004 * n) ra = deg(math.atan2(math.cos(eps) * math.sin(lam), math.cos(lam))) % 360.0 dec = deg(math.asin(math.sin(eps) * math.sin(lam))) return ra / 15.0, dec def precess(ra_h, dec_d, years): """Approximate precession from J2000 by `years` (annual rates m, n); enough for a tenth of a degree.""" m, n = 3.075 / 3600.0, 1.336 / 3600.0 # hours of RA per year ra, dec = rad(ra_h * 15.0), rad(dec_d) dra = (m + n * math.sin(ra) * math.tan(dec)) * years # hours ddec = (n * 15.0 * math.cos(ra)) * years # degrees return ra_h + dra, dec_d + ddec def altaz(ra_h, dec_d, t, lat=LAT, lon=LON): lst = (gmst_hours(t) + lon / 15.0) % 24.0 H = rad((lst - ra_h) * 15.0) d, p = rad(dec_d), rad(lat) alt = math.asin(math.sin(p) * math.sin(d) + math.cos(p) * math.cos(d) * math.cos(H)) az = math.atan2(-math.cos(d) * math.sin(H), math.sin(d) * math.cos(p) - math.cos(d) * math.cos(H) * math.sin(p)) return deg(alt), deg(az) % 360.0 def bearing(lat1, lon1, lat2, lon2): p1, p2, dl = rad(lat1), rad(lat2), rad(lon2 - lon1) b = math.atan2(math.sin(dl) * math.cos(p2), math.cos(p1) * math.sin(p2) - math.sin(p1) * math.cos(p2) * math.cos(dl)) c = math.acos(math.sin(p1) * math.sin(p2) + math.cos(p1) * math.cos(p2) * math.cos(dl)) return deg(b) % 360.0, deg(c) def geocentric(lat_deg): return deg(math.atan((1 - 1 / 298.257223563) ** 2 * math.tan(rad(lat_deg)))) def cd_lat(lat, lon): """Centred-dipole latitude of a geocentric point.""" p, pp, dl = rad(lat), rad(POLE[0]), rad(lon - POLE[1]) return deg(math.asin(math.sin(p) * math.sin(pp) + math.cos(p) * math.cos(pp) * math.cos(dl))) def dest(lat, lon, az, d): """Point at great-circle distance d (degrees) along azimuth az from (lat, lon), geocentric.""" p, a, c = rad(lat), rad(az), rad(d) p2 = math.asin(math.sin(p) * math.cos(c) + math.cos(p) * math.sin(c) * math.cos(a)) l2 = rad(lon) + math.atan2(math.sin(a) * math.sin(c) * math.cos(p), math.cos(c) - math.sin(p) * math.sin(p2)) return deg(p2), deg(l2) def elevation(d_deg, h_km): """Elevation (degrees) of a point at height h and ground distance d (degrees of arc); no refraction.""" c = rad(d_deg) k = R / (R + h_km) return deg(math.atan2(math.cos(c) - k, math.sin(c))) def main(): rules, outdir = sys.argv[1:3] log = [] def say(*a): s = " ".join(str(x) for x in a) print(s) log.append(s) say("photo_geometry.py run at", dt.datetime.now(dt.timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")) say("rules ", hashlib.sha256(open(rules, "rb").read()).hexdigest(), os.path.basename(rules)) out = {"what": "Where the Chiefland photograph of 24 March 2023 looks (factchecked.science, Our analysis; RULES_photo_geometry.txt)", "place": {"lat": LAT, "lon": LON}, "stamp_UT": ["2023-03-24 04:12", "2023-03-24 04:34"]} times = [dt.datetime(2023, 3, 24, 4, 12), dt.datetime(2023, 3, 24, 4, 23), dt.datetime(2023, 3, 24, 4, 34)] yrs = 23.22 say("\nG1 labelled objects: altitude, azimuth (degrees; azimuth from north through east) at 04:12, 04:23, 04:34 UT") g1 = {} for name, (ra, dec) in OBJECTS.items(): ra2, dec2 = precess(ra, dec, yrs) row = [altaz(ra2, dec2, t) for t in times] g1[name] = {"alt": [round(a, 1) for a, z in row], "az": [round(z, 1) for a, z in row]} say(f" {name:45s} alt {row[0][0]:5.1f} {row[1][0]:5.1f} {row[2][0]:5.1f} az {row[0][1]:5.1f} {row[1][1]:5.1f} {row[2][1]:5.1f}") sra, sdec = sun_radec(times[1]) row = [altaz((sun_radec(t)[0] + 12.0) % 24.0, -sun_radec(t)[1], t) for t in times] g1["Antisolar point (Gegenschein)"] = {"alt": [round(a, 1) for a, z in row], "az": [round(z, 1) for a, z in row]} say(f" {'Antisolar point (Gegenschein)':45s} alt {row[0][0]:5.1f} {row[1][0]:5.1f} {row[2][0]:5.1f} az {row[0][1]:5.1f} {row[1][1]:5.1f} {row[2][1]:5.1f}") sun_alt = altaz(sra, sdec, times[1]) say(f" Sun at 04:23 UT: altitude {sun_alt[0]:.1f} (night)") b, c = bearing(LAT, LON, *OCALA) g1["Ocala (bearing, distance km)"] = [round(b, 1), round(rad(c) * R, 0)] say(f" Ocala: bearing {b:.1f}, {rad(c) * R:.0f} km") glat = geocentric(LAT) bp, cp = bearing(glat, LON, *POLE) g1["dipole pole (bearing)"] = round(bp, 1) g1["Chiefland centred-dipole latitude"] = round(cd_lat(glat, LON), 2) say(f" bearing of the dipole-axis pole: {bp:.1f}; Chiefland's centred-dipole latitude {cd_lat(glat, LON):.2f}") out["G1"] = g1 say("\nG2 highest elevation of light at the oval's edge, by azimuth") g2 = {} for edge in (50.5, 56.0, 58.8): for h in (250, 400, 500, 700, 950): best = {} for az in range(0, 360): # walk out along this azimuth to the first point whose centred-dipole latitude reaches the edge found = None d = 0.0 while d <= 40.0: la, lo = dest(glat, LON, az, d) if cd_lat(la, lo) >= edge: found = d break d += 0.05 best[az] = elevation(found, h) if found is not None else None above0 = [az for az, e in best.items() if e is not None and e > 0] above5 = [az for az, e in best.items() if e is not None and e > 5] def span(azs): if not azs: return None # the set is one arc through north; express as [from, to] going clockwise through 0 s = sorted(azs, key=lambda a: (a + 180) % 360) return [s[0], s[-1]] emax = max((e for e in best.values() if e is not None), default=None) azmax = max(best, key=lambda a: best[a] if best[a] is not None else -99) key = f"edge{edge}_h{h}" g2[key] = {"max_elevation": round(emax, 2) if emax is not None else None, "at_azimuth": azmax, "above_horizon_azimuths": span(above0), "above_5deg_azimuths": span(above5), "elevation_at_az_315_NW": round(best[315], 2) if best[315] is not None else None, "elevation_at_az_300": round(best[300], 2) if best[300] is not None else None, "elevation_at_az_270_W": round(best[270], 2) if best[270] is not None else None, "elevation_at_az_225_SW": round(best[225], 2) if best[225] is not None else None} say(f" edge {edge:4.1f}, height {h:3d} km: highest {emax:5.1f} deg at azimuth {azmax:3d}; above the horizon over azimuths " f"{span(above0)}, above 5 deg over {span(above5)}; at 315 (NW) {g2[key]['elevation_at_az_315_NW']}, " f"at 300 {g2[key]['elevation_at_az_300']}, at 270 (W) {g2[key]['elevation_at_az_270_W']}, at 225 (SW) {g2[key]['elevation_at_az_225_SW']}") out["G2"] = g2 say("") say("G3 highest centred-dipole latitude from which emission stands 5 degrees or more high, by azimuth") g3 = {} for az in (204, 241, 264, 280, 290, 300, 315, 330, 2): row = {} for h in (250, 400, 500): best = None d = 0.0 while d <= 40.0: if elevation(d, h) >= 5.0: la, lo = dest(glat, LON, az, d) m = cd_lat(la, lo) if best is None or m > best[0]: best = (m, d) d += 0.05 row[f"h{h}"] = {"cd_lat": round(best[0], 2), "at_distance_deg": round(best[1], 2)} if best else None g3[f"az{az}"] = row say(f" azimuth {az:3d}: " + "; ".join(f"{h} km: lat {row[f'h{h}']['cd_lat']:.2f} (at {row[f'h{h}']['at_distance_deg']:.1f} deg of arc)" for h in (250, 400, 500))) out["G3"] = g3 # G4 (addendum, written while the page was built): the lowest satellite edge in Love et al.'s Table 2 for any storm # weaker than 200 nT is 40.9 degrees, for the storm of 1 November 1972 (190 nT). The same question as G2 for that edge. say("") say("G4 the same as G2 for an edge at 40.9 degrees (Love et al., Table 2: 1 November 1972, 190 nT)") g4 = {} for h in (250, 400, 500, 950): best = {} for az in range(0, 360): found = None d = 0.0 while d <= 40.0: la, lo = dest(glat, LON, az, d) if cd_lat(la, lo) >= 40.9: found = d break d += 0.05 best[az] = elevation(found, h) if found is not None else None def span4(azs): if not azs: return None s = sorted(azs, key=lambda a: (a + 180) % 360) return [s[0], s[-1]] above0 = [az for az, e in best.items() if e is not None and e > 0] above5 = [az for az, e in best.items() if e is not None and e > 5] at = {a: (round(best[a], 1) if best[a] is not None else None) for a in (204, 241, 264, 280, 290, 300)} emax = max(e for e in best.values() if e is not None) azmax = max(best, key=lambda a: best[a] if best[a] is not None else -99) g4[f"h{h}"] = {"max_elevation": round(emax, 2), "at_azimuth": azmax, "above_horizon_azimuths": span4(above0), "above_5deg_azimuths": span4(above5), "elevation_at": at} say(f" height {h:3d} km: highest {emax:5.1f} deg at azimuth {azmax:3d}; above the horizon over azimuths {span4(above0)}, above 5 deg over {span4(above5)}; " f"elevation at 204, 241, 264, 280, 290, 300: {[at[a] for a in (204, 241, 264, 280, 290, 300)]}") out["G4"] = g4 with open(os.path.join(outdir, "photo_geometry.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_geometry.log"), "w", encoding="utf-8", newline="\n") as f: f.write("\n".join(log) + "\n") if __name__ == "__main__": main()