Files
astro/neptune/neptune.go
T

230 lines
9.5 KiB
Go
Raw Normal View History

2019-10-24 10:44:21 +08:00
package neptune
import (
"errors"
"time"
"b612.me/astro/basic"
"b612.me/astro/calendar"
2019-10-24 10:44:21 +08:00
)
var (
ERR_NEPTUNE_NEVER_RISE = errors.New("ERROR:极夜,海王星今日永远在地平线下!")
ERR_NEPTUNE_NEVER_SET = errors.New("ERROR:极昼,海王星今日永远在地平线上!")
// ERR_NEPTUNE_NEVER_DOWN deprecated: -- use ERR_NEPTUNE_NEVER_SET instead
ERR_NEPTUNE_NEVER_DOWN = ERR_NEPTUNE_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_NEPTUNE_NEVER_RISE
case errors.Is(err, basic.ErrNeverSet):
return time.Time{}, ERR_NEPTUNE_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 *Neptune) ApparentLo(date time.Time) float64 {
jd := calendar.Date2JD(date.UTC())
return basic.NeptuneApparentLoWithInstance(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 *Neptune) ApparentBo(date time.Time) float64 {
jd := calendar.Date2JD(date.UTC())
return basic.NeptuneApparentBoWithInstance(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 *Neptune) ApparentRa(date time.Time) float64 {
jd := calendar.Date2JD(date.UTC())
return basic.NeptuneApparentRaWithInstance(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 *Neptune) ApparentDec(date time.Time) float64 {
jd := calendar.Date2JD(date.UTC())
return basic.NeptuneApparentDecWithInstance(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 *Neptune) ApparentRaDec(date time.Time) (float64, float64) {
jd := calendar.Date2JD(date.UTC())
return basic.NeptuneApparentRaDecWithInstance(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 *Neptune) ApparentMagnitude(date time.Time) float64 {
jd := calendar.Date2JD(date.UTC())
return basic.NeptuneMagWithInstance(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 *Neptune) EarthDistance(date time.Time) float64 {
jd := calendar.Date2JD(date.UTC())
return basic.EarthNeptuneAwayWithInstance(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 *Neptune) SunDistance(date time.Time) float64 {
jd := calendar.Date2JD(date.UTC())
return basic.PlanetCoordinateWithInstance(7, 2, basic.UTC2TT(jd), module.inst)
}
// Altitude 站心视高度角,不含大气折射 / topocentric apparent altitude without refraction.
func (module *Neptune) Altitude(date time.Time, lon, lat float64) float64 {
localJD := basic.Date2JD(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
return basic.NeptuneHeightWithInstance(localJD, lon, lat, timezone, module.inst)
}
2026-05-01 22:38:44 +08:00
// Zenith 天顶距 / zenith distance.
func (module *Neptune) 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 *Neptune) Azimuth(date time.Time, lon, lat float64) float64 {
localJD := basic.Date2JD(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
return basic.NeptuneAzimuthWithInstance(localJD, lon, lat, timezone, module.inst)
}
// HourAngle 地心视时角,不含站心视差 / geocentric apparent hour angle without topocentric parallax.
func (module *Neptune) HourAngle(date time.Time, lon float64) float64 {
localJD := basic.Date2JD(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
return basic.NeptuneHourAngleWithInstance(localJD, lon, timezone, module.inst)
}
2026-05-01 22:38:44 +08:00
// CulminationTime 中天时刻 / culmination time.
func (module *Neptune) 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.NeptuneCulminationTimeWithInstance(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 *Neptune) 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.NeptuneRiseTimeWithInstance(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 *Neptune) 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 *Neptune) 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.NeptuneSetTimeWithInstance(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 *Neptune) LastConjunction(date time.Time) time.Time {
jde := basic.UTC2TT(basic.Date2JD(date.UTC()))
return basic.JD2DateByZone(basic.LastNeptuneConjunctionWithInstance(jde, module.inst), date.Location(), false)
}
2026-05-01 22:38:44 +08:00
// NextConjunction 下一次合日 / next conjunction with the Sun.
func (module *Neptune) NextConjunction(date time.Time) time.Time {
jde := basic.UTC2TT(basic.Date2JD(date.UTC()))
return basic.JD2DateByZone(basic.NextNeptuneConjunctionWithInstance(jde, module.inst), date.Location(), false)
}
2026-05-01 22:38:44 +08:00
// LastOpposition 上一次冲日 / previous opposition.
func (module *Neptune) LastOpposition(date time.Time) time.Time {
jde := basic.UTC2TT(basic.Date2JD(date.UTC()))
return basic.JD2DateByZone(basic.LastNeptuneOppositionWithInstance(jde, module.inst), date.Location(), false)
}
2026-05-01 22:38:44 +08:00
// NextOpposition 下一次冲日 / next opposition.
func (module *Neptune) NextOpposition(date time.Time) time.Time {
jde := basic.UTC2TT(basic.Date2JD(date.UTC()))
return basic.JD2DateByZone(basic.NextNeptuneOppositionWithInstance(jde, module.inst), date.Location(), false)
}
2026-05-01 22:38:44 +08:00
// LastProgradeToRetrograde 上一次顺行转逆行留 / previous station from prograde to retrograde.
func (module *Neptune) LastProgradeToRetrograde(date time.Time) time.Time {
jde := basic.UTC2TT(basic.Date2JD(date.UTC()))
return basic.JD2DateByZone(basic.LastNeptuneProgradeToRetrogradeWithInstance(jde, module.inst), date.Location(), false)
}
2026-05-01 22:38:44 +08:00
// NextProgradeToRetrograde 下一次顺行转逆行留 / next station from prograde to retrograde.
func (module *Neptune) NextProgradeToRetrograde(date time.Time) time.Time {
jde := basic.UTC2TT(basic.Date2JD(date.UTC()))
return basic.JD2DateByZone(basic.NextNeptuneProgradeToRetrogradeWithInstance(jde, module.inst), date.Location(), false)
}
2026-05-01 22:38:44 +08:00
// LastRetrogradeToPrograde 上一次逆行转顺行留 / previous station from retrograde to prograde.
func (module *Neptune) LastRetrogradeToPrograde(date time.Time) time.Time {
jde := basic.UTC2TT(basic.Date2JD(date.UTC()))
return basic.JD2DateByZone(basic.LastNeptuneRetrogradeToProgradeWithInstance(jde, module.inst), date.Location(), false)
}
2026-05-01 22:38:44 +08:00
// NextRetrogradeToPrograde 下一次逆行转顺行留 / next station from retrograde to prograde.
func (module *Neptune) NextRetrogradeToPrograde(date time.Time) time.Time {
jde := basic.UTC2TT(basic.Date2JD(date.UTC()))
return basic.JD2DateByZone(basic.NextNeptuneRetrogradeToProgradeWithInstance(jde, module.inst), date.Location(), false)
}
2026-05-01 22:38:44 +08:00
// LastEasternQuadrature 上一次东方照 / previous eastern quadrature.
func (module *Neptune) LastEasternQuadrature(date time.Time) time.Time {
jde := basic.UTC2TT(basic.Date2JD(date.UTC()))
return basic.JD2DateByZone(basic.LastNeptuneEasternQuadratureWithInstance(jde, module.inst), date.Location(), false)
}
2026-05-01 22:38:44 +08:00
// NextEasternQuadrature 下一次东方照 / next eastern quadrature.
func (module *Neptune) NextEasternQuadrature(date time.Time) time.Time {
jde := basic.UTC2TT(basic.Date2JD(date.UTC()))
return basic.JD2DateByZone(basic.NextNeptuneEasternQuadratureWithInstance(jde, module.inst), date.Location(), false)
}
2026-05-01 22:38:44 +08:00
// LastWesternQuadrature 上一次西方照 / previous western quadrature.
func (module *Neptune) LastWesternQuadrature(date time.Time) time.Time {
jde := basic.UTC2TT(basic.Date2JD(date.UTC()))
return basic.JD2DateByZone(basic.LastNeptuneWesternQuadratureWithInstance(jde, module.inst), date.Location(), false)
}
2026-05-01 22:38:44 +08:00
// NextWesternQuadrature 下一次西方照 / next western quadrature.
func (module *Neptune) NextWesternQuadrature(date time.Time) time.Time {
jde := basic.UTC2TT(basic.Date2JD(date.UTC()))
return basic.JD2DateByZone(basic.NextNeptuneWesternQuadratureWithInstance(jde, module.inst), date.Location(), false)
}
// ApparentMagnitude2018 视星等(Mallama & Hilton 2018 模型)/ apparent magnitude, Mallama & Hilton 2018 model.
func (module *Neptune) ApparentMagnitude2018(date time.Time) float64 {
jd := calendar.Date2JD(date.UTC())
return basic.NeptuneMag2018WithInstance(basic.UTC2TT(jd), module.inst)
2019-10-24 10:44:21 +08:00
}