import { calculateSun } from '../src/astronomy/sunCalculator.ts'; import { observer } from '../src/config/observer.ts'; import { noaaPosition } from './noaa-reference.ts'; export const solarCases = [ '2026-03-20T06:40:00+09:00', '2026-03-20T12:00:00+09:00', '2026-06-21T05:10:00+09:00', '2026-06-21T12:00:00+09:00', '2026-09-23T06:20:00+09:00', '2026-09-23T18:00:00+09:00', '2026-10-29T06:50:00+09:00', '2026-10-29T12:00:00+09:00', '2026-12-21T07:45:00+09:00', '2026-12-21T12:00:00+09:00', '2026-12-31T23:59:00+09:00', '2027-01-01T00:00:00+09:00', ]; // Independent implementations differ in atmospheric refraction and ephemeris details. export const ANGLE_TOLERANCE = 0.1; // Below 0°, SunCalc clamps its refraction input to 0° (~0.484° correction), // whereas NOAA continues its piecewise formula. Below-zero positions are // compared with a separate 0.5° model tolerance; terrain mode can expose some. export const BELOW_HORIZON_TOLERANCE = 0.5; export function compareSolar(iso: string) { const date = new Date(iso); const actual = calculateSun(date, observer); const reference = noaaPosition(date, observer.latitude, observer.longitude); const azimuthError = Math.abs(((actual.azimuth - reference.azimuth + 540) % 360) - 180); const altitudeTolerance = actual.altitude < 0 ? BELOW_HORIZON_TOLERANCE : ANGLE_TOLERANCE; return { iso, actual, reference, azimuthError, altitudeTolerance, altitudeError: Math.abs(actual.altitude - reference.altitude) }; }