Files
astro/eclipse/solar_path_isochrone_test.go
T
b612 2bf8478639 feat: 完善日月食与月掩几何链路并扩展历法接口
- 新增日月食中心带、偏食带、阴影足迹、等时线、食分线及升落边界计算,支持极区与混合食拓扑
- 新增日食单时刻阴影求解器、站心状态查询、批量采样和 ΔT 覆盖接口
- 重构恒星与行星月掩路径,补充有限盘面接触、站心修正、掩带宽度、极区投影及升落边界
- 扩展 SVG 与 GeoJSON 输出,支持详细面板、全球/极区/地球投影、边界闭合、时间标记和拓扑签名
- 扩展日月食候选搜索、局地搜索、沙罗序列预计算与范围外推,补充系列锚点和成员一致性校验
- 补齐古历纪年、儒略历独有闰日、多公历候选、历法改革跨日及精确日期运算接口
- 优化 ΔT、章动、恒星时、月球地平线、事件根搜索和本地星历缓存,降低重复计算开销并提升边界稳定
2026-09-17 12:27:40 +08:00

78 lines
2.6 KiB
Go

package eclipse
import (
"testing"
"time"
)
// 请求的电平必须原样返回:JDE 往返只有微秒级误差,但整分电平会落到 59.999 秒。
func TestSolarEclipsePartialFootprintsReturnsRequestedGreatestTimes(t *testing.T) {
date := time.Date(2009, time.July, 22, 0, 0, 0, 0, time.UTC)
levels := []time.Time{
time.Date(2009, time.July, 22, 1, 0, 0, 0, time.UTC),
time.Date(2009, time.July, 22, 2, 0, 0, 0, time.UTC),
time.Date(2009, time.July, 22, 3, 0, 0, 0, time.UTC),
}
info, ok := SolarEclipsePartialFootprintsNASABulletinSplitK(date, SolarEclipsePartialFootprintOptions{
Step: 10 * time.Minute, BoundaryPoints: 24, DisableRiseSet: true,
GreatestTimeValues: levels,
})
if !ok {
t.Fatal("missing footprints")
}
if len(info.GreatestTimeContours) == 0 {
t.Fatal("no greatest-time contours")
}
for _, contour := range info.GreatestTimeContours {
matched := false
for _, level := range levels {
if contour.Time.Equal(level) {
matched = true
break
}
}
if !matched {
t.Fatalf("contour time %s is not one of the requested levels",
contour.Time.Format("15:04:05.000"))
}
for _, segment := range contour.Segments {
if len(segment) < 2 {
t.Fatalf("contour %s has a degenerate branch", contour.Time.Format("15:04"))
}
}
}
}
// 按步长请求等时线:时刻按输入时区对齐到整刻度、落在偏食窗口内,并回填 JDE。
func TestSolarEclipsePartialFootprintsGreatestTimeStep(t *testing.T) {
location := time.FixedZone("UTC+8", 8*3600)
date := time.Date(2009, time.July, 22, 0, 0, 0, 0, location)
info, ok := SolarEclipsePartialFootprintsNASABulletinSplitK(date, SolarEclipsePartialFootprintOptions{
Step: 10 * time.Minute, BoundaryPoints: 24, DisableRiseSet: true,
GreatestTimeStep: 30 * time.Minute,
})
if !ok {
t.Fatal("missing footprints")
}
if len(info.GreatestTimeContours) < 2 {
t.Fatalf("step request produced %d contours", len(info.GreatestTimeContours))
}
for _, contour := range info.GreatestTimeContours {
if contour.JDE == 0 {
t.Fatal("contour JDE is not populated")
}
if contour.Time.Nanosecond() != 0 || contour.Time.Second() != 0 || contour.Time.Minute()%30 != 0 {
t.Fatalf("contour time %s is not aligned to the requested step",
contour.Time.Format("15:04:05.000000000"))
}
if contour.Time.Before(info.Eclipse.PartialBeginOnEarth) || contour.Time.After(info.Eclipse.PartialEndOnEarth) {
t.Fatalf("contour %s is outside the partial-eclipse window", contour.Time.Format("15:04"))
}
for _, segment := range contour.Segments {
if len(segment) < 2 {
t.Fatalf("contour %s has a degenerate branch", contour.Time.Format("15:04"))
}
}
}
}