feat: 引入可切换星历模型并扩展天象观测链路
- 新增半解析、旧模型、自定义与多源堆叠星历实例,提供 Context、Instance、SPK 读取及状态与视位置计算 - 统一太阳、月球和行星实例接口,扩展黄经穿越、留、相位、最近角距、偕日可见、任意高度升落、轨道节点及凌日等天象查询 - 完善日月食、月掩与凌日的月缘剖面、有限盘面接触、站心修正、局地可见性、全球路径和地图输出 - 新增 SVG、GeoJSON、KML 天象输出及凌日、月掩和月缘地形相关缓存与几何求解 - 新增恒星星表导入与查询,支持 CSV、Hipparcos、BSC5、Stellarium 等格式及名称、交叉标识、锥面检索和星等过滤 - 补充 IAU 2006、地球定向、折射消光、大气观测、轨道传播及半解析行星/月球数据支持 - 将默认未来民用时标切换为 TimeScaleLeapHour,更新 2027–2400 农历速查表、中文日期解析和时区边界处理 - 增加事件基线、跨模型回归、几何边界、月缘地形和输出契约测试,完善中英文手册、示例资源、NOTICE 与忽略规则
This commit is contained in:
@@ -0,0 +1,144 @@
|
||||
package moon
|
||||
|
||||
import (
|
||||
"b612.me/astro/basic"
|
||||
"b612.me/astro/internal/ephem"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
type contextAPI interface {
|
||||
Altitude(date time.Time, lon, lat float64) float64
|
||||
ApogeesInMonth(year int, month time.Month) []ApsisInfo
|
||||
ApparentAltitude(date time.Time, lon, lat, pressureHPa, temperatureC float64) float64
|
||||
ApparentDec(date time.Time, lon, lat float64) float64
|
||||
ApparentLo(date time.Time) float64
|
||||
ApparentRa(date time.Time, lon, lat float64) float64
|
||||
ApparentRaDec(date time.Time, lon, lat float64) (float64, float64)
|
||||
ApparentZenith(date time.Time, lon, lat, pressureHPa, temperatureC float64) float64
|
||||
AscendingNode(date time.Time) float64
|
||||
AscendingNodeN(date time.Time, n int) float64
|
||||
Azimuth(date time.Time, lon, lat float64) float64
|
||||
BrightLimbPositionAngle(date time.Time) float64
|
||||
BrightLimbPositionAngleN(date time.Time, n int) float64
|
||||
ClosestConjunctionWithPlanet(date time.Time, planet ConjunctionPlanet) time.Time
|
||||
ClosestFirstQuarter(date time.Time) time.Time
|
||||
ClosestFullMoon(date time.Time) time.Time
|
||||
ClosestLastQuarter(date time.Time) time.Time
|
||||
ClosestMaximumNorthDeclination(date time.Time) MaximumDeclinationInfo
|
||||
ClosestMaximumSouthDeclination(date time.Time) MaximumDeclinationInfo
|
||||
ClosestNewMoon(date time.Time) time.Time
|
||||
ClosestShangXianYue(date time.Time) time.Time
|
||||
ClosestShuoYue(date time.Time) time.Time
|
||||
ClosestWangYue(date time.Time) time.Time
|
||||
ClosestXiaXianYue(date time.Time) time.Time
|
||||
CulminationTime(date time.Time, lon, lat float64) time.Time
|
||||
DescendingNode(date time.Time) float64
|
||||
DescendingNodeN(date time.Time, n int) float64
|
||||
Diameter(date time.Time) float64
|
||||
DiameterN(date time.Time, n int) float64
|
||||
DownTime(date time.Time, lon, lat, height float64, aero bool) (time.Time, error)
|
||||
EarthDistance(date time.Time) float64
|
||||
FindBestPlanetOccultations(start, end time.Time, planet OccultationPlanet,
|
||||
options OccultationSearchOptions) ([]PlanetOccultationInfo, error)
|
||||
FindBestStarOccultations(start, end time.Time, star StarCoordinate, options OccultationSearchOptions) ([]StarOccultationInfo, error)
|
||||
FindPlanetOccultationPaths(start, end time.Time, planet OccultationPlanet,
|
||||
options OccultationPathOptions) ([]PlanetOccultationPath, error)
|
||||
FindPlanetOccultations(start, end time.Time, planet OccultationPlanet, longitude, latitude, height float64,
|
||||
options OccultationSearchOptions) ([]PlanetOccultationInfo, error)
|
||||
FindStarOccultationPaths(start, end time.Time, star StarCoordinate, options OccultationPathOptions) ([]StarOccultationPath, error)
|
||||
FindStarOccultations(start, end time.Time, star StarCoordinate, longitude, latitude, height float64,
|
||||
options OccultationSearchOptions) ([]StarOccultationInfo, error)
|
||||
FirstQuarter(year float64) time.Time
|
||||
FullMoon(year float64) time.Time
|
||||
GeocentricApparentDec(date time.Time) float64
|
||||
GeocentricApparentRa(date time.Time) float64
|
||||
GeocentricApparentRaDec(date time.Time) (float64, float64)
|
||||
HourAngle(date time.Time, lon, lat float64) float64
|
||||
LastConjunctionWithPlanet(date time.Time, planet ConjunctionPlanet) time.Time
|
||||
LastFirstQuarter(date time.Time) time.Time
|
||||
LastFullMoon(date time.Time) time.Time
|
||||
LastLastQuarter(date time.Time) time.Time
|
||||
LastMaximumNorthDeclination(date time.Time) MaximumDeclinationInfo
|
||||
LastMaximumSouthDeclination(date time.Time) MaximumDeclinationInfo
|
||||
LastNewMoon(date time.Time) time.Time
|
||||
LastQuarter(year float64) time.Time
|
||||
LastShangXianYue(date time.Time) time.Time
|
||||
LastShuoYue(date time.Time) time.Time
|
||||
LastWangYue(date time.Time) time.Time
|
||||
LastXiaXianYue(date time.Time) time.Time
|
||||
MaximumNorthDeclinationsInMonth(year int, month time.Month) []MaximumDeclinationInfo
|
||||
MaximumSouthDeclinationsInMonth(year int, month time.Month) []MaximumDeclinationInfo
|
||||
NewMoon(year float64) time.Time
|
||||
NextConjunctionWithPlanet(date time.Time, planet ConjunctionPlanet) time.Time
|
||||
NextFirstQuarter(date time.Time) time.Time
|
||||
NextFullMoon(date time.Time) time.Time
|
||||
NextLastQuarter(date time.Time) time.Time
|
||||
NextMaximumNorthDeclination(date time.Time) MaximumDeclinationInfo
|
||||
NextMaximumSouthDeclination(date time.Time) MaximumDeclinationInfo
|
||||
NextNewMoon(date time.Time) time.Time
|
||||
NextShangXianYue(date time.Time) time.Time
|
||||
NextShuoYue(date time.Time) time.Time
|
||||
NextWangYue(date time.Time) time.Time
|
||||
NextXiaXianYue(date time.Time) time.Time
|
||||
ParallacticAngle(date time.Time, lon, lat float64) float64
|
||||
PerigeesInMonth(year int, month time.Month) []ApsisInfo
|
||||
Phase(date time.Time) float64
|
||||
PhaseDesc(date time.Time) string
|
||||
Physical(date time.Time) PhysicalInfo
|
||||
PhysicalN(date time.Time, n int) PhysicalInfo
|
||||
PlanetOccultationDiagram(
|
||||
info PlanetOccultationInfo,
|
||||
options PlanetOccultationDiagramOptions,
|
||||
) PlanetOccultationDiagramResult
|
||||
PlanetOccultationFootprintsAt(at time.Time, planet OccultationPlanet) (PlanetOccultationInstant, error)
|
||||
PlanetOccultationInfoInUT1(info basic.PlanetOccultationInfo) basic.PlanetOccultationInfo
|
||||
PlanetOccultationPathInUT1(path basic.PlanetOccultationPath) basic.PlanetOccultationPath
|
||||
RiseTime(date time.Time, lon, lat, height float64, aero bool) (time.Time, error)
|
||||
Semidiameter(date time.Time) float64
|
||||
SemidiameterN(date time.Time, n int) float64
|
||||
SetTime(date time.Time, lon, lat, height float64, aero bool) (time.Time, error)
|
||||
ShangXianYue(year float64) time.Time
|
||||
ShuoYue(year float64) time.Time
|
||||
StarCoordinateFromStarData(star StarData) (StarCoordinate, error)
|
||||
StarOccultationDiagram(
|
||||
info StarOccultationInfo,
|
||||
star StarCoordinate,
|
||||
options StarOccultationDiagramOptions,
|
||||
) StarOccultationDiagramResult
|
||||
StarOccultationFootprintAt(at time.Time, star StarCoordinate) (StarOccultationInstant, error)
|
||||
StarOccultationInfoInUT1(info basic.StarOccultationInfo) basic.StarOccultationInfo
|
||||
StarOccultationPathInUT1(path basic.StarOccultationPath) basic.StarOccultationPath
|
||||
SunMoonLoDiff(date time.Time) float64
|
||||
TopocentricBrightLimbPositionAngle(date time.Time, observerLon, observerLat, height float64) float64
|
||||
TopocentricBrightLimbPositionAngleN(date time.Time, observerLon, observerLat, height float64, n int) float64
|
||||
TopocentricPhysical(date time.Time, observerLon, observerLat, height float64) PhysicalInfo
|
||||
TopocentricPhysicalN(date time.Time, observerLon, observerLat, height float64, n int) PhysicalInfo
|
||||
TrueBo(date time.Time) float64
|
||||
TrueBoN(date time.Time, n int) float64
|
||||
TrueDec(date time.Time) float64
|
||||
TrueLo(date time.Time) float64
|
||||
TrueLoN(date time.Time, n int) float64
|
||||
TrueRa(date time.Time) float64
|
||||
TrueRaDec(date time.Time) (float64, float64)
|
||||
WangYue(year float64) time.Time
|
||||
XiaXianYue(year float64) time.Time
|
||||
Zenith(date time.Time, lon, lat float64) float64
|
||||
}
|
||||
|
||||
var _ contextAPI = (*Moon)(nil)
|
||||
|
||||
func TestContextModuleIsolation(t *testing.T) {
|
||||
previous := basic.GetEphemerisModel()
|
||||
t.Cleanup(func() { basic.SetEphemerisModel(previous) })
|
||||
date := time.Date(2024, 10, 6, 12, 0, 0, 0, time.UTC)
|
||||
for _, model := range []ephem.Model{ephem.Legacy, ephem.Semianalytic} {
|
||||
basic.SetEphemerisModel(basic.EphemerisModel(model))
|
||||
want := ApparentLo(date)
|
||||
module := NewWithInstance(ephem.NewModelInstance(model))
|
||||
basic.SetEphemerisModel(basic.EphemerisModel(1 - int(model)))
|
||||
if got := module.ApparentLo(date); got != want {
|
||||
t.Fatalf("model %d: longitude %.12f, want %.12f", model, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user