master v0.0.2
兔子 12 months ago
parent 460e042aa9
commit d479d39352

@ -101,7 +101,6 @@ func SunMidFun(JD float64) float64 { //'太阳中间方程
return SunMidFun return SunMidFun
} }
func SunTrueLo(JD float64) float64 { // '太阳真黄经 func SunTrueLo(JD float64) float64 { // '太阳真黄经
SunTrueLo := SunLo(JD) + SunMidFun(JD) SunTrueLo := SunLo(JD) + SunMidFun(JD)
return SunTrueLo return SunTrueLo
} }

@ -153,3 +153,70 @@ func Test_SunAz(t *testing.T) {
fmt.Println(SunAngle(Date2JDE(time.Date(2022, 5, 30, 11, 55, 0, 0, cst)), fmt.Println(SunAngle(Date2JDE(time.Date(2022, 5, 30, 11, 55, 0, 0, cst)),
120, 30, 8.0)) 120, 30, 8.0))
} }
func TestJQDate(t *testing.T) {
trimDay := func(d float64) float64 {
if d-math.Floor(d) < 0.5 {
return math.Floor(d) - 0.5
}
return math.Floor(d) + 0.5
}
c := 0
for year := 1900; year <= 2600; year++ {
for pos := 0; pos < 360; pos += 15 {
n := newGetJQTime(year, pos)
o := GetJQTime(year, pos)
if trimDay(n) != trimDay(o) {
c++
fmt.Printf("\"%d%03d\":%.0f,", year, pos, trimDay(o)-trimDay(n))
}
}
}
fmt.Println(c)
}
func newGetJQTime(Year, Angle int) float64 { //节气时间
var j int = 1
var Day int
var tp float64
if Angle%2 == 0 {
Day = 18
} else {
Day = 3
}
if Angle%10 != 0 {
tp = float64(Angle+15.0) / 30.0
} else {
tp = float64(Angle) / 30.0
}
Month := 3 + tp
if Month > 12 {
Month -= 12
}
JD1 := JDECalc(int(Year), int(Month), float64(Day))
if Angle == 0 {
Angle = 360
}
for i := 0; i < j; i++ {
for {
JD0 := JD1
stDegree := newJQLospec(JD0) - float64(Angle)
stDegreep := (newJQLospec(JD0+0.000005) - newJQLospec(JD0-0.000005)) / 0.00001
JD1 = JD0 - stDegree/stDegreep
if math.Abs(JD1-JD0) <= 0.00001 {
break
}
}
JD1 -= 0.001
}
JD1 += 0.001
return JD1 - 0.0046296296296296
}
func newJQLospec(JD float64) float64 {
t := tools.FloatRound(SunApparentLo(JD), 9)
if t <= 12 {
t += 360
}
return t
}

@ -166,8 +166,7 @@ recalc:
strday := []string{"初", "十", "廿", "三"} strday := []string{"初", "十", "廿", "三"}
for i := 0; i < 13; i++ { for i := 0; i < 13; i++ {
var dayofLunar = 29 var dayofLunar = 29
tmp := uint8(magic&0x3FFE>>(13-i)) & 1 if uint8(magic&0x3FFE>>(13-i))&1 == 1 {
if tmp == 1 {
dayofLunar++ dayofLunar++
} }
if totalDay+dayofLunar > diffDay { if totalDay+dayofLunar > diffDay {
@ -222,10 +221,8 @@ func rapidSolar(year, month, day int, isLeap bool) time.Time {
target := spring.AddDate(0, 0, totalDay+day-1) target := spring.AddDate(0, 0, totalDay+day-1)
return target return target
} }
var dayofLunar = 29 var dayofLunar = 29
tmp := uint8(magic&0x3FFE>>(13-i)) & 1 if uint8(magic&0x3FFE>>(13-i))&1 == 1 {
if tmp == 1 {
dayofLunar++ dayofLunar++
} }
totalDay += dayofLunar totalDay += dayofLunar

Loading…
Cancel
Save