Files
astro/basic/traditional_calendar.go
T
b612 16c62a97d5 feat: 完善时标与天象几何计算并扩展输出接口
- 新增时标、ΔT 模型、质心时间与 UT1 支持
- 改进日月食、月掩、行星事件及路径边界计算
- 完善恒星三维自行与动态距离传播
- 扩展 SVG、GeoJSON、KML 输出与底层距离换算工具
- 整理中英文手册、示例资源及回归测试
2026-09-23 18:55:12 +08:00

99 lines
2.4 KiB
Go

package basic
import "math"
// GetShiErCi 十二次 / twelve divisions of the ecliptic in traditional Chinese astronomy.
func GetShiErCi(jde float64) string { //十二次
tlo := HSunApparentLo(jde)
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
}
jd := JDCalc(Year, Month, float64(Day))
jd += float64(tmp - Angle)
Angle = tmp
if Angle <= 5 {
Angle = 360 + Angle
}
// 种子是民用时刻,牛顿迭代解出的是力学时事件时刻,两者必须分开命名。
jde := jd
converged := false
for i := 0; i < eventNewtonMaxIterations; i++ {
jde0 := jde
stDegree := JQLospec(jde0, float64(Angle)) - float64(Angle)
stDegreep := (JQLospec(jde0+0.000005, float64(Angle)) - JQLospec(jde0-0.000005, float64(Angle))) / 0.00001
nextJD := jde0 - stDegree/stDegreep
if !isFiniteFloat(nextJD) {
return math.NaN()
}
jde = nextJD
if math.Abs(nextJD-jde0) <= 0.00001 {
converged = true
break
}
}
if !converged {
return math.NaN()
}
return TT2UTC(jde)
}
// 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]
}