16c62a97d5
- 新增时标、ΔT 模型、质心时间与 UT1 支持 - 改进日月食、月掩、行星事件及路径边界计算 - 完善恒星三维自行与动态距离传播 - 扩展 SVG、GeoJSON、KML 输出与底层距离换算工具 - 整理中英文手册、示例资源及回归测试
48 lines
2.0 KiB
Go
48 lines
2.0 KiB
Go
package eclipse
|
||
|
||
import (
|
||
"math"
|
||
"testing"
|
||
"time"
|
||
|
||
"b612.me/astro/basic"
|
||
)
|
||
|
||
// 三个 info 都带 provenance:GreatestJDE(力学时)经 TT2UTC 复现民用时刻字段;
|
||
// DeltaTSeconds 是 TT−UT1,不能用来做这次换算(会差一个 DUT1)。
|
||
func TestEclipseInfoCarriesProvenance(t *testing.T) {
|
||
date := time.Date(2024, time.April, 8, 12, 0, 0, 0, time.UTC)
|
||
solar, ok := SolarEclipseOnDate(date)
|
||
if !ok {
|
||
t.Fatal("缺少 2024-04-08 日食")
|
||
}
|
||
if solar.GreatestJDE == 0 || solar.DeltaTSeconds == 0 {
|
||
t.Fatalf("日食 provenance 未填充: JDE=%v ΔT=%v", solar.GreatestJDE, solar.DeltaTSeconds)
|
||
}
|
||
if got := solarEclipseTTJDEToTime(solar.GreatestJDE, solar.GreatestEclipse.Location()); !got.Equal(solar.GreatestEclipse) {
|
||
t.Errorf("GreatestJDE 未经 TT2UTC 复现食甚时刻: %v vs %v", got, solar.GreatestEclipse)
|
||
}
|
||
// DUT1 非零时,用 ΔT 换算出来的 UT1 时刻必须与民用时刻不同:两者的差就是 DUT1。
|
||
ut1 := basic.JD2DateByZone(solar.GreatestJDE-solar.DeltaTSeconds/86400, solar.GreatestEclipse.Location(), false)
|
||
dut1 := (basic.TT2UTC(solar.GreatestJDE)-solar.GreatestJDE)*86400 - solar.DeltaTSeconds
|
||
if math.Abs(dut1) > 1e-3 && ut1.Equal(solar.GreatestEclipse) {
|
||
t.Errorf("民用时刻字段走了 ΔT(TT−UT1)换算: %v vs %v", ut1, solar.GreatestEclipse)
|
||
}
|
||
|
||
local := ClosestLocalSolarEclipse(date, -96.8, 32.8, 0)
|
||
if local.GreatestJDE == 0 || local.DeltaTSeconds == 0 {
|
||
t.Fatalf("站心日食 provenance 未填充: JDE=%v ΔT=%v", local.GreatestJDE, local.DeltaTSeconds)
|
||
}
|
||
if got := solarEclipseTTJDEToTime(local.GreatestJDE, local.GreatestEclipse.Location()); !got.Equal(local.GreatestEclipse) {
|
||
t.Errorf("GreatestJDE+ΔT 未复现站心食甚: %v vs %v", got, local.GreatestEclipse)
|
||
}
|
||
|
||
lunar, ok := LunarEclipseOnDate(time.Date(2025, time.September, 7, 12, 0, 0, 0, time.UTC))
|
||
if !ok {
|
||
t.Fatal("缺少 2025-09-07 月食")
|
||
}
|
||
if lunar.GreatestJDE == 0 || lunar.DeltaTSeconds == 0 {
|
||
t.Fatalf("月食 provenance 未填充: JDE=%v ΔT=%v", lunar.GreatestJDE, lunar.DeltaTSeconds)
|
||
}
|
||
}
|