Files
astro/moon/occultation_ut1.go
T
b612 044f2f4381 feat: 引入可切换星历模型并扩展天象观测链路
- 新增半解析、旧模型、自定义与多源堆叠星历实例,提供 Context、Instance、SPK 读取及状态与视位置计算
- 统一太阳、月球和行星实例接口,扩展黄经穿越、留、相位、最近角距、偕日可见、任意高度升落、轨道节点及凌日等天象查询
- 完善日月食、月掩与凌日的月缘剖面、有限盘面接触、站心修正、局地可见性、全球路径和地图输出
- 新增 SVG、GeoJSON、KML 天象输出及凌日、月掩和月缘地形相关缓存与几何求解
- 新增恒星星表导入与查询,支持 CSV、Hipparcos、BSC5、Stellarium 等格式及名称、交叉标识、锥面检索和星等过滤
- 补充 IAU 2006、地球定向、折射消光、大气观测、轨道传播及半解析行星/月球数据支持
- 将默认未来民用时标切换为 TimeScaleLeapHour,更新 2027–2400 农历速查表、中文日期解析和时区边界处理
- 增加事件基线、跨模型回归、几何边界、月缘地形和输出契约测试,完善中英文手册、示例资源、NOTICE 与忽略规则
2026-10-15 23:54:15 +08:00

151 lines
6.6 KiB
Go

package moon
import (
"time"
"b612.me/astro/basic"
)
// 月掩各载体的 UT1 时刻换算,供月掩 SVG 使用。两条铁律与日食侧一致:
// 零值 time.Time 表示该点或阶段不存在,一律原样保留;返回新副本,不改写调用方传进来的 path/info。
func occultationUT1Label(t time.Time) time.Time {
if t.IsZero() {
return t
}
return basic.LabelIn(basic.TimeScaleUT1, t)
}
func occultationUT1PathPoint(p basic.OccultationPathPoint) basic.OccultationPathPoint {
p.Time = occultationUT1Label(p.Time)
return p
}
func occultationUT1PathPoints(points []basic.OccultationPathPoint) []basic.OccultationPathPoint {
out := make([]basic.OccultationPathPoint, len(points))
for i := range points {
out[i] = occultationUT1PathPoint(points[i])
}
return out
}
func occultationUT1PathGrid(grid [][]basic.OccultationPathPoint) [][]basic.OccultationPathPoint {
out := make([][]basic.OccultationPathPoint, len(grid))
for i := range grid {
out[i] = occultationUT1PathPoints(grid[i])
}
return out
}
func occultationUT1Footprints(list []basic.OccultationFootprint) []basic.OccultationFootprint {
out := make([]basic.OccultationFootprint, len(list))
for i := range list {
out[i] = list[i]
out[i].Time = occultationUT1Label(list[i].Time)
out[i].Polygons = occultationUT1PathGrid(list[i].Polygons)
out[i].InteriorPolygons = occultationUT1PathGrid(list[i].InteriorPolygons)
out[i].Boundaries = occultationUT1PathGrid(list[i].Boundaries)
}
return out
}
func occultationUT1RiseSetCurves(list []basic.OccultationRiseSetCurve) []basic.OccultationRiseSetCurve {
out := make([]basic.OccultationRiseSetCurve, len(list))
for i := range list {
out[i] = list[i]
out[i].Segments = occultationUT1PathGrid(list[i].Segments)
}
return out
}
func occultationUT1GreatestTimeContours(list []basic.OccultationGreatestTimeContour) []basic.OccultationGreatestTimeContour {
out := make([]basic.OccultationGreatestTimeContour, len(list))
for i := range list {
out[i] = list[i]
out[i].Time = occultationUT1Label(list[i].Time)
out[i].Segments = occultationUT1PathGrid(list[i].Segments)
}
return out
}
// StarOccultationPathInUT1 返回恒星月掩全球路径的 UT1 时刻副本 / copy in UT1 of a stellar path.
func StarOccultationPathInUT1(path basic.StarOccultationPath) basic.StarOccultationPath {
path.Start = occultationUT1PathPoint(path.Start)
path.Greatest = occultationUT1PathPoint(path.Greatest)
path.End = occultationUT1PathPoint(path.End)
path.CenterLine = occultationUT1PathPoints(path.CenterLine)
path.NorthernLimit = occultationUT1PathPoints(path.NorthernLimit)
path.SouthernLimit = occultationUT1PathPoints(path.SouthernLimit)
path.BandContours = occultationUT1PathGrid(path.BandContours)
path.VisibilityContours = occultationUT1PathGrid(path.VisibilityContours)
path.Footprints = occultationUT1Footprints(path.Footprints)
path.BandFootprints = occultationUT1Footprints(path.BandFootprints)
path.RiseSetCurves = occultationUT1RiseSetCurves(path.RiseSetCurves)
path.GreatestTimeContours = occultationUT1GreatestTimeContours(path.GreatestTimeContours)
return path
}
// PlanetOccultationPathInUT1 返回行星月掩全球掩带的 UT1 时刻副本 / copy in UT1 of a planetary path.
func PlanetOccultationPathInUT1(path basic.PlanetOccultationPath) basic.PlanetOccultationPath {
path.Start = occultationUT1PathPoint(path.Start)
path.Greatest = occultationUT1PathPoint(path.Greatest)
path.End = occultationUT1PathPoint(path.End)
path.CenterLine = occultationUT1PathPoints(path.CenterLine)
path.NorthernLimit = occultationUT1PathPoints(path.NorthernLimit)
path.SouthernLimit = occultationUT1PathPoints(path.SouthernLimit)
path.PartialBandContours = occultationUT1PathGrid(path.PartialBandContours)
path.PartialVisibilityContours = occultationUT1PathGrid(path.PartialVisibilityContours)
path.PartialFootprints = occultationUT1Footprints(path.PartialFootprints)
path.PartialBandFootprints = occultationUT1Footprints(path.PartialBandFootprints)
path.RiseSetCurves = occultationUT1RiseSetCurves(path.RiseSetCurves)
path.TotalStart = occultationUT1PathPoint(path.TotalStart)
path.TotalEnd = occultationUT1PathPoint(path.TotalEnd)
path.NorthernTotalLimit = occultationUT1PathPoints(path.NorthernTotalLimit)
path.SouthernTotalLimit = occultationUT1PathPoints(path.SouthernTotalLimit)
path.TotalBandContours = occultationUT1PathGrid(path.TotalBandContours)
path.TotalVisibilityContours = occultationUT1PathGrid(path.TotalVisibilityContours)
path.TotalFootprints = occultationUT1Footprints(path.TotalFootprints)
path.TotalBandFootprints = occultationUT1Footprints(path.TotalBandFootprints)
path.TotalRiseSetCurves = occultationUT1RiseSetCurves(path.TotalRiseSetCurves)
path.GreatestTimeContours = occultationUT1GreatestTimeContours(path.GreatestTimeContours)
return path
}
// StarOccultationInfoInUT1 返回固定地点恒星月掩的 UT1 时刻副本 / copy in UT1 of a local stellar result.
func StarOccultationInfoInUT1(info basic.StarOccultationInfo) basic.StarOccultationInfo {
info.Immersion = occultationUT1Label(info.Immersion)
info.Greatest = occultationUT1Label(info.Greatest)
info.Emersion = occultationUT1Label(info.Emersion)
return info
}
// PlanetOccultationInfoInUT1 返回固定地点行星月掩的 UT1 时刻副本 / copy in UT1 of a local planetary result.
func PlanetOccultationInfoInUT1(info basic.PlanetOccultationInfo) basic.PlanetOccultationInfo {
info.ExternalImmersion = occultationUT1Label(info.ExternalImmersion)
info.InternalImmersion = occultationUT1Label(info.InternalImmersion)
info.Greatest = occultationUT1Label(info.Greatest)
info.InternalEmersion = occultationUT1Label(info.InternalEmersion)
info.ExternalEmersion = occultationUT1Label(info.ExternalEmersion)
return info
}
// StarOccultationLimbProfileInUT1 返回精密恒星月掩的 UT1 时刻副本 / copy in UT1 of a precise stellar occultation.
func StarOccultationLimbProfileInUT1(profile basic.StarOccultationLimbProfileResult) basic.StarOccultationLimbProfileResult {
profile.Occultation = StarOccultationInfoInUT1(profile.Occultation)
segments := make([][]basic.StarOccultationLimbSample, len(profile.Segments))
for i, segment := range profile.Segments {
segments[i] = append([]basic.StarOccultationLimbSample(nil), segment...)
for j := range segments[i] {
segments[i][j].Time = occultationUT1Label(segments[i][j].Time)
}
}
profile.Segments = segments
hidden := append([]basic.OccultationInterval(nil), profile.Hidden...)
for i := range hidden {
hidden[i].Start = occultationUT1Label(hidden[i].Start)
hidden[i].End = occultationUT1Label(hidden[i].End)
}
profile.Hidden = hidden
return profile
}