2019-10-24 10:44:21 +08:00
|
|
|
package basic
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"math"
|
|
|
|
|
|
|
|
|
|
"b612.me/astro/planet"
|
|
|
|
|
. "b612.me/astro/tools"
|
|
|
|
|
)
|
|
|
|
|
|
2026-09-23 18:55:12 +08:00
|
|
|
func SaturnL(jde float64) float64 {
|
|
|
|
|
return planet.WherePlanet(5, 0, jde)
|
2019-10-24 10:44:21 +08:00
|
|
|
}
|
|
|
|
|
|
2026-09-23 18:55:12 +08:00
|
|
|
func SaturnB(jde float64) float64 {
|
|
|
|
|
return planet.WherePlanet(5, 1, jde)
|
2019-10-24 10:44:21 +08:00
|
|
|
}
|
2026-09-23 18:55:12 +08:00
|
|
|
func SaturnR(jde float64) float64 {
|
|
|
|
|
return planet.WherePlanet(5, 2, jde)
|
2019-10-24 10:44:21 +08:00
|
|
|
}
|
2026-09-23 18:55:12 +08:00
|
|
|
func ASaturnX(jde float64) float64 {
|
|
|
|
|
l := SaturnL(jde)
|
|
|
|
|
b := SaturnB(jde)
|
|
|
|
|
r := SaturnR(jde)
|
|
|
|
|
el := planet.WherePlanet(-1, 0, jde)
|
|
|
|
|
eb := planet.WherePlanet(-1, 1, jde)
|
|
|
|
|
er := planet.WherePlanet(-1, 2, jde)
|
2019-10-24 10:44:21 +08:00
|
|
|
x := r*Cos(b)*Cos(l) - er*Cos(eb)*Cos(el)
|
|
|
|
|
return x
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-23 18:55:12 +08:00
|
|
|
func ASaturnY(jde float64) float64 {
|
2019-10-24 10:44:21 +08:00
|
|
|
|
2026-09-23 18:55:12 +08:00
|
|
|
l := SaturnL(jde)
|
|
|
|
|
b := SaturnB(jde)
|
|
|
|
|
r := SaturnR(jde)
|
|
|
|
|
el := planet.WherePlanet(-1, 0, jde)
|
|
|
|
|
eb := planet.WherePlanet(-1, 1, jde)
|
|
|
|
|
er := planet.WherePlanet(-1, 2, jde)
|
2019-10-24 10:44:21 +08:00
|
|
|
y := r*Cos(b)*Sin(l) - er*Cos(eb)*Sin(el)
|
|
|
|
|
return y
|
|
|
|
|
}
|
2026-09-23 18:55:12 +08:00
|
|
|
func ASaturnZ(jde float64) float64 {
|
|
|
|
|
//l := SaturnL(jde)
|
|
|
|
|
b := SaturnB(jde)
|
|
|
|
|
r := SaturnR(jde)
|
|
|
|
|
// el := planet.WherePlanet(-1, 0, jde)
|
|
|
|
|
eb := planet.WherePlanet(-1, 1, jde)
|
|
|
|
|
er := planet.WherePlanet(-1, 2, jde)
|
2019-10-24 10:44:21 +08:00
|
|
|
z := r*Sin(b) - er*Sin(eb)
|
|
|
|
|
return z
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-23 18:55:12 +08:00
|
|
|
func ASaturnXYZ(jde float64) (float64, float64, float64) {
|
|
|
|
|
l := SaturnL(jde)
|
|
|
|
|
b := SaturnB(jde)
|
|
|
|
|
r := SaturnR(jde)
|
|
|
|
|
el := planet.WherePlanet(-1, 0, jde)
|
|
|
|
|
eb := planet.WherePlanet(-1, 1, jde)
|
|
|
|
|
er := planet.WherePlanet(-1, 2, jde)
|
2019-10-24 10:44:21 +08:00
|
|
|
x := r*Cos(b)*Cos(l) - er*Cos(eb)*Cos(el)
|
|
|
|
|
y := r*Cos(b)*Sin(l) - er*Cos(eb)*Sin(el)
|
|
|
|
|
z := r*Sin(b) - er*Sin(eb)
|
|
|
|
|
return x, y, z
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-23 18:55:12 +08:00
|
|
|
func SaturnApparentRa(jde float64) float64 {
|
|
|
|
|
lo, bo := SaturnApparentLoBo(jde)
|
|
|
|
|
eps := TrueObliquity(jde)
|
2026-05-01 22:38:44 +08:00
|
|
|
ra := math.Atan2((Sin(lo)*Cos(eps) - Tan(bo)*Sin(eps)), Cos(lo))
|
2019-10-24 10:44:21 +08:00
|
|
|
ra = ra * 180 / math.Pi
|
|
|
|
|
return Limit360(ra)
|
|
|
|
|
}
|
2026-09-23 18:55:12 +08:00
|
|
|
func SaturnApparentDec(jde float64) float64 {
|
|
|
|
|
lo, bo := SaturnApparentLoBo(jde)
|
|
|
|
|
eps := TrueObliquity(jde)
|
2026-05-01 22:38:44 +08:00
|
|
|
dec := ArcSin(Sin(bo)*Cos(eps) + Cos(bo)*Sin(eps)*Sin(lo))
|
2019-10-24 10:44:21 +08:00
|
|
|
return dec
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-23 18:55:12 +08:00
|
|
|
func SaturnApparentRaDec(jde float64) (float64, float64) {
|
|
|
|
|
lo, bo := SaturnApparentLoBo(jde)
|
|
|
|
|
eps := TrueObliquity(jde)
|
2026-05-01 22:38:44 +08:00
|
|
|
ra := math.Atan2((Sin(lo)*Cos(eps) - Tan(bo)*Sin(eps)), Cos(lo))
|
2019-10-24 10:44:21 +08:00
|
|
|
ra = ra * 180 / math.Pi
|
2026-05-01 22:38:44 +08:00
|
|
|
dec := ArcSin(Sin(bo)*Cos(eps) + Cos(bo)*Sin(eps)*Sin(lo))
|
2019-10-24 10:44:21 +08:00
|
|
|
return Limit360(ra), dec
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-01 22:38:44 +08:00
|
|
|
func EarthSaturnAway(jd float64) float64 {
|
2026-05-22 12:24:41 +08:00
|
|
|
return planetEarthAwayExplicitN(5, jd, -1)
|
2019-10-24 10:44:21 +08:00
|
|
|
}
|
|
|
|
|
|
2026-05-01 22:38:44 +08:00
|
|
|
func SaturnApparentLo(jd float64) float64 {
|
2026-05-22 12:24:41 +08:00
|
|
|
geo, _ := planetApparentGeocentricPositionN(5, jd, -1)
|
|
|
|
|
return geo.lo
|
2019-10-24 10:44:21 +08:00
|
|
|
}
|
|
|
|
|
|
2026-05-01 22:38:44 +08:00
|
|
|
func SaturnApparentBo(jd float64) float64 {
|
2026-05-22 12:24:41 +08:00
|
|
|
geo, _ := planetApparentGeocentricPositionN(5, jd, -1)
|
|
|
|
|
return geo.bo
|
2019-10-24 10:44:21 +08:00
|
|
|
}
|
|
|
|
|
|
2026-05-01 22:38:44 +08:00
|
|
|
func SaturnApparentLoBo(jd float64) (float64, float64) {
|
2026-05-22 12:24:41 +08:00
|
|
|
geo, _ := planetApparentGeocentricPositionN(5, jd, -1)
|
|
|
|
|
return geo.lo, geo.bo
|
2019-10-24 10:44:21 +08:00
|
|
|
}
|
|
|
|
|
|
2026-09-23 18:55:12 +08:00
|
|
|
func SaturnMag(jde float64) float64 {
|
|
|
|
|
return SaturnMagN(jde, -1)
|
2019-10-24 10:44:21 +08:00
|
|
|
}
|
2022-05-16 20:42:15 +08:00
|
|
|
|
2026-10-15 23:54:15 +08:00
|
|
|
// SaturnHeightWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model.
|
|
|
|
|
func SaturnHeightWithInstance(localJD, lon, lat, timezone float64, inst *Instance) float64 {
|
|
|
|
|
return planetHeightN(5, localJD, lon, lat, timezone, -1, inst)
|
2022-05-16 20:42:15 +08:00
|
|
|
}
|
|
|
|
|
|
2026-10-15 23:54:15 +08:00
|
|
|
// SaturnAzimuthWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model.
|
|
|
|
|
func SaturnAzimuthWithInstance(localJD, lon, lat, timezone float64, inst *Instance) float64 {
|
|
|
|
|
return planetAzimuthN(5, localJD, lon, lat, timezone, -1, inst)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// SaturnHourAngleWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model.
|
|
|
|
|
func SaturnHourAngleWithInstance(jd, lon, timezone float64, inst *Instance) float64 {
|
2026-09-23 18:55:12 +08:00
|
|
|
siderealLongitude := Limit360(ApparentSiderealTime(UTC2UT1(jd-timezone/24))*15 + lon)
|
2026-10-15 23:54:15 +08:00
|
|
|
hourAngle := siderealLongitude - SaturnApparentRaWithInstance(UTC2TT(jd-timezone/24.0), inst)
|
2026-05-01 22:38:44 +08:00
|
|
|
if hourAngle < 0 {
|
|
|
|
|
hourAngle += 360
|
2022-05-16 20:42:15 +08:00
|
|
|
}
|
2026-05-01 22:38:44 +08:00
|
|
|
return hourAngle
|
2022-05-16 20:42:15 +08:00
|
|
|
}
|
|
|
|
|
|
2026-10-15 23:54:15 +08:00
|
|
|
// SaturnCulminationTimeWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model.
|
|
|
|
|
func SaturnCulminationTimeWithInstance(localJD, lon, timezone float64, inst *Instance) float64 {
|
2026-09-23 18:55:12 +08:00
|
|
|
// localJD 是本地民用日锚点(当地 0 时),不是力学时。
|
2022-05-16 20:42:15 +08:00
|
|
|
//ra,dec 瞬时天球座标,非J2000等时间天球坐标
|
2026-09-23 18:55:12 +08:00
|
|
|
localJD = math.Floor(localJD) + 0.5
|
2026-10-15 23:54:15 +08:00
|
|
|
estimateJD := localJD + Limit360(360-SaturnHourAngleWithInstance(localJD, lon, timezone, inst))/15.0/24.0*0.99726851851851851851
|
2026-09-23 18:55:12 +08:00
|
|
|
normalizedHourAngle := func(localJD, lon, timezone float64) float64 {
|
2026-10-15 23:54:15 +08:00
|
|
|
currentHourAngle := SaturnHourAngleWithInstance(localJD, lon, timezone, inst)
|
2026-05-01 22:38:44 +08:00
|
|
|
if currentHourAngle < 180 {
|
|
|
|
|
currentHourAngle += 360
|
2022-05-16 20:42:15 +08:00
|
|
|
}
|
2026-05-01 22:38:44 +08:00
|
|
|
return currentHourAngle
|
2022-05-16 20:42:15 +08:00
|
|
|
}
|
2026-08-06 12:00:56 +08:00
|
|
|
var ok bool
|
|
|
|
|
estimateJD, ok = eventNewtonRefine(estimateJD, 0.00001, func(prevJD float64) float64 {
|
2026-05-01 22:38:44 +08:00
|
|
|
hourAngleDelta := normalizedHourAngle(prevJD, lon, timezone) - 360
|
|
|
|
|
hourAngleSlope := (normalizedHourAngle(prevJD+0.000005, lon, timezone) - normalizedHourAngle(prevJD-0.000005, lon, timezone)) / 0.00001
|
2026-08-06 12:00:56 +08:00
|
|
|
return hourAngleDelta / hourAngleSlope
|
|
|
|
|
})
|
|
|
|
|
if !ok {
|
|
|
|
|
return math.NaN()
|
2022-05-16 20:42:15 +08:00
|
|
|
}
|
2026-05-01 22:38:44 +08:00
|
|
|
return estimateJD
|
2022-05-16 20:42:15 +08:00
|
|
|
}
|
|
|
|
|
|
2026-10-15 23:54:15 +08:00
|
|
|
// SaturnRiseTimeWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model.
|
|
|
|
|
func SaturnRiseTimeWithInstance(jd, lon, lat, timezone, aeroCorrection, observerHeight float64, inst *Instance) (float64, error) {
|
|
|
|
|
return saturnRiseDown(jd, lon, lat, timezone, aeroCorrection, observerHeight, true, inst)
|
2022-05-16 20:42:15 +08:00
|
|
|
}
|
|
|
|
|
|
2026-10-15 23:54:15 +08:00
|
|
|
// SaturnSetTimeWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model.
|
|
|
|
|
func SaturnSetTimeWithInstance(jd, lon, lat, timezone, aeroCorrection, observerHeight float64, inst *Instance) (float64, error) {
|
|
|
|
|
return saturnRiseDown(jd, lon, lat, timezone, aeroCorrection, observerHeight, false, inst)
|
2022-05-16 20:42:15 +08:00
|
|
|
}
|
|
|
|
|
|
2026-10-15 23:54:15 +08:00
|
|
|
func saturnRiseDown(jd, lon, lat, timezone, aeroCorrection, observerHeight float64, isRise bool, instances ...*Instance) (float64, error) {
|
|
|
|
|
inst := instanceValue(instances)
|
|
|
|
|
|
|
|
|
|
return planetRiseDown(jd, lon, lat, timezone, aeroCorrection, observerHeight, isRise, func(localJD, lon, timezone float64) float64 {
|
|
|
|
|
return SaturnCulminationTimeWithInstance(localJD, lon, timezone, inst)
|
|
|
|
|
}, func(localJD, lon, lat, timezone float64) float64 {
|
|
|
|
|
return SaturnHeightWithInstance(localJD, lon, lat, timezone, inst)
|
|
|
|
|
}, func(jde float64) float64 { return SaturnApparentDecWithInstance(jde, inst) })
|
2022-05-16 20:42:15 +08:00
|
|
|
}
|