change delta T formula and add planet phenomena function

master
兔子 3 years ago
parent bb07e23238
commit 97c017be08
Signed by: b612
GPG Key ID: 481225A74DEB62A1

8
.idea/.gitignore vendored

@ -0,0 +1,8 @@
# 默认忽略的文件
/shelf/
/workspace.xml
# 数据源本地存储已忽略文件
/../../../../../../:\gocode\src\b612.me\astro\.idea/dataSources/
/dataSources.local.xml
# 基于编辑器的 HTTP 客户端请求
/httpRequests/

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="Go" enabled="true" />
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/astro.iml" filepath="$PROJECT_DIR$/.idea/astro.iml" />
</modules>
</component>
</project>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

@ -104,8 +104,8 @@ func DeltaT(Date float64, IsJDE bool) (Result float64) { //传入年或儒略日
return return
} }
if Year < 2100 && Year >= 2010 { if Year < 2100 && Year >= 2010 {
//fmt.Println(Year) var t = (Year - 2000.0)
Result = dt_cal(Year) //-3.2-(Year-2017)*0.029915; Result = 62.92 + 0.32217*t + 0.005589*t*t
return return
} }
if Year >= 2100 && Year <= 2150 { if Year >= 2100 && Year <= 2150 {

@ -9,8 +9,8 @@ import (
/* /*
* *
*/ */
func LoToRa(lo, bo, jde float64) float64 { func LoToRa(jde, lo, bo float64) float64 {
ra := math.Atan2(Sin(lo)*Cos(Sita(jde)-Tan(bo)*Sin(Sita(jde))), Cos(lo)) ra := math.Atan2(Sin(lo)*Cos(Sita(jde))-Tan(bo)*Sin(Sita(jde)), Cos(lo))
ra = ra * 180 / math.Pi ra = ra * 180 / math.Pi
if ra < 0 { if ra < 0 {
ra += 360 ra += 360
@ -18,11 +18,48 @@ func LoToRa(lo, bo, jde float64) float64 {
return ra return ra
} }
func BoToDec(lo, bo, jde float64) float64 { func BoToDec(jde, lo, bo float64) float64 {
dec := ArcSin(Sin(bo)*Cos(Sita(jde)) + Cos(bo)*Sin(Sita(jde))*Sin(lo)) dec := ArcSin(Sin(bo)*Cos(Sita(jde)) + Cos(bo)*Sin(Sita(jde))*Sin(lo))
return dec return dec
} }
func LoBoToRaDec(jde, lo, bo float64) (float64, float64) {
dec := ArcSin(Sin(bo)*Cos(Sita(jde)) + Cos(bo)*Sin(Sita(jde))*Sin(lo))
ra := math.Atan2(Sin(lo)*Cos(Sita(jde))-Tan(bo)*Sin(Sita(jde)), Cos(lo))
ra = ra * 180 / math.Pi
if ra < 0 {
ra += 360
}
return ra, dec
}
func RaDecToLoBo(jde, ra, dec float64) (float64, float64) {
//tan(λ) = (sin(α)*cos(ε) + tan(δ)*sin(ε)) / cos(α)
//sin(β)=sin(δ)*cos(ε)-cos(δ)*sin(ε)*sin(α)
sita := Sita(jde)
sinBo := Sin(dec)*Cos(sita) - Cos(dec)*Sin(sita)*Sin(ra)
lo := math.Atan2((Sin(ra)*Cos(sita) + Tan(dec)*Sin(sita)), Cos(ra))
lo = Limit360(lo * 180 / math.Pi)
return lo, ArcSin(sinBo)
}
func RaToLo(jde, ra, dec float64) float64 {
//tan(λ) = (sin(α)*cos(ε) + tan(δ)*sin(ε)) / cos(α)
//sin(β)=sin(δ)*cos(ε)-cos(δ)*sin(ε)*sin(α)
sita := Sita(jde)
lo := math.Atan2((Sin(ra)*Cos(sita) + Tan(dec)*Sin(sita)), Cos(ra))
lo = Limit360(lo * 180 / math.Pi)
return lo
}
func DecToBo(jde, ra, dec float64) float64 {
//tan(λ) = (sin(α)*cos(ε) + tan(δ)*sin(ε)) / cos(α)
//sin(β)=sin(δ)*cos(ε)-cos(δ)*sin(ε)*sin(α)
sita := Sita(jde)
sinBo := Sin(dec)*Cos(sita) - Cos(dec)*Sin(sita)*Sin(ra)
return ArcSin(sinBo)
}
/* /*
* st end JDE * st end JDE
*/ */
@ -98,7 +135,7 @@ func ZhanXinLo(lo, bo, lat, lon, jd, au, h float64) float64 { //jd为格林尼
C := pcosi(lat, h) C := pcosi(lat, h)
S := psini(lat, h) S := psini(lat, h)
sinpi := Sin(0.0024427777777) / au sinpi := Sin(0.0024427777777) / au
ra := LoToRa(lo, bo, jd) ra := LoToRa(jd, lo, bo)
tH := Limit360(TD2UT(ApparentSiderealTime(jd), false)*15 + lon - ra) tH := Limit360(TD2UT(ApparentSiderealTime(jd), false)*15 + lon - ra)
N := Cos(lo)*Cos(bo) - C*sinpi*Cos(tH) N := Cos(lo)*Cos(bo) - C*sinpi*Cos(tH)
nlo := math.Atan2(Sin(lo)*Cos(bo)-sinpi*(S*Sin(Sita(jd))+C*Cos(Sita(jd))*Sin(tH)), N) * 180 / math.Pi nlo := math.Atan2(Sin(lo)*Cos(bo)-sinpi*(S*Sin(Sita(jd))+C*Cos(Sita(jd))*Sin(tH)), N) * 180 / math.Pi
@ -109,7 +146,7 @@ func ZhanXinBo(lo, bo, lat, lon, jd, au, h float64) float64 { //jd为格林尼
C := pcosi(lat, h) C := pcosi(lat, h)
S := psini(lat, h) S := psini(lat, h)
sinpi := Sin(0.0024427777777) / au sinpi := Sin(0.0024427777777) / au
ra := LoToRa(lo, bo, jd) ra := LoToRa(jd, lo, bo)
tH := Limit360(TD2UT(ApparentSiderealTime(jd), false)*15 + lon - ra) tH := Limit360(TD2UT(ApparentSiderealTime(jd), false)*15 + lon - ra)
N := Cos(lo)*Cos(bo) - C*sinpi*Cos(tH) N := Cos(lo)*Cos(bo) - C*sinpi*Cos(tH)
nlo := math.Atan2(Sin(lo)*Cos(bo)-sinpi*(S*Sin(Sita(jd))+C*Cos(Sita(jd))*Sin(tH)), N) * 180 / math.Pi nlo := math.Atan2(Sin(lo)*Cos(bo)-sinpi*(S*Sin(Sita(jd))+C*Cos(Sita(jd))*Sin(tH)), N) * 180 / math.Pi
@ -117,25 +154,20 @@ func ZhanXinBo(lo, bo, lat, lon, jd, au, h float64) float64 { //jd为格林尼
return nbo return nbo
} }
/*
func GXCLo(lo, bo, jd float64) float64 { //光行差修正 func GXCLo(lo, bo, jd float64) float64 { //光行差修正
k:=20.49552; k := 20.49552
sunlo:=SunTrueLo(jd); sunlo := SunTrueLo(jd)
e:=Earthe(jd); e := Earthe(jd)
epi=earth->EarthPI(jd); epi := EarthPI(jd)
tmp=(-k*this->CosR(sunlo-lo)+e*k*this->CosR(epi-lo))/this->CosR(bo); tmp := (-k*Cos(sunlo-lo) + e*k*Cos(epi-lo)) / Cos(bo)
return tmp; return tmp
} }
public function GXCBo(lo,bo,jd) func GXCBo(lo, bo, jd float64) float64 {
{ k := 20.49552
earth=new Earth(); sunlo := SunTrueLo(jd)
k=20.49552; e := Earthe(jd)
sunlo=earth->SunTrueLo(jd); epi := EarthPI(jd)
e=earth->Earthe(jd); tmp := -k * Sin(bo) * (Sin(sunlo-lo) - e*Sin(epi-lo))
epi=earth->EarthPI(jd); return tmp
tmp=-k*this->SinR(bo)*(this->SinR(sunlo-lo)-e*this->SinR(epi-lo));
return tmp;
} }
*/

@ -8,3 +8,43 @@ import (
func Test_LoBo(t *testing.T) { func Test_LoBo(t *testing.T) {
fmt.Printf("%.9f", dt_cal(2020.5)) fmt.Printf("%.9f", dt_cal(2020.5))
} }
func Test_LoBoRaDec(t *testing.T) {
jde := 2451545.0
lo, bo := RaDecToLoBo(jde, 10, 50)
fmt.Println("LO,BO", lo, bo)
fmt.Println(LoBoToRaDec(jde, lo, bo))
lo, bo = RaDecToLoBo(jde, 40, 80)
fmt.Println("LO,BO", lo, bo)
fmt.Println(LoBoToRaDec(jde, lo, bo))
lo, bo = RaDecToLoBo(jde, 90, 50)
fmt.Println("LO,BO", lo, bo)
fmt.Println(LoBoToRaDec(jde, lo, bo))
lo, bo = RaDecToLoBo(jde, 130, 50)
fmt.Println("LO,BO", lo, bo)
fmt.Println(LoBoToRaDec(jde, lo, bo))
lo, bo = RaDecToLoBo(jde, 160, 50)
fmt.Println("LO,BO", lo, bo)
fmt.Println(LoBoToRaDec(jde, lo, bo))
lo, bo = RaDecToLoBo(jde, 180, 50)
fmt.Println("LO,BO", lo, bo)
fmt.Println(LoBoToRaDec(jde, lo, bo))
lo, bo = RaDecToLoBo(jde, 210, 50)
fmt.Println("LO,BO", lo, bo)
fmt.Println(LoBoToRaDec(jde, lo, bo))
lo, bo = RaDecToLoBo(jde, 260, 50)
fmt.Println("LO,BO", lo, bo)
fmt.Println(LoBoToRaDec(jde, lo, bo))
lo, bo = RaDecToLoBo(jde, 270, 50)
fmt.Println("LO,BO", lo, bo)
fmt.Println(LoBoToRaDec(jde, lo, bo))
lo, bo = RaDecToLoBo(jde, 300, 50)
fmt.Println("LO,BO", lo, bo)
fmt.Println(LoBoToRaDec(jde, lo, bo))
lo, bo = RaDecToLoBo(jde, 350, 50)
fmt.Println("LO,BO", lo, bo)
fmt.Println(LoBoToRaDec(jde, lo, bo))
lo, bo = RaDecToLoBo(jde, 0, 50)
fmt.Println("LO,BO", lo, bo)
fmt.Println(LoBoToRaDec(jde, lo, bo))
}

@ -63,22 +63,22 @@ func AJupiterXYZ(JD float64) (float64, float64, float64) {
return x, y, z return x, y, z
} }
func JupiterSeeRa(JD float64) float64 { func JupiterApparentRa(JD float64) float64 {
lo, bo := JupiterSeeLoBo(JD) lo, bo := JupiterApparentLoBo(JD)
sita := Sita(JD) sita := Sita(JD)
ra := math.Atan2((Sin(lo)*Cos(sita) - Tan(bo)*Sin(sita)), Cos(lo)) ra := math.Atan2((Sin(lo)*Cos(sita) - Tan(bo)*Sin(sita)), Cos(lo))
ra = ra * 180 / math.Pi ra = ra * 180 / math.Pi
return Limit360(ra) return Limit360(ra)
} }
func JupiterSeeDec(JD float64) float64 { func JupiterApparentDec(JD float64) float64 {
lo, bo := JupiterSeeLoBo(JD) lo, bo := JupiterApparentLoBo(JD)
sita := Sita(JD) sita := Sita(JD)
dec := ArcSin(Sin(bo)*Cos(sita) + Cos(bo)*Sin(sita)*Sin(lo)) dec := ArcSin(Sin(bo)*Cos(sita) + Cos(bo)*Sin(sita)*Sin(lo))
return dec return dec
} }
func JupiterSeeRaDec(JD float64) (float64, float64) { func JupiterApparentRaDec(JD float64) (float64, float64) {
lo, bo := JupiterSeeLoBo(JD) lo, bo := JupiterApparentLoBo(JD)
sita := Sita(JD) sita := Sita(JD)
ra := math.Atan2((Sin(lo)*Cos(sita) - Tan(bo)*Sin(sita)), Cos(lo)) ra := math.Atan2((Sin(lo)*Cos(sita) - Tan(bo)*Sin(sita)), Cos(lo))
ra = ra * 180 / math.Pi ra = ra * 180 / math.Pi
@ -92,7 +92,7 @@ func EarthJupiterAway(JD float64) float64 {
return to return to
} }
func JupiterSeeLo(JD float64) float64 { func JupiterApparentLo(JD float64) float64 {
x, y, z := AJupiterXYZ(JD) x, y, z := AJupiterXYZ(JD)
to := 0.0057755183 * math.Sqrt(x*x+y*y+z*z) to := 0.0057755183 * math.Sqrt(x*x+y*y+z*z)
x, y, z = AJupiterXYZ(JD - to) x, y, z = AJupiterXYZ(JD - to)
@ -107,7 +107,7 @@ func JupiterSeeLo(JD float64) float64 {
return lo return lo
} }
func JupiterSeeBo(JD float64) float64 { func JupiterApparentBo(JD float64) float64 {
x, y, z := AJupiterXYZ(JD) x, y, z := AJupiterXYZ(JD)
to := 0.0057755183 * math.Sqrt(x*x+y*y+z*z) to := 0.0057755183 * math.Sqrt(x*x+y*y+z*z)
x, y, z = AJupiterXYZ(JD - to) x, y, z = AJupiterXYZ(JD - to)
@ -121,7 +121,7 @@ func JupiterSeeBo(JD float64) float64 {
return bo return bo
} }
func JupiterSeeLoBo(JD float64) (float64, float64) { func JupiterApparentLoBo(JD float64) (float64, float64) {
x, y, z := AJupiterXYZ(JD) x, y, z := AJupiterXYZ(JD)
to := 0.0057755183 * math.Sqrt(x*x+y*y+z*z) to := 0.0057755183 * math.Sqrt(x*x+y*y+z*z)
x, y, z = AJupiterXYZ(JD - to) x, y, z = AJupiterXYZ(JD - to)
@ -145,3 +145,293 @@ func JupiterMag(JD float64) float64 {
Mag := -9.40 + 5*math.Log10(AwaySun*AwayEarth) + 0.0005*i Mag := -9.40 + 5*math.Log10(AwaySun*AwayEarth) + 0.0005*i
return FloatRound(Mag, 2) return FloatRound(Mag, 2)
} }
func JupiterHeight(jde, lon, lat, timezone float64) float64 {
// 转换为世界时
utcJde := jde - timezone/24.0
// 计算视恒星时
ra, dec := JupiterApparentRaDec(TD2UT(utcJde, true))
st := Limit360(ApparentSiderealTime(utcJde)*15 + lon)
// 计算时角
H := Limit360(st - ra)
// 高度角、时角与天球座标三角转换公式
// sin(h)=sin(lat)*sin(dec)+cos(dec)*cos(lat)*cos(H)
sinHeight := Sin(lat)*Sin(dec) + Cos(dec)*Cos(lat)*Cos(H)
return ArcSin(sinHeight)
}
func JupiterAzimuth(jde, lon, lat, timezone float64) float64 {
// 转换为世界时
utcJde := jde - timezone/24.0
// 计算视恒星时
ra, dec := JupiterApparentRaDec(TD2UT(utcJde, true))
st := Limit360(ApparentSiderealTime(utcJde)*15 + lon)
// 计算时角
H := Limit360(st - ra)
// 三角转换公式
tanAzimuth := Sin(H) / (Cos(H)*Sin(lat) - Tan(dec)*Cos(lat))
Azimuth := ArcTan(tanAzimuth)
if Azimuth < 0 {
if H/15 < 12 {
return Azimuth + 360
}
return Azimuth + 180
}
if H/15 < 12 {
return Azimuth + 180
}
return Azimuth
}
func JupiterHourAngle(JD, Lon, TZ float64) float64 {
startime := Limit360(ApparentSiderealTime(JD-TZ/24)*15 + Lon)
timeangle := startime - JupiterApparentRa(TD2UT(JD-TZ/24.0, true))
if timeangle < 0 {
timeangle += 360
}
return timeangle
}
func JupiterCulminationTime(jde, lon, timezone float64) float64 {
//jde 世界时,非力学时,当地时区 0时无需转换力学时
//ra,dec 瞬时天球座标非J2000等时间天球坐标
jde = math.Floor(jde) + 0.5
JD1 := jde + Limit360(360-JupiterHourAngle(jde, lon, timezone))/15.0/24.0*0.99726851851851851851
limitHA := func(jde, lon, timezone float64) float64 {
ha := JupiterHourAngle(jde, lon, timezone)
if ha < 180 {
ha += 360
}
return ha
}
for {
JD0 := JD1
stDegree := limitHA(JD0, lon, timezone) - 360
stDegreep := (limitHA(JD0+0.000005, lon, timezone) - limitHA(JD0-0.000005, lon, timezone)) / 0.00001
JD1 = JD0 - stDegree/stDegreep
if math.Abs(JD1-JD0) <= 0.00001 {
break
}
}
return JD1
}
func JupiterRiseTime(JD, Lon, Lat, TZ, ZS, HEI float64) float64 {
return jupiterRiseDown(JD, Lon, Lat, TZ, ZS, HEI, true)
}
func JupiterDownTime(JD, Lon, Lat, TZ, ZS, HEI float64) float64 {
return jupiterRiseDown(JD, Lon, Lat, TZ, ZS, HEI, false)
}
func jupiterRiseDown(JD, Lon, Lat, TZ, ZS, HEI float64, isRise bool) float64 {
var An float64
JD = math.Floor(JD) + 0.5
ntz := math.Round(Lon / 15)
if ZS != 0 {
An = -0.8333
}
An = An - HeightDegreeByLat(HEI, Lat)
tztime := JupiterCulminationTime(JD, Lon, ntz)
if JupiterHeight(tztime, Lon, Lat, ntz) < An {
return -2 //极夜
}
if JupiterHeight(tztime-0.5, Lon, Lat, ntz) > An {
return -1 //极昼
}
dec := HSunApparentDec(TD2UT(tztime-ntz/24, true))
//(sin(ho)-sin(φ)*sin(δ2))/(cos(φ)*cos(δ2))
tmp := (Sin(An) - Sin(dec)*Sin(Lat)) / (Cos(dec) * Cos(Lat))
var rise float64
if math.Abs(tmp) <= 1 {
rzsc := ArcCos(tmp) / 15
if isRise {
rise = tztime - rzsc/24 - 25.0/24.0/60.0
} else {
rise = tztime + rzsc/24 - 25.0/24.0/60.0
}
} else {
rise = tztime
i := 0
//TODO:使用二分法计算
for JupiterHeight(rise, Lon, Lat, ntz) > An {
i++
if isRise {
rise -= 15.0 / 60.0 / 24.0
} else {
rise += 15.0 / 60.0 / 24.0
}
if i > 48 {
break
}
}
}
JD1 := rise
for {
JD0 := JD1
stDegree := JupiterHeight(JD0, Lon, Lat, ntz) - An
stDegreep := (JupiterHeight(JD0+0.000005, Lon, Lat, ntz) - JupiterHeight(JD0-0.000005, Lon, Lat, ntz)) / 0.00001
JD1 = JD0 - stDegree/stDegreep
if math.Abs(JD1-JD0) <= 0.00001 {
break
}
}
return JD1 - ntz/24 + TZ/24
}
// Pos
const JUPITER_S_PERIOD = 1 / ((1 / 365.256363004) - (1 / 4332.59))
func jupiterConjunction(jde, degree float64, next uint8) float64 {
//0=last 1=next
decSub := func(jde float64, degree float64, filter bool) float64 {
sub := Limit360(Limit360(JupiterApparentLo(jde)-HSunApparentLo(jde)) - degree)
if filter {
if sub > 180 {
sub -= 360
}
if sub < -180 {
sub += 360
}
}
return sub
}
dayCost := JUPITER_S_PERIOD / 360
nowSub := decSub(jde, degree, false)
if next == 0 {
jde -= (360 - nowSub) * dayCost
} else {
jde += dayCost * nowSub
}
JD1 := jde
for {
JD0 := JD1
stDegree := decSub(JD0, degree, true)
stDegreep := (decSub(JD0+0.000005, degree, true) - decSub(JD0-0.000005, degree, true)) / 0.00001
JD1 = JD0 - stDegree/stDegreep
if math.Abs(JD1-JD0) <= 0.00001 {
break
}
}
return TD2UT(JD1, false)
}
func LastJupiterConjunction(jde float64) float64 {
return jupiterConjunction(jde, 0, 0)
}
func NextJupiterConjunction(jde float64) float64 {
return jupiterConjunction(jde, 0, 1)
}
func LastJupiterOpposition(jde float64) float64 {
return jupiterConjunction(jde, 180, 0)
}
func NextJupiterOpposition(jde float64) float64 {
return jupiterConjunction(jde, 180, 1)
}
func NextJupiterEasternQuadrature(jde float64) float64 {
return jupiterConjunction(jde, 90, 1)
}
func LastJupiterEasternQuadrature(jde float64) float64 {
return jupiterConjunction(jde, 90, 0)
}
func NextJupiterWesternQuadrature(jde float64) float64 {
return jupiterConjunction(jde, 270, 1)
}
func LastJupiterWesternQuadrature(jde float64) float64 {
return jupiterConjunction(jde, 270, 0)
}
func jupiterRetrograde(jde float64, isLeft bool) float64 {
//0=last 1=next
decSub := func(jde float64, val float64) float64 {
sub := JupiterApparentRa(jde+val) - JupiterApparentRa(jde-val)
if sub > 180 {
sub -= 360
}
if sub < -180 {
sub += 360
}
return sub / (2 * val)
}
jde = NextJupiterOpposition(jde)
if isLeft {
jde -= 60
} else {
jde += 60
}
for {
nowSub := decSub(jde, 1.0/86400.0)
if math.Abs(nowSub) > 0.55 {
jde += 2
continue
}
break
}
JD1 := jde
for {
JD0 := JD1
stDegree := decSub(JD0, 2.0/86400.0)
stDegreep := (decSub(JD0+15.0/86400.0, 2.0/86400.0) - decSub(JD0-15.0/86400.0, 2.0/86400.0)) / (30.0 / 86400.0)
JD1 = JD0 - stDegree/stDegreep
if math.Abs(JD1-JD0) <= 30.0/86400.0 {
break
}
}
JD1 = JD1 - 15.0/86400.0
min := JD1
minRa := 100.0
for i := 0.0; i < 60.0; i++ {
tmp := decSub(JD1+i*0.5/86400.0, 0.5/86400.0)
if math.Abs(tmp) < math.Abs(minRa) {
minRa = tmp
min = JD1 + i*0.5/86400.0
}
}
return TD2UT(min, false)
}
func NextJupiterRetrogradeToPrograde(jde float64) float64 {
date := jupiterRetrograde(jde, false)
if date < jde {
op := NextJupiterOpposition(jde)
return jupiterRetrograde(op+10, false)
}
return date
}
func LastJupiterRetrogradeToPrograde(jde float64) float64 {
jde = LastJupiterOpposition(jde) - 10
date := jupiterRetrograde(jde, false)
if date > jde {
op := LastJupiterOpposition(jde)
return jupiterRetrograde(op-10, false)
}
return date
}
func NextJupiterProgradeToRetrograde(jde float64) float64 {
date := jupiterRetrograde(jde, true)
if date < jde {
op := NextJupiterOpposition(jde)
return jupiterRetrograde(op+10, true)
}
return date
}
func LastJupiterProgradeToRetrograde(jde float64) float64 {
jde = LastJupiterOpposition(jde) - 10
date := jupiterRetrograde(jde, true)
if date > jde {
op := LastJupiterOpposition(jde)
return jupiterRetrograde(op-10, true)
}
return date
}

@ -0,0 +1,13 @@
package basic
import (
"fmt"
"testing"
)
func TestJupiter(t *testing.T) {
jde := GetNowJDE() - 6000
for i := 0.00; i < 20; i++ {
fmt.Println(jde+i*365, JDE2Date(jde+i*365), JDE2Date(NextJupiterRetrogradeToPrograde(jde+i*365)))
}
}

@ -63,22 +63,22 @@ func AMarsXYZ(JD float64) (float64, float64, float64) {
return x, y, z return x, y, z
} }
func MarsSeeRa(JD float64) float64 { func MarsApparentRa(JD float64) float64 {
lo, bo := MarsSeeLoBo(JD) lo, bo := MarsApparentLoBo(JD)
sita := Sita(JD) sita := Sita(JD)
ra := math.Atan2((Sin(lo)*Cos(sita) - Tan(bo)*Sin(sita)), Cos(lo)) ra := math.Atan2((Sin(lo)*Cos(sita) - Tan(bo)*Sin(sita)), Cos(lo))
ra = ra * 180 / math.Pi ra = ra * 180 / math.Pi
return Limit360(ra) return Limit360(ra)
} }
func MarsSeeDec(JD float64) float64 { func MarsApparentDec(JD float64) float64 {
lo, bo := MarsSeeLoBo(JD) lo, bo := MarsApparentLoBo(JD)
sita := Sita(JD) sita := Sita(JD)
dec := ArcSin(Sin(bo)*Cos(sita) + Cos(bo)*Sin(sita)*Sin(lo)) dec := ArcSin(Sin(bo)*Cos(sita) + Cos(bo)*Sin(sita)*Sin(lo))
return dec return dec
} }
func MarsSeeRaDec(JD float64) (float64, float64) { func MarsApparentRaDec(JD float64) (float64, float64) {
lo, bo := MarsSeeLoBo(JD) lo, bo := MarsApparentLoBo(JD)
sita := Sita(JD) sita := Sita(JD)
ra := math.Atan2((Sin(lo)*Cos(sita) - Tan(bo)*Sin(sita)), Cos(lo)) ra := math.Atan2((Sin(lo)*Cos(sita) - Tan(bo)*Sin(sita)), Cos(lo))
ra = ra * 180 / math.Pi ra = ra * 180 / math.Pi
@ -92,22 +92,21 @@ func EarthMarsAway(JD float64) float64 {
return to return to
} }
func MarsSeeLo(JD float64) float64 { func MarsApparentLo(JD float64) float64 {
x, y, z := AMarsXYZ(JD) x, y, z := AMarsXYZ(JD)
to := 0.0057755183 * math.Sqrt(x*x+y*y+z*z) to := 0.0057755183 * math.Sqrt(x*x+y*y+z*z)
x, y, z = AMarsXYZ(JD - to) x, y, z = AMarsXYZ(JD - to)
lo := math.Atan2(y, x) lo := math.Atan2(y, x)
bo := math.Atan2(z, math.Sqrt(x*x+y*y)) //bo := math.Atan2(z, math.Sqrt(x*x+y*y))
lo = lo * 180 / math.Pi lo = lo * 180.0 / math.Pi
bo = bo * 180 / math.Pi //bo = bo * 180 / math.Pi
lo = Limit360(lo) lo = Limit360(lo) + HJZD(JD)
//lo-=GXCLo(lo,bo,JD)/3600; //lo-=GXCLo(lo,bo,JD)/3600;
//bo+=GXCBo(lo,bo,JD); //bo+=GXCBo(lo,bo,JD);
lo += HJZD(JD)
return lo return lo
} }
func MarsSeeBo(JD float64) float64 { func MarsApparentBo(JD float64) float64 {
x, y, z := AMarsXYZ(JD) x, y, z := AMarsXYZ(JD)
to := 0.0057755183 * math.Sqrt(x*x+y*y+z*z) to := 0.0057755183 * math.Sqrt(x*x+y*y+z*z)
x, y, z = AMarsXYZ(JD - to) x, y, z = AMarsXYZ(JD - to)
@ -121,7 +120,7 @@ func MarsSeeBo(JD float64) float64 {
return bo return bo
} }
func MarsSeeLoBo(JD float64) (float64, float64) { func MarsApparentLoBo(JD float64) (float64, float64) {
x, y, z := AMarsXYZ(JD) x, y, z := AMarsXYZ(JD)
to := 0.0057755183 * math.Sqrt(x*x+y*y+z*z) to := 0.0057755183 * math.Sqrt(x*x+y*y+z*z)
x, y, z = AMarsXYZ(JD - to) x, y, z = AMarsXYZ(JD - to)
@ -130,12 +129,32 @@ func MarsSeeLoBo(JD float64) (float64, float64) {
lo = lo * 180 / math.Pi lo = lo * 180 / math.Pi
bo = bo * 180 / math.Pi bo = bo * 180 / math.Pi
lo = Limit360(lo) lo = Limit360(lo)
//lo-=GXCLo(lo,bo,JD)/3600; //lo -= GXCLo(lo, bo, JD) / 3600
//bo+=GXCBo(lo,bo,JD); //bo += GXCBo(lo, bo, JD)
lo += HJZD(JD) lo += HJZD(JD)
return lo, bo return lo, bo
} }
func MarsTrueLoBo(JD float64) (float64, float64) {
x, y, z := AMarsXYZ(JD)
to := 0.0057755183 * math.Sqrt(x*x+y*y+z*z)
x, y, z = AMarsXYZ(JD - to)
lo := math.Atan2(y, x)
bo := math.Atan2(z, math.Sqrt(x*x+y*y))
lo = lo * 180 / math.Pi
bo = bo * 180 / math.Pi
lo = Limit360(lo)
return lo, bo
}
func MarsTrueLo(JD float64) float64 {
x, y, _ := AMarsXYZ(JD)
lo := math.Atan2(y, x)
lo = lo * 180 / math.Pi
lo = Limit360(lo)
return lo
}
func MarsMag(JD float64) float64 { func MarsMag(JD float64) float64 {
AwaySun := MarsR(JD) AwaySun := MarsR(JD)
AwayEarth := EarthMarsAway(JD) AwayEarth := EarthMarsAway(JD)
@ -145,3 +164,293 @@ func MarsMag(JD float64) float64 {
Mag := -1.52 + 5*math.Log10(AwaySun*AwayEarth) + 0.016*i Mag := -1.52 + 5*math.Log10(AwaySun*AwayEarth) + 0.016*i
return FloatRound(Mag, 2) return FloatRound(Mag, 2)
} }
func MarsHeight(jde, lon, lat, timezone float64) float64 {
// 转换为世界时
utcJde := jde - timezone/24.0
// 计算视恒星时
ra, dec := MarsApparentRaDec(TD2UT(utcJde, true))
st := Limit360(ApparentSiderealTime(utcJde)*15 + lon)
// 计算时角
H := Limit360(st - ra)
// 高度角、时角与天球座标三角转换公式
// sin(h)=sin(lat)*sin(dec)+cos(dec)*cos(lat)*cos(H)
sinHeight := Sin(lat)*Sin(dec) + Cos(dec)*Cos(lat)*Cos(H)
return ArcSin(sinHeight)
}
func MarsAzimuth(jde, lon, lat, timezone float64) float64 {
// 转换为世界时
utcJde := jde - timezone/24.0
// 计算视恒星时
ra, dec := MarsApparentRaDec(TD2UT(utcJde, true))
st := Limit360(ApparentSiderealTime(utcJde)*15 + lon)
// 计算时角
H := Limit360(st - ra)
// 三角转换公式
tanAzimuth := Sin(H) / (Cos(H)*Sin(lat) - Tan(dec)*Cos(lat))
Azimuth := ArcTan(tanAzimuth)
if Azimuth < 0 {
if H/15 < 12 {
return Azimuth + 360
}
return Azimuth + 180
}
if H/15 < 12 {
return Azimuth + 180
}
return Azimuth
}
func MarsHourAngle(JD, Lon, TZ float64) float64 {
startime := Limit360(ApparentSiderealTime(JD-TZ/24)*15 + Lon)
timeangle := startime - MarsApparentRa(TD2UT(JD-TZ/24.0, true))
if timeangle < 0 {
timeangle += 360
}
return timeangle
}
func MarsCulminationTime(jde, lon, timezone float64) float64 {
//jde 世界时,非力学时,当地时区 0时无需转换力学时
//ra,dec 瞬时天球座标非J2000等时间天球坐标
jde = math.Floor(jde) + 0.5
JD1 := jde + Limit360(360-MarsHourAngle(jde, lon, timezone))/15.0/24.0*0.99726851851851851851
limitHA := func(jde, lon, timezone float64) float64 {
ha := MarsHourAngle(jde, lon, timezone)
if ha < 180 {
ha += 360
}
return ha
}
for {
JD0 := JD1
stDegree := limitHA(JD0, lon, timezone) - 360
stDegreep := (limitHA(JD0+0.000005, lon, timezone) - limitHA(JD0-0.000005, lon, timezone)) / 0.00001
JD1 = JD0 - stDegree/stDegreep
if math.Abs(JD1-JD0) <= 0.00001 {
break
}
}
return JD1
}
func MarsRiseTime(JD, Lon, Lat, TZ, ZS, HEI float64) float64 {
return marsRiseDown(JD, Lon, Lat, TZ, ZS, HEI, true)
}
func MarsDownTime(JD, Lon, Lat, TZ, ZS, HEI float64) float64 {
return marsRiseDown(JD, Lon, Lat, TZ, ZS, HEI, false)
}
func marsRiseDown(JD, Lon, Lat, TZ, ZS, HEI float64, isRise bool) float64 {
var An float64
JD = math.Floor(JD) + 0.5
ntz := math.Round(Lon / 15)
if ZS != 0 {
An = -0.8333
}
An = An - HeightDegreeByLat(HEI, Lat)
tztime := MarsCulminationTime(JD, Lon, ntz)
if MarsHeight(tztime, Lon, Lat, ntz) < An {
return -2 //极夜
}
if MarsHeight(tztime-0.5, Lon, Lat, ntz) > An {
return -1 //极昼
}
dec := HSunApparentDec(TD2UT(tztime-ntz/24, true))
//(sin(ho)-sin(φ)*sin(δ2))/(cos(φ)*cos(δ2))
tmp := (Sin(An) - Sin(dec)*Sin(Lat)) / (Cos(dec) * Cos(Lat))
var rise float64
if math.Abs(tmp) <= 1 {
rzsc := ArcCos(tmp) / 15
if isRise {
rise = tztime - rzsc/24 - 25.0/24.0/60.0
} else {
rise = tztime + rzsc/24 - 25.0/24.0/60.0
}
} else {
rise = tztime
i := 0
//TODO:使用二分法计算
for MarsHeight(rise, Lon, Lat, ntz) > An {
i++
if isRise {
rise -= 15.0 / 60.0 / 24.0
} else {
rise += 15.0 / 60.0 / 24.0
}
if i > 48 {
break
}
}
}
JD1 := rise
for {
JD0 := JD1
stDegree := MarsHeight(JD0, Lon, Lat, ntz) - An
stDegreep := (MarsHeight(JD0+0.000005, Lon, Lat, ntz) - MarsHeight(JD0-0.000005, Lon, Lat, ntz)) / 0.00001
JD1 = JD0 - stDegree/stDegreep
if math.Abs(JD1-JD0) <= 0.00001 {
break
}
}
return JD1 - ntz/24 + TZ/24
}
// Pos
const MARS_S_PERIOD = 1 / ((1 / 365.256363004) - (1 / 686.98))
func marsConjunction(jde, degree float64, next uint8) float64 {
//0=last 1=next
decSub := func(jde float64, degree float64, filter bool) float64 {
sub := Limit360(Limit360(MarsApparentLo(jde)-HSunApparentLo(jde)) - degree)
if filter {
if sub > 180 {
sub -= 360
}
if sub < -180 {
sub += 360
}
}
return sub
}
dayCost := MARS_S_PERIOD / 360
nowSub := decSub(jde, degree, false)
if next == 0 {
jde -= (360 - nowSub) * dayCost
} else {
jde += dayCost * nowSub
}
JD1 := jde
for {
JD0 := JD1
stDegree := decSub(JD0, degree, true)
stDegreep := (decSub(JD0+0.000005, degree, true) - decSub(JD0-0.000005, degree, true)) / 0.00001
JD1 = JD0 - stDegree/stDegreep
if math.Abs(JD1-JD0) <= 0.00001 {
break
}
}
return TD2UT(JD1, false)
}
func LastMarsConjunction(jde float64) float64 {
return marsConjunction(jde, 0, 0)
}
func NextMarsConjunction(jde float64) float64 {
return marsConjunction(jde, 0, 1)
}
func LastMarsOpposition(jde float64) float64 {
return marsConjunction(jde, 180, 0)
}
func NextMarsOpposition(jde float64) float64 {
return marsConjunction(jde, 180, 1)
}
func NextMarsEasternQuadrature(jde float64) float64 {
return marsConjunction(jde, 90, 1)
}
func LastMarsEasternQuadrature(jde float64) float64 {
return marsConjunction(jde, 90, 0)
}
func NextMarsWesternQuadrature(jde float64) float64 {
return marsConjunction(jde, 270, 1)
}
func LastMarsWesternQuadrature(jde float64) float64 {
return marsConjunction(jde, 270, 0)
}
func marsRetrograde(jde float64, isLeft bool) float64 {
//0=last 1=next
decSub := func(jde float64, val float64) float64 {
sub := MarsApparentRa(jde+val) - MarsApparentRa(jde-val)
if sub > 180 {
sub -= 360
}
if sub < -180 {
sub += 360
}
return sub / (2 * val)
}
jde = NextMarsOpposition(jde)
if isLeft {
jde -= 60
} else {
jde += 60
}
for {
nowSub := decSub(jde, 1.0/86400.0)
if math.Abs(nowSub) > 0.55 {
jde += 2
continue
}
break
}
JD1 := jde
for {
JD0 := JD1
stDegree := decSub(JD0, 2.0/86400.0)
stDegreep := (decSub(JD0+15.0/86400.0, 2.0/86400.0) - decSub(JD0-15.0/86400.0, 2.0/86400.0)) / (30.0 / 86400.0)
JD1 = JD0 - stDegree/stDegreep
if math.Abs(JD1-JD0) <= 30.0/86400.0 {
break
}
}
JD1 = JD1 - 15.0/86400.0
min := JD1
minRa := 100.0
for i := 0.0; i < 60.0; i++ {
tmp := decSub(JD1+i*0.5/86400.0, 0.5/86400.0)
if math.Abs(tmp) < math.Abs(minRa) {
minRa = tmp
min = JD1 + i*0.5/86400.0
}
}
return TD2UT(min, false)
}
func NextMarsRetrogradeToPrograde(jde float64) float64 {
date := marsRetrograde(jde, false)
if date < jde {
op := NextMarsOpposition(jde)
return marsRetrograde(op+10, false)
}
return date
}
func LastMarsRetrogradeToPrograde(jde float64) float64 {
jde = LastMarsOpposition(jde) - 10
date := marsRetrograde(jde, false)
if date > jde {
op := LastMarsOpposition(jde)
return marsRetrograde(op-10, false)
}
return date
}
func NextMarsProgradeToRetrograde(jde float64) float64 {
date := marsRetrograde(jde, true)
if date < jde {
op := NextMarsOpposition(jde)
return marsRetrograde(op+10, true)
}
return date
}
func LastMarsProgradeToRetrograde(jde float64) float64 {
jde = LastMarsOpposition(jde) - 10
date := marsRetrograde(jde, true)
if date > jde {
op := LastMarsOpposition(jde)
return marsRetrograde(op-10, true)
}
return date
}

@ -0,0 +1,21 @@
package basic
import (
"fmt"
"testing"
)
func TestMars(t *testing.T) {
jde := GetNowJDE() - 6000
/*
fmt.Println(JDE2Date(VenusCulminationTime(jde, 115, 8)))
fmt.Println(JDE2Date(VenusRiseTime(jde, 115, 23, 8, 0, 0)))
fmt.Println(JDE2Date(VenusDownTime(jde, 115, 23, 8, 0, 0)))
fmt.Println("----------------")
*/
//LastVenusConjunction(2.4596600340162036e+06)
//fmt.Println(2.4590359532407406e+06, JDE2Date(2.4590359532407406e+06), JDE2Date(NextVenusRetrograde(2.4590359532407406e+06)))
for i := 0.00; i < 1; i++ {
fmt.Println(jde+i*740, JDE2Date(jde+i*740), JDE2Date(LastMarsProgradeToRetrograde(jde+i*740)))
}
}

@ -63,27 +63,20 @@ func AMercuryXYZ(JD float64) (float64, float64, float64) {
return x, y, z return x, y, z
} }
func MercurySeeRa(JD float64) float64 { func MercuryApparentRa(JD float64) float64 {
lo, bo := MercurySeeLoBo(JD) lo, bo := MercuryApparentLoBo(JD)
sita := Sita(JD) return LoToRa(JD, lo, bo)
ra := math.Atan2((Sin(lo)*Cos(sita) - Tan(bo)*Sin(sita)), Cos(lo))
ra = ra * 180 / math.Pi
return Limit360(ra)
} }
func MercurySeeDec(JD float64) float64 { func MercuryApparentDec(JD float64) float64 {
lo, bo := MercurySeeLoBo(JD) lo, bo := MercuryApparentLoBo(JD)
sita := Sita(JD) sita := Sita(JD)
dec := ArcSin(Sin(bo)*Cos(sita) + Cos(bo)*Sin(sita)*Sin(lo)) dec := ArcSin(Sin(bo)*Cos(sita) + Cos(bo)*Sin(sita)*Sin(lo))
return dec return dec
} }
func MercurySeeRaDec(JD float64) (float64, float64) { func MercuryApparentRaDec(JD float64) (float64, float64) {
lo, bo := MercurySeeLoBo(JD) lo, bo := MercuryApparentLoBo(JD)
sita := Sita(JD) return LoBoToRaDec(JD, lo, bo)
ra := math.Atan2((Sin(lo)*Cos(sita) - Tan(bo)*Sin(sita)), Cos(lo))
ra = ra * 180 / math.Pi
dec := ArcSin(Sin(bo)*Cos(sita) + Cos(bo)*Sin(sita)*Sin(lo))
return Limit360(ra), dec
} }
func EarthMercuryAway(JD float64) float64 { func EarthMercuryAway(JD float64) float64 {
@ -92,7 +85,7 @@ func EarthMercuryAway(JD float64) float64 {
return to return to
} }
func MercurySeeLo(JD float64) float64 { func MercuryApparentLo(JD float64) float64 {
x, y, z := AMercuryXYZ(JD) x, y, z := AMercuryXYZ(JD)
to := 0.0057755183 * math.Sqrt(x*x+y*y+z*z) to := 0.0057755183 * math.Sqrt(x*x+y*y+z*z)
x, y, z = AMercuryXYZ(JD - to) x, y, z = AMercuryXYZ(JD - to)
@ -107,7 +100,7 @@ func MercurySeeLo(JD float64) float64 {
return lo return lo
} }
func MercurySeeBo(JD float64) float64 { func MercuryApparentBo(JD float64) float64 {
x, y, z := AMercuryXYZ(JD) x, y, z := AMercuryXYZ(JD)
to := 0.0057755183 * math.Sqrt(x*x+y*y+z*z) to := 0.0057755183 * math.Sqrt(x*x+y*y+z*z)
x, y, z = AMercuryXYZ(JD - to) x, y, z = AMercuryXYZ(JD - to)
@ -121,7 +114,7 @@ func MercurySeeBo(JD float64) float64 {
return bo return bo
} }
func MercurySeeLoBo(JD float64) (float64, float64) { func MercuryApparentLoBo(JD float64) (float64, float64) {
x, y, z := AMercuryXYZ(JD) x, y, z := AMercuryXYZ(JD)
to := 0.0057755183 * math.Sqrt(x*x+y*y+z*z) to := 0.0057755183 * math.Sqrt(x*x+y*y+z*z)
x, y, z = AMercuryXYZ(JD - to) x, y, z = AMercuryXYZ(JD - to)
@ -129,10 +122,9 @@ func MercurySeeLoBo(JD float64) (float64, float64) {
bo := math.Atan2(z, math.Sqrt(x*x+y*y)) bo := math.Atan2(z, math.Sqrt(x*x+y*y))
lo = lo * 180 / math.Pi lo = lo * 180 / math.Pi
bo = bo * 180 / math.Pi bo = bo * 180 / math.Pi
lo = Limit360(lo) lo = Limit360(lo) + HJZD(JD)
//lo-=GXCLo(lo,bo,JD)/3600; //lo-=GXCLo(lo,bo,JD)/3600;
//bo+=GXCBo(lo,bo,JD); //bo+=GXCBo(lo,bo,JD);
lo += HJZD(JD)
return lo, bo return lo, bo
} }
@ -145,3 +137,472 @@ func MercuryMag(JD float64) float64 {
Mag := -0.42 + 5*math.Log10(AwaySun*AwayEarth) + 0.0380*i - 0.000273*i*i + 0.000002*i*i*i Mag := -0.42 + 5*math.Log10(AwaySun*AwayEarth) + 0.0380*i - 0.000273*i*i + 0.000002*i*i*i
return FloatRound(Mag, 2) return FloatRound(Mag, 2)
} }
func MercuryHeight(jde, lon, lat, timezone float64) float64 {
// 转换为世界时
utcJde := jde - timezone/24.0
// 计算视恒星时
ra, dec := MercuryApparentRaDec(TD2UT(utcJde, true))
st := Limit360(ApparentSiderealTime(utcJde)*15 + lon)
// 计算时角
H := Limit360(st - ra)
// 高度角、时角与天球座标三角转换公式
// sin(h)=sin(lat)*sin(dec)+cos(dec)*cos(lat)*cos(H)
sinHeight := Sin(lat)*Sin(dec) + Cos(dec)*Cos(lat)*Cos(H)
return ArcSin(sinHeight)
}
func MercuryAzimuth(jde, lon, lat, timezone float64) float64 {
// 转换为世界时
utcJde := jde - timezone/24.0
// 计算视恒星时
ra, dec := MercuryApparentRaDec(TD2UT(utcJde, true))
st := Limit360(ApparentSiderealTime(utcJde)*15 + lon)
// 计算时角
H := Limit360(st - ra)
// 三角转换公式
tanAzimuth := Sin(H) / (Cos(H)*Sin(lat) - Tan(dec)*Cos(lat))
Azimuth := ArcTan(tanAzimuth)
if Azimuth < 0 {
if H/15 < 12 {
return Azimuth + 360
}
return Azimuth + 180
}
if H/15 < 12 {
return Azimuth + 180
}
return Azimuth
}
func MercuryHourAngle(JD, Lon, TZ float64) float64 {
startime := Limit360(ApparentSiderealTime(JD-TZ/24)*15 + Lon)
timeangle := startime - MercuryApparentRa(TD2UT(JD-TZ/24.0, true))
if timeangle < 0 {
timeangle += 360
}
return timeangle
}
func MercuryCulminationTime(jde, lon, timezone float64) float64 {
//jde 世界时,非力学时,当地时区 0时无需转换力学时
//ra,dec 瞬时天球座标非J2000等时间天球坐标
jde = math.Floor(jde) + 0.5
JD1 := jde + Limit360(360-MercuryHourAngle(jde, lon, timezone))/15.0/24.0*0.99726851851851851851
limitHA := func(jde, lon, timezone float64) float64 {
ha := MercuryHourAngle(jde, lon, timezone)
if ha < 180 {
ha += 360
}
return ha
}
for {
JD0 := JD1
stDegree := limitHA(JD0, lon, timezone) - 360
stDegreep := (limitHA(JD0+0.000005, lon, timezone) - limitHA(JD0-0.000005, lon, timezone)) / 0.00001
JD1 = JD0 - stDegree/stDegreep
if math.Abs(JD1-JD0) <= 0.00001 {
break
}
}
return JD1
}
func MercuryRiseTime(JD, Lon, Lat, TZ, ZS, HEI float64) float64 {
return mercuryRiseDown(JD, Lon, Lat, TZ, ZS, HEI, true)
}
func MercuryDownTime(JD, Lon, Lat, TZ, ZS, HEI float64) float64 {
return mercuryRiseDown(JD, Lon, Lat, TZ, ZS, HEI, false)
}
func mercuryRiseDown(JD, Lon, Lat, TZ, ZS, HEI float64, isRise bool) float64 {
var An float64
JD = math.Floor(JD) + 0.5
ntz := math.Round(Lon / 15)
if ZS != 0 {
An = -0.8333
}
An = An - HeightDegreeByLat(HEI, Lat)
tztime := MercuryCulminationTime(JD, Lon, ntz)
if MercuryHeight(tztime, Lon, Lat, ntz) < An {
return -2 //极夜
}
if MercuryHeight(tztime-0.5, Lon, Lat, ntz) > An {
return -1 //极昼
}
dec := HSunApparentDec(TD2UT(tztime-ntz/24, true))
//(sin(ho)-sin(φ)*sin(δ2))/(cos(φ)*cos(δ2))
tmp := (Sin(An) - Sin(dec)*Sin(Lat)) / (Cos(dec) * Cos(Lat))
var rise float64
if math.Abs(tmp) <= 1 {
rzsc := ArcCos(tmp) / 15
if isRise {
rise = tztime - rzsc/24 - 25.0/24.0/60.0
} else {
rise = tztime + rzsc/24 - 25.0/24.0/60.0
}
} else {
rise = tztime
i := 0
//TODO:使用二分法计算
for MercuryHeight(rise, Lon, Lat, ntz) > An {
i++
if isRise {
rise -= 15.0 / 60.0 / 24.0
} else {
rise += 15.0 / 60.0 / 24.0
}
if i > 48 {
break
}
}
}
JD1 := rise
for {
JD0 := JD1
stDegree := MercuryHeight(JD0, Lon, Lat, ntz) - An
stDegreep := (MercuryHeight(JD0+0.000005, Lon, Lat, ntz) - MercuryHeight(JD0-0.000005, Lon, Lat, ntz)) / 0.00001
JD1 = JD0 - stDegree/stDegreep
if math.Abs(JD1-JD0) <= 0.00001 {
break
}
}
return JD1 - ntz/24 + TZ/24
}
// Pos
const MERCURY_S_PERIOD = 1 / ((1 / 87.9691) - (1 / 365.256363004))
func mercuryConjunction(jde float64, next uint8) float64 {
//0=last 1=next
decSub := func(jde float64) float64 {
sub := Limit360(MercuryApparentLo(jde) - HSunApparentLo(jde))
if sub > 180 {
sub -= 360
}
if sub < -180 {
sub += 360
}
return sub
}
nowSub := decSub(jde)
// pos 大于0:远离太阳 小于0:靠近太阳
pos := math.Abs(decSub(jde+1/86400.0)) - math.Abs(nowSub)
if pos >= 0 && next == 1 && nowSub > 0 {
jde += MERCURY_S_PERIOD/8.0 + 2
}
if pos >= 0 && next == 1 && nowSub < 0 {
jde += MERCURY_S_PERIOD/6.0 + 2
}
if pos <= 0 && next == 0 && nowSub < 0 {
jde -= MERCURY_S_PERIOD/8.0 + 2
}
if pos <= 0 && next == 0 && nowSub > 0 {
jde -= MERCURY_S_PERIOD/6.0 + 2
}
for {
nowSub := decSub(jde)
pos := math.Abs(decSub(jde+1/86400.0)) - math.Abs(nowSub)
if math.Abs(nowSub) > 12 || (pos > 0 && next == 1) || (pos < 0 && next == 0) {
if next == 1 {
jde += 2
} else {
jde -= 2
}
continue
}
break
}
JD1 := jde
for {
JD0 := JD1
stDegree := decSub(JD0)
stDegreep := (decSub(JD0+0.000005) - decSub(JD0-0.000005)) / 0.00001
JD1 = JD0 - stDegree/stDegreep
if math.Abs(JD1-JD0) <= 0.00001 {
break
}
}
return TD2UT(JD1, false)
}
func LastMercuryConjunction(jde float64) float64 {
return mercuryConjunction(jde, 0)
}
func NextMercuryConjunction(jde float64) float64 {
return mercuryConjunction(jde, 1)
}
func NextMercuryInferiorConjunction(jde float64) float64 {
date := NextMercuryConjunction(jde)
if EarthMercuryAway(date) > EarthAway(date) {
return NextMercuryConjunction(date + 2)
}
return date
}
func NextMercurySuperiorConjunction(jde float64) float64 {
date := NextMercuryConjunction(jde)
if EarthMercuryAway(date) < EarthAway(date) {
return NextMercuryConjunction(date + 2)
}
return date
}
func LastMercuryInferiorConjunction(jde float64) float64 {
date := LastMercuryConjunction(jde)
if EarthMercuryAway(date) > EarthAway(date) {
return LastMercuryConjunction(date - 2)
}
return date
}
func LastMercurySuperiorConjunction(jde float64) float64 {
date := LastMercuryConjunction(jde)
if EarthMercuryAway(date) < EarthAway(date) {
return LastMercuryConjunction(date - 2)
}
return date
}
func mercuryRetrograde(jde float64) float64 {
//0=last 1=next
decSunSub := func(jde float64) float64 {
sub := Limit360(MercuryApparentRa(jde) - SunApparentRa(jde))
if sub > 180 {
sub -= 360
}
if sub < -180 {
sub += 360
}
return sub
}
decSub := func(jde float64, val float64) float64 {
sub := MercuryApparentRa(jde+val) - MercuryApparentRa(jde-val)
if sub > 180 {
sub -= 360
}
if sub < -180 {
sub += 360
}
return sub / (2 * val)
}
lastHe := LastMercuryConjunction(jde)
nextHe := NextMercuryConjunction(jde)
nowSub := decSunSub(jde)
if nowSub > 0 {
jde = lastHe + ((nextHe - lastHe) / 5.0 * 3.5)
} else {
jde = lastHe + ((nextHe - lastHe) / 5.5)
}
for {
nowSub := decSub(jde, 1.0/86400.0)
if math.Abs(nowSub) > 0.55 {
jde += 2
continue
}
break
}
JD1 := jde
for {
JD0 := JD1
stDegree := decSub(JD0, 2.0/86400.0)
stDegreep := (decSub(JD0+15.0/86400.0, 2.0/86400.0) - decSub(JD0-15.0/86400.0, 2.0/86400.0)) / (30.0 / 86400.0)
JD1 = JD0 - stDegree/stDegreep
if math.Abs(JD1-JD0) <= 30.0/86400.0 {
break
}
}
JD1 = JD1 - 15.0/86400.0
min := JD1
minRa := 100.0
for i := 0.0; i < 60.0; i++ {
tmp := decSub(JD1+i*0.5/86400.0, 0.5/86400.0)
if math.Abs(tmp) < math.Abs(minRa) {
minRa = tmp
min = JD1 + i*0.5/86400.0
}
}
//fmt.Println((min - lastHe) / (nextHe - lastHe))
return TD2UT(min, false)
}
func NextMercuryRetrograde(jde float64) float64 {
date := mercuryRetrograde(jde)
if date < jde {
nextHe := NextMercuryConjunction(jde)
return mercuryRetrograde(nextHe + 2)
}
return date
}
func LastMercuryRetrograde(jde float64) float64 {
lastHe := LastMercuryConjunction(jde)
date := mercuryRetrograde(lastHe + 2)
if date > jde {
lastLastHe := LastMercuryConjunction(lastHe - 2)
return mercuryRetrograde(lastLastHe + 2)
}
return date
}
func NextMercuryProgradeToRetrograde(jde float64) float64 {
date := NextMercuryRetrograde(jde)
sub := Limit360(MercuryApparentRa(date) - SunApparentRa(date))
if sub > 180 {
return NextMercuryRetrograde(date + MERCURY_S_PERIOD/2)
}
return date
}
func NextMercuryRetrogradeToPrograde(jde float64) float64 {
date := NextMercuryRetrograde(jde)
sub := Limit360(MercuryApparentRa(date) - SunApparentRa(date))
if sub < 180 {
return NextMercuryRetrograde(date + 12)
}
return date
}
func LastMercuryProgradeToRetrograde(jde float64) float64 {
date := LastMercuryRetrograde(jde)
sub := Limit360(MercuryApparentRa(date) - SunApparentRa(date))
if sub > 180 {
return LastMercuryRetrograde(date - 12)
}
return date
}
func LastMercuryRetrogradeToPrograde(jde float64) float64 {
date := LastMercuryRetrograde(jde)
sub := Limit360(MercuryApparentRa(date) - SunApparentRa(date))
if sub < 180 {
return LastMercuryRetrograde(date - MERCURY_S_PERIOD/2)
}
return date
}
func MercurySunElongation(jde float64) float64 {
lo1, bo1 := MercuryApparentLoBo(jde)
lo2 := SunApparentLo(jde)
bo2 := HSunTrueBo(jde)
return StarAngularSeparation(lo1, bo1, lo2, bo2)
}
func mercuryGreatestElongation(jde float64) float64 {
decSunSub := func(jde float64) float64 {
sub := Limit360(MercuryApparentRa(jde) - SunApparentRa(jde))
if sub > 180 {
sub -= 360
}
if sub < -180 {
sub += 360
}
return sub
}
decSub := func(jde float64, val float64) float64 {
sub := MercurySunElongation(jde+val) - MercurySunElongation(jde-val)
if sub > 180 {
sub -= 360
}
if sub < -180 {
sub += 360
}
return sub / (2 * val)
}
lastHe := LastMercuryConjunction(jde)
nextHe := NextMercuryConjunction(jde)
nowSub := decSunSub(jde)
if nowSub > 0 {
jde = lastHe + ((nextHe - lastHe) / 5.0 * 2.0)
} else {
jde = lastHe + ((nextHe - lastHe) / 6.0)
}
for {
nowSub := decSub(jde, 1.0/86400.0)
if math.Abs(nowSub) > 0.4 {
jde += 2
continue
}
break
}
JD1 := jde
for {
JD0 := JD1
stDegree := decSub(JD0, 2.0/86400.0)
stDegreep := (decSub(JD0+15.0/86400.0, 2.0/86400.0) - decSub(JD0-15.0/86400.0, 2.0/86400.0)) / (30.0 / 86400.0)
JD1 = JD0 - stDegree/stDegreep
if math.Abs(JD1-JD0) <= 30.0/86400.0 {
break
}
}
JD1 = JD1 - 15.0/86400.0
min := JD1
minRa := 100.0
for i := 0.0; i < 60.0; i++ {
tmp := decSub(JD1+i*0.5/86400.0, 0.5/86400.0)
if math.Abs(tmp) < math.Abs(minRa) {
minRa = tmp
min = JD1 + i*0.5/86400.0
}
}
//fmt.Println((min - lastHe) / (nextHe - lastHe))
return TD2UT(min, false)
}
func NextMercuryGreatestElongation(jde float64) float64 {
date := mercuryGreatestElongation(jde)
if date < jde {
nextHe := NextMercuryConjunction(jde)
return mercuryGreatestElongation(nextHe + 2)
}
return date
}
func LastMercuryGreatestElongation(jde float64) float64 {
lastHe := LastMercuryConjunction(jde)
date := mercuryGreatestElongation(lastHe + 2)
if date > jde {
lastLastHe := LastMercuryConjunction(lastHe - 2)
return mercuryGreatestElongation(lastLastHe + 2)
}
return date
}
func NextMercuryGreatestElongationEast(jde float64) float64 {
date := NextMercuryGreatestElongation(jde)
sub := Limit360(MercuryApparentRa(date) - SunApparentRa(date))
if sub > 180 {
return NextMercuryGreatestElongation(date + 1)
}
return date
}
func NextMercuryGreatestElongationWest(jde float64) float64 {
date := NextMercuryGreatestElongation(jde)
sub := Limit360(MercuryApparentRa(date) - SunApparentRa(date))
if sub < 180 {
return NextMercuryGreatestElongation(date + 1)
}
return date
}
func LastMercuryGreatestElongationEast(jde float64) float64 {
date := LastMercuryGreatestElongation(jde)
sub := Limit360(MercuryApparentRa(date) - SunApparentRa(date))
if sub > 180 {
return LastMercuryGreatestElongation(date - 1)
}
return date
}
func LastMercuryGreatestElongationWest(jde float64) float64 {
date := LastMercuryGreatestElongation(jde)
sub := Limit360(MercuryApparentRa(date) - SunApparentRa(date))
if sub < 180 {
return LastMercuryGreatestElongation(date - 1)
}
return date
}

@ -0,0 +1,16 @@
package basic
import (
"fmt"
"testing"
)
func TestMercury(t *testing.T) {
jde := GetNowJDE()
fmt.Println(2.459941309513889e+06, JDE2Date(2.459941309513889e+06), JDE2Date(8.0/24.0+LastMercuryGreatestElongation(2.459941309513889e+06)))
fmt.Println("-------------for------------")
for i := 0.00; i < 700.0; i += 5 {
fmt.Println(jde+i, JDE2Date(jde+i), JDE2Date(8.0/24.0+LastMercuryGreatestElongationWest(jde+i)))
// fmt.Println("")
}
}

@ -1052,18 +1052,7 @@ func MoonTrueDec(JD float64) float64 {
* *
*/ */
func MoonTrueRa(JD float64) float64 { func MoonTrueRa(JD float64) float64 {
MoonLo := MoonApparentLo(JD) return LoToRa(JD, MoonApparentLo(JD), MoonTrueBo(JD))
MoonBo := MoonTrueBo(JD)
tmp := (Sin(MoonLo)*Cos(Sita(JD)) - Tan(MoonBo)*Sin(Sita(JD))) / Cos(MoonLo)
tmp = ArcTan(tmp)
if MoonLo >= 90 && MoonLo < 180 {
tmp = 180 + tmp
} else if MoonLo >= 180 && MoonLo < 270 {
tmp = 180 + tmp
} else if MoonLo >= 270 && MoonLo <= 360 {
tmp = 360 + tmp
}
return tmp
} }
/** /**
@ -1382,6 +1371,7 @@ func HMoonHeight(JD, Lon, Lat, TZ float64) float64 {
return ArcSin(tmp2) return ArcSin(tmp2)
} }
// 废弃
func GetMoonTZTime(JD, Lon, Lat, TZ float64) float64 { //实际中天时间{ func GetMoonTZTime(JD, Lon, Lat, TZ float64) float64 { //实际中天时间{
JD = math.Floor(JD) + 0.5 JD = math.Floor(JD) + 0.5
ttm := MoonTimeAngle(JD, Lon, Lat, TZ) ttm := MoonTimeAngle(JD, Lon, Lat, TZ)
@ -1401,9 +1391,33 @@ func GetMoonTZTime(JD, Lon, Lat, TZ float64) float64 { //实际中天时间{
return JD1 return JD1
} }
func MoonCulminationTime(jde, lon, lat, timezone float64) float64 {
//jde 世界时,非力学时,当地时区 0时无需转换力学时
//ra,dec 瞬时天球座标非J2000等时间天球坐标
jde = math.Floor(jde) + 0.5
JD1 := jde + Limit360(360-MoonTimeAngle(jde, lon, lat, timezone))/15.0/24.0/0.9
limitHA := func(jde, lon, timezone float64) float64 {
ha := MoonTimeAngle(jde, lon, lat, timezone)
if ha < 180 {
ha += 360
}
return ha
}
for {
JD0 := JD1
stDegree := limitHA(JD0, lon, timezone) - 360
stDegreep := (limitHA(JD0+0.000005, lon, timezone) - limitHA(JD0-0.000005, lon, timezone)) / 0.00001
JD1 = JD0 - stDegree/stDegreep
if math.Abs(JD1-JD0) <= 0.00001 {
break
}
}
return JD1
}
func MoonTimeAngle(JD, Lon, Lat, TZ float64) float64 { func MoonTimeAngle(JD, Lon, Lat, TZ float64) float64 {
startime := Limit360(ApparentSiderealTime(JD-TZ/24)*15 + Lon) startime := Limit360(ApparentSiderealTime(JD-TZ/24)*15 + Lon)
timeangle := startime - HMoonApparentRa(JD-TZ/24, Lon, Lat, TZ) timeangle := startime - HMoonApparentRa(JD, Lon, Lat, TZ)
if timeangle < 0 { if timeangle < 0 {
timeangle += 360 timeangle += 360
} }
@ -1667,20 +1681,7 @@ func HMoonApparentLo(JD float64) float64 {
} }
func HMoonTrueRaDec(JD float64) (float64, float64) { func HMoonTrueRaDec(JD float64) (float64, float64) {
MoonLo := HMoonApparentLo(JD) return LoBoToRaDec(JD, HMoonApparentLo(JD), HMoonTrueBo(JD))
MoonBo := HMoonTrueBo(JD)
tmp := Sin(MoonBo)*Cos(Sita(JD)) + Cos(MoonBo)*Sin(Sita(JD))*Sin(MoonLo)
res := ArcSin(tmp)
tmp = (Sin(MoonLo)*Cos(Sita(JD)) - Tan(MoonBo)*Sin(Sita(JD))) / Cos(MoonLo)
tmp = ArcTan(tmp)
if MoonLo >= 90 && MoonLo < 180 {
tmp = 180 + tmp
} else if MoonLo >= 180 && MoonLo < 270 {
tmp = 180 + tmp
} else if MoonLo >= 270 && MoonLo <= 360 {
tmp = 360 + tmp
}
return tmp, res
} }
/* /*
@ -1698,18 +1699,7 @@ func HMoonTrueDec(JD float64) float64 {
* *
*/ */
func HMoonTrueRa(JD float64) float64 { func HMoonTrueRa(JD float64) float64 {
MoonLo := HMoonApparentLo(JD) return LoToRa(JD, HMoonApparentLo(JD), HMoonTrueBo(JD))
MoonBo := HMoonTrueBo(JD)
tmp := (Sin(MoonLo)*Cos(Sita(JD)) - Tan(MoonBo)*Sin(Sita(JD))) / Cos(MoonLo)
tmp = ArcTan(tmp)
if MoonLo >= 90 && MoonLo < 180 {
tmp = 180 + tmp
} else if MoonLo >= 180 && MoonLo < 270 {
tmp = 180 + tmp
} else if MoonLo >= 270 && MoonLo <= 360 {
tmp = 360 + tmp
}
return tmp
} }
/** /**

@ -2,6 +2,7 @@ package basic
import ( import (
"fmt" "fmt"
"math"
"testing" "testing"
"time" "time"
) )
@ -45,3 +46,16 @@ func Test_MoonS(t *testing.T) {
fmt.Println(time.Now().UnixNano() - a) fmt.Println(time.Now().UnixNano() - a)
//fmt.Printf("%.14f", GetMoonRiseTime(2451547, 115, 32, 8, 0)) //fmt.Printf("%.14f", GetMoonRiseTime(2451547, 115, 32, 8, 0))
} }
func TestMoonCu(t *testing.T) {
jde := math.Floor(GetNowJDE() - 20.0/24.0)
n := MoonCulminationTime(jde, 115, 23, 8)
fmt.Println(JDE2Date(n))
fmt.Println(MoonTimeAngle(n, 115, 23, 8))
fmt.Println(MoonAngle(n, 115, 23, 8))
//fmt.Println(JDE2Date(jde))
//ra, dec := HMoonApparentRaDec(jde, 115, 23, 8)
//fmt.Println(tools.Format(ra/15, 1), tools.Format(dec, 0))
//fmt.Println(JDE2Date(GetMoonTZTime(jde, 115, 23, 8)))
//fmt.Println(JDE2Date(GetMoonDownTime(jde+1, 115, 23, 8, 1, 0)))
}

@ -63,22 +63,22 @@ func ANeptuneXYZ(JD float64) (float64, float64, float64) {
return x, y, z return x, y, z
} }
func NeptuneSeeRa(JD float64) float64 { func NeptuneApparentRa(JD float64) float64 {
lo, bo := NeptuneSeeLoBo(JD) lo, bo := NeptuneApparentLoBo(JD)
sita := Sita(JD) sita := Sita(JD)
ra := math.Atan2((Sin(lo)*Cos(sita) - Tan(bo)*Sin(sita)), Cos(lo)) ra := math.Atan2((Sin(lo)*Cos(sita) - Tan(bo)*Sin(sita)), Cos(lo))
ra = ra * 180 / math.Pi ra = ra * 180 / math.Pi
return Limit360(ra) return Limit360(ra)
} }
func NeptuneSeeDec(JD float64) float64 { func NeptuneApparentDec(JD float64) float64 {
lo, bo := NeptuneSeeLoBo(JD) lo, bo := NeptuneApparentLoBo(JD)
sita := Sita(JD) sita := Sita(JD)
dec := ArcSin(Sin(bo)*Cos(sita) + Cos(bo)*Sin(sita)*Sin(lo)) dec := ArcSin(Sin(bo)*Cos(sita) + Cos(bo)*Sin(sita)*Sin(lo))
return dec return dec
} }
func NeptuneSeeRaDec(JD float64) (float64, float64) { func NeptuneApparentRaDec(JD float64) (float64, float64) {
lo, bo := NeptuneSeeLoBo(JD) lo, bo := NeptuneApparentLoBo(JD)
sita := Sita(JD) sita := Sita(JD)
ra := math.Atan2((Sin(lo)*Cos(sita) - Tan(bo)*Sin(sita)), Cos(lo)) ra := math.Atan2((Sin(lo)*Cos(sita) - Tan(bo)*Sin(sita)), Cos(lo))
ra = ra * 180 / math.Pi ra = ra * 180 / math.Pi
@ -92,7 +92,7 @@ func EarthNeptuneAway(JD float64) float64 {
return to return to
} }
func NeptuneSeeLo(JD float64) float64 { func NeptuneApparentLo(JD float64) float64 {
x, y, z := ANeptuneXYZ(JD) x, y, z := ANeptuneXYZ(JD)
to := 0.0057755183 * math.Sqrt(x*x+y*y+z*z) to := 0.0057755183 * math.Sqrt(x*x+y*y+z*z)
x, y, z = ANeptuneXYZ(JD - to) x, y, z = ANeptuneXYZ(JD - to)
@ -107,7 +107,7 @@ func NeptuneSeeLo(JD float64) float64 {
return lo return lo
} }
func NeptuneSeeBo(JD float64) float64 { func NeptuneApparentBo(JD float64) float64 {
x, y, z := ANeptuneXYZ(JD) x, y, z := ANeptuneXYZ(JD)
to := 0.0057755183 * math.Sqrt(x*x+y*y+z*z) to := 0.0057755183 * math.Sqrt(x*x+y*y+z*z)
x, y, z = ANeptuneXYZ(JD - to) x, y, z = ANeptuneXYZ(JD - to)
@ -121,7 +121,7 @@ func NeptuneSeeBo(JD float64) float64 {
return bo return bo
} }
func NeptuneSeeLoBo(JD float64) (float64, float64) { func NeptuneApparentLoBo(JD float64) (float64, float64) {
x, y, z := ANeptuneXYZ(JD) x, y, z := ANeptuneXYZ(JD)
to := 0.0057755183 * math.Sqrt(x*x+y*y+z*z) to := 0.0057755183 * math.Sqrt(x*x+y*y+z*z)
x, y, z = ANeptuneXYZ(JD - to) x, y, z = ANeptuneXYZ(JD - to)
@ -145,3 +145,293 @@ func NeptuneMag(JD float64) float64 {
Mag := -6.87 + 5*math.Log10(AwaySun*AwayEarth) Mag := -6.87 + 5*math.Log10(AwaySun*AwayEarth)
return FloatRound(Mag, 2) return FloatRound(Mag, 2)
} }
func NeptuneHeight(jde, lon, lat, timezone float64) float64 {
// 转换为世界时
utcJde := jde - timezone/24.0
// 计算视恒星时
ra, dec := NeptuneApparentRaDec(TD2UT(utcJde, true))
st := Limit360(ApparentSiderealTime(utcJde)*15 + lon)
// 计算时角
H := Limit360(st - ra)
// 高度角、时角与天球座标三角转换公式
// sin(h)=sin(lat)*sin(dec)+cos(dec)*cos(lat)*cos(H)
sinHeight := Sin(lat)*Sin(dec) + Cos(dec)*Cos(lat)*Cos(H)
return ArcSin(sinHeight)
}
func NeptuneAzimuth(jde, lon, lat, timezone float64) float64 {
// 转换为世界时
utcJde := jde - timezone/24.0
// 计算视恒星时
ra, dec := NeptuneApparentRaDec(TD2UT(utcJde, true))
st := Limit360(ApparentSiderealTime(utcJde)*15 + lon)
// 计算时角
H := Limit360(st - ra)
// 三角转换公式
tanAzimuth := Sin(H) / (Cos(H)*Sin(lat) - Tan(dec)*Cos(lat))
Azimuth := ArcTan(tanAzimuth)
if Azimuth < 0 {
if H/15 < 12 {
return Azimuth + 360
}
return Azimuth + 180
}
if H/15 < 12 {
return Azimuth + 180
}
return Azimuth
}
func NeptuneHourAngle(JD, Lon, TZ float64) float64 {
startime := Limit360(ApparentSiderealTime(JD-TZ/24)*15 + Lon)
timeangle := startime - NeptuneApparentRa(TD2UT(JD-TZ/24.0, true))
if timeangle < 0 {
timeangle += 360
}
return timeangle
}
func NeptuneCulminationTime(jde, lon, timezone float64) float64 {
//jde 世界时,非力学时,当地时区 0时无需转换力学时
//ra,dec 瞬时天球座标非J2000等时间天球坐标
jde = math.Floor(jde) + 0.5
JD1 := jde + Limit360(360-NeptuneHourAngle(jde, lon, timezone))/15.0/24.0*0.99726851851851851851
limitHA := func(jde, lon, timezone float64) float64 {
ha := NeptuneHourAngle(jde, lon, timezone)
if ha < 180 {
ha += 360
}
return ha
}
for {
JD0 := JD1
stDegree := limitHA(JD0, lon, timezone) - 360
stDegreep := (limitHA(JD0+0.000005, lon, timezone) - limitHA(JD0-0.000005, lon, timezone)) / 0.00001
JD1 = JD0 - stDegree/stDegreep
if math.Abs(JD1-JD0) <= 0.00001 {
break
}
}
return JD1
}
func NeptuneRiseTime(JD, Lon, Lat, TZ, ZS, HEI float64) float64 {
return neptuneRiseDown(JD, Lon, Lat, TZ, ZS, HEI, true)
}
func NeptuneDownTime(JD, Lon, Lat, TZ, ZS, HEI float64) float64 {
return neptuneRiseDown(JD, Lon, Lat, TZ, ZS, HEI, false)
}
func neptuneRiseDown(JD, Lon, Lat, TZ, ZS, HEI float64, isRise bool) float64 {
var An float64
JD = math.Floor(JD) + 0.5
ntz := math.Round(Lon / 15)
if ZS != 0 {
An = -0.8333
}
An = An - HeightDegreeByLat(HEI, Lat)
tztime := NeptuneCulminationTime(JD, Lon, ntz)
if NeptuneHeight(tztime, Lon, Lat, ntz) < An {
return -2 //极夜
}
if NeptuneHeight(tztime-0.5, Lon, Lat, ntz) > An {
return -1 //极昼
}
dec := HSunApparentDec(TD2UT(tztime-ntz/24, true))
//(sin(ho)-sin(φ)*sin(δ2))/(cos(φ)*cos(δ2))
tmp := (Sin(An) - Sin(dec)*Sin(Lat)) / (Cos(dec) * Cos(Lat))
var rise float64
if math.Abs(tmp) <= 1 {
rzsc := ArcCos(tmp) / 15
if isRise {
rise = tztime - rzsc/24 - 25.0/24.0/60.0
} else {
rise = tztime + rzsc/24 - 25.0/24.0/60.0
}
} else {
rise = tztime
i := 0
//TODO:使用二分法计算
for NeptuneHeight(rise, Lon, Lat, ntz) > An {
i++
if isRise {
rise -= 15.0 / 60.0 / 24.0
} else {
rise += 15.0 / 60.0 / 24.0
}
if i > 48 {
break
}
}
}
JD1 := rise
for {
JD0 := JD1
stDegree := NeptuneHeight(JD0, Lon, Lat, ntz) - An
stDegreep := (NeptuneHeight(JD0+0.000005, Lon, Lat, ntz) - NeptuneHeight(JD0-0.000005, Lon, Lat, ntz)) / 0.00001
JD1 = JD0 - stDegree/stDegreep
if math.Abs(JD1-JD0) <= 0.00001 {
break
}
}
return JD1 - ntz/24 + TZ/24
}
// Pos
const NEPTUNE_S_PERIOD = 1 / ((1 / 365.256363004) - (1 / 4332.59))
func neptuneConjunction(jde, degree float64, next uint8) float64 {
//0=last 1=next
decSub := func(jde float64, degree float64, filter bool) float64 {
sub := Limit360(Limit360(NeptuneApparentLo(jde)-HSunApparentLo(jde)) - degree)
if filter {
if sub > 180 {
sub -= 360
}
if sub < -180 {
sub += 360
}
}
return sub
}
dayCost := NEPTUNE_S_PERIOD / 360
nowSub := decSub(jde, degree, false)
if next == 0 {
jde -= (360 - nowSub) * dayCost
} else {
jde += dayCost * nowSub
}
JD1 := jde
for {
JD0 := JD1
stDegree := decSub(JD0, degree, true)
stDegreep := (decSub(JD0+0.000005, degree, true) - decSub(JD0-0.000005, degree, true)) / 0.00001
JD1 = JD0 - stDegree/stDegreep
if math.Abs(JD1-JD0) <= 0.00001 {
break
}
}
return TD2UT(JD1, false)
}
func LastNeptuneConjunction(jde float64) float64 {
return neptuneConjunction(jde, 0, 0)
}
func NextNeptuneConjunction(jde float64) float64 {
return neptuneConjunction(jde, 0, 1)
}
func LastNeptuneOpposition(jde float64) float64 {
return neptuneConjunction(jde, 180, 0)
}
func NextNeptuneOpposition(jde float64) float64 {
return neptuneConjunction(jde, 180, 1)
}
func NextNeptuneEasternQuadrature(jde float64) float64 {
return neptuneConjunction(jde, 90, 1)
}
func LastNeptuneEasternQuadrature(jde float64) float64 {
return neptuneConjunction(jde, 90, 0)
}
func NextNeptuneWesternQuadrature(jde float64) float64 {
return neptuneConjunction(jde, 270, 1)
}
func LastNeptuneWesternQuadrature(jde float64) float64 {
return neptuneConjunction(jde, 270, 0)
}
func neptuneRetrograde(jde float64, isLeft bool) float64 {
//0=last 1=next
decSub := func(jde float64, val float64) float64 {
sub := NeptuneApparentRa(jde+val) - NeptuneApparentRa(jde-val)
if sub > 180 {
sub -= 360
}
if sub < -180 {
sub += 360
}
return sub / (2 * val)
}
jde = NextNeptuneOpposition(jde)
if isLeft {
jde -= 60
} else {
jde += 60
}
for {
nowSub := decSub(jde, 1.0/86400.0)
if math.Abs(nowSub) > 0.55 {
jde += 2
continue
}
break
}
JD1 := jde
for {
JD0 := JD1
stDegree := decSub(JD0, 2.0/86400.0)
stDegreep := (decSub(JD0+15.0/86400.0, 2.0/86400.0) - decSub(JD0-15.0/86400.0, 2.0/86400.0)) / (30.0 / 86400.0)
JD1 = JD0 - stDegree/stDegreep
if math.Abs(JD1-JD0) <= 30.0/86400.0 {
break
}
}
JD1 = JD1 - 15.0/86400.0
min := JD1
minRa := 100.0
for i := 0.0; i < 60.0; i++ {
tmp := decSub(JD1+i*0.5/86400.0, 0.5/86400.0)
if math.Abs(tmp) < math.Abs(minRa) {
minRa = tmp
min = JD1 + i*0.5/86400.0
}
}
return TD2UT(min, false)
}
func NextNeptuneRetrogradeToPrograde(jde float64) float64 {
date := neptuneRetrograde(jde, false)
if date < jde {
op := NextNeptuneOpposition(jde)
return neptuneRetrograde(op+10, false)
}
return date
}
func LastNeptuneRetrogradeToPrograde(jde float64) float64 {
jde = LastNeptuneOpposition(jde) - 10
date := neptuneRetrograde(jde, false)
if date > jde {
op := LastNeptuneOpposition(jde)
return neptuneRetrograde(op-10, false)
}
return date
}
func NextNeptuneProgradeToRetrograde(jde float64) float64 {
date := neptuneRetrograde(jde, true)
if date < jde {
op := NextNeptuneOpposition(jde)
return neptuneRetrograde(op+10, true)
}
return date
}
func LastNeptuneProgradeToRetrograde(jde float64) float64 {
jde = LastNeptuneOpposition(jde) - 10
date := neptuneRetrograde(jde, true)
if date > jde {
op := LastNeptuneOpposition(jde)
return neptuneRetrograde(op-10, true)
}
return date
}

@ -6,10 +6,10 @@ import (
) )
func Test_Ra(t *testing.T) { func Test_Ra(t *testing.T) {
ra, dec := UranusSeeRaDec(2456789.12345) ra, dec := UranusApparentRaDec(2456789.12345)
fmt.Printf("%.14f\n%.14f\n", ra, dec) fmt.Printf("%.14f\n%.14f\n", ra, dec)
fmt.Println(UranusMag(2456789.12345)) fmt.Println(UranusMag(2456789.12345))
ra, dec = NeptuneSeeRaDec(2456789.12345) ra, dec = NeptuneApparentRaDec(2456789.12345)
fmt.Printf("%.14f\n%.14f\n", ra, dec) fmt.Printf("%.14f\n%.14f\n", ra, dec)
fmt.Println(NeptuneMag(2456789.12345)) fmt.Println(NeptuneMag(2456789.12345))
} }

@ -63,22 +63,22 @@ func ASaturnXYZ(JD float64) (float64, float64, float64) {
return x, y, z return x, y, z
} }
func SaturnSeeRa(JD float64) float64 { func SaturnApparentRa(JD float64) float64 {
lo, bo := SaturnSeeLoBo(JD) lo, bo := SaturnApparentLoBo(JD)
sita := Sita(JD) sita := Sita(JD)
ra := math.Atan2((Sin(lo)*Cos(sita) - Tan(bo)*Sin(sita)), Cos(lo)) ra := math.Atan2((Sin(lo)*Cos(sita) - Tan(bo)*Sin(sita)), Cos(lo))
ra = ra * 180 / math.Pi ra = ra * 180 / math.Pi
return Limit360(ra) return Limit360(ra)
} }
func SaturnSeeDec(JD float64) float64 { func SaturnApparentDec(JD float64) float64 {
lo, bo := SaturnSeeLoBo(JD) lo, bo := SaturnApparentLoBo(JD)
sita := Sita(JD) sita := Sita(JD)
dec := ArcSin(Sin(bo)*Cos(sita) + Cos(bo)*Sin(sita)*Sin(lo)) dec := ArcSin(Sin(bo)*Cos(sita) + Cos(bo)*Sin(sita)*Sin(lo))
return dec return dec
} }
func SaturnSeeRaDec(JD float64) (float64, float64) { func SaturnApparentRaDec(JD float64) (float64, float64) {
lo, bo := SaturnSeeLoBo(JD) lo, bo := SaturnApparentLoBo(JD)
sita := Sita(JD) sita := Sita(JD)
ra := math.Atan2((Sin(lo)*Cos(sita) - Tan(bo)*Sin(sita)), Cos(lo)) ra := math.Atan2((Sin(lo)*Cos(sita) - Tan(bo)*Sin(sita)), Cos(lo))
ra = ra * 180 / math.Pi ra = ra * 180 / math.Pi
@ -92,7 +92,7 @@ func EarthSaturnAway(JD float64) float64 {
return to return to
} }
func SaturnSeeLo(JD float64) float64 { func SaturnApparentLo(JD float64) float64 {
x, y, z := ASaturnXYZ(JD) x, y, z := ASaturnXYZ(JD)
to := 0.0057755183 * math.Sqrt(x*x+y*y+z*z) to := 0.0057755183 * math.Sqrt(x*x+y*y+z*z)
x, y, z = ASaturnXYZ(JD - to) x, y, z = ASaturnXYZ(JD - to)
@ -107,7 +107,7 @@ func SaturnSeeLo(JD float64) float64 {
return lo return lo
} }
func SaturnSeeBo(JD float64) float64 { func SaturnApparentBo(JD float64) float64 {
x, y, z := ASaturnXYZ(JD) x, y, z := ASaturnXYZ(JD)
to := 0.0057755183 * math.Sqrt(x*x+y*y+z*z) to := 0.0057755183 * math.Sqrt(x*x+y*y+z*z)
x, y, z = ASaturnXYZ(JD - to) x, y, z = ASaturnXYZ(JD - to)
@ -121,7 +121,7 @@ func SaturnSeeBo(JD float64) float64 {
return bo return bo
} }
func SaturnSeeLoBo(JD float64) (float64, float64) { func SaturnApparentLoBo(JD float64) (float64, float64) {
x, y, z := ASaturnXYZ(JD) x, y, z := ASaturnXYZ(JD)
to := 0.0057755183 * math.Sqrt(x*x+y*y+z*z) to := 0.0057755183 * math.Sqrt(x*x+y*y+z*z)
x, y, z = ASaturnXYZ(JD - to) x, y, z = ASaturnXYZ(JD - to)
@ -150,7 +150,297 @@ func SaturnRingB(JD float64) float64 {
T := (JD - 2451545) / 36525 T := (JD - 2451545) / 36525
i := 28.075216 - 0.012998*T + 0.000004*T*T i := 28.075216 - 0.012998*T + 0.000004*T*T
omi := 169.508470 + 1.394681*T + 0.000412*T*T omi := 169.508470 + 1.394681*T + 0.000412*T*T
lo, bo := SaturnSeeLoBo(JD) lo, bo := SaturnApparentLoBo(JD)
B := Sin(i)*Cos(bo)*Sin(lo-omi) - Cos(i)*Cos(bo) B := Sin(i)*Cos(bo)*Sin(lo-omi) - Cos(i)*Cos(bo)
return ArcSin(B) return ArcSin(B)
} }
func SaturnHeight(jde, lon, lat, timezone float64) float64 {
// 转换为世界时
utcJde := jde - timezone/24.0
// 计算视恒星时
ra, dec := SaturnApparentRaDec(TD2UT(utcJde, true))
st := Limit360(ApparentSiderealTime(utcJde)*15 + lon)
// 计算时角
H := Limit360(st - ra)
// 高度角、时角与天球座标三角转换公式
// sin(h)=sin(lat)*sin(dec)+cos(dec)*cos(lat)*cos(H)
sinHeight := Sin(lat)*Sin(dec) + Cos(dec)*Cos(lat)*Cos(H)
return ArcSin(sinHeight)
}
func SaturnAzimuth(jde, lon, lat, timezone float64) float64 {
// 转换为世界时
utcJde := jde - timezone/24.0
// 计算视恒星时
ra, dec := SaturnApparentRaDec(TD2UT(utcJde, true))
st := Limit360(ApparentSiderealTime(utcJde)*15 + lon)
// 计算时角
H := Limit360(st - ra)
// 三角转换公式
tanAzimuth := Sin(H) / (Cos(H)*Sin(lat) - Tan(dec)*Cos(lat))
Azimuth := ArcTan(tanAzimuth)
if Azimuth < 0 {
if H/15 < 12 {
return Azimuth + 360
}
return Azimuth + 180
}
if H/15 < 12 {
return Azimuth + 180
}
return Azimuth
}
func SaturnHourAngle(JD, Lon, TZ float64) float64 {
startime := Limit360(ApparentSiderealTime(JD-TZ/24)*15 + Lon)
timeangle := startime - SaturnApparentRa(TD2UT(JD-TZ/24.0, true))
if timeangle < 0 {
timeangle += 360
}
return timeangle
}
func SaturnCulminationTime(jde, lon, timezone float64) float64 {
//jde 世界时,非力学时,当地时区 0时无需转换力学时
//ra,dec 瞬时天球座标非J2000等时间天球坐标
jde = math.Floor(jde) + 0.5
JD1 := jde + Limit360(360-SaturnHourAngle(jde, lon, timezone))/15.0/24.0*0.99726851851851851851
limitHA := func(jde, lon, timezone float64) float64 {
ha := SaturnHourAngle(jde, lon, timezone)
if ha < 180 {
ha += 360
}
return ha
}
for {
JD0 := JD1
stDegree := limitHA(JD0, lon, timezone) - 360
stDegreep := (limitHA(JD0+0.000005, lon, timezone) - limitHA(JD0-0.000005, lon, timezone)) / 0.00001
JD1 = JD0 - stDegree/stDegreep
if math.Abs(JD1-JD0) <= 0.00001 {
break
}
}
return JD1
}
func SaturnRiseTime(JD, Lon, Lat, TZ, ZS, HEI float64) float64 {
return saturnRiseDown(JD, Lon, Lat, TZ, ZS, HEI, true)
}
func SaturnDownTime(JD, Lon, Lat, TZ, ZS, HEI float64) float64 {
return saturnRiseDown(JD, Lon, Lat, TZ, ZS, HEI, false)
}
func saturnRiseDown(JD, Lon, Lat, TZ, ZS, HEI float64, isRise bool) float64 {
var An float64
JD = math.Floor(JD) + 0.5
ntz := math.Round(Lon / 15)
if ZS != 0 {
An = -0.8333
}
An = An - HeightDegreeByLat(HEI, Lat)
tztime := SaturnCulminationTime(JD, Lon, ntz)
if SaturnHeight(tztime, Lon, Lat, ntz) < An {
return -2 //极夜
}
if SaturnHeight(tztime-0.5, Lon, Lat, ntz) > An {
return -1 //极昼
}
dec := HSunApparentDec(TD2UT(tztime-ntz/24, true))
//(sin(ho)-sin(φ)*sin(δ2))/(cos(φ)*cos(δ2))
tmp := (Sin(An) - Sin(dec)*Sin(Lat)) / (Cos(dec) * Cos(Lat))
var rise float64
if math.Abs(tmp) <= 1 {
rzsc := ArcCos(tmp) / 15
if isRise {
rise = tztime - rzsc/24 - 25.0/24.0/60.0
} else {
rise = tztime + rzsc/24 - 25.0/24.0/60.0
}
} else {
rise = tztime
i := 0
//TODO:使用二分法计算
for SaturnHeight(rise, Lon, Lat, ntz) > An {
i++
if isRise {
rise -= 15.0 / 60.0 / 24.0
} else {
rise += 15.0 / 60.0 / 24.0
}
if i > 48 {
break
}
}
}
JD1 := rise
for {
JD0 := JD1
stDegree := SaturnHeight(JD0, Lon, Lat, ntz) - An
stDegreep := (SaturnHeight(JD0+0.000005, Lon, Lat, ntz) - SaturnHeight(JD0-0.000005, Lon, Lat, ntz)) / 0.00001
JD1 = JD0 - stDegree/stDegreep
if math.Abs(JD1-JD0) <= 0.00001 {
break
}
}
return JD1 - ntz/24 + TZ/24
}
// Pos
const SATURN_S_PERIOD = 1 / ((1 / 365.256363004) - (1 / 10759.0))
func saturnConjunction(jde, degree float64, next uint8) float64 {
//0=last 1=next
decSub := func(jde float64, degree float64, filter bool) float64 {
sub := Limit360(Limit360(SaturnApparentLo(jde)-HSunApparentLo(jde)) - degree)
if filter {
if sub > 180 {
sub -= 360
}
if sub < -180 {
sub += 360
}
}
return sub
}
dayCost := SATURN_S_PERIOD / 360
nowSub := decSub(jde, degree, false)
if next == 0 {
jde -= (360 - nowSub) * dayCost
} else {
jde += dayCost * nowSub
}
JD1 := jde
for {
JD0 := JD1
stDegree := decSub(JD0, degree, true)
stDegreep := (decSub(JD0+0.000005, degree, true) - decSub(JD0-0.000005, degree, true)) / 0.00001
JD1 = JD0 - stDegree/stDegreep
if math.Abs(JD1-JD0) <= 0.00001 {
break
}
}
return TD2UT(JD1, false)
}
func LastSaturnConjunction(jde float64) float64 {
return saturnConjunction(jde, 0, 0)
}
func NextSaturnConjunction(jde float64) float64 {
return saturnConjunction(jde, 0, 1)
}
func LastSaturnOpposition(jde float64) float64 {
return saturnConjunction(jde, 180, 0)
}
func NextSaturnOpposition(jde float64) float64 {
return saturnConjunction(jde, 180, 1)
}
func NextSaturnEasternQuadrature(jde float64) float64 {
return saturnConjunction(jde, 90, 1)
}
func LastSaturnEasternQuadrature(jde float64) float64 {
return saturnConjunction(jde, 90, 0)
}
func NextSaturnWesternQuadrature(jde float64) float64 {
return saturnConjunction(jde, 270, 1)
}
func LastSaturnWesternQuadrature(jde float64) float64 {
return saturnConjunction(jde, 270, 0)
}
func saturnRetrograde(jde float64, isLeft bool) float64 {
//0=last 1=next
decSub := func(jde float64, val float64) float64 {
sub := SaturnApparentRa(jde+val) - SaturnApparentRa(jde-val)
if sub > 180 {
sub -= 360
}
if sub < -180 {
sub += 360
}
return sub / (2 * val)
}
jde = NextSaturnOpposition(jde)
if isLeft {
jde -= 60
} else {
jde += 60
}
for {
nowSub := decSub(jde, 1.0/86400.0)
if math.Abs(nowSub) > 0.55 {
jde += 2
continue
}
break
}
JD1 := jde
for {
JD0 := JD1
stDegree := decSub(JD0, 2.0/86400.0)
stDegreep := (decSub(JD0+15.0/86400.0, 2.0/86400.0) - decSub(JD0-15.0/86400.0, 2.0/86400.0)) / (30.0 / 86400.0)
JD1 = JD0 - stDegree/stDegreep
if math.Abs(JD1-JD0) <= 30.0/86400.0 {
break
}
}
JD1 = JD1 - 15.0/86400.0
min := JD1
minRa := 100.0
for i := 0.0; i < 60.0; i++ {
tmp := decSub(JD1+i*0.5/86400.0, 0.5/86400.0)
if math.Abs(tmp) < math.Abs(minRa) {
minRa = tmp
min = JD1 + i*0.5/86400.0
}
}
return TD2UT(min, false)
}
func NextSaturnRetrogradeToPrograde(jde float64) float64 {
date := saturnRetrograde(jde, false)
if date < jde {
op := NextSaturnOpposition(jde)
return saturnRetrograde(op+10, false)
}
return date
}
func LastSaturnRetrogradeToPrograde(jde float64) float64 {
jde = LastSaturnOpposition(jde) - 10
date := saturnRetrograde(jde, false)
if date > jde {
op := LastSaturnOpposition(jde)
return saturnRetrograde(op-10, false)
}
return date
}
func NextSaturnProgradeToRetrograde(jde float64) float64 {
date := saturnRetrograde(jde, true)
if date < jde {
op := NextSaturnOpposition(jde)
return saturnRetrograde(op+10, true)
}
return date
}
func LastSaturnProgradeToRetrograde(jde float64) float64 {
jde = LastSaturnOpposition(jde) - 10
date := saturnRetrograde(jde, true)
if date > jde {
op := LastSaturnOpposition(jde)
return saturnRetrograde(op-10, true)
}
return date
}

@ -0,0 +1,13 @@
package basic
import (
"fmt"
"testing"
)
func TestSaturn(t *testing.T) {
jde := GetNowJDE() - 6000
for i := 0.00; i < 20; i++ {
fmt.Println(jde+i*365, JDE2Date(jde+i*365), JDE2Date(LastSaturnProgradeToRetrograde(jde+i*365)))
}
}

@ -150,7 +150,7 @@ func StarCulminationTime(jde, ra, lon, timezone float64) float64 {
for { for {
JD0 := JD1 JD0 := JD1
stDegree := limitStarHA(JD0, ra, lon, timezone) - 360 stDegree := limitStarHA(JD0, ra, lon, timezone) - 360
stDegreep := (limitStarHA(JD0+0.000005, ra, lon, timezone) - SunHeight(JD0-0.000005, ra, lon, timezone)) / 0.00001 stDegreep := (limitStarHA(JD0+0.000005, ra, lon, timezone) - limitStarHA(JD0-0.000005, ra, lon, timezone)) / 0.00001
JD1 = JD0 - stDegree/stDegreep JD1 = JD0 - stDegree/stDegreep
if math.Abs(JD1-JD0) <= 0.00001 { if math.Abs(JD1-JD0) <= 0.00001 {
break break
@ -158,3 +158,15 @@ func StarCulminationTime(jde, ra, lon, timezone float64) float64 {
} }
return JD1 return JD1
} }
func StarAngularSeparation(ra1, dec1, ra2, dec2 float64) float64 {
//cos(d)=sinδ1 sinδ2 + cosδ1 cosδ2 cos(α1-α2)
d := Sin(dec1)*Sin(dec2) + Cos(dec1)*Cos(dec2)*Cos(ra1-ra2)
if math.Abs(d) >= 0.999999997 {
//d = √(Δα*cosδ)2+(Δδ)2
tmp1 := ((ra1 - ra2) * Cos((dec1+dec2)/2))
tmp2 := (dec1 - dec2)
return math.Sqrt(tmp1*tmp1 + tmp2*tmp2)
}
return ArcCos(d)
}

@ -20,3 +20,8 @@ func Test_Star(t *testing.T) {
fmt.Println("Sirius CulminationTime:", JDE2Date(StarCulminationTime(date, 101.529, 113.568, 8.0))) fmt.Println("Sirius CulminationTime:", JDE2Date(StarCulminationTime(date, 101.529, 113.568, 8.0)))
fmt.Println("Sirius DownTime:", JDE2Date(StarDownTime(date, 101.529, -16.8, 113.568, 22.5, 0, 8.0, true))) fmt.Println("Sirius DownTime:", JDE2Date(StarDownTime(date, 101.529, -16.8, 113.568, 22.5, 0, 8.0, true)))
} }
func TestZB(t *testing.T) {
jde := GetNowJDE()
fmt.Println(LoBoToRaDec(jde, 156, 0))
}

@ -838,18 +838,7 @@ func SunApparentLo(JD float64) float64 { //'太阳视黄经
} }
func SunApparentRa(JD float64) float64 { // '太阳视赤经 func SunApparentRa(JD float64) float64 { // '太阳视赤经
T := (JD - 2451545) / 36525 return LoToRa(JD, SunApparentLo(JD), 0)
sitas := Sita(JD) + 0.00256*Cos(125.04-1934.136*T)
SunApparentRa := ArcTan(Cos(sitas) * Sin(SunApparentLo(JD)) / Cos(SunApparentLo(JD)))
tmp := SunApparentLo(JD)
if tmp >= 90 && tmp < 180 {
SunApparentRa = 180 + SunApparentRa
} else if tmp >= 180 && tmp < 270 {
SunApparentRa = 180 + SunApparentRa
} else if tmp >= 270 && tmp <= 360 {
SunApparentRa = 360 + SunApparentRa
}
return SunApparentRa
} }
func SunTrueRa(JD float64) float64 { //'太阳真赤经 func SunTrueRa(JD float64) float64 { //'太阳真赤经
@ -934,35 +923,11 @@ func EarthAway(JD float64) float64 {
} }
func HSunApparentRaDec(JD float64) (float64, float64) { func HSunApparentRaDec(JD float64) (float64, float64) {
T := (JD - 2451545) / 36525 return LoBoToRaDec(JD, HSunApparentLo(JD), HSunTrueBo(JD))
sitas := Sita(JD) + 0.00256*Cos(125.04-1934.136*T)
sitas2 := EclipticObliquity(JD, false) + 0.00256*Cos(125.04-1934.136*T)
tmp := HSunApparentLo(JD)
HSunApparentRa := ArcTan(Cos(sitas) * Sin(tmp) / Cos(tmp))
HSunApparentDec := ArcSin(Sin(sitas2) * Sin(tmp))
if tmp >= 90 && tmp < 180 {
HSunApparentRa = 180 + HSunApparentRa
} else if tmp >= 180 && tmp < 270 {
HSunApparentRa = 180 + HSunApparentRa
} else if tmp >= 270 && tmp <= 360 {
HSunApparentRa = 360 + HSunApparentRa
}
return HSunApparentRa, HSunApparentDec
} }
func HSunApparentRa(JD float64) float64 { // '太阳视赤经 func HSunApparentRa(JD float64) float64 { // '太阳视赤经
T := (JD - 2451545) / 36525 return LoToRa(JD, HSunApparentLo(JD), HSunTrueBo(JD))
sitas := Sita(JD) + 0.00256*Cos(125.04-1934.136*T)
tmp := HSunApparentLo(JD)
HSunApparentRa := ArcTan(Cos(sitas) * Sin(tmp) / Cos(tmp))
if tmp >= 90 && tmp < 180 {
HSunApparentRa = 180 + HSunApparentRa
} else if tmp >= 180 && tmp < 270 {
HSunApparentRa = 180 + HSunApparentRa
} else if tmp >= 270 && tmp <= 360 {
HSunApparentRa = 360 + HSunApparentRa
}
return HSunApparentRa
} }
func HSunTrueRa(JD float64) float64 { //'太阳真赤经 func HSunTrueRa(JD float64) float64 { //'太阳真赤经
@ -1030,10 +995,10 @@ func GetOneYearMoon(year float64) map[int]float64 {
} }
return moon return moon
} }
func GetOneYearJQ(year int) map[int]float64 { func GetOneYearJQ(year int) []float64 {
start := 270 start := 270
var years int var years int
jq := make(map[int]float64) jq := make([]float64, 26)
for i := 1; i < 26; i++ { for i := 1; i < 26; i++ {
angle := start + 15*(i-1) angle := start + 15*(i-1)
if angle > 360 { if angle > 360 {
@ -1047,6 +1012,7 @@ func GetOneYearJQ(year int) map[int]float64 {
jq[i] = GetJQTime(years, angle) + 8.0/24.0 jq[i] = GetJQTime(years, angle) + 8.0/24.0
// echo DateCalc(jq[i])."<br />"; // echo DateCalc(jq[i])."<br />";
} }
jq[0] = jq[1]
return jq return jq
} }

@ -63,22 +63,22 @@ func AUranusXYZ(JD float64) (float64, float64, float64) {
return x, y, z return x, y, z
} }
func UranusSeeRa(JD float64) float64 { func UranusApparentRa(JD float64) float64 {
lo, bo := UranusSeeLoBo(JD) lo, bo := UranusApparentLoBo(JD)
sita := Sita(JD) sita := Sita(JD)
ra := math.Atan2((Sin(lo)*Cos(sita) - Tan(bo)*Sin(sita)), Cos(lo)) ra := math.Atan2((Sin(lo)*Cos(sita) - Tan(bo)*Sin(sita)), Cos(lo))
ra = ra * 180 / math.Pi ra = ra * 180 / math.Pi
return Limit360(ra) return Limit360(ra)
} }
func UranusSeeDec(JD float64) float64 { func UranusApparentDec(JD float64) float64 {
lo, bo := UranusSeeLoBo(JD) lo, bo := UranusApparentLoBo(JD)
sita := Sita(JD) sita := Sita(JD)
dec := ArcSin(Sin(bo)*Cos(sita) + Cos(bo)*Sin(sita)*Sin(lo)) dec := ArcSin(Sin(bo)*Cos(sita) + Cos(bo)*Sin(sita)*Sin(lo))
return dec return dec
} }
func UranusSeeRaDec(JD float64) (float64, float64) { func UranusApparentRaDec(JD float64) (float64, float64) {
lo, bo := UranusSeeLoBo(JD) lo, bo := UranusApparentLoBo(JD)
sita := Sita(JD) sita := Sita(JD)
ra := math.Atan2((Sin(lo)*Cos(sita) - Tan(bo)*Sin(sita)), Cos(lo)) ra := math.Atan2((Sin(lo)*Cos(sita) - Tan(bo)*Sin(sita)), Cos(lo))
ra = ra * 180 / math.Pi ra = ra * 180 / math.Pi
@ -92,7 +92,7 @@ func EarthUranusAway(JD float64) float64 {
return to return to
} }
func UranusSeeLo(JD float64) float64 { func UranusApparentLo(JD float64) float64 {
x, y, z := AUranusXYZ(JD) x, y, z := AUranusXYZ(JD)
to := 0.0057755183 * math.Sqrt(x*x+y*y+z*z) to := 0.0057755183 * math.Sqrt(x*x+y*y+z*z)
x, y, z = AUranusXYZ(JD - to) x, y, z = AUranusXYZ(JD - to)
@ -107,7 +107,7 @@ func UranusSeeLo(JD float64) float64 {
return lo return lo
} }
func UranusSeeBo(JD float64) float64 { func UranusApparentBo(JD float64) float64 {
x, y, z := AUranusXYZ(JD) x, y, z := AUranusXYZ(JD)
to := 0.0057755183 * math.Sqrt(x*x+y*y+z*z) to := 0.0057755183 * math.Sqrt(x*x+y*y+z*z)
x, y, z = AUranusXYZ(JD - to) x, y, z = AUranusXYZ(JD - to)
@ -121,7 +121,7 @@ func UranusSeeBo(JD float64) float64 {
return bo return bo
} }
func UranusSeeLoBo(JD float64) (float64, float64) { func UranusApparentLoBo(JD float64) (float64, float64) {
x, y, z := AUranusXYZ(JD) x, y, z := AUranusXYZ(JD)
to := 0.0057755183 * math.Sqrt(x*x+y*y+z*z) to := 0.0057755183 * math.Sqrt(x*x+y*y+z*z)
x, y, z = AUranusXYZ(JD - to) x, y, z = AUranusXYZ(JD - to)
@ -145,3 +145,293 @@ func UranusMag(JD float64) float64 {
Mag := -7.19 + 5*math.Log10(AwaySun*AwayEarth) + 0.016*i Mag := -7.19 + 5*math.Log10(AwaySun*AwayEarth) + 0.016*i
return FloatRound(Mag, 2) return FloatRound(Mag, 2)
} }
func UranusHeight(jde, lon, lat, timezone float64) float64 {
// 转换为世界时
utcJde := jde - timezone/24.0
// 计算视恒星时
ra, dec := UranusApparentRaDec(TD2UT(utcJde, true))
st := Limit360(ApparentSiderealTime(utcJde)*15 + lon)
// 计算时角
H := Limit360(st - ra)
// 高度角、时角与天球座标三角转换公式
// sin(h)=sin(lat)*sin(dec)+cos(dec)*cos(lat)*cos(H)
sinHeight := Sin(lat)*Sin(dec) + Cos(dec)*Cos(lat)*Cos(H)
return ArcSin(sinHeight)
}
func UranusAzimuth(jde, lon, lat, timezone float64) float64 {
// 转换为世界时
utcJde := jde - timezone/24.0
// 计算视恒星时
ra, dec := UranusApparentRaDec(TD2UT(utcJde, true))
st := Limit360(ApparentSiderealTime(utcJde)*15 + lon)
// 计算时角
H := Limit360(st - ra)
// 三角转换公式
tanAzimuth := Sin(H) / (Cos(H)*Sin(lat) - Tan(dec)*Cos(lat))
Azimuth := ArcTan(tanAzimuth)
if Azimuth < 0 {
if H/15 < 12 {
return Azimuth + 360
}
return Azimuth + 180
}
if H/15 < 12 {
return Azimuth + 180
}
return Azimuth
}
func UranusHourAngle(JD, Lon, TZ float64) float64 {
startime := Limit360(ApparentSiderealTime(JD-TZ/24)*15 + Lon)
timeangle := startime - UranusApparentRa(TD2UT(JD-TZ/24.0, true))
if timeangle < 0 {
timeangle += 360
}
return timeangle
}
func UranusCulminationTime(jde, lon, timezone float64) float64 {
//jde 世界时,非力学时,当地时区 0时无需转换力学时
//ra,dec 瞬时天球座标非J2000等时间天球坐标
jde = math.Floor(jde) + 0.5
JD1 := jde + Limit360(360-UranusHourAngle(jde, lon, timezone))/15.0/24.0*0.99726851851851851851
limitHA := func(jde, lon, timezone float64) float64 {
ha := UranusHourAngle(jde, lon, timezone)
if ha < 180 {
ha += 360
}
return ha
}
for {
JD0 := JD1
stDegree := limitHA(JD0, lon, timezone) - 360
stDegreep := (limitHA(JD0+0.000005, lon, timezone) - limitHA(JD0-0.000005, lon, timezone)) / 0.00001
JD1 = JD0 - stDegree/stDegreep
if math.Abs(JD1-JD0) <= 0.00001 {
break
}
}
return JD1
}
func UranusRiseTime(JD, Lon, Lat, TZ, ZS, HEI float64) float64 {
return uranusRiseDown(JD, Lon, Lat, TZ, ZS, HEI, true)
}
func UranusDownTime(JD, Lon, Lat, TZ, ZS, HEI float64) float64 {
return uranusRiseDown(JD, Lon, Lat, TZ, ZS, HEI, false)
}
func uranusRiseDown(JD, Lon, Lat, TZ, ZS, HEI float64, isRise bool) float64 {
var An float64
JD = math.Floor(JD) + 0.5
ntz := math.Round(Lon / 15)
if ZS != 0 {
An = -0.8333
}
An = An - HeightDegreeByLat(HEI, Lat)
tztime := UranusCulminationTime(JD, Lon, ntz)
if UranusHeight(tztime, Lon, Lat, ntz) < An {
return -2 //极夜
}
if UranusHeight(tztime-0.5, Lon, Lat, ntz) > An {
return -1 //极昼
}
dec := HSunApparentDec(TD2UT(tztime-ntz/24, true))
//(sin(ho)-sin(φ)*sin(δ2))/(cos(φ)*cos(δ2))
tmp := (Sin(An) - Sin(dec)*Sin(Lat)) / (Cos(dec) * Cos(Lat))
var rise float64
if math.Abs(tmp) <= 1 {
rzsc := ArcCos(tmp) / 15
if isRise {
rise = tztime - rzsc/24 - 25.0/24.0/60.0
} else {
rise = tztime + rzsc/24 - 25.0/24.0/60.0
}
} else {
rise = tztime
i := 0
//TODO:使用二分法计算
for UranusHeight(rise, Lon, Lat, ntz) > An {
i++
if isRise {
rise -= 15.0 / 60.0 / 24.0
} else {
rise += 15.0 / 60.0 / 24.0
}
if i > 48 {
break
}
}
}
JD1 := rise
for {
JD0 := JD1
stDegree := UranusHeight(JD0, Lon, Lat, ntz) - An
stDegreep := (UranusHeight(JD0+0.000005, Lon, Lat, ntz) - UranusHeight(JD0-0.000005, Lon, Lat, ntz)) / 0.00001
JD1 = JD0 - stDegree/stDegreep
if math.Abs(JD1-JD0) <= 0.00001 {
break
}
}
return JD1 - ntz/24 + TZ/24
}
// Pos
const URANUS_S_PERIOD = 1 / ((1 / 365.256363004) - (1 / 30799.095))
func uranusConjunction(jde, degree float64, next uint8) float64 {
//0=last 1=next
decSub := func(jde float64, degree float64, filter bool) float64 {
sub := Limit360(Limit360(UranusApparentLo(jde)-HSunApparentLo(jde)) - degree)
if filter {
if sub > 180 {
sub -= 360
}
if sub < -180 {
sub += 360
}
}
return sub
}
dayCost := URANUS_S_PERIOD / 360
nowSub := decSub(jde, degree, false)
if next == 0 {
jde -= (360 - nowSub) * dayCost
} else {
jde += dayCost * nowSub
}
JD1 := jde
for {
JD0 := JD1
stDegree := decSub(JD0, degree, true)
stDegreep := (decSub(JD0+0.000005, degree, true) - decSub(JD0-0.000005, degree, true)) / 0.00001
JD1 = JD0 - stDegree/stDegreep
if math.Abs(JD1-JD0) <= 0.00001 {
break
}
}
return TD2UT(JD1, false)
}
func LastUranusConjunction(jde float64) float64 {
return uranusConjunction(jde, 0, 0)
}
func NextUranusConjunction(jde float64) float64 {
return uranusConjunction(jde, 0, 1)
}
func LastUranusOpposition(jde float64) float64 {
return uranusConjunction(jde, 180, 0)
}
func NextUranusOpposition(jde float64) float64 {
return uranusConjunction(jde, 180, 1)
}
func NextUranusEasternQuadrature(jde float64) float64 {
return uranusConjunction(jde, 90, 1)
}
func LastUranusEasternQuadrature(jde float64) float64 {
return uranusConjunction(jde, 90, 0)
}
func NextUranusWesternQuadrature(jde float64) float64 {
return uranusConjunction(jde, 270, 1)
}
func LastUranusWesternQuadrature(jde float64) float64 {
return uranusConjunction(jde, 270, 0)
}
func uranusRetrograde(jde float64, isLeft bool) float64 {
//0=last 1=next
decSub := func(jde float64, val float64) float64 {
sub := UranusApparentRa(jde+val) - UranusApparentRa(jde-val)
if sub > 180 {
sub -= 360
}
if sub < -180 {
sub += 360
}
return sub / (2 * val)
}
jde = NextUranusOpposition(jde)
if isLeft {
jde -= 60
} else {
jde += 60
}
for {
nowSub := decSub(jde, 1.0/86400.0)
if math.Abs(nowSub) > 0.55 {
jde += 2
continue
}
break
}
JD1 := jde
for {
JD0 := JD1
stDegree := decSub(JD0, 2.0/86400.0)
stDegreep := (decSub(JD0+15.0/86400.0, 2.0/86400.0) - decSub(JD0-15.0/86400.0, 2.0/86400.0)) / (30.0 / 86400.0)
JD1 = JD0 - stDegree/stDegreep
if math.Abs(JD1-JD0) <= 30.0/86400.0 {
break
}
}
JD1 = JD1 - 15.0/86400.0
min := JD1
minRa := 100.0
for i := 0.0; i < 60.0; i++ {
tmp := decSub(JD1+i*0.5/86400.0, 0.5/86400.0)
if math.Abs(tmp) < math.Abs(minRa) {
minRa = tmp
min = JD1 + i*0.5/86400.0
}
}
return TD2UT(min, false)
}
func NextUranusRetrogradeToPrograde(jde float64) float64 {
date := uranusRetrograde(jde, false)
if date < jde {
op := NextUranusOpposition(jde)
return uranusRetrograde(op+10, false)
}
return date
}
func LastUranusRetrogradeToPrograde(jde float64) float64 {
jde = LastUranusOpposition(jde) - 10
date := uranusRetrograde(jde, false)
if date > jde {
op := LastUranusOpposition(jde)
return uranusRetrograde(op-10, false)
}
return date
}
func NextUranusProgradeToRetrograde(jde float64) float64 {
date := uranusRetrograde(jde, true)
if date < jde {
op := NextUranusOpposition(jde)
return uranusRetrograde(op+10, true)
}
return date
}
func LastUranusProgradeToRetrograde(jde float64) float64 {
jde = LastUranusOpposition(jde) - 10
date := uranusRetrograde(jde, true)
if date > jde {
op := LastUranusOpposition(jde)
return uranusRetrograde(op-10, true)
}
return date
}

@ -63,22 +63,22 @@ func AVenusXYZ(JD float64) (float64, float64, float64) {
return x, y, z return x, y, z
} }
func VenusSeeRa(JD float64) float64 { func VenusApparentRa(JD float64) float64 {
lo, bo := VenusSeeLoBo(JD) lo, bo := VenusApparentLoBo(JD)
sita := Sita(JD) sita := Sita(JD)
ra := math.Atan2((Sin(lo)*Cos(sita) - Tan(bo)*Sin(sita)), Cos(lo)) ra := math.Atan2((Sin(lo)*Cos(sita) - Tan(bo)*Sin(sita)), Cos(lo))
ra = ra * 180 / math.Pi ra = ra * 180 / math.Pi
return Limit360(ra) return Limit360(ra)
} }
func VenusSeeDec(JD float64) float64 { func VenusApparentDec(JD float64) float64 {
lo, bo := VenusSeeLoBo(JD) lo, bo := VenusApparentLoBo(JD)
sita := Sita(JD) sita := Sita(JD)
dec := ArcSin(Sin(bo)*Cos(sita) + Cos(bo)*Sin(sita)*Sin(lo)) dec := ArcSin(Sin(bo)*Cos(sita) + Cos(bo)*Sin(sita)*Sin(lo))
return dec return dec
} }
func VenusSeeRaDec(JD float64) (float64, float64) { func VenusApparentRaDec(JD float64) (float64, float64) {
lo, bo := VenusSeeLoBo(JD) lo, bo := VenusApparentLoBo(JD)
sita := Sita(JD) sita := Sita(JD)
ra := math.Atan2((Sin(lo)*Cos(sita) - Tan(bo)*Sin(sita)), Cos(lo)) ra := math.Atan2((Sin(lo)*Cos(sita) - Tan(bo)*Sin(sita)), Cos(lo))
ra = ra * 180 / math.Pi ra = ra * 180 / math.Pi
@ -92,7 +92,7 @@ func EarthVenusAway(JD float64) float64 {
return to return to
} }
func VenusSeeLo(JD float64) float64 { func VenusApparentLo(JD float64) float64 {
x, y, z := AVenusXYZ(JD) x, y, z := AVenusXYZ(JD)
to := 0.0057755183 * math.Sqrt(x*x+y*y+z*z) to := 0.0057755183 * math.Sqrt(x*x+y*y+z*z)
x, y, z = AVenusXYZ(JD - to) x, y, z = AVenusXYZ(JD - to)
@ -107,7 +107,7 @@ func VenusSeeLo(JD float64) float64 {
return lo return lo
} }
func VenusSeeBo(JD float64) float64 { func VenusApparentBo(JD float64) float64 {
x, y, z := AVenusXYZ(JD) x, y, z := AVenusXYZ(JD)
to := 0.0057755183 * math.Sqrt(x*x+y*y+z*z) to := 0.0057755183 * math.Sqrt(x*x+y*y+z*z)
x, y, z = AVenusXYZ(JD - to) x, y, z = AVenusXYZ(JD - to)
@ -121,7 +121,7 @@ func VenusSeeBo(JD float64) float64 {
return bo return bo
} }
func VenusSeeLoBo(JD float64) (float64, float64) { func VenusApparentLoBo(JD float64) (float64, float64) {
x, y, z := AVenusXYZ(JD) x, y, z := AVenusXYZ(JD)
to := 0.0057755183 * math.Sqrt(x*x+y*y+z*z) to := 0.0057755183 * math.Sqrt(x*x+y*y+z*z)
x, y, z = AVenusXYZ(JD - to) x, y, z = AVenusXYZ(JD - to)
@ -145,3 +145,471 @@ func VenusMag(JD float64) float64 {
Mag := -4.40 + 5*math.Log10(AwaySun*AwayEarth) + 0.0009*i + 0.000239*i*i - 0.00000065*i*i*i Mag := -4.40 + 5*math.Log10(AwaySun*AwayEarth) + 0.0009*i + 0.000239*i*i - 0.00000065*i*i*i
return FloatRound(Mag, 2) return FloatRound(Mag, 2)
} }
func VenusHeight(jde, lon, lat, timezone float64) float64 {
// 转换为世界时
utcJde := jde - timezone/24.0
// 计算视恒星时
ra, dec := VenusApparentRaDec(TD2UT(utcJde, true))
st := Limit360(ApparentSiderealTime(utcJde)*15 + lon)
// 计算时角
H := Limit360(st - ra)
// 高度角、时角与天球座标三角转换公式
// sin(h)=sin(lat)*sin(dec)+cos(dec)*cos(lat)*cos(H)
sinHeight := Sin(lat)*Sin(dec) + Cos(dec)*Cos(lat)*Cos(H)
return ArcSin(sinHeight)
}
func VenusAzimuth(jde, lon, lat, timezone float64) float64 {
// 转换为世界时
utcJde := jde - timezone/24.0
// 计算视恒星时
ra, dec := VenusApparentRaDec(TD2UT(utcJde, true))
st := Limit360(ApparentSiderealTime(utcJde)*15 + lon)
// 计算时角
H := Limit360(st - ra)
// 三角转换公式
tanAzimuth := Sin(H) / (Cos(H)*Sin(lat) - Tan(dec)*Cos(lat))
Azimuth := ArcTan(tanAzimuth)
if Azimuth < 0 {
if H/15 < 12 {
return Azimuth + 360
}
return Azimuth + 180
}
if H/15 < 12 {
return Azimuth + 180
}
return Azimuth
}
func VenusHourAngle(JD, Lon, TZ float64) float64 {
startime := Limit360(ApparentSiderealTime(JD-TZ/24)*15 + Lon)
timeangle := startime - VenusApparentRa(TD2UT(JD-TZ/24.0, true))
if timeangle < 0 {
timeangle += 360
}
return timeangle
}
func VenusCulminationTime(jde, lon, timezone float64) float64 {
//jde 世界时,非力学时,当地时区 0时无需转换力学时
//ra,dec 瞬时天球座标非J2000等时间天球坐标
jde = math.Floor(jde) + 0.5
JD1 := jde + Limit360(360-VenusHourAngle(jde, lon, timezone))/15.0/24.0*0.99726851851851851851
limitHA := func(jde, lon, timezone float64) float64 {
ha := VenusHourAngle(jde, lon, timezone)
if ha < 180 {
ha += 360
}
return ha
}
for {
JD0 := JD1
stDegree := limitHA(JD0, lon, timezone) - 360
stDegreep := (limitHA(JD0+0.000005, lon, timezone) - limitHA(JD0-0.000005, lon, timezone)) / 0.00001
JD1 = JD0 - stDegree/stDegreep
if math.Abs(JD1-JD0) <= 0.00001 {
break
}
}
return JD1
}
func VenusRiseTime(JD, Lon, Lat, TZ, ZS, HEI float64) float64 {
return venusRiseDown(JD, Lon, Lat, TZ, ZS, HEI, true)
}
func VenusDownTime(JD, Lon, Lat, TZ, ZS, HEI float64) float64 {
return venusRiseDown(JD, Lon, Lat, TZ, ZS, HEI, false)
}
func venusRiseDown(JD, Lon, Lat, TZ, ZS, HEI float64, isRise bool) float64 {
var An float64
JD = math.Floor(JD) + 0.5
ntz := math.Round(Lon / 15)
if ZS != 0 {
An = -0.8333
}
An = An - HeightDegreeByLat(HEI, Lat)
tztime := VenusCulminationTime(JD, Lon, ntz)
if VenusHeight(tztime, Lon, Lat, ntz) < An {
return -2 //极夜
}
if VenusHeight(tztime-0.5, Lon, Lat, ntz) > An {
return -1 //极昼
}
dec := HSunApparentDec(TD2UT(tztime-ntz/24, true))
//(sin(ho)-sin(φ)*sin(δ2))/(cos(φ)*cos(δ2))
tmp := (Sin(An) - Sin(dec)*Sin(Lat)) / (Cos(dec) * Cos(Lat))
var rise float64
if math.Abs(tmp) <= 1 {
rzsc := ArcCos(tmp) / 15
if isRise {
rise = tztime - rzsc/24 - 25.0/24.0/60.0
} else {
rise = tztime + rzsc/24 - 25.0/24.0/60.0
}
} else {
rise = tztime
i := 0
//TODO:使用二分法计算
for VenusHeight(rise, Lon, Lat, ntz) > An {
i++
if isRise {
rise -= 15.0 / 60.0 / 24.0
} else {
rise += 15.0 / 60.0 / 24.0
}
if i > 48 {
break
}
}
}
JD1 := rise
for {
JD0 := JD1
stDegree := VenusHeight(JD0, Lon, Lat, ntz) - An
stDegreep := (VenusHeight(JD0+0.000005, Lon, Lat, ntz) - VenusHeight(JD0-0.000005, Lon, Lat, ntz)) / 0.00001
JD1 = JD0 - stDegree/stDegreep
if math.Abs(JD1-JD0) <= 0.00001 {
break
}
}
return JD1 - ntz/24 + TZ/24
}
// Pos
const VENUS_S_PERIOD = 1 / ((1 / 224.701) - (1 / 365.256363004))
func venusConjunction(jde float64, next uint8) float64 {
//0=last 1=next
decSub := func(jde float64) float64 {
sub := Limit360(VenusApparentLo(jde) - HSunApparentLo(jde))
if sub > 180 {
sub -= 360
}
if sub < -180 {
sub += 360
}
return sub
}
nowSub := decSub(jde)
pos := math.Abs(decSub(jde+1/86400.0)) - math.Abs(nowSub)
if pos >= 0 && next == 1 && nowSub > 0 {
jde += VENUS_S_PERIOD/8.0 + 2
}
if pos >= 0 && next == 1 && nowSub < 0 {
jde += VENUS_S_PERIOD/6.0 + 2
}
if pos <= 0 && next == 0 && nowSub < 0 {
jde -= VENUS_S_PERIOD/8.0 + 2
}
if pos <= 0 && next == 0 && nowSub > 0 {
jde -= VENUS_S_PERIOD/6.0 + 2
}
for {
nowSub := decSub(jde)
pos := math.Abs(decSub(jde+1/86400.0)) - math.Abs(nowSub)
if math.Abs(nowSub) > 24 || (pos > 0 && next == 1) || (pos < 0 && next == 0) {
if next == 1 {
jde += 8
} else {
jde -= 8
}
continue
}
break
}
JD1 := jde
for {
JD0 := JD1
stDegree := decSub(JD0)
stDegreep := (decSub(JD0+0.000005) - decSub(JD0-0.000005)) / 0.00001
JD1 = JD0 - stDegree/stDegreep
if math.Abs(JD1-JD0) <= 0.00001 {
break
}
}
return TD2UT(JD1, false)
}
func LastVenusConjunction(jde float64) float64 {
return venusConjunction(jde, 0)
}
func NextVenusConjunction(jde float64) float64 {
return venusConjunction(jde, 1)
}
func NextVenusInferiorConjunction(jde float64) float64 {
date := NextVenusConjunction(jde)
if EarthVenusAway(date) > EarthAway(date) {
return NextVenusConjunction(date + 2)
}
return date
}
func NextVenusSuperiorConjunction(jde float64) float64 {
date := NextVenusConjunction(jde)
if EarthVenusAway(date) < EarthAway(date) {
return NextVenusConjunction(date + 2)
}
return date
}
func LastVenusInferiorConjunction(jde float64) float64 {
date := LastVenusConjunction(jde)
if EarthVenusAway(date) > EarthAway(date) {
return LastVenusConjunction(date - 2)
}
return date
}
func LastVenusSuperiorConjunction(jde float64) float64 {
date := LastVenusConjunction(jde)
if EarthVenusAway(date) < EarthAway(date) {
return LastVenusConjunction(date - 2)
}
return date
}
func venusRetrograde(jde float64) float64 {
//0=last 1=next
decSunSub := func(jde float64) float64 {
sub := Limit360(VenusApparentRa(jde) - SunApparentRa(jde))
if sub > 180 {
sub -= 360
}
if sub < -180 {
sub += 360
}
return sub
}
decSub := func(jde float64, val float64) float64 {
sub := VenusApparentRa(jde+val) - VenusApparentRa(jde-val)
if sub > 180 {
sub -= 360
}
if sub < -180 {
sub += 360
}
return sub / (2 * val)
}
lastHe := LastVenusConjunction(jde)
nextHe := NextVenusConjunction(jde)
nowSub := decSunSub(jde)
if nowSub > 0 {
jde = lastHe + ((nextHe - lastHe) / 5.0 * 3.5)
} else {
jde = lastHe + 10
}
for {
nowSub := decSub(jde, 1.0/86400.0)
if math.Abs(nowSub) > 0.5 {
jde += 5
continue
}
break
}
JD1 := jde
for {
JD0 := JD1
stDegree := decSub(JD0, 0.5/86400.0)
stDegreep := (decSub(JD0+10.0/86400.0, 0.5/86400.0) - decSub(JD0-10.0/86400.0, 0.5/86400.0)) / (20.0 / 86400.0)
JD1 = JD0 - stDegree/stDegreep
if math.Abs(JD1-JD0) <= 20.0/86400.0 {
break
}
}
JD1 = JD1 - 10.0/86400.0
min := JD1
minRa := 100.0
for i := 0.0; i < 40.0; i++ {
tmp := decSub(JD1+i*0.5/86400.0, 0.5/86400.0)
if math.Abs(tmp) < math.Abs(minRa) {
minRa = tmp
min = JD1 + i*0.5/86400.0
}
}
//fmt.Println((min - lastHe) / (nextHe - lastHe))
return TD2UT(min, false)
}
func NextVenusRetrograde(jde float64) float64 {
date := venusRetrograde(jde)
if date < jde {
nextHe := NextVenusConjunction(jde)
return venusRetrograde(nextHe + 2)
}
return date
}
func LastVenusRetrograde(jde float64) float64 {
lastHe := LastVenusConjunction(jde)
date := venusRetrograde(lastHe + 2)
if date > jde {
lastLastHe := LastVenusConjunction(lastHe - 2)
return venusRetrograde(lastLastHe + 2)
}
return date
}
func NextVenusProgradeToRetrograde(jde float64) float64 {
date := NextVenusRetrograde(jde)
sub := Limit360(VenusApparentRa(date) - SunApparentRa(date))
if sub > 180 {
return NextVenusRetrograde(date + VENUS_S_PERIOD/2)
}
return date
}
func NextVenusRetrogradeToPrograde(jde float64) float64 {
date := NextVenusRetrograde(jde)
sub := Limit360(VenusApparentRa(date) - SunApparentRa(date))
if sub < 180 {
return NextVenusRetrograde(date + 12)
}
return date
}
func LastVenusProgradeToRetrograde(jde float64) float64 {
date := LastVenusRetrograde(jde)
sub := Limit360(VenusApparentRa(date) - SunApparentRa(date))
if sub > 180 {
return LastVenusRetrograde(date - 12)
}
return date
}
func LastVenusRetrogradeToPrograde(jde float64) float64 {
date := LastVenusRetrograde(jde)
sub := Limit360(VenusApparentRa(date) - SunApparentRa(date))
if sub < 180 {
return LastVenusRetrograde(date - VENUS_S_PERIOD/2)
}
return date
}
func VenusSunElongation(jde float64) float64 {
lo1, bo1 := VenusApparentLoBo(jde)
lo2 := SunApparentLo(jde)
bo2 := HSunTrueBo(jde)
return StarAngularSeparation(lo1, bo1, lo2, bo2)
}
func venusGreatestElongation(jde float64) float64 {
decSunSub := func(jde float64) float64 {
sub := Limit360(VenusApparentRa(jde) - SunApparentRa(jde))
if sub > 180 {
sub -= 360
}
if sub < -180 {
sub += 360
}
return sub
}
decSub := func(jde float64, val float64) float64 {
sub := VenusSunElongation(jde+val) - VenusSunElongation(jde-val)
if sub > 180 {
sub -= 360
}
if sub < -180 {
sub += 360
}
return sub / (2 * val)
}
lastHe := LastVenusConjunction(jde)
nextHe := NextVenusConjunction(jde)
nowSub := decSunSub(jde)
if nowSub > 0 {
jde = lastHe + ((nextHe - lastHe) / 5.0 * 2.5)
} else {
jde = lastHe + ((nextHe - lastHe) / 5.0)
}
for {
nowSub := decSub(jde, 1.0/86400.0)
if math.Abs(nowSub) > 0.15 {
jde += 5
continue
}
break
}
JD1 := jde
for {
JD0 := JD1
stDegree := decSub(JD0, 2.0/86400.0)
stDegreep := (decSub(JD0+15.0/86400.0, 2.0/86400.0) - decSub(JD0-15.0/86400.0, 2.0/86400.0)) / (30.0 / 86400.0)
JD1 = JD0 - stDegree/stDegreep
if math.Abs(JD1-JD0) <= 30.0/86400.0 {
break
}
}
JD1 = JD1 - 15.0/86400.0
min := JD1
minRa := 100.0
for i := 0.0; i < 60.0; i++ {
tmp := decSub(JD1+i*0.5/86400.0, 0.5/86400.0)
if math.Abs(tmp) < math.Abs(minRa) {
minRa = tmp
min = JD1 + i*0.5/86400.0
}
}
//fmt.Println((min - lastHe) / (nextHe - lastHe))
return TD2UT(min, false)
}
func NextVenusGreatestElongation(jde float64) float64 {
date := venusGreatestElongation(jde)
if date < jde {
nextHe := NextVenusConjunction(jde)
return venusGreatestElongation(nextHe + 2)
}
return date
}
func LastVenusGreatestElongation(jde float64) float64 {
lastHe := LastVenusConjunction(jde)
date := venusGreatestElongation(lastHe + 2)
if date > jde {
lastLastHe := LastVenusConjunction(lastHe - 2)
return venusGreatestElongation(lastLastHe + 2)
}
return date
}
func NextVenusGreatestElongationEast(jde float64) float64 {
date := NextVenusGreatestElongation(jde)
sub := Limit360(VenusApparentRa(date) - SunApparentRa(date))
if sub > 180 {
return NextVenusGreatestElongation(date + 1)
}
return date
}
func NextVenusGreatestElongationWest(jde float64) float64 {
date := NextVenusGreatestElongation(jde)
sub := Limit360(VenusApparentRa(date) - SunApparentRa(date))
if sub < 180 {
return NextVenusGreatestElongation(date + 1)
}
return date
}
func LastVenusGreatestElongationEast(jde float64) float64 {
date := LastVenusGreatestElongation(jde)
sub := Limit360(VenusApparentRa(date) - SunApparentRa(date))
if sub > 180 {
return LastVenusGreatestElongation(date - 1)
}
return date
}
func LastVenusGreatestElongationWest(jde float64) float64 {
date := LastVenusGreatestElongation(jde)
sub := Limit360(VenusApparentRa(date) - SunApparentRa(date))
if sub < 180 {
return LastVenusGreatestElongation(date - 1)
}
return date
}

@ -0,0 +1,37 @@
package basic
import (
"fmt"
"testing"
)
func TestVenus(t *testing.T) {
jde := 2.4597161573032406e+06 - 720
/*
fmt.Println(JDE2Date(VenusCulminationTime(jde, 115, 8)))
fmt.Println(JDE2Date(VenusRiseTime(jde, 115, 23, 8, 0, 0)))
fmt.Println(JDE2Date(VenusDownTime(jde, 115, 23, 8, 0, 0)))
fmt.Println("----------------")
*/
//LastVenusConjunction(2.4596600340162036e+06)
//fmt.Println(2.4590359532407406e+06, JDE2Date(2.4590359532407406e+06), JDE2Date(NextVenusRetrograde(2.4590359532407406e+06)))
//fmt.Println(jde)
///fmt.Println(MarsTrueLoBo(jde))
//fmt.Println((jde-2451545)/36525, JDE2Date(0.2293425175054224*36525+2451545))
decSub := func(jde float64, val float64) float64 {
sub := VenusSunElongation(jde+val) - VenusSunElongation(jde-val)
if sub > 180 {
sub -= 360
}
if sub < -180 {
sub += 360
}
return sub / (2 * val)
}
_ = decSub
for i := 0.00; i < 1800.0; i += 50 {
fmt.Println(jde+i, JDE2Date(jde+i), JDE2Date(LastVenusGreatestElongationWest(jde+i)))
//fmt.Println(decSub(jde+i, 1.0/86400.0))
}
}

@ -34,27 +34,47 @@ const (
) )
// Lunar 公历转农历 // Lunar 公历转农历
// 传入 公历年月日 // 传入 公历年月日,时区
// 返回 农历月,日,是否闰月以及文字描述 // 返回 农历月,日,是否闰月以及文字描述
func Lunar(year, month, day int) (int, int, bool, string) { // 按现行农历GB/T 33661-2017算法计算推荐使用年限为[1929-3000]年
return basic.GetLunar(year, month, day, 8.0/24.0) // 古代由于定朔定气误差此处计算会与古时不符
func Lunar(year, month, day int, timezone float64) (int, int, bool, string) {
return basic.GetLunar(year, month, day, timezone)
}
// Solar 农历转公历
// 传入 农历年份,月,日,是否闰月,时区
// 传出 公历时间
// 农历年份用公历年份代替,但是岁首需要使用农历岁首
// 例计算己亥猪年腊月三十日对应的公历即2020年1月24日
// 由于农历还未到鼠年故应当传入Solar(2019,12,30,false)
// 按现行农历GB/T 33661-2017算法计算推荐使用年限为[1929-3000]年
// 古代由于定朔定气误差此处计算会与古时不符
func Solar(year, month, day int, leap bool, timezone float64) time.Time {
jde := basic.GetSolar(year, month, day, leap, timezone/24.0)
zone := time.FixedZone("CST", int(timezone*3600))
return basic.JDE2DateByZone(jde, zone, true)
} }
// ChineseLunar 公历转农历 // SolarToLunar 公历转农历
// 传入 公历年月日 // 传入 公历年月日
// 返回 农历月,日,是否闰月以及文字描述 // 返回 农历月,日,是否闰月以及文字描述
// 忽略时区,日期一律按北京时间计算 // 忽略时区,日期一律按北京时间计算
func ChineseLunar(date time.Time) (int, int, bool, string) { // 按现行农历GB/T 33661-2017算法计算推荐使用年限为[1929-3000]年
// 古代由于定朔定气误差此处计算会与古时不符
func SolarToLunar(date time.Time) (int, int, bool, string) {
return basic.GetLunar(date.Year(), int(date.Month()), date.Day(), 8.0/24.0) return basic.GetLunar(date.Year(), int(date.Month()), date.Day(), 8.0/24.0)
} }
// Solar 农历转公历 // LunarToSolar 农历转公历
// 传入 农历年份,月,日,是否闰月 // 传入 农历年份,月,日,是否闰月
// 传出 公历时间 // 传出 公历时间
// 农历年份用公历年份代替,但是岁首需要使用农历岁首 // 农历年份用公历年份代替,但是岁首需要使用农历岁首
// 例计算己亥猪年腊月三十日对应的公历即2020年1月24日 // 例计算己亥猪年腊月三十日对应的公历即2020年1月24日
// 由于农历还未到鼠年故应当传入Solar(2019,12,30,false) // 由于农历还未到鼠年故应当传入Solar(2019,12,30,false)
func Solar(year, month, day int, leap bool) time.Time { // 按现行农历GB/T 33661-2017算法计算推荐使用年限为[1929-3000]年
// 古代由于定朔定气误差此处计算会与古时不符
func LunarToSolar(year, month, day int, leap bool) time.Time {
jde := basic.GetSolar(year, month, day, leap, 8.0/24.0) jde := basic.GetSolar(year, month, day, leap, 8.0/24.0)
zone := time.FixedZone("CST", 8*3600) zone := time.FixedZone("CST", 8*3600)
return basic.JDE2DateByZone(jde, zone, true) return basic.JDE2DateByZone(jde, zone, true)

@ -2,69 +2,239 @@ package jupiter
import ( import (
"b612.me/astro/basic" "b612.me/astro/basic"
"b612.me/astro/calendar"
"b612.me/astro/planet" "b612.me/astro/planet"
"errors"
"time"
) )
/* var (
ERR_JUPITER_NEVER_RISE = errors.New("ERROR:极夜,木星今日永远在地平线下!")
jde: UTC ERR_JUPITER_NEVER_DOWN = errors.New("ERROR:极昼,木星今日永远在地平线上!")
*/ )
func SeeLo(jde float64) float64 {
return basic.JupiterSeeLo(basic.TD2UT(jde, true)) // ApparentLo 视黄经
func ApparentLo(date time.Time) float64 {
jde := calendar.Date2JDE(date)
return basic.JupiterApparentLo(basic.TD2UT(jde, true))
} }
/* // ApparentBo 视黄纬
func ApparentBo(date time.Time) float64 {
jde: UTC jde := calendar.Date2JDE(date)
*/ return basic.JupiterApparentBo(basic.TD2UT(jde, true))
func SeeBo(jde float64) float64 {
return basic.JupiterSeeBo(basic.TD2UT(jde, true))
} }
/* // ApparentRa 视赤经
func ApparentRa(date time.Time) float64 {
jde: UTC jde := calendar.Date2JDE(date)
*/ return basic.JupiterApparentRa(basic.TD2UT(jde, true))
func SeeRa(jde float64) float64 {
return basic.JupiterSeeRa(basic.TD2UT(jde, true))
} }
/* // ApparentDec 视赤纬
func ApparentDec(date time.Time) float64 {
jde: UTC jde := calendar.Date2JDE(date)
*/ return basic.JupiterApparentDec(basic.TD2UT(jde, true))
func SeeDec(jde float64) float64 {
return basic.JupiterSeeDec(basic.TD2UT(jde, true))
} }
/* // ApparentRaDec 视赤经赤纬
func ApparentRaDec(date time.Time) (float64, float64) {
jde: UTC jde := calendar.Date2JDE(date)
*/ return basic.JupiterApparentRaDec(basic.TD2UT(jde, true))
func SeeRaDec(jde float64) (float64, float64) {
return basic.JupiterSeeRaDec(basic.TD2UT(jde, true))
} }
/* // ApparentMagnitude 视星等
func ApparentMagnitude(date time.Time) float64 {
jde: UTC jde := calendar.Date2JDE(date)
*/
func SeeMag(jde float64) float64 {
return basic.JupiterMag(basic.TD2UT(jde, true)) return basic.JupiterMag(basic.TD2UT(jde, true))
} }
/* // EarthDistance 与地球距离(天文单位)
func EarthDistance(date time.Time) float64 {
jde: UTC jde := calendar.Date2JDE(date)
*/
func EarthAway(jde float64) float64 {
return basic.EarthJupiterAway(basic.TD2UT(jde, true)) return basic.EarthJupiterAway(basic.TD2UT(jde, true))
} }
/* // EarthDistance 与太阳距离(天文单位)
func SunDistance(date time.Time) float64 {
jde: UTC jde := calendar.Date2JDE(date)
*/ return planet.WherePlanet(4, 2, basic.TD2UT(jde, true))
func SunAway(jde float64) float64 { }
return planet.WherePlanet(1, 2, basic.TD2UT(jde, true))
// Zenith 高度角
func Zenith(date time.Time, lon, lat float64) float64 {
jde := basic.Date2JDE(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
return basic.JupiterHeight(jde, lon, lat, timezone)
}
// Azimuth 方位角
func Azimuth(date time.Time, lon, lat float64) float64 {
jde := basic.Date2JDE(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
return basic.JupiterAzimuth(jde, lon, lat, timezone)
}
// HourAngle 时角
// 返回给定经纬度、对应date时区date时刻的时角
func HourAngle(date time.Time, lon float64) float64 {
jde := basic.Date2JDE(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
return basic.JupiterHourAngle(jde, lon, timezone)
}
// CulminationTime 中天时间
// 返回给定经纬度、对应date时区date时刻的中天日期
func CulminationTime(date time.Time, lon float64) time.Time {
if date.Hour() > 12 {
date = date.Add(time.Hour * -12)
}
jde := basic.Date2JDE(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
calcJde := basic.JupiterCulminationTime(jde, lon, timezone) - timezone/24.00
return basic.JDE2DateByZone(calcJde, date.Location(), false)
}
// RiseTime 升起时间
// date取日期时区忽略
// lon经度东正西负
// lat纬度北正南负
// height高度
// aerotrue时进行大气修正
func RiseTime(date time.Time, lon, lat, height float64, aero bool) (time.Time, error) {
var err error
var aeroFloat float64
if aero {
aeroFloat = 1
}
if date.Hour() > 12 {
date = date.Add(time.Hour * -12)
}
jde := basic.Date2JDE(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
riseJde := basic.JupiterRiseTime(jde, lon, lat, timezone, aeroFloat, height)
if riseJde == -2 {
err = ERR_JUPITER_NEVER_RISE
}
if riseJde == -1 {
err = ERR_JUPITER_NEVER_DOWN
}
return basic.JDE2DateByZone(riseJde, date.Location(), true), err
}
// DownTime 落下时间
// date取日期时区忽略
// lon经度东正西负
// lat纬度北正南负
// height高度
// aerotrue时进行大气修正
func DownTime(date time.Time, lon, lat, height float64, aero bool) (time.Time, error) {
var err error
var aeroFloat float64
if aero {
aeroFloat = 1
}
if date.Hour() > 12 {
date = date.Add(time.Hour * -12)
}
jde := basic.Date2JDE(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
riseJde := basic.JupiterDownTime(jde, lon, lat, timezone, aeroFloat, height)
if riseJde == -2 {
err = ERR_JUPITER_NEVER_RISE
}
if riseJde == -1 {
err = ERR_JUPITER_NEVER_DOWN
}
return basic.JDE2DateByZone(riseJde, date.Location(), true), err
}
// LastConjunction 上次合日时间
// 返回上次合日时间
func LastConjunction(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.LastJupiterConjunction(jde), date.Location(), false)
}
// NextConjunction 下次合日时间
// 返回下次合日时间
func NextConjunction(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.NextJupiterConjunction(jde), date.Location(), false)
}
// LastOpposition 上次冲日时间
// 返回上次冲日时间
func LastOpposition(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.LastJupiterOpposition(jde), date.Location(), false)
}
// NextOpposition 下次冲日时间
// 返回下次冲日时间
func NextOpposition(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.NextJupiterOpposition(jde), date.Location(), false)
}
// LastProgradeToRetrograde 上次留(顺转逆)
// 返回上次顺转逆留的时间
func LastProgradeToRetrograde(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.LastJupiterProgradeToRetrograde(jde), date.Location(), false)
}
// NextProgradeToRetrograde 下次留(顺转逆)
// 返回下次顺转逆留的时间
func NextProgradeToRetrograde(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.NextJupiterProgradeToRetrograde(jde), date.Location(), false)
}
// LastRetrogradeToPrograde 上次留(逆转瞬)
// 返回上次逆转瞬留的时间
func LastRetrogradeToPrograde(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.LastJupiterRetrogradeToPrograde(jde), date.Location(), false)
}
// NextRetrogradeToPrograde 上次留(逆转瞬)
//// 返回上次逆转瞬留的时间
func NextRetrogradeToPrograde(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.NextJupiterRetrogradeToPrograde(jde), date.Location(), false)
}
// LastEasternQuadrature 上次东方照时间
// 返回上次东方照时间
func LastEasternQuadrature(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.LastJupiterEasternQuadrature(jde), date.Location(), false)
}
// NextEasternQuadrature 下次东方照时间
// 返回下次东方照时间
func NextEasternQuadrature(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.NextJupiterEasternQuadrature(jde), date.Location(), false)
}
// LastWesternQuadrature 上次西方照时间
// 返回上次西方照时间
func LastWesternQuadrature(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.LastJupiterWesternQuadrature(jde), date.Location(), false)
}
// NextWesternQuadrature 下次西方照时间
// 返回下次西方照时间
func NextWesternQuadrature(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.NextJupiterWesternQuadrature(jde), date.Location(), false)
} }

@ -2,69 +2,239 @@ package mars
import ( import (
"b612.me/astro/basic" "b612.me/astro/basic"
"b612.me/astro/calendar"
"b612.me/astro/planet" "b612.me/astro/planet"
"errors"
"time"
) )
/* var (
ERR_MARS_NEVER_RISE = errors.New("ERROR:极夜,火星今日永远在地平线下!")
jde: UTC ERR_MARS_NEVER_DOWN = errors.New("ERROR:极昼,火星今日永远在地平线上!")
*/ )
func SeeLo(jde float64) float64 {
return basic.MarsSeeLo(basic.TD2UT(jde, true)) // ApparentLo 视黄经
func ApparentLo(date time.Time) float64 {
jde := calendar.Date2JDE(date)
return basic.MarsApparentLo(basic.TD2UT(jde, true))
} }
/* // ApparentBo 视黄纬
func ApparentBo(date time.Time) float64 {
jde: UTC jde := calendar.Date2JDE(date)
*/ return basic.MarsApparentBo(basic.TD2UT(jde, true))
func SeeBo(jde float64) float64 {
return basic.MarsSeeBo(basic.TD2UT(jde, true))
} }
/* // ApparentRa 视赤经
func ApparentRa(date time.Time) float64 {
jde: UTC jde := calendar.Date2JDE(date)
*/ return basic.MarsApparentRa(basic.TD2UT(jde, true))
func SeeRa(jde float64) float64 {
return basic.MarsSeeRa(basic.TD2UT(jde, true))
} }
/* // ApparentDec 视赤纬
func ApparentDec(date time.Time) float64 {
jde: UTC jde := calendar.Date2JDE(date)
*/ return basic.MarsApparentDec(basic.TD2UT(jde, true))
func SeeDec(jde float64) float64 {
return basic.MarsSeeDec(basic.TD2UT(jde, true))
} }
/* // ApparentRaDec 视赤经赤纬
func ApparentRaDec(date time.Time) (float64, float64) {
jde: UTC jde := calendar.Date2JDE(date)
*/ return basic.MarsApparentRaDec(basic.TD2UT(jde, true))
func SeeRaDec(jde float64) (float64, float64) {
return basic.MarsSeeRaDec(basic.TD2UT(jde, true))
} }
/* // ApparentMagnitude 视星等
func ApparentMagnitude(date time.Time) float64 {
jde: UTC jde := calendar.Date2JDE(date)
*/
func SeeMag(jde float64) float64 {
return basic.MarsMag(basic.TD2UT(jde, true)) return basic.MarsMag(basic.TD2UT(jde, true))
} }
/* // EarthDistance 与地球距离(天文单位)
func EarthDistance(date time.Time) float64 {
jde: UTC jde := calendar.Date2JDE(date)
*/
func EarthAway(jde float64) float64 {
return basic.EarthMarsAway(basic.TD2UT(jde, true)) return basic.EarthMarsAway(basic.TD2UT(jde, true))
} }
/* // EarthDistance 与太阳距离(天文单位)
func SunDistance(date time.Time) float64 {
jde: UTC jde := calendar.Date2JDE(date)
*/ return planet.WherePlanet(3, 2, basic.TD2UT(jde, true))
func SunAway(jde float64) float64 { }
return planet.WherePlanet(1, 2, basic.TD2UT(jde, true))
// Zenith 高度角
func Zenith(date time.Time, lon, lat float64) float64 {
jde := basic.Date2JDE(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
return basic.MarsHeight(jde, lon, lat, timezone)
}
// Azimuth 方位角
func Azimuth(date time.Time, lon, lat float64) float64 {
jde := basic.Date2JDE(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
return basic.MarsAzimuth(jde, lon, lat, timezone)
}
// HourAngle 时角
// 返回给定经纬度、对应date时区date时刻的时角
func HourAngle(date time.Time, lon float64) float64 {
jde := basic.Date2JDE(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
return basic.MarsHourAngle(jde, lon, timezone)
}
// CulminationTime 中天时间
// 返回给定经纬度、对应date时区date时刻的中天日期
func CulminationTime(date time.Time, lon float64) time.Time {
if date.Hour() > 12 {
date = date.Add(time.Hour * -12)
}
jde := basic.Date2JDE(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
calcJde := basic.MarsCulminationTime(jde, lon, timezone) - timezone/24.00
return basic.JDE2DateByZone(calcJde, date.Location(), false)
}
// RiseTime 升起时间
// date取日期时区忽略
// lon经度东正西负
// lat纬度北正南负
// height高度
// aerotrue时进行大气修正
func RiseTime(date time.Time, lon, lat, height float64, aero bool) (time.Time, error) {
var err error
var aeroFloat float64
if aero {
aeroFloat = 1
}
if date.Hour() > 12 {
date = date.Add(time.Hour * -12)
}
jde := basic.Date2JDE(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
riseJde := basic.MarsRiseTime(jde, lon, lat, timezone, aeroFloat, height)
if riseJde == -2 {
err = ERR_MARS_NEVER_RISE
}
if riseJde == -1 {
err = ERR_MARS_NEVER_DOWN
}
return basic.JDE2DateByZone(riseJde, date.Location(), true), err
}
// DownTime 落下时间
// date取日期时区忽略
// lon经度东正西负
// lat纬度北正南负
// height高度
// aerotrue时进行大气修正
func DownTime(date time.Time, lon, lat, height float64, aero bool) (time.Time, error) {
var err error
var aeroFloat float64
if aero {
aeroFloat = 1
}
if date.Hour() > 12 {
date = date.Add(time.Hour * -12)
}
jde := basic.Date2JDE(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
riseJde := basic.MarsDownTime(jde, lon, lat, timezone, aeroFloat, height)
if riseJde == -2 {
err = ERR_MARS_NEVER_RISE
}
if riseJde == -1 {
err = ERR_MARS_NEVER_DOWN
}
return basic.JDE2DateByZone(riseJde, date.Location(), true), err
}
// LastConjunction 上次合日时间
// 返回上次合日时间
func LastConjunction(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.LastMarsConjunction(jde), date.Location(), false)
}
// NextConjunction 下次合日时间
// 返回下次合日时间
func NextConjunction(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.NextMarsConjunction(jde), date.Location(), false)
}
// LastOpposition 上次冲日时间
// 返回上次冲日时间
func LastOpposition(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.LastMarsOpposition(jde), date.Location(), false)
}
// NextOpposition 下次冲日时间
// 返回下次冲日时间
func NextOpposition(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.NextMarsOpposition(jde), date.Location(), false)
}
// LastProgradeToRetrograde 上次留(顺转逆)
// 返回上次顺转逆留的时间
func LastProgradeToRetrograde(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.LastMarsProgradeToRetrograde(jde), date.Location(), false)
}
// NextProgradeToRetrograde 下次留(顺转逆)
// 返回下次顺转逆留的时间
func NextProgradeToRetrograde(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.NextMarsProgradeToRetrograde(jde), date.Location(), false)
}
// LastRetrogradeToPrograde 上次留(逆转瞬)
// 返回上次逆转瞬留的时间
func LastRetrogradeToPrograde(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.LastMarsRetrogradeToPrograde(jde), date.Location(), false)
}
// NextRetrogradeToPrograde 上次留(逆转瞬)
//// 返回上次逆转瞬留的时间
func NextRetrogradeToPrograde(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.NextMarsRetrogradeToPrograde(jde), date.Location(), false)
}
// LastEasternQuadrature 上次东方照时间
// 返回上次东方照时间
func LastEasternQuadrature(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.LastMarsEasternQuadrature(jde), date.Location(), false)
}
// NextEasternQuadrature 下次东方照时间
// 返回下次东方照时间
func NextEasternQuadrature(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.NextMarsEasternQuadrature(jde), date.Location(), false)
}
// LastWesternQuadrature 上次西方照时间
// 返回上次西方照时间
func LastWesternQuadrature(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.LastMarsWesternQuadrature(jde), date.Location(), false)
}
// NextWesternQuadrature 下次西方照时间
// 返回下次西方照时间
func NextWesternQuadrature(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.NextMarsWesternQuadrature(jde), date.Location(), false)
} }

@ -2,69 +2,281 @@ package mercury
import ( import (
"b612.me/astro/basic" "b612.me/astro/basic"
"b612.me/astro/calendar"
"b612.me/astro/planet" "b612.me/astro/planet"
"errors"
"time"
) )
/* var (
ERR_MERCURY_NEVER_RISE = errors.New("ERROR:极夜,水星今日永远在地平线下!")
jde: UTC ERR_MERCURY_NEVER_DOWN = errors.New("ERROR:极昼,水星今日永远在地平线上!")
*/ )
func SeeLo(jde float64) float64 {
return basic.MercurySeeLo(basic.TD2UT(jde, true)) // ApparentLo 视黄经
func ApparentLo(date time.Time) float64 {
jde := calendar.Date2JDE(date)
return basic.MercuryApparentLo(basic.TD2UT(jde, true))
} }
/* // ApparentBo 视黄纬
func ApparentBo(date time.Time) float64 {
jde: UTC jde := calendar.Date2JDE(date)
*/ return basic.MercuryApparentBo(basic.TD2UT(jde, true))
func SeeBo(jde float64) float64 {
return basic.MercurySeeBo(basic.TD2UT(jde, true))
} }
/* // ApparentRa 视赤经
func ApparentRa(date time.Time) float64 {
jde: UTC jde := calendar.Date2JDE(date)
*/ return basic.MercuryApparentRa(basic.TD2UT(jde, true))
func SeeRa(jde float64) float64 {
return basic.MercurySeeRa(basic.TD2UT(jde, true))
} }
/* // ApparentDec 视赤纬
func ApparentDec(date time.Time) float64 {
jde: UTC jde := calendar.Date2JDE(date)
*/ return basic.MercuryApparentDec(basic.TD2UT(jde, true))
func SeeDec(jde float64) float64 {
return basic.MercurySeeDec(basic.TD2UT(jde, true))
} }
/* // ApparentRaDec 视赤经赤纬
func ApparentRaDec(date time.Time) (float64, float64) {
jde: UTC jde := calendar.Date2JDE(date)
*/ return basic.MercuryApparentRaDec(basic.TD2UT(jde, true))
func SeeRaDec(jde float64) (float64, float64) {
return basic.MercurySeeRaDec(basic.TD2UT(jde, true))
} }
/* // ApparentMagnitude 视星等
func ApparentMagnitude(date time.Time) float64 {
jde: UTC jde := calendar.Date2JDE(date)
*/
func SeeMag(jde float64) float64 {
return basic.MercuryMag(basic.TD2UT(jde, true)) return basic.MercuryMag(basic.TD2UT(jde, true))
} }
/* // EarthDistance 与地球距离(天文单位)
func EarthDistance(date time.Time) float64 {
jde: UTC jde := calendar.Date2JDE(date)
*/
func EarthAway(jde float64) float64 {
return basic.EarthMercuryAway(basic.TD2UT(jde, true)) return basic.EarthMercuryAway(basic.TD2UT(jde, true))
} }
/* // EarthDistance 与太阳距离(天文单位)
func SunDistance(date time.Time) float64 {
jde: UTC jde := calendar.Date2JDE(date)
*/
func SunAway(jde float64) float64 {
return planet.WherePlanet(1, 2, basic.TD2UT(jde, true)) return planet.WherePlanet(1, 2, basic.TD2UT(jde, true))
} }
// Zenith 高度角
func Zenith(date time.Time, lon, lat float64) float64 {
jde := basic.Date2JDE(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
return basic.MercuryHeight(jde, lon, lat, timezone)
}
// Azimuth 方位角
func Azimuth(date time.Time, lon, lat float64) float64 {
jde := basic.Date2JDE(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
return basic.MercuryAzimuth(jde, lon, lat, timezone)
}
// HourAngle 时角
// 返回给定经纬度、对应date时区date时刻的时角
func HourAngle(date time.Time, lon float64) float64 {
jde := basic.Date2JDE(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
return basic.MercuryHourAngle(jde, lon, timezone)
}
// CulminationTime 中天时间
// 返回给定经纬度、对应date时区date时刻的中天日期
func CulminationTime(date time.Time, lon float64) time.Time {
if date.Hour() > 12 {
date = date.Add(time.Hour * -12)
}
jde := basic.Date2JDE(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
calcJde := basic.MercuryCulminationTime(jde, lon, timezone) - timezone/24.00
return basic.JDE2DateByZone(calcJde, date.Location(), false)
}
// RiseTime 升起时间
// date取日期时区忽略
// lon经度东正西负
// lat纬度北正南负
// height高度
// aerotrue时进行大气修正
func RiseTime(date time.Time, lon, lat, height float64, aero bool) (time.Time, error) {
var err error
var aeroFloat float64
if aero {
aeroFloat = 1
}
if date.Hour() > 12 {
date = date.Add(time.Hour * -12)
}
jde := basic.Date2JDE(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
riseJde := basic.MercuryRiseTime(jde, lon, lat, timezone, aeroFloat, height)
if riseJde == -2 {
err = ERR_MERCURY_NEVER_RISE
}
if riseJde == -1 {
err = ERR_MERCURY_NEVER_DOWN
}
return basic.JDE2DateByZone(riseJde, date.Location(), true), err
}
// DownTime 落下时间
// date取日期时区忽略
// lon经度东正西负
// lat纬度北正南负
// height高度
// aerotrue时进行大气修正
func DownTime(date time.Time, lon, lat, height float64, aero bool) (time.Time, error) {
var err error
var aeroFloat float64
if aero {
aeroFloat = 1
}
if date.Hour() > 12 {
date = date.Add(time.Hour * -12)
}
jde := basic.Date2JDE(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
riseJde := basic.MercuryDownTime(jde, lon, lat, timezone, aeroFloat, height)
if riseJde == -2 {
err = ERR_MERCURY_NEVER_RISE
}
if riseJde == -1 {
err = ERR_MERCURY_NEVER_DOWN
}
return basic.JDE2DateByZone(riseJde, date.Location(), true), err
}
// LastConjunction 上次合日时间
// 返回上次合日时间,不区分上合下合
func LastConjunction(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.LastMercuryConjunction(jde), date.Location(), false)
}
// NextConjunction 下次合日时间
// 返回下次合日时间,不区分上合下合
func NextConjunction(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.NextMercuryConjunction(jde), date.Location(), false)
}
// LastInferiorConjunction 上次下合时间
// 返回上次下合日时间
func LastInferiorConjunction(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.LastMercuryInferiorConjunction(jde), date.Location(), false)
}
// NextInferiorConjunction 下次下合时间
// 返回下次合日时间
func NextInferiorConjunction(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.NextMercuryInferiorConjunction(jde), date.Location(), false)
}
// LastSuperiorConjunction 上次上合时间
// 返回上次下合时间
func LastSuperiorConjunction(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.LastMercurySuperiorConjunction(jde), date.Location(), false)
}
// NextSuperiorConjunction 下次上合时间
// 返回下次上合时间
func NextSuperiorConjunction(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.NextMercurySuperiorConjunction(jde), date.Location(), false)
}
// LastRetrograde 上次留的时间
// 返回上次留时间,不区分顺逆
func LastRetrograde(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.LastMercuryRetrograde(jde), date.Location(), false)
}
// NextRetrograde 下次留时间
// 返回下次留的时间,不区分顺逆
func NextRetrograde(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.NextMercuryRetrograde(jde), date.Location(), false)
}
// LastProgradeToRetrograde 上次留(顺转逆)
// 返回上次顺转逆留的时间
func LastProgradeToRetrograde(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.LastMercuryProgradeToRetrograde(jde), date.Location(), false)
}
// NextProgradeToRetrograde 下次留(顺转逆)
// 返回下次顺转逆留的时间
func NextProgradeToRetrograde(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.NextMercuryProgradeToRetrograde(jde), date.Location(), false)
}
// LastRetrogradeToPrograde 上次留(逆转瞬)
// 返回上次逆转瞬留的时间
func LastRetrogradeToPrograde(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.LastMercuryRetrogradeToPrograde(jde), date.Location(), false)
}
// NextRetrogradeToPrograde 上次留(逆转瞬)
//// 返回上次逆转瞬留的时间
func NextRetrogradeToPrograde(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.NextMercuryRetrogradeToPrograde(jde), date.Location(), false)
}
// LastGreatestElongation 上次大距时间
// 返回上次大距时间,不区分东西大距
func LastGreatestElongation(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.LastMercuryGreatestElongation(jde), date.Location(), false)
}
// NextGreatestElongation 下次大距时间
// 返回下次大距时间,不区分东西大距
func NextGreatestElongation(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.NextMercuryGreatestElongation(jde), date.Location(), false)
}
// LastGreatestElongationEast 上次东大距时间
// 返回上次东大距时间
func LastGreatestElongationEast(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.LastMercuryGreatestElongationEast(jde), date.Location(), false)
}
// NextGreatestElongationEast 下次东大距时间
// 返回下次东大距时间
func NextGreatestElongationEast(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.NextMercuryGreatestElongationEast(jde), date.Location(), false)
}
// LastGreatestElongationWest 上次西大距时间
// 返回上次西大距时间
func LastGreatestElongationWest(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.LastMercuryGreatestElongationWest(jde), date.Location(), false)
}
// NextGreatestElongationWest 下次西大距时间
// 返回下次西大距时间
func NextGreatestElongationWest(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.NextMercuryGreatestElongationWest(jde), date.Location(), false)
}

@ -0,0 +1,14 @@
package mercury
import (
"fmt"
"testing"
"time"
)
func TestMercury(t *testing.T) {
date := time.Now().Add(time.Hour * -24)
fmt.Println(CulminationTime(date, 115))
fmt.Println(RiseTime(date, 115, 23, 0, false))
fmt.Println(DownTime(date, 115, 23, 0, false))
}

@ -127,7 +127,7 @@ func Zenith(date time.Time, lon, lat float64) float64 {
func CulminationTime(date time.Time, lon, lat float64) float64 { func CulminationTime(date time.Time, lon, lat float64) float64 {
jde := basic.Date2JDE(date) jde := basic.Date2JDE(date)
_, loc := date.Zone() _, loc := date.Zone()
return basic.GetMoonTZTime(jde, lon, lat, float64(loc)/3600.0) return basic.MoonCulminationTime(jde, lon, lat, float64(loc)/3600.0)
} }
// RiseTime 月亮升起时间 // RiseTime 月亮升起时间

@ -2,69 +2,239 @@ package neptune
import ( import (
"b612.me/astro/basic" "b612.me/astro/basic"
"b612.me/astro/calendar"
"b612.me/astro/planet" "b612.me/astro/planet"
"errors"
"time"
) )
/* var (
ERR_NEPTUNE_NEVER_RISE = errors.New("ERROR:极夜,海王星今日永远在地平线下!")
jde: UTC ERR_NEPTUNE_NEVER_DOWN = errors.New("ERROR:极昼,海王星今日永远在地平线上!")
*/ )
func SeeLo(jde float64) float64 {
return basic.NeptuneSeeLo(basic.TD2UT(jde, true)) // ApparentLo 视黄经
func ApparentLo(date time.Time) float64 {
jde := calendar.Date2JDE(date)
return basic.NeptuneApparentLo(basic.TD2UT(jde, true))
} }
/* // ApparentBo 视黄纬
func ApparentBo(date time.Time) float64 {
jde: UTC jde := calendar.Date2JDE(date)
*/ return basic.NeptuneApparentBo(basic.TD2UT(jde, true))
func SeeBo(jde float64) float64 {
return basic.NeptuneSeeBo(basic.TD2UT(jde, true))
} }
/* // ApparentRa 视赤经
func ApparentRa(date time.Time) float64 {
jde: UTC jde := calendar.Date2JDE(date)
*/ return basic.NeptuneApparentRa(basic.TD2UT(jde, true))
func SeeRa(jde float64) float64 {
return basic.NeptuneSeeRa(basic.TD2UT(jde, true))
} }
/* // ApparentDec 视赤纬
func ApparentDec(date time.Time) float64 {
jde: UTC jde := calendar.Date2JDE(date)
*/ return basic.NeptuneApparentDec(basic.TD2UT(jde, true))
func SeeDec(jde float64) float64 {
return basic.NeptuneSeeDec(basic.TD2UT(jde, true))
} }
/* // ApparentRaDec 视赤经赤纬
func ApparentRaDec(date time.Time) (float64, float64) {
jde: UTC jde := calendar.Date2JDE(date)
*/ return basic.NeptuneApparentRaDec(basic.TD2UT(jde, true))
func SeeRaDec(jde float64) (float64, float64) {
return basic.NeptuneSeeRaDec(basic.TD2UT(jde, true))
} }
/* // ApparentMagnitude 视星等
func ApparentMagnitude(date time.Time) float64 {
jde: UTC jde := calendar.Date2JDE(date)
*/
func SeeMag(jde float64) float64 {
return basic.NeptuneMag(basic.TD2UT(jde, true)) return basic.NeptuneMag(basic.TD2UT(jde, true))
} }
/* // EarthDistance 与地球距离(天文单位)
func EarthDistance(date time.Time) float64 {
jde: UTC jde := calendar.Date2JDE(date)
*/
func EarthAway(jde float64) float64 {
return basic.EarthNeptuneAway(basic.TD2UT(jde, true)) return basic.EarthNeptuneAway(basic.TD2UT(jde, true))
} }
/* // EarthDistance 与太阳距离(天文单位)
func SunDistance(date time.Time) float64 {
jde: UTC jde := calendar.Date2JDE(date)
*/ return planet.WherePlanet(7, 2, basic.TD2UT(jde, true))
func SunAway(jde float64) float64 { }
return planet.WherePlanet(1, 2, basic.TD2UT(jde, true))
// Zenith 高度角
func Zenith(date time.Time, lon, lat float64) float64 {
jde := basic.Date2JDE(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
return basic.NeptuneHeight(jde, lon, lat, timezone)
}
// Azimuth 方位角
func Azimuth(date time.Time, lon, lat float64) float64 {
jde := basic.Date2JDE(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
return basic.NeptuneAzimuth(jde, lon, lat, timezone)
}
// HourAngle 时角
// 返回给定经纬度、对应date时区date时刻的时角
func HourAngle(date time.Time, lon float64) float64 {
jde := basic.Date2JDE(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
return basic.NeptuneHourAngle(jde, lon, timezone)
}
// CulminationTime 中天时间
// 返回给定经纬度、对应date时区date时刻的中天日期
func CulminationTime(date time.Time, lon float64) time.Time {
if date.Hour() > 12 {
date = date.Add(time.Hour * -12)
}
jde := basic.Date2JDE(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
calcJde := basic.NeptuneCulminationTime(jde, lon, timezone) - timezone/24.00
return basic.JDE2DateByZone(calcJde, date.Location(), false)
}
// RiseTime 升起时间
// date取日期时区忽略
// lon经度东正西负
// lat纬度北正南负
// height高度
// aerotrue时进行大气修正
func RiseTime(date time.Time, lon, lat, height float64, aero bool) (time.Time, error) {
var err error
var aeroFloat float64
if aero {
aeroFloat = 1
}
if date.Hour() > 12 {
date = date.Add(time.Hour * -12)
}
jde := basic.Date2JDE(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
riseJde := basic.NeptuneRiseTime(jde, lon, lat, timezone, aeroFloat, height)
if riseJde == -2 {
err = ERR_NEPTUNE_NEVER_RISE
}
if riseJde == -1 {
err = ERR_NEPTUNE_NEVER_DOWN
}
return basic.JDE2DateByZone(riseJde, date.Location(), true), err
}
// DownTime 落下时间
// date取日期时区忽略
// lon经度东正西负
// lat纬度北正南负
// height高度
// aerotrue时进行大气修正
func DownTime(date time.Time, lon, lat, height float64, aero bool) (time.Time, error) {
var err error
var aeroFloat float64
if aero {
aeroFloat = 1
}
if date.Hour() > 12 {
date = date.Add(time.Hour * -12)
}
jde := basic.Date2JDE(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
riseJde := basic.NeptuneDownTime(jde, lon, lat, timezone, aeroFloat, height)
if riseJde == -2 {
err = ERR_NEPTUNE_NEVER_RISE
}
if riseJde == -1 {
err = ERR_NEPTUNE_NEVER_DOWN
}
return basic.JDE2DateByZone(riseJde, date.Location(), true), err
}
// LastConjunction 上次合日时间
// 返回上次合日时间
func LastConjunction(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.LastNeptuneConjunction(jde), date.Location(), false)
}
// NextConjunction 下次合日时间
// 返回下次合日时间
func NextConjunction(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.NextNeptuneConjunction(jde), date.Location(), false)
}
// LastOpposition 上次冲日时间
// 返回上次冲日时间
func LastOpposition(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.LastNeptuneOpposition(jde), date.Location(), false)
}
// NextOpposition 下次冲日时间
// 返回下次冲日时间
func NextOpposition(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.NextNeptuneOpposition(jde), date.Location(), false)
}
// LastProgradeToRetrograde 上次留(顺转逆)
// 返回上次顺转逆留的时间
func LastProgradeToRetrograde(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.LastNeptuneProgradeToRetrograde(jde), date.Location(), false)
}
// NextProgradeToRetrograde 下次留(顺转逆)
// 返回下次顺转逆留的时间
func NextProgradeToRetrograde(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.NextNeptuneProgradeToRetrograde(jde), date.Location(), false)
}
// LastRetrogradeToPrograde 上次留(逆转瞬)
// 返回上次逆转瞬留的时间
func LastRetrogradeToPrograde(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.LastNeptuneRetrogradeToPrograde(jde), date.Location(), false)
}
// NextRetrogradeToPrograde 上次留(逆转瞬)
//// 返回上次逆转瞬留的时间
func NextRetrogradeToPrograde(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.NextNeptuneRetrogradeToPrograde(jde), date.Location(), false)
}
// LastEasternQuadrature 上次东方照时间
// 返回上次东方照时间
func LastEasternQuadrature(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.LastNeptuneEasternQuadrature(jde), date.Location(), false)
}
// NextEasternQuadrature 下次东方照时间
// 返回下次东方照时间
func NextEasternQuadrature(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.NextNeptuneEasternQuadrature(jde), date.Location(), false)
}
// LastWesternQuadrature 上次西方照时间
// 返回上次西方照时间
func LastWesternQuadrature(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.LastNeptuneWesternQuadrature(jde), date.Location(), false)
}
// NextWesternQuadrature 下次西方照时间
// 返回下次西方照时间
func NextWesternQuadrature(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.NextNeptuneWesternQuadrature(jde), date.Location(), false)
} }

@ -0,0 +1,14 @@
package neptune
import (
"fmt"
"testing"
"time"
)
func TestNeptune(t *testing.T) {
date := time.Now().Add(time.Hour * -24)
fmt.Println(CulminationTime(date, 115))
fmt.Println(RiseTime(date, 115, 23, 0, false))
fmt.Println(DownTime(date, 115, 23, 0, false))
}

@ -1,9 +1,10 @@
package planet package planet
import ( import (
"math"
. "b612.me/astro/tools" . "b612.me/astro/tools"
"math"
) )
func WherePlanet(xt, zn int, jd float64) float64 { func WherePlanet(xt, zn int, jd float64) float64 {
var XL0 [][]float64 var XL0 [][]float64
XL0 = [][]float64{ XL0 = [][]float64{
@ -141,7 +142,6 @@ func WherePlanet(xt, zn int, jd float64) float64 {
/*R4*/ 1202, 1.4150, 220.4126, 708, 1.162, 213.299, 516, 6.240, 206.186, 427, 2.469, 7.114, 268, 0.187, 426.598, 170, 5.959, 199.072, 150, 0.480, 433.712, 145, 1.442, 227.526, 121, 2.405, 14.227, 47, 5.57, 639.90, 19, 5.86, 647.01, 17, 0.53, 440.83, 16, 2.90, 110.21, 15, 0.30, 419.48, 14, 1.30, 412.37, 13, 2.09, 323.51, 11, 0.22, 95.98, 11, 2.46, 117.32, 10, 3.14, 0.00, 9, 1.56, 88.87, 9, 2.28, 21.34, 9, 0.68, 216.48, 8, 1.27, 234.64, 8, 4.49, 853.20, 8, 3.59, 302.16, 6, 5.17, 103.09, 5, 2.59, 515.46, 4, 4.97, 860.31, 4, 0.02, 191.96, 4, 5.97, 654.12, 4, 1.60, 330.62, 4, 1.60, 405.26, 4, 3.30, 210.12, 3, 2.73, 522.58, 3, 0.75, 209.37, 3, 1.32, 728.76, 2, 1.19, 124.43, 2, 0.49, 447.94, 2, 3.28, 203.00, 2, 0.73, 625.67, 2, 6.15, 429.78, 2, 0.75, 295.05, 2, 3.89, 1066.50, 2, 2.00, 831.86, 2, 0.09, 942.06, 2, 0.82, 223.59, 2, 1.40, 224.34, 2, 3.02, 184.84, 2, 5.41, 824.74, 2, 5.96, 422.67, 1, 2.12, 529.69, 1, 0.72, 536.80, 1, 1.65, 17.41, 1, 1.90, 956.29, 1, 5.97, 195.14, 1, 1.12, 838.97, 1, 0.89, 721.65, 1, 1.59, 735.88, 1, 3.06, 1574.85, 1, 1.01, 1045.15, 1, 5.36, 316.39, 1, 4.93, 56.62, 1, 2.72, 508.35, 1, 1.11, 1169.59, /*R4*/ 1202, 1.4150, 220.4126, 708, 1.162, 213.299, 516, 6.240, 206.186, 427, 2.469, 7.114, 268, 0.187, 426.598, 170, 5.959, 199.072, 150, 0.480, 433.712, 145, 1.442, 227.526, 121, 2.405, 14.227, 47, 5.57, 639.90, 19, 5.86, 647.01, 17, 0.53, 440.83, 16, 2.90, 110.21, 15, 0.30, 419.48, 14, 1.30, 412.37, 13, 2.09, 323.51, 11, 0.22, 95.98, 11, 2.46, 117.32, 10, 3.14, 0.00, 9, 1.56, 88.87, 9, 2.28, 21.34, 9, 0.68, 216.48, 8, 1.27, 234.64, 8, 4.49, 853.20, 8, 3.59, 302.16, 6, 5.17, 103.09, 5, 2.59, 515.46, 4, 4.97, 860.31, 4, 0.02, 191.96, 4, 5.97, 654.12, 4, 1.60, 330.62, 4, 1.60, 405.26, 4, 3.30, 210.12, 3, 2.73, 522.58, 3, 0.75, 209.37, 3, 1.32, 728.76, 2, 1.19, 124.43, 2, 0.49, 447.94, 2, 3.28, 203.00, 2, 0.73, 625.67, 2, 6.15, 429.78, 2, 0.75, 295.05, 2, 3.89, 1066.50, 2, 2.00, 831.86, 2, 0.09, 942.06, 2, 0.82, 223.59, 2, 1.40, 224.34, 2, 3.02, 184.84, 2, 5.41, 824.74, 2, 5.96, 422.67, 1, 2.12, 529.69, 1, 0.72, 536.80, 1, 1.65, 17.41, 1, 1.90, 956.29, 1, 5.97, 195.14, 1, 1.12, 838.97, 1, 0.89, 721.65, 1, 1.59, 735.88, 1, 3.06, 1574.85, 1, 1.01, 1045.15, 1, 5.36, 316.39, 1, 4.93, 56.62, 1, 2.72, 508.35, 1, 1.11, 1169.59,
/*R5*/ 129, 5.913, 220.413, 32, 0.69, 7.11, 27, 5.91, 227.53, 20, 4.95, 433.71, 20, 0.67, 14.23, 14, 2.67, 206.19, 14, 1.46, 199.07, 13, 4.59, 426.60, 7, 4.63, 213.30, 5, 3.61, 639.90, 4, 4.90, 440.83, 3, 4.07, 647.01, 3, 4.66, 191.96, 3, 0.49, 323.51, 3, 3.18, 419.48, 2, 3.70, 88.87, 2, 3.32, 95.98, 2, 0.56, 117.32, 2, 5.33, 302.16, 2, 0.00, 0.00, 2, 2.67, 853.20, 2, 0.86, 515.46, 1, 5.83, 234.64, 1, 0.16, 412.37, 1, 5.98, 3.18, 1, 5.23, 216.48, 1, 5.05, 124.43, 1, 0.37, 28.45}, /*R5*/ 129, 5.913, 220.413, 32, 0.69, 7.11, 27, 5.91, 227.53, 20, 4.95, 433.71, 20, 0.67, 14.23, 14, 2.67, 206.19, 14, 1.46, 199.07, 13, 4.59, 426.60, 7, 4.63, 213.30, 5, 3.61, 639.90, 4, 4.90, 440.83, 3, 4.07, 647.01, 3, 4.66, 191.96, 3, 0.49, 323.51, 3, 3.18, 419.48, 2, 3.70, 88.87, 2, 3.32, 95.98, 2, 0.56, 117.32, 2, 5.33, 302.16, 2, 0.00, 0.00, 2, 2.67, 853.20, 2, 0.86, 515.46, 1, 5.83, 234.64, 1, 0.16, 412.37, 1, 5.98, 3.18, 1, 5.23, 216.48, 1, 5.05, 124.43, 1, 0.37, 28.45},
//Dura精度:J2000+-4千年 黄经1角秒 黄纬1角秒 距离20AU/10^6 //Dura精度:J2000+-4千年 黄经1角秒 黄纬1角秒 距离20AU/10^6
[]float64{ []float64{
100000000, //A的倍率 100000000, //A的倍率
@ -183,42 +183,40 @@ func WherePlanet(xt, zn int, jd float64) float64 {
/*R1*/ 236339, 0.704980, 38.133036, 13220, 3.32015, 1.48447, 8622, 6.2163, 35.1641, 2702, 1.8814, 39.6175, 2155, 2.0943, 2.9689, 2153, 5.1687, 76.2661, 1603, 0.0000, 0.0000, 1464, 1.1842, 33.6796, 1136, 3.9189, 36.6486, 898, 5.241, 388.465, 790, 0.533, 168.053, 760, 0.021, 182.280, 607, 1.077, 1021.249, 572, 3.401, 484.444, 561, 2.887, 498.671, 490, 3.468, 137.033, 271, 3.274, 71.813, 264, 0.862, 4.453, 204, 2.418, 32.195, 155, 0.365, 41.102, 133, 3.602, 9.561, /*R1*/ 236339, 0.704980, 38.133036, 13220, 3.32015, 1.48447, 8622, 6.2163, 35.1641, 2702, 1.8814, 39.6175, 2155, 2.0943, 2.9689, 2153, 5.1687, 76.2661, 1603, 0.0000, 0.0000, 1464, 1.1842, 33.6796, 1136, 3.9189, 36.6486, 898, 5.241, 388.465, 790, 0.533, 168.053, 760, 0.021, 182.280, 607, 1.077, 1021.249, 572, 3.401, 484.444, 561, 2.887, 498.671, 490, 3.468, 137.033, 271, 3.274, 71.813, 264, 0.862, 4.453, 204, 2.418, 32.195, 155, 0.365, 41.102, 133, 3.602, 9.561,
/*R2*/ 4247, 5.8991, 38.1330, 218, 0.346, 1.484, 163, 2.239, 168.053, 156, 4.594, 182.280, 127, 2.848, 35.164, 118, 5.103, 484.444, 112, 1.190, 498.671, 99, 3.42, 175.17, 77, 0.02, 491.56, 65, 3.46, 388.47, 50, 4.07, 76.27, 39, 6.10, 1021.25, 37, 5.97, 2.97, 36, 5.17, 137.03, /*R2*/ 4247, 5.8991, 38.1330, 218, 0.346, 1.484, 163, 2.239, 168.053, 156, 4.594, 182.280, 127, 2.848, 35.164, 118, 5.103, 484.444, 112, 1.190, 498.671, 99, 3.42, 175.17, 77, 0.02, 491.56, 65, 3.46, 388.47, 50, 4.07, 76.27, 39, 6.10, 1021.25, 37, 5.97, 2.97, 36, 5.17, 137.03,
/*R3*/ 166, 4.552, 38.133}, /*R3*/ 166, 4.552, 38.133},
} }
sata := 0 sata := 0
if(xt==-1){ if xt == -1 {
xt=0; xt = 0
sata=1; sata = 1
} }
rad := 180.0000 * 3600.0000 / math.Pi rad := 180.0000 * 3600.0000 / math.Pi
n:=-1; n := -1
t := (jd - 2451545) / 36525.0000 t := (jd - 2451545) / 36525.0000
t /= 10 //转为儒略千年数 t /= 10 //转为儒略千年数
tn := float64(1) tn := float64(1)
F :=XL0[xt]; F := XL0[xt]
pn := zn*6 + 1 pn := zn*6 + 1
N0 := F[pn+1]-F[pn]; //N0序列总数 N0 := F[pn+1] - F[pn] //N0序列总数
var N, v float64 var N, v float64
for i := 0; i < 6; i++ { for i := 0; i < 6; i++ {
n1 := F[pn+i] n1 := F[pn+i]
n2 := F[pn+1+i] n2 := F[pn+1+i]
n0 := n2 - n1 n0 := n2 - n1
if(n0==0) { if n0 == 0 {
continue continue
} }
if(n<0) { if n < 0 {
N = n2 //确定项数 N = n2 //确定项数
} else { } else {
N = math.Floor(3*float64(n)*n0/N0+0.5) + n1 N = math.Floor(3*float64(n)*n0/N0+0.5) + n1
} }
if(i!=0) { if i != 0 {
N += 3 N += 3
} }
if(N > n2) { if N > n2 {
N = n2 N = n2
} }
@ -226,14 +224,14 @@ func WherePlanet(xt, zn int, jd float64) float64 {
for j := n1; j < N; j += 3 { for j := n1; j < N; j += 3 {
c += F[int(j)] * math.Cos(F[int(j)+1]+t*F[int(j)+2]) c += F[int(j)] * math.Cos(F[int(j)+1]+t*F[int(j)+2])
} }
v += c*tn; v += c * tn
tn *= t tn *= t
} }
v /= F[0] v /= F[0]
if xt == 0 { //地球 if xt == 0 { //地球
t2 := t * t t2 := t * t
t3:=t2*t; //千年数的各次方 t3 := t2 * t //千年数的各次方
if zn == 0 { if zn == 0 {
v += (-0.0728 - 2.7702*t - 1.1019*t2 - 0.0996*t3) / rad v += (-0.0728 - 2.7702*t - 1.1019*t2 - 0.0996*t3) / rad
} else if zn == 1 { } else if zn == 1 {
@ -251,8 +249,8 @@ func WherePlanet(xt, zn int, jd float64) float64 {
-0.25486, +0.00276, +0.42926, //土星 -0.25486, +0.00276, +0.42926, //土星
+0.24588, +0.00345, -14.46266, //天王星 +0.24588, +0.00345, -14.46266, //天王星
-0.95116, +0.02481, +58.30651, //海王星 -0.95116, +0.02481, +58.30651, //海王星
}; }
dv := XL0_xzb[ (xt-1)*3+zn ]; dv := XL0_xzb[(xt-1)*3+zn]
if zn == 0 { if zn == 0 {
v += -3 * t / rad v += -3 * t / rad
} }
@ -277,9 +275,8 @@ func WherePlanet(xt, zn int, jd float64) float64 {
if xt > 0 && zn == 1 { if xt > 0 && zn == 1 {
return (v * 180 / math.Pi) return (v * 180 / math.Pi)
} }
if (xt>0 && zn==0){ if xt > 0 && zn == 0 {
return (Limit360(v * 180 / math.Pi)) return (Limit360(v * 180 / math.Pi))
} }
return v
return (v)
} }

@ -2,69 +2,239 @@ package saturn
import ( import (
"b612.me/astro/basic" "b612.me/astro/basic"
"b612.me/astro/calendar"
"b612.me/astro/planet" "b612.me/astro/planet"
"errors"
"time"
) )
/* var (
ERR_SATURN_NEVER_RISE = errors.New("ERROR:极夜,木星今日永远在地平线下!")
jde: UTC ERR_SATURN_NEVER_DOWN = errors.New("ERROR:极昼,木星今日永远在地平线上!")
*/ )
func SeeLo(jde float64) float64 {
return basic.SaturnSeeLo(basic.TD2UT(jde, true)) // ApparentLo 视黄经
func ApparentLo(date time.Time) float64 {
jde := calendar.Date2JDE(date)
return basic.SaturnApparentLo(basic.TD2UT(jde, true))
} }
/* // ApparentBo 视黄纬
func ApparentBo(date time.Time) float64 {
jde: UTC jde := calendar.Date2JDE(date)
*/ return basic.SaturnApparentBo(basic.TD2UT(jde, true))
func SeeBo(jde float64) float64 {
return basic.SaturnSeeBo(basic.TD2UT(jde, true))
} }
/* // ApparentRa 视赤经
func ApparentRa(date time.Time) float64 {
jde: UTC jde := calendar.Date2JDE(date)
*/ return basic.SaturnApparentRa(basic.TD2UT(jde, true))
func SeeRa(jde float64) float64 {
return basic.SaturnSeeRa(basic.TD2UT(jde, true))
} }
/* // ApparentDec 视赤纬
func ApparentDec(date time.Time) float64 {
jde: UTC jde := calendar.Date2JDE(date)
*/ return basic.SaturnApparentDec(basic.TD2UT(jde, true))
func SeeDec(jde float64) float64 {
return basic.SaturnSeeDec(basic.TD2UT(jde, true))
} }
/* // ApparentRaDec 视赤经赤纬
func ApparentRaDec(date time.Time) (float64, float64) {
jde: UTC jde := calendar.Date2JDE(date)
*/ return basic.SaturnApparentRaDec(basic.TD2UT(jde, true))
func SeeRaDec(jde float64) (float64, float64) {
return basic.SaturnSeeRaDec(basic.TD2UT(jde, true))
} }
/* // ApparentMagnitude 视星等
func ApparentMagnitude(date time.Time) float64 {
jde: UTC jde := calendar.Date2JDE(date)
*/
func SeeMag(jde float64) float64 {
return basic.SaturnMag(basic.TD2UT(jde, true)) return basic.SaturnMag(basic.TD2UT(jde, true))
} }
/* // EarthDistance 与地球距离(天文单位)
func EarthDistance(date time.Time) float64 {
jde: UTC jde := calendar.Date2JDE(date)
*/
func EarthAway(jde float64) float64 {
return basic.EarthSaturnAway(basic.TD2UT(jde, true)) return basic.EarthSaturnAway(basic.TD2UT(jde, true))
} }
/* // EarthDistance 与太阳距离(天文单位)
func SunDistance(date time.Time) float64 {
jde: UTC jde := calendar.Date2JDE(date)
*/ return planet.WherePlanet(5, 2, basic.TD2UT(jde, true))
func SunAway(jde float64) float64 { }
return planet.WherePlanet(1, 2, basic.TD2UT(jde, true))
// Zenith 高度角
func Zenith(date time.Time, lon, lat float64) float64 {
jde := basic.Date2JDE(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
return basic.SaturnHeight(jde, lon, lat, timezone)
}
// Azimuth 方位角
func Azimuth(date time.Time, lon, lat float64) float64 {
jde := basic.Date2JDE(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
return basic.SaturnAzimuth(jde, lon, lat, timezone)
}
// HourAngle 时角
// 返回给定经纬度、对应date时区date时刻的时角
func HourAngle(date time.Time, lon float64) float64 {
jde := basic.Date2JDE(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
return basic.SaturnHourAngle(jde, lon, timezone)
}
// CulminationTime 中天时间
// 返回给定经纬度、对应date时区date时刻的中天日期
func CulminationTime(date time.Time, lon float64) time.Time {
if date.Hour() > 12 {
date = date.Add(time.Hour * -12)
}
jde := basic.Date2JDE(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
calcJde := basic.SaturnCulminationTime(jde, lon, timezone) - timezone/24.00
return basic.JDE2DateByZone(calcJde, date.Location(), false)
}
// RiseTime 升起时间
// date取日期时区忽略
// lon经度东正西负
// lat纬度北正南负
// height高度
// aerotrue时进行大气修正
func RiseTime(date time.Time, lon, lat, height float64, aero bool) (time.Time, error) {
var err error
var aeroFloat float64
if aero {
aeroFloat = 1
}
if date.Hour() > 12 {
date = date.Add(time.Hour * -12)
}
jde := basic.Date2JDE(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
riseJde := basic.SaturnRiseTime(jde, lon, lat, timezone, aeroFloat, height)
if riseJde == -2 {
err = ERR_SATURN_NEVER_RISE
}
if riseJde == -1 {
err = ERR_SATURN_NEVER_DOWN
}
return basic.JDE2DateByZone(riseJde, date.Location(), true), err
}
// DownTime 落下时间
// date取日期时区忽略
// lon经度东正西负
// lat纬度北正南负
// height高度
// aerotrue时进行大气修正
func DownTime(date time.Time, lon, lat, height float64, aero bool) (time.Time, error) {
var err error
var aeroFloat float64
if aero {
aeroFloat = 1
}
if date.Hour() > 12 {
date = date.Add(time.Hour * -12)
}
jde := basic.Date2JDE(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
riseJde := basic.SaturnDownTime(jde, lon, lat, timezone, aeroFloat, height)
if riseJde == -2 {
err = ERR_SATURN_NEVER_RISE
}
if riseJde == -1 {
err = ERR_SATURN_NEVER_DOWN
}
return basic.JDE2DateByZone(riseJde, date.Location(), true), err
}
// LastConjunction 上次合日时间
// 返回上次合日时间
func LastConjunction(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.LastSaturnConjunction(jde), date.Location(), false)
}
// NextConjunction 下次合日时间
// 返回下次合日时间
func NextConjunction(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.NextSaturnConjunction(jde), date.Location(), false)
}
// LastOpposition 上次冲日时间
// 返回上次冲日时间
func LastOpposition(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.LastSaturnOpposition(jde), date.Location(), false)
}
// NextOpposition 下次冲日时间
// 返回下次冲日时间
func NextOpposition(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.NextSaturnOpposition(jde), date.Location(), false)
}
// LastProgradeToRetrograde 上次留(顺转逆)
// 返回上次顺转逆留的时间
func LastProgradeToRetrograde(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.LastSaturnProgradeToRetrograde(jde), date.Location(), false)
}
// NextProgradeToRetrograde 下次留(顺转逆)
// 返回下次顺转逆留的时间
func NextProgradeToRetrograde(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.NextSaturnProgradeToRetrograde(jde), date.Location(), false)
}
// LastRetrogradeToPrograde 上次留(逆转瞬)
// 返回上次逆转瞬留的时间
func LastRetrogradeToPrograde(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.LastSaturnRetrogradeToPrograde(jde), date.Location(), false)
}
// NextRetrogradeToPrograde 上次留(逆转瞬)
//// 返回上次逆转瞬留的时间
func NextRetrogradeToPrograde(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.NextSaturnRetrogradeToPrograde(jde), date.Location(), false)
}
// LastEasternQuadrature 上次东方照时间
// 返回上次东方照时间
func LastEasternQuadrature(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.LastSaturnEasternQuadrature(jde), date.Location(), false)
}
// NextEasternQuadrature 下次东方照时间
// 返回下次东方照时间
func NextEasternQuadrature(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.NextSaturnEasternQuadrature(jde), date.Location(), false)
}
// LastWesternQuadrature 上次西方照时间
// 返回上次西方照时间
func LastWesternQuadrature(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.LastSaturnWesternQuadrature(jde), date.Location(), false)
}
// NextWesternQuadrature 下次西方照时间
// 返回下次西方照时间
func NextWesternQuadrature(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.NextSaturnWesternQuadrature(jde), date.Location(), false)
} }

@ -2,69 +2,239 @@ package uranus
import ( import (
"b612.me/astro/basic" "b612.me/astro/basic"
"b612.me/astro/calendar"
"b612.me/astro/planet" "b612.me/astro/planet"
"errors"
"time"
) )
/* var (
ERR_URANUS_NEVER_RISE = errors.New("ERROR:极夜,天王星今日永远在地平线下!")
jde: UTC ERR_URANUS_NEVER_DOWN = errors.New("ERROR:极昼,天王星今日永远在地平线上!")
*/ )
func SeeLo(jde float64) float64 {
return basic.UranusSeeLo(basic.TD2UT(jde, true)) // ApparentLo 视黄经
func ApparentLo(date time.Time) float64 {
jde := calendar.Date2JDE(date)
return basic.UranusApparentLo(basic.TD2UT(jde, true))
} }
/* // ApparentBo 视黄纬
func ApparentBo(date time.Time) float64 {
jde: UTC jde := calendar.Date2JDE(date)
*/ return basic.UranusApparentBo(basic.TD2UT(jde, true))
func SeeBo(jde float64) float64 {
return basic.UranusSeeBo(basic.TD2UT(jde, true))
} }
/* // ApparentRa 视赤经
func ApparentRa(date time.Time) float64 {
jde: UTC jde := calendar.Date2JDE(date)
*/ return basic.UranusApparentRa(basic.TD2UT(jde, true))
func SeeRa(jde float64) float64 {
return basic.UranusSeeRa(basic.TD2UT(jde, true))
} }
/* // ApparentDec 视赤纬
func ApparentDec(date time.Time) float64 {
jde: UTC jde := calendar.Date2JDE(date)
*/ return basic.UranusApparentDec(basic.TD2UT(jde, true))
func SeeDec(jde float64) float64 {
return basic.UranusSeeDec(basic.TD2UT(jde, true))
} }
/* // ApparentRaDec 视赤经赤纬
func ApparentRaDec(date time.Time) (float64, float64) {
jde: UTC jde := calendar.Date2JDE(date)
*/ return basic.UranusApparentRaDec(basic.TD2UT(jde, true))
func SeeRaDec(jde float64) (float64, float64) {
return basic.UranusSeeRaDec(basic.TD2UT(jde, true))
} }
/* // ApparentMagnitude 视星等
func ApparentMagnitude(date time.Time) float64 {
jde: UTC jde := calendar.Date2JDE(date)
*/
func SeeMag(jde float64) float64 {
return basic.UranusMag(basic.TD2UT(jde, true)) return basic.UranusMag(basic.TD2UT(jde, true))
} }
/* // EarthDistance 与地球距离(天文单位)
func EarthDistance(date time.Time) float64 {
jde: UTC jde := calendar.Date2JDE(date)
*/
func EarthAway(jde float64) float64 {
return basic.EarthUranusAway(basic.TD2UT(jde, true)) return basic.EarthUranusAway(basic.TD2UT(jde, true))
} }
/* // EarthDistance 与太阳距离(天文单位)
func SunDistance(date time.Time) float64 {
jde: UTC jde := calendar.Date2JDE(date)
*/ return planet.WherePlanet(6, 2, basic.TD2UT(jde, true))
func SunAway(jde float64) float64 { }
return planet.WherePlanet(1, 2, basic.TD2UT(jde, true))
// Zenith 高度角
func Zenith(date time.Time, lon, lat float64) float64 {
jde := basic.Date2JDE(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
return basic.UranusHeight(jde, lon, lat, timezone)
}
// Azimuth 方位角
func Azimuth(date time.Time, lon, lat float64) float64 {
jde := basic.Date2JDE(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
return basic.UranusAzimuth(jde, lon, lat, timezone)
}
// HourAngle 时角
// 返回给定经纬度、对应date时区date时刻的时角
func HourAngle(date time.Time, lon float64) float64 {
jde := basic.Date2JDE(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
return basic.UranusHourAngle(jde, lon, timezone)
}
// CulminationTime 中天时间
// 返回给定经纬度、对应date时区date时刻的中天日期
func CulminationTime(date time.Time, lon float64) time.Time {
if date.Hour() > 12 {
date = date.Add(time.Hour * -12)
}
jde := basic.Date2JDE(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
calcJde := basic.UranusCulminationTime(jde, lon, timezone) - timezone/24.00
return basic.JDE2DateByZone(calcJde, date.Location(), false)
}
// RiseTime 升起时间
// date取日期时区忽略
// lon经度东正西负
// lat纬度北正南负
// height高度
// aerotrue时进行大气修正
func RiseTime(date time.Time, lon, lat, height float64, aero bool) (time.Time, error) {
var err error
var aeroFloat float64
if aero {
aeroFloat = 1
}
if date.Hour() > 12 {
date = date.Add(time.Hour * -12)
}
jde := basic.Date2JDE(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
riseJde := basic.UranusRiseTime(jde, lon, lat, timezone, aeroFloat, height)
if riseJde == -2 {
err = ERR_URANUS_NEVER_RISE
}
if riseJde == -1 {
err = ERR_URANUS_NEVER_DOWN
}
return basic.JDE2DateByZone(riseJde, date.Location(), true), err
}
// DownTime 落下时间
// date取日期时区忽略
// lon经度东正西负
// lat纬度北正南负
// height高度
// aerotrue时进行大气修正
func DownTime(date time.Time, lon, lat, height float64, aero bool) (time.Time, error) {
var err error
var aeroFloat float64
if aero {
aeroFloat = 1
}
if date.Hour() > 12 {
date = date.Add(time.Hour * -12)
}
jde := basic.Date2JDE(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
riseJde := basic.UranusDownTime(jde, lon, lat, timezone, aeroFloat, height)
if riseJde == -2 {
err = ERR_URANUS_NEVER_RISE
}
if riseJde == -1 {
err = ERR_URANUS_NEVER_DOWN
}
return basic.JDE2DateByZone(riseJde, date.Location(), true), err
}
// LastConjunction 上次合日时间
// 返回上次合日时间
func LastConjunction(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.LastUranusConjunction(jde), date.Location(), false)
}
// NextConjunction 下次合日时间
// 返回下次合日时间
func NextConjunction(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.NextUranusConjunction(jde), date.Location(), false)
}
// LastOpposition 上次冲日时间
// 返回上次冲日时间
func LastOpposition(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.LastUranusOpposition(jde), date.Location(), false)
}
// NextOpposition 下次冲日时间
// 返回下次冲日时间
func NextOpposition(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.NextUranusOpposition(jde), date.Location(), false)
}
// LastProgradeToRetrograde 上次留(顺转逆)
// 返回上次顺转逆留的时间
func LastProgradeToRetrograde(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.LastUranusProgradeToRetrograde(jde), date.Location(), false)
}
// NextProgradeToRetrograde 下次留(顺转逆)
// 返回下次顺转逆留的时间
func NextProgradeToRetrograde(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.NextUranusProgradeToRetrograde(jde), date.Location(), false)
}
// LastRetrogradeToPrograde 上次留(逆转瞬)
// 返回上次逆转瞬留的时间
func LastRetrogradeToPrograde(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.LastUranusRetrogradeToPrograde(jde), date.Location(), false)
}
// NextRetrogradeToPrograde 上次留(逆转瞬)
//// 返回上次逆转瞬留的时间
func NextRetrogradeToPrograde(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.NextUranusRetrogradeToPrograde(jde), date.Location(), false)
}
// LastEasternQuadrature 上次东方照时间
// 返回上次东方照时间
func LastEasternQuadrature(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.LastUranusEasternQuadrature(jde), date.Location(), false)
}
// NextEasternQuadrature 下次东方照时间
// 返回下次东方照时间
func NextEasternQuadrature(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.NextUranusEasternQuadrature(jde), date.Location(), false)
}
// LastWesternQuadrature 上次西方照时间
// 返回上次西方照时间
func LastWesternQuadrature(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.LastUranusWesternQuadrature(jde), date.Location(), false)
}
// NextWesternQuadrature 下次西方照时间
// 返回下次西方照时间
func NextWesternQuadrature(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.NextUranusWesternQuadrature(jde), date.Location(), false)
} }

@ -2,69 +2,281 @@ package venus
import ( import (
"b612.me/astro/basic" "b612.me/astro/basic"
"b612.me/astro/calendar"
"b612.me/astro/planet" "b612.me/astro/planet"
"errors"
"time"
) )
/* var (
ERR_VENUS_NEVER_RISE = errors.New("ERROR:极夜,金星今日永远在地平线下!")
jde: UTC ERR_VENUS_NEVER_DOWN = errors.New("ERROR:极昼,金星今日永远在地平线上!")
*/ )
func SeeLo(jde float64) float64 {
return basic.VenusSeeLo(basic.TD2UT(jde, true)) // ApparentLo 视黄经
func ApparentLo(date time.Time) float64 {
jde := calendar.Date2JDE(date)
return basic.VenusApparentLo(basic.TD2UT(jde, true))
} }
/* // ApparentBo 视黄纬
func ApparentBo(date time.Time) float64 {
jde: UTC jde := calendar.Date2JDE(date)
*/ return basic.VenusApparentBo(basic.TD2UT(jde, true))
func SeeBo(jde float64) float64 {
return basic.VenusSeeBo(basic.TD2UT(jde, true))
} }
/* // ApparentRa 视赤经
func ApparentRa(date time.Time) float64 {
jde: UTC jde := calendar.Date2JDE(date)
*/ return basic.VenusApparentRa(basic.TD2UT(jde, true))
func SeeRa(jde float64) float64 {
return basic.VenusSeeRa(basic.TD2UT(jde, true))
} }
/* // ApparentDec 视赤纬
func ApparentDec(date time.Time) float64 {
jde: UTC jde := calendar.Date2JDE(date)
*/ return basic.VenusApparentDec(basic.TD2UT(jde, true))
func SeeDec(jde float64) float64 {
return basic.VenusSeeDec(basic.TD2UT(jde, true))
} }
/* // ApparentRaDec 视赤经赤纬
func ApparentRaDec(date time.Time) (float64, float64) {
jde: UTC jde := calendar.Date2JDE(date)
*/ return basic.VenusApparentRaDec(basic.TD2UT(jde, true))
func SeeRaDec(jde float64) (float64, float64) {
return basic.VenusSeeRaDec(basic.TD2UT(jde, true))
} }
/* // ApparentMagnitude 视星等
func ApparentMagnitude(date time.Time) float64 {
jde: UTC jde := calendar.Date2JDE(date)
*/
func SeeMag(jde float64) float64 {
return basic.VenusMag(basic.TD2UT(jde, true)) return basic.VenusMag(basic.TD2UT(jde, true))
} }
/* // EarthDistance 与地球距离(天文单位)
func EarthDistance(date time.Time) float64 {
jde: UTC jde := calendar.Date2JDE(date)
*/
func EarthAway(jde float64) float64 {
return basic.EarthVenusAway(basic.TD2UT(jde, true)) return basic.EarthVenusAway(basic.TD2UT(jde, true))
} }
/* // EarthDistance 与太阳距离(天文单位)
func SunDistance(date time.Time) float64 {
jde: UTC jde := calendar.Date2JDE(date)
*/ return planet.WherePlanet(2, 2, basic.TD2UT(jde, true))
func SunAway(jde float64) float64 { }
return planet.WherePlanet(1, 2, basic.TD2UT(jde, true))
// Zenith 高度角
func Zenith(date time.Time, lon, lat float64) float64 {
jde := basic.Date2JDE(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
return basic.VenusHeight(jde, lon, lat, timezone)
}
// Azimuth 方位角
func Azimuth(date time.Time, lon, lat float64) float64 {
jde := basic.Date2JDE(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
return basic.VenusAzimuth(jde, lon, lat, timezone)
}
// HourAngle 时角
// 返回给定经纬度、对应date时区date时刻的时角
func HourAngle(date time.Time, lon float64) float64 {
jde := basic.Date2JDE(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
return basic.VenusHourAngle(jde, lon, timezone)
}
// CulminationTime 中天时间
// 返回给定经纬度、对应date时区date时刻的中天日期
func CulminationTime(date time.Time, lon float64) time.Time {
if date.Hour() > 12 {
date = date.Add(time.Hour * -12)
}
jde := basic.Date2JDE(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
calcJde := basic.VenusCulminationTime(jde, lon, timezone) - timezone/24.00
return basic.JDE2DateByZone(calcJde, date.Location(), false)
}
// RiseTime 升起时间
// date取日期时区忽略
// lon经度东正西负
// lat纬度北正南负
// height高度
// aerotrue时进行大气修正
func RiseTime(date time.Time, lon, lat, height float64, aero bool) (time.Time, error) {
var err error
var aeroFloat float64
if aero {
aeroFloat = 1
}
if date.Hour() > 12 {
date = date.Add(time.Hour * -12)
}
jde := basic.Date2JDE(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
riseJde := basic.VenusRiseTime(jde, lon, lat, timezone, aeroFloat, height)
if riseJde == -2 {
err = ERR_VENUS_NEVER_RISE
}
if riseJde == -1 {
err = ERR_VENUS_NEVER_DOWN
}
return basic.JDE2DateByZone(riseJde, date.Location(), true), err
}
// DownTime 落下时间
// date取日期时区忽略
// lon经度东正西负
// lat纬度北正南负
// height高度
// aerotrue时进行大气修正
func DownTime(date time.Time, lon, lat, height float64, aero bool) (time.Time, error) {
var err error
var aeroFloat float64
if aero {
aeroFloat = 1
}
if date.Hour() > 12 {
date = date.Add(time.Hour * -12)
}
jde := basic.Date2JDE(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
riseJde := basic.VenusDownTime(jde, lon, lat, timezone, aeroFloat, height)
if riseJde == -2 {
err = ERR_VENUS_NEVER_RISE
}
if riseJde == -1 {
err = ERR_VENUS_NEVER_DOWN
}
return basic.JDE2DateByZone(riseJde, date.Location(), true), err
}
// LastConjunction 上次合日时间
// 返回上次合日时间,不区分上合下合
func LastConjunction(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.LastVenusConjunction(jde), date.Location(), false)
}
// NextConjunction 下次合日时间
// 返回下次合日时间,不区分上合下合
func NextConjunction(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.NextVenusConjunction(jde), date.Location(), false)
}
// LastInferiorConjunction 上次下合时间
// 返回上次下合日时间
func LastInferiorConjunction(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.LastVenusInferiorConjunction(jde), date.Location(), false)
}
// NextInferiorConjunction 下次下合时间
// 返回下次合日时间
func NextInferiorConjunction(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.NextVenusInferiorConjunction(jde), date.Location(), false)
}
// LastSuperiorConjunction 上次上合时间
// 返回上次下合时间
func LastSuperiorConjunction(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.LastVenusSuperiorConjunction(jde), date.Location(), false)
}
// NextSuperiorConjunction 下次上合时间
// 返回下次上合时间
func NextSuperiorConjunction(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.NextVenusSuperiorConjunction(jde), date.Location(), false)
}
// LastRetrograde 上次留的时间
// 返回上次留时间,不区分顺逆
func LastRetrograde(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.LastVenusRetrograde(jde), date.Location(), false)
}
// NextRetrograde 下次留时间
// 返回下次留的时间,不区分顺逆
func NextRetrograde(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.NextVenusRetrograde(jde), date.Location(), false)
}
// LastProgradeToRetrograde 上次留(顺转逆)
// 返回上次顺转逆留的时间
func LastProgradeToRetrograde(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.LastVenusProgradeToRetrograde(jde), date.Location(), false)
}
// NextProgradeToRetrograde 下次留(顺转逆)
// 返回下次顺转逆留的时间
func NextProgradeToRetrograde(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.NextVenusProgradeToRetrograde(jde), date.Location(), false)
}
// LastRetrogradeToPrograde 上次留(逆转瞬)
// 返回上次逆转瞬留的时间
func LastRetrogradeToPrograde(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.LastVenusRetrogradeToPrograde(jde), date.Location(), false)
}
// NextRetrogradeToPrograde 上次留(逆转瞬)
//// 返回上次逆转瞬留的时间
func NextRetrogradeToPrograde(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.NextVenusRetrogradeToPrograde(jde), date.Location(), false)
}
// LastGreatestElongation 上次大距时间
// 返回上次大距时间,不区分东西大距
func LastGreatestElongation(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.LastVenusGreatestElongation(jde), date.Location(), false)
}
// NextGreatestElongation 下次大距时间
// 返回下次大距时间,不区分东西大距
func NextGreatestElongation(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.NextVenusGreatestElongation(jde), date.Location(), false)
}
// LastGreatestElongationEast 上次东大距时间
// 返回上次东大距时间
func LastGreatestElongationEast(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.LastVenusGreatestElongationEast(jde), date.Location(), false)
}
// NextGreatestElongationEast 下次东大距时间
// 返回下次东大距时间
func NextGreatestElongationEast(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.NextVenusGreatestElongationEast(jde), date.Location(), false)
}
// LastGreatestElongationWest 上次西大距时间
// 返回上次西大距时间
func LastGreatestElongationWest(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.LastVenusGreatestElongationWest(jde), date.Location(), false)
}
// NextGreatestElongationWest 下次西大距时间
// 返回下次西大距时间
func NextGreatestElongationWest(date time.Time) time.Time {
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
return basic.JDE2DateByZone(basic.NextVenusGreatestElongationWest(jde), date.Location(), false)
} }

@ -0,0 +1,14 @@
package venus
import (
"fmt"
"testing"
"time"
)
func TestVenus(t *testing.T) {
date := time.Now().Add(time.Hour * -24)
fmt.Println(CulminationTime(date, 115))
fmt.Println(RiseTime(date, 115, 23, 0, false))
fmt.Println(DownTime(date, 115, 23, 0, false))
}
Loading…
Cancel
Save