Files
astro/basic/traditional_calendar.go
T
b612 9ee2163cc7 feat: 新增月掩与日月食地理绘图并提升观测计算精度
- 新增月掩恒星和行星:支持搜索、掩甚点、全球掩带及固定地点轨迹计算
- 支持恒星星表坐标转换、有限盘面行星接触事件和月掩 SVG 输出
- 新增日月食及月掩全球投影图、时间标记和 GeoJSON 地理数据接口
- 扩展日食中心线、南北界及偏食足迹采样,支持极区投影
- 修正站心时角、月出月落、月球视半径、折射和恒星自行计算
- 优化内外行星事件搜索、边界选择、极端输入处理和计算稳定性
2026-08-06 12:00:56 +08:00

97 lines
2.3 KiB
Go

package basic
import "math"
// GetShiErCi 十二次 / twelve divisions of the ecliptic in traditional Chinese astronomy.
func GetShiErCi(jd float64) string { //十二次
tlo := HSunApparentLo(jd)
if tlo >= 255 && tlo < 285 {
return "星纪"
} else if tlo >= 285 && tlo < 315 {
return "玄枵"
} else if tlo >= 315 && tlo < 345 {
return "娵訾"
} else if tlo >= 345 || tlo < 15 {
return "降娄"
} else if tlo >= 15 && tlo < 45 {
return "大梁"
} else if tlo >= 45 && tlo < 75 {
return "实沈"
} else if tlo >= 75 && tlo < 105 {
return "鹑首"
} else if tlo >= 105 && tlo < 135 {
return "鹑火"
} else if tlo >= 135 && tlo < 165 {
return "鹑尾"
} else if tlo >= 165 && tlo < 195 {
return "寿星"
} else if tlo >= 195 && tlo < 225 {
return "大火"
} else if tlo >= 225 && tlo < 255 {
return "析木"
}
return ""
}
// GetWuHouTime 七十二候时刻 / time of a pentad marker in traditional Chinese calendrics.
func GetWuHouTime(Year, Angle int) float64 {
tmp := Angle
var Day int
var tp float64
Angle = int(Angle/15) * 15
if Angle%2 == 0 {
Day = 18
} else {
Day = 3
}
if Angle%10 != 0 {
tp = float64(Angle+15) / 30.0
} else {
tp = float64(Angle) / 30.0
}
Month := int(3 + tp)
if Month > 12 {
Month -= 12
}
JD1 := JDECalc(Year, Month, float64(Day))
JD1 += float64(tmp - Angle)
Angle = tmp
if Angle <= 5 {
Angle = 360 + Angle
}
converged := false
for i := 0; i < eventNewtonMaxIterations; i++ {
JD0 := JD1
stDegree := JQLospec(JD0, float64(Angle)) - float64(Angle)
stDegreep := (JQLospec(JD0+0.000005, float64(Angle)) - JQLospec(JD0-0.000005, float64(Angle))) / 0.00001
nextJD := JD0 - stDegree/stDegreep
if !isFiniteFloat(nextJD) {
return math.NaN()
}
JD1 = nextJD
if math.Abs(nextJD-JD0) <= 0.00001 {
converged = true
break
}
}
if !converged {
return math.NaN()
}
return TD2UT(JD1, false)
}
// GetGanZhi 年干支 / ganzhi for a year number.
func GetGanZhi(year int) string {
tiangan := []string{"庚", "辛", "壬", "癸", "甲", "乙", "丙", "丁", "戊", "己"}
dizhi := []string{"申", "酉", "戌", "亥", "子", "丑", "寅", "卯", "辰", "巳", "午", "未"}
t := year - (year / 10 * 10)
if t < 0 {
t += 10
}
d := year % 12
if d < 0 {
d += 12
}
return tiangan[t] + dizhi[d]
}