Files
astro/jupiter/jupiter.go
T

230 lines
9.5 KiB
Go
Raw Permalink Normal View History

2019-10-24 10:44:21 +08:00
package jupiter
import (
"errors"
"time"
"b612.me/astro/basic"
"b612.me/astro/calendar"
2019-10-24 10:44:21 +08:00
)
var (
ERR_JUPITER_NEVER_RISE = errors.New("ERROR:极夜,木星今日永远在地平线下!")
ERR_JUPITER_NEVER_SET = errors.New("ERROR:极昼,木星今日永远在地平线上!")
// ERR_JUPITER_NEVER_DOWN deprecated: -- use ERR_JUPITER_NEVER_SET instead
ERR_JUPITER_NEVER_DOWN = ERR_JUPITER_NEVER_SET
)
func riseSetResult(date time.Time, jd float64, err error) (time.Time, error) {
2026-05-01 22:38:44 +08:00
if err != nil {
switch {
case errors.Is(err, basic.ErrNeverRise):
return time.Time{}, ERR_JUPITER_NEVER_RISE
case errors.Is(err, basic.ErrNeverSet):
return time.Time{}, ERR_JUPITER_NEVER_SET
default:
return time.Time{}, err
}
}
_, offset := date.Zone()
return basic.JD2DateByZone(jd-float64(offset)/86400, date.Location(), false), nil
2026-05-01 22:38:44 +08:00
}
// ApparentLo 视黄经 / apparent ecliptic longitude.
func (module *Jupiter) ApparentLo(date time.Time) float64 {
jd := calendar.Date2JD(date.UTC())
return basic.JupiterApparentLoWithInstance(basic.UTC2TT(jd), module.inst)
2019-10-24 10:44:21 +08:00
}
2026-05-01 22:38:44 +08:00
// ApparentBo 视黄纬 / apparent ecliptic latitude.
func (module *Jupiter) ApparentBo(date time.Time) float64 {
jd := calendar.Date2JD(date.UTC())
return basic.JupiterApparentBoWithInstance(basic.UTC2TT(jd), module.inst)
2019-10-24 10:44:21 +08:00
}
2026-05-01 22:38:44 +08:00
// ApparentRa 视赤经 / apparent right ascension.
func (module *Jupiter) ApparentRa(date time.Time) float64 {
jd := calendar.Date2JD(date.UTC())
return basic.JupiterApparentRaWithInstance(basic.UTC2TT(jd), module.inst)
2019-10-24 10:44:21 +08:00
}
2026-05-01 22:38:44 +08:00
// ApparentDec 视赤纬 / apparent declination.
func (module *Jupiter) ApparentDec(date time.Time) float64 {
jd := calendar.Date2JD(date.UTC())
return basic.JupiterApparentDecWithInstance(basic.UTC2TT(jd), module.inst)
2019-10-24 10:44:21 +08:00
}
2026-05-01 22:38:44 +08:00
// ApparentRaDec 视赤经、视赤纬 / apparent right ascension and declination.
func (module *Jupiter) ApparentRaDec(date time.Time) (float64, float64) {
jd := calendar.Date2JD(date.UTC())
return basic.JupiterApparentRaDecWithInstance(basic.UTC2TT(jd), module.inst)
2019-10-24 10:44:21 +08:00
}
2026-05-01 22:38:44 +08:00
// ApparentMagnitude 视星等 / apparent magnitude.
func (module *Jupiter) ApparentMagnitude(date time.Time) float64 {
jd := calendar.Date2JD(date.UTC())
return basic.JupiterMagWithInstance(basic.UTC2TT(jd), module.inst)
2019-10-24 10:44:21 +08:00
}
2026-05-01 22:38:44 +08:00
// EarthDistance 地心距离 / Earth distance.
func (module *Jupiter) EarthDistance(date time.Time) float64 {
jd := calendar.Date2JD(date.UTC())
return basic.EarthJupiterAwayWithInstance(basic.UTC2TT(jd), module.inst)
2019-10-24 10:44:21 +08:00
}
2026-05-01 22:38:44 +08:00
// SunDistance 日心距离 / Sun distance.
func (module *Jupiter) SunDistance(date time.Time) float64 {
jd := calendar.Date2JD(date.UTC())
return basic.PlanetCoordinateWithInstance(4, 2, basic.UTC2TT(jd), module.inst)
}
// Altitude 站心视高度角,不含大气折射 / topocentric apparent altitude without refraction.
func (module *Jupiter) Altitude(date time.Time, lon, lat float64) float64 {
localJD := basic.Date2JD(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
return basic.JupiterHeightWithInstance(localJD, lon, lat, timezone, module.inst)
}
2026-05-01 22:38:44 +08:00
// Zenith 天顶距 / zenith distance.
func (module *Jupiter) Zenith(date time.Time, lon, lat float64) float64 {
return 90 - module.Altitude(date, lon, lat)
2026-05-01 22:38:44 +08:00
}
// Azimuth 站心方位角 / topocentric azimuth.
func (module *Jupiter) Azimuth(date time.Time, lon, lat float64) float64 {
localJD := basic.Date2JD(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
return basic.JupiterAzimuthWithInstance(localJD, lon, lat, timezone, module.inst)
}
// HourAngle 地心视时角,不含站心视差 / geocentric apparent hour angle without topocentric parallax.
func (module *Jupiter) HourAngle(date time.Time, lon float64) float64 {
localJD := basic.Date2JD(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
return basic.JupiterHourAngleWithInstance(localJD, lon, timezone, module.inst)
}
2026-05-01 22:38:44 +08:00
// CulminationTime 中天时刻 / culmination time.
func (module *Jupiter) CulminationTime(date time.Time, lon float64) time.Time {
date = time.Date(date.Year(), date.Month(), date.Day(), 0, 0, 0, 0, date.Location())
localJD := basic.Date2JD(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
calcJD := basic.JupiterCulminationTimeWithInstance(localJD, lon, timezone, module.inst) - timezone/24.00
return basic.JD2DateByZone(calcJD, date.Location(), false)
}
2026-05-01 22:38:44 +08:00
// RiseTime 升起时间 / rise time.
func (module *Jupiter) RiseTime(date time.Time, lon, lat, height float64, aero bool) (time.Time, error) {
var aeroFloat float64
if aero {
aeroFloat = 1
}
date = time.Date(date.Year(), date.Month(), date.Day(), 0, 0, 0, 0, date.Location())
localJD := basic.Date2JD(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
riseJD, err := basic.JupiterRiseTimeWithInstance(localJD, lon, lat, timezone, aeroFloat, height, module.inst)
return riseSetResult(date, riseJD, err)
}
2026-05-01 22:38:44 +08:00
// DownTime 落下时间别名 / deprecated set-time alias.
func (module *Jupiter) DownTime(date time.Time, lon, lat, height float64, aero bool) (time.Time, error) {
return module.SetTime(date, lon, lat, height, aero)
}
2026-05-01 22:38:44 +08:00
// SetTime 落下时间 / set time.
func (module *Jupiter) SetTime(date time.Time, lon, lat, height float64, aero bool) (time.Time, error) {
var aeroFloat float64
if aero {
aeroFloat = 1
}
date = time.Date(date.Year(), date.Month(), date.Day(), 0, 0, 0, 0, date.Location())
localJD := basic.Date2JD(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
riseJD, err := basic.JupiterSetTimeWithInstance(localJD, lon, lat, timezone, aeroFloat, height, module.inst)
return riseSetResult(date, riseJD, err)
}
2026-05-01 22:38:44 +08:00
// LastConjunction 上一次合日 / previous conjunction with the Sun.
func (module *Jupiter) LastConjunction(date time.Time) time.Time {
jde := basic.UTC2TT(basic.Date2JD(date.UTC()))
return basic.JD2DateByZone(basic.LastJupiterConjunctionWithInstance(jde, module.inst), date.Location(), false)
}
2026-05-01 22:38:44 +08:00
// NextConjunction 下一次合日 / next conjunction with the Sun.
func (module *Jupiter) NextConjunction(date time.Time) time.Time {
jde := basic.UTC2TT(basic.Date2JD(date.UTC()))
return basic.JD2DateByZone(basic.NextJupiterConjunctionWithInstance(jde, module.inst), date.Location(), false)
}
2026-05-01 22:38:44 +08:00
// LastOpposition 上一次冲日 / previous opposition.
func (module *Jupiter) LastOpposition(date time.Time) time.Time {
jde := basic.UTC2TT(basic.Date2JD(date.UTC()))
return basic.JD2DateByZone(basic.LastJupiterOppositionWithInstance(jde, module.inst), date.Location(), false)
}
2026-05-01 22:38:44 +08:00
// NextOpposition 下一次冲日 / next opposition.
func (module *Jupiter) NextOpposition(date time.Time) time.Time {
jde := basic.UTC2TT(basic.Date2JD(date.UTC()))
return basic.JD2DateByZone(basic.NextJupiterOppositionWithInstance(jde, module.inst), date.Location(), false)
}
2026-05-01 22:38:44 +08:00
// LastProgradeToRetrograde 上一次顺行转逆行留 / previous station from prograde to retrograde.
func (module *Jupiter) LastProgradeToRetrograde(date time.Time) time.Time {
jde := basic.UTC2TT(basic.Date2JD(date.UTC()))
return basic.JD2DateByZone(basic.LastJupiterProgradeToRetrogradeWithInstance(jde, module.inst), date.Location(), false)
}
2026-05-01 22:38:44 +08:00
// NextProgradeToRetrograde 下一次顺行转逆行留 / next station from prograde to retrograde.
func (module *Jupiter) NextProgradeToRetrograde(date time.Time) time.Time {
jde := basic.UTC2TT(basic.Date2JD(date.UTC()))
return basic.JD2DateByZone(basic.NextJupiterProgradeToRetrogradeWithInstance(jde, module.inst), date.Location(), false)
}
2026-05-01 22:38:44 +08:00
// LastRetrogradeToPrograde 上一次逆行转顺行留 / previous station from retrograde to prograde.
func (module *Jupiter) LastRetrogradeToPrograde(date time.Time) time.Time {
jde := basic.UTC2TT(basic.Date2JD(date.UTC()))
return basic.JD2DateByZone(basic.LastJupiterRetrogradeToProgradeWithInstance(jde, module.inst), date.Location(), false)
}
2026-05-01 22:38:44 +08:00
// NextRetrogradeToPrograde 下一次逆行转顺行留 / next station from retrograde to prograde.
func (module *Jupiter) NextRetrogradeToPrograde(date time.Time) time.Time {
jde := basic.UTC2TT(basic.Date2JD(date.UTC()))
return basic.JD2DateByZone(basic.NextJupiterRetrogradeToProgradeWithInstance(jde, module.inst), date.Location(), false)
}
2026-05-01 22:38:44 +08:00
// LastEasternQuadrature 上一次东方照 / previous eastern quadrature.
func (module *Jupiter) LastEasternQuadrature(date time.Time) time.Time {
jde := basic.UTC2TT(basic.Date2JD(date.UTC()))
return basic.JD2DateByZone(basic.LastJupiterEasternQuadratureWithInstance(jde, module.inst), date.Location(), false)
}
2026-05-01 22:38:44 +08:00
// NextEasternQuadrature 下一次东方照 / next eastern quadrature.
func (module *Jupiter) NextEasternQuadrature(date time.Time) time.Time {
jde := basic.UTC2TT(basic.Date2JD(date.UTC()))
return basic.JD2DateByZone(basic.NextJupiterEasternQuadratureWithInstance(jde, module.inst), date.Location(), false)
}
2026-05-01 22:38:44 +08:00
// LastWesternQuadrature 上一次西方照 / previous western quadrature.
func (module *Jupiter) LastWesternQuadrature(date time.Time) time.Time {
jde := basic.UTC2TT(basic.Date2JD(date.UTC()))
return basic.JD2DateByZone(basic.LastJupiterWesternQuadratureWithInstance(jde, module.inst), date.Location(), false)
}
2026-05-01 22:38:44 +08:00
// NextWesternQuadrature 下一次西方照 / next western quadrature.
func (module *Jupiter) NextWesternQuadrature(date time.Time) time.Time {
jde := basic.UTC2TT(basic.Date2JD(date.UTC()))
return basic.JD2DateByZone(basic.NextJupiterWesternQuadratureWithInstance(jde, module.inst), date.Location(), false)
}
// ApparentMagnitude2018 视星等(Mallama & Hilton 2018 模型)/ apparent magnitude, Mallama & Hilton 2018 model.
func (module *Jupiter) ApparentMagnitude2018(date time.Time) float64 {
jd := calendar.Date2JD(date.UTC())
return basic.JupiterMag2018WithInstance(basic.UTC2TT(jd), module.inst)
2019-10-24 10:44:21 +08:00
}