feat: 扩展天文计算能力
- 新增日食、月食、本地可见性、中心线、半影区域、SVG 图示与沙罗周期信息 - 新增行星冲合、留、方照、物理星历、视直径、相位、亮肢角、轨道节点等计算 - 新增木星伽利略卫星位置、现象与接触事件计算 - 新增恒星星表、星座判定、自行修正与观测辅助能力 - 新增 coord、formula、orbit、sundial、lite/sun、lite/moon 等扩展包 - 完善农历年号、月相英文别名、视差角、大气质量、折射、日晷与双星计算 - 增加 NASA、JPL Horizons、IMCCE 等回归测试数据与基线测试 - 重构基础算法文件组织,补充大量公开 API 注释和语义回归测试 - 更新中文和英文 README,补充示例、精度说明、SVG 配图
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
package basic
|
||||
|
||||
import (
|
||||
"math"
|
||||
"time"
|
||||
)
|
||||
|
||||
type mercuryEventFunc func(float64) float64
|
||||
|
||||
type mercuryEventCase struct {
|
||||
name string
|
||||
tolerance float64
|
||||
fn mercuryEventFunc
|
||||
}
|
||||
|
||||
func mercuryEventSamples() []time.Time {
|
||||
start := time.Date(1995, 1, 15, 12, 34, 56, 789000000, time.UTC)
|
||||
samples := make([]time.Time, 0, 96)
|
||||
for i := 0; i < 48; i++ {
|
||||
d := start.AddDate(0, 0, i*137)
|
||||
d = d.Add(time.Duration((i%7)*3)*time.Hour + time.Duration((i%11)*7)*time.Minute + time.Duration((i%13)*11)*time.Second)
|
||||
samples = append(samples, d)
|
||||
}
|
||||
extraStart := start.AddDate(0, 0, 41)
|
||||
for i := 0; i < 48; i++ {
|
||||
d := extraStart.AddDate(0, 0, i*89)
|
||||
d = d.Add(time.Duration((i%5)*7)*time.Hour + time.Duration((i%13)*5)*time.Minute + time.Duration((i%17)*19)*time.Second)
|
||||
samples = append(samples, d)
|
||||
}
|
||||
return samples
|
||||
}
|
||||
|
||||
func mercuryEventSampleTTJD(date time.Time) float64 {
|
||||
return TD2UT(Date2JDE(date.UTC()), true)
|
||||
}
|
||||
|
||||
func mercuryEventCases() []mercuryEventCase {
|
||||
const (
|
||||
conjunctionTolerance = 0.00001
|
||||
searchTolerance = 30.0 / 86400.0
|
||||
)
|
||||
return []mercuryEventCase{
|
||||
{name: "LastMercuryConjunction", tolerance: conjunctionTolerance, fn: LastMercuryConjunction},
|
||||
{name: "NextMercuryConjunction", tolerance: conjunctionTolerance, fn: NextMercuryConjunction},
|
||||
{name: "LastMercuryInferiorConjunction", tolerance: conjunctionTolerance, fn: LastMercuryInferiorConjunction},
|
||||
{name: "NextMercuryInferiorConjunction", tolerance: conjunctionTolerance, fn: NextMercuryInferiorConjunction},
|
||||
{name: "LastMercurySuperiorConjunction", tolerance: conjunctionTolerance, fn: LastMercurySuperiorConjunction},
|
||||
{name: "NextMercurySuperiorConjunction", tolerance: conjunctionTolerance, fn: NextMercurySuperiorConjunction},
|
||||
{name: "LastMercuryRetrograde", tolerance: searchTolerance, fn: LastMercuryRetrograde},
|
||||
{name: "NextMercuryRetrograde", tolerance: searchTolerance, fn: NextMercuryRetrograde},
|
||||
{name: "LastMercuryProgradeToRetrograde", tolerance: searchTolerance, fn: LastMercuryProgradeToRetrograde},
|
||||
{name: "NextMercuryProgradeToRetrograde", tolerance: searchTolerance, fn: NextMercuryProgradeToRetrograde},
|
||||
{name: "LastMercuryRetrogradeToPrograde", tolerance: searchTolerance, fn: LastMercuryRetrogradeToPrograde},
|
||||
{name: "NextMercuryRetrogradeToPrograde", tolerance: searchTolerance, fn: NextMercuryRetrogradeToPrograde},
|
||||
{name: "LastMercuryGreatestElongation", tolerance: searchTolerance, fn: LastMercuryGreatestElongation},
|
||||
{name: "NextMercuryGreatestElongation", tolerance: searchTolerance, fn: NextMercuryGreatestElongation},
|
||||
{name: "LastMercuryGreatestElongationEast", tolerance: searchTolerance, fn: LastMercuryGreatestElongationEast},
|
||||
{name: "NextMercuryGreatestElongationEast", tolerance: searchTolerance, fn: NextMercuryGreatestElongationEast},
|
||||
{name: "LastMercuryGreatestElongationWest", tolerance: searchTolerance, fn: LastMercuryGreatestElongationWest},
|
||||
{name: "NextMercuryGreatestElongationWest", tolerance: searchTolerance, fn: NextMercuryGreatestElongationWest},
|
||||
}
|
||||
}
|
||||
|
||||
func almostEqualWithinDays(got, want, tolerance float64) bool {
|
||||
return math.Abs(got-want) <= tolerance
|
||||
}
|
||||
Reference in New Issue
Block a user