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

Packages/MoonriseKit/Tests/SkyEngineTests/ProgramVisibilityTests.swift

21 lines · 865 bytes

1 symbol in this file
 1import Foundation
 2import Testing
 3@testable import SkyEngine
 4
 5@Test func bestInDarknessFromChicago() throws {
 6    let m31 = (ra: 10.68471, dec: 41.26875)
 7    let m7 = (ra: 268.46325, dec: -34.79283)
 8    let m104 = (ra: 189.99763, dec: -11.62305)
 9    let t = try Tonight(at: observed, from: chicago)
10    let best = try SkyEngine.bestInDarkness(j2000: [m31, m7, m104], from: t.start, to: t.end, observer: chicago)
11    let andromeda = try #require(best[0])
12    #expect(andromeda.position.altitude > 85)
13    #expect(andromeda.date > t.start && andromeda.date < t.end)
14    // M7 peaks at about 13°, M104 is near the Sun.
15    #expect(best[1] == nil)
16    #expect(best[2] == nil)
17
18    // M104 is 30° up at 13:00 CDT, but in daylight.
19    let day = try SkyEngine.bestInDarkness(j2000: [m104], from: ut(18, 0), to: ut(20, 0), observer: chicago)
20    #expect(day[0] == nil)
21}