feat: 引入可切换星历模型并扩展天象观测链路
- 新增半解析、旧模型、自定义与多源堆叠星历实例,提供 Context、Instance、SPK 读取及状态与视位置计算 - 统一太阳、月球和行星实例接口,扩展黄经穿越、留、相位、最近角距、偕日可见、任意高度升落、轨道节点及凌日等天象查询 - 完善日月食、月掩与凌日的月缘剖面、有限盘面接触、站心修正、局地可见性、全球路径和地图输出 - 新增 SVG、GeoJSON、KML 天象输出及凌日、月掩和月缘地形相关缓存与几何求解 - 新增恒星星表导入与查询,支持 CSV、Hipparcos、BSC5、Stellarium 等格式及名称、交叉标识、锥面检索和星等过滤 - 补充 IAU 2006、地球定向、折射消光、大气观测、轨道传播及半解析行星/月球数据支持 - 将默认未来民用时标切换为 TimeScaleLeapHour,更新 2027–2400 农历速查表、中文日期解析和时区边界处理 - 增加事件基线、跨模型回归、几何边界、月缘地形和输出契约测试,完善中英文手册、示例资源、NOTICE 与忽略规则
This commit is contained in:
+101
-59
@@ -14,8 +14,10 @@ const (
|
||||
uranusPhaseCoarseTolerance = 30.0 / 86400.0
|
||||
)
|
||||
|
||||
func uranusSunLongitudeDelta(jde, degree float64, filter bool) float64 {
|
||||
sub := Limit360(Limit360(UranusApparentLo(jde)-HSunApparentLo(jde)) - degree)
|
||||
func uranusSunLongitudeDelta(jde, degree float64, filter bool, instances ...*Instance) float64 {
|
||||
inst := instanceValue(instances)
|
||||
|
||||
sub := Limit360(Limit360(UranusApparentLoWithInstance(jde, inst)-HSunApparentLoWithInstance(jde, inst)) - degree)
|
||||
if filter {
|
||||
if sub > 180 {
|
||||
sub -= 360
|
||||
@@ -27,8 +29,10 @@ func uranusSunLongitudeDelta(jde, degree float64, filter bool) float64 {
|
||||
return sub
|
||||
}
|
||||
|
||||
func uranusSunLongitudeDeltaN(jde, degree float64, filter bool, n int) float64 {
|
||||
sub := Limit360(Limit360(UranusApparentLoN(jde, n)-HSunApparentLoN(jde, n)) - degree)
|
||||
func uranusSunLongitudeDeltaN(jde, degree float64, filter bool, n int, instances ...*Instance) float64 {
|
||||
inst := instanceValue(instances)
|
||||
|
||||
sub := Limit360(Limit360(UranusApparentLoNWithInstance(jde, n, inst)-HSunApparentLoNWithInstance(jde, n, inst)) - degree)
|
||||
if filter {
|
||||
if sub > 180 {
|
||||
sub -= 360
|
||||
@@ -40,8 +44,10 @@ func uranusSunLongitudeDeltaN(jde, degree float64, filter bool, n int) float64 {
|
||||
return sub
|
||||
}
|
||||
|
||||
func uranusRADerivative(jde, delta float64) float64 {
|
||||
sub := UranusApparentRa(jde+delta) - UranusApparentRa(jde-delta)
|
||||
func uranusRADerivative(jde, delta float64, instances ...*Instance) float64 {
|
||||
inst := instanceValue(instances)
|
||||
|
||||
sub := UranusApparentRaWithInstance(jde+delta, inst) - UranusApparentRaWithInstance(jde-delta, inst)
|
||||
if sub > 180 {
|
||||
sub -= 360
|
||||
}
|
||||
@@ -51,8 +57,10 @@ func uranusRADerivative(jde, delta float64) float64 {
|
||||
return sub / (2 * delta)
|
||||
}
|
||||
|
||||
func uranusRADerivativeN(jde, delta float64, n int) float64 {
|
||||
sub := UranusApparentRaN(jde+delta, n) - UranusApparentRaN(jde-delta, n)
|
||||
func uranusRADerivativeN(jde, delta float64, n int, instances ...*Instance) float64 {
|
||||
inst := instanceValue(instances)
|
||||
|
||||
sub := UranusApparentRaNWithInstance(jde+delta, n, inst) - UranusApparentRaNWithInstance(jde-delta, n, inst)
|
||||
if sub > 180 {
|
||||
sub -= 360
|
||||
}
|
||||
@@ -62,13 +70,15 @@ func uranusRADerivativeN(jde, delta float64, n int) float64 {
|
||||
return sub / (2 * delta)
|
||||
}
|
||||
|
||||
func uranusConjunctionFull(jde, degree float64, next uint8) float64 {
|
||||
func uranusConjunctionFull(jde, degree float64, next uint8, instances ...*Instance) float64 {
|
||||
inst := instanceValue(instances)
|
||||
|
||||
//0=last 1=next
|
||||
if !isFiniteFloat(jde) || !isFiniteFloat(degree) {
|
||||
return math.NaN()
|
||||
}
|
||||
daysPerDegree := URANUS_S_PERIOD / 360
|
||||
currentDelta := uranusSunLongitudeDelta(jde, degree, false)
|
||||
currentDelta := uranusSunLongitudeDelta(jde, degree, false, inst)
|
||||
if next == 0 {
|
||||
jde -= (360 - currentDelta) * daysPerDegree
|
||||
} else {
|
||||
@@ -78,8 +88,8 @@ func uranusConjunctionFull(jde, degree float64, next uint8) float64 {
|
||||
converged := false
|
||||
for i := 0; i < eventNewtonMaxIterations; i++ {
|
||||
prevJDE := estimateJDE
|
||||
longitudeDelta := uranusSunLongitudeDelta(prevJDE, degree, true)
|
||||
longitudeSlope := (uranusSunLongitudeDelta(prevJDE+0.000005, degree, true) - uranusSunLongitudeDelta(prevJDE-0.000005, degree, true)) / 0.00001
|
||||
longitudeDelta := uranusSunLongitudeDelta(prevJDE, degree, true, inst)
|
||||
longitudeSlope := (uranusSunLongitudeDelta(prevJDE+0.000005, degree, true, inst) - uranusSunLongitudeDelta(prevJDE-0.000005, degree, true, inst)) / 0.00001
|
||||
nextJD := prevJDE - longitudeDelta/longitudeSlope
|
||||
estimateJDE = nextJD
|
||||
if math.Abs(nextJD-prevJDE) <= 0.00001 {
|
||||
@@ -93,13 +103,15 @@ func uranusConjunctionFull(jde, degree float64, next uint8) float64 {
|
||||
return TT2UTC(estimateJDE)
|
||||
}
|
||||
|
||||
func uranusConjunction(jde, degree float64, next uint8) float64 {
|
||||
func uranusConjunction(jde, degree float64, next uint8, instances ...*Instance) float64 {
|
||||
inst := instanceValue(instances)
|
||||
|
||||
//0=last 1=next
|
||||
if !isFiniteFloat(jde) || !isFiniteFloat(degree) {
|
||||
return math.NaN()
|
||||
}
|
||||
daysPerDegree := URANUS_S_PERIOD / 360
|
||||
currentDelta := uranusSunLongitudeDelta(jde, degree, false)
|
||||
currentDelta := uranusSunLongitudeDelta(jde, degree, false, inst)
|
||||
if next == 0 {
|
||||
jde -= (360 - currentDelta) * daysPerDegree
|
||||
} else {
|
||||
@@ -109,8 +121,8 @@ func uranusConjunction(jde, degree float64, next uint8) float64 {
|
||||
converged := false
|
||||
for i := 0; i < eventNewtonMaxIterations; i++ {
|
||||
prevJDE := estimateJDE
|
||||
longitudeDelta := uranusSunLongitudeDeltaN(prevJDE, degree, true, uranusEventSearchN)
|
||||
longitudeSlope := (uranusSunLongitudeDeltaN(prevJDE+0.000005, degree, true, uranusEventSearchN) - uranusSunLongitudeDeltaN(prevJDE-0.000005, degree, true, uranusEventSearchN)) / 0.00001
|
||||
longitudeDelta := uranusSunLongitudeDeltaN(prevJDE, degree, true, uranusEventSearchN, inst)
|
||||
longitudeSlope := (uranusSunLongitudeDeltaN(prevJDE+0.000005, degree, true, uranusEventSearchN, inst) - uranusSunLongitudeDeltaN(prevJDE-0.000005, degree, true, uranusEventSearchN, inst)) / 0.00001
|
||||
nextJD := prevJDE - longitudeDelta/longitudeSlope
|
||||
estimateJDE = nextJD
|
||||
if math.Abs(nextJD-prevJDE) <= uranusPhaseCoarseTolerance {
|
||||
@@ -124,8 +136,8 @@ func uranusConjunction(jde, degree float64, next uint8) float64 {
|
||||
converged = false
|
||||
for i := 0; i < eventNewtonMaxIterations; i++ {
|
||||
prevJDE := estimateJDE
|
||||
longitudeDelta := uranusSunLongitudeDelta(prevJDE, degree, true)
|
||||
longitudeSlope := (uranusSunLongitudeDelta(prevJDE+0.000005, degree, true) - uranusSunLongitudeDelta(prevJDE-0.000005, degree, true)) / 0.00001
|
||||
longitudeDelta := uranusSunLongitudeDelta(prevJDE, degree, true, inst)
|
||||
longitudeSlope := (uranusSunLongitudeDelta(prevJDE+0.000005, degree, true, inst) - uranusSunLongitudeDelta(prevJDE-0.000005, degree, true, inst)) / 0.00001
|
||||
nextJD := prevJDE - longitudeDelta/longitudeSlope
|
||||
estimateJDE = nextJD
|
||||
if math.Abs(nextJD-prevJDE) <= 0.00001 {
|
||||
@@ -139,39 +151,65 @@ func uranusConjunction(jde, degree float64, next uint8) float64 {
|
||||
return TT2UTC(estimateJDE)
|
||||
}
|
||||
|
||||
func LastUranusConjunction(jde float64) float64 {
|
||||
return inclusiveLastPhaseEvent(jde, 0, uranusConjunction)
|
||||
// LastUranusConjunctionWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model.
|
||||
func LastUranusConjunctionWithInstance(jde float64, inst *Instance) float64 {
|
||||
return inclusiveLastPhaseEvent(jde, 0, func(jde, degree float64, next uint8) float64 {
|
||||
return uranusConjunction(jde, degree, next, inst)
|
||||
})
|
||||
}
|
||||
|
||||
func NextUranusConjunction(jde float64) float64 {
|
||||
return inclusiveNextPhaseEvent(jde, 0, uranusConjunction)
|
||||
// NextUranusConjunctionWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model.
|
||||
func NextUranusConjunctionWithInstance(jde float64, inst *Instance) float64 {
|
||||
return inclusiveNextPhaseEvent(jde, 0, func(jde, degree float64, next uint8) float64 {
|
||||
return uranusConjunction(jde, degree, next, inst)
|
||||
})
|
||||
}
|
||||
|
||||
func LastUranusOpposition(jde float64) float64 {
|
||||
return inclusiveLastPhaseEvent(jde, 180, uranusConjunction)
|
||||
// LastUranusOppositionWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model.
|
||||
func LastUranusOppositionWithInstance(jde float64, inst *Instance) float64 {
|
||||
return inclusiveLastPhaseEvent(jde, 180, func(jde, degree float64, next uint8) float64 {
|
||||
return uranusConjunction(jde, degree, next, inst)
|
||||
})
|
||||
}
|
||||
|
||||
func NextUranusOpposition(jde float64) float64 {
|
||||
return inclusiveNextPhaseEvent(jde, 180, uranusConjunction)
|
||||
// NextUranusOppositionWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model.
|
||||
func NextUranusOppositionWithInstance(jde float64, inst *Instance) float64 {
|
||||
return inclusiveNextPhaseEvent(jde, 180, func(jde, degree float64, next uint8) float64 {
|
||||
return uranusConjunction(jde, degree, next, inst)
|
||||
})
|
||||
}
|
||||
|
||||
func NextUranusEasternQuadrature(jde float64) float64 {
|
||||
return inclusiveNextPhaseEvent(jde, 90, uranusConjunction)
|
||||
// NextUranusEasternQuadratureWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model.
|
||||
func NextUranusEasternQuadratureWithInstance(jde float64, inst *Instance) float64 {
|
||||
return inclusiveNextPhaseEvent(jde, 90, func(jde, degree float64, next uint8) float64 {
|
||||
return uranusConjunction(jde, degree, next, inst)
|
||||
})
|
||||
}
|
||||
|
||||
func LastUranusEasternQuadrature(jde float64) float64 {
|
||||
return inclusiveLastPhaseEvent(jde, 90, uranusConjunction)
|
||||
// LastUranusEasternQuadratureWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model.
|
||||
func LastUranusEasternQuadratureWithInstance(jde float64, inst *Instance) float64 {
|
||||
return inclusiveLastPhaseEvent(jde, 90, func(jde, degree float64, next uint8) float64 {
|
||||
return uranusConjunction(jde, degree, next, inst)
|
||||
})
|
||||
}
|
||||
|
||||
func NextUranusWesternQuadrature(jde float64) float64 {
|
||||
return inclusiveNextPhaseEvent(jde, 270, uranusConjunction)
|
||||
// NextUranusWesternQuadratureWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model.
|
||||
func NextUranusWesternQuadratureWithInstance(jde float64, inst *Instance) float64 {
|
||||
return inclusiveNextPhaseEvent(jde, 270, func(jde, degree float64, next uint8) float64 {
|
||||
return uranusConjunction(jde, degree, next, inst)
|
||||
})
|
||||
}
|
||||
|
||||
func LastUranusWesternQuadrature(jde float64) float64 {
|
||||
return inclusiveLastPhaseEvent(jde, 270, uranusConjunction)
|
||||
// LastUranusWesternQuadratureWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model.
|
||||
func LastUranusWesternQuadratureWithInstance(jde float64, inst *Instance) float64 {
|
||||
return inclusiveLastPhaseEvent(jde, 270, func(jde, degree float64, next uint8) float64 {
|
||||
return uranusConjunction(jde, degree, next, inst)
|
||||
})
|
||||
}
|
||||
|
||||
func uranusRetrogradeAroundOpposition(oppositionJD float64, searchBeforeOpposition bool) float64 {
|
||||
func uranusRetrogradeAroundOpposition(oppositionJD float64, searchBeforeOpposition bool, instances ...*Instance) float64 {
|
||||
inst := instanceValue(instances)
|
||||
|
||||
if !isFiniteFloat(oppositionJD) {
|
||||
return math.NaN()
|
||||
}
|
||||
@@ -179,103 +217,107 @@ func uranusRetrogradeAroundOpposition(oppositionJD float64, searchBeforeOppositi
|
||||
startTT := oppositionTT
|
||||
endTT := oppositionTT
|
||||
if searchBeforeOpposition {
|
||||
easternQuadratureUT := uranusConjunction(oppositionTT, 90, 0)
|
||||
easternQuadratureUT := uranusConjunction(oppositionTT, 90, 0, inst)
|
||||
startTT = UTC2TT(easternQuadratureUT)
|
||||
} else {
|
||||
westernQuadratureUT := uranusConjunction(oppositionTT, 270, 1)
|
||||
westernQuadratureUT := uranusConjunction(oppositionTT, 270, 1, inst)
|
||||
endTT = UTC2TT(westernQuadratureUT)
|
||||
}
|
||||
bestJDE := zeroEventInWindow(startTT, endTT, 2.0, 2.0, 30.0/86400.0, func(jd float64) float64 {
|
||||
return uranusRADerivativeN(jd, stationDerivativeStepDay, uranusEventSearchN)
|
||||
return uranusRADerivativeN(jd, stationDerivativeStepDay, uranusEventSearchN, inst)
|
||||
}, func(jd float64) float64 {
|
||||
return uranusRADerivative(jd, stationDerivativeStepDay)
|
||||
return uranusRADerivative(jd, stationDerivativeStepDay, inst)
|
||||
})
|
||||
return TT2UTC(bestJDE)
|
||||
}
|
||||
|
||||
func NextUranusRetrogradeToPrograde(jde float64) float64 {
|
||||
// NextUranusRetrogradeToProgradeWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model.
|
||||
func NextUranusRetrogradeToProgradeWithInstance(jde float64, inst *Instance) float64 {
|
||||
if !isFiniteFloat(jde) {
|
||||
return math.NaN()
|
||||
}
|
||||
lastOppositionJD := uranusConjunctionFull(jde, 180, 0)
|
||||
date := uranusRetrogradeAroundOpposition(lastOppositionJD, false)
|
||||
lastOppositionJD := uranusConjunctionFull(jde, 180, 0, inst)
|
||||
date := uranusRetrogradeAroundOpposition(lastOppositionJD, false, inst)
|
||||
if isFiniteFloat(date) && stationUTQueryAfterOrEqual(date, jde) {
|
||||
return date
|
||||
}
|
||||
nextOppositionJD := uranusConjunctionFull(jde, 180, 1)
|
||||
nextOppositionJD := uranusConjunctionFull(jde, 180, 1, inst)
|
||||
if !isFiniteFloat(nextOppositionJD) {
|
||||
return math.NaN()
|
||||
}
|
||||
date = uranusRetrogradeAroundOpposition(nextOppositionJD, false)
|
||||
date = uranusRetrogradeAroundOpposition(nextOppositionJD, false, inst)
|
||||
if !isFiniteFloat(date) || !stationUTQueryAfterOrEqual(date, jde) {
|
||||
return math.NaN()
|
||||
}
|
||||
return date
|
||||
}
|
||||
|
||||
func LastUranusRetrogradeToPrograde(jde float64) float64 {
|
||||
// LastUranusRetrogradeToProgradeWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model.
|
||||
func LastUranusRetrogradeToProgradeWithInstance(jde float64, inst *Instance) float64 {
|
||||
if !isFiniteFloat(jde) {
|
||||
return math.NaN()
|
||||
}
|
||||
lastOppositionJD := uranusConjunctionFull(jde, 180, 0)
|
||||
date := uranusRetrogradeAroundOpposition(lastOppositionJD, false)
|
||||
lastOppositionJD := uranusConjunctionFull(jde, 180, 0, inst)
|
||||
date := uranusRetrogradeAroundOpposition(lastOppositionJD, false, inst)
|
||||
if isFiniteFloat(date) && stationUTQueryBeforeOrEqual(date, jde) {
|
||||
return date
|
||||
}
|
||||
if !isFiniteFloat(lastOppositionJD) {
|
||||
return math.NaN()
|
||||
}
|
||||
previousOppositionJD := uranusConjunctionFull(eventUTLastQueryTT(lastOppositionJD), 180, 0)
|
||||
previousOppositionJD := uranusConjunctionFull(eventUTLastQueryTT(lastOppositionJD), 180, 0, inst)
|
||||
if !isFiniteFloat(previousOppositionJD) {
|
||||
return math.NaN()
|
||||
}
|
||||
date = uranusRetrogradeAroundOpposition(previousOppositionJD, false)
|
||||
date = uranusRetrogradeAroundOpposition(previousOppositionJD, false, inst)
|
||||
if !isFiniteFloat(date) || !stationUTQueryBeforeOrEqual(date, jde) {
|
||||
return math.NaN()
|
||||
}
|
||||
return date
|
||||
}
|
||||
|
||||
func NextUranusProgradeToRetrograde(jde float64) float64 {
|
||||
// NextUranusProgradeToRetrogradeWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model.
|
||||
func NextUranusProgradeToRetrogradeWithInstance(jde float64, inst *Instance) float64 {
|
||||
if !isFiniteFloat(jde) {
|
||||
return math.NaN()
|
||||
}
|
||||
nextOppositionJD := uranusConjunctionFull(jde, 180, 1)
|
||||
date := uranusRetrogradeAroundOpposition(nextOppositionJD, true)
|
||||
nextOppositionJD := uranusConjunctionFull(jde, 180, 1, inst)
|
||||
date := uranusRetrogradeAroundOpposition(nextOppositionJD, true, inst)
|
||||
if isFiniteFloat(date) && stationUTQueryAfterOrEqual(date, jde) {
|
||||
return date
|
||||
}
|
||||
if !isFiniteFloat(nextOppositionJD) {
|
||||
return math.NaN()
|
||||
}
|
||||
followingOppositionJD := uranusConjunctionFull(eventUTNextQueryTT(nextOppositionJD), 180, 1)
|
||||
followingOppositionJD := uranusConjunctionFull(eventUTNextQueryTT(nextOppositionJD), 180, 1, inst)
|
||||
if !isFiniteFloat(followingOppositionJD) {
|
||||
return math.NaN()
|
||||
}
|
||||
date = uranusRetrogradeAroundOpposition(followingOppositionJD, true)
|
||||
date = uranusRetrogradeAroundOpposition(followingOppositionJD, true, inst)
|
||||
if !isFiniteFloat(date) || !stationUTQueryAfterOrEqual(date, jde) {
|
||||
return math.NaN()
|
||||
}
|
||||
return date
|
||||
}
|
||||
|
||||
func LastUranusProgradeToRetrograde(jde float64) float64 {
|
||||
// LastUranusProgradeToRetrogradeWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model.
|
||||
func LastUranusProgradeToRetrogradeWithInstance(jde float64, inst *Instance) float64 {
|
||||
if !isFiniteFloat(jde) {
|
||||
return math.NaN()
|
||||
}
|
||||
nextOppositionJD := uranusConjunctionFull(jde, 180, 1)
|
||||
date := uranusRetrogradeAroundOpposition(nextOppositionJD, true)
|
||||
nextOppositionJD := uranusConjunctionFull(jde, 180, 1, inst)
|
||||
date := uranusRetrogradeAroundOpposition(nextOppositionJD, true, inst)
|
||||
if isFiniteFloat(date) && stationUTQueryBeforeOrEqual(date, jde) {
|
||||
return date
|
||||
}
|
||||
if !isFiniteFloat(nextOppositionJD) {
|
||||
return math.NaN()
|
||||
}
|
||||
lastOppositionJD := uranusConjunctionFull(jde, 180, 0)
|
||||
lastOppositionJD := uranusConjunctionFull(jde, 180, 0, inst)
|
||||
if !isFiniteFloat(lastOppositionJD) {
|
||||
return math.NaN()
|
||||
}
|
||||
date = uranusRetrogradeAroundOpposition(lastOppositionJD, true)
|
||||
date = uranusRetrogradeAroundOpposition(lastOppositionJD, true, inst)
|
||||
if !isFiniteFloat(date) || !stationUTQueryBeforeOrEqual(date, jde) {
|
||||
return math.NaN()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user