krz/moonrise

Night-sky companion for iPhone, Apple Watch and Vision Pro: what's up tonight, the Moon, planets, launches and missions, and a Library of the solar system. SwiftUI app with a Cloudflare Workers backend. astronomy cloudflare-workers ios night-sky space swiftui visionos watchos

Commit d8a14acfea

d8a14acfea6e1aaf0fd417ad2ab44b7b7fa619a3

parent: 74a8292860

Unsigned

cmc <hello@cleberg.net> · 2026-10-22 04:34 UTC

Events: meteor radiant altitude (!134)

- `MeteorShower.ra`/`dec`: IMO working-list radiants at peak, J2000.
- `highestRadiant(in:from:)`: 10-minute samples over the dark window, precessed to date.
- `radiantNote`: "Radiant highest at 05:12, 64° up: about 18 an hour then.", or below the horizon all night. Added to the meteor peak detail in Events.
- Test: Perseids from Chicago peak near dawn at 60–80°; Ursids never rise from Sydney.

Layout: unified · split

PLAN.org +2
@@ -584,6 +584,8 @@ Worker; DSN Now freshness; NASA/ESA image licences; 26 LoC plates bundled.
584584
585585** v5.6: Observing
586586- Meteor radiant altitude (radiant coordinates for the major showers).
587 Done: IMO radiants; each peak in Events gives when the radiant is highest
588 in the dark window, how high, and ZHR × sin(altitude).
587589- IMO, COBS and AAVSO exports; a program log PDF.
588590- Astronomical League lists (Herschel 400, Double Star, Lunar, Binocular
589591 Messier) and Lunar 100 (Charles Wood, Sky & Telescope), with permission;
Packages/MoonriseKit/Sources/SkyEngine/Events.swift +32 −9
@@ -21,6 +21,26 @@ public struct SkyEvent: Sendable, Identifiable, Equatable {
2121 public var id: String { "\(kind.rawValue)-\(title)-\(Int(date.timeIntervalSince1970))" }
2222}
2323
24extension MeteorShower {
25 /// When in `window` the radiant stands highest, and how high (degrees), sampled every 10 minutes.
26 public func highestRadiant(in window: DateInterval, from observer: Observer) -> (date: Date, altitude: Double) {
27 let eq = SkyEngine.equatorOfDate(j2000: (ra, dec), at: window.start)
28 let steps = max(1, Int(window.duration / 600))
29 return (0...steps).map { i -> (date: Date, altitude: Double) in
30 let t = min(window.end, window.start.addingTimeInterval(Double(i) * 600))
31 return (t, SkyEngine.horizontal(rightAscension: eq.ra / 15, declination: eq.dec, at: t, from: observer).altitude)
32 }.max { $0.altitude < $1.altitude }!
33 }
34
35 /// The radiant's best altitude in `window` and the rate it allows, ZHR × sin(altitude), as a sentence.
36 public func radiantNote(in window: DateInterval, from observer: Observer, time: Date.FormatStyle = .init(date: .omitted, time: .shortened)) -> String {
37 let best = highestRadiant(in: window, from: observer)
38 guard best.altitude > 0 else { return "The radiant stays below the horizon while it is dark." }
39 let rate = Int((Double(zhr) * sin(best.altitude * .pi / 180)).rounded())
40 return "Radiant highest at \(best.date.formatted(time)), \(Int(best.altitude.rounded()))° up: about \(rate) an hour then."
41 }
42}
43
2444extension SkyEvent {
2545 /// When a Lock Screen activity for a meteor shower's peak night starts: 10 minutes before dark, or `now` if that
2646 /// has passed. Nil for other events, once the night is over, or more than a day ahead.
@@ -38,16 +58,19 @@ public struct MeteorShower: Sendable {
3858 public var day: Int
3959 /// Zenithal hourly rate at peak under ideal skies.
4060 public var zhr: Int
61 /// Radiant at peak, J2000 degrees.
62 public var ra: Double
63 public var dec: Double
4164
4265 public static let major: [MeteorShower] = [
43 MeteorShower(name: "Quadrantids", month: 1, day: 3, zhr: 80),
44 MeteorShower(name: "Lyrids", month: 4, day: 22, zhr: 18),
45 MeteorShower(name: "Eta Aquariids", month: 5, day: 6, zhr: 50),
46 MeteorShower(name: "Perseids", month: 8, day: 12, zhr: 100),
47 MeteorShower(name: "Orionids", month: 10, day: 21, zhr: 20),
48 MeteorShower(name: "Leonids", month: 11, day: 17, zhr: 15),
49 MeteorShower(name: "Geminids", month: 12, day: 14, zhr: 150),
50 MeteorShower(name: "Ursids", month: 12, day: 22, zhr: 10),
66 MeteorShower(name: "Quadrantids", month: 1, day: 3, zhr: 80, ra: 230, dec: 49),
67 MeteorShower(name: "Lyrids", month: 4, day: 22, zhr: 18, ra: 271, dec: 34),
68 MeteorShower(name: "Eta Aquariids", month: 5, day: 6, zhr: 50, ra: 338, dec: -1),
69 MeteorShower(name: "Perseids", month: 8, day: 12, zhr: 100, ra: 48, dec: 58),
70 MeteorShower(name: "Orionids", month: 10, day: 21, zhr: 20, ra: 95, dec: 16),
71 MeteorShower(name: "Leonids", month: 11, day: 17, zhr: 15, ra: 152, dec: 22),
72 MeteorShower(name: "Geminids", month: 12, day: 14, zhr: 150, ra: 112, dec: 33),
73 MeteorShower(name: "Ursids", month: 12, day: 22, zhr: 10, ra: 217, dec: 75),
5174 ]
5275}
5376
@@ -169,7 +192,7 @@ extension SkyEngine {
169192 let dark = try? darkness(from: night.start, to: night.end, observer: observer)
170193 let moon = moonAndDarkness(night: night, dark: dark,
171194 moonUp: (try? moonUp(from: night.start, to: night.end, observer: observer)) ?? [], moonIllumination: lit)
172 out.append(SkyEvent(kind: .meteorShower, date: d, title: "\(m.name) peak", detail: "Up to about \(m.zhr) meteors an hour under dark skies. \(moon)", visibleHere: nil, window: dark ?? night,
195 out.append(SkyEvent(kind: .meteorShower, date: d, title: "\(m.name) peak", detail: "Up to about \(m.zhr) meteors an hour under dark skies. \(m.radiantNote(in: dark ?? night, from: observer)) \(moon)", visibleHere: nil, window: dark ?? night,
173196 zhr: m.zhr, moonIllumination: lit))
174197 }
175198 }
Packages/MoonriseKit/Tests/SkyEngineTests/MeteorActivityTests.swift +14
@@ -26,3 +26,17 @@ private func peak(darkIn seconds: TimeInterval, kind: SkyEvent.Kind = .meteorSho
2626 #expect(e.zhr != nil)
2727 #expect((0...1).contains(try #require(e.moonIllumination)))
2828}
29
30@Test func radiantAltitudeFollowsTheSky() throws {
31 let chicago = Observer(latitude: 41.88, longitude: -87.63)
32 let perseids = try #require(MeteorShower.major.first { $0.name == "Perseids" })
33 // 2026-08-13 03:00–09:00 UTC, the dark hours over Chicago: the radiant climbs all night and peaks near dawn.
34 let night = DateInterval(start: Date(timeIntervalSince1970: 1_786_590_000), duration: 6 * 3600)
35 let best = perseids.highestRadiant(in: night, from: chicago)
36 #expect(best.date > night.start.addingTimeInterval(5 * 3600))
37 #expect((60...80).contains(best.altitude))
38 // From Sydney the Ursids (dec +75) never rise.
39 let ursids = try #require(MeteorShower.major.first { $0.name == "Ursids" })
40 let sydney = Observer(latitude: -33.87, longitude: 151.21)
41 #expect(ursids.radiantNote(in: night, from: sydney) == "The radiant stays below the horizon while it is dark.")
42}