Files
astro/basic/sun.go
T

210 lines
5.6 KiB
Go
Raw Normal View History

2019-10-24 10:44:21 +08:00
package basic
import (
"b612.me/astro/planet"
. "b612.me/astro/tools"
)
2025-09-18 13:16:04 +08:00
// SunLo 太阳几何黄经
func SunLo(jde float64) float64 {
return planet.SunLo(jde)
2019-10-24 10:44:21 +08:00
}
func SunM(jde float64) float64 {
return planet.SunM(jde)
2019-10-24 10:44:21 +08:00
}
/*
2024-01-15 17:05:18 +08:00
@name 地球偏心率
2019-10-24 10:44:21 +08:00
*/
func Earthe(jde float64) float64 { //'地球偏心率
return planet.Earthe(jde)
2019-10-24 10:44:21 +08:00
}
func EarthPI(jde float64) float64 { //近日點經度
return planet.EarthPI(jde)
2019-10-24 10:44:21 +08:00
}
2025-09-18 13:16:04 +08:00
func SunMidFun(jde float64) float64 { //'太阳中间方程
return planet.SunMidFun(jde)
2019-10-24 10:44:21 +08:00
}
2025-09-18 13:16:04 +08:00
func SunTrueLo(jde float64) float64 { // '太阳真黄经
return planet.SunTrueLo(jde)
2019-10-24 10:44:21 +08:00
}
func SunApparentLo(jde float64) float64 { //'太阳视黄经
return planet.SunApparentLo(jde)
2019-10-24 10:44:21 +08:00
}
func SunApparentRa(jde float64) float64 { // '太阳视赤经
return LoToRa(jde, SunApparentLo(jde), 0)
2019-10-24 10:44:21 +08:00
}
func SunApparentRaDec(jde float64) (float64, float64) {
return LoBoToRaDec(jde, SunApparentLo(jde), 0)
2024-01-15 17:05:18 +08:00
}
func SunTrueRa(jde float64) float64 { //'太阳真赤经
eps := TrueObliquity(jde)
sunTrueRa := ArcTan(Cos(eps) * Sin(SunTrueLo(jde)) / Cos(SunTrueLo(jde)))
2019-10-24 10:44:21 +08:00
//Select Case SunTrueLo(JD)
sunTrueLo := SunTrueLo(jde)
2026-05-01 22:38:44 +08:00
if sunTrueLo >= 90 && sunTrueLo < 180 {
2025-09-18 13:16:04 +08:00
sunTrueRa = 180 + sunTrueRa
2026-05-01 22:38:44 +08:00
} else if sunTrueLo >= 180 && sunTrueLo < 270 {
2025-09-18 13:16:04 +08:00
sunTrueRa = 180 + sunTrueRa
2026-05-01 22:38:44 +08:00
} else if sunTrueLo >= 270 && sunTrueLo <= 360 {
2025-09-18 13:16:04 +08:00
sunTrueRa = 360 + sunTrueRa
2019-10-24 10:44:21 +08:00
}
2025-09-18 13:16:04 +08:00
return sunTrueRa
2019-10-24 10:44:21 +08:00
}
func SunApparentDec(jde float64) float64 { // '太阳视赤纬
// TrueObliquity 已是“平交角 + 交角章动”,不能再加 0.00256*cos(Ω):
// 那一项就是交角章动的近似值(见《天文算法》24 章译者注),加了会把章动计两次。
eps := TrueObliquity(jde)
sunApparentDec := ArcSin(Sin(eps) * Sin(SunApparentLo(jde)))
2026-05-01 22:38:44 +08:00
return sunApparentDec
}
func SunTrueDec(jde float64) float64 { // '太阳真赤纬
eps := TrueObliquity(jde)
sunTrueDec := ArcSin(Sin(eps) * Sin(SunTrueLo(jde)))
2026-05-01 22:38:44 +08:00
return sunTrueDec
2019-10-24 10:44:21 +08:00
}
// SunTime 均时差,单位小时 / equation of time in hours.
//
// jde 按力学时取用;CulminationTime 传的是本地民用日锚点,历元差最大半天,
// 对均时差的影响在 10 s 量级,是该近似入口的既有取舍。
func SunTime(jde float64) float64 { //均时差
tm := (SunLo(jde) - 0.0057183 - (HSunApparentRa(jde)) + (Nutation2000Bi(jde))*Cos(TrueObliquity(jde))) / 15
2026-05-01 22:38:44 +08:00
if tm > 23 {
tm = -24 + tm
}
return tm
2019-10-24 10:44:21 +08:00
}
func SunTimeN(jde float64, n int) float64 { //均时差
tm := (SunLo(jde) - 0.0057183 - (HSunApparentRaN(jde, n)) + (Nutation2000Bi(jde))*Cos(TrueObliquity(jde))) / 15
2019-10-24 10:44:21 +08:00
if tm > 23 {
tm = -24 + tm
}
return tm
}
2026-05-01 22:38:44 +08:00
func SunSC(lo, jd float64) float64 { //黄道上的岁差,仅黄纬=0时
t := (jd - 2451545) / 36525
2019-10-24 10:44:21 +08:00
//n := 47.0029/3600*t - 0.03302/3600*t*t + 0.000060/3600*t*t*t
//m := 174.876384/3600 - 869.8089/3600*t + 0.03536/3600*t*t
pk := 5029.0966/3600.00*t + 1.11113/3600.00*t*t - 0.000006/3600.00*t*t*t
2026-05-01 22:38:44 +08:00
return lo + pk
2019-10-24 10:44:21 +08:00
}
2025-09-18 13:16:04 +08:00
// 高精度,使用VSOP87
func HSunTrueLo(jde float64) float64 {
return HSunTrueLoN(jde, -1)
2019-10-24 10:44:21 +08:00
}
2026-05-01 22:38:44 +08:00
// HSunTrueLoN 高精度太阳真黄经,n<0 时取全量 VSOP 项。
func HSunTrueLoN(jde float64, n int) float64 {
return planet.WherePlanetN(0, 0, jde, n)
2020-07-14 15:38:51 +08:00
}
func HSunTrueBo(jde float64) float64 {
return HSunTrueBoN(jde, -1)
2019-10-24 10:44:21 +08:00
}
2026-05-01 22:38:44 +08:00
// HSunTrueBoN 高精度太阳真黄纬,n<0 时取全量 VSOP 项。
func HSunTrueBoN(jde float64, n int) float64 {
return planet.WherePlanetN(0, 1, jde, n)
2020-07-14 15:38:51 +08:00
}
func HSunApparentLo(jde float64) float64 {
return HSunApparentLoN(jde, -1)
2019-10-24 10:44:21 +08:00
}
func HSunApparentLoN(jde float64, n int) float64 {
lo := HSunTrueLoN(jde, n)
lo = lo + Nutation2000Bi(jde) + SunLoGXCN(jde, n)
2026-05-01 22:38:44 +08:00
return lo
2019-10-24 10:44:21 +08:00
}
func SunLoGXC(jde float64) float64 {
return SunLoGXCN(jde, -1)
2019-10-24 10:44:21 +08:00
}
func SunLoGXCN(jde float64, n int) float64 {
radius := EarthAwayN(jde, n)
2026-05-01 22:38:44 +08:00
return -20.49552 / radius / 3600
2019-10-24 10:44:21 +08:00
}
func EarthAway(jde float64) float64 {
return EarthAwayN(jde, -1)
2019-10-24 10:44:21 +08:00
}
func EarthAwayN(jde float64, n int) float64 {
return planet.WherePlanetN(0, 2, jde, n)
2019-10-24 10:44:21 +08:00
}
func HSunApparentRaDec(jde float64) (float64, float64) {
return HSunApparentRaDecN(jde, -1)
2019-10-24 10:44:21 +08:00
}
func HSunApparentRaDecN(jde float64, n int) (float64, float64) {
ra, dec, _ := hSunApparentRaDecDistanceN(jde, n)
return ra, dec
}
func hSunApparentRaDecDistanceN(jde float64, n int) (ra, dec, distanceAU float64) {
trueLongitude := HSunTrueLoN(jde, n)
trueLatitude := HSunTrueBoN(jde, n)
distanceAU = EarthAwayN(jde, n)
apparentLongitude := trueLongitude + Nutation2000Bi(jde) - 20.49552/distanceAU/3600
ra, dec = LoBoToRaDec(jde, apparentLongitude, trueLatitude)
return ra, dec, distanceAU
2019-10-24 10:44:21 +08:00
}
func HSunApparentRa(jde float64) float64 { // '太阳视赤经
return HSunApparentRaN(jde, -1)
2019-10-24 10:44:21 +08:00
}
func HSunApparentRaN(jde float64, n int) float64 { // '太阳视赤经
return LoToRa(jde, HSunApparentLoN(jde, n), HSunTrueBoN(jde, n))
2019-10-24 10:44:21 +08:00
}
func HSunTrueRa(jde float64) float64 {
return HSunTrueRaN(jde, -1)
2019-10-24 10:44:21 +08:00
}
func HSunTrueRaN(jde float64, n int) float64 {
sunTrueLo := HSunTrueLoN(jde, n)
eps := TrueObliquity(jde)
2025-09-18 13:16:04 +08:00
2026-05-01 22:38:44 +08:00
numerator := Cos(eps) * Sin(sunTrueLo)
denominator := Cos(sunTrueLo)
2025-09-18 13:16:04 +08:00
2026-05-01 22:38:44 +08:00
return ArcTan2(numerator, denominator)
2019-10-24 10:44:21 +08:00
}
func HSunApparentDec(jde float64) float64 { // '太阳视赤纬
return HSunApparentDecN(jde, -1)
2019-10-24 10:44:21 +08:00
}
func HSunApparentDecN(jde float64, n int) float64 { // '太阳视赤纬
return ArcSin(Sin(EclipticObliquity(jde, true)) * Sin(HSunApparentLoN(jde, n)))
2025-09-15 20:55:38 +08:00
}
func HSunTrueDec(jde float64) float64 { // '太阳真赤纬
return HSunTrueDecN(jde, -1)
2025-09-15 20:55:38 +08:00
}
func HSunTrueDecN(jde float64, n int) float64 { // '太阳真赤纬
return ArcSin(Sin(EclipticObliquity(jde, false)) * Sin(HSunTrueLoN(jde, n)))
2025-09-15 20:55:38 +08:00
}
func Distance(jde float64) float64 { //ri di ju li
return planet.Distance(jde)
2019-10-24 10:44:21 +08:00
}