update rapid lunar calc

This commit is contained in:
2024-01-15 17:05:18 +08:00
parent c2c79c3615
commit 460e042aa9
8 changed files with 448 additions and 807 deletions
+24 -24
View File
@@ -265,33 +265,33 @@ func GetLunar(year, month, day int, tz float64) (lmonth, lday int, leap bool, re
} else {
year--
}
jieqi := GetOneYearJQ(year) //一年的节气
moon := GetOneYearMoon(float64(year)) //一年朔月日
winter1 := jieqi[1] - 8.0/24 + tz //第一年冬至日
winter2 := jieqi[25] - 8.0/24 + tz //第二年冬至日
for k, v := range moon {
jieqi := GetJieqiLoops(year, 25) //一年的节气
moon := GetMoonLoops(float64(year), 17) //一年朔月日
winter1 := jieqi[0] - 8.0/24 + tz //第一年冬至日
winter2 := jieqi[24] - 8.0/24 + tz //第二年冬至日
for idx, v := range moon {
if tz != 8.0/24 {
v = v - 8.0/24 + tz
}
if v-math.Floor(v) > 0.5 {
moon[k] = math.Floor(v) + 0.5
moon[idx] = math.Floor(v) + 0.5
} else {
moon[k] = math.Floor(v) - 0.5
moon[idx] = math.Floor(v) - 0.5
}
} //置闰月为0点
for k, v := range jieqi {
for idx, v := range jieqi {
if tz != 8.0/24 {
v = v - 8.0/24 + tz
}
if v-math.Floor(v) > 0.5 {
jieqi[k] = math.Floor(v) + 0.5
jieqi[idx] = math.Floor(v) + 0.5
} else {
jieqi[k] = math.Floor(v) - 0.5
jieqi[idx] = math.Floor(v) - 0.5
}
} //置节气为0点
mooncount := 0 //年内朔望月计数
var min, max int = 20, 0 //最大最小计数
for i := 1; i < 16; i++ {
for i := 0; i < 15; i++ {
if moon[i] >= winter1 && moon[i] < winter2 {
if i <= min {
min = i
@@ -304,7 +304,7 @@ func GetLunar(year, month, day int, tz float64) (lmonth, lday int, leap bool, re
}
leapmonth := 20
if mooncount == 13 { //存在闰月
j, i := 3, 1
var j, i = 2, 0
for i = min; i <= max; i++ {
if !(moon[i] <= jieqi[j] && moon[i+1] > jieqi[j]) {
break
@@ -364,33 +364,33 @@ func GetSolar(year, month, day int, leap bool, tz float64) float64 {
if month < 11 {
year--
}
jieqi := GetOneYearJQ(year) //一年的节气
moon := GetOneYearMoon(float64(year)) //一年朔月日
winter1 := jieqi[1] - 8.0/24 + tz //第一年冬至日
winter2 := jieqi[25] - 8.0/24 + tz //第二年冬至日
for k, v := range moon {
jieqi := GetJieqiLoops(year, 25) //一年的节气
moon := GetMoonLoops(float64(year), 17) //一年朔月日
winter1 := jieqi[0] - 8.0/24 + tz //第一年冬至日
winter2 := jieqi[24] - 8.0/24 + tz //第二年冬至日
for idx, v := range moon {
if tz != 8.0/24 {
v = v - 8.0/24 + tz
}
if v-math.Floor(v) > 0.5 {
moon[k] = math.Floor(v) + 0.5
moon[idx] = math.Floor(v) + 0.5
} else {
moon[k] = math.Floor(v) - 0.5
moon[idx] = math.Floor(v) - 0.5
}
} //置闰月为0点
for k, v := range jieqi {
for idx, v := range jieqi {
if tz != 8.0/24 {
v = v - 8.0/24 + tz
}
if v-math.Floor(v) > 0.5 {
jieqi[k] = math.Floor(v) + 0.5
jieqi[idx] = math.Floor(v) + 0.5
} else {
jieqi[k] = math.Floor(v) - 0.5
jieqi[idx] = math.Floor(v) - 0.5
}
} //置节气为0点
mooncount := 0 //年内朔望月计数
var min, max int = 20, 0 //最大最小计数
for i := 1; i < 16; i++ {
for i := 0; i < 15; i++ {
if moon[i] >= winter1 && moon[i] < winter2 {
if i <= min {
min = i
@@ -403,7 +403,7 @@ func GetSolar(year, month, day int, leap bool, tz float64) float64 {
}
leapmonth := 20
if mooncount == 13 { //存在闰月
j, i := 3, 1
var j, i = 2, 0
for i = min; i <= max; i++ {
if !(moon[i] <= jieqi[j] && moon[i+1] > jieqi[j]) {
break
+126
View File
@@ -0,0 +1,126 @@
package basic
import (
"encoding/json"
"fmt"
"math"
"os"
)
func generateMagicNumber() {
//0月份 00000 日期 0000闰月 0000000000000 农历信息
var tz = 8.0000 / 24.000
yearMap := make(map[int][][]int) // {1 month,1 leap,2 29/30}
spYear := make(map[int][]int)
var upper []uint16
var lower []uint16
//var info uint32 = 0
for year := 1899; year <= 2401; year++ {
fmt.Println(year)
jieqi := GetJieqiLoops(year, 25) //一年的节气
moon := GetMoonLoops(float64(year), 17) //一年朔月日
winter1 := jieqi[0] - 8.0/24 + tz //第一年冬至日
winter2 := jieqi[24] - 8.0/24 + tz //第二年冬至日
for idx, v := range moon {
if tz != 8.0/24 {
v = v - 8.0/24 + tz
}
if v-math.Floor(v) > 0.5 {
moon[idx] = math.Floor(v) + 0.5
} else {
moon[idx] = math.Floor(v) - 0.5
}
} //置闰月为0点
for idx, v := range jieqi {
if tz != 8.0/24 {
v = v - 8.0/24 + tz
}
if v-math.Floor(v) > 0.5 {
jieqi[idx] = math.Floor(v) + 0.5
} else {
jieqi[idx] = math.Floor(v) - 0.5
}
} //置节气为0点
mooncount := 0 //年内朔望月计数
var min, max int = 20, 0 //最大最小计数
for i := 0; i < 15; i++ {
if moon[i] >= winter1 && moon[i] < winter2 {
if i <= min {
min = i
}
if i >= max {
max = i
}
mooncount++
}
}
leapmonth := 20
if mooncount == 13 { //存在闰月
var j, i = 2, 0
for i = min; i <= max; i++ {
if !(moon[i] <= jieqi[j] && moon[i+1] > jieqi[j]) {
break
}
j += 2
}
leapmonth = i - min + 1
}
month := 11
for idx := min; idx <= max; idx++ {
leap := 0
if idx != leapmonth {
month++
if month > 12 {
month -= 12
}
} else {
leap = 1
}
if leap == 0 && month == 1 {
cp := JDE2Date(moon[idx])
spYear[year+1] = append(spYear[year+1], []int{int(cp.Month()), cp.Day()}...)
}
if idx < 6 && month > 10 {
yearMap[year] = append(yearMap[year], []int{month, leap, int(moon[idx+1] - moon[idx])})
} else {
yearMap[year+1] = append(yearMap[year+1], []int{month, leap, int(moon[idx+1] - moon[idx])})
}
}
}
for year := 1900; year <= 2400; year++ {
fmt.Println(year)
up, low := magicNumberSpilt(magicNumber(yearMap[year], spYear[year]))
upper = append(upper, up)
lower = append(lower, uint16(low))
}
res := make(map[string]interface{})
res["up"] = upper
res["low"] = lower
d, _ := json.Marshal(res)
os.WriteFile("test.json", d, 0644)
}
func magicNumber(y1 [][]int, y2 []int) int32 {
var res int32
res = int32(y2[1]) << 18
if y2[0] == 2 {
res = res | 0x800000
}
for idx, v := range y1 {
if v[2] == 30 {
res = res | (1 << (13 - idx))
}
if v[1] == 1 {
res = (res & 0xFC3FFF) | int32((v[0])<<14)
}
}
return res
}
func magicNumberSpilt(magic int32) (uint16, uint8) {
var upper uint16
var lower uint8
lower = uint8(magic)
upper = uint16(magic >> 8)
return upper, lower
}
+11 -4
View File
@@ -1055,9 +1055,15 @@ func MoonTrueRa(JD float64) float64 {
return LoToRa(JD, MoonApparentLo(JD), MoonTrueBo(JD))
}
/**
*
传入世界时
func MoonTrueRaDec(JD float64) (float64, float64) {
return LoBoToRaDec(JD, MoonApparentLo(JD), MoonTrueBo(JD))
}
/*
*
*
传入世界时
*/
func MoonApparentRa(JD, lon, lat float64, tz int) float64 {
jde := TD2UT(JD, true)
@@ -1702,7 +1708,8 @@ func HMoonTrueRa(JD float64) float64 {
return LoToRa(JD, HMoonApparentLo(JD), HMoonTrueBo(JD))
}
/**
/*
*
*
传入世界时
*/
+43
View File
@@ -1,6 +1,7 @@
package basic
import (
"b612.me/astro/tools"
"fmt"
"math"
"testing"
@@ -21,7 +22,49 @@ func Test_MoonDown(t *testing.T) {
fmt.Println(i, GetMoonDownTime(jde, 115, float64(i), 8, 1, 0))
}
}
func Test_MoonDiff(t *testing.T) {
n := JDECalc(2000, 1, 1)
var maxRa, maxDec, maxLo, maxBo float64
for i := float64(0); i < 365.2422*3; i++ {
tLo := HMoonApparentLo(n + i)
tBo := HMoonTrueBo(n + i)
tRa, tDec := HMoonTrueRaDec(n + i)
fRa, fDec := MoonTrueRaDec(n + i)
fLo := MoonApparentLo(n + i)
fBo := MoonTrueBo(n + i)
tmp := tools.Limit360(math.Abs(tRa - fRa))
if tmp > 300 {
tmp = 360 - tmp
}
if tmp > maxRa {
maxRa = tmp
}
tmp = tools.Limit360(math.Abs(tDec - fDec))
if tmp > 300 {
tmp = 360 - tmp
}
if tmp > maxDec {
maxDec = tmp
}
tmp = tools.Limit360(math.Abs(tLo - fLo))
if tmp > 300 {
tmp = 360 - tmp
}
if tmp > maxLo {
maxLo = tmp
}
tmp = tools.Limit360(math.Abs(tBo - fBo))
if tmp > 300 {
tmp = 360 - tmp
}
if tmp > maxBo {
maxBo = tmp
}
}
fmt.Printf("%.15f %.15f %.15f %.15f\n", maxRa*3600, maxDec*3600, maxLo*3600, maxBo*3600)
}
func Test_MoonRise(t *testing.T) {
//2.459984692085961e+06 113.58880556 87.36833333 8 0 0
//2.459984692085961e+06 113.58880556 87.36833333 8 0 0
+49 -776
View File
@@ -8,7 +8,7 @@ import (
)
/*
黄赤交角nutation==true时计算交角章动
黄赤交角nutation==true时计算交角章动
*/
func EclipticObliquity(jde float64, nutation bool) float64 {
U := (jde - 2451545) / 3652500.000
@@ -27,771 +27,47 @@ func Sita(JD float64) float64 {
/*
* @name 黄经章动
*/
func HJZD(JD float64) float64 { // '黄经章动
// Dim p As Double, T As Double, Lmoon As Double
T := (JD - 2451545) / 36525.000
D := 297.8502042 + 445267.1115168*T - 0.0016300*T*T + T*T*T/545868 - T*T*T*T/113065000
M := SunM(JD)
N := MoonM(JD)
F := MoonLonX(JD)
O := 125.04452 - 1934.136261*T + 0.0020708*T*T + T*T*T/450000
//die(T." ".D." ".M." ".N." ".F." ".O);
tp := make(map[int]map[int]float64)
for i := 1; i < 64; i++ {
tp[i] = make(map[int]float64)
func HJZD(jd float64) float64 { // '黄经章动
t := (jd - 2451545) / 36525.000
d := 297.8502042 + 445267.1115168*t - 0.0016300*t*t + t*t*t/545868 - t*t*t*t/113065000
m := SunM(jd)
n := MoonM(jd)
f := MoonLonX(jd)
o := 125.04452 - 1934.136261*t + 0.0020708*t*t + t*t*t/450000
tp := [][]float64{{0, 0, 0, 0, 1, -171996, -174.2 * t}, {-2, 0, 0, 2, 2, -13187, -1.6 * t}, {0, 0, 0, 2, 2, -2274, -0.2 * t}, {0, 0, 0, 0, 2, 2062, 0.2 * t}, {0, 1, 0, 0, 0, 1426, -3.4 * t}, {0, 0, 1, 0, 0, 712, 0.1 * t}, {-2, 1, 0, 2, 2, -517, 1.2 * t}, {0, 0, 0, 2, 1, -386, -0.4 * t}, {0, 0, 1, 2, 2, -301, 0}, {-2, -1, 0, 2, 2, 217, -0.5 * t}, {-2, 0, 1, 0, 0, -158, 0}, {-2, 0, 0, 2, 1, 129, 0.1 * t}, {0, 0, -1, 2, 2, 123, 0}, {2, 0, 0, 0, 0, 63, 0}, {0, 0, 1, 0, 1, 63, 0.1 * t}, {2, 0, -1, 2, 2, -59, 0}, {0, 0, -1, 0, 1, -58, -0.1 * t}, {0, 0, 1, 2, 1, -51, 0}, {-2, 0, 2, 0, 0, 48, 0}, {0, 0, -2, 2, 1, 46, 0}, {2, 0, 0, 2, 2, -38, 0}, {0, 0, 2, 2, 2, -31, 0}, {0, 0, 2, 0, 0, 29, 0}, {-2, 0, 1, 2, 2, 29, 0}, {0, 0, 0, 2, 0, 26, 0}, {-2, 0, 0, 2, 0, -22, 0}, {0, 0, -1, 2, 1, 21, 0}, {0, 2, 0, 0, 0, 17, -0.1 * t}, {2, 0, -1, 0, 1, 16, 0}, {-2, 2, 0, 2, 2, -16, 0.1 * t}, {0, 1, 0, 0, 1, -15, 0}, {-2, 0, 1, 0, 1, -13, 0}, {0, -1, 0, 0, 1, -12, 0}, {0, 0, 2, -2, 0, 11, 0}, {2, 0, -1, 2, 1, -10, 0}, {2, 0, 1, 2, 2, -8, 0}, {0, 1, 0, 2, 2, 7, 0}, {-2, 1, 1, 0, 0, -7, 0}, {0, -1, 0, 2, 2, -7, 0}, {2, 0, 0, 2, 1, -7, 0}, {2, 0, 1, 0, 0, 6, 0}, {-2, 0, 2, 2, 2, 6, 0}, {-2, 0, 1, 2, 1, 6, 0}, {2, 0, -2, 0, 1, -6, 0}, {2, 0, 0, 0, 1, -6, 0}, {0, -1, 1, 0, 0, 5, 0}, {-2, -1, 0, 2, 1, -5, 0}, {-2, 0, 0, 0, 1, -5, 0}, {0, 0, 2, 2, 1, -5, 0}, {-2, 0, 2, 0, 1, 4, 0}, {-2, 1, 0, 2, 1, 4, 0}, {0, 0, 1, -2, 0, 4, 0}, {-1, 0, 1, 0, 0, -4, 0}, {-2, 1, 0, 0, 0, -4, 0}, {1, 0, 0, 0, 0, -4, 0}, {0, 0, 1, 2, 0, 3, 0}, {0, 0, -2, 2, 2, -3, 0}, {-1, -1, 1, 0, 0, -3, 0}, {0, 1, 1, 0, 0, -3, 0}, {0, -1, 1, 2, 2, -3, 0}, {2, -1, -1, 2, 2, -3, 0}, {0, 0, 3, 2, 2, -3, 0}, {2, -1, 0, 2, 2, -3, 0}}
var s float64
for i := 0; i < len(tp); i++ {
s += (tp[i][5] + tp[i][6]) * Sin(d*tp[i][0]+m*tp[i][1]+n*tp[i][2]+f*tp[i][3]+o*tp[i][4])
}
tp[1][1] = 0
tp[1][2] = 0
tp[1][3] = 0
tp[1][4] = 0
tp[1][5] = 1
tp[1][6] = -171996
tp[1][7] = -174.2 * T
tp[2][1] = -2
tp[2][2] = 0
tp[2][3] = 0
tp[2][4] = 2
tp[2][5] = 2
tp[2][6] = -13187
tp[2][7] = -1.6 * T
tp[3][1] = 0
tp[3][2] = 0
tp[3][3] = 0
tp[3][4] = 2
tp[3][5] = 2
tp[3][6] = -2274
tp[3][7] = -0.2 * T
tp[4][1] = 0
tp[4][2] = 0
tp[4][3] = 0
tp[4][4] = 0
tp[4][5] = 2
tp[4][6] = 2062
tp[4][7] = 0.2 * T
tp[5][1] = 0
tp[5][2] = 1
tp[5][3] = 0
tp[5][4] = 0
tp[5][5] = 0
tp[5][6] = 1426
tp[5][7] = -3.4 * T
tp[6][1] = 0
tp[6][2] = 0
tp[6][3] = 1
tp[6][4] = 0
tp[6][5] = 0
tp[6][6] = 712
tp[6][7] = 0.1 * T
tp[7][1] = -2
tp[7][2] = 1
tp[7][3] = 0
tp[7][4] = 2
tp[7][5] = 2
tp[7][6] = -517
tp[7][7] = 1.2 * T
tp[8][1] = 0
tp[8][2] = 0
tp[8][3] = 0
tp[8][4] = 2
tp[8][5] = 1
tp[8][6] = -386
tp[8][7] = -0.4 * T
tp[9][1] = 0
tp[9][2] = 0
tp[9][3] = 1
tp[9][4] = 2
tp[9][5] = 2
tp[9][6] = -301
tp[9][7] = 0
tp[10][1] = -2
tp[10][2] = -1
tp[10][3] = 0
tp[10][4] = 2
tp[10][5] = 2
tp[10][6] = 217
tp[10][7] = -0.5 * T
tp[11][1] = -2
tp[11][2] = 0
tp[11][3] = 1
tp[11][4] = 0
tp[11][5] = 0
tp[11][6] = -158
tp[11][7] = 0
tp[12][1] = -2
tp[12][2] = 0
tp[12][3] = 0
tp[12][4] = 2
tp[12][5] = 1
tp[12][6] = 129
tp[12][7] = 0.1 * T
tp[13][1] = 0
tp[13][2] = 0
tp[13][3] = -1
tp[13][4] = 2
tp[13][5] = 2
tp[13][6] = 123
tp[13][7] = 0
tp[14][1] = 2
tp[14][2] = 0
tp[14][3] = 0
tp[14][4] = 0
tp[14][5] = 0
tp[14][6] = 63
tp[14][7] = 0
tp[15][1] = 0
tp[15][2] = 0
tp[15][3] = 1
tp[15][4] = 0
tp[15][5] = 1
tp[15][6] = 63
tp[15][7] = 0.1 * T
tp[16][1] = 2
tp[16][2] = 0
tp[16][3] = -1
tp[16][4] = 2
tp[16][5] = 2
tp[16][6] = -59
tp[16][7] = 0
tp[17][1] = 0
tp[17][2] = 0
tp[17][3] = -1
tp[17][4] = 0
tp[17][5] = 1
tp[17][6] = -58
tp[17][7] = -0.1 * T
tp[18][1] = 0
tp[18][2] = 0
tp[18][3] = 1
tp[18][4] = 2
tp[18][5] = 1
tp[18][6] = -51
tp[18][7] = 0
tp[19][1] = -2
tp[19][2] = 0
tp[19][3] = 2
tp[19][4] = 0
tp[19][5] = 0
tp[19][6] = 48
tp[19][7] = 0
tp[20][1] = 0
tp[20][2] = 0
tp[20][3] = -2
tp[20][4] = 2
tp[20][5] = 1
tp[20][6] = 46
tp[20][7] = 0
tp[21][1] = 2
tp[21][2] = 0
tp[21][3] = 0
tp[21][4] = 2
tp[21][5] = 2
tp[21][6] = -38
tp[21][7] = 0
tp[22][1] = 0
tp[22][2] = 0
tp[22][3] = 2
tp[22][4] = 2
tp[22][5] = 2
tp[22][6] = -31
tp[22][7] = 0
tp[23][1] = 0
tp[23][2] = 0
tp[23][3] = 2
tp[23][4] = 0
tp[23][5] = 0
tp[23][6] = 29
tp[23][7] = 0
tp[24][1] = -2
tp[24][2] = 0
tp[24][3] = 1
tp[24][4] = 2
tp[24][5] = 2
tp[24][6] = 29
tp[24][7] = 0
tp[25][1] = 0
tp[25][2] = 0
tp[25][3] = 0
tp[25][4] = 2
tp[25][5] = 0
tp[25][6] = 26
tp[25][7] = 0
tp[26][1] = -2
tp[26][2] = 0
tp[26][3] = 0
tp[26][4] = 2
tp[26][5] = 0
tp[26][6] = -22
tp[26][7] = 0
tp[27][1] = 0
tp[27][2] = 0
tp[27][3] = -1
tp[27][4] = 2
tp[27][5] = 1
tp[27][6] = 21
tp[27][7] = 0
tp[28][1] = 0
tp[28][2] = 2
tp[28][3] = 0
tp[28][4] = 0
tp[28][5] = 0
tp[28][6] = 17
tp[28][7] = -0.1 * T
tp[29][1] = 2
tp[29][2] = 0
tp[29][3] = -1
tp[29][4] = 0
tp[29][5] = 1
tp[29][6] = 16
tp[29][7] = 0
tp[30][1] = -2
tp[30][2] = 2
tp[30][3] = 0
tp[30][4] = 2
tp[30][5] = 2
tp[30][6] = -16
tp[30][7] = 0.1 * T
tp[31][1] = 0
tp[31][2] = 1
tp[31][3] = 0
tp[31][4] = 0
tp[31][5] = 1
tp[31][6] = -15
tp[31][7] = 0
tp[32][1] = -2
tp[32][2] = 0
tp[32][3] = 1
tp[32][4] = 0
tp[32][5] = 1
tp[32][6] = -13
tp[32][7] = 0
tp[33][1] = 0
tp[33][2] = -1
tp[33][3] = 0
tp[33][4] = 0
tp[33][5] = 1
tp[33][6] = -12
tp[33][7] = 0
tp[34][1] = 0
tp[34][2] = 0
tp[34][3] = 2
tp[34][4] = -2
tp[34][5] = 0
tp[34][6] = 11
tp[34][7] = 0
tp[35][1] = 2
tp[35][2] = 0
tp[35][3] = -1
tp[35][4] = 2
tp[35][5] = 1
tp[35][6] = -10
tp[35][7] = 0
tp[36][1] = 2
tp[36][2] = 0
tp[36][3] = 1
tp[36][4] = 2
tp[36][5] = 2
tp[36][6] = -8
tp[36][7] = 0
tp[37][1] = 0
tp[37][2] = 1
tp[37][3] = 0
tp[37][4] = 2
tp[37][5] = 2
tp[37][6] = 7
tp[37][7] = 0
tp[38][1] = -2
tp[38][2] = 1
tp[38][3] = 1
tp[38][4] = 0
tp[38][5] = 0
tp[38][6] = -7
tp[38][7] = 0
tp[39][1] = 0
tp[39][2] = -1
tp[39][3] = 0
tp[39][4] = 2
tp[39][5] = 2
tp[39][6] = -7
tp[39][7] = 0
tp[40][1] = 2
tp[40][2] = 0
tp[40][3] = 0
tp[40][4] = 2
tp[40][5] = 1
tp[40][6] = -7
tp[40][7] = 0
tp[41][1] = 2
tp[41][2] = 0
tp[41][3] = 1
tp[41][4] = 0
tp[41][5] = 0
tp[41][6] = 6
tp[41][7] = 0
tp[42][1] = -2
tp[42][2] = 0
tp[42][3] = 2
tp[42][4] = 2
tp[42][5] = 2
tp[42][6] = 6
tp[42][7] = 0
tp[43][1] = -2
tp[43][2] = 0
tp[43][3] = 1
tp[43][4] = 2
tp[43][5] = 1
tp[43][6] = 6
tp[43][7] = 0
tp[44][1] = 2
tp[44][2] = 0
tp[44][3] = -2
tp[44][4] = 0
tp[44][5] = 1
tp[44][6] = -6
tp[44][7] = 0
tp[45][1] = 2
tp[45][2] = 0
tp[45][3] = 0
tp[45][4] = 0
tp[45][5] = 1
tp[45][6] = -6
tp[45][7] = 0
tp[46][1] = 0
tp[46][2] = -1
tp[46][3] = 1
tp[46][4] = 0
tp[46][5] = 0
tp[46][6] = 5
tp[46][7] = 0
tp[47][1] = -2
tp[47][2] = -1
tp[47][3] = 0
tp[47][4] = 2
tp[47][5] = 1
tp[47][6] = -5
tp[47][7] = 0
tp[48][1] = -2
tp[48][2] = 0
tp[48][3] = 0
tp[48][4] = 0
tp[48][5] = 1
tp[48][6] = -5
tp[48][7] = 0
tp[49][1] = 0
tp[49][2] = 0
tp[49][3] = 2
tp[49][4] = 2
tp[49][5] = 1
tp[49][6] = -5
tp[49][7] = 0
tp[50][1] = -2
tp[50][2] = 0
tp[50][3] = 2
tp[50][4] = 0
tp[50][5] = 1
tp[50][6] = 4
tp[50][7] = 0
tp[51][1] = -2
tp[51][2] = 1
tp[51][3] = 0
tp[51][4] = 2
tp[51][5] = 1
tp[51][6] = 4
tp[51][7] = 0
tp[52][1] = 0
tp[52][2] = 0
tp[52][3] = 1
tp[52][4] = -2
tp[52][5] = 0
tp[52][6] = 4
tp[52][7] = 0
tp[53][1] = -1
tp[53][2] = 0
tp[53][3] = 1
tp[53][4] = 0
tp[53][5] = 0
tp[53][6] = -4
tp[53][7] = 0
tp[54][1] = -2
tp[54][2] = 1
tp[54][3] = 0
tp[54][4] = 0
tp[54][5] = 0
tp[54][6] = -4
tp[54][7] = 0
tp[55][1] = 1
tp[55][2] = 0
tp[55][3] = 0
tp[55][4] = 0
tp[55][5] = 0
tp[55][6] = -4
tp[55][7] = 0
tp[56][1] = 0
tp[56][2] = 0
tp[56][3] = 1
tp[56][4] = 2
tp[56][5] = 0
tp[56][6] = 3
tp[56][7] = 0
tp[57][1] = 0
tp[57][2] = 0
tp[57][3] = -2
tp[57][4] = 2
tp[57][5] = 2
tp[57][6] = -3
tp[57][7] = 0
tp[58][1] = -1
tp[58][2] = -1
tp[58][3] = 1
tp[58][4] = 0
tp[58][5] = 0
tp[58][6] = -3
tp[58][7] = 0
tp[59][1] = 0
tp[59][2] = 1
tp[59][3] = 1
tp[59][4] = 0
tp[59][5] = 0
tp[59][6] = -3
tp[59][7] = 0
tp[60][1] = 0
tp[60][2] = -1
tp[60][3] = 1
tp[60][4] = 2
tp[60][5] = 2
tp[60][6] = -3
tp[60][7] = 0
tp[61][1] = 2
tp[61][2] = -1
tp[61][3] = -1
tp[61][4] = 2
tp[61][5] = 2
tp[61][6] = -3
tp[61][7] = 0
tp[62][1] = 0
tp[62][2] = 0
tp[62][3] = 3
tp[62][4] = 2
tp[62][5] = 2
tp[62][6] = -3
tp[62][7] = 0
tp[63][1] = 2
tp[63][2] = -1
tp[63][3] = 0
tp[63][4] = 2
tp[63][5] = 2
tp[63][6] = -3
tp[63][7] = 0
var S float64
for i := 1; i < 64; i++ {
S += (tp[i][6] + tp[i][7]) * Sin(D*tp[i][1]+M*tp[i][2]+N*tp[i][3]+F*tp[i][4]+O*tp[i][5])
}
//P=-17.20*Sin(O)-1.32*Sin(2*280.4665 + 36000.7698*T)-0.23*Sin(2*218.3165 + 481267.8813*T )+0.21*Sin(2*O);
//P=-17.20*Sin(o)-1.32*Sin(2*280.4665 + 36000.7698*t)-0.23*Sin(2*218.3165 + 481267.8813*t )+0.21*Sin(2*o);
//return P/3600;
return (S / 10000) / 3600
return (s / 10000) / 3600
}
/*
* 交角章动
*/
func JJZD(JD float64) float64 { //交角章动
T := (JD - 2451545) / 36525
//D = 297.85036 +455267.111480*T - 0.0019142*T*T+ T*T*T/189474;
//M = 357.52772 + 35999.050340*T - 0.0001603*T*T- T*T*T/300000;
//N= 134.96298 + 477198.867398*T + 0.0086972*T*T + T*T*T/56250;
//F = 93.27191 + 483202.017538*T - 0.0036825*T*T + T*T*T/327270;
D := 297.8502042 + 445267.1115168*T - 0.0016300*T*T + T*T*T/545868 - T*T*T*T/113065000
M := SunM(JD)
N := MoonM(JD)
F := MoonLonX(JD)
O := 125.04452 - 1934.136261*T + 0.0020708*T*T + T*T*T/450000
tp := make(map[int]map[int]float64)
for i := 1; i < 64; i++ {
tp[i] = make(map[int]float64)
func JJZD(jd float64) float64 { //交角章动
t := (jd - 2451545) / 36525
//d = 297.85036 +455267.111480*t - 0.0019142*t*t+ t*t*t/189474;
//m = 357.52772 + 35999.050340*t - 0.0001603*t*t- t*t*t/300000;
//n= 134.96298 + 477198.867398*t + 0.0086972*t*t + t*t*t/56250;
//f = 93.27191 + 483202.017538*t - 0.0036825*t*t + t*t*t/327270;
d := 297.8502042 + 445267.1115168*t - 0.0016300*t*t + t*t*t/545868 - t*t*t*t/113065000
m := SunM(jd)
n := MoonM(jd)
f := MoonLonX(jd)
o := 125.04452 - 1934.136261*t + 0.0020708*t*t + t*t*t/450000
tp := [][]float64{{0, 0, 0, 0, 1, 92025, 8.9 * t}, {-2, 0, 0, 2, 2, 5736, -3.1 * t}, {0, 0, 0, 2, 2, 977, -0.5 * t}, {0, 0, 0, 0, 2, -895, 0.5 * t}, {0, 1, 0, 0, 0, 54, -0.1 * t}, {0, 0, 1, 0, 0, -7, 0}, {-2, 1, 0, 2, 2, 224, -0.6 * t}, {0, 0, 0, 2, 1, 200, 0}, {0, 0, 1, 2, 2, 129, -0.1 * t}, {-2, -1, 0, 2, 2, -95, 0.3 * t}, {-2, 0, 0, 2, 1, -70, 0}, {0, 0, -1, 2, 2, -53, 0}, {2, 0, 0, 0, 0, 63, 0}, {0, 0, 1, 0, 1, -33, 0}, {2, 0, -1, 2, 2, 26, 0}, {0, 0, -1, 0, 1, 32, 0}, {0, 0, 1, 2, 1, 27, 0}, {0, 0, -2, 2, 1, -24, 0}, {2, 0, 0, 2, 2, 16, 0}, {0, 0, 2, 2, 2, 13, 0}, {-2, 0, 1, 2, 2, -12, 0}, {0, 0, -1, 2, 1, -10, 0}, {2, 0, -1, 0, 1, -8, 0}, {-2, 2, 0, 2, 2, 7, 0}, {0, 1, 0, 0, 1, 9, 0}, {-2, 0, 1, 0, 1, 7, 0}, {0, -1, 0, 0, 1, 6, 0}, {2, 0, -1, 2, 1, 5, 0}, {2, 0, 1, 2, 2, 3, 0}, {0, 1, 0, 2, 2, -3, 0}, {0, -1, 0, 2, 2, 3, 0}, {2, 0, 0, 2, 1, 3, 0}, {-2, 0, 2, 2, 2, -3, 0}, {-2, 0, 1, 2, 1, -3, 0}, {2, 0, -2, 0, 1, 3, 0}, {2, 0, 0, 0, 1, 3, 0}, {-2, -1, 0, 2, 1, 3, 0}, {-2, 0, 0, 0, 1, 3, 0}, {0, 0, 2, 2, 1, 3, 0}}
var s float64 = 0
for i := 0; i < len(tp); i++ {
s += (tp[i][5] + tp[i][6]) * Cos(d*tp[i][0]+m*tp[i][1]+n*tp[i][2]+f*tp[i][3]+o*tp[i][4])
}
tp[1][1] = 0
tp[1][2] = 0
tp[1][3] = 0
tp[1][4] = 0
tp[1][5] = 1
tp[1][6] = 92025
tp[1][7] = 8.9 * T
tp[2][1] = -2
tp[2][2] = 0
tp[2][3] = 0
tp[2][4] = 2
tp[2][5] = 2
tp[2][6] = 5736
tp[2][7] = -3.1 * T
tp[3][1] = 0
tp[3][2] = 0
tp[3][3] = 0
tp[3][4] = 2
tp[3][5] = 2
tp[3][6] = 977
tp[3][7] = -0.5 * T
tp[4][1] = 0
tp[4][2] = 0
tp[4][3] = 0
tp[4][4] = 0
tp[4][5] = 2
tp[4][6] = -895
tp[4][7] = 0.5 * T
tp[5][1] = 0
tp[5][2] = 1
tp[5][3] = 0
tp[5][4] = 0
tp[5][5] = 0
tp[5][6] = 54
tp[5][7] = -0.1 * T
tp[6][1] = 0
tp[6][2] = 0
tp[6][3] = 1
tp[6][4] = 0
tp[6][5] = 0
tp[6][6] = -7
tp[6][7] = 0
tp[7][1] = -2
tp[7][2] = 1
tp[7][3] = 0
tp[7][4] = 2
tp[7][5] = 2
tp[7][6] = 224
tp[7][7] = -0.6 * T
tp[8][1] = 0
tp[8][2] = 0
tp[8][3] = 0
tp[8][4] = 2
tp[8][5] = 1
tp[8][6] = 200
tp[8][7] = 0
tp[9][1] = 0
tp[9][2] = 0
tp[9][3] = 1
tp[9][4] = 2
tp[9][5] = 2
tp[9][6] = 129
tp[9][7] = -0.1 * T
tp[10][1] = -2
tp[10][2] = -1
tp[10][3] = 0
tp[10][4] = 2
tp[10][5] = 2
tp[10][6] = -95
tp[10][7] = 0.3 * T
tp[11][1] = -2
tp[11][2] = 0
tp[11][3] = 0
tp[11][4] = 2
tp[11][5] = 1
tp[11][6] = -70
tp[11][7] = 0
tp[12][1] = 0
tp[12][2] = 0
tp[12][3] = -1
tp[12][4] = 2
tp[12][5] = 2
tp[12][6] = -53
tp[12][7] = 0
tp[13][1] = 2
tp[13][2] = 0
tp[13][3] = 0
tp[13][4] = 0
tp[13][5] = 0
tp[13][6] = 63
tp[13][7] = 0
tp[14][1] = 0
tp[14][2] = 0
tp[14][3] = 1
tp[14][4] = 0
tp[14][5] = 1
tp[14][6] = -33
tp[14][7] = 0
tp[15][1] = 2
tp[15][2] = 0
tp[15][3] = -1
tp[15][4] = 2
tp[15][5] = 2
tp[15][6] = 26
tp[15][7] = 0
tp[16][1] = 0
tp[16][2] = 0
tp[16][3] = -1
tp[16][4] = 0
tp[16][5] = 1
tp[16][6] = 32
tp[16][7] = 0
tp[17][1] = 0
tp[17][2] = 0
tp[17][3] = 1
tp[17][4] = 2
tp[17][5] = 1
tp[17][6] = 27
tp[17][7] = 0
tp[18][1] = 0
tp[18][2] = 0
tp[18][3] = -2
tp[18][4] = 2
tp[18][5] = 1
tp[18][6] = -24
tp[18][7] = 0
tp[19][1] = 2
tp[19][2] = 0
tp[19][3] = 0
tp[19][4] = 2
tp[19][5] = 2
tp[19][6] = 16
tp[19][7] = 0
tp[20][1] = 0
tp[20][2] = 0
tp[20][3] = 2
tp[20][4] = 2
tp[20][5] = 2
tp[20][6] = 13
tp[20][7] = 0
tp[21][1] = -2
tp[21][2] = 0
tp[21][3] = 1
tp[21][4] = 2
tp[21][5] = 2
tp[21][6] = -12
tp[21][7] = 0
tp[22][1] = 0
tp[22][2] = 0
tp[22][3] = -1
tp[22][4] = 2
tp[22][5] = 1
tp[22][6] = -10
tp[22][7] = 0
tp[23][1] = 2
tp[23][2] = 0
tp[23][3] = -1
tp[23][4] = 0
tp[23][5] = 1
tp[23][6] = -8
tp[23][7] = 0
tp[24][1] = -2
tp[24][2] = 2
tp[24][3] = 0
tp[24][4] = 2
tp[24][5] = 2
tp[24][6] = 7
tp[24][7] = 0
tp[25][1] = 0
tp[25][2] = 1
tp[25][3] = 0
tp[25][4] = 0
tp[25][5] = 1
tp[25][6] = 9
tp[25][7] = 0
tp[26][1] = -2
tp[26][2] = 0
tp[26][3] = 1
tp[26][4] = 0
tp[26][5] = 1
tp[26][6] = 7
tp[26][7] = 0
tp[27][1] = 0
tp[27][2] = -1
tp[27][3] = 0
tp[27][4] = 0
tp[27][5] = 1
tp[27][6] = 6
tp[27][7] = 0
tp[28][1] = 2
tp[28][2] = 0
tp[28][3] = -1
tp[28][4] = 2
tp[28][5] = 1
tp[28][6] = 5
tp[28][7] = 0
tp[29][1] = 2
tp[29][2] = 0
tp[29][3] = 1
tp[29][4] = 2
tp[29][5] = 2
tp[29][6] = 3
tp[29][7] = 0
tp[30][1] = 0
tp[30][2] = 1
tp[30][3] = 0
tp[30][4] = 2
tp[30][5] = 2
tp[30][6] = -3
tp[30][7] = 0
tp[31][1] = 0
tp[31][2] = -1
tp[31][3] = 0
tp[31][4] = 2
tp[31][5] = 2
tp[31][6] = 3
tp[31][7] = 0
tp[32][1] = 2
tp[32][2] = 0
tp[32][3] = 0
tp[32][4] = 2
tp[32][5] = 1
tp[32][6] = 3
tp[32][7] = 0
tp[33][1] = -2
tp[33][2] = 0
tp[33][3] = 2
tp[33][4] = 2
tp[33][5] = 2
tp[33][6] = -3
tp[33][7] = 0
tp[34][1] = -2
tp[34][2] = 0
tp[34][3] = 1
tp[34][4] = 2
tp[34][5] = 1
tp[34][6] = -3
tp[34][7] = 0
tp[35][1] = 2
tp[35][2] = 0
tp[35][3] = -2
tp[35][4] = 0
tp[35][5] = 1
tp[35][6] = 3
tp[35][7] = 0
tp[36][1] = 2
tp[36][2] = 0
tp[36][3] = 0
tp[36][4] = 0
tp[36][5] = 1
tp[36][6] = 3
tp[36][7] = 0
tp[37][1] = -2
tp[37][2] = -1
tp[37][3] = 0
tp[37][4] = 2
tp[37][5] = 1
tp[37][6] = 3
tp[37][7] = 0
tp[38][1] = -2
tp[38][2] = 0
tp[38][3] = 0
tp[38][4] = 0
tp[38][5] = 1
tp[38][6] = 3
tp[38][7] = 0
tp[39][1] = 0
tp[39][2] = 0
tp[39][3] = 2
tp[39][4] = 2
tp[39][5] = 1
tp[39][6] = 3
tp[39][7] = 0
var S float64 = 0
for i := 1; i < 40; i++ {
S += (tp[i][6] + tp[i][7]) * Cos(D*tp[i][1]+M*tp[i][2]+N*tp[i][3]+F*tp[i][4]+O*tp[i][5])
}
return S / 10000 / 3600
return s / 10000 / 3600
}
/*
@name 太阳几何黄经
@name 太阳几何黄经
*/
func SunLo(jd float64) float64 {
T := (jd - 2451545) / 365250
@@ -806,7 +82,7 @@ func SunM(JD float64) float64 {
}
/*
@name 地球偏心率
@name 地球偏心率
*/
func Earthe(JD float64) float64 { //'地球偏心率
T := (JD - 2451545) / 36525
@@ -841,6 +117,10 @@ func SunApparentRa(JD float64) float64 { // '太阳视赤经
return LoToRa(JD, SunApparentLo(JD), 0)
}
func SunApparentRaDec(JD float64) (float64, float64) {
return LoBoToRaDec(JD, SunApparentLo(JD), 0)
}
func SunTrueRa(JD float64) float64 { //'太阳真赤经
sitas := Sita(JD)
@@ -965,54 +245,47 @@ func RDJL(jd float64) float64 { //ri di ju li
return (1.000001018 * (1 - e*e) / (1 + e*Cos(f+m)))
}
func GetOneYearMoon(year float64) map[int]float64 {
func GetMoonLoops(year float64, loop int) []float64 {
var start float64
var tmp1, tmp float64
moon := make(map[int]float64)
var newMoon, tmp float64
moon := make([]float64, loop)
if year < 6000 {
start = year + 11.00/12.00 + 5.00/30.00/12.00
} else {
start = year + 9.00/12.00 + 5.00/30.00/12.00
}
i := 1
for j := 1; j < 17; j++ {
for j := 0; j < loop; j++ {
if year > 3000 {
tmp1 = TD2UT(CalcMoonSH(start+float64(i-1)/12.5, 0)+8.0/24.0, false)
newMoon = TD2UT(CalcMoonSH(start+float64(i-1)/12.5, 0)+8.0/24.0, false)
} else {
tmp1 = TD2UT(CalcMoonS(start+float64(i-1)/12.5, 0)+8.0/24.0, false)
newMoon = TD2UT(CalcMoonS(start+float64(i-1)/12.5, 0)+8.0/24.0, false)
}
if i != 1 {
if tmp1 == tmp {
if newMoon == tmp {
j--
i++
continue
}
}
moon[j] = tmp1
moon[j] = newMoon
tmp = moon[j]
i++
// echo DateCalc(moon[i])."<br />";
}
return moon
}
func GetOneYearJQ(year int) []float64 {
func GetJieqiLoops(year, loop int) []float64 {
start := 270
var years int
jq := make([]float64, 26)
for i := 1; i < 26; i++ {
jq := make([]float64, loop)
for i := 1; i <= loop; i++ {
angle := start + 15*(i-1)
if angle > 360 {
angle -= 360
}
if i > 1 {
years = year + 1
} else {
years = year
}
jq[i] = GetJQTime(years, angle) + 8.0/24.0
// echo DateCalc(jq[i])."<br />";
jq[i-1] = GetJQTime(year+int(math.Ceil(float64(i-1)/24.000)), angle) + 8.0/24.0
}
jq[0] = jq[1]
return jq
}
+51 -1
View File
@@ -1,13 +1,15 @@
package basic
import (
"b612.me/astro/tools"
"fmt"
"math"
"testing"
"time"
)
func Test_Jq(t *testing.T) {
data := GetOneYearJQ(2019)
data := GetJieqiLoops(2019, 24)
for i := 1; i < 25; i++ {
fmt.Println(JDE2Date(data[i]))
}
@@ -17,11 +19,59 @@ func Test_Jq(t *testing.T) {
//fmt.Println(HSunApparentLo(date))
}
func TestZD(t *testing.T) {
jde := 2452982.9872345612
zd := HJZD(jde)
fmt.Println(zd)
if zd != -0.003746747950462434 {
t.Fatal("not equal")
}
zd = JJZD(jde)
fmt.Println(zd)
if zd != 0.001513453926274198 {
t.Fatal("not equal")
}
}
func Test_SunLo(t *testing.T) {
fmt.Printf("%.14f\n", HSunTrueLo(2458840.0134162))
fmt.Printf("%.14f", HSunApparentLo(2458840.0134162))
}
func Test_SunDiff(t *testing.T) {
n := JDECalc(2000, 1, 1)
var maxRa, maxDec, maxLo float64
for i := float64(0); i < 365.2422*30; i++ {
tLo := HSunApparentLo(n + i)
tRa, tDec := HSunApparentRaDec(n + i)
fRa, fDec := SunApparentRaDec(n + i)
fLo := SunApparentLo(n + i)
tmp := tools.Limit360(math.Abs(tRa - fRa))
if tmp > 300 {
tmp = 360 - tmp
}
if tmp > maxRa {
maxRa = tmp
}
tmp = tools.Limit360(math.Abs(tDec - fDec))
if tmp > 300 {
tmp = 360 - tmp
}
if tmp > maxDec {
maxDec = tmp
}
tmp = tools.Limit360(math.Abs(tLo - fLo))
if tmp > 300 {
tmp = 360 - tmp
}
if tmp > maxLo {
maxLo = tmp
}
}
fmt.Printf("%.15f %.15f %.15f\n", maxRa*3600, maxDec*3600, maxLo*3600)
}
func Benchmark_SunRise(b *testing.B) {
jde := GetNowJDE()
for i := 0; i < b.N; i++ {