Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
c8dd777a7b
|
|||
|
46b555cd49
|
|||
|
be3af3884c
|
@@ -2,14 +2,17 @@ package basic
|
|||||||
|
|
||||||
import "math"
|
import "math"
|
||||||
|
|
||||||
const exactEventTolerance = 2.0 / 86400.0
|
const (
|
||||||
|
exactEventTolerance = 2.0 / 86400.0
|
||||||
|
exactQueryTTToleranceUT = 0.1 / 86400.0
|
||||||
|
)
|
||||||
|
|
||||||
func sameEventJD(a, b float64) bool {
|
func sameEventJD(a, b float64) bool {
|
||||||
return math.Abs(a-b) <= exactEventTolerance
|
return math.Abs(a-b) <= exactEventTolerance
|
||||||
}
|
}
|
||||||
|
|
||||||
func sameEventUTQueryTT(eventUT, queryTT float64) bool {
|
func sameEventUTQueryTT(eventUT, queryTT float64) bool {
|
||||||
return math.Abs(eventUTQueryTTDelta(eventUT, queryTT)) <= exactEventTolerance
|
return math.Abs(eventUTQueryTTDelta(eventUT, queryTT)) <= exactQueryTTToleranceUT
|
||||||
}
|
}
|
||||||
|
|
||||||
func closestEventUTToQueryTT(queryTT, best float64, candidates ...float64) float64 {
|
func closestEventUTToQueryTT(queryTT, best float64, candidates ...float64) float64 {
|
||||||
|
|||||||
@@ -2,7 +2,11 @@ package basic
|
|||||||
|
|
||||||
import "math"
|
import "math"
|
||||||
|
|
||||||
const innerEventEpsilon = 4.0 / 86400.0
|
const (
|
||||||
|
innerEventEpsilon = 0.1 / 86400.0
|
||||||
|
innerEventWindowPadding = 4.0 / 86400.0
|
||||||
|
innerEventMaximizeEpsilon = 4.0 / 86400.0
|
||||||
|
)
|
||||||
|
|
||||||
func eventQueryTTAsUT(queryTT float64) float64 {
|
func eventQueryTTAsUT(queryTT float64) float64 {
|
||||||
return TD2UT(queryTT, false)
|
return TD2UT(queryTT, false)
|
||||||
@@ -157,7 +161,7 @@ func maximizeInWindow(start, end, coarseStep float64, coarseFn, exactFn func(flo
|
|||||||
guess := scanWindowForMax(start, end, coarseStep, coarseFn)
|
guess := scanWindowForMax(start, end, coarseStep, coarseFn)
|
||||||
left := clampFloat64(guess-coarseStep, start, end)
|
left := clampFloat64(guess-coarseStep, start, end)
|
||||||
right := clampFloat64(guess+coarseStep, start, end)
|
right := clampFloat64(guess+coarseStep, start, end)
|
||||||
if right-left <= innerEventEpsilon {
|
if right-left <= innerEventMaximizeEpsilon {
|
||||||
return guess
|
return guess
|
||||||
}
|
}
|
||||||
for i := 0; i < 20; i++ {
|
for i := 0; i < 20; i++ {
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
package basic
|
package basic
|
||||||
|
|
||||||
import "testing"
|
import (
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
func TestInnerPlanetExactEventBoundaryIncludesCurrent(t *testing.T) {
|
func TestInnerPlanetExactEventBoundaryIncludesCurrent(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
@@ -43,3 +46,60 @@ func TestInnerPlanetExactEventBoundaryIncludesCurrent(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestInnerPlanetNextEventAdvancesPastReturnedEvent(t *testing.T) {
|
||||||
|
cases := []struct {
|
||||||
|
name string
|
||||||
|
seed float64
|
||||||
|
next func(float64) float64
|
||||||
|
}{
|
||||||
|
{name: "MercuryConjunction", seed: ttjdUTC(2026, 5, 1, 0, 0, 0), next: NextMercuryConjunction},
|
||||||
|
{name: "MercuryInferior", seed: ttjdUTC(2026, 5, 1, 0, 0, 0), next: NextMercuryInferiorConjunction},
|
||||||
|
{name: "MercuryP2R", seed: ttjdUTC(2026, 5, 1, 0, 0, 0), next: NextMercuryProgradeToRetrograde},
|
||||||
|
{name: "MercuryEastElongation", seed: ttjdUTC(2026, 5, 1, 0, 0, 0), next: NextMercuryGreatestElongationEast},
|
||||||
|
{name: "VenusConjunction", seed: ttjdUTC(2026, 5, 1, 0, 0, 0), next: NextVenusConjunction},
|
||||||
|
{name: "VenusWestElongation", seed: ttjdUTC(2026, 5, 1, 0, 0, 0), next: NextVenusGreatestElongationWest},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tc := range cases {
|
||||||
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
|
first := tc.next(tc.seed)
|
||||||
|
query := TD2UT(Date2JDE(JDE2DateByZone(first, time.UTC, false).Add(time.Second)), true)
|
||||||
|
next := tc.next(query)
|
||||||
|
if !eventUTQueryAfterOrEqual(next, query) {
|
||||||
|
t.Fatalf("next should be after query: first=%.12f query=%.12f next=%.12f", first, query, next)
|
||||||
|
}
|
||||||
|
if sameEventJD(next, first) {
|
||||||
|
t.Fatalf("next should advance past first event: first=%.12f next=%.12f", first, next)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestInnerPlanetTypedConjunctionExactBoundaryIncludesCurrent(t *testing.T) {
|
||||||
|
cases := []struct {
|
||||||
|
name string
|
||||||
|
seed float64
|
||||||
|
next func(float64) float64
|
||||||
|
last func(float64) float64
|
||||||
|
}{
|
||||||
|
{name: "MercuryInferior", seed: NextMercuryInferiorConjunction(ttjdUTC(2026, 1, 1, 0, 0, 0)), next: NextMercuryInferiorConjunction, last: LastMercuryInferiorConjunction},
|
||||||
|
{name: "MercurySuperior", seed: NextMercurySuperiorConjunction(ttjdUTC(2026, 1, 1, 0, 0, 0)), next: NextMercurySuperiorConjunction, last: LastMercurySuperiorConjunction},
|
||||||
|
{name: "VenusInferior", seed: NextVenusInferiorConjunction(ttjdUTC(2026, 1, 1, 0, 0, 0)), next: NextVenusInferiorConjunction, last: LastVenusInferiorConjunction},
|
||||||
|
{name: "VenusSuperior", seed: NextVenusSuperiorConjunction(ttjdUTC(2026, 1, 1, 0, 0, 0)), next: NextVenusSuperiorConjunction, last: LastVenusSuperiorConjunction},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tc := range cases {
|
||||||
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
|
queryTT := TD2UT(tc.seed, true)
|
||||||
|
last := tc.last(queryTT)
|
||||||
|
next := tc.next(queryTT)
|
||||||
|
if !sameEventJD(last, tc.seed) {
|
||||||
|
t.Fatalf("last exact boundary mismatch: got %.12f want %.12f", last, tc.seed)
|
||||||
|
}
|
||||||
|
if !sameEventJD(next, tc.seed) {
|
||||||
|
t.Fatalf("next exact boundary mismatch: got %.12f want %.12f", next, tc.seed)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
+34
-8
@@ -186,12 +186,29 @@ func marsOppositionFromAfter(oppositionJD float64) float64 {
|
|||||||
return marsConjunctionFull(eventUTNextQueryTT(oppositionJD), 180, 0)
|
return marsConjunctionFull(eventUTNextQueryTT(oppositionJD), 180, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func stabilizeMarsStationNearQuery(jde, date float64, searchBeforeOpposition bool) float64 {
|
||||||
|
if math.Abs(eventUTQueryTTDelta(date, jde)) > exactEventTolerance {
|
||||||
|
return date
|
||||||
|
}
|
||||||
|
if searchBeforeOpposition {
|
||||||
|
stableOppositionJD := NextMarsOpposition(jde)
|
||||||
|
sameOppositionJD := marsOppositionFromAfter(stableOppositionJD)
|
||||||
|
return closestEventUTToQueryTT(jde, date, marsRetrogradeAroundOpposition(stableOppositionJD, true), marsRetrogradeAroundOpposition(sameOppositionJD, true))
|
||||||
|
}
|
||||||
|
stableOppositionJD := LastMarsOpposition(jde)
|
||||||
|
sameOppositionJD := marsOppositionFromBefore(stableOppositionJD)
|
||||||
|
return closestEventUTToQueryTT(jde, date, marsRetrogradeAroundOpposition(stableOppositionJD, false), marsRetrogradeAroundOpposition(sameOppositionJD, false))
|
||||||
|
}
|
||||||
|
|
||||||
func NextMarsRetrogradeToPrograde(jde float64) float64 {
|
func NextMarsRetrogradeToPrograde(jde float64) float64 {
|
||||||
lastOppositionJD := marsConjunctionFull(jde, 180, 0)
|
lastOppositionJD := marsConjunctionFull(jde, 180, 0)
|
||||||
date := marsRetrogradeAroundOpposition(lastOppositionJD, false)
|
date := marsRetrogradeAroundOpposition(lastOppositionJD, false)
|
||||||
|
date = stabilizeMarsStationNearQuery(jde, date, false)
|
||||||
if sameEventUTQueryTT(date, jde) {
|
if sameEventUTQueryTT(date, jde) {
|
||||||
sameOppositionJD := marsOppositionFromBefore(lastOppositionJD)
|
stableOppositionJD := LastMarsOpposition(jde)
|
||||||
return closestEventUTToQueryTT(jde, date, marsRetrogradeAroundOpposition(sameOppositionJD, false))
|
stableDate := marsRetrogradeAroundOpposition(stableOppositionJD, false)
|
||||||
|
sameOppositionJD := marsOppositionFromBefore(stableOppositionJD)
|
||||||
|
return closestEventUTToQueryTT(jde, date, stableDate, marsRetrogradeAroundOpposition(sameOppositionJD, false))
|
||||||
}
|
}
|
||||||
if !eventUTQueryAfterOrEqual(date, jde) {
|
if !eventUTQueryAfterOrEqual(date, jde) {
|
||||||
nextOppositionJD := marsConjunctionFull(jde, 180, 1)
|
nextOppositionJD := marsConjunctionFull(jde, 180, 1)
|
||||||
@@ -203,9 +220,12 @@ func NextMarsRetrogradeToPrograde(jde float64) float64 {
|
|||||||
func LastMarsRetrogradeToPrograde(jde float64) float64 {
|
func LastMarsRetrogradeToPrograde(jde float64) float64 {
|
||||||
lastOppositionJD := marsConjunctionFull(jde, 180, 0)
|
lastOppositionJD := marsConjunctionFull(jde, 180, 0)
|
||||||
date := marsRetrogradeAroundOpposition(lastOppositionJD, false)
|
date := marsRetrogradeAroundOpposition(lastOppositionJD, false)
|
||||||
|
date = stabilizeMarsStationNearQuery(jde, date, false)
|
||||||
if sameEventUTQueryTT(date, jde) {
|
if sameEventUTQueryTT(date, jde) {
|
||||||
sameOppositionJD := marsOppositionFromBefore(lastOppositionJD)
|
stableOppositionJD := LastMarsOpposition(jde)
|
||||||
return closestEventUTToQueryTT(jde, date, marsRetrogradeAroundOpposition(sameOppositionJD, false))
|
stableDate := marsRetrogradeAroundOpposition(stableOppositionJD, false)
|
||||||
|
sameOppositionJD := marsOppositionFromBefore(stableOppositionJD)
|
||||||
|
return closestEventUTToQueryTT(jde, date, stableDate, marsRetrogradeAroundOpposition(sameOppositionJD, false))
|
||||||
}
|
}
|
||||||
if !eventUTQueryBeforeOrEqual(date, jde) {
|
if !eventUTQueryBeforeOrEqual(date, jde) {
|
||||||
previousOppositionJD := marsConjunctionFull(eventUTLastQueryTT(lastOppositionJD), 180, 0)
|
previousOppositionJD := marsConjunctionFull(eventUTLastQueryTT(lastOppositionJD), 180, 0)
|
||||||
@@ -217,9 +237,12 @@ func LastMarsRetrogradeToPrograde(jde float64) float64 {
|
|||||||
func NextMarsProgradeToRetrograde(jde float64) float64 {
|
func NextMarsProgradeToRetrograde(jde float64) float64 {
|
||||||
nextOppositionJD := marsConjunctionFull(jde, 180, 1)
|
nextOppositionJD := marsConjunctionFull(jde, 180, 1)
|
||||||
date := marsRetrogradeAroundOpposition(nextOppositionJD, true)
|
date := marsRetrogradeAroundOpposition(nextOppositionJD, true)
|
||||||
|
date = stabilizeMarsStationNearQuery(jde, date, true)
|
||||||
if sameEventUTQueryTT(date, jde) {
|
if sameEventUTQueryTT(date, jde) {
|
||||||
sameOppositionJD := marsOppositionFromAfter(nextOppositionJD)
|
stableOppositionJD := NextMarsOpposition(jde)
|
||||||
return closestEventUTToQueryTT(jde, date, marsRetrogradeAroundOpposition(sameOppositionJD, true))
|
stableDate := marsRetrogradeAroundOpposition(stableOppositionJD, true)
|
||||||
|
sameOppositionJD := marsOppositionFromAfter(stableOppositionJD)
|
||||||
|
return closestEventUTToQueryTT(jde, date, stableDate, marsRetrogradeAroundOpposition(sameOppositionJD, true))
|
||||||
}
|
}
|
||||||
if !eventUTQueryAfterOrEqual(date, jde) {
|
if !eventUTQueryAfterOrEqual(date, jde) {
|
||||||
followingOppositionJD := marsConjunctionFull(eventUTNextQueryTT(nextOppositionJD), 180, 1)
|
followingOppositionJD := marsConjunctionFull(eventUTNextQueryTT(nextOppositionJD), 180, 1)
|
||||||
@@ -231,9 +254,12 @@ func NextMarsProgradeToRetrograde(jde float64) float64 {
|
|||||||
func LastMarsProgradeToRetrograde(jde float64) float64 {
|
func LastMarsProgradeToRetrograde(jde float64) float64 {
|
||||||
nextOppositionJD := marsConjunctionFull(jde, 180, 1)
|
nextOppositionJD := marsConjunctionFull(jde, 180, 1)
|
||||||
date := marsRetrogradeAroundOpposition(nextOppositionJD, true)
|
date := marsRetrogradeAroundOpposition(nextOppositionJD, true)
|
||||||
|
date = stabilizeMarsStationNearQuery(jde, date, true)
|
||||||
if sameEventUTQueryTT(date, jde) {
|
if sameEventUTQueryTT(date, jde) {
|
||||||
sameOppositionJD := marsOppositionFromAfter(nextOppositionJD)
|
stableOppositionJD := NextMarsOpposition(jde)
|
||||||
return closestEventUTToQueryTT(jde, date, marsRetrogradeAroundOpposition(sameOppositionJD, true))
|
stableDate := marsRetrogradeAroundOpposition(stableOppositionJD, true)
|
||||||
|
sameOppositionJD := marsOppositionFromAfter(stableOppositionJD)
|
||||||
|
return closestEventUTToQueryTT(jde, date, stableDate, marsRetrogradeAroundOpposition(sameOppositionJD, true))
|
||||||
}
|
}
|
||||||
if !eventUTQueryBeforeOrEqual(date, jde) {
|
if !eventUTQueryBeforeOrEqual(date, jde) {
|
||||||
lastOppositionJD := marsConjunctionFull(jde, 180, 0)
|
lastOppositionJD := marsConjunctionFull(jde, 180, 0)
|
||||||
|
|||||||
+22
-2
@@ -168,6 +168,26 @@ func mercuryConjunctionLegacy(jde float64, next uint8) float64 {
|
|||||||
|
|
||||||
func mercuryConjunction(jde float64, next uint8) float64 {
|
func mercuryConjunction(jde float64, next uint8) float64 {
|
||||||
//0=last 1=next
|
//0=last 1=next
|
||||||
|
if math.Abs(mercuryConjunctionExactDelta(jde)) <= 30.0/86400.0 {
|
||||||
|
best := math.NaN()
|
||||||
|
consider := func(inferior bool) {
|
||||||
|
eventUT := TD2UT(mercuryConjunctionExactTT(jde, inferior), false)
|
||||||
|
if next == 0 && !eventUTQueryBeforeOrEqual(eventUT, jde) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if next == 1 && !eventUTQueryAfterOrEqual(eventUT, jde) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if math.IsNaN(best) || math.Abs(eventUTQueryTTDelta(eventUT, jde)) < math.Abs(eventUTQueryTTDelta(best, jde)) {
|
||||||
|
best = eventUT
|
||||||
|
}
|
||||||
|
}
|
||||||
|
consider(true)
|
||||||
|
consider(false)
|
||||||
|
if !math.IsNaN(best) {
|
||||||
|
return best
|
||||||
|
}
|
||||||
|
}
|
||||||
currentDelta := mercuryConjunctionExactDelta(jde)
|
currentDelta := mercuryConjunctionExactDelta(jde)
|
||||||
// pos 大于0:远离太阳 小于0:靠近太阳
|
// pos 大于0:远离太阳 小于0:靠近太阳
|
||||||
distanceTrend := math.Abs(mercuryConjunctionExactDelta(jde+1/86400.0)) - math.Abs(currentDelta)
|
distanceTrend := math.Abs(mercuryConjunctionExactDelta(jde+1/86400.0)) - math.Abs(currentDelta)
|
||||||
@@ -417,12 +437,12 @@ func mercuryGreatestElongationInWindow(start, end float64) float64 {
|
|||||||
|
|
||||||
func mercuryEastElongationWindowEndingAt(inferior float64) (float64, float64) {
|
func mercuryEastElongationWindowEndingAt(inferior float64) (float64, float64) {
|
||||||
lastSuperior := LastMercurySuperiorConjunction(eventUTLastQueryTT(inferior))
|
lastSuperior := LastMercurySuperiorConjunction(eventUTLastQueryTT(inferior))
|
||||||
return lastSuperior + innerEventEpsilon, inferior - innerEventEpsilon
|
return lastSuperior + innerEventWindowPadding, inferior - innerEventWindowPadding
|
||||||
}
|
}
|
||||||
|
|
||||||
func mercuryWestElongationWindowEndingAt(superior float64) (float64, float64) {
|
func mercuryWestElongationWindowEndingAt(superior float64) (float64, float64) {
|
||||||
lastInferior := LastMercuryInferiorConjunction(eventUTLastQueryTT(superior))
|
lastInferior := LastMercuryInferiorConjunction(eventUTLastQueryTT(superior))
|
||||||
return lastInferior + innerEventEpsilon, superior - innerEventEpsilon
|
return lastInferior + innerEventWindowPadding, superior - innerEventWindowPadding
|
||||||
}
|
}
|
||||||
|
|
||||||
func mercuryEastElongationWindowContaining(jde float64) (float64, float64) {
|
func mercuryEastElongationWindowContaining(jde float64) (float64, float64) {
|
||||||
|
|||||||
@@ -0,0 +1,64 @@
|
|||||||
|
package basic
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"os"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type moonGeocentricApparentSample struct {
|
||||||
|
InputUTC string `json:"input_utc"`
|
||||||
|
RightAscension float64 `json:"right_ascension"`
|
||||||
|
Declination float64 `json:"declination"`
|
||||||
|
EclipticLongitude float64 `json:"ecliptic_longitude"`
|
||||||
|
EclipticLatitude float64 `json:"ecliptic_latitude"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMoonGeocentricApparentCoordinatesMatchHorizonsBaseline(t *testing.T) {
|
||||||
|
data, err := os.ReadFile("testdata/moon_geocentric_apparent_baseline.json")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("read baseline: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
var samples []moonGeocentricApparentSample
|
||||||
|
if err := json.Unmarshal(data, &samples); err != nil {
|
||||||
|
t.Fatalf("decode baseline: %v", err)
|
||||||
|
}
|
||||||
|
if len(samples) == 0 {
|
||||||
|
t.Fatal("empty moon apparent baseline")
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, sample := range samples {
|
||||||
|
date, err := time.Parse(time.RFC3339, sample.InputUTC)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("parse sample time %q: %v", sample.InputUTC, err)
|
||||||
|
}
|
||||||
|
jd := TD2UT(Date2JDE(date.UTC()), true)
|
||||||
|
prefix := "moon." + sample.InputUTC
|
||||||
|
|
||||||
|
assertPlanetApparentAngleClose(t, prefix+".RightAscension", HMoonGeocentricApparentRa(jd), sample.RightAscension, 0.001)
|
||||||
|
assertPlanetPhaseClose(t, prefix+".Declination", HMoonGeocentricApparentDec(jd), sample.Declination, 0.001)
|
||||||
|
assertPlanetApparentAngleClose(t, prefix+".EclipticLongitude", HMoonApparentLo(jd), sample.EclipticLongitude, 0.001)
|
||||||
|
assertPlanetPhaseClose(t, prefix+".EclipticLatitude", HMoonTrueBo(jd), sample.EclipticLatitude, 0.001)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMoonGeocentricTrueCoordinatesFollowDefinition(t *testing.T) {
|
||||||
|
samples := []time.Time{
|
||||||
|
time.Date(1900, 1, 14, 12, 0, 0, 0, time.UTC),
|
||||||
|
time.Date(1950, 6, 3, 0, 0, 0, 0, time.UTC),
|
||||||
|
time.Date(2000, 2, 29, 18, 0, 0, 0, time.UTC),
|
||||||
|
time.Date(2026, 1, 1, 6, 0, 0, 0, time.UTC),
|
||||||
|
time.Date(2100, 8, 17, 9, 0, 0, 0, time.UTC),
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, sample := range samples {
|
||||||
|
jd := TD2UT(Date2JDE(sample.UTC()), true)
|
||||||
|
wantRA, wantDec := LoBoToRaDec(jd, HMoonTrueLo(jd), HMoonTrueBo(jd))
|
||||||
|
gotRA, gotDec := HMoonGeocentricTrueRaDec(jd)
|
||||||
|
|
||||||
|
assertPlanetApparentAngleClose(t, sample.Format(time.RFC3339)+".TrueRightAscension", gotRA, wantRA, 1e-12)
|
||||||
|
assertPlanetPhaseClose(t, sample.Format(time.RFC3339)+".TrueDeclination", gotDec, wantDec, 1e-12)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package basic
|
||||||
|
|
||||||
|
import (
|
||||||
|
"math"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestHMoonGeocentricApparentRaDecComponentsMatch(t *testing.T) {
|
||||||
|
jd := TD2UT(JDECalc(2026, 1, 1.25), true)
|
||||||
|
|
||||||
|
ra, dec := HMoonGeocentricApparentRaDec(jd)
|
||||||
|
if diff := math.Abs(ra - HMoonGeocentricApparentRa(jd)); diff > 1e-12 {
|
||||||
|
t.Fatalf("RA pair mismatch: got %.15f want %.15f", ra, HMoonGeocentricApparentRa(jd))
|
||||||
|
}
|
||||||
|
if diff := math.Abs(dec - HMoonGeocentricApparentDec(jd)); diff > 1e-12 {
|
||||||
|
t.Fatalf("Dec pair mismatch: got %.15f want %.15f", dec, HMoonGeocentricApparentDec(jd))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestHMoonGeocentricTrueRaDecComponentsMatch(t *testing.T) {
|
||||||
|
jd := TD2UT(JDECalc(2026, 1, 1.25), true)
|
||||||
|
|
||||||
|
ra, dec := HMoonGeocentricTrueRaDec(jd)
|
||||||
|
if diff := math.Abs(ra - HMoonGeocentricTrueRa(jd)); diff > 1e-12 {
|
||||||
|
t.Fatalf("RA pair mismatch: got %.15f want %.15f", ra, HMoonGeocentricTrueRa(jd))
|
||||||
|
}
|
||||||
|
if diff := math.Abs(dec - HMoonGeocentricTrueDec(jd)); diff > 1e-12 {
|
||||||
|
t.Fatalf("Dec pair mismatch: got %.15f want %.15f", dec, HMoonGeocentricTrueDec(jd))
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,397 @@
|
|||||||
|
package basic
|
||||||
|
|
||||||
|
import "math"
|
||||||
|
|
||||||
|
const (
|
||||||
|
moonPlanetConjunctionEstimateN = 8
|
||||||
|
moonPlanetConjunctionNearQueryDeltaDeg = 3.0
|
||||||
|
moonPlanetConjunctionDirectionEpsilon = 0.1 / 86400.0
|
||||||
|
moonPlanetConjunctionBracketStepDays = 0.5
|
||||||
|
moonPlanetConjunctionNearQueryStepDays = 0.25
|
||||||
|
moonPlanetConjunctionNearQueryHalfSpan = 1.5
|
||||||
|
moonPlanetConjunctionBracketHalfSpan = 2.0
|
||||||
|
moonPlanetConjunctionBracketGrowth = 2.0
|
||||||
|
moonPlanetConjunctionBracketAttempts = 3
|
||||||
|
moonPlanetConjunctionRefineStepDays = 0.5 / 86400.0
|
||||||
|
moonPlanetConjunctionEventTolerance = 0.01
|
||||||
|
moonPlanetConjunctionFallbackSpanScale = 1.5
|
||||||
|
)
|
||||||
|
|
||||||
|
type moonPlanetConjunctionLocalResult struct {
|
||||||
|
lastUT float64
|
||||||
|
nextUT float64
|
||||||
|
}
|
||||||
|
|
||||||
|
func emptyMoonPlanetConjunctionLocalResult() moonPlanetConjunctionLocalResult {
|
||||||
|
return moonPlanetConjunctionLocalResult{
|
||||||
|
lastUT: math.NaN(),
|
||||||
|
nextUT: math.NaN(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MoonPlanetConjunctionPlanet 月球合月目标行星 / target planet for Moon-planet conjunction events.
|
||||||
|
type MoonPlanetConjunctionPlanet int
|
||||||
|
|
||||||
|
const (
|
||||||
|
MoonPlanetConjunctionMercury MoonPlanetConjunctionPlanet = iota + 1
|
||||||
|
MoonPlanetConjunctionVenus
|
||||||
|
MoonPlanetConjunctionMars
|
||||||
|
MoonPlanetConjunctionJupiter
|
||||||
|
MoonPlanetConjunctionSaturn
|
||||||
|
MoonPlanetConjunctionUranus
|
||||||
|
MoonPlanetConjunctionNeptune
|
||||||
|
)
|
||||||
|
|
||||||
|
func moonPlanetConjunctionWrappedDelta(diff float64) float64 {
|
||||||
|
diff = math.Mod(diff+180, 360)
|
||||||
|
if diff < 0 {
|
||||||
|
diff += 360
|
||||||
|
}
|
||||||
|
return diff - 180
|
||||||
|
}
|
||||||
|
|
||||||
|
func moonPlanetConjunctionDeltaAt(jdTT float64, planet MoonPlanetConjunctionPlanet, n int) float64 {
|
||||||
|
moonRA := HMoonGeocentricApparentRaN(jdTT, n)
|
||||||
|
var planetRA float64
|
||||||
|
switch planet {
|
||||||
|
case MoonPlanetConjunctionMercury:
|
||||||
|
planetRA = MercuryApparentRaN(jdTT, n)
|
||||||
|
case MoonPlanetConjunctionVenus:
|
||||||
|
planetRA = VenusApparentRaN(jdTT, n)
|
||||||
|
case MoonPlanetConjunctionMars:
|
||||||
|
planetRA = MarsApparentRaN(jdTT, n)
|
||||||
|
case MoonPlanetConjunctionJupiter:
|
||||||
|
planetRA = JupiterApparentRaN(jdTT, n)
|
||||||
|
case MoonPlanetConjunctionSaturn:
|
||||||
|
planetRA = SaturnApparentRaN(jdTT, n)
|
||||||
|
case MoonPlanetConjunctionUranus:
|
||||||
|
planetRA = UranusApparentRaN(jdTT, n)
|
||||||
|
case MoonPlanetConjunctionNeptune:
|
||||||
|
planetRA = NeptuneApparentRaN(jdTT, n)
|
||||||
|
default:
|
||||||
|
return math.NaN()
|
||||||
|
}
|
||||||
|
return moonPlanetConjunctionWrappedDelta(moonRA - planetRA)
|
||||||
|
}
|
||||||
|
|
||||||
|
func moonPlanetConjunctionPeriodDays(planet MoonPlanetConjunctionPlanet) float64 {
|
||||||
|
switch planet {
|
||||||
|
case MoonPlanetConjunctionMercury:
|
||||||
|
return 28.1
|
||||||
|
case MoonPlanetConjunctionVenus:
|
||||||
|
return 28.4
|
||||||
|
case MoonPlanetConjunctionMars:
|
||||||
|
return 29.2
|
||||||
|
case MoonPlanetConjunctionJupiter:
|
||||||
|
return 28.0
|
||||||
|
case MoonPlanetConjunctionSaturn:
|
||||||
|
return 27.4
|
||||||
|
case MoonPlanetConjunctionUranus:
|
||||||
|
return 27.3
|
||||||
|
case MoonPlanetConjunctionNeptune:
|
||||||
|
return 27.3
|
||||||
|
default:
|
||||||
|
return math.NaN()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func moonPlanetConjunctionBeforeOrEqual(eventUT, queryTT float64) bool {
|
||||||
|
return eventUTQueryTTDelta(eventUT, queryTT) <= moonPlanetConjunctionDirectionEpsilon
|
||||||
|
}
|
||||||
|
|
||||||
|
func moonPlanetConjunctionAfterOrEqual(eventUT, queryTT float64) bool {
|
||||||
|
return eventUTQueryTTDelta(eventUT, queryTT) >= -moonPlanetConjunctionDirectionEpsilon
|
||||||
|
}
|
||||||
|
|
||||||
|
func moonPlanetConjunctionInDirection(eventUT, queryTT float64, direction int) bool {
|
||||||
|
switch direction {
|
||||||
|
case -1:
|
||||||
|
return moonPlanetConjunctionBeforeOrEqual(eventUT, queryTT)
|
||||||
|
case 1:
|
||||||
|
return moonPlanetConjunctionAfterOrEqual(eventUT, queryTT)
|
||||||
|
default:
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func moonPlanetConjunctionFindBracket(centerTT, halfSpan, step float64, planet MoonPlanetConjunctionPlanet) (float64, float64, bool) {
|
||||||
|
if math.IsNaN(centerTT) || math.IsNaN(halfSpan) || math.IsNaN(step) || halfSpan <= 0 || step <= 0 {
|
||||||
|
return 0, 0, false
|
||||||
|
}
|
||||||
|
start := centerTT - halfSpan
|
||||||
|
end := centerTT + halfSpan
|
||||||
|
samples := int(math.Ceil((end-start)/step)) + 1
|
||||||
|
prevTT := start
|
||||||
|
prevVal := moonPlanetConjunctionDeltaAt(prevTT, planet, -1)
|
||||||
|
if math.IsNaN(prevVal) {
|
||||||
|
return 0, 0, false
|
||||||
|
}
|
||||||
|
if prevVal == 0 {
|
||||||
|
return prevTT, prevTT, true
|
||||||
|
}
|
||||||
|
bestLeft := 0.0
|
||||||
|
bestRight := 0.0
|
||||||
|
bestDistance := math.Inf(1)
|
||||||
|
for i := 1; i <= samples; i++ {
|
||||||
|
tt := start + float64(i)*step
|
||||||
|
if tt > end {
|
||||||
|
tt = end
|
||||||
|
}
|
||||||
|
val := moonPlanetConjunctionDeltaAt(tt, planet, -1)
|
||||||
|
if math.IsNaN(val) {
|
||||||
|
return 0, 0, false
|
||||||
|
}
|
||||||
|
if val == 0 {
|
||||||
|
return tt, tt, true
|
||||||
|
}
|
||||||
|
if prevVal*val < 0 {
|
||||||
|
mid := (prevTT + tt) / 2.0
|
||||||
|
distance := math.Abs(mid - centerTT)
|
||||||
|
if distance < bestDistance {
|
||||||
|
bestLeft = prevTT
|
||||||
|
bestRight = tt
|
||||||
|
bestDistance = distance
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if tt == end {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
prevTT = tt
|
||||||
|
prevVal = val
|
||||||
|
}
|
||||||
|
if math.IsInf(bestDistance, 1) {
|
||||||
|
return 0, 0, false
|
||||||
|
}
|
||||||
|
return bestLeft, bestRight, true
|
||||||
|
}
|
||||||
|
|
||||||
|
func moonPlanetConjunctionRefineBracket(leftTT, rightTT float64, planet MoonPlanetConjunctionPlanet) float64 {
|
||||||
|
if leftTT > rightTT {
|
||||||
|
leftTT, rightTT = rightTT, leftTT
|
||||||
|
}
|
||||||
|
if leftTT == rightTT {
|
||||||
|
return leftTT
|
||||||
|
}
|
||||||
|
center := (leftTT + rightTT) / 2.0
|
||||||
|
halfWindow := (rightTT - leftTT) / 2.0
|
||||||
|
return eventZeroRefine(center, halfWindow, moonPlanetConjunctionRefineStepDays, func(sampleTT float64) float64 {
|
||||||
|
return moonPlanetConjunctionDeltaAt(sampleTT, planet, -1)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func moonPlanetConjunctionEventUT(leftTT, rightTT float64, planet MoonPlanetConjunctionPlanet) float64 {
|
||||||
|
eventTT := moonPlanetConjunctionRefineBracket(leftTT, rightTT, planet)
|
||||||
|
if math.Abs(moonPlanetConjunctionDeltaAt(eventTT, planet, -1)) > moonPlanetConjunctionEventTolerance {
|
||||||
|
return math.NaN()
|
||||||
|
}
|
||||||
|
return TD2UT(eventTT, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
func moonPlanetConjunctionCollectLocalEvent(result *moonPlanetConjunctionLocalResult, queryTT, eventUT float64) {
|
||||||
|
if math.IsNaN(eventUT) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if moonPlanetConjunctionBeforeOrEqual(eventUT, queryTT) {
|
||||||
|
if math.IsNaN(result.lastUT) || math.Abs(eventUTQueryTTDelta(eventUT, queryTT)) < math.Abs(eventUTQueryTTDelta(result.lastUT, queryTT)) {
|
||||||
|
result.lastUT = eventUT
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if moonPlanetConjunctionAfterOrEqual(eventUT, queryTT) {
|
||||||
|
if math.IsNaN(result.nextUT) || math.Abs(eventUTQueryTTDelta(eventUT, queryTT)) < math.Abs(eventUTQueryTTDelta(result.nextUT, queryTT)) {
|
||||||
|
result.nextUT = eventUT
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func moonPlanetConjunctionShouldCheckLocal(queryTT float64, planet MoonPlanetConjunctionPlanet) bool {
|
||||||
|
delta := moonPlanetConjunctionDeltaAt(queryTT, planet, moonPlanetConjunctionEstimateN)
|
||||||
|
if math.IsNaN(delta) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return math.Abs(delta) <= moonPlanetConjunctionNearQueryDeltaDeg
|
||||||
|
}
|
||||||
|
|
||||||
|
func moonPlanetConjunctionLocalEvents(queryTT float64, planet MoonPlanetConjunctionPlanet) moonPlanetConjunctionLocalResult {
|
||||||
|
result := emptyMoonPlanetConjunctionLocalResult()
|
||||||
|
start := queryTT - moonPlanetConjunctionNearQueryHalfSpan
|
||||||
|
end := queryTT + moonPlanetConjunctionNearQueryHalfSpan
|
||||||
|
step := moonPlanetConjunctionNearQueryStepDays
|
||||||
|
prevTT := start
|
||||||
|
prevVal := moonPlanetConjunctionDeltaAt(prevTT, planet, -1)
|
||||||
|
if math.IsNaN(prevVal) {
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
samples := int(math.Ceil((end-start)/step)) + 1
|
||||||
|
for i := 1; i <= samples; i++ {
|
||||||
|
tt := start + float64(i)*step
|
||||||
|
if tt > end {
|
||||||
|
tt = end
|
||||||
|
}
|
||||||
|
val := moonPlanetConjunctionDeltaAt(tt, planet, -1)
|
||||||
|
if math.IsNaN(val) {
|
||||||
|
return emptyMoonPlanetConjunctionLocalResult()
|
||||||
|
}
|
||||||
|
if prevVal == 0 || val == 0 || prevVal*val < 0 {
|
||||||
|
moonPlanetConjunctionCollectLocalEvent(&result, queryTT, moonPlanetConjunctionEventUT(prevTT, tt, planet))
|
||||||
|
}
|
||||||
|
if tt == end {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
prevTT = tt
|
||||||
|
prevVal = val
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
func moonPlanetConjunctionMaybeLocalEvents(queryTT float64, planet MoonPlanetConjunctionPlanet) moonPlanetConjunctionLocalResult {
|
||||||
|
if !moonPlanetConjunctionShouldCheckLocal(queryTT, planet) {
|
||||||
|
return emptyMoonPlanetConjunctionLocalResult()
|
||||||
|
}
|
||||||
|
return moonPlanetConjunctionLocalEvents(queryTT, planet)
|
||||||
|
}
|
||||||
|
|
||||||
|
func moonPlanetConjunctionGuessTT(queryTT float64, planet MoonPlanetConjunctionPlanet, direction int) float64 {
|
||||||
|
delta := moonPlanetConjunctionDeltaAt(queryTT, planet, moonPlanetConjunctionEstimateN)
|
||||||
|
if math.IsNaN(delta) {
|
||||||
|
return math.NaN()
|
||||||
|
}
|
||||||
|
period := moonPlanetConjunctionPeriodDays(planet)
|
||||||
|
if math.IsNaN(period) {
|
||||||
|
return math.NaN()
|
||||||
|
}
|
||||||
|
switch direction {
|
||||||
|
case -1:
|
||||||
|
return queryTT - innerLastCycleOffset(delta, period)
|
||||||
|
case 1:
|
||||||
|
return queryTT + innerNextCycleOffset(delta, period)
|
||||||
|
default:
|
||||||
|
return math.NaN()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func moonPlanetConjunctionDirectionalFallback(queryTT float64, planet MoonPlanetConjunctionPlanet, direction int) float64 {
|
||||||
|
period := moonPlanetConjunctionPeriodDays(planet)
|
||||||
|
if math.IsNaN(period) {
|
||||||
|
return math.NaN()
|
||||||
|
}
|
||||||
|
span := period * moonPlanetConjunctionFallbackSpanScale
|
||||||
|
if span <= 0 {
|
||||||
|
return math.NaN()
|
||||||
|
}
|
||||||
|
step := moonPlanetConjunctionNearQueryStepDays
|
||||||
|
start := queryTT
|
||||||
|
end := queryTT
|
||||||
|
switch direction {
|
||||||
|
case -1:
|
||||||
|
start -= span
|
||||||
|
case 1:
|
||||||
|
end += span
|
||||||
|
default:
|
||||||
|
return math.NaN()
|
||||||
|
}
|
||||||
|
|
||||||
|
prevTT := start
|
||||||
|
prevVal := moonPlanetConjunctionDeltaAt(prevTT, planet, -1)
|
||||||
|
if math.IsNaN(prevVal) {
|
||||||
|
return math.NaN()
|
||||||
|
}
|
||||||
|
|
||||||
|
bestEventUT := math.NaN()
|
||||||
|
for tt := start + step; ; tt += step {
|
||||||
|
if tt > end {
|
||||||
|
tt = end
|
||||||
|
}
|
||||||
|
val := moonPlanetConjunctionDeltaAt(tt, planet, -1)
|
||||||
|
if math.IsNaN(val) {
|
||||||
|
return math.NaN()
|
||||||
|
}
|
||||||
|
if prevVal == 0 || val == 0 || prevVal*val < 0 {
|
||||||
|
eventUT := moonPlanetConjunctionEventUT(prevTT, tt, planet)
|
||||||
|
if !math.IsNaN(eventUT) && moonPlanetConjunctionInDirection(eventUT, queryTT, direction) {
|
||||||
|
if direction == 1 {
|
||||||
|
return eventUT
|
||||||
|
}
|
||||||
|
bestEventUT = eventUT
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if tt == end {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
prevTT = tt
|
||||||
|
prevVal = val
|
||||||
|
}
|
||||||
|
return bestEventUT
|
||||||
|
}
|
||||||
|
|
||||||
|
func moonPlanetConjunctionDirectionalEventWithLocal(queryTT float64, planet MoonPlanetConjunctionPlanet, direction int, local moonPlanetConjunctionLocalResult) float64 {
|
||||||
|
switch direction {
|
||||||
|
case -1:
|
||||||
|
if !math.IsNaN(local.lastUT) {
|
||||||
|
return local.lastUT
|
||||||
|
}
|
||||||
|
case 1:
|
||||||
|
if !math.IsNaN(local.nextUT) {
|
||||||
|
return local.nextUT
|
||||||
|
}
|
||||||
|
}
|
||||||
|
guessTT := moonPlanetConjunctionGuessTT(queryTT, planet, direction)
|
||||||
|
if math.IsNaN(guessTT) {
|
||||||
|
return math.NaN()
|
||||||
|
}
|
||||||
|
halfSpan := moonPlanetConjunctionBracketHalfSpan
|
||||||
|
for attempt := 0; attempt < moonPlanetConjunctionBracketAttempts; attempt++ {
|
||||||
|
left, right, ok := moonPlanetConjunctionFindBracket(guessTT, halfSpan, moonPlanetConjunctionBracketStepDays, planet)
|
||||||
|
if ok {
|
||||||
|
eventUT := moonPlanetConjunctionEventUT(left, right, planet)
|
||||||
|
if math.IsNaN(eventUT) {
|
||||||
|
halfSpan *= moonPlanetConjunctionBracketGrowth
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if moonPlanetConjunctionInDirection(eventUT, queryTT, direction) {
|
||||||
|
return eventUT
|
||||||
|
}
|
||||||
|
}
|
||||||
|
halfSpan *= moonPlanetConjunctionBracketGrowth
|
||||||
|
}
|
||||||
|
return moonPlanetConjunctionDirectionalFallback(queryTT, planet, direction)
|
||||||
|
}
|
||||||
|
|
||||||
|
func moonPlanetConjunctionDirectionalEvent(queryTT float64, planet MoonPlanetConjunctionPlanet, direction int) float64 {
|
||||||
|
return moonPlanetConjunctionDirectionalEventWithLocal(queryTT, planet, direction, moonPlanetConjunctionMaybeLocalEvents(queryTT, planet))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LastMoonPlanetConjunction 指定时刻之前最近一次行星合月(赤经合) / previous Moon-planet conjunction at or before jde.
|
||||||
|
func LastMoonPlanetConjunction(jde float64, planet MoonPlanetConjunctionPlanet) float64 {
|
||||||
|
return moonPlanetConjunctionDirectionalEvent(jde, planet, -1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NextMoonPlanetConjunction 指定时刻之后最近一次行星合月(赤经合) / next Moon-planet conjunction at or after jde.
|
||||||
|
func NextMoonPlanetConjunction(jde float64, planet MoonPlanetConjunctionPlanet) float64 {
|
||||||
|
return moonPlanetConjunctionDirectionalEvent(jde, planet, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClosestMoonPlanetConjunction 离指定时刻最近一次行星合月(赤经合) / closest Moon-planet conjunction to jde.
|
||||||
|
func ClosestMoonPlanetConjunction(jde float64, planet MoonPlanetConjunctionPlanet) float64 {
|
||||||
|
local := moonPlanetConjunctionMaybeLocalEvents(jde, planet)
|
||||||
|
if !math.IsNaN(local.lastUT) && !math.IsNaN(local.nextUT) {
|
||||||
|
if sameEventJD(local.lastUT, local.nextUT) {
|
||||||
|
return local.lastUT
|
||||||
|
}
|
||||||
|
return closestEventUTToQueryTT(jde, local.lastUT, local.nextUT)
|
||||||
|
}
|
||||||
|
if !math.IsNaN(local.lastUT) {
|
||||||
|
return local.lastUT
|
||||||
|
}
|
||||||
|
if !math.IsNaN(local.nextUT) {
|
||||||
|
return local.nextUT
|
||||||
|
}
|
||||||
|
last := moonPlanetConjunctionDirectionalEventWithLocal(jde, planet, -1, local)
|
||||||
|
next := moonPlanetConjunctionDirectionalEventWithLocal(jde, planet, 1, local)
|
||||||
|
if math.IsNaN(last) {
|
||||||
|
return next
|
||||||
|
}
|
||||||
|
if math.IsNaN(next) {
|
||||||
|
return last
|
||||||
|
}
|
||||||
|
return closestEventUTToQueryTT(jde, last, next)
|
||||||
|
}
|
||||||
@@ -0,0 +1,284 @@
|
|||||||
|
package basic
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"math"
|
||||||
|
"os"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type moonPlanetConjunctionBaselineSample struct {
|
||||||
|
Planet string `json:"planet"`
|
||||||
|
Year int `json:"year"`
|
||||||
|
Month int `json:"month"`
|
||||||
|
TimeUTC string `json:"time_utc"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type moonPlanetConjunctionBaseline struct {
|
||||||
|
Samples []moonPlanetConjunctionBaselineSample `json:"samples"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func loadMoonPlanetConjunctionBaseline(t *testing.T) moonPlanetConjunctionBaseline {
|
||||||
|
t.Helper()
|
||||||
|
|
||||||
|
paths := [][]string{
|
||||||
|
{
|
||||||
|
"testdata/moon_planet_conjunction_baseline.json",
|
||||||
|
"basic/testdata/moon_planet_conjunction_baseline.json",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"testdata/moon_planet_conjunction_baseline_samples.json",
|
||||||
|
"basic/testdata/moon_planet_conjunction_baseline_samples.json",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
var merged moonPlanetConjunctionBaseline
|
||||||
|
for index, candidates := range paths {
|
||||||
|
var (
|
||||||
|
data []byte
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
for _, path := range candidates {
|
||||||
|
data, err = os.ReadFile(path)
|
||||||
|
if err == nil {
|
||||||
|
var baseline moonPlanetConjunctionBaseline
|
||||||
|
if err := json.Unmarshal(data, &baseline); err != nil {
|
||||||
|
t.Fatalf("decode baseline %s: %v", path, err)
|
||||||
|
}
|
||||||
|
merged.Samples = append(merged.Samples, baseline.Samples...)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if err != nil && index == 0 {
|
||||||
|
t.Fatalf("read baseline: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(merged.Samples) == 0 {
|
||||||
|
t.Fatal("empty moon-planet conjunction baseline")
|
||||||
|
}
|
||||||
|
return merged
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMoonPlanetConjunctionsMatchHorizonsBaseline(t *testing.T) {
|
||||||
|
baseline := loadMoonPlanetConjunctionBaseline(t)
|
||||||
|
|
||||||
|
type conjunctionCase struct {
|
||||||
|
planet MoonPlanetConjunctionPlanet
|
||||||
|
next func(float64, MoonPlanetConjunctionPlanet) float64
|
||||||
|
}
|
||||||
|
|
||||||
|
cases := map[string]conjunctionCase{
|
||||||
|
"mercury": {planet: MoonPlanetConjunctionMercury, next: NextMoonPlanetConjunction},
|
||||||
|
"venus": {planet: MoonPlanetConjunctionVenus, next: NextMoonPlanetConjunction},
|
||||||
|
"mars": {planet: MoonPlanetConjunctionMars, next: NextMoonPlanetConjunction},
|
||||||
|
"jupiter": {planet: MoonPlanetConjunctionJupiter, next: NextMoonPlanetConjunction},
|
||||||
|
"saturn": {planet: MoonPlanetConjunctionSaturn, next: NextMoonPlanetConjunction},
|
||||||
|
"uranus": {planet: MoonPlanetConjunctionUranus, next: NextMoonPlanetConjunction},
|
||||||
|
"neptune": {planet: MoonPlanetConjunctionNeptune, next: NextMoonPlanetConjunction},
|
||||||
|
}
|
||||||
|
|
||||||
|
const tolerance = 20 * time.Second
|
||||||
|
var maxDiff time.Duration
|
||||||
|
|
||||||
|
seen := make(map[string]int, len(cases))
|
||||||
|
for _, sample := range baseline.Samples {
|
||||||
|
tc, ok := cases[sample.Planet]
|
||||||
|
if !ok {
|
||||||
|
t.Fatalf("unknown planet %q", sample.Planet)
|
||||||
|
}
|
||||||
|
|
||||||
|
wantTime, err := time.Parse(time.RFC3339Nano, sample.TimeUTC)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("parse sample time %q: %v", sample.TimeUTC, err)
|
||||||
|
}
|
||||||
|
queryTT := TD2UT(Date2JDE(wantTime.Add(-12*time.Hour).UTC()), true)
|
||||||
|
gotUT := tc.next(queryTT, tc.planet)
|
||||||
|
gotTime := JDE2DateByZone(gotUT, time.UTC, false)
|
||||||
|
diff := gotTime.Sub(wantTime)
|
||||||
|
if diff < 0 {
|
||||||
|
diff = -diff
|
||||||
|
}
|
||||||
|
if diff > maxDiff {
|
||||||
|
maxDiff = diff
|
||||||
|
}
|
||||||
|
if diff > tolerance {
|
||||||
|
t.Fatalf("%s %04d-%02d time mismatch: got %s want %s tolerance %v", sample.Planet, sample.Year, sample.Month, gotTime.Format(time.RFC3339Nano), sample.TimeUTC, tolerance)
|
||||||
|
}
|
||||||
|
|
||||||
|
delta := math.Abs(moonPlanetConjunctionDeltaAt(TD2UT(gotUT, true), tc.planet, -1))
|
||||||
|
if delta > 0.01 {
|
||||||
|
t.Fatalf("%s %04d-%02d event not near conjunction: delta=%.8f deg", sample.Planet, sample.Year, sample.Month, delta)
|
||||||
|
}
|
||||||
|
seen[sample.Planet]++
|
||||||
|
}
|
||||||
|
|
||||||
|
for planet := range cases {
|
||||||
|
if seen[planet] == 0 {
|
||||||
|
t.Fatalf("missing baseline samples for %s", planet)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
t.Logf("moon-planet conjunction max diff: time=%v", maxDiff)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMoonPlanetConjunctionDirectionalConsistencyAtComputedEvent(t *testing.T) {
|
||||||
|
baseline := loadMoonPlanetConjunctionBaseline(t)
|
||||||
|
|
||||||
|
planets := map[string]MoonPlanetConjunctionPlanet{
|
||||||
|
"mercury": MoonPlanetConjunctionMercury,
|
||||||
|
"venus": MoonPlanetConjunctionVenus,
|
||||||
|
"mars": MoonPlanetConjunctionMars,
|
||||||
|
"jupiter": MoonPlanetConjunctionJupiter,
|
||||||
|
"saturn": MoonPlanetConjunctionSaturn,
|
||||||
|
"uranus": MoonPlanetConjunctionUranus,
|
||||||
|
"neptune": MoonPlanetConjunctionNeptune,
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, sample := range baseline.Samples {
|
||||||
|
planet, ok := planets[sample.Planet]
|
||||||
|
if !ok {
|
||||||
|
t.Fatalf("unknown planet %q", sample.Planet)
|
||||||
|
}
|
||||||
|
wantTime, err := time.Parse(time.RFC3339Nano, sample.TimeUTC)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("parse sample time %q: %v", sample.TimeUTC, err)
|
||||||
|
}
|
||||||
|
seedTT := TD2UT(Date2JDE(wantTime.Add(-12*time.Hour).UTC()), true)
|
||||||
|
eventUT := NextMoonPlanetConjunction(seedTT, planet)
|
||||||
|
eventTime := JDE2DateByZone(eventUT, time.UTC, false)
|
||||||
|
queryAtTT := TD2UT(Date2JDE(eventTime.UTC()), true)
|
||||||
|
queryAfterTT := TD2UT(Date2JDE(eventTime.Add(time.Hour).UTC()), true)
|
||||||
|
|
||||||
|
exactNext := NextMoonPlanetConjunction(queryAtTT, planet)
|
||||||
|
exactClosest := ClosestMoonPlanetConjunction(queryAtTT, planet)
|
||||||
|
exactLastAfter := LastMoonPlanetConjunction(queryAfterTT, planet)
|
||||||
|
|
||||||
|
for name, gotUT := range map[string]float64{
|
||||||
|
"exactNext": exactNext,
|
||||||
|
"exactClosest": exactClosest,
|
||||||
|
"lastAfterEvent": exactLastAfter,
|
||||||
|
} {
|
||||||
|
gotTime := JDE2DateByZone(gotUT, time.UTC, false)
|
||||||
|
if diff := math.Abs(gotUT - eventUT); diff > 1e-9 {
|
||||||
|
t.Fatalf("%s %s mismatch: got %s want %s diff=%v", sample.Planet, name, gotTime.Format(time.RFC3339Nano), eventTime.Format(time.RFC3339Nano), diff*86400)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMoonPlanetConjunctionRejectsOppositionBranchJump(t *testing.T) {
|
||||||
|
query := time.Date(1900, 11, 10, 12, 0, 0, 0, time.UTC)
|
||||||
|
queryTT := TD2UT(Date2JDE(query), true)
|
||||||
|
|
||||||
|
lastUT := LastMoonPlanetConjunction(queryTT, MoonPlanetConjunctionSaturn)
|
||||||
|
nextUT := NextMoonPlanetConjunction(queryTT, MoonPlanetConjunctionSaturn)
|
||||||
|
|
||||||
|
if math.Abs(lastUT-Date2JDE(query)) <= 5.0/86400.0 {
|
||||||
|
t.Fatalf("last returned query time on branch jump: got %s", JDE2DateByZone(lastUT, time.UTC, false).Format(time.RFC3339Nano))
|
||||||
|
}
|
||||||
|
if math.Abs(nextUT-Date2JDE(query)) <= 5.0/86400.0 {
|
||||||
|
t.Fatalf("next returned query time on branch jump: got %s", JDE2DateByZone(nextUT, time.UTC, false).Format(time.RFC3339Nano))
|
||||||
|
}
|
||||||
|
|
||||||
|
for name, gotUT := range map[string]float64{
|
||||||
|
"last": lastUT,
|
||||||
|
"next": nextUT,
|
||||||
|
} {
|
||||||
|
delta := math.Abs(moonPlanetConjunctionDeltaAt(TD2UT(gotUT, true), MoonPlanetConjunctionSaturn, -1))
|
||||||
|
if delta > moonPlanetConjunctionEventTolerance {
|
||||||
|
t.Fatalf("%s returned non-event candidate: delta=%.8f event=%s", name, delta, JDE2DateByZone(gotUT, time.UTC, false).Format(time.RFC3339Nano))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMoonPlanetConjunctionDirectionalOrderingOnSampleQueries(t *testing.T) {
|
||||||
|
samples := []struct {
|
||||||
|
planet MoonPlanetConjunctionPlanet
|
||||||
|
query time.Time
|
||||||
|
}{
|
||||||
|
{planet: MoonPlanetConjunctionSaturn, query: time.Date(1700, 4, 15, 12, 0, 0, 0, time.UTC)},
|
||||||
|
{planet: MoonPlanetConjunctionMercury, query: time.Date(1900, 1, 14, 12, 0, 0, 0, time.UTC)},
|
||||||
|
{planet: MoonPlanetConjunctionVenus, query: time.Date(1950, 6, 3, 12, 0, 0, 0, time.UTC)},
|
||||||
|
{planet: MoonPlanetConjunctionMars, query: time.Date(2000, 2, 29, 18, 0, 0, 0, time.UTC)},
|
||||||
|
{planet: MoonPlanetConjunctionJupiter, query: time.Date(2026, 5, 20, 0, 0, 0, 0, time.UTC)},
|
||||||
|
{planet: MoonPlanetConjunctionSaturn, query: time.Date(2100, 8, 17, 6, 0, 0, 0, time.UTC)},
|
||||||
|
{planet: MoonPlanetConjunctionUranus, query: time.Date(2200, 11, 2, 9, 0, 0, 0, time.UTC)},
|
||||||
|
{planet: MoonPlanetConjunctionNeptune, query: time.Date(2300, 4, 24, 3, 0, 0, 0, time.UTC)},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, sample := range samples {
|
||||||
|
queryTT := TD2UT(Date2JDE(sample.query.UTC()), true)
|
||||||
|
lastUT := LastMoonPlanetConjunction(queryTT, sample.planet)
|
||||||
|
nextUT := NextMoonPlanetConjunction(queryTT, sample.planet)
|
||||||
|
closestUT := ClosestMoonPlanetConjunction(queryTT, sample.planet)
|
||||||
|
|
||||||
|
if math.IsNaN(lastUT) || math.IsNaN(nextUT) || math.IsNaN(closestUT) {
|
||||||
|
t.Fatalf("planet=%v query=%s returned NaN event(s): last=%v next=%v closest=%v", sample.planet, sample.query.Format(time.RFC3339), lastUT, nextUT, closestUT)
|
||||||
|
}
|
||||||
|
if !eventUTQueryBeforeOrEqual(lastUT, queryTT) {
|
||||||
|
t.Fatalf("planet=%v last after query: last=%s query=%s", sample.planet, JDE2DateByZone(lastUT, time.UTC, false).Format(time.RFC3339Nano), sample.query.Format(time.RFC3339Nano))
|
||||||
|
}
|
||||||
|
if !eventUTQueryAfterOrEqual(nextUT, queryTT) {
|
||||||
|
t.Fatalf("planet=%v next before query: next=%s query=%s", sample.planet, JDE2DateByZone(nextUT, time.UTC, false).Format(time.RFC3339Nano), sample.query.Format(time.RFC3339Nano))
|
||||||
|
}
|
||||||
|
if closestUT != closestEventUTToQueryTT(queryTT, lastUT, nextUT) {
|
||||||
|
t.Fatalf("planet=%v closest mismatch: got=%s want=%s", sample.planet, JDE2DateByZone(closestUT, time.UTC, false).Format(time.RFC3339Nano), JDE2DateByZone(closestEventUTToQueryTT(queryTT, lastUT, nextUT), time.UTC, false).Format(time.RFC3339Nano))
|
||||||
|
}
|
||||||
|
for name, gotUT := range map[string]float64{
|
||||||
|
"last": lastUT,
|
||||||
|
"next": nextUT,
|
||||||
|
"closest": closestUT,
|
||||||
|
} {
|
||||||
|
delta := math.Abs(moonPlanetConjunctionDeltaAt(TD2UT(gotUT, true), sample.planet, -1))
|
||||||
|
if delta > moonPlanetConjunctionEventTolerance {
|
||||||
|
t.Fatalf("planet=%v %s returned non-event candidate: delta=%.8f event=%s", sample.planet, name, delta, JDE2DateByZone(gotUT, time.UTC, false).Format(time.RFC3339Nano))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMoonPlanetConjunctionKeepsImmediateNeighborEvents(t *testing.T) {
|
||||||
|
query := time.Date(1700, 4, 15, 12, 0, 0, 0, time.UTC)
|
||||||
|
queryTT := TD2UT(Date2JDE(query.UTC()), true)
|
||||||
|
|
||||||
|
lastUT := LastMoonPlanetConjunction(queryTT, MoonPlanetConjunctionSaturn)
|
||||||
|
nextUT := NextMoonPlanetConjunction(queryTT, MoonPlanetConjunctionSaturn)
|
||||||
|
closestUT := ClosestMoonPlanetConjunction(queryTT, MoonPlanetConjunctionSaturn)
|
||||||
|
|
||||||
|
wantLast := time.Date(1700, 4, 15, 11, 55, 59, 115569293, time.UTC)
|
||||||
|
wantNext := time.Date(1700, 5, 13, 0, 35, 5, 981616675, time.UTC)
|
||||||
|
const tolerance = 5.0 / 86400.0
|
||||||
|
|
||||||
|
if diff := math.Abs(lastUT - Date2JDE(wantLast)); diff > tolerance {
|
||||||
|
t.Fatalf("last mismatch: got=%s want=%s diff=%.3fs", JDE2DateByZone(lastUT, time.UTC, false).Format(time.RFC3339Nano), wantLast.Format(time.RFC3339Nano), diff*86400)
|
||||||
|
}
|
||||||
|
if diff := math.Abs(nextUT - Date2JDE(wantNext)); diff > tolerance {
|
||||||
|
t.Fatalf("next mismatch: got=%s want=%s diff=%.3fs", JDE2DateByZone(nextUT, time.UTC, false).Format(time.RFC3339Nano), wantNext.Format(time.RFC3339Nano), diff*86400)
|
||||||
|
}
|
||||||
|
if !sameEventJD(closestUT, lastUT) {
|
||||||
|
t.Fatalf("closest should keep immediate previous event: closest=%s last=%s", JDE2DateByZone(closestUT, time.UTC, false).Format(time.RFC3339Nano), JDE2DateByZone(lastUT, time.UTC, false).Format(time.RFC3339Nano))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMoonPlanetConjunctionNextAdvancesPastReturnedEvent(t *testing.T) {
|
||||||
|
seed := TD2UT(Date2JDE(time.Date(2026, 5, 1, 0, 0, 0, 0, time.UTC)), true)
|
||||||
|
eventUT := NextMoonPlanetConjunction(seed, MoonPlanetConjunctionMercury)
|
||||||
|
query := JDE2DateByZone(eventUT, time.UTC, false).Add(time.Second)
|
||||||
|
queryTT := TD2UT(Date2JDE(query.UTC()), true)
|
||||||
|
|
||||||
|
nextUT := NextMoonPlanetConjunction(queryTT, MoonPlanetConjunctionMercury)
|
||||||
|
if eventUTQueryTTDelta(nextUT, queryTT) <= 0 {
|
||||||
|
t.Fatalf("expected next conjunction after query: query=%s next=%s delta=%.6fs",
|
||||||
|
query.Format(time.RFC3339Nano),
|
||||||
|
JDE2DateByZone(nextUT, time.UTC, false).Format(time.RFC3339Nano),
|
||||||
|
eventUTQueryTTDelta(nextUT, queryTT)*86400,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if sameEventJD(nextUT, eventUT) {
|
||||||
|
t.Fatalf("next conjunction should advance to a later event: event=%s next=%s",
|
||||||
|
JDE2DateByZone(eventUT, time.UTC, false).Format(time.RFC3339Nano),
|
||||||
|
JDE2DateByZone(nextUT, time.UTC, false).Format(time.RFC3339Nano),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -126,6 +126,68 @@ func HMoonApparentLoN(jd float64, n int) float64 {
|
|||||||
return HMoonTrueLoN(jd, n) + Nutation2000Bi(jd)
|
return HMoonTrueLoN(jd, n) + Nutation2000Bi(jd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HMoonGeocentricApparentRa 月亮地心视赤经 / apparent geocentric right ascension of the Moon.
|
||||||
|
func HMoonGeocentricApparentRa(jd float64) float64 {
|
||||||
|
return HMoonGeocentricApparentRaN(jd, -1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HMoonGeocentricApparentRaN 月亮地心视赤经(截断版) / truncated apparent geocentric right ascension of the Moon.
|
||||||
|
func HMoonGeocentricApparentRaN(jd float64, n int) float64 {
|
||||||
|
return LoToRa(jd, HMoonApparentLoN(jd, n), HMoonTrueBoN(jd, n))
|
||||||
|
}
|
||||||
|
|
||||||
|
// HMoonGeocentricApparentDec 月亮地心视赤纬 / apparent geocentric declination of the Moon.
|
||||||
|
func HMoonGeocentricApparentDec(jd float64) float64 {
|
||||||
|
return HMoonGeocentricApparentDecN(jd, -1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HMoonGeocentricApparentDecN 月亮地心视赤纬(截断版) / truncated apparent geocentric declination of the Moon.
|
||||||
|
func HMoonGeocentricApparentDecN(jd float64, n int) float64 {
|
||||||
|
return ArcSin(Sin(HMoonTrueBoN(jd, n))*Cos(TrueObliquity(jd)) +
|
||||||
|
Cos(HMoonTrueBoN(jd, n))*Sin(TrueObliquity(jd))*Sin(HMoonApparentLoN(jd, n)))
|
||||||
|
}
|
||||||
|
|
||||||
|
// HMoonGeocentricApparentRaDec 月亮地心视赤经、视赤纬 / apparent geocentric right ascension and declination of the Moon.
|
||||||
|
func HMoonGeocentricApparentRaDec(jd float64) (float64, float64) {
|
||||||
|
return HMoonGeocentricApparentRaDecN(jd, -1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HMoonGeocentricApparentRaDecN 月亮地心视赤经、视赤纬(截断版) / truncated apparent geocentric right ascension and declination of the Moon.
|
||||||
|
func HMoonGeocentricApparentRaDecN(jd float64, n int) (float64, float64) {
|
||||||
|
return LoBoToRaDec(jd, HMoonApparentLoN(jd, n), HMoonTrueBoN(jd, n))
|
||||||
|
}
|
||||||
|
|
||||||
|
// HMoonGeocentricTrueRa 月亮地心真赤经 / true geocentric right ascension of the Moon.
|
||||||
|
func HMoonGeocentricTrueRa(jd float64) float64 {
|
||||||
|
return HMoonGeocentricTrueRaN(jd, -1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HMoonGeocentricTrueRaN 月亮地心真赤经(截断版) / truncated true geocentric right ascension of the Moon.
|
||||||
|
func HMoonGeocentricTrueRaN(jd float64, n int) float64 {
|
||||||
|
return LoToRa(jd, HMoonTrueLoN(jd, n), HMoonTrueBoN(jd, n))
|
||||||
|
}
|
||||||
|
|
||||||
|
// HMoonGeocentricTrueDec 月亮地心真赤纬 / true geocentric declination of the Moon.
|
||||||
|
func HMoonGeocentricTrueDec(jd float64) float64 {
|
||||||
|
return HMoonGeocentricTrueDecN(jd, -1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HMoonGeocentricTrueDecN 月亮地心真赤纬(截断版) / truncated true geocentric declination of the Moon.
|
||||||
|
func HMoonGeocentricTrueDecN(jd float64, n int) float64 {
|
||||||
|
return ArcSin(Sin(HMoonTrueBoN(jd, n))*Cos(TrueObliquity(jd)) +
|
||||||
|
Cos(HMoonTrueBoN(jd, n))*Sin(TrueObliquity(jd))*Sin(HMoonTrueLoN(jd, n)))
|
||||||
|
}
|
||||||
|
|
||||||
|
// HMoonGeocentricTrueRaDec 月亮地心真赤经、真赤纬 / true geocentric right ascension and declination of the Moon.
|
||||||
|
func HMoonGeocentricTrueRaDec(jd float64) (float64, float64) {
|
||||||
|
return HMoonGeocentricTrueRaDecN(jd, -1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HMoonGeocentricTrueRaDecN 月亮地心真赤经、真赤纬(截断版) / truncated true geocentric right ascension and declination of the Moon.
|
||||||
|
func HMoonGeocentricTrueRaDecN(jd float64, n int) (float64, float64) {
|
||||||
|
return LoBoToRaDec(jd, HMoonTrueLoN(jd, n), HMoonTrueBoN(jd, n))
|
||||||
|
}
|
||||||
|
|
||||||
func HMoonTrueRaDec(jd float64) (float64, float64) {
|
func HMoonTrueRaDec(jd float64) (float64, float64) {
|
||||||
return HMoonTrueRaDecN(jd, -1)
|
return HMoonTrueRaDecN(jd, -1)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ func TestOuterPlanetExactEventBoundaryIncludesCurrent(t *testing.T) {
|
|||||||
{name: "MarsEasternQuadrature", seed: NextMarsEasternQuadrature(ttjdUTC(2026, 1, 1, 0, 0, 0)), lastFn: LastMarsEasternQuadrature, nextFn: NextMarsEasternQuadrature},
|
{name: "MarsEasternQuadrature", seed: NextMarsEasternQuadrature(ttjdUTC(2026, 1, 1, 0, 0, 0)), lastFn: LastMarsEasternQuadrature, nextFn: NextMarsEasternQuadrature},
|
||||||
{name: "MarsWesternQuadrature", seed: NextMarsWesternQuadrature(ttjdUTC(2026, 1, 1, 0, 0, 0)), lastFn: LastMarsWesternQuadrature, nextFn: NextMarsWesternQuadrature},
|
{name: "MarsWesternQuadrature", seed: NextMarsWesternQuadrature(ttjdUTC(2026, 1, 1, 0, 0, 0)), lastFn: LastMarsWesternQuadrature, nextFn: NextMarsWesternQuadrature},
|
||||||
{name: "MarsP2R", seed: NextMarsProgradeToRetrograde(ttjdUTC(2026, 1, 1, 0, 0, 0)), lastFn: LastMarsProgradeToRetrograde, nextFn: NextMarsProgradeToRetrograde},
|
{name: "MarsP2R", seed: NextMarsProgradeToRetrograde(ttjdUTC(2026, 1, 1, 0, 0, 0)), lastFn: LastMarsProgradeToRetrograde, nextFn: NextMarsProgradeToRetrograde},
|
||||||
{name: "MarsR2P", seed: NextMarsRetrogradeToPrograde(ttjdUTC(2026, 1, 1, 0, 0, 0)), lastFn: LastMarsRetrogradeToPrograde, nextFn: NextMarsRetrogradeToPrograde},
|
{name: "MarsR2P", seed: NextMarsRetrogradeToPrograde(ttjdUTC(2025, 1, 1, 0, 0, 0)), lastFn: LastMarsRetrogradeToPrograde, nextFn: NextMarsRetrogradeToPrograde},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range cases {
|
for _, tc := range cases {
|
||||||
@@ -50,6 +50,35 @@ func TestOuterPlanetExactEventBoundaryIncludesCurrent(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestOuterPlanetNextEventAdvancesPastReturnedEvent(t *testing.T) {
|
||||||
|
cases := []struct {
|
||||||
|
name string
|
||||||
|
seed float64
|
||||||
|
next func(float64) float64
|
||||||
|
}{
|
||||||
|
{name: "MarsOpposition", seed: ttjdUTC(2026, 1, 1, 0, 0, 0), next: NextMarsOpposition},
|
||||||
|
{name: "MarsP2R", seed: ttjdUTC(2026, 1, 1, 0, 0, 0), next: NextMarsProgradeToRetrograde},
|
||||||
|
{name: "JupiterOpposition", seed: ttjdUTC(2026, 1, 1, 0, 0, 0), next: NextJupiterOpposition},
|
||||||
|
{name: "SaturnConjunction", seed: ttjdUTC(2026, 1, 1, 0, 0, 0), next: NextSaturnConjunction},
|
||||||
|
{name: "UranusP2R", seed: ttjdUTC(2026, 1, 1, 0, 0, 0), next: NextUranusProgradeToRetrograde},
|
||||||
|
{name: "NeptuneR2P", seed: ttjdUTC(2026, 1, 1, 0, 0, 0), next: NextNeptuneRetrogradeToPrograde},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tc := range cases {
|
||||||
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
|
first := tc.next(tc.seed)
|
||||||
|
query := TD2UT(Date2JDE(JDE2DateByZone(first, time.UTC, false).Add(time.Second)), true)
|
||||||
|
next := tc.next(query)
|
||||||
|
if !eventUTQueryAfterOrEqual(next, query) {
|
||||||
|
t.Fatalf("next should be after query: first=%.12f query=%.12f next=%.12f", first, query, next)
|
||||||
|
}
|
||||||
|
if sameEventJD(next, first) {
|
||||||
|
t.Fatalf("next should advance past first event: first=%.12f next=%.12f", first, next)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func ttjdUTC(year, month, day, hour, min, sec int) float64 {
|
func ttjdUTC(year, month, day, hour, min, sec int) float64 {
|
||||||
return TD2UT(Date2JDE(time.Date(year, time.Month(month), day, hour, min, sec, 0, time.UTC)), true)
|
return TD2UT(Date2JDE(time.Date(year, time.Month(month), day, hour, min, sec, 0, time.UTC)), true)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"input_utc": "2026-01-01T00:00:00Z",
|
||||||
|
"right_ascension": 63.920306258,
|
||||||
|
"declination": 26.403701421,
|
||||||
|
"ecliptic_longitude": 66.7156363,
|
||||||
|
"ecliptic_latitude": 5.0490966
|
||||||
|
}
|
||||||
|
,
|
||||||
|
{
|
||||||
|
"input_utc": "2026-05-01T00:00:00Z",
|
||||||
|
"right_ascension": 208.849626532,
|
||||||
|
"declination": -16.256039871,
|
||||||
|
"ecliptic_longitude": 212.5315932,
|
||||||
|
"ecliptic_latitude": -4.1622995
|
||||||
|
}
|
||||||
|
,
|
||||||
|
{
|
||||||
|
"input_utc": "2026-08-29T00:00:00Z",
|
||||||
|
"right_ascension": 346.062573698,
|
||||||
|
"declination": -4.416718092,
|
||||||
|
"ecliptic_longitude": 345.4608613,
|
||||||
|
"ecliptic_latitude": 1.4247855
|
||||||
|
}
|
||||||
|
,
|
||||||
|
{
|
||||||
|
"input_utc": "2026-12-27T00:00:00Z",
|
||||||
|
"right_ascension": 139.195692903,
|
||||||
|
"declination": 16.272137989,
|
||||||
|
"ecliptic_longitude": 136.6058459,
|
||||||
|
"ecliptic_latitude": 0.4338603
|
||||||
|
}
|
||||||
|
|
||||||
|
]
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
{
|
||||||
|
"samples": [
|
||||||
|
{"planet":"mercury","year":2026,"month":1,"time_utc":"2026-01-18T15:06:38Z"},
|
||||||
|
{"planet":"mercury","year":2026,"month":2,"time_utc":"2026-02-18T23:02:34Z"},
|
||||||
|
{"planet":"mercury","year":2026,"month":3,"time_utc":"2026-03-17T14:07:16Z"},
|
||||||
|
{"planet":"mercury","year":2026,"month":4,"time_utc":"2026-04-15T19:11:09Z"},
|
||||||
|
{"planet":"mercury","year":2026,"month":5,"time_utc":"2026-05-17T02:50:17Z"},
|
||||||
|
{"planet":"mercury","year":2026,"month":6,"time_utc":"2026-06-16T19:32:07Z"},
|
||||||
|
{"planet":"mercury","year":2026,"month":7,"time_utc":"2026-07-14T04:37:03Z"},
|
||||||
|
{"planet":"mercury","year":2026,"month":8,"time_utc":"2026-08-11T12:47:22Z"},
|
||||||
|
{"planet":"mercury","year":2026,"month":9,"time_utc":"2026-09-12T07:28:45Z"},
|
||||||
|
{"planet":"mercury","year":2026,"month":10,"time_utc":"2026-10-12T20:08:25Z"},
|
||||||
|
{"planet":"mercury","year":2026,"month":11,"time_utc":"2026-11-08T16:33:09Z"},
|
||||||
|
{"planet":"mercury","year":2026,"month":12,"time_utc":"2026-12-07T22:03:14Z"},
|
||||||
|
{"planet":"venus","year":2026,"month":1,"time_utc":"2026-01-19T01:01:00Z"},
|
||||||
|
{"planet":"venus","year":2026,"month":2,"time_utc":"2026-02-18T09:20:04Z"},
|
||||||
|
{"planet":"venus","year":2026,"month":3,"time_utc":"2026-03-20T12:37:37Z"},
|
||||||
|
{"planet":"venus","year":2026,"month":4,"time_utc":"2026-04-19T08:47:17Z"},
|
||||||
|
{"planet":"venus","year":2026,"month":5,"time_utc":"2026-05-19T01:49:30Z"},
|
||||||
|
{"planet":"venus","year":2026,"month":6,"time_utc":"2026-06-17T20:20:35Z"},
|
||||||
|
{"planet":"venus","year":2026,"month":7,"time_utc":"2026-07-17T16:31:26Z"},
|
||||||
|
{"planet":"venus","year":2026,"month":8,"time_utc":"2026-08-16T08:47:10Z"},
|
||||||
|
{"planet":"venus","year":2026,"month":9,"time_utc":"2026-09-14T11:10:57Z"},
|
||||||
|
{"planet":"venus","year":2026,"month":10,"time_utc":"2026-10-12T02:31:37Z"},
|
||||||
|
{"planet":"venus","year":2026,"month":11,"time_utc":"2026-11-07T11:33:28Z"},
|
||||||
|
{"planet":"venus","year":2026,"month":12,"time_utc":"2026-12-05T10:44:42Z"},
|
||||||
|
{"planet":"mars","year":2026,"month":1,"time_utc":"2026-01-18T14:09:59Z"},
|
||||||
|
{"planet":"mars","year":2026,"month":2,"time_utc":"2026-02-16T17:40:45Z"},
|
||||||
|
{"planet":"mars","year":2026,"month":3,"time_utc":"2026-03-17T21:52:35Z"},
|
||||||
|
{"planet":"mars","year":2026,"month":4,"time_utc":"2026-04-16T00:46:20Z"},
|
||||||
|
{"planet":"mars","year":2026,"month":5,"time_utc":"2026-05-15T00:44:20Z"},
|
||||||
|
{"planet":"mars","year":2026,"month":6,"time_utc":"2026-06-12T21:15:20Z"},
|
||||||
|
{"planet":"mars","year":2026,"month":7,"time_utc":"2026-07-11T14:38:57Z"},
|
||||||
|
{"planet":"mars","year":2026,"month":8,"time_utc":"2026-08-09T05:31:55Z"},
|
||||||
|
{"planet":"mars","year":2026,"month":9,"time_utc":"2026-09-06T18:25:43Z"},
|
||||||
|
{"planet":"mars","year":2026,"month":10,"time_utc":"2026-10-05T05:31:58Z"},
|
||||||
|
{"planet":"mars","year":2026,"month":11,"time_utc":"2026-11-02T14:25:02Z"},
|
||||||
|
{"planet":"mars","year":2026,"month":11,"time_utc":"2026-11-30T19:34:48Z"},
|
||||||
|
{"planet":"mars","year":2026,"month":12,"time_utc":"2026-12-28T17:44:28Z"},
|
||||||
|
{"planet":"jupiter","year":2026,"month":1,"time_utc":"2026-01-03T21:59:20Z"},
|
||||||
|
{"planet":"jupiter","year":2026,"month":1,"time_utc":"2026-01-31T02:29:07Z"},
|
||||||
|
{"planet":"jupiter","year":2026,"month":2,"time_utc":"2026-02-27T06:24:21Z"},
|
||||||
|
{"planet":"jupiter","year":2026,"month":3,"time_utc":"2026-03-26T12:11:13Z"},
|
||||||
|
{"planet":"jupiter","year":2026,"month":4,"time_utc":"2026-04-22T22:03:39Z"},
|
||||||
|
{"planet":"jupiter","year":2026,"month":5,"time_utc":"2026-05-20T12:36:55Z"},
|
||||||
|
{"planet":"jupiter","year":2026,"month":6,"time_utc":"2026-06-17T06:51:28Z"},
|
||||||
|
{"planet":"jupiter","year":2026,"month":7,"time_utc":"2026-07-15T03:03:33Z"},
|
||||||
|
{"planet":"jupiter","year":2026,"month":8,"time_utc":"2026-08-11T23:22:55Z"},
|
||||||
|
{"planet":"jupiter","year":2026,"month":9,"time_utc":"2026-09-08T18:11:18Z"},
|
||||||
|
{"planet":"jupiter","year":2026,"month":10,"time_utc":"2026-10-06T10:16:20Z"},
|
||||||
|
{"planet":"jupiter","year":2026,"month":11,"time_utc":"2026-11-02T23:09:31Z"},
|
||||||
|
{"planet":"jupiter","year":2026,"month":11,"time_utc":"2026-11-30T09:16:19Z"},
|
||||||
|
{"planet":"jupiter","year":2026,"month":12,"time_utc":"2026-12-27T17:30:35Z"},
|
||||||
|
{"planet":"saturn","year":2026,"month":1,"time_utc":"2026-01-23T12:40:10Z"},
|
||||||
|
{"planet":"saturn","year":2026,"month":2,"time_utc":"2026-02-20T00:03:21Z"},
|
||||||
|
{"planet":"saturn","year":2026,"month":3,"time_utc":"2026-03-19T14:12:20Z"},
|
||||||
|
{"planet":"saturn","year":2026,"month":4,"time_utc":"2026-04-16T06:08:13Z"},
|
||||||
|
{"planet":"saturn","year":2026,"month":5,"time_utc":"2026-05-13T21:58:07Z"},
|
||||||
|
{"planet":"saturn","year":2026,"month":6,"time_utc":"2026-06-10T11:41:01Z"},
|
||||||
|
{"planet":"saturn","year":2026,"month":7,"time_utc":"2026-07-07T21:49:36Z"},
|
||||||
|
{"planet":"saturn","year":2026,"month":8,"time_utc":"2026-08-04T04:10:47Z"},
|
||||||
|
{"planet":"saturn","year":2026,"month":8,"time_utc":"2026-08-31T08:07:26Z"},
|
||||||
|
{"planet":"saturn","year":2026,"month":9,"time_utc":"2026-09-27T12:00:54Z"},
|
||||||
|
{"planet":"saturn","year":2026,"month":10,"time_utc":"2026-10-24T17:41:49Z"},
|
||||||
|
{"planet":"saturn","year":2026,"month":11,"time_utc":"2026-11-21T01:26:46Z"},
|
||||||
|
{"planet":"saturn","year":2026,"month":12,"time_utc":"2026-12-18T10:18:35Z"},
|
||||||
|
{"planet":"uranus","year":2026,"month":1,"time_utc":"2026-01-27T18:46:51Z"},
|
||||||
|
{"planet":"uranus","year":2026,"month":2,"time_utc":"2026-02-24T00:35:51Z"},
|
||||||
|
{"planet":"uranus","year":2026,"month":3,"time_utc":"2026-03-23T07:40:49Z"},
|
||||||
|
{"planet":"uranus","year":2026,"month":4,"time_utc":"2026-04-19T17:35:45Z"},
|
||||||
|
{"planet":"uranus","year":2026,"month":5,"time_utc":"2026-05-17T05:58:41Z"},
|
||||||
|
{"planet":"uranus","year":2026,"month":6,"time_utc":"2026-06-13T19:08:48Z"},
|
||||||
|
{"planet":"uranus","year":2026,"month":7,"time_utc":"2026-07-11T07:07:53Z"},
|
||||||
|
{"planet":"uranus","year":2026,"month":8,"time_utc":"2026-08-07T16:30:03Z"},
|
||||||
|
{"planet":"uranus","year":2026,"month":9,"time_utc":"2026-09-03T23:05:03Z"},
|
||||||
|
{"planet":"uranus","year":2026,"month":10,"time_utc":"2026-10-01T04:18:41Z"},
|
||||||
|
{"planet":"uranus","year":2026,"month":10,"time_utc":"2026-10-28T10:24:46Z"},
|
||||||
|
{"planet":"uranus","year":2026,"month":11,"time_utc":"2026-11-24T18:39:41Z"},
|
||||||
|
{"planet":"uranus","year":2026,"month":12,"time_utc":"2026-12-22T04:19:54Z"},
|
||||||
|
{"planet":"neptune","year":2026,"month":1,"time_utc":"2026-01-23T15:49:28Z"},
|
||||||
|
{"planet":"neptune","year":2026,"month":2,"time_utc":"2026-02-19T23:30:09Z"},
|
||||||
|
{"planet":"neptune","year":2026,"month":3,"time_utc":"2026-03-19T09:34:27Z"},
|
||||||
|
{"planet":"neptune","year":2026,"month":4,"time_utc":"2026-04-15T21:23:14Z"},
|
||||||
|
{"planet":"neptune","year":2026,"month":5,"time_utc":"2026-05-13T09:11:35Z"},
|
||||||
|
{"planet":"neptune","year":2026,"month":6,"time_utc":"2026-06-09T19:13:52Z"},
|
||||||
|
{"planet":"neptune","year":2026,"month":7,"time_utc":"2026-07-07T02:37:58Z"},
|
||||||
|
{"planet":"neptune","year":2026,"month":8,"time_utc":"2026-08-03T07:56:14Z"},
|
||||||
|
{"planet":"neptune","year":2026,"month":8,"time_utc":"2026-08-30T12:50:11Z"},
|
||||||
|
{"planet":"neptune","year":2026,"month":9,"time_utc":"2026-09-26T19:04:28Z"},
|
||||||
|
{"planet":"neptune","year":2026,"month":10,"time_utc":"2026-10-24T03:16:37Z"},
|
||||||
|
{"planet":"neptune","year":2026,"month":11,"time_utc":"2026-11-20T12:35:40Z"},
|
||||||
|
{"planet":"neptune","year":2026,"month":12,"time_utc":"2026-12-17T21:26:40Z"}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
{
|
||||||
|
"samples": [
|
||||||
|
{"planet":"mercury","year":1996,"month":1,"time_utc":"1996-01-20T07:48:44Z"},
|
||||||
|
{"planet":"mercury","year":1996,"month":2,"time_utc":"1996-02-17T05:58:27Z"},
|
||||||
|
{"planet":"mercury","year":1996,"month":3,"time_utc":"1996-03-18T21:54:14Z"},
|
||||||
|
{"planet":"mercury","year":1996,"month":4,"time_utc":"1996-04-19T10:29:52Z"},
|
||||||
|
{"planet":"mercury","year":1996,"month":5,"time_utc":"1996-05-17T04:02:30Z"},
|
||||||
|
{"planet":"mercury","year":1996,"month":6,"time_utc":"1996-06-14T00:19:49Z"},
|
||||||
|
{"planet":"mercury","year":1996,"month":7,"time_utc":"1996-07-16T08:03:39Z"},
|
||||||
|
{"planet":"mercury","year":1996,"month":8,"time_utc":"1996-08-16T18:24:11Z"},
|
||||||
|
{"planet":"mercury","year":1996,"month":9,"time_utc":"1996-09-13T13:17:46Z"},
|
||||||
|
{"planet":"mercury","year":1996,"month":10,"time_utc":"1996-10-11T09:44:59Z"},
|
||||||
|
{"planet":"mercury","year":1996,"month":11,"time_utc":"1996-11-11T12:53:54Z"},
|
||||||
|
{"planet":"mercury","year":1996,"month":12,"time_utc":"1996-12-12T05:10:41Z"},
|
||||||
|
{"planet":"venus","year":1996,"month":1,"time_utc":"1996-01-23T08:25:31Z"},
|
||||||
|
{"planet":"venus","year":1996,"month":2,"time_utc":"1996-02-22T04:36:35Z"},
|
||||||
|
{"planet":"venus","year":1996,"month":3,"time_utc":"1996-03-22T23:53:11Z"},
|
||||||
|
{"planet":"venus","year":1996,"month":4,"time_utc":"1996-04-21T14:13:39Z"},
|
||||||
|
{"planet":"venus","year":1996,"month":5,"time_utc":"1996-05-20T00:40:14Z"},
|
||||||
|
{"planet":"venus","year":1996,"month":6,"time_utc":"1996-06-15T09:13:17Z"},
|
||||||
|
{"planet":"venus","year":1996,"month":7,"time_utc":"1996-07-12T08:38:52Z"},
|
||||||
|
{"planet":"venus","year":1996,"month":8,"time_utc":"1996-08-10T03:59:30Z"},
|
||||||
|
{"planet":"venus","year":1996,"month":9,"time_utc":"1996-09-08T23:10:01Z"},
|
||||||
|
{"planet":"venus","year":1996,"month":10,"time_utc":"1996-10-09T04:07:49Z"},
|
||||||
|
{"planet":"venus","year":1996,"month":11,"time_utc":"1996-11-08T09:31:53Z"},
|
||||||
|
{"planet":"venus","year":1996,"month":12,"time_utc":"1996-12-08T13:14:51Z"},
|
||||||
|
{"planet":"mars","year":1996,"month":1,"time_utc":"1996-01-21T07:43:41Z"},
|
||||||
|
{"planet":"mars","year":1996,"month":2,"time_utc":"1996-02-19T07:57:56Z"},
|
||||||
|
{"planet":"mars","year":1996,"month":3,"time_utc":"1996-03-19T07:08:23Z"},
|
||||||
|
{"planet":"mars","year":1996,"month":4,"time_utc":"1996-04-17T05:16:03Z"},
|
||||||
|
{"planet":"mars","year":1996,"month":5,"time_utc":"1996-05-16T02:56:01Z"},
|
||||||
|
{"planet":"mars","year":1996,"month":6,"time_utc":"1996-06-14T00:47:52Z"},
|
||||||
|
{"planet":"mars","year":1996,"month":7,"time_utc":"1996-07-12T23:06:35Z"},
|
||||||
|
{"planet":"mars","year":1996,"month":8,"time_utc":"1996-08-10T21:29:02Z"},
|
||||||
|
{"planet":"mars","year":1996,"month":9,"time_utc":"1996-09-08T19:05:05Z"},
|
||||||
|
{"planet":"mars","year":1996,"month":10,"time_utc":"1996-10-07T14:58:13Z"},
|
||||||
|
{"planet":"mars","year":1996,"month":11,"time_utc":"1996-11-05T08:08:58Z"},
|
||||||
|
{"planet":"mars","year":1996,"month":12,"time_utc":"1996-12-03T21:11:34Z"},
|
||||||
|
{"planet":"jupiter","year":1996,"month":1,"time_utc":"1996-01-18T19:46:08Z"},
|
||||||
|
{"planet":"jupiter","year":1996,"month":2,"time_utc":"1996-02-15T15:00:36Z"},
|
||||||
|
{"planet":"jupiter","year":1996,"month":3,"time_utc":"1996-03-14T06:11:13Z"},
|
||||||
|
{"planet":"jupiter","year":1996,"month":4,"time_utc":"1996-04-10T16:55:53Z"},
|
||||||
|
{"planet":"jupiter","year":1996,"month":5,"time_utc":"1996-05-08T00:11:28Z"},
|
||||||
|
{"planet":"jupiter","year":1996,"month":6,"time_utc":"1996-06-04T05:31:30Z"},
|
||||||
|
{"planet":"jupiter","year":1996,"month":7,"time_utc":"1996-07-01T10:21:43Z"},
|
||||||
|
{"planet":"jupiter","year":1996,"month":7,"time_utc":"1996-07-28T15:41:14Z"},
|
||||||
|
{"planet":"jupiter","year":1996,"month":8,"time_utc":"1996-08-24T22:04:24Z"},
|
||||||
|
{"planet":"jupiter","year":1996,"month":9,"time_utc":"1996-09-21T05:58:04Z"},
|
||||||
|
{"planet":"jupiter","year":1996,"month":10,"time_utc":"1996-10-18T16:05:44Z"},
|
||||||
|
{"planet":"jupiter","year":1996,"month":11,"time_utc":"1996-11-15T05:27:06Z"},
|
||||||
|
{"planet":"jupiter","year":1996,"month":12,"time_utc":"1996-12-12T22:38:11Z"},
|
||||||
|
{"planet":"saturn","year":1996,"month":1,"time_utc":"1996-01-24T03:47:15Z"},
|
||||||
|
{"planet":"saturn","year":1996,"month":2,"time_utc":"1996-02-20T19:10:42Z"},
|
||||||
|
{"planet":"saturn","year":1996,"month":3,"time_utc":"1996-03-19T10:59:03Z"},
|
||||||
|
{"planet":"saturn","year":1996,"month":4,"time_utc":"1996-04-16T01:04:52Z"},
|
||||||
|
{"planet":"saturn","year":1996,"month":5,"time_utc":"1996-05-13T12:31:53Z"},
|
||||||
|
{"planet":"saturn","year":1996,"month":6,"time_utc":"1996-06-09T21:39:17Z"},
|
||||||
|
{"planet":"saturn","year":1996,"month":7,"time_utc":"1996-07-07T05:32:21Z"},
|
||||||
|
{"planet":"saturn","year":1996,"month":8,"time_utc":"1996-08-03T13:13:36Z"},
|
||||||
|
{"planet":"saturn","year":1996,"month":8,"time_utc":"1996-08-30T21:01:02Z"},
|
||||||
|
{"planet":"saturn","year":1996,"month":9,"time_utc":"1996-09-27T04:20:31Z"},
|
||||||
|
{"planet":"saturn","year":1996,"month":10,"time_utc":"1996-10-24T10:21:42Z"},
|
||||||
|
{"planet":"saturn","year":1996,"month":11,"time_utc":"1996-11-20T15:05:45Z"},
|
||||||
|
{"planet":"saturn","year":1996,"month":12,"time_utc":"1996-12-17T20:17:06Z"},
|
||||||
|
{"planet":"uranus","year":1996,"month":1,"time_utc":"1996-01-20T15:54:24Z"},
|
||||||
|
{"planet":"uranus","year":1996,"month":2,"time_utc":"1996-02-17T05:20:18Z"},
|
||||||
|
{"planet":"uranus","year":1996,"month":3,"time_utc":"1996-03-15T16:05:29Z"},
|
||||||
|
{"planet":"uranus","year":1996,"month":4,"time_utc":"1996-04-11T23:42:31Z"},
|
||||||
|
{"planet":"uranus","year":1996,"month":5,"time_utc":"1996-05-09T05:36:22Z"},
|
||||||
|
{"planet":"uranus","year":1996,"month":6,"time_utc":"1996-06-05T11:50:19Z"},
|
||||||
|
{"planet":"uranus","year":1996,"month":7,"time_utc":"1996-07-02T19:33:47Z"},
|
||||||
|
{"planet":"uranus","year":1996,"month":7,"time_utc":"1996-07-30T04:29:08Z"},
|
||||||
|
{"planet":"uranus","year":1996,"month":8,"time_utc":"1996-08-26T13:21:06Z"},
|
||||||
|
{"planet":"uranus","year":1996,"month":9,"time_utc":"1996-09-22T20:54:56Z"},
|
||||||
|
{"planet":"uranus","year":1996,"month":10,"time_utc":"1996-10-20T03:02:32Z"},
|
||||||
|
{"planet":"uranus","year":1996,"month":11,"time_utc":"1996-11-16T09:17:15Z"},
|
||||||
|
{"planet":"uranus","year":1996,"month":12,"time_utc":"1996-12-13T17:54:51Z"},
|
||||||
|
{"planet":"neptune","year":1996,"month":1,"time_utc":"1996-01-20T07:21:06Z"},
|
||||||
|
{"planet":"neptune","year":1996,"month":2,"time_utc":"1996-02-16T19:38:46Z"},
|
||||||
|
{"planet":"neptune","year":1996,"month":3,"time_utc":"1996-03-15T05:08:50Z"},
|
||||||
|
{"planet":"neptune","year":1996,"month":4,"time_utc":"1996-04-11T11:48:33Z"},
|
||||||
|
{"planet":"neptune","year":1996,"month":5,"time_utc":"1996-05-08T17:24:20Z"},
|
||||||
|
{"planet":"neptune","year":1996,"month":6,"time_utc":"1996-06-04T23:59:10Z"},
|
||||||
|
{"planet":"neptune","year":1996,"month":7,"time_utc":"1996-07-02T08:22:46Z"},
|
||||||
|
{"planet":"neptune","year":1996,"month":7,"time_utc":"1996-07-29T17:55:53Z"},
|
||||||
|
{"planet":"neptune","year":1996,"month":8,"time_utc":"1996-08-26T03:10:20Z"},
|
||||||
|
{"planet":"neptune","year":1996,"month":9,"time_utc":"1996-09-22T10:48:58Z"},
|
||||||
|
{"planet":"neptune","year":1996,"month":10,"time_utc":"1996-10-19T16:49:59Z"},
|
||||||
|
{"planet":"neptune","year":1996,"month":11,"time_utc":"1996-11-15T22:54:41Z"},
|
||||||
|
{"planet":"neptune","year":1996,"month":12,"time_utc":"1996-12-13T07:18:13Z"}
|
||||||
|
]
|
||||||
|
}
|
||||||
+13
-25
@@ -202,10 +202,14 @@ func venusConjunction(jde float64, next uint8) float64 {
|
|||||||
}
|
}
|
||||||
left := queryTT
|
left := queryTT
|
||||||
leftVal := venusSunLongitudeDeltaN(left, venusEventSearchN)
|
leftVal := venusSunLongitudeDeltaN(left, venusEventSearchN)
|
||||||
if math.Abs(leftVal) <= 30.0/86400.0 {
|
if math.Abs(venusSunLongitudeDelta(queryTT)) <= 30.0/86400.0 {
|
||||||
exact := eventZeroRefine(left, 1.0, 0.000005, venusSunLongitudeDelta)
|
exact := eventZeroRefine(left, 1.0, 0.000005, venusSunLongitudeDelta)
|
||||||
if math.Abs(exact-queryTT) <= 1.0 {
|
eventUT := TD2UT(exact, false)
|
||||||
return TD2UT(exact, false)
|
if next == 0 && eventUTQueryBeforeOrEqual(eventUT, queryTT) {
|
||||||
|
return eventUT
|
||||||
|
}
|
||||||
|
if next == 1 && eventUTQueryAfterOrEqual(eventUT, queryTT) {
|
||||||
|
return eventUT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const step = 8.0
|
const step = 8.0
|
||||||
@@ -432,12 +436,12 @@ func venusGreatestElongationInWindow(start, end float64) float64 {
|
|||||||
|
|
||||||
func venusEastElongationWindowEndingAt(inferior float64) (float64, float64) {
|
func venusEastElongationWindowEndingAt(inferior float64) (float64, float64) {
|
||||||
lastSuperior := LastVenusSuperiorConjunction(eventUTLastQueryTT(inferior))
|
lastSuperior := LastVenusSuperiorConjunction(eventUTLastQueryTT(inferior))
|
||||||
return lastSuperior + innerEventEpsilon, inferior - innerEventEpsilon
|
return lastSuperior + innerEventWindowPadding, inferior - innerEventWindowPadding
|
||||||
}
|
}
|
||||||
|
|
||||||
func venusWestElongationWindowEndingAt(superior float64) (float64, float64) {
|
func venusWestElongationWindowEndingAt(superior float64) (float64, float64) {
|
||||||
lastInferior := LastVenusInferiorConjunction(eventUTLastQueryTT(superior))
|
lastInferior := LastVenusInferiorConjunction(eventUTLastQueryTT(superior))
|
||||||
return lastInferior + innerEventEpsilon, superior - innerEventEpsilon
|
return lastInferior + innerEventWindowPadding, superior - innerEventWindowPadding
|
||||||
}
|
}
|
||||||
|
|
||||||
func venusEastElongationWindowContaining(jde float64) (float64, float64) {
|
func venusEastElongationWindowContaining(jde float64) (float64, float64) {
|
||||||
@@ -539,35 +543,19 @@ func LastVenusGreatestElongation(jde float64) float64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func LastVenusInferiorConjunctionInclusive(jde float64) float64 {
|
func LastVenusInferiorConjunctionInclusive(jde float64) float64 {
|
||||||
date := LastVenusConjunction(jde)
|
return inclusiveLastSimpleEvent(jde, LastVenusInferiorConjunction, NextVenusInferiorConjunction)
|
||||||
if venusConjunctionTypeAt(date) {
|
|
||||||
return date
|
|
||||||
}
|
|
||||||
return LastVenusConjunction(eventUTLastQueryTT(date))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NextVenusInferiorConjunctionInclusive(jde float64) float64 {
|
func NextVenusInferiorConjunctionInclusive(jde float64) float64 {
|
||||||
date := NextVenusConjunction(jde)
|
return inclusiveNextSimpleEvent(jde, LastVenusInferiorConjunction, NextVenusInferiorConjunction)
|
||||||
if venusConjunctionTypeAt(date) {
|
|
||||||
return date
|
|
||||||
}
|
|
||||||
return NextVenusConjunction(eventUTNextQueryTT(date))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func LastVenusSuperiorConjunctionInclusive(jde float64) float64 {
|
func LastVenusSuperiorConjunctionInclusive(jde float64) float64 {
|
||||||
date := LastVenusConjunction(jde)
|
return inclusiveLastSimpleEvent(jde, LastVenusSuperiorConjunction, NextVenusSuperiorConjunction)
|
||||||
if !venusConjunctionTypeAt(date) {
|
|
||||||
return date
|
|
||||||
}
|
|
||||||
return LastVenusConjunction(eventUTLastQueryTT(date))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NextVenusSuperiorConjunctionInclusive(jde float64) float64 {
|
func NextVenusSuperiorConjunctionInclusive(jde float64) float64 {
|
||||||
date := NextVenusConjunction(jde)
|
return inclusiveNextSimpleEvent(jde, LastVenusSuperiorConjunction, NextVenusSuperiorConjunction)
|
||||||
if !venusConjunctionTypeAt(date) {
|
|
||||||
return date
|
|
||||||
}
|
|
||||||
return NextVenusConjunction(eventUTNextQueryTT(date))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func LastVenusRetrogradeInclusive(jde float64) float64 {
|
func LastVenusRetrogradeInclusive(jde float64) float64 {
|
||||||
|
|||||||
@@ -50,6 +50,10 @@ const (
|
|||||||
// 返回 农历月,日,是否闰月以及文字描述
|
// 返回 农历月,日,是否闰月以及文字描述
|
||||||
// 按现行农历GB/T 33661-2017算法计算,推荐使用年限为[1929-3000]年
|
// 按现行农历GB/T 33661-2017算法计算,推荐使用年限为[1929-3000]年
|
||||||
// 古代由于定朔定气误差此处计算会与古时不符
|
// 古代由于定朔定气误差此处计算会与古时不符
|
||||||
|
// Inputs are civil year, month, day, and timezone offset in hours.
|
||||||
|
// Returns the lunar year, month, day, leap-month flag, and text description.
|
||||||
|
// The current GB/T 33661-2017 lunar-calendar convention is recommended for years 1929-3000.
|
||||||
|
// For ancient dates, the result may differ from historical practice because computed new-moon and solar-term reconstructions are approximate for ancient dates.
|
||||||
func Lunar(year, month, day int, timezone float64) (int, int, int, bool, string) {
|
func Lunar(year, month, day int, timezone float64) (int, int, int, bool, string) {
|
||||||
return basic.GetLunar(year, month, day, timezone/24.0)
|
return basic.GetLunar(year, month, day, timezone/24.0)
|
||||||
}
|
}
|
||||||
@@ -62,6 +66,12 @@ func Lunar(year, month, day int, timezone float64) (int, int, int, bool, string)
|
|||||||
// 由于农历还未到鼠年,故应当传入Solar(2019,12,30,false)
|
// 由于农历还未到鼠年,故应当传入Solar(2019,12,30,false)
|
||||||
// 按现行农历GB/T 33661-2017算法计算,推荐使用年限为[1929-3000]年
|
// 按现行农历GB/T 33661-2017算法计算,推荐使用年限为[1929-3000]年
|
||||||
// 古代由于定朔定气误差此处计算会与古时不符
|
// 古代由于定朔定气误差此处计算会与古时不符
|
||||||
|
// Inputs are the civil-year proxy of the lunar year, lunar month, lunar day, leap-month flag, and timezone offset in hours.
|
||||||
|
// Returns the corresponding civil time.
|
||||||
|
// The lunar year parameter follows the civil year containing the lunar New Year of that cycle.
|
||||||
|
// For example, the last day of the Ji-Hai year corresponds to 2020-01-24, but should still be passed as `Solar(2019, 12, 30, false, ...)`.
|
||||||
|
// The current GB/T 33661-2017 lunar-calendar convention is recommended for years 1929-3000.
|
||||||
|
// For ancient dates, the result may differ from historical practice because computed new-moon and solar-term reconstructions are approximate for ancient dates.
|
||||||
func Solar(year, month, day int, leap bool, timezone float64) time.Time {
|
func Solar(year, month, day int, leap bool, timezone float64) time.Time {
|
||||||
jde := basic.GetSolar(year, month, day, leap, timezone/24.0)
|
jde := basic.GetSolar(year, month, day, leap, timezone/24.0)
|
||||||
zone := time.FixedZone("CST", int(timezone*3600))
|
zone := time.FixedZone("CST", int(timezone*3600))
|
||||||
@@ -74,6 +84,11 @@ func Solar(year, month, day int, leap bool, timezone float64) time.Time {
|
|||||||
// 支持年份:[-103,3000]
|
// 支持年份:[-103,3000]
|
||||||
// [-103,1912] 按照古代历法提供的农历信息
|
// [-103,1912] 按照古代历法提供的农历信息
|
||||||
// (1912,3000]按现行农历GB/T 33661-2017算法计算
|
// (1912,3000]按现行农历GB/T 33661-2017算法计算
|
||||||
|
// Input is a civil `time.Time`.
|
||||||
|
// Returns a `Time` value carrying the lunar-calendar information.
|
||||||
|
// Supported years are [-103, 3000].
|
||||||
|
// Years [-103, 1912] use the historical-calendar tables included in this package.
|
||||||
|
// Years (1912, 3000] use the current GB/T 33661-2017 lunar-calendar convention.
|
||||||
func SolarToLunar(date time.Time) (Time, error) {
|
func SolarToLunar(date time.Time) (Time, error) {
|
||||||
return innerSolarToLunar(date)
|
return innerSolarToLunar(date)
|
||||||
}
|
}
|
||||||
@@ -84,6 +99,11 @@ func SolarToLunar(date time.Time) (Time, error) {
|
|||||||
// 支持年份:[-103,3000]
|
// 支持年份:[-103,3000]
|
||||||
// [-103,1912] 按照古代历法提供的农历信息
|
// [-103,1912] 按照古代历法提供的农历信息
|
||||||
// (1912,3000]按现行农历GB/T 33661-2017算法计算
|
// (1912,3000]按现行农历GB/T 33661-2017算法计算
|
||||||
|
// Inputs are the civil year, month, and day.
|
||||||
|
// Returns a `Time` value carrying the lunar-calendar information.
|
||||||
|
// Supported years are [-103, 3000].
|
||||||
|
// Years [-103, 1912] use the historical-calendar tables included in this package.
|
||||||
|
// Years (1912, 3000] use the current GB/T 33661-2017 lunar-calendar convention.
|
||||||
func SolarToLunarByYMD(year, month, day int) (Time, error) {
|
func SolarToLunarByYMD(year, month, day int) (Time, error) {
|
||||||
return innerSolarToLunarByYMD(year, month, day)
|
return innerSolarToLunarByYMD(year, month, day)
|
||||||
}
|
}
|
||||||
@@ -165,6 +185,14 @@ func transformModenLunar2Time(date time.Time, year, month, day int, leap bool, d
|
|||||||
// 年号+农历月中文描述+农历日中文描述
|
// 年号+农历月中文描述+农历日中文描述
|
||||||
// 年号+农历月中文描述+干支日中文描述
|
// 年号+农历月中文描述+干支日中文描述
|
||||||
// 支持年份:[-103,3000]
|
// 支持年份:[-103,3000]
|
||||||
|
// Input is a lunar-date description such as `二零二零年正月初一`, `元丰六年十月十二`, or `元嘉二十七年七月庚午日`.
|
||||||
|
// Returns all matching `Time` results with both civil and lunar information.
|
||||||
|
// The parser accepts these forms:
|
||||||
|
// lunar year text + lunar month text + lunar day text
|
||||||
|
// lunar year text + lunar month text + sexagenary day text
|
||||||
|
// era name + lunar month text + lunar day text
|
||||||
|
// era name + lunar month text + sexagenary day text
|
||||||
|
// Supported years are [-103, 3000].
|
||||||
func LunarToSolar(desc string) ([]Time, error) {
|
func LunarToSolar(desc string) ([]Time, error) {
|
||||||
dates, err := innerParseLunar(desc)
|
dates, err := innerParseLunar(desc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -189,6 +217,12 @@ func LunarToSolar(desc string) ([]Time, error) {
|
|||||||
// 支持年份:[-103,3000]
|
// 支持年份:[-103,3000]
|
||||||
// [-103,1912] 按照古代历法提供的农历信息,注意,这里农历月份代表的是以当时的历法推定的农历月与正月的距离,正月为1,二月为2,依次类推,闰月显示所闰月
|
// [-103,1912] 按照古代历法提供的农历信息,注意,这里农历月份代表的是以当时的历法推定的农历月与正月的距离,正月为1,二月为2,依次类推,闰月显示所闰月
|
||||||
// (1912,3000]按现行农历GB/T 33661-2017算法计算
|
// (1912,3000]按现行农历GB/T 33661-2017算法计算
|
||||||
|
// Deprecated: use LunarToSolarByYMD.
|
||||||
|
// Inputs are lunar year, month, day, and the leap-month flag.
|
||||||
|
// Returns a `Time` value carrying both civil and lunar information.
|
||||||
|
// Supported years are [-103, 3000].
|
||||||
|
// For years [-103, 1912], the lunar month index follows the historical calendar in force at that time, counted from the first month of that year.
|
||||||
|
// Years (1912, 3000] use the current GB/T 33661-2017 lunar-calendar convention.
|
||||||
func LunarToSolarSingle(year, month, day int, leap bool) (Time, error) {
|
func LunarToSolarSingle(year, month, day int, leap bool) (Time, error) {
|
||||||
return LunarToSolarByYMD(year, month, day, leap)
|
return LunarToSolarByYMD(year, month, day, leap)
|
||||||
}
|
}
|
||||||
@@ -199,6 +233,11 @@ func LunarToSolarSingle(year, month, day int, leap bool) (Time, error) {
|
|||||||
// 支持年份:[-103,3000]
|
// 支持年份:[-103,3000]
|
||||||
// [-103,1912] 按照古代历法提供的农历信息,注意,这里农历月份代表的是以当时的历法推定的农历月与正月的距离,正月为1,二月为2,依次类推,闰月显示所闰月
|
// [-103,1912] 按照古代历法提供的农历信息,注意,这里农历月份代表的是以当时的历法推定的农历月与正月的距离,正月为1,二月为2,依次类推,闰月显示所闰月
|
||||||
// (1912,3000]按现行农历GB/T 33661-2017算法计算
|
// (1912,3000]按现行农历GB/T 33661-2017算法计算
|
||||||
|
// Inputs are lunar year, month, day, and the leap-month flag.
|
||||||
|
// Returns a `Time` value carrying both civil and lunar information.
|
||||||
|
// Supported years are [-103, 3000].
|
||||||
|
// For years [-103, 1912], the lunar month index follows the historical calendar in force at that time, counted from the first month of that year.
|
||||||
|
// Years (1912, 3000] use the current GB/T 33661-2017 lunar-calendar convention.
|
||||||
func LunarToSolarByYMD(year, month, day int, leap bool) (Time, error) {
|
func LunarToSolarByYMD(year, month, day int, leap bool) (Time, error) {
|
||||||
if year < -103 || year > 9999 {
|
if year < -103 || year > 9999 {
|
||||||
return Time{}, fmt.Errorf("年份超出范围")
|
return Time{}, fmt.Errorf("年份超出范围")
|
||||||
@@ -218,6 +257,7 @@ func LunarToSolarByYMD(year, month, day int, leap bool) (Time, error) {
|
|||||||
// JieQi 节气时刻(北京时间) / solar term instant in Beijing time.
|
// JieQi 节气时刻(北京时间) / solar term instant in Beijing time.
|
||||||
//
|
//
|
||||||
// 返回传入年份、节气对应的北京时间节气时间。
|
// 返回传入年份、节气对应的北京时间节气时间。
|
||||||
|
// Returns the Beijing-time instant of the requested solar term in the supplied year.
|
||||||
func JieQi(year, term int) time.Time {
|
func JieQi(year, term int) time.Time {
|
||||||
calcJde := basic.GetJQTime(year, term)
|
calcJde := basic.GetJQTime(year, term)
|
||||||
zone := time.FixedZone("CST", 8*3600)
|
zone := time.FixedZone("CST", 8*3600)
|
||||||
@@ -227,6 +267,7 @@ func JieQi(year, term int) time.Time {
|
|||||||
// WuHou 物候时刻(北京时间) / pentad instant in Beijing time.
|
// WuHou 物候时刻(北京时间) / pentad instant in Beijing time.
|
||||||
//
|
//
|
||||||
// 返回传入年份、物候对应的北京时间物候时间。
|
// 返回传入年份、物候对应的北京时间物候时间。
|
||||||
|
// Returns the Beijing-time instant of the requested pentad in the supplied year.
|
||||||
func WuHou(year, term int) time.Time {
|
func WuHou(year, term int) time.Time {
|
||||||
calcJde := basic.GetWuHouTime(year, term)
|
calcJde := basic.GetWuHouTime(year, term)
|
||||||
zone := time.FixedZone("CST", 8*3600)
|
zone := time.FixedZone("CST", 8*3600)
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ type Time struct {
|
|||||||
// Solar 公历时间 / solar time.
|
// Solar 公历时间 / solar time.
|
||||||
//
|
//
|
||||||
// 返回内部保存的公历 `time.Time`,不做时区或历法再计算。
|
// 返回内部保存的公历 `time.Time`,不做时区或历法再计算。
|
||||||
|
// Returns the stored civil `time.Time` directly, without any further time-zone or calendar conversion.
|
||||||
func (t Time) Solar() time.Time {
|
func (t Time) Solar() time.Time {
|
||||||
return t.solarTime
|
return t.solarTime
|
||||||
}
|
}
|
||||||
@@ -59,6 +60,7 @@ func (t Time) Solar() time.Time {
|
|||||||
// Time 公历时间 / solar time.
|
// Time 公历时间 / solar time.
|
||||||
//
|
//
|
||||||
// 是 `Solar` 的同义接口,便于把 `calendar.Time` 当作普通时间对象使用。
|
// 是 `Solar` 的同义接口,便于把 `calendar.Time` 当作普通时间对象使用。
|
||||||
|
// This is an alias of `Solar`, convenient when `calendar.Time` is used as a regular time object.
|
||||||
func (t Time) Time() time.Time {
|
func (t Time) Time() time.Time {
|
||||||
return t.solarTime
|
return t.solarTime
|
||||||
}
|
}
|
||||||
@@ -66,6 +68,7 @@ func (t Time) Time() time.Time {
|
|||||||
// Lunars 农历候选结果 / lunar candidates.
|
// Lunars 农历候选结果 / lunar candidates.
|
||||||
//
|
//
|
||||||
// 返回全部候选农历结果。
|
// 返回全部候选农历结果。
|
||||||
|
// Returns all candidate lunar-calendar results.
|
||||||
func (t Time) Lunars() []LunarTime {
|
func (t Time) Lunars() []LunarTime {
|
||||||
return t.lunars
|
return t.lunars
|
||||||
}
|
}
|
||||||
@@ -73,6 +76,7 @@ func (t Time) Lunars() []LunarTime {
|
|||||||
// LunarDesc 农历描述 / lunar descriptions.
|
// LunarDesc 农历描述 / lunar descriptions.
|
||||||
//
|
//
|
||||||
// 返回全部候选结果的农历描述,如开元二年正月初一;若无年号,则返回年份描述,如二零二五年正月初一。
|
// 返回全部候选结果的农历描述,如开元二年正月初一;若无年号,则返回年份描述,如二零二五年正月初一。
|
||||||
|
// Returns the lunar-date descriptions for all candidates. If no era name is available, the year is described directly.
|
||||||
func (t Time) LunarDesc() []string {
|
func (t Time) LunarDesc() []string {
|
||||||
var res []string
|
var res []string
|
||||||
for _, v := range t.lunars {
|
for _, v := range t.lunars {
|
||||||
@@ -84,6 +88,7 @@ func (t Time) LunarDesc() []string {
|
|||||||
// LunarDescWithEmperor 含君主信息的农历描述 / lunar descriptions with emperor.
|
// LunarDescWithEmperor 含君主信息的农历描述 / lunar descriptions with emperor.
|
||||||
//
|
//
|
||||||
// 返回全部候选结果中含有君主信息的农历描述,如唐玄宗 开元二年正月初一;若无年号,则返回年份描述,如二零二五年正月初一。
|
// 返回全部候选结果中含有君主信息的农历描述,如唐玄宗 开元二年正月初一;若无年号,则返回年份描述,如二零二五年正月初一。
|
||||||
|
// Returns the candidate descriptions with emperor names when available. If no era name is available, the year is described directly.
|
||||||
func (t Time) LunarDescWithEmperor() []string {
|
func (t Time) LunarDescWithEmperor() []string {
|
||||||
var res []string
|
var res []string
|
||||||
for _, v := range t.lunars {
|
for _, v := range t.lunars {
|
||||||
@@ -95,6 +100,7 @@ func (t Time) LunarDescWithEmperor() []string {
|
|||||||
// LunarDescWithDynasty 含朝代信息的农历描述 / lunar descriptions with dynasty.
|
// LunarDescWithDynasty 含朝代信息的农历描述 / lunar descriptions with dynasty.
|
||||||
//
|
//
|
||||||
// 返回全部候选结果中含有朝代信息的农历描述,如唐 开元二年正月初一;若无年号,则返回年份描述,如二零二五年正月初一。
|
// 返回全部候选结果中含有朝代信息的农历描述,如唐 开元二年正月初一;若无年号,则返回年份描述,如二零二五年正月初一。
|
||||||
|
// Returns the candidate descriptions with dynasty names when available. If no era name is available, the year is described directly.
|
||||||
func (t Time) LunarDescWithDynasty() []string {
|
func (t Time) LunarDescWithDynasty() []string {
|
||||||
var res []string
|
var res []string
|
||||||
for _, v := range t.lunars {
|
for _, v := range t.lunars {
|
||||||
@@ -106,6 +112,7 @@ func (t Time) LunarDescWithDynasty() []string {
|
|||||||
// LunarDescWithDynastyAndEmperor 含朝代与君主信息的农历描述 / lunar descriptions with dynasty and emperor.
|
// LunarDescWithDynastyAndEmperor 含朝代与君主信息的农历描述 / lunar descriptions with dynasty and emperor.
|
||||||
//
|
//
|
||||||
// 返回全部候选结果中含有朝代和君主信息的农历描述,如唐 唐玄宗 开元二年正月初一;若无年号,则返回年份描述,如二零二五年正月初一。
|
// 返回全部候选结果中含有朝代和君主信息的农历描述,如唐 唐玄宗 开元二年正月初一;若无年号,则返回年份描述,如二零二五年正月初一。
|
||||||
|
// Returns the candidate descriptions with both dynasty and emperor names when available. If no era name is available, the year is described directly.
|
||||||
func (t Time) LunarDescWithDynastyAndEmperor() []string {
|
func (t Time) LunarDescWithDynastyAndEmperor() []string {
|
||||||
var res []string
|
var res []string
|
||||||
for _, v := range t.lunars {
|
for _, v := range t.lunars {
|
||||||
@@ -117,6 +124,7 @@ func (t Time) LunarDescWithDynastyAndEmperor() []string {
|
|||||||
// LunarInfo 农历结构化信息 / structured lunar information.
|
// LunarInfo 农历结构化信息 / structured lunar information.
|
||||||
//
|
//
|
||||||
// 返回全部候选结果对应的结构化农历信息切片。
|
// 返回全部候选结果对应的结构化农历信息切片。
|
||||||
|
// Returns the structured lunar-calendar information for all candidates.
|
||||||
func (t Time) LunarInfo() []LunarInfo {
|
func (t Time) LunarInfo() []LunarInfo {
|
||||||
var res []LunarInfo
|
var res []LunarInfo
|
||||||
for _, v := range t.lunars {
|
for _, v := range t.lunars {
|
||||||
@@ -128,6 +136,7 @@ func (t Time) LunarInfo() []LunarInfo {
|
|||||||
// Eras 朝代、皇帝、年号信息 / era information.
|
// Eras 朝代、皇帝、年号信息 / era information.
|
||||||
//
|
//
|
||||||
// 返回全部候选结果对应的朝代、皇帝、年号信息。
|
// 返回全部候选结果对应的朝代、皇帝、年号信息。
|
||||||
|
// Returns the dynasty, emperor, and era-name records associated with all candidates.
|
||||||
func (t Time) Eras() []EraDesc {
|
func (t Time) Eras() []EraDesc {
|
||||||
var res []EraDesc
|
var res []EraDesc
|
||||||
for _, v := range t.lunars {
|
for _, v := range t.lunars {
|
||||||
@@ -139,6 +148,7 @@ func (t Time) Eras() []EraDesc {
|
|||||||
// Lunar 首个农历结果 / first lunar result.
|
// Lunar 首个农历结果 / first lunar result.
|
||||||
//
|
//
|
||||||
// 若存在多个候选结果,只返回第一个;无结果时返回零值 `LunarTime`。
|
// 若存在多个候选结果,只返回第一个;无结果时返回零值 `LunarTime`。
|
||||||
|
// Returns only the first candidate when multiple results exist. A zero-value `LunarTime` is returned when no result is available.
|
||||||
func (t Time) Lunar() LunarTime {
|
func (t Time) Lunar() LunarTime {
|
||||||
if len(t.lunars) > 0 {
|
if len(t.lunars) > 0 {
|
||||||
return t.lunars[0]
|
return t.lunars[0]
|
||||||
@@ -149,6 +159,7 @@ func (t Time) Lunar() LunarTime {
|
|||||||
// Add 时间偏移 / add a duration.
|
// Add 时间偏移 / add a duration.
|
||||||
//
|
//
|
||||||
// 返回公历时间偏移后的农历结果。
|
// 返回公历时间偏移后的农历结果。
|
||||||
|
// Returns the lunar-calendar result after applying the duration to the stored civil time.
|
||||||
func (t Time) Add(d time.Duration) Time {
|
func (t Time) Add(d time.Duration) Time {
|
||||||
if d < time.Second {
|
if d < time.Second {
|
||||||
newT := t.solarTime.Add(d)
|
newT := t.solarTime.Add(d)
|
||||||
@@ -236,6 +247,7 @@ func (l LunarTime) IsLeap() bool {
|
|||||||
// Eras 朝代、皇帝、年号信息 / era information.
|
// Eras 朝代、皇帝、年号信息 / era information.
|
||||||
//
|
//
|
||||||
// 返回该农历结果对应的朝代、皇帝、年号信息。
|
// 返回该农历结果对应的朝代、皇帝、年号信息。
|
||||||
|
// Returns the dynasty, emperor, and era-name records associated with this lunar result.
|
||||||
func (l LunarTime) Eras() []EraDesc {
|
func (l LunarTime) Eras() []EraDesc {
|
||||||
return l.eras
|
return l.eras
|
||||||
}
|
}
|
||||||
@@ -243,6 +255,7 @@ func (l LunarTime) Eras() []EraDesc {
|
|||||||
// MonthDay 农历月日描述 / lunar month-day description.
|
// MonthDay 农历月日描述 / lunar month-day description.
|
||||||
//
|
//
|
||||||
// 获取农历月日描述,如正月初一。此处,十一月表示为冬月,十二月表示为腊月。
|
// 获取农历月日描述,如正月初一。此处,十一月表示为冬月,十二月表示为腊月。
|
||||||
|
// Returns the lunar month-day description, such as `正月初一`. In this package, month 11 is written as `冬月` and month 12 as `腊月`.
|
||||||
func (l LunarTime) MonthDay() string {
|
func (l LunarTime) MonthDay() string {
|
||||||
return l.desc
|
return l.desc
|
||||||
}
|
}
|
||||||
@@ -250,6 +263,7 @@ func (l LunarTime) MonthDay() string {
|
|||||||
// LunarDesc 农历描述 / lunar descriptions.
|
// LunarDesc 农历描述 / lunar descriptions.
|
||||||
//
|
//
|
||||||
// 获取农历描述,如开元二年正月初一,若无年号,则返回年份描述,如二零二五年正月初一。
|
// 获取农历描述,如开元二年正月初一,若无年号,则返回年份描述,如二零二五年正月初一。
|
||||||
|
// Returns the lunar-date descriptions for this result. If no era name is available, the year is described directly.
|
||||||
func (l LunarTime) LunarDesc() []string {
|
func (l LunarTime) LunarDesc() []string {
|
||||||
return l.innerDescWithNianHao(false, false)
|
return l.innerDescWithNianHao(false, false)
|
||||||
}
|
}
|
||||||
@@ -258,6 +272,7 @@ func (l LunarTime) LunarDesc() []string {
|
|||||||
//
|
//
|
||||||
// 获取含有君主信息的农历描述,如唐玄宗 开元二年正月初一,若无年号,则返回年份描述,如二零二五年正月初一。
|
// 获取含有君主信息的农历描述,如唐玄宗 开元二年正月初一,若无年号,则返回年份描述,如二零二五年正月初一。
|
||||||
// 君主信息仅供参考,多个皇帝用同一个年号的场景,此处不准
|
// 君主信息仅供参考,多个皇帝用同一个年号的场景,此处不准
|
||||||
|
// Returns the lunar-date descriptions with emperor names when available. Emperor names are for reference only and may be ambiguous when multiple emperors used the same era name.
|
||||||
func (l LunarTime) LunarDescWithEmperor() []string {
|
func (l LunarTime) LunarDescWithEmperor() []string {
|
||||||
return l.innerDescWithNianHao(true, false)
|
return l.innerDescWithNianHao(true, false)
|
||||||
}
|
}
|
||||||
@@ -265,6 +280,7 @@ func (l LunarTime) LunarDescWithEmperor() []string {
|
|||||||
// LunarDescWithDynasty 含朝代信息的农历描述 / lunar descriptions with dynasty.
|
// LunarDescWithDynasty 含朝代信息的农历描述 / lunar descriptions with dynasty.
|
||||||
//
|
//
|
||||||
// 获取含有朝代信息的农历描述,如唐 开元二年正月初一,若无年号,则返回年份描述,如二零二五年正月初一。
|
// 获取含有朝代信息的农历描述,如唐 开元二年正月初一,若无年号,则返回年份描述,如二零二五年正月初一。
|
||||||
|
// Returns the lunar-date descriptions with dynasty names when available. If no era name is available, the year is described directly.
|
||||||
func (l LunarTime) LunarDescWithDynasty() []string {
|
func (l LunarTime) LunarDescWithDynasty() []string {
|
||||||
return l.innerDescWithNianHao(false, true)
|
return l.innerDescWithNianHao(false, true)
|
||||||
}
|
}
|
||||||
@@ -273,6 +289,7 @@ func (l LunarTime) LunarDescWithDynasty() []string {
|
|||||||
//
|
//
|
||||||
// 获取含有朝代和君主信息的农历描述,如唐 唐玄宗 开元二年正月初一,若无年号,则返回年份描述,如二零二五年正月初一。
|
// 获取含有朝代和君主信息的农历描述,如唐 唐玄宗 开元二年正月初一,若无年号,则返回年份描述,如二零二五年正月初一。
|
||||||
// 君主信息仅供参考,多个皇帝用同一个年号的场景,此处不准
|
// 君主信息仅供参考,多个皇帝用同一个年号的场景,此处不准
|
||||||
|
// Returns the lunar-date descriptions with both dynasty and emperor names when available. Emperor names are for reference only and may be ambiguous when multiple emperors used the same era name.
|
||||||
func (l LunarTime) LunarDescWithDynastyAndEmperor() []string {
|
func (l LunarTime) LunarDescWithDynastyAndEmperor() []string {
|
||||||
return l.innerDescWithNianHao(true, true)
|
return l.innerDescWithNianHao(true, true)
|
||||||
}
|
}
|
||||||
@@ -299,6 +316,7 @@ func (l LunarTime) innerDescWithNianHao(withEmperor bool, withDynasty bool) []st
|
|||||||
// LunarInfo 农历结构化信息 / structured lunar information.
|
// LunarInfo 农历结构化信息 / structured lunar information.
|
||||||
//
|
//
|
||||||
// 返回该农历结果对应的结构化农历信息切片;若存在多个并行年号,则会有多条记录。
|
// 返回该农历结果对应的结构化农历信息切片;若存在多个并行年号,则会有多条记录。
|
||||||
|
// Returns the structured lunar-calendar information for this result. Multiple records are returned when parallel era-name interpretations exist.
|
||||||
func (l LunarTime) LunarInfo() []LunarInfo {
|
func (l LunarTime) LunarInfo() []LunarInfo {
|
||||||
var res []LunarInfo
|
var res []LunarInfo
|
||||||
for _, v := range l.eras {
|
for _, v := range l.eras {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import "b612.me/astro/formula"
|
|||||||
// AirmassPlaneParallelFromTrueAltitude 平行平板大气质量 / plane-parallel airmass from true altitude.
|
// AirmassPlaneParallelFromTrueAltitude 平行平板大气质量 / plane-parallel airmass from true altitude.
|
||||||
//
|
//
|
||||||
// 输入为真高度角,单位度。适合中高空几何近似,接近地平线时会发散。
|
// 输入为真高度角,单位度。适合中高空几何近似,接近地平线时会发散。
|
||||||
|
// Input is true altitude in degrees. This geometric approximation is suitable at moderate and high altitudes but diverges near the horizon.
|
||||||
func AirmassPlaneParallelFromTrueAltitude(trueAltitude float64) float64 {
|
func AirmassPlaneParallelFromTrueAltitude(trueAltitude float64) float64 {
|
||||||
return formula.AirmassPlaneParallel(trueAltitude)
|
return formula.AirmassPlaneParallel(trueAltitude)
|
||||||
}
|
}
|
||||||
@@ -12,6 +13,7 @@ func AirmassPlaneParallelFromTrueAltitude(trueAltitude float64) float64 {
|
|||||||
// AirmassKastenYoungFromApparentAltitude Kasten-Young 大气质量 / Kasten-Young airmass from apparent altitude.
|
// AirmassKastenYoungFromApparentAltitude Kasten-Young 大气质量 / Kasten-Young airmass from apparent altitude.
|
||||||
//
|
//
|
||||||
// 输入为视高度角,单位度。
|
// 输入为视高度角,单位度。
|
||||||
|
// Input is apparent altitude in degrees.
|
||||||
func AirmassKastenYoungFromApparentAltitude(apparentAltitude float64) float64 {
|
func AirmassKastenYoungFromApparentAltitude(apparentAltitude float64) float64 {
|
||||||
return formula.AirmassKastenYoung(apparentAltitude)
|
return formula.AirmassKastenYoung(apparentAltitude)
|
||||||
}
|
}
|
||||||
@@ -19,6 +21,7 @@ func AirmassKastenYoungFromApparentAltitude(apparentAltitude float64) float64 {
|
|||||||
// AirmassPickeringFromApparentAltitude Pickering 大气质量 / Pickering airmass from apparent altitude.
|
// AirmassPickeringFromApparentAltitude Pickering 大气质量 / Pickering airmass from apparent altitude.
|
||||||
//
|
//
|
||||||
// 输入为视高度角,单位度。
|
// 输入为视高度角,单位度。
|
||||||
|
// Input is apparent altitude in degrees.
|
||||||
func AirmassPickeringFromApparentAltitude(apparentAltitude float64) float64 {
|
func AirmassPickeringFromApparentAltitude(apparentAltitude float64) float64 {
|
||||||
return formula.AirmassPickering(apparentAltitude)
|
return formula.AirmassPickering(apparentAltitude)
|
||||||
}
|
}
|
||||||
@@ -26,6 +29,7 @@ func AirmassPickeringFromApparentAltitude(apparentAltitude float64) float64 {
|
|||||||
// AirmassKastenYoungFromTrueAltitude Kasten-Young 大气质量 / Kasten-Young airmass from true altitude.
|
// AirmassKastenYoungFromTrueAltitude Kasten-Young 大气质量 / Kasten-Young airmass from true altitude.
|
||||||
//
|
//
|
||||||
// 先用 pressureHPa / temperatureC 估算大气折射,将真高度角换算为视高度角,再代入经验公式。
|
// 先用 pressureHPa / temperatureC 估算大气折射,将真高度角换算为视高度角,再代入经验公式。
|
||||||
|
// First estimates atmospheric refraction from pressureHPa and temperatureC, converts true altitude to apparent altitude, and then applies the empirical formula.
|
||||||
func AirmassKastenYoungFromTrueAltitude(trueAltitude, pressureHPa, temperatureC float64) float64 {
|
func AirmassKastenYoungFromTrueAltitude(trueAltitude, pressureHPa, temperatureC float64) float64 {
|
||||||
return formula.AirmassKastenYoung(ApparentAltitude(trueAltitude, pressureHPa, temperatureC))
|
return formula.AirmassKastenYoung(ApparentAltitude(trueAltitude, pressureHPa, temperatureC))
|
||||||
}
|
}
|
||||||
@@ -33,6 +37,7 @@ func AirmassKastenYoungFromTrueAltitude(trueAltitude, pressureHPa, temperatureC
|
|||||||
// AirmassPickeringFromTrueAltitude Pickering 大气质量 / Pickering airmass from true altitude.
|
// AirmassPickeringFromTrueAltitude Pickering 大气质量 / Pickering airmass from true altitude.
|
||||||
//
|
//
|
||||||
// 先用 pressureHPa / temperatureC 估算大气折射,将真高度角换算为视高度角,再代入经验公式。
|
// 先用 pressureHPa / temperatureC 估算大气折射,将真高度角换算为视高度角,再代入经验公式。
|
||||||
|
// First estimates atmospheric refraction from pressureHPa and temperatureC, converts true altitude to apparent altitude, and then applies the empirical formula.
|
||||||
func AirmassPickeringFromTrueAltitude(trueAltitude, pressureHPa, temperatureC float64) float64 {
|
func AirmassPickeringFromTrueAltitude(trueAltitude, pressureHPa, temperatureC float64) float64 {
|
||||||
return formula.AirmassPickering(ApparentAltitude(trueAltitude, pressureHPa, temperatureC))
|
return formula.AirmassPickering(ApparentAltitude(trueAltitude, pressureHPa, temperatureC))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
// AtmosphericRefractionFromTrueAltitude 真高度角折射修正 / atmospheric refraction from true altitude.
|
// AtmosphericRefractionFromTrueAltitude 真高度角折射修正 / atmospheric refraction from true altitude.
|
||||||
//
|
//
|
||||||
// 输入真高度角,返回应加到真高度角上的大气折射修正量,单位度。
|
// 输入真高度角,返回应加到真高度角上的大气折射修正量,单位度。
|
||||||
|
// Takes true altitude and returns the atmospheric-refraction correction to be added to it, in degrees.
|
||||||
func AtmosphericRefractionFromTrueAltitude(trueAltitude, pressureHPa, temperatureC float64) float64 {
|
func AtmosphericRefractionFromTrueAltitude(trueAltitude, pressureHPa, temperatureC float64) float64 {
|
||||||
return basic.RefractionFromTrueAltitude(trueAltitude, pressureHPa, temperatureC)
|
return basic.RefractionFromTrueAltitude(trueAltitude, pressureHPa, temperatureC)
|
||||||
}
|
}
|
||||||
@@ -16,6 +17,7 @@ func AtmosphericRefractionFromTrueAltitude(trueAltitude, pressureHPa, temperatur
|
|||||||
// AtmosphericRefractionFromApparentAltitude 视高度角折射修正 / atmospheric refraction from apparent altitude.
|
// AtmosphericRefractionFromApparentAltitude 视高度角折射修正 / atmospheric refraction from apparent altitude.
|
||||||
//
|
//
|
||||||
// 输入视高度角,返回对应的大气折射修正量,单位度。
|
// 输入视高度角,返回对应的大气折射修正量,单位度。
|
||||||
|
// Takes apparent altitude and returns the corresponding atmospheric-refraction correction, in degrees.
|
||||||
func AtmosphericRefractionFromApparentAltitude(apparentAltitude, pressureHPa, temperatureC float64) float64 {
|
func AtmosphericRefractionFromApparentAltitude(apparentAltitude, pressureHPa, temperatureC float64) float64 {
|
||||||
return basic.RefractionFromApparentAltitude(apparentAltitude, pressureHPa, temperatureC)
|
return basic.RefractionFromApparentAltitude(apparentAltitude, pressureHPa, temperatureC)
|
||||||
}
|
}
|
||||||
@@ -23,6 +25,7 @@ func AtmosphericRefractionFromApparentAltitude(apparentAltitude, pressureHPa, te
|
|||||||
// ApparentAltitude 真高度角转视高度角 / apparent altitude from true altitude.
|
// ApparentAltitude 真高度角转视高度角 / apparent altitude from true altitude.
|
||||||
//
|
//
|
||||||
// 输入真高度角,返回加入标准大气折射后的视高度角,单位度。
|
// 输入真高度角,返回加入标准大气折射后的视高度角,单位度。
|
||||||
|
// Takes true altitude and returns the apparent altitude after applying standard atmospheric refraction, in degrees.
|
||||||
func ApparentAltitude(trueAltitude, pressureHPa, temperatureC float64) float64 {
|
func ApparentAltitude(trueAltitude, pressureHPa, temperatureC float64) float64 {
|
||||||
return basic.ApparentAltitude(trueAltitude, pressureHPa, temperatureC)
|
return basic.ApparentAltitude(trueAltitude, pressureHPa, temperatureC)
|
||||||
}
|
}
|
||||||
@@ -30,6 +33,7 @@ func ApparentAltitude(trueAltitude, pressureHPa, temperatureC float64) float64 {
|
|||||||
// TrueAltitude 视高度角转真高度角 / true altitude from apparent altitude.
|
// TrueAltitude 视高度角转真高度角 / true altitude from apparent altitude.
|
||||||
//
|
//
|
||||||
// 输入视高度角,返回去除大气折射后的真高度角,单位度。
|
// 输入视高度角,返回去除大气折射后的真高度角,单位度。
|
||||||
|
// Takes apparent altitude and returns the true altitude after removing atmospheric refraction, in degrees.
|
||||||
func TrueAltitude(apparentAltitude, pressureHPa, temperatureC float64) float64 {
|
func TrueAltitude(apparentAltitude, pressureHPa, temperatureC float64) float64 {
|
||||||
return basic.TrueAltitude(apparentAltitude, pressureHPa, temperatureC)
|
return basic.TrueAltitude(apparentAltitude, pressureHPa, temperatureC)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ var icrsToGalacticMatrix = [3][3]float64{
|
|||||||
// 返回:
|
// 返回:
|
||||||
//
|
//
|
||||||
// 赤经 RA,单位度;赤纬 Dec,单位度
|
// 赤经 RA,单位度;赤纬 Dec,单位度
|
||||||
|
//
|
||||||
|
// Returns right ascension and declination in degrees for the supplied ecliptic longitude, latitude, and obliquity.
|
||||||
func EclipticToEquatorialByObliquity(lon, lat, obliquity float64) Equatorial {
|
func EclipticToEquatorialByObliquity(lon, lat, obliquity float64) Equatorial {
|
||||||
sinLon, cosLon := sinCosDeg(lon)
|
sinLon, cosLon := sinCosDeg(lon)
|
||||||
sinLat, cosLat := sinCosDeg(lat)
|
sinLat, cosLat := sinCosDeg(lat)
|
||||||
@@ -44,6 +46,8 @@ func EclipticToEquatorialByObliquity(lon, lat, obliquity float64) Equatorial {
|
|||||||
// 返回:
|
// 返回:
|
||||||
//
|
//
|
||||||
// 黄经 Lon,单位度;黄纬 Lat,单位度
|
// 黄经 Lon,单位度;黄纬 Lat,单位度
|
||||||
|
//
|
||||||
|
// Returns ecliptic longitude and latitude in degrees for the supplied right ascension, declination, and obliquity.
|
||||||
func EquatorialToEclipticByObliquity(ra, dec, obliquity float64) Ecliptic {
|
func EquatorialToEclipticByObliquity(ra, dec, obliquity float64) Ecliptic {
|
||||||
sinRA, cosRA := sinCosDeg(ra)
|
sinRA, cosRA := sinCosDeg(ra)
|
||||||
sinDec, cosDec := sinCosDeg(dec)
|
sinDec, cosDec := sinCosDeg(dec)
|
||||||
@@ -63,6 +67,8 @@ func EquatorialToEclipticByObliquity(ra, dec, obliquity float64) Ecliptic {
|
|||||||
// 返回:
|
// 返回:
|
||||||
//
|
//
|
||||||
// 方位角 Azimuth(正北为0,顺时针增加)、高度角 Altitude、天顶距 Zenith,均为度
|
// 方位角 Azimuth(正北为0,顺时针增加)、高度角 Altitude、天顶距 Zenith,均为度
|
||||||
|
//
|
||||||
|
// Returns azimuth, altitude, and zenith distance in degrees from the supplied hour angle, declination, and site latitude.
|
||||||
func HourAngleDeclinationToHorizontal(hourAngle, declination, latitude float64) Horizontal {
|
func HourAngleDeclinationToHorizontal(hourAngle, declination, latitude float64) Horizontal {
|
||||||
sinLatitude, cosLatitude := sinCosDeg(latitude)
|
sinLatitude, cosLatitude := sinCosDeg(latitude)
|
||||||
sinDeclination, cosDeclination := sinCosDeg(declination)
|
sinDeclination, cosDeclination := sinCosDeg(declination)
|
||||||
@@ -87,6 +93,8 @@ func HourAngleDeclinationToHorizontal(hourAngle, declination, latitude float64)
|
|||||||
// 返回:
|
// 返回:
|
||||||
//
|
//
|
||||||
// 时角 HourAngle,单位度;赤纬 Declination,单位度
|
// 时角 HourAngle,单位度;赤纬 Declination,单位度
|
||||||
|
//
|
||||||
|
// Returns hour angle and declination in degrees from the supplied horizontal coordinates and site latitude.
|
||||||
func HorizontalToHourAngleDeclination(azimuth, altitude, latitude float64) (hourAngle, declination float64) {
|
func HorizontalToHourAngleDeclination(azimuth, altitude, latitude float64) (hourAngle, declination float64) {
|
||||||
sinLatitude, cosLatitude := sinCosDeg(latitude)
|
sinLatitude, cosLatitude := sinCosDeg(latitude)
|
||||||
sinAltitude, cosAltitude := sinCosDeg(altitude)
|
sinAltitude, cosAltitude := sinCosDeg(altitude)
|
||||||
@@ -111,6 +119,8 @@ func HorizontalToHourAngleDeclination(azimuth, altitude, latitude float64) (hour
|
|||||||
// 方位角 Azimuth(正北为0,顺时针增加)、高度角 Altitude、天顶距 Zenith,均为度;
|
// 方位角 Azimuth(正北为0,顺时针增加)、高度角 Altitude、天顶距 Zenith,均为度;
|
||||||
// 附带返回对应的时角 HourAngle,单位度
|
// 附带返回对应的时角 HourAngle,单位度
|
||||||
//
|
//
|
||||||
|
// Returns horizontal coordinates in degrees from local sidereal time, right ascension, declination, and site latitude.
|
||||||
|
//
|
||||||
// 例:
|
// 例:
|
||||||
//
|
//
|
||||||
// hz := coord.EquatorialToHorizontalByLocalSiderealTime(10.5, 83.6331, 22.0145, 31.2)
|
// hz := coord.EquatorialToHorizontalByLocalSiderealTime(10.5, 83.6331, 22.0145, 31.2)
|
||||||
@@ -130,6 +140,8 @@ func EquatorialToHorizontalByLocalSiderealTime(localSiderealTimeHours, ra, dec,
|
|||||||
//
|
//
|
||||||
// 赤经 RA,单位度;赤纬 Dec,单位度
|
// 赤经 RA,单位度;赤纬 Dec,单位度
|
||||||
//
|
//
|
||||||
|
// Returns right ascension and declination in degrees from local sidereal time and the supplied horizontal coordinates.
|
||||||
|
//
|
||||||
// 例:
|
// 例:
|
||||||
//
|
//
|
||||||
// eq := coord.HorizontalToEquatorialByLocalSiderealTime(10.5, 128.2, 37.6, 31.2)
|
// eq := coord.HorizontalToEquatorialByLocalSiderealTime(10.5, 128.2, 37.6, 31.2)
|
||||||
@@ -147,6 +159,8 @@ func HorizontalToEquatorialByLocalSiderealTime(localSiderealTimeHours, azimuth,
|
|||||||
// 返回:
|
// 返回:
|
||||||
//
|
//
|
||||||
// 银经 Lon,单位度;银纬 Lat,单位度
|
// 银经 Lon,单位度;银纬 Lat,单位度
|
||||||
|
//
|
||||||
|
// Returns galactic longitude and latitude in degrees from ICRS right ascension and declination.
|
||||||
func EquatorialToGalactic(ra, dec float64) Galactic {
|
func EquatorialToGalactic(ra, dec float64) Galactic {
|
||||||
vector := sphericalToVector(ra, dec)
|
vector := sphericalToVector(ra, dec)
|
||||||
rotated := matrixVectorMul(icrsToGalacticMatrix, vector)
|
rotated := matrixVectorMul(icrsToGalacticMatrix, vector)
|
||||||
@@ -162,6 +176,8 @@ func EquatorialToGalactic(ra, dec float64) Galactic {
|
|||||||
// 返回:
|
// 返回:
|
||||||
//
|
//
|
||||||
// ICRS 赤经 RA,单位度;ICRS 赤纬 Dec,单位度
|
// ICRS 赤经 RA,单位度;ICRS 赤纬 Dec,单位度
|
||||||
|
//
|
||||||
|
// Returns ICRS right ascension and declination in degrees from galactic longitude and latitude.
|
||||||
func GalacticToEquatorial(lon, lat float64) Equatorial {
|
func GalacticToEquatorial(lon, lat float64) Equatorial {
|
||||||
vector := sphericalToVector(lon, lat)
|
vector := sphericalToVector(lon, lat)
|
||||||
rotated := matrixTransposeVectorMul(icrsToGalacticMatrix, vector)
|
rotated := matrixTransposeVectorMul(icrsToGalacticMatrix, vector)
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
"b612.me/astro/jupiter"
|
"b612.me/astro/jupiter"
|
||||||
"b612.me/astro/mars"
|
"b612.me/astro/mars"
|
||||||
"b612.me/astro/mercury"
|
"b612.me/astro/mercury"
|
||||||
|
"b612.me/astro/moon"
|
||||||
"b612.me/astro/neptune"
|
"b612.me/astro/neptune"
|
||||||
"b612.me/astro/saturn"
|
"b612.me/astro/saturn"
|
||||||
"b612.me/astro/uranus"
|
"b612.me/astro/uranus"
|
||||||
@@ -88,6 +89,56 @@ func TestPublicPlanetEventBoundaryIncludesCurrent(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestPublicMoonPlanetConjunctionBoundaryIncludesCurrent(t *testing.T) {
|
||||||
|
type eventFuncs struct {
|
||||||
|
last func(time.Time) time.Time
|
||||||
|
next func(time.Time) time.Time
|
||||||
|
}
|
||||||
|
|
||||||
|
cases := []struct {
|
||||||
|
name string
|
||||||
|
eventUT float64
|
||||||
|
funcs eventFuncs
|
||||||
|
}{
|
||||||
|
{name: "MoonMercuryConjunction", eventUT: basic.NextMoonPlanetConjunction(eventBoundaryTT(2026), basic.MoonPlanetConjunctionMercury), funcs: eventFuncs{
|
||||||
|
last: func(date time.Time) time.Time { return moon.LastConjunctionWithPlanet(date, moon.ConjunctionMercury) },
|
||||||
|
next: func(date time.Time) time.Time { return moon.NextConjunctionWithPlanet(date, moon.ConjunctionMercury) },
|
||||||
|
}},
|
||||||
|
{name: "MoonVenusConjunction", eventUT: basic.NextMoonPlanetConjunction(eventBoundaryTT(2026), basic.MoonPlanetConjunctionVenus), funcs: eventFuncs{
|
||||||
|
last: func(date time.Time) time.Time { return moon.LastConjunctionWithPlanet(date, moon.ConjunctionVenus) },
|
||||||
|
next: func(date time.Time) time.Time { return moon.NextConjunctionWithPlanet(date, moon.ConjunctionVenus) },
|
||||||
|
}},
|
||||||
|
{name: "MoonMarsConjunction", eventUT: basic.NextMoonPlanetConjunction(eventBoundaryTT(2026), basic.MoonPlanetConjunctionMars), funcs: eventFuncs{
|
||||||
|
last: func(date time.Time) time.Time { return moon.LastConjunctionWithPlanet(date, moon.ConjunctionMars) },
|
||||||
|
next: func(date time.Time) time.Time { return moon.NextConjunctionWithPlanet(date, moon.ConjunctionMars) },
|
||||||
|
}},
|
||||||
|
{name: "MoonJupiterConjunction", eventUT: basic.NextMoonPlanetConjunction(eventBoundaryTT(2026), basic.MoonPlanetConjunctionJupiter), funcs: eventFuncs{
|
||||||
|
last: func(date time.Time) time.Time { return moon.LastConjunctionWithPlanet(date, moon.ConjunctionJupiter) },
|
||||||
|
next: func(date time.Time) time.Time { return moon.NextConjunctionWithPlanet(date, moon.ConjunctionJupiter) },
|
||||||
|
}},
|
||||||
|
{name: "MoonSaturnConjunction", eventUT: basic.NextMoonPlanetConjunction(eventBoundaryTT(2026), basic.MoonPlanetConjunctionSaturn), funcs: eventFuncs{
|
||||||
|
last: func(date time.Time) time.Time { return moon.LastConjunctionWithPlanet(date, moon.ConjunctionSaturn) },
|
||||||
|
next: func(date time.Time) time.Time { return moon.NextConjunctionWithPlanet(date, moon.ConjunctionSaturn) },
|
||||||
|
}},
|
||||||
|
{name: "MoonUranusConjunction", eventUT: basic.NextMoonPlanetConjunction(eventBoundaryTT(2026), basic.MoonPlanetConjunctionUranus), funcs: eventFuncs{
|
||||||
|
last: func(date time.Time) time.Time { return moon.LastConjunctionWithPlanet(date, moon.ConjunctionUranus) },
|
||||||
|
next: func(date time.Time) time.Time { return moon.NextConjunctionWithPlanet(date, moon.ConjunctionUranus) },
|
||||||
|
}},
|
||||||
|
{name: "MoonNeptuneConjunction", eventUT: basic.NextMoonPlanetConjunction(eventBoundaryTT(2026), basic.MoonPlanetConjunctionNeptune), funcs: eventFuncs{
|
||||||
|
last: func(date time.Time) time.Time { return moon.LastConjunctionWithPlanet(date, moon.ConjunctionNeptune) },
|
||||||
|
next: func(date time.Time) time.Time { return moon.NextConjunctionWithPlanet(date, moon.ConjunctionNeptune) },
|
||||||
|
}},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tc := range cases {
|
||||||
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
|
eventTime := basic.JDE2DateByZone(tc.eventUT, time.UTC, false)
|
||||||
|
assertSameEventTime(t, "last", tc.funcs.last(eventTime), eventTime)
|
||||||
|
assertSameEventTime(t, "next", tc.funcs.next(eventTime), eventTime)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func eventBoundaryTT(year int) float64 {
|
func eventBoundaryTT(year int) float64 {
|
||||||
return basic.TD2UT(basic.Date2JDE(time.Date(year, 1, 1, 0, 0, 0, 0, time.UTC)), true)
|
return basic.TD2UT(basic.Date2JDE(time.Date(year, 1, 1, 0, 0, 0, 0, time.UTC)), true)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ const (
|
|||||||
// 返回:
|
// 返回:
|
||||||
//
|
//
|
||||||
// 峰值波长,单位米
|
// 峰值波长,单位米
|
||||||
|
//
|
||||||
|
// Returns the wavelength of maximum emission in meters for a blackbody at the supplied temperature.
|
||||||
func WienPeakWavelength(temperatureK float64) float64 {
|
func WienPeakWavelength(temperatureK float64) float64 {
|
||||||
if temperatureK <= 0 || math.IsNaN(temperatureK) || math.IsInf(temperatureK, 0) {
|
if temperatureK <= 0 || math.IsNaN(temperatureK) || math.IsInf(temperatureK, 0) {
|
||||||
return math.NaN()
|
return math.NaN()
|
||||||
@@ -32,6 +34,8 @@ func WienPeakWavelength(temperatureK float64) float64 {
|
|||||||
// 返回:
|
// 返回:
|
||||||
//
|
//
|
||||||
// 单位面积总出射度,单位 W/m^2
|
// 单位面积总出射度,单位 W/m^2
|
||||||
|
//
|
||||||
|
// Returns the total radiant exitance in W/m^2 for a blackbody at the supplied temperature.
|
||||||
func StefanBoltzmannFlux(temperatureK float64) float64 {
|
func StefanBoltzmannFlux(temperatureK float64) float64 {
|
||||||
if temperatureK < 0 || math.IsNaN(temperatureK) || math.IsInf(temperatureK, 0) {
|
if temperatureK < 0 || math.IsNaN(temperatureK) || math.IsInf(temperatureK, 0) {
|
||||||
return math.NaN()
|
return math.NaN()
|
||||||
@@ -48,6 +52,8 @@ func StefanBoltzmannFlux(temperatureK float64) float64 {
|
|||||||
//
|
//
|
||||||
// 谱辐亮度,单位 W·sr^-1·m^-3
|
// 谱辐亮度,单位 W·sr^-1·m^-3
|
||||||
//
|
//
|
||||||
|
// Returns spectral radiance in W·sr^-1·m^-3 at the supplied wavelength and temperature.
|
||||||
|
//
|
||||||
// 例:
|
// 例:
|
||||||
//
|
//
|
||||||
// b := formula.PlanckRadianceByWavelength(500e-9, 5772)
|
// b := formula.PlanckRadianceByWavelength(500e-9, 5772)
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ import "math"
|
|||||||
//
|
//
|
||||||
// 会合周期,单位与输入相同
|
// 会合周期,单位与输入相同
|
||||||
//
|
//
|
||||||
|
// Returns the synodic period in the same unit as the two input periods.
|
||||||
|
//
|
||||||
// 例:
|
// 例:
|
||||||
//
|
//
|
||||||
// // 地球与金星的会合周期,单位天
|
// // 地球与金星的会合周期,单位天
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import "math"
|
|||||||
// 返回:
|
// 返回:
|
||||||
//
|
//
|
||||||
// 距离模数 m-M
|
// 距离模数 m-M
|
||||||
|
//
|
||||||
|
// Returns the distance modulus m-M for the supplied distance in parsecs.
|
||||||
func DistanceModulus(distanceParsec float64) float64 {
|
func DistanceModulus(distanceParsec float64) float64 {
|
||||||
if distanceParsec <= 0 || math.IsNaN(distanceParsec) || math.IsInf(distanceParsec, 0) {
|
if distanceParsec <= 0 || math.IsNaN(distanceParsec) || math.IsInf(distanceParsec, 0) {
|
||||||
return math.NaN()
|
return math.NaN()
|
||||||
@@ -24,6 +26,8 @@ func DistanceModulus(distanceParsec float64) float64 {
|
|||||||
// 返回:
|
// 返回:
|
||||||
//
|
//
|
||||||
// 视星等 m
|
// 视星等 m
|
||||||
|
//
|
||||||
|
// Returns apparent magnitude from absolute magnitude and distance.
|
||||||
func ApparentMagnitudeFromAbsolute(absoluteMagnitude, distanceParsec float64) float64 {
|
func ApparentMagnitudeFromAbsolute(absoluteMagnitude, distanceParsec float64) float64 {
|
||||||
modulus := DistanceModulus(distanceParsec)
|
modulus := DistanceModulus(distanceParsec)
|
||||||
if math.IsNaN(modulus) {
|
if math.IsNaN(modulus) {
|
||||||
@@ -40,6 +44,8 @@ func ApparentMagnitudeFromAbsolute(absoluteMagnitude, distanceParsec float64) fl
|
|||||||
// 返回:
|
// 返回:
|
||||||
//
|
//
|
||||||
// 绝对星等 M
|
// 绝对星等 M
|
||||||
|
//
|
||||||
|
// Returns absolute magnitude from apparent magnitude and distance.
|
||||||
func AbsoluteMagnitudeFromApparent(apparentMagnitude, distanceParsec float64) float64 {
|
func AbsoluteMagnitudeFromApparent(apparentMagnitude, distanceParsec float64) float64 {
|
||||||
modulus := DistanceModulus(distanceParsec)
|
modulus := DistanceModulus(distanceParsec)
|
||||||
if math.IsNaN(modulus) {
|
if math.IsNaN(modulus) {
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ const (
|
|||||||
// 返回:
|
// 返回:
|
||||||
//
|
//
|
||||||
// 总光度,单位瓦特
|
// 总光度,单位瓦特
|
||||||
|
//
|
||||||
|
// Returns stellar luminosity in watts from radius and effective temperature.
|
||||||
func LuminosityFromRadiusTemperature(radiusM, temperatureK float64) float64 {
|
func LuminosityFromRadiusTemperature(radiusM, temperatureK float64) float64 {
|
||||||
if radiusM <= 0 || temperatureK <= 0 ||
|
if radiusM <= 0 || temperatureK <= 0 ||
|
||||||
math.IsNaN(radiusM) || math.IsInf(radiusM, 0) ||
|
math.IsNaN(radiusM) || math.IsInf(radiusM, 0) ||
|
||||||
@@ -33,6 +35,8 @@ func LuminosityFromRadiusTemperature(radiusM, temperatureK float64) float64 {
|
|||||||
// 返回:
|
// 返回:
|
||||||
//
|
//
|
||||||
// 恒星半径,单位米
|
// 恒星半径,单位米
|
||||||
|
//
|
||||||
|
// Returns stellar radius in meters from luminosity and effective temperature.
|
||||||
func RadiusFromLuminosityTemperature(luminosityW, temperatureK float64) float64 {
|
func RadiusFromLuminosityTemperature(luminosityW, temperatureK float64) float64 {
|
||||||
if luminosityW <= 0 || temperatureK <= 0 ||
|
if luminosityW <= 0 || temperatureK <= 0 ||
|
||||||
math.IsNaN(luminosityW) || math.IsInf(luminosityW, 0) ||
|
math.IsNaN(luminosityW) || math.IsInf(luminosityW, 0) ||
|
||||||
@@ -54,6 +58,8 @@ func RadiusFromLuminosityTemperature(luminosityW, temperatureK float64) float64
|
|||||||
// 返回:
|
// 返回:
|
||||||
//
|
//
|
||||||
// 恒星有效温度,单位开尔文
|
// 恒星有效温度,单位开尔文
|
||||||
|
//
|
||||||
|
// Returns stellar effective temperature in kelvin from luminosity and radius.
|
||||||
func EffectiveTemperatureFromLuminosityRadius(luminosityW, radiusM float64) float64 {
|
func EffectiveTemperatureFromLuminosityRadius(luminosityW, radiusM float64) float64 {
|
||||||
if luminosityW <= 0 || radiusM <= 0 ||
|
if luminosityW <= 0 || radiusM <= 0 ||
|
||||||
math.IsNaN(luminosityW) || math.IsInf(luminosityW, 0) ||
|
math.IsNaN(luminosityW) || math.IsInf(luminosityW, 0) ||
|
||||||
@@ -75,6 +81,8 @@ func EffectiveTemperatureFromLuminosityRadius(luminosityW, radiusM float64) floa
|
|||||||
// 返回:
|
// 返回:
|
||||||
//
|
//
|
||||||
// 总光度,单位为太阳光度 L☉
|
// 总光度,单位为太阳光度 L☉
|
||||||
|
//
|
||||||
|
// Returns luminosity in solar units from radius in solar radii and effective temperature.
|
||||||
func LuminositySolarFromRadiusTemperature(radiusSolar, temperatureK float64) float64 {
|
func LuminositySolarFromRadiusTemperature(radiusSolar, temperatureK float64) float64 {
|
||||||
if radiusSolar <= 0 || temperatureK <= 0 ||
|
if radiusSolar <= 0 || temperatureK <= 0 ||
|
||||||
math.IsNaN(radiusSolar) || math.IsInf(radiusSolar, 0) ||
|
math.IsNaN(radiusSolar) || math.IsInf(radiusSolar, 0) ||
|
||||||
@@ -92,6 +100,8 @@ func LuminositySolarFromRadiusTemperature(radiusSolar, temperatureK float64) flo
|
|||||||
// 返回:
|
// 返回:
|
||||||
//
|
//
|
||||||
// 恒星半径,单位为太阳半径 R☉
|
// 恒星半径,单位为太阳半径 R☉
|
||||||
|
//
|
||||||
|
// Returns radius in solar radii from luminosity in solar units and effective temperature.
|
||||||
func RadiusSolarFromLuminosityTemperature(luminositySolar, temperatureK float64) float64 {
|
func RadiusSolarFromLuminosityTemperature(luminositySolar, temperatureK float64) float64 {
|
||||||
if luminositySolar <= 0 || temperatureK <= 0 ||
|
if luminositySolar <= 0 || temperatureK <= 0 ||
|
||||||
math.IsNaN(luminositySolar) || math.IsInf(luminositySolar, 0) ||
|
math.IsNaN(luminositySolar) || math.IsInf(luminositySolar, 0) ||
|
||||||
@@ -110,6 +120,8 @@ func RadiusSolarFromLuminosityTemperature(luminositySolar, temperatureK float64)
|
|||||||
//
|
//
|
||||||
// 恒星有效温度,单位开尔文
|
// 恒星有效温度,单位开尔文
|
||||||
//
|
//
|
||||||
|
// Returns stellar effective temperature in kelvin from luminosity and radius expressed in solar units.
|
||||||
|
//
|
||||||
// 例:
|
// 例:
|
||||||
//
|
//
|
||||||
// // 半径 2.5 R☉、光度 20 L☉ 的主序星
|
// // 半径 2.5 R☉、光度 20 L☉ 的主序星
|
||||||
@@ -128,6 +140,8 @@ func EffectiveTemperatureFromLuminositySolarRadius(luminositySolar, radiusSolar
|
|||||||
// 返回:
|
// 返回:
|
||||||
//
|
//
|
||||||
// 太阳有效温度,单位开尔文
|
// 太阳有效温度,单位开尔文
|
||||||
|
//
|
||||||
|
// Returns the adopted solar effective temperature constant in kelvin.
|
||||||
func SolarEffectiveTemperature() float64 {
|
func SolarEffectiveTemperature() float64 {
|
||||||
return solarEffectiveTempK
|
return solarEffectiveTempK
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ const darkAdaptedPupilDiameterMM = 7.0
|
|||||||
// 返回:
|
// 返回:
|
||||||
//
|
//
|
||||||
// 集光力比值,等于 (diameter1MM / diameter2MM)^2
|
// 集光力比值,等于 (diameter1MM / diameter2MM)^2
|
||||||
|
//
|
||||||
|
// Returns the light-gathering power ratio, equal to (diameter1MM / diameter2MM)^2.
|
||||||
func LightGatheringPowerRatio(diameter1MM, diameter2MM float64) float64 {
|
func LightGatheringPowerRatio(diameter1MM, diameter2MM float64) float64 {
|
||||||
if diameter1MM <= 0 || diameter2MM <= 0 ||
|
if diameter1MM <= 0 || diameter2MM <= 0 ||
|
||||||
math.IsNaN(diameter1MM) || math.IsInf(diameter1MM, 0) ||
|
math.IsNaN(diameter1MM) || math.IsInf(diameter1MM, 0) ||
|
||||||
@@ -28,6 +30,8 @@ func LightGatheringPowerRatio(diameter1MM, diameter2MM float64) float64 {
|
|||||||
// 返回:
|
// 返回:
|
||||||
//
|
//
|
||||||
// Dawes 极限,单位角秒
|
// Dawes 极限,单位角秒
|
||||||
|
//
|
||||||
|
// Returns the Dawes limit in arcseconds for the supplied aperture.
|
||||||
func DawesLimitArcsec(diameterMM float64) float64 {
|
func DawesLimitArcsec(diameterMM float64) float64 {
|
||||||
if diameterMM <= 0 || math.IsNaN(diameterMM) || math.IsInf(diameterMM, 0) {
|
if diameterMM <= 0 || math.IsNaN(diameterMM) || math.IsInf(diameterMM, 0) {
|
||||||
return math.NaN()
|
return math.NaN()
|
||||||
@@ -42,6 +46,8 @@ func DawesLimitArcsec(diameterMM float64) float64 {
|
|||||||
// 返回:
|
// 返回:
|
||||||
//
|
//
|
||||||
// Rayleigh 极限,单位角秒
|
// Rayleigh 极限,单位角秒
|
||||||
|
//
|
||||||
|
// Returns the Rayleigh limit in arcseconds for the supplied aperture.
|
||||||
func RayleighLimitArcsec(diameterMM float64) float64 {
|
func RayleighLimitArcsec(diameterMM float64) float64 {
|
||||||
if diameterMM <= 0 || math.IsNaN(diameterMM) || math.IsInf(diameterMM, 0) {
|
if diameterMM <= 0 || math.IsNaN(diameterMM) || math.IsInf(diameterMM, 0) {
|
||||||
return math.NaN()
|
return math.NaN()
|
||||||
@@ -58,6 +64,8 @@ func RayleighLimitArcsec(diameterMM float64) float64 {
|
|||||||
//
|
//
|
||||||
// 经验极限星等;这是经验值,不包含天空背景、倍率、透过率和观测经验修正
|
// 经验极限星等;这是经验值,不包含天空背景、倍率、透过率和观测经验修正
|
||||||
//
|
//
|
||||||
|
// Returns an empirical limiting magnitude estimate. It does not account for sky background, magnification, transmission, or observer skill.
|
||||||
|
//
|
||||||
// 例:
|
// 例:
|
||||||
//
|
//
|
||||||
// // 70mm 小型折射镜,裸眼极限 6 等
|
// // 70mm 小型折射镜,裸眼极限 6 等
|
||||||
|
|||||||
@@ -208,6 +208,7 @@ func SetTime(date time.Time, lon, lat, height float64, aero bool) (time.Time, er
|
|||||||
// LastConjunction 上一次合日 / previous conjunction with the Sun.
|
// LastConjunction 上一次合日 / previous conjunction with the Sun.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之前最近一次与太阳的合日时刻,结果保持 date 的时区。
|
// 返回 date 当前或之前最近一次与太阳的合日时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest conjunction with the Sun at or before date, keeping date's time zone.
|
||||||
func LastConjunction(date time.Time) time.Time {
|
func LastConjunction(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.LastJupiterConjunction(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.LastJupiterConjunction(jde), date.Location(), false)
|
||||||
@@ -216,6 +217,7 @@ func LastConjunction(date time.Time) time.Time {
|
|||||||
// NextConjunction 下一次合日 / next conjunction with the Sun.
|
// NextConjunction 下一次合日 / next conjunction with the Sun.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之后最近一次与太阳的合日时刻,结果保持 date 的时区。
|
// 返回 date 当前或之后最近一次与太阳的合日时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest conjunction with the Sun at or after date, keeping date's time zone.
|
||||||
func NextConjunction(date time.Time) time.Time {
|
func NextConjunction(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.NextJupiterConjunction(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.NextJupiterConjunction(jde), date.Location(), false)
|
||||||
@@ -224,6 +226,7 @@ func NextConjunction(date time.Time) time.Time {
|
|||||||
// LastOpposition 上一次冲日 / previous opposition.
|
// LastOpposition 上一次冲日 / previous opposition.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之前最近一次冲日时刻,结果保持 date 的时区。
|
// 返回 date 当前或之前最近一次冲日时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest opposition at or before date, keeping date's time zone.
|
||||||
func LastOpposition(date time.Time) time.Time {
|
func LastOpposition(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.LastJupiterOpposition(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.LastJupiterOpposition(jde), date.Location(), false)
|
||||||
@@ -232,6 +235,7 @@ func LastOpposition(date time.Time) time.Time {
|
|||||||
// NextOpposition 下一次冲日 / next opposition.
|
// NextOpposition 下一次冲日 / next opposition.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之后最近一次冲日时刻,结果保持 date 的时区。
|
// 返回 date 当前或之后最近一次冲日时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest opposition at or after date, keeping date's time zone.
|
||||||
func NextOpposition(date time.Time) time.Time {
|
func NextOpposition(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.NextJupiterOpposition(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.NextJupiterOpposition(jde), date.Location(), false)
|
||||||
@@ -240,6 +244,7 @@ func NextOpposition(date time.Time) time.Time {
|
|||||||
// LastProgradeToRetrograde 上一次顺行转逆行留 / previous station from prograde to retrograde.
|
// LastProgradeToRetrograde 上一次顺行转逆行留 / previous station from prograde to retrograde.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之前最近一次由顺行转为逆行的留时刻,结果保持 date 的时区。
|
// 返回 date 当前或之前最近一次由顺行转为逆行的留时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest station at or before date where motion changes from prograde to retrograde, keeping date's time zone.
|
||||||
func LastProgradeToRetrograde(date time.Time) time.Time {
|
func LastProgradeToRetrograde(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.LastJupiterProgradeToRetrograde(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.LastJupiterProgradeToRetrograde(jde), date.Location(), false)
|
||||||
@@ -248,6 +253,7 @@ func LastProgradeToRetrograde(date time.Time) time.Time {
|
|||||||
// NextProgradeToRetrograde 下一次顺行转逆行留 / next station from prograde to retrograde.
|
// NextProgradeToRetrograde 下一次顺行转逆行留 / next station from prograde to retrograde.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之后最近一次由顺行转为逆行的留时刻,结果保持 date 的时区。
|
// 返回 date 当前或之后最近一次由顺行转为逆行的留时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest station at or after date where motion changes from prograde to retrograde, keeping date's time zone.
|
||||||
func NextProgradeToRetrograde(date time.Time) time.Time {
|
func NextProgradeToRetrograde(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.NextJupiterProgradeToRetrograde(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.NextJupiterProgradeToRetrograde(jde), date.Location(), false)
|
||||||
@@ -256,6 +262,7 @@ func NextProgradeToRetrograde(date time.Time) time.Time {
|
|||||||
// LastRetrogradeToPrograde 上一次逆行转顺行留 / previous station from retrograde to prograde.
|
// LastRetrogradeToPrograde 上一次逆行转顺行留 / previous station from retrograde to prograde.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之前最近一次由逆行转为顺行的留时刻,结果保持 date 的时区。
|
// 返回 date 当前或之前最近一次由逆行转为顺行的留时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest station at or before date where motion changes from retrograde to prograde, keeping date's time zone.
|
||||||
func LastRetrogradeToPrograde(date time.Time) time.Time {
|
func LastRetrogradeToPrograde(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.LastJupiterRetrogradeToPrograde(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.LastJupiterRetrogradeToPrograde(jde), date.Location(), false)
|
||||||
@@ -264,6 +271,7 @@ func LastRetrogradeToPrograde(date time.Time) time.Time {
|
|||||||
// NextRetrogradeToPrograde 下一次逆行转顺行留 / next station from retrograde to prograde.
|
// NextRetrogradeToPrograde 下一次逆行转顺行留 / next station from retrograde to prograde.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之后最近一次由逆行转为顺行的留时刻,结果保持 date 的时区。
|
// 返回 date 当前或之后最近一次由逆行转为顺行的留时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest station at or after date where motion changes from retrograde to prograde, keeping date's time zone.
|
||||||
func NextRetrogradeToPrograde(date time.Time) time.Time {
|
func NextRetrogradeToPrograde(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.NextJupiterRetrogradeToPrograde(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.NextJupiterRetrogradeToPrograde(jde), date.Location(), false)
|
||||||
@@ -272,6 +280,7 @@ func NextRetrogradeToPrograde(date time.Time) time.Time {
|
|||||||
// LastEasternQuadrature 上一次东方照 / previous eastern quadrature.
|
// LastEasternQuadrature 上一次东方照 / previous eastern quadrature.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之前最近一次东方照时刻,结果保持 date 的时区。
|
// 返回 date 当前或之前最近一次东方照时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest eastern quadrature at or before date, keeping date's time zone.
|
||||||
func LastEasternQuadrature(date time.Time) time.Time {
|
func LastEasternQuadrature(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.LastJupiterEasternQuadrature(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.LastJupiterEasternQuadrature(jde), date.Location(), false)
|
||||||
@@ -280,6 +289,7 @@ func LastEasternQuadrature(date time.Time) time.Time {
|
|||||||
// NextEasternQuadrature 下一次东方照 / next eastern quadrature.
|
// NextEasternQuadrature 下一次东方照 / next eastern quadrature.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之后最近一次东方照时刻,结果保持 date 的时区。
|
// 返回 date 当前或之后最近一次东方照时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest eastern quadrature at or after date, keeping date's time zone.
|
||||||
func NextEasternQuadrature(date time.Time) time.Time {
|
func NextEasternQuadrature(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.NextJupiterEasternQuadrature(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.NextJupiterEasternQuadrature(jde), date.Location(), false)
|
||||||
@@ -288,6 +298,7 @@ func NextEasternQuadrature(date time.Time) time.Time {
|
|||||||
// LastWesternQuadrature 上一次西方照 / previous western quadrature.
|
// LastWesternQuadrature 上一次西方照 / previous western quadrature.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之前最近一次西方照时刻,结果保持 date 的时区。
|
// 返回 date 当前或之前最近一次西方照时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest western quadrature at or before date, keeping date's time zone.
|
||||||
func LastWesternQuadrature(date time.Time) time.Time {
|
func LastWesternQuadrature(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.LastJupiterWesternQuadrature(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.LastJupiterWesternQuadrature(jde), date.Location(), false)
|
||||||
@@ -296,6 +307,7 @@ func LastWesternQuadrature(date time.Time) time.Time {
|
|||||||
// NextWesternQuadrature 下一次西方照 / next western quadrature.
|
// NextWesternQuadrature 下一次西方照 / next western quadrature.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之后最近一次西方照时刻,结果保持 date 的时区。
|
// 返回 date 当前或之后最近一次西方照时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest western quadrature at or after date, keeping date's time zone.
|
||||||
func NextWesternQuadrature(date time.Time) time.Time {
|
func NextWesternQuadrature(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.NextJupiterWesternQuadrature(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.NextJupiterWesternQuadrature(jde), date.Location(), false)
|
||||||
|
|||||||
@@ -208,6 +208,7 @@ func SetTime(date time.Time, lon, lat, height float64, aero bool) (time.Time, er
|
|||||||
// LastConjunction 上一次合日 / previous conjunction with the Sun.
|
// LastConjunction 上一次合日 / previous conjunction with the Sun.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之前最近一次与太阳的合日时刻,结果保持 date 的时区。
|
// 返回 date 当前或之前最近一次与太阳的合日时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest conjunction with the Sun at or before date, keeping date's time zone.
|
||||||
func LastConjunction(date time.Time) time.Time {
|
func LastConjunction(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.LastMarsConjunction(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.LastMarsConjunction(jde), date.Location(), false)
|
||||||
@@ -216,6 +217,7 @@ func LastConjunction(date time.Time) time.Time {
|
|||||||
// NextConjunction 下一次合日 / next conjunction with the Sun.
|
// NextConjunction 下一次合日 / next conjunction with the Sun.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之后最近一次与太阳的合日时刻,结果保持 date 的时区。
|
// 返回 date 当前或之后最近一次与太阳的合日时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest conjunction with the Sun at or after date, keeping date's time zone.
|
||||||
func NextConjunction(date time.Time) time.Time {
|
func NextConjunction(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.NextMarsConjunction(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.NextMarsConjunction(jde), date.Location(), false)
|
||||||
@@ -224,6 +226,7 @@ func NextConjunction(date time.Time) time.Time {
|
|||||||
// LastOpposition 上一次冲日 / previous opposition.
|
// LastOpposition 上一次冲日 / previous opposition.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之前最近一次冲日时刻,结果保持 date 的时区。
|
// 返回 date 当前或之前最近一次冲日时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest opposition at or before date, keeping date's time zone.
|
||||||
func LastOpposition(date time.Time) time.Time {
|
func LastOpposition(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.LastMarsOpposition(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.LastMarsOpposition(jde), date.Location(), false)
|
||||||
@@ -232,6 +235,7 @@ func LastOpposition(date time.Time) time.Time {
|
|||||||
// NextOpposition 下一次冲日 / next opposition.
|
// NextOpposition 下一次冲日 / next opposition.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之后最近一次冲日时刻,结果保持 date 的时区。
|
// 返回 date 当前或之后最近一次冲日时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest opposition at or after date, keeping date's time zone.
|
||||||
func NextOpposition(date time.Time) time.Time {
|
func NextOpposition(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.NextMarsOpposition(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.NextMarsOpposition(jde), date.Location(), false)
|
||||||
@@ -240,6 +244,7 @@ func NextOpposition(date time.Time) time.Time {
|
|||||||
// LastProgradeToRetrograde 上一次顺行转逆行留 / previous station from prograde to retrograde.
|
// LastProgradeToRetrograde 上一次顺行转逆行留 / previous station from prograde to retrograde.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之前最近一次由顺行转为逆行的留时刻,结果保持 date 的时区。
|
// 返回 date 当前或之前最近一次由顺行转为逆行的留时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest station at or before date where motion changes from prograde to retrograde, keeping date's time zone.
|
||||||
func LastProgradeToRetrograde(date time.Time) time.Time {
|
func LastProgradeToRetrograde(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.LastMarsProgradeToRetrograde(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.LastMarsProgradeToRetrograde(jde), date.Location(), false)
|
||||||
@@ -248,6 +253,7 @@ func LastProgradeToRetrograde(date time.Time) time.Time {
|
|||||||
// NextProgradeToRetrograde 下一次顺行转逆行留 / next station from prograde to retrograde.
|
// NextProgradeToRetrograde 下一次顺行转逆行留 / next station from prograde to retrograde.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之后最近一次由顺行转为逆行的留时刻,结果保持 date 的时区。
|
// 返回 date 当前或之后最近一次由顺行转为逆行的留时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest station at or after date where motion changes from prograde to retrograde, keeping date's time zone.
|
||||||
func NextProgradeToRetrograde(date time.Time) time.Time {
|
func NextProgradeToRetrograde(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.NextMarsProgradeToRetrograde(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.NextMarsProgradeToRetrograde(jde), date.Location(), false)
|
||||||
@@ -256,6 +262,7 @@ func NextProgradeToRetrograde(date time.Time) time.Time {
|
|||||||
// LastRetrogradeToPrograde 上一次逆行转顺行留 / previous station from retrograde to prograde.
|
// LastRetrogradeToPrograde 上一次逆行转顺行留 / previous station from retrograde to prograde.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之前最近一次由逆行转为顺行的留时刻,结果保持 date 的时区。
|
// 返回 date 当前或之前最近一次由逆行转为顺行的留时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest station at or before date where motion changes from retrograde to prograde, keeping date's time zone.
|
||||||
func LastRetrogradeToPrograde(date time.Time) time.Time {
|
func LastRetrogradeToPrograde(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.LastMarsRetrogradeToPrograde(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.LastMarsRetrogradeToPrograde(jde), date.Location(), false)
|
||||||
@@ -264,6 +271,7 @@ func LastRetrogradeToPrograde(date time.Time) time.Time {
|
|||||||
// NextRetrogradeToPrograde 下一次逆行转顺行留 / next station from retrograde to prograde.
|
// NextRetrogradeToPrograde 下一次逆行转顺行留 / next station from retrograde to prograde.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之后最近一次由逆行转为顺行的留时刻,结果保持 date 的时区。
|
// 返回 date 当前或之后最近一次由逆行转为顺行的留时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest station at or after date where motion changes from retrograde to prograde, keeping date's time zone.
|
||||||
func NextRetrogradeToPrograde(date time.Time) time.Time {
|
func NextRetrogradeToPrograde(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.NextMarsRetrogradeToPrograde(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.NextMarsRetrogradeToPrograde(jde), date.Location(), false)
|
||||||
@@ -272,6 +280,7 @@ func NextRetrogradeToPrograde(date time.Time) time.Time {
|
|||||||
// LastEasternQuadrature 上一次东方照 / previous eastern quadrature.
|
// LastEasternQuadrature 上一次东方照 / previous eastern quadrature.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之前最近一次东方照时刻,结果保持 date 的时区。
|
// 返回 date 当前或之前最近一次东方照时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest eastern quadrature at or before date, keeping date's time zone.
|
||||||
func LastEasternQuadrature(date time.Time) time.Time {
|
func LastEasternQuadrature(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.LastMarsEasternQuadrature(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.LastMarsEasternQuadrature(jde), date.Location(), false)
|
||||||
@@ -280,6 +289,7 @@ func LastEasternQuadrature(date time.Time) time.Time {
|
|||||||
// NextEasternQuadrature 下一次东方照 / next eastern quadrature.
|
// NextEasternQuadrature 下一次东方照 / next eastern quadrature.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之后最近一次东方照时刻,结果保持 date 的时区。
|
// 返回 date 当前或之后最近一次东方照时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest eastern quadrature at or after date, keeping date's time zone.
|
||||||
func NextEasternQuadrature(date time.Time) time.Time {
|
func NextEasternQuadrature(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.NextMarsEasternQuadrature(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.NextMarsEasternQuadrature(jde), date.Location(), false)
|
||||||
@@ -288,6 +298,7 @@ func NextEasternQuadrature(date time.Time) time.Time {
|
|||||||
// LastWesternQuadrature 上一次西方照 / previous western quadrature.
|
// LastWesternQuadrature 上一次西方照 / previous western quadrature.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之前最近一次西方照时刻,结果保持 date 的时区。
|
// 返回 date 当前或之前最近一次西方照时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest western quadrature at or before date, keeping date's time zone.
|
||||||
func LastWesternQuadrature(date time.Time) time.Time {
|
func LastWesternQuadrature(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.LastMarsWesternQuadrature(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.LastMarsWesternQuadrature(jde), date.Location(), false)
|
||||||
@@ -296,6 +307,7 @@ func LastWesternQuadrature(date time.Time) time.Time {
|
|||||||
// NextWesternQuadrature 下一次西方照 / next western quadrature.
|
// NextWesternQuadrature 下一次西方照 / next western quadrature.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之后最近一次西方照时刻,结果保持 date 的时区。
|
// 返回 date 当前或之后最近一次西方照时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest western quadrature at or after date, keeping date's time zone.
|
||||||
func NextWesternQuadrature(date time.Time) time.Time {
|
func NextWesternQuadrature(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.NextMarsWesternQuadrature(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.NextMarsWesternQuadrature(jde), date.Location(), false)
|
||||||
|
|||||||
@@ -208,6 +208,7 @@ func SetTime(date time.Time, lon, lat, height float64, aero bool) (time.Time, er
|
|||||||
// LastConjunction 上一次合日 / previous conjunction with the Sun.
|
// LastConjunction 上一次合日 / previous conjunction with the Sun.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之前最近一次与太阳的合日时刻,结果保持 date 的时区。
|
// 返回 date 当前或之前最近一次与太阳的合日时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest conjunction with the Sun at or before date, keeping date's time zone.
|
||||||
func LastConjunction(date time.Time) time.Time {
|
func LastConjunction(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.LastMercuryConjunction(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.LastMercuryConjunction(jde), date.Location(), false)
|
||||||
@@ -216,6 +217,7 @@ func LastConjunction(date time.Time) time.Time {
|
|||||||
// NextConjunction 下一次合日 / next conjunction with the Sun.
|
// NextConjunction 下一次合日 / next conjunction with the Sun.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之后最近一次与太阳的合日时刻,结果保持 date 的时区。
|
// 返回 date 当前或之后最近一次与太阳的合日时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest conjunction with the Sun at or after date, keeping date's time zone.
|
||||||
func NextConjunction(date time.Time) time.Time {
|
func NextConjunction(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.NextMercuryConjunction(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.NextMercuryConjunction(jde), date.Location(), false)
|
||||||
@@ -224,6 +226,7 @@ func NextConjunction(date time.Time) time.Time {
|
|||||||
// LastInferiorConjunction 上一次下合 / previous inferior conjunction.
|
// LastInferiorConjunction 上一次下合 / previous inferior conjunction.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之前最近一次下合时刻,结果保持 date 的时区。
|
// 返回 date 当前或之前最近一次下合时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest inferior conjunction at or before date, keeping date's time zone.
|
||||||
func LastInferiorConjunction(date time.Time) time.Time {
|
func LastInferiorConjunction(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.LastMercuryInferiorConjunctionInclusive(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.LastMercuryInferiorConjunctionInclusive(jde), date.Location(), false)
|
||||||
@@ -232,6 +235,7 @@ func LastInferiorConjunction(date time.Time) time.Time {
|
|||||||
// NextInferiorConjunction 下一次下合 / next inferior conjunction.
|
// NextInferiorConjunction 下一次下合 / next inferior conjunction.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之后最近一次下合时刻,结果保持 date 的时区。
|
// 返回 date 当前或之后最近一次下合时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest inferior conjunction at or after date, keeping date's time zone.
|
||||||
func NextInferiorConjunction(date time.Time) time.Time {
|
func NextInferiorConjunction(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.NextMercuryInferiorConjunctionInclusive(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.NextMercuryInferiorConjunctionInclusive(jde), date.Location(), false)
|
||||||
@@ -240,6 +244,7 @@ func NextInferiorConjunction(date time.Time) time.Time {
|
|||||||
// LastSuperiorConjunction 上一次上合 / previous superior conjunction.
|
// LastSuperiorConjunction 上一次上合 / previous superior conjunction.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之前最近一次上合时刻,结果保持 date 的时区。
|
// 返回 date 当前或之前最近一次上合时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest superior conjunction at or before date, keeping date's time zone.
|
||||||
func LastSuperiorConjunction(date time.Time) time.Time {
|
func LastSuperiorConjunction(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.LastMercurySuperiorConjunctionInclusive(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.LastMercurySuperiorConjunctionInclusive(jde), date.Location(), false)
|
||||||
@@ -248,6 +253,7 @@ func LastSuperiorConjunction(date time.Time) time.Time {
|
|||||||
// NextSuperiorConjunction 下一次上合 / next superior conjunction.
|
// NextSuperiorConjunction 下一次上合 / next superior conjunction.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之后最近一次上合时刻,结果保持 date 的时区。
|
// 返回 date 当前或之后最近一次上合时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest superior conjunction at or after date, keeping date's time zone.
|
||||||
func NextSuperiorConjunction(date time.Time) time.Time {
|
func NextSuperiorConjunction(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.NextMercurySuperiorConjunctionInclusive(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.NextMercurySuperiorConjunctionInclusive(jde), date.Location(), false)
|
||||||
@@ -256,6 +262,7 @@ func NextSuperiorConjunction(date time.Time) time.Time {
|
|||||||
// LastRetrograde 上一次留 / previous stationary point.
|
// LastRetrograde 上一次留 / previous stationary point.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之前最近一次留时刻,不区分顺转逆还是逆转顺,结果保持 date 的时区。
|
// 返回 date 当前或之前最近一次留时刻,不区分顺转逆还是逆转顺,结果保持 date 的时区。
|
||||||
|
// Returns the nearest stationary point at or before date, regardless of the direction change, keeping date's time zone.
|
||||||
func LastRetrograde(date time.Time) time.Time {
|
func LastRetrograde(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.LastMercuryRetrogradeInclusive(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.LastMercuryRetrogradeInclusive(jde), date.Location(), false)
|
||||||
@@ -264,6 +271,7 @@ func LastRetrograde(date time.Time) time.Time {
|
|||||||
// NextRetrograde 下一次留 / next stationary point.
|
// NextRetrograde 下一次留 / next stationary point.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之后最近一次留时刻,不区分顺转逆还是逆转顺,结果保持 date 的时区。
|
// 返回 date 当前或之后最近一次留时刻,不区分顺转逆还是逆转顺,结果保持 date 的时区。
|
||||||
|
// Returns the nearest stationary point at or after date, regardless of the direction change, keeping date's time zone.
|
||||||
func NextRetrograde(date time.Time) time.Time {
|
func NextRetrograde(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.NextMercuryRetrogradeInclusive(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.NextMercuryRetrogradeInclusive(jde), date.Location(), false)
|
||||||
@@ -272,6 +280,7 @@ func NextRetrograde(date time.Time) time.Time {
|
|||||||
// LastProgradeToRetrograde 上一次顺行转逆行留 / previous station from prograde to retrograde.
|
// LastProgradeToRetrograde 上一次顺行转逆行留 / previous station from prograde to retrograde.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之前最近一次由顺行转为逆行的留时刻,结果保持 date 的时区。
|
// 返回 date 当前或之前最近一次由顺行转为逆行的留时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest station at or before date where motion changes from prograde to retrograde, keeping date's time zone.
|
||||||
func LastProgradeToRetrograde(date time.Time) time.Time {
|
func LastProgradeToRetrograde(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.LastMercuryProgradeToRetrogradeInclusive(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.LastMercuryProgradeToRetrogradeInclusive(jde), date.Location(), false)
|
||||||
@@ -280,6 +289,7 @@ func LastProgradeToRetrograde(date time.Time) time.Time {
|
|||||||
// NextProgradeToRetrograde 下一次顺行转逆行留 / next station from prograde to retrograde.
|
// NextProgradeToRetrograde 下一次顺行转逆行留 / next station from prograde to retrograde.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之后最近一次由顺行转为逆行的留时刻,结果保持 date 的时区。
|
// 返回 date 当前或之后最近一次由顺行转为逆行的留时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest station at or after date where motion changes from prograde to retrograde, keeping date's time zone.
|
||||||
func NextProgradeToRetrograde(date time.Time) time.Time {
|
func NextProgradeToRetrograde(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.NextMercuryProgradeToRetrogradeInclusive(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.NextMercuryProgradeToRetrogradeInclusive(jde), date.Location(), false)
|
||||||
@@ -288,6 +298,7 @@ func NextProgradeToRetrograde(date time.Time) time.Time {
|
|||||||
// LastRetrogradeToPrograde 上一次逆行转顺行留 / previous station from retrograde to prograde.
|
// LastRetrogradeToPrograde 上一次逆行转顺行留 / previous station from retrograde to prograde.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之前最近一次由逆行转为顺行的留时刻,结果保持 date 的时区。
|
// 返回 date 当前或之前最近一次由逆行转为顺行的留时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest station at or before date where motion changes from retrograde to prograde, keeping date's time zone.
|
||||||
func LastRetrogradeToPrograde(date time.Time) time.Time {
|
func LastRetrogradeToPrograde(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.LastMercuryRetrogradeToProgradeInclusive(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.LastMercuryRetrogradeToProgradeInclusive(jde), date.Location(), false)
|
||||||
@@ -296,6 +307,7 @@ func LastRetrogradeToPrograde(date time.Time) time.Time {
|
|||||||
// NextRetrogradeToPrograde 下一次逆行转顺行留 / next station from retrograde to prograde.
|
// NextRetrogradeToPrograde 下一次逆行转顺行留 / next station from retrograde to prograde.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之后最近一次由逆行转为顺行的留时刻,结果保持 date 的时区。
|
// 返回 date 当前或之后最近一次由逆行转为顺行的留时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest station at or after date where motion changes from retrograde to prograde, keeping date's time zone.
|
||||||
func NextRetrogradeToPrograde(date time.Time) time.Time {
|
func NextRetrogradeToPrograde(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.NextMercuryRetrogradeToProgradeInclusive(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.NextMercuryRetrogradeToProgradeInclusive(jde), date.Location(), false)
|
||||||
@@ -304,6 +316,7 @@ func NextRetrogradeToPrograde(date time.Time) time.Time {
|
|||||||
// LastGreatestElongation 上一次大距 / previous greatest elongation.
|
// LastGreatestElongation 上一次大距 / previous greatest elongation.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之前最近一次大距时刻,不区分东西大距,结果保持 date 的时区。
|
// 返回 date 当前或之前最近一次大距时刻,不区分东西大距,结果保持 date 的时区。
|
||||||
|
// Returns the nearest greatest elongation at or before date, regardless of east or west, keeping date's time zone.
|
||||||
func LastGreatestElongation(date time.Time) time.Time {
|
func LastGreatestElongation(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.LastMercuryGreatestElongationInclusive(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.LastMercuryGreatestElongationInclusive(jde), date.Location(), false)
|
||||||
@@ -312,6 +325,7 @@ func LastGreatestElongation(date time.Time) time.Time {
|
|||||||
// NextGreatestElongation 下一次大距 / next greatest elongation.
|
// NextGreatestElongation 下一次大距 / next greatest elongation.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之后最近一次大距时刻,不区分东西大距,结果保持 date 的时区。
|
// 返回 date 当前或之后最近一次大距时刻,不区分东西大距,结果保持 date 的时区。
|
||||||
|
// Returns the nearest greatest elongation at or after date, regardless of east or west, keeping date's time zone.
|
||||||
func NextGreatestElongation(date time.Time) time.Time {
|
func NextGreatestElongation(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.NextMercuryGreatestElongationInclusive(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.NextMercuryGreatestElongationInclusive(jde), date.Location(), false)
|
||||||
@@ -320,6 +334,7 @@ func NextGreatestElongation(date time.Time) time.Time {
|
|||||||
// LastGreatestElongationEast 上一次东大距 / previous greatest eastern elongation.
|
// LastGreatestElongationEast 上一次东大距 / previous greatest eastern elongation.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之前最近一次东大距时刻,结果保持 date 的时区。
|
// 返回 date 当前或之前最近一次东大距时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest eastern greatest elongation at or before date, keeping date's time zone.
|
||||||
func LastGreatestElongationEast(date time.Time) time.Time {
|
func LastGreatestElongationEast(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.LastMercuryGreatestElongationEastInclusive(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.LastMercuryGreatestElongationEastInclusive(jde), date.Location(), false)
|
||||||
@@ -328,6 +343,7 @@ func LastGreatestElongationEast(date time.Time) time.Time {
|
|||||||
// NextGreatestElongationEast 下一次东大距 / next greatest eastern elongation.
|
// NextGreatestElongationEast 下一次东大距 / next greatest eastern elongation.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之后最近一次东大距时刻,结果保持 date 的时区。
|
// 返回 date 当前或之后最近一次东大距时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest eastern greatest elongation at or after date, keeping date's time zone.
|
||||||
func NextGreatestElongationEast(date time.Time) time.Time {
|
func NextGreatestElongationEast(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.NextMercuryGreatestElongationEastInclusive(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.NextMercuryGreatestElongationEastInclusive(jde), date.Location(), false)
|
||||||
@@ -336,6 +352,7 @@ func NextGreatestElongationEast(date time.Time) time.Time {
|
|||||||
// LastGreatestElongationWest 上一次西大距 / previous greatest western elongation.
|
// LastGreatestElongationWest 上一次西大距 / previous greatest western elongation.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之前最近一次西大距时刻,结果保持 date 的时区。
|
// 返回 date 当前或之前最近一次西大距时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest western greatest elongation at or before date, keeping date's time zone.
|
||||||
func LastGreatestElongationWest(date time.Time) time.Time {
|
func LastGreatestElongationWest(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.LastMercuryGreatestElongationWestInclusive(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.LastMercuryGreatestElongationWestInclusive(jde), date.Location(), false)
|
||||||
@@ -344,6 +361,7 @@ func LastGreatestElongationWest(date time.Time) time.Time {
|
|||||||
// NextGreatestElongationWest 下一次西大距 / next greatest western elongation.
|
// NextGreatestElongationWest 下一次西大距 / next greatest western elongation.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之后最近一次西大距时刻,结果保持 date 的时区。
|
// 返回 date 当前或之后最近一次西大距时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest western greatest elongation at or after date, keeping date's time zone.
|
||||||
func NextGreatestElongationWest(date time.Time) time.Time {
|
func NextGreatestElongationWest(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.NextMercuryGreatestElongationWestInclusive(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.NextMercuryGreatestElongationWestInclusive(jde), date.Location(), false)
|
||||||
|
|||||||
@@ -0,0 +1,72 @@
|
|||||||
|
package moon
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"b612.me/astro/basic"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ConjunctionPlanet 月球合月目标行星 / target planet for Moon-planet conjunction.
|
||||||
|
type ConjunctionPlanet string
|
||||||
|
|
||||||
|
const (
|
||||||
|
ConjunctionMercury ConjunctionPlanet = "mercury"
|
||||||
|
ConjunctionVenus ConjunctionPlanet = "venus"
|
||||||
|
ConjunctionMars ConjunctionPlanet = "mars"
|
||||||
|
ConjunctionJupiter ConjunctionPlanet = "jupiter"
|
||||||
|
ConjunctionSaturn ConjunctionPlanet = "saturn"
|
||||||
|
ConjunctionUranus ConjunctionPlanet = "uranus"
|
||||||
|
ConjunctionNeptune ConjunctionPlanet = "neptune"
|
||||||
|
)
|
||||||
|
|
||||||
|
func conjunctionPlanetToBasic(planet ConjunctionPlanet) basic.MoonPlanetConjunctionPlanet {
|
||||||
|
switch planet {
|
||||||
|
case ConjunctionMercury:
|
||||||
|
return basic.MoonPlanetConjunctionMercury
|
||||||
|
case ConjunctionVenus:
|
||||||
|
return basic.MoonPlanetConjunctionVenus
|
||||||
|
case ConjunctionMars:
|
||||||
|
return basic.MoonPlanetConjunctionMars
|
||||||
|
case ConjunctionJupiter:
|
||||||
|
return basic.MoonPlanetConjunctionJupiter
|
||||||
|
case ConjunctionSaturn:
|
||||||
|
return basic.MoonPlanetConjunctionSaturn
|
||||||
|
case ConjunctionUranus:
|
||||||
|
return basic.MoonPlanetConjunctionUranus
|
||||||
|
case ConjunctionNeptune:
|
||||||
|
return basic.MoonPlanetConjunctionNeptune
|
||||||
|
default:
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func validConjunctionPlanet(planet ConjunctionPlanet) bool {
|
||||||
|
return conjunctionPlanetToBasic(planet) != 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// LastConjunctionWithPlanet 上一次行星合月(赤经合) / previous Moon-planet conjunction.
|
||||||
|
func LastConjunctionWithPlanet(date time.Time, planet ConjunctionPlanet) time.Time {
|
||||||
|
if !validConjunctionPlanet(planet) {
|
||||||
|
return time.Time{}
|
||||||
|
}
|
||||||
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
|
return basic.JDE2DateByZone(basic.LastMoonPlanetConjunction(jde, conjunctionPlanetToBasic(planet)), date.Location(), false)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NextConjunctionWithPlanet 下一次行星合月(赤经合) / next Moon-planet conjunction.
|
||||||
|
func NextConjunctionWithPlanet(date time.Time, planet ConjunctionPlanet) time.Time {
|
||||||
|
if !validConjunctionPlanet(planet) {
|
||||||
|
return time.Time{}
|
||||||
|
}
|
||||||
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
|
return basic.JDE2DateByZone(basic.NextMoonPlanetConjunction(jde, conjunctionPlanetToBasic(planet)), date.Location(), false)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClosestConjunctionWithPlanet 最近一次行星合月(赤经合) / closest Moon-planet conjunction.
|
||||||
|
func ClosestConjunctionWithPlanet(date time.Time, planet ConjunctionPlanet) time.Time {
|
||||||
|
if !validConjunctionPlanet(planet) {
|
||||||
|
return time.Time{}
|
||||||
|
}
|
||||||
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
|
return basic.JDE2DateByZone(basic.ClosestMoonPlanetConjunction(jde, conjunctionPlanetToBasic(planet)), date.Location(), false)
|
||||||
|
}
|
||||||
@@ -0,0 +1,103 @@
|
|||||||
|
package moon
|
||||||
|
|
||||||
|
import (
|
||||||
|
"math"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"b612.me/astro/basic"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestConjunctionPlanetWrappersMatchBasic(t *testing.T) {
|
||||||
|
loc := time.FixedZone("CST", 8*3600)
|
||||||
|
query := time.Date(2026, 1, 15, 20, 0, 0, 0, loc)
|
||||||
|
queryTT := basic.TD2UT(basic.Date2JDE(query.UTC()), true)
|
||||||
|
|
||||||
|
cases := []struct {
|
||||||
|
name string
|
||||||
|
planet ConjunctionPlanet
|
||||||
|
basic basic.MoonPlanetConjunctionPlanet
|
||||||
|
}{
|
||||||
|
{name: "Mercury", planet: ConjunctionMercury, basic: basic.MoonPlanetConjunctionMercury},
|
||||||
|
{name: "Venus", planet: ConjunctionVenus, basic: basic.MoonPlanetConjunctionVenus},
|
||||||
|
{name: "Mars", planet: ConjunctionMars, basic: basic.MoonPlanetConjunctionMars},
|
||||||
|
{name: "Jupiter", planet: ConjunctionJupiter, basic: basic.MoonPlanetConjunctionJupiter},
|
||||||
|
{name: "Saturn", planet: ConjunctionSaturn, basic: basic.MoonPlanetConjunctionSaturn},
|
||||||
|
{name: "Uranus", planet: ConjunctionUranus, basic: basic.MoonPlanetConjunctionUranus},
|
||||||
|
{name: "Neptune", planet: ConjunctionNeptune, basic: basic.MoonPlanetConjunctionNeptune},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tc := range cases {
|
||||||
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
|
assertSameConjunctionTime(t, "last", LastConjunctionWithPlanet(query, tc.planet), basic.LastMoonPlanetConjunction(queryTT, tc.basic), loc)
|
||||||
|
assertSameConjunctionTime(t, "next", NextConjunctionWithPlanet(query, tc.planet), basic.NextMoonPlanetConjunction(queryTT, tc.basic), loc)
|
||||||
|
assertSameConjunctionTime(t, "closest", ClosestConjunctionWithPlanet(query, tc.planet), basic.ClosestMoonPlanetConjunction(queryTT, tc.basic), loc)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func assertSameConjunctionTime(t *testing.T, name string, got time.Time, wantJDE float64, loc *time.Location) {
|
||||||
|
t.Helper()
|
||||||
|
want := basic.JDE2DateByZone(wantJDE, loc, false)
|
||||||
|
if got.Location() != loc {
|
||||||
|
t.Fatalf("%s location mismatch: got %q want %q", name, got.Location().String(), loc.String())
|
||||||
|
}
|
||||||
|
if !got.Equal(want) {
|
||||||
|
t.Fatalf("%s time mismatch: got %s want %s", name, got.Format(time.RFC3339Nano), want.Format(time.RFC3339Nano))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestClosestConjunctionReturnsNearestCandidate(t *testing.T) {
|
||||||
|
query := time.Date(2026, 1, 15, 12, 0, 0, 0, time.UTC)
|
||||||
|
last := LastConjunctionWithPlanet(query, ConjunctionMercury)
|
||||||
|
next := NextConjunctionWithPlanet(query, ConjunctionMercury)
|
||||||
|
got := ClosestConjunctionWithPlanet(query, ConjunctionMercury)
|
||||||
|
|
||||||
|
lastDiff := math.Abs(query.Sub(last).Seconds())
|
||||||
|
nextDiff := math.Abs(next.Sub(query).Seconds())
|
||||||
|
if lastDiff <= nextDiff {
|
||||||
|
if !got.Equal(last) {
|
||||||
|
t.Fatalf("closest should match last: got %s want %s", got.Format(time.RFC3339Nano), last.Format(time.RFC3339Nano))
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if !got.Equal(next) {
|
||||||
|
t.Fatalf("closest should match next: got %s want %s", got.Format(time.RFC3339Nano), next.Format(time.RFC3339Nano))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestInvalidConjunctionPlanetReturnsZeroTime(t *testing.T) {
|
||||||
|
query := time.Date(2026, 1, 15, 12, 0, 0, 0, time.FixedZone("CST", 8*3600))
|
||||||
|
invalid := ConjunctionPlanet("pluto")
|
||||||
|
|
||||||
|
for name, fn := range map[string]func(time.Time, ConjunctionPlanet) time.Time{
|
||||||
|
"last": LastConjunctionWithPlanet,
|
||||||
|
"next": NextConjunctionWithPlanet,
|
||||||
|
"closest": ClosestConjunctionWithPlanet,
|
||||||
|
} {
|
||||||
|
if got := fn(query, invalid); !got.IsZero() {
|
||||||
|
t.Fatalf("%s should return zero time for invalid planet, got %s", name, got.Format(time.RFC3339Nano))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNextConjunctionAdvancesPastReturnedEvent(t *testing.T) {
|
||||||
|
cursor := time.Date(2026, 5, 1, 0, 0, 0, 0, time.UTC)
|
||||||
|
first := NextConjunctionWithPlanet(cursor, ConjunctionMercury)
|
||||||
|
query := first.Add(time.Second)
|
||||||
|
next := NextConjunctionWithPlanet(query, ConjunctionMercury)
|
||||||
|
|
||||||
|
if !next.After(query) {
|
||||||
|
t.Fatalf("expected next conjunction after query: query=%s next=%s delta=%v",
|
||||||
|
query.Format(time.RFC3339Nano),
|
||||||
|
next.Format(time.RFC3339Nano),
|
||||||
|
next.Sub(query),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if next.Equal(first) {
|
||||||
|
t.Fatalf("expected next conjunction to advance: first=%s next=%s",
|
||||||
|
first.Format(time.RFC3339Nano),
|
||||||
|
next.Format(time.RFC3339Nano),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package moon
|
||||||
|
|
||||||
|
import (
|
||||||
|
"math"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"b612.me/astro/basic"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestGeocentricApparentRaDecComponentsMatch(t *testing.T) {
|
||||||
|
date := time.Date(2026, 1, 1, 6, 0, 0, 0, time.UTC)
|
||||||
|
|
||||||
|
ra, dec := GeocentricApparentRaDec(date)
|
||||||
|
if diff := math.Abs(ra - GeocentricApparentRa(date)); diff > 1e-12 {
|
||||||
|
t.Fatalf("RA pair mismatch: got %.15f want %.15f", ra, GeocentricApparentRa(date))
|
||||||
|
}
|
||||||
|
if diff := math.Abs(dec - GeocentricApparentDec(date)); diff > 1e-12 {
|
||||||
|
t.Fatalf("Dec pair mismatch: got %.15f want %.15f", dec, GeocentricApparentDec(date))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGeocentricApparentRaDecDiffersFromTopocentricAtSite(t *testing.T) {
|
||||||
|
date := time.Date(2026, 1, 1, 6, 0, 0, 0, time.FixedZone("CST", 8*3600))
|
||||||
|
|
||||||
|
geoRA, geoDec := GeocentricApparentRaDec(date)
|
||||||
|
topoRA, topoDec := ApparentRaDec(date, 121.4737, 31.2304)
|
||||||
|
|
||||||
|
if math.Abs(geoRA-topoRA) < 1e-6 && math.Abs(geoDec-topoDec) < 1e-6 {
|
||||||
|
t.Fatalf("geocentric apparent RA/Dec unexpectedly matches topocentric values: geo=(%.12f, %.12f) topo=(%.12f, %.12f)",
|
||||||
|
geoRA, geoDec, topoRA, topoDec)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestTrueRaDecUsesBasicGeocentricTrue(t *testing.T) {
|
||||||
|
date := time.Date(2026, 1, 1, 6, 0, 0, 0, time.UTC)
|
||||||
|
|
||||||
|
wantRA, wantDec := basic.HMoonGeocentricTrueRaDec(basic.TD2UT(basic.Date2JDE(date.UTC()), true))
|
||||||
|
gotRA, gotDec := TrueRaDec(date)
|
||||||
|
if math.Abs(gotRA-wantRA) > 1e-12 || math.Abs(gotDec-wantDec) > 1e-12 {
|
||||||
|
t.Fatalf("TrueRaDec mismatch: got (%.15f, %.15f) want (%.15f, %.15f)", gotRA, gotDec, wantRA, wantDec)
|
||||||
|
}
|
||||||
|
}
|
||||||
+30
-3
@@ -84,7 +84,7 @@ func ApparentLo(date time.Time) float64 {
|
|||||||
// Returns the Moon's geocentric true right ascension at the instant represented by date, in degrees.
|
// Returns the Moon's geocentric true right ascension at the instant represented by date, in degrees.
|
||||||
func TrueRa(date time.Time) float64 {
|
func TrueRa(date time.Time) float64 {
|
||||||
jde := basic.Date2JDE(date.UTC())
|
jde := basic.Date2JDE(date.UTC())
|
||||||
return basic.HMoonTrueRa(basic.TD2UT(jde, true))
|
return basic.HMoonGeocentricTrueRa(basic.TD2UT(jde, true))
|
||||||
}
|
}
|
||||||
|
|
||||||
// TrueDec 月亮地心真赤纬 / true geocentric declination.
|
// TrueDec 月亮地心真赤纬 / true geocentric declination.
|
||||||
@@ -93,7 +93,7 @@ func TrueRa(date time.Time) float64 {
|
|||||||
// Returns the Moon's geocentric true declination at the instant represented by date, in degrees.
|
// Returns the Moon's geocentric true declination at the instant represented by date, in degrees.
|
||||||
func TrueDec(date time.Time) float64 {
|
func TrueDec(date time.Time) float64 {
|
||||||
jde := basic.Date2JDE(date.UTC())
|
jde := basic.Date2JDE(date.UTC())
|
||||||
return basic.HMoonTrueDec(basic.TD2UT(jde, true))
|
return basic.HMoonGeocentricTrueDec(basic.TD2UT(jde, true))
|
||||||
}
|
}
|
||||||
|
|
||||||
// TrueRaDec 月亮地心真赤经、真赤纬 / true geocentric right ascension and declination.
|
// TrueRaDec 月亮地心真赤经、真赤纬 / true geocentric right ascension and declination.
|
||||||
@@ -102,7 +102,34 @@ func TrueDec(date time.Time) float64 {
|
|||||||
// Returns the Moon's geocentric true right ascension and declination at the instant represented by date, in degrees.
|
// Returns the Moon's geocentric true right ascension and declination at the instant represented by date, in degrees.
|
||||||
func TrueRaDec(date time.Time) (float64, float64) {
|
func TrueRaDec(date time.Time) (float64, float64) {
|
||||||
jde := basic.Date2JDE(date.UTC())
|
jde := basic.Date2JDE(date.UTC())
|
||||||
return basic.HMoonTrueRaDec(basic.TD2UT(jde, true))
|
return basic.HMoonGeocentricTrueRaDec(basic.TD2UT(jde, true))
|
||||||
|
}
|
||||||
|
|
||||||
|
// GeocentricApparentRa 月亮地心视赤经 / apparent geocentric right ascension.
|
||||||
|
//
|
||||||
|
// 返回月亮在 date 对应绝对时刻的地心视赤经,单位度。
|
||||||
|
// Returns the Moon's apparent geocentric right ascension at the instant represented by date, in degrees.
|
||||||
|
func GeocentricApparentRa(date time.Time) float64 {
|
||||||
|
jde := basic.Date2JDE(date.UTC())
|
||||||
|
return basic.HMoonGeocentricApparentRa(basic.TD2UT(jde, true))
|
||||||
|
}
|
||||||
|
|
||||||
|
// GeocentricApparentDec 月亮地心视赤纬 / apparent geocentric declination.
|
||||||
|
//
|
||||||
|
// 返回月亮在 date 对应绝对时刻的地心视赤纬,单位度。
|
||||||
|
// Returns the Moon's apparent geocentric declination at the instant represented by date, in degrees.
|
||||||
|
func GeocentricApparentDec(date time.Time) float64 {
|
||||||
|
jde := basic.Date2JDE(date.UTC())
|
||||||
|
return basic.HMoonGeocentricApparentDec(basic.TD2UT(jde, true))
|
||||||
|
}
|
||||||
|
|
||||||
|
// GeocentricApparentRaDec 月亮地心视赤经、视赤纬 / apparent geocentric right ascension and declination.
|
||||||
|
//
|
||||||
|
// 返回月亮在 date 对应绝对时刻的地心视赤经与视赤纬,单位度。
|
||||||
|
// Returns the Moon's apparent geocentric right ascension and declination at the instant represented by date, in degrees.
|
||||||
|
func GeocentricApparentRaDec(date time.Time) (float64, float64) {
|
||||||
|
jde := basic.Date2JDE(date.UTC())
|
||||||
|
return basic.HMoonGeocentricApparentRaDec(basic.TD2UT(jde, true))
|
||||||
}
|
}
|
||||||
|
|
||||||
// ApparentRa 月亮站心视赤经 / apparent topocentric right ascension.
|
// ApparentRa 月亮站心视赤经 / apparent topocentric right ascension.
|
||||||
|
|||||||
@@ -208,6 +208,7 @@ func SetTime(date time.Time, lon, lat, height float64, aero bool) (time.Time, er
|
|||||||
// LastConjunction 上一次合日 / previous conjunction with the Sun.
|
// LastConjunction 上一次合日 / previous conjunction with the Sun.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之前最近一次与太阳的合日时刻,结果保持 date 的时区。
|
// 返回 date 当前或之前最近一次与太阳的合日时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest conjunction with the Sun at or before date, keeping date's time zone.
|
||||||
func LastConjunction(date time.Time) time.Time {
|
func LastConjunction(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.LastNeptuneConjunction(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.LastNeptuneConjunction(jde), date.Location(), false)
|
||||||
@@ -216,6 +217,7 @@ func LastConjunction(date time.Time) time.Time {
|
|||||||
// NextConjunction 下一次合日 / next conjunction with the Sun.
|
// NextConjunction 下一次合日 / next conjunction with the Sun.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之后最近一次与太阳的合日时刻,结果保持 date 的时区。
|
// 返回 date 当前或之后最近一次与太阳的合日时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest conjunction with the Sun at or after date, keeping date's time zone.
|
||||||
func NextConjunction(date time.Time) time.Time {
|
func NextConjunction(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.NextNeptuneConjunction(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.NextNeptuneConjunction(jde), date.Location(), false)
|
||||||
@@ -224,6 +226,7 @@ func NextConjunction(date time.Time) time.Time {
|
|||||||
// LastOpposition 上一次冲日 / previous opposition.
|
// LastOpposition 上一次冲日 / previous opposition.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之前最近一次冲日时刻,结果保持 date 的时区。
|
// 返回 date 当前或之前最近一次冲日时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest opposition at or before date, keeping date's time zone.
|
||||||
func LastOpposition(date time.Time) time.Time {
|
func LastOpposition(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.LastNeptuneOpposition(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.LastNeptuneOpposition(jde), date.Location(), false)
|
||||||
@@ -232,6 +235,7 @@ func LastOpposition(date time.Time) time.Time {
|
|||||||
// NextOpposition 下一次冲日 / next opposition.
|
// NextOpposition 下一次冲日 / next opposition.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之后最近一次冲日时刻,结果保持 date 的时区。
|
// 返回 date 当前或之后最近一次冲日时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest opposition at or after date, keeping date's time zone.
|
||||||
func NextOpposition(date time.Time) time.Time {
|
func NextOpposition(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.NextNeptuneOpposition(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.NextNeptuneOpposition(jde), date.Location(), false)
|
||||||
@@ -240,6 +244,7 @@ func NextOpposition(date time.Time) time.Time {
|
|||||||
// LastProgradeToRetrograde 上一次顺行转逆行留 / previous station from prograde to retrograde.
|
// LastProgradeToRetrograde 上一次顺行转逆行留 / previous station from prograde to retrograde.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之前最近一次由顺行转为逆行的留时刻,结果保持 date 的时区。
|
// 返回 date 当前或之前最近一次由顺行转为逆行的留时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest station at or before date where motion changes from prograde to retrograde, keeping date's time zone.
|
||||||
func LastProgradeToRetrograde(date time.Time) time.Time {
|
func LastProgradeToRetrograde(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.LastNeptuneProgradeToRetrograde(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.LastNeptuneProgradeToRetrograde(jde), date.Location(), false)
|
||||||
@@ -248,6 +253,7 @@ func LastProgradeToRetrograde(date time.Time) time.Time {
|
|||||||
// NextProgradeToRetrograde 下一次顺行转逆行留 / next station from prograde to retrograde.
|
// NextProgradeToRetrograde 下一次顺行转逆行留 / next station from prograde to retrograde.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之后最近一次由顺行转为逆行的留时刻,结果保持 date 的时区。
|
// 返回 date 当前或之后最近一次由顺行转为逆行的留时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest station at or after date where motion changes from prograde to retrograde, keeping date's time zone.
|
||||||
func NextProgradeToRetrograde(date time.Time) time.Time {
|
func NextProgradeToRetrograde(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.NextNeptuneProgradeToRetrograde(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.NextNeptuneProgradeToRetrograde(jde), date.Location(), false)
|
||||||
@@ -256,6 +262,7 @@ func NextProgradeToRetrograde(date time.Time) time.Time {
|
|||||||
// LastRetrogradeToPrograde 上一次逆行转顺行留 / previous station from retrograde to prograde.
|
// LastRetrogradeToPrograde 上一次逆行转顺行留 / previous station from retrograde to prograde.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之前最近一次由逆行转为顺行的留时刻,结果保持 date 的时区。
|
// 返回 date 当前或之前最近一次由逆行转为顺行的留时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest station at or before date where motion changes from retrograde to prograde, keeping date's time zone.
|
||||||
func LastRetrogradeToPrograde(date time.Time) time.Time {
|
func LastRetrogradeToPrograde(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.LastNeptuneRetrogradeToPrograde(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.LastNeptuneRetrogradeToPrograde(jde), date.Location(), false)
|
||||||
@@ -264,6 +271,7 @@ func LastRetrogradeToPrograde(date time.Time) time.Time {
|
|||||||
// NextRetrogradeToPrograde 下一次逆行转顺行留 / next station from retrograde to prograde.
|
// NextRetrogradeToPrograde 下一次逆行转顺行留 / next station from retrograde to prograde.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之后最近一次由逆行转为顺行的留时刻,结果保持 date 的时区。
|
// 返回 date 当前或之后最近一次由逆行转为顺行的留时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest station at or after date where motion changes from retrograde to prograde, keeping date's time zone.
|
||||||
func NextRetrogradeToPrograde(date time.Time) time.Time {
|
func NextRetrogradeToPrograde(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.NextNeptuneRetrogradeToPrograde(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.NextNeptuneRetrogradeToPrograde(jde), date.Location(), false)
|
||||||
@@ -272,6 +280,7 @@ func NextRetrogradeToPrograde(date time.Time) time.Time {
|
|||||||
// LastEasternQuadrature 上一次东方照 / previous eastern quadrature.
|
// LastEasternQuadrature 上一次东方照 / previous eastern quadrature.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之前最近一次东方照时刻,结果保持 date 的时区。
|
// 返回 date 当前或之前最近一次东方照时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest eastern quadrature at or before date, keeping date's time zone.
|
||||||
func LastEasternQuadrature(date time.Time) time.Time {
|
func LastEasternQuadrature(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.LastNeptuneEasternQuadrature(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.LastNeptuneEasternQuadrature(jde), date.Location(), false)
|
||||||
@@ -280,6 +289,7 @@ func LastEasternQuadrature(date time.Time) time.Time {
|
|||||||
// NextEasternQuadrature 下一次东方照 / next eastern quadrature.
|
// NextEasternQuadrature 下一次东方照 / next eastern quadrature.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之后最近一次东方照时刻,结果保持 date 的时区。
|
// 返回 date 当前或之后最近一次东方照时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest eastern quadrature at or after date, keeping date's time zone.
|
||||||
func NextEasternQuadrature(date time.Time) time.Time {
|
func NextEasternQuadrature(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.NextNeptuneEasternQuadrature(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.NextNeptuneEasternQuadrature(jde), date.Location(), false)
|
||||||
@@ -288,6 +298,7 @@ func NextEasternQuadrature(date time.Time) time.Time {
|
|||||||
// LastWesternQuadrature 上一次西方照 / previous western quadrature.
|
// LastWesternQuadrature 上一次西方照 / previous western quadrature.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之前最近一次西方照时刻,结果保持 date 的时区。
|
// 返回 date 当前或之前最近一次西方照时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest western quadrature at or before date, keeping date's time zone.
|
||||||
func LastWesternQuadrature(date time.Time) time.Time {
|
func LastWesternQuadrature(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.LastNeptuneWesternQuadrature(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.LastNeptuneWesternQuadrature(jde), date.Location(), false)
|
||||||
@@ -296,6 +307,7 @@ func LastWesternQuadrature(date time.Time) time.Time {
|
|||||||
// NextWesternQuadrature 下一次西方照 / next western quadrature.
|
// NextWesternQuadrature 下一次西方照 / next western quadrature.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之后最近一次西方照时刻,结果保持 date 的时区。
|
// 返回 date 当前或之后最近一次西方照时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest western quadrature at or after date, keeping date's time zone.
|
||||||
func NextWesternQuadrature(date time.Time) time.Time {
|
func NextWesternQuadrature(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.NextNeptuneWesternQuadrature(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.NextNeptuneWesternQuadrature(jde), date.Location(), false)
|
||||||
|
|||||||
+33
-3
@@ -12,13 +12,17 @@ var (
|
|||||||
ERR_ORBIT_NEVER_SET = errors.New("ERROR:轨道目标今日永远在地平线上!")
|
ERR_ORBIT_NEVER_SET = errors.New("ERROR:轨道目标今日永远在地平线上!")
|
||||||
)
|
)
|
||||||
|
|
||||||
// Elements 日心二体圆锥曲线根数,参考系为 J2000 平黄道/平春分点。
|
// Elements 日心二体圆锥曲线根数 / heliocentric two-body conic elements.
|
||||||
|
// 参考系为 J2000 平黄道/平春分点。
|
||||||
|
// The reference frame is the J2000 mean ecliptic and mean equinox.
|
||||||
// EpochJD 与 TpJD 使用 TT/TDB 对应的儒略日。
|
// EpochJD 与 TpJD 使用 TT/TDB 对应的儒略日。
|
||||||
|
// EpochJD and TpJD are Julian days on the TT/TDB scale.
|
||||||
//
|
//
|
||||||
// 经典椭圆根数:A/E/I/Omega/W/M0
|
// 经典椭圆根数:A/E/I/Omega/W/M0
|
||||||
// 近日点形式:Q/E/I/Omega/W/TpJD
|
// 近日点形式:Q/E/I/Omega/W/TpJD
|
||||||
//
|
//
|
||||||
// 线性 rates 仅作用于经典椭圆根数,单位均为每天变化量。
|
// 线性 rates 仅作用于经典椭圆根数,单位均为每天变化量。
|
||||||
|
// The linear rates apply only to the classical elliptical element form and are expressed per day.
|
||||||
type Elements struct {
|
type Elements struct {
|
||||||
EpochJD float64 // 历元儒略日(TT/TDB) / epoch Julian day in TT/TDB.
|
EpochJD float64 // 历元儒略日(TT/TDB) / epoch Julian day in TT/TDB.
|
||||||
A float64 // 半长径,单位 AU / semi-major axis in AU.
|
A float64 // 半长径,单位 AU / semi-major axis in AU.
|
||||||
@@ -38,14 +42,20 @@ type Elements struct {
|
|||||||
MDot float64 // 平近点角日变化,单位 deg/day / daily rate of M.
|
MDot float64 // 平近点角日变化,单位 deg/day / daily rate of M.
|
||||||
}
|
}
|
||||||
|
|
||||||
// EclipticPosition 黄道球坐标结果,Lon/Lat 单位度,Distance 单位 AU。
|
// EclipticPosition 黄道球坐标结果 / ecliptic spherical coordinates.
|
||||||
|
//
|
||||||
|
// Lon/Lat 单位度,Distance 单位 AU。
|
||||||
|
// Lon/Lat are in degrees and Distance is in AU.
|
||||||
type EclipticPosition struct {
|
type EclipticPosition struct {
|
||||||
Lon float64
|
Lon float64
|
||||||
Lat float64
|
Lat float64
|
||||||
Distance float64
|
Distance float64
|
||||||
}
|
}
|
||||||
|
|
||||||
// EquatorialPosition 赤道球坐标结果,RA/Dec 单位度,Distance 单位 AU。
|
// EquatorialPosition 赤道球坐标结果 / equatorial spherical coordinates.
|
||||||
|
//
|
||||||
|
// RA/Dec 单位度,Distance 单位 AU。
|
||||||
|
// RA/Dec are in degrees and Distance is in AU.
|
||||||
type EquatorialPosition struct {
|
type EquatorialPosition struct {
|
||||||
RA float64
|
RA float64
|
||||||
Dec float64
|
Dec float64
|
||||||
@@ -55,6 +65,7 @@ type EquatorialPosition struct {
|
|||||||
// MeanMotion 平均角速度 / mean motion.
|
// MeanMotion 平均角速度 / mean motion.
|
||||||
//
|
//
|
||||||
// 返回平均角速度,单位度/日;对抛物线和双曲线轨道返回 `NaN`。
|
// 返回平均角速度,单位度/日;对抛物线和双曲线轨道返回 `NaN`。
|
||||||
|
// Returns mean motion in degrees per day. Parabolic and hyperbolic cases return `NaN`.
|
||||||
func MeanMotion(elements Elements) float64 {
|
func MeanMotion(elements Elements) float64 {
|
||||||
return basic.OrbitMeanMotion(toBasicElements(elements))
|
return basic.OrbitMeanMotion(toBasicElements(elements))
|
||||||
}
|
}
|
||||||
@@ -62,6 +73,7 @@ func MeanMotion(elements Elements) float64 {
|
|||||||
// MeanAnomaly 平近点角 / mean anomaly.
|
// MeanAnomaly 平近点角 / mean anomaly.
|
||||||
//
|
//
|
||||||
// 返回给定时刻的平近点角,单位度;对抛物线和双曲线轨道返回 `NaN`。
|
// 返回给定时刻的平近点角,单位度;对抛物线和双曲线轨道返回 `NaN`。
|
||||||
|
// Returns mean anomaly in degrees for the supplied instant. Parabolic and hyperbolic cases return `NaN`.
|
||||||
func MeanAnomaly(date time.Time, elements Elements) float64 {
|
func MeanAnomaly(date time.Time, elements Elements) float64 {
|
||||||
return basic.OrbitMeanAnomaly(ttJulianDay(date), toBasicElements(elements))
|
return basic.OrbitMeanAnomaly(ttJulianDay(date), toBasicElements(elements))
|
||||||
}
|
}
|
||||||
@@ -69,6 +81,7 @@ func MeanAnomaly(date time.Time, elements Elements) float64 {
|
|||||||
// TrueAnomaly 真近点角 / true anomaly.
|
// TrueAnomaly 真近点角 / true anomaly.
|
||||||
//
|
//
|
||||||
// 返回给定时刻的真近点角,单位度。
|
// 返回给定时刻的真近点角,单位度。
|
||||||
|
// Returns true anomaly in degrees for the supplied instant.
|
||||||
func TrueAnomaly(date time.Time, elements Elements) float64 {
|
func TrueAnomaly(date time.Time, elements Elements) float64 {
|
||||||
return basic.OrbitTrueAnomaly(ttJulianDay(date), toBasicElements(elements))
|
return basic.OrbitTrueAnomaly(ttJulianDay(date), toBasicElements(elements))
|
||||||
}
|
}
|
||||||
@@ -76,6 +89,7 @@ func TrueAnomaly(date time.Time, elements Elements) float64 {
|
|||||||
// HeliocentricEclipticJ2000 日心 J2000 平黄道坐标 / heliocentric J2000 ecliptic coordinates.
|
// HeliocentricEclipticJ2000 日心 J2000 平黄道坐标 / heliocentric J2000 ecliptic coordinates.
|
||||||
//
|
//
|
||||||
// 返回黄经、黄纬和距离;角度单位度,距离单位 AU。
|
// 返回黄经、黄纬和距离;角度单位度,距离单位 AU。
|
||||||
|
// Returns heliocentric J2000 ecliptic longitude, latitude, and distance. Angles are in degrees and distance is in AU.
|
||||||
func HeliocentricEclipticJ2000(date time.Time, elements Elements) EclipticPosition {
|
func HeliocentricEclipticJ2000(date time.Time, elements Elements) EclipticPosition {
|
||||||
lon, lat, distance := basic.OrbitHeliocentricEclipticJ2000(ttJulianDay(date), toBasicElements(elements))
|
lon, lat, distance := basic.OrbitHeliocentricEclipticJ2000(ttJulianDay(date), toBasicElements(elements))
|
||||||
return EclipticPosition{Lon: lon, Lat: lat, Distance: distance}
|
return EclipticPosition{Lon: lon, Lat: lat, Distance: distance}
|
||||||
@@ -84,6 +98,7 @@ func HeliocentricEclipticJ2000(date time.Time, elements Elements) EclipticPositi
|
|||||||
// HeliocentricEcliptic 日心历元黄道坐标 / heliocentric ecliptic coordinates of date.
|
// HeliocentricEcliptic 日心历元黄道坐标 / heliocentric ecliptic coordinates of date.
|
||||||
//
|
//
|
||||||
// 返回历元黄经、黄纬和距离;角度单位度,距离单位 AU。
|
// 返回历元黄经、黄纬和距离;角度单位度,距离单位 AU。
|
||||||
|
// Returns heliocentric ecliptic longitude, latitude, and distance of date. Angles are in degrees and distance is in AU.
|
||||||
func HeliocentricEcliptic(date time.Time, elements Elements) EclipticPosition {
|
func HeliocentricEcliptic(date time.Time, elements Elements) EclipticPosition {
|
||||||
lon, lat, distance := basic.OrbitHeliocentricEcliptic(ttJulianDay(date), toBasicElements(elements))
|
lon, lat, distance := basic.OrbitHeliocentricEcliptic(ttJulianDay(date), toBasicElements(elements))
|
||||||
return EclipticPosition{Lon: lon, Lat: lat, Distance: distance}
|
return EclipticPosition{Lon: lon, Lat: lat, Distance: distance}
|
||||||
@@ -92,6 +107,7 @@ func HeliocentricEcliptic(date time.Time, elements Elements) EclipticPosition {
|
|||||||
// GeocentricEclipticJ2000 地心 J2000 平黄道坐标 / geocentric J2000 ecliptic coordinates.
|
// GeocentricEclipticJ2000 地心 J2000 平黄道坐标 / geocentric J2000 ecliptic coordinates.
|
||||||
//
|
//
|
||||||
// 返回黄经、黄纬和距离;角度单位度,距离单位 AU。
|
// 返回黄经、黄纬和距离;角度单位度,距离单位 AU。
|
||||||
|
// Returns geocentric J2000 ecliptic longitude, latitude, and distance. Angles are in degrees and distance is in AU.
|
||||||
func GeocentricEclipticJ2000(date time.Time, elements Elements) EclipticPosition {
|
func GeocentricEclipticJ2000(date time.Time, elements Elements) EclipticPosition {
|
||||||
lon, lat, distance := basic.OrbitGeocentricEclipticJ2000(ttJulianDay(date), toBasicElements(elements))
|
lon, lat, distance := basic.OrbitGeocentricEclipticJ2000(ttJulianDay(date), toBasicElements(elements))
|
||||||
return EclipticPosition{Lon: lon, Lat: lat, Distance: distance}
|
return EclipticPosition{Lon: lon, Lat: lat, Distance: distance}
|
||||||
@@ -100,6 +116,7 @@ func GeocentricEclipticJ2000(date time.Time, elements Elements) EclipticPosition
|
|||||||
// GeocentricEcliptic 地心历元黄道坐标 / geocentric ecliptic coordinates of date.
|
// GeocentricEcliptic 地心历元黄道坐标 / geocentric ecliptic coordinates of date.
|
||||||
//
|
//
|
||||||
// 返回历元黄经、黄纬和距离;角度单位度,距离单位 AU。
|
// 返回历元黄经、黄纬和距离;角度单位度,距离单位 AU。
|
||||||
|
// Returns geocentric ecliptic longitude, latitude, and distance of date. Angles are in degrees and distance is in AU.
|
||||||
func GeocentricEcliptic(date time.Time, elements Elements) EclipticPosition {
|
func GeocentricEcliptic(date time.Time, elements Elements) EclipticPosition {
|
||||||
lon, lat, distance := basic.OrbitGeocentricEcliptic(ttJulianDay(date), toBasicElements(elements))
|
lon, lat, distance := basic.OrbitGeocentricEcliptic(ttJulianDay(date), toBasicElements(elements))
|
||||||
return EclipticPosition{Lon: lon, Lat: lat, Distance: distance}
|
return EclipticPosition{Lon: lon, Lat: lat, Distance: distance}
|
||||||
@@ -108,6 +125,7 @@ func GeocentricEcliptic(date time.Time, elements Elements) EclipticPosition {
|
|||||||
// GeocentricEquatorialJ2000 地心 J2000 平赤道坐标 / geocentric J2000 equatorial coordinates.
|
// GeocentricEquatorialJ2000 地心 J2000 平赤道坐标 / geocentric J2000 equatorial coordinates.
|
||||||
//
|
//
|
||||||
// 返回赤经、赤纬和距离;角度单位度,距离单位 AU。
|
// 返回赤经、赤纬和距离;角度单位度,距离单位 AU。
|
||||||
|
// Returns geocentric J2000 right ascension, declination, and distance. Angles are in degrees and distance is in AU.
|
||||||
func GeocentricEquatorialJ2000(date time.Time, elements Elements) EquatorialPosition {
|
func GeocentricEquatorialJ2000(date time.Time, elements Elements) EquatorialPosition {
|
||||||
ra, dec, distance := basic.OrbitGeocentricEquatorialJ2000(ttJulianDay(date), toBasicElements(elements))
|
ra, dec, distance := basic.OrbitGeocentricEquatorialJ2000(ttJulianDay(date), toBasicElements(elements))
|
||||||
return EquatorialPosition{RA: ra, Dec: dec, Distance: distance}
|
return EquatorialPosition{RA: ra, Dec: dec, Distance: distance}
|
||||||
@@ -116,6 +134,7 @@ func GeocentricEquatorialJ2000(date time.Time, elements Elements) EquatorialPosi
|
|||||||
// GeocentricEquatorial 地心历元平赤道坐标 / geocentric equatorial coordinates of date.
|
// GeocentricEquatorial 地心历元平赤道坐标 / geocentric equatorial coordinates of date.
|
||||||
//
|
//
|
||||||
// 返回历元赤经、赤纬和距离;角度单位度,距离单位 AU。
|
// 返回历元赤经、赤纬和距离;角度单位度,距离单位 AU。
|
||||||
|
// Returns geocentric right ascension, declination, and distance of date. Angles are in degrees and distance is in AU.
|
||||||
func GeocentricEquatorial(date time.Time, elements Elements) EquatorialPosition {
|
func GeocentricEquatorial(date time.Time, elements Elements) EquatorialPosition {
|
||||||
ra, dec, distance := basic.OrbitGeocentricEquatorial(ttJulianDay(date), toBasicElements(elements))
|
ra, dec, distance := basic.OrbitGeocentricEquatorial(ttJulianDay(date), toBasicElements(elements))
|
||||||
return EquatorialPosition{RA: ra, Dec: dec, Distance: distance}
|
return EquatorialPosition{RA: ra, Dec: dec, Distance: distance}
|
||||||
@@ -124,6 +143,7 @@ func GeocentricEquatorial(date time.Time, elements Elements) EquatorialPosition
|
|||||||
// AstrometricGeocentricEquatorialJ2000 地心测算 J2000 赤道坐标 / astrometric geocentric J2000 equatorial coordinates.
|
// AstrometricGeocentricEquatorialJ2000 地心测算 J2000 赤道坐标 / astrometric geocentric J2000 equatorial coordinates.
|
||||||
//
|
//
|
||||||
// 返回加入光行时修正后的地心 J2000 赤经、赤纬和距离;角度单位度,距离单位 AU。
|
// 返回加入光行时修正后的地心 J2000 赤经、赤纬和距离;角度单位度,距离单位 AU。
|
||||||
|
// Returns astrometric geocentric J2000 right ascension, declination, and distance after light-time correction. Angles are in degrees and distance is in AU.
|
||||||
func AstrometricGeocentricEquatorialJ2000(date time.Time, elements Elements) EquatorialPosition {
|
func AstrometricGeocentricEquatorialJ2000(date time.Time, elements Elements) EquatorialPosition {
|
||||||
ra, dec, distance := basic.OrbitAstrometricGeocentricEquatorialJ2000(ttJulianDay(date), toBasicElements(elements))
|
ra, dec, distance := basic.OrbitAstrometricGeocentricEquatorialJ2000(ttJulianDay(date), toBasicElements(elements))
|
||||||
return EquatorialPosition{RA: ra, Dec: dec, Distance: distance}
|
return EquatorialPosition{RA: ra, Dec: dec, Distance: distance}
|
||||||
@@ -132,6 +152,7 @@ func AstrometricGeocentricEquatorialJ2000(date time.Time, elements Elements) Equ
|
|||||||
// ApparentGeocentricEcliptic 地心视黄道坐标 / apparent geocentric ecliptic coordinates.
|
// ApparentGeocentricEcliptic 地心视黄道坐标 / apparent geocentric ecliptic coordinates.
|
||||||
//
|
//
|
||||||
// 返回加入光行时与章动修正后的地心视黄经、黄纬和距离;角度单位度,距离单位 AU。
|
// 返回加入光行时与章动修正后的地心视黄经、黄纬和距离;角度单位度,距离单位 AU。
|
||||||
|
// Returns apparent geocentric ecliptic longitude, latitude, and distance after light-time and nutation corrections. Angles are in degrees and distance is in AU.
|
||||||
func ApparentGeocentricEcliptic(date time.Time, elements Elements) EclipticPosition {
|
func ApparentGeocentricEcliptic(date time.Time, elements Elements) EclipticPosition {
|
||||||
lon, lat, distance := basic.OrbitApparentGeocentricEcliptic(ttJulianDay(date), toBasicElements(elements))
|
lon, lat, distance := basic.OrbitApparentGeocentricEcliptic(ttJulianDay(date), toBasicElements(elements))
|
||||||
return EclipticPosition{Lon: lon, Lat: lat, Distance: distance}
|
return EclipticPosition{Lon: lon, Lat: lat, Distance: distance}
|
||||||
@@ -140,6 +161,7 @@ func ApparentGeocentricEcliptic(date time.Time, elements Elements) EclipticPosit
|
|||||||
// ApparentGeocentricEquatorial 地心视赤道坐标 / apparent geocentric equatorial coordinates.
|
// ApparentGeocentricEquatorial 地心视赤道坐标 / apparent geocentric equatorial coordinates.
|
||||||
//
|
//
|
||||||
// 返回加入光行时与章动修正后的地心视赤经、赤纬和距离;角度单位度,距离单位 AU。
|
// 返回加入光行时与章动修正后的地心视赤经、赤纬和距离;角度单位度,距离单位 AU。
|
||||||
|
// Returns apparent geocentric right ascension, declination, and distance after light-time and nutation corrections. Angles are in degrees and distance is in AU.
|
||||||
func ApparentGeocentricEquatorial(date time.Time, elements Elements) EquatorialPosition {
|
func ApparentGeocentricEquatorial(date time.Time, elements Elements) EquatorialPosition {
|
||||||
ra, dec, distance := basic.OrbitApparentGeocentricEquatorial(ttJulianDay(date), toBasicElements(elements))
|
ra, dec, distance := basic.OrbitApparentGeocentricEquatorial(ttJulianDay(date), toBasicElements(elements))
|
||||||
return EquatorialPosition{RA: ra, Dec: dec, Distance: distance}
|
return EquatorialPosition{RA: ra, Dec: dec, Distance: distance}
|
||||||
@@ -149,6 +171,7 @@ func ApparentGeocentricEquatorial(date time.Time, elements Elements) EquatorialP
|
|||||||
//
|
//
|
||||||
// 返回加入光行时、章动和站心修正后的视赤经、赤纬和距离;
|
// 返回加入光行时、章动和站心修正后的视赤经、赤纬和距离;
|
||||||
// `observerLon` 东经为正,`observerLat` 北纬为正,`observerHeight` 单位米。
|
// `observerLon` 东经为正,`observerLat` 北纬为正,`observerHeight` 单位米。
|
||||||
|
// Returns apparent topocentric right ascension, declination, and distance after light-time, nutation, and topocentric corrections.
|
||||||
func ApparentTopocentricEquatorial(date time.Time, elements Elements, observerLon, observerLat, observerHeight float64) EquatorialPosition {
|
func ApparentTopocentricEquatorial(date time.Time, elements Elements, observerLon, observerLat, observerHeight float64) EquatorialPosition {
|
||||||
ra, dec, distance := basic.OrbitApparentTopocentricEquatorial(ttJulianDay(date), observerLon, observerLat, observerHeight, toBasicElements(elements))
|
ra, dec, distance := basic.OrbitApparentTopocentricEquatorial(ttJulianDay(date), observerLon, observerLat, observerHeight, toBasicElements(elements))
|
||||||
return EquatorialPosition{RA: ra, Dec: dec, Distance: distance}
|
return EquatorialPosition{RA: ra, Dec: dec, Distance: distance}
|
||||||
@@ -157,6 +180,7 @@ func ApparentTopocentricEquatorial(date time.Time, elements Elements, observerLo
|
|||||||
// Altitude 视高度角 / apparent altitude.
|
// Altitude 视高度角 / apparent altitude.
|
||||||
//
|
//
|
||||||
// 返回目标在观测者所在地的视高度角,单位度;经度东正西负,纬度北正南负,海拔单位米。
|
// 返回目标在观测者所在地的视高度角,单位度;经度东正西负,纬度北正南负,海拔单位米。
|
||||||
|
// Returns the apparent altitude of the target for the observing site, in degrees. Longitude is east-positive, latitude is north-positive, and height is in meters.
|
||||||
func Altitude(date time.Time, elements Elements, observerLon, observerLat, observerHeight float64) float64 {
|
func Altitude(date time.Time, elements Elements, observerLon, observerLat, observerHeight float64) float64 {
|
||||||
jde := basic.Date2JDE(date)
|
jde := basic.Date2JDE(date)
|
||||||
return basic.OrbitHeight(jde, observerLon, observerLat, observationTimezone(date), observerHeight, toBasicElements(elements))
|
return basic.OrbitHeight(jde, observerLon, observerLat, observationTimezone(date), observerHeight, toBasicElements(elements))
|
||||||
@@ -165,6 +189,7 @@ func Altitude(date time.Time, elements Elements, observerLon, observerLat, obser
|
|||||||
// Zenith 天顶距 / zenith distance.
|
// Zenith 天顶距 / zenith distance.
|
||||||
//
|
//
|
||||||
// 返回目标在观测者所在地的天顶距,单位度。
|
// 返回目标在观测者所在地的天顶距,单位度。
|
||||||
|
// Returns the zenith distance of the target for the observing site, in degrees.
|
||||||
func Zenith(date time.Time, elements Elements, observerLon, observerLat, observerHeight float64) float64 {
|
func Zenith(date time.Time, elements Elements, observerLon, observerLat, observerHeight float64) float64 {
|
||||||
return 90 - Altitude(date, elements, observerLon, observerLat, observerHeight)
|
return 90 - Altitude(date, elements, observerLon, observerLat, observerHeight)
|
||||||
}
|
}
|
||||||
@@ -172,6 +197,7 @@ func Zenith(date time.Time, elements Elements, observerLon, observerLat, observe
|
|||||||
// Azimuth 视方位角 / apparent azimuth.
|
// Azimuth 视方位角 / apparent azimuth.
|
||||||
//
|
//
|
||||||
// 返回目标在观测者所在地的视方位角,按正北为 0°、向东增加。
|
// 返回目标在观测者所在地的视方位角,按正北为 0°、向东增加。
|
||||||
|
// Returns the apparent azimuth of the target for the observing site, measured from north toward east.
|
||||||
func Azimuth(date time.Time, elements Elements, observerLon, observerLat, observerHeight float64) float64 {
|
func Azimuth(date time.Time, elements Elements, observerLon, observerLat, observerHeight float64) float64 {
|
||||||
jde := basic.Date2JDE(date)
|
jde := basic.Date2JDE(date)
|
||||||
return basic.OrbitAzimuth(jde, observerLon, observerLat, observationTimezone(date), observerHeight, toBasicElements(elements))
|
return basic.OrbitAzimuth(jde, observerLon, observerLat, observationTimezone(date), observerHeight, toBasicElements(elements))
|
||||||
@@ -180,6 +206,7 @@ func Azimuth(date time.Time, elements Elements, observerLon, observerLat, observ
|
|||||||
// HourAngle 站心视时角 / topocentric hour angle.
|
// HourAngle 站心视时角 / topocentric hour angle.
|
||||||
//
|
//
|
||||||
// 返回目标在观测者所在地的站心视时角,单位度。
|
// 返回目标在观测者所在地的站心视时角,单位度。
|
||||||
|
// Returns the apparent topocentric hour angle of the target for the observing site, in degrees.
|
||||||
func HourAngle(date time.Time, elements Elements, observerLon, observerLat, observerHeight float64) float64 {
|
func HourAngle(date time.Time, elements Elements, observerLon, observerLat, observerHeight float64) float64 {
|
||||||
jde := basic.Date2JDE(date)
|
jde := basic.Date2JDE(date)
|
||||||
return basic.OrbitHourAngle(jde, observerLon, observerLat, observationTimezone(date), observerHeight, toBasicElements(elements))
|
return basic.OrbitHourAngle(jde, observerLon, observerLat, observationTimezone(date), observerHeight, toBasicElements(elements))
|
||||||
@@ -188,6 +215,7 @@ func HourAngle(date time.Time, elements Elements, observerLon, observerLat, obse
|
|||||||
// CulminationTime 中天时刻 / culmination time.
|
// CulminationTime 中天时刻 / culmination time.
|
||||||
//
|
//
|
||||||
// 返回目标在给定当地日期内的中天时刻,结果保持输入 `date` 的时区。
|
// 返回目标在给定当地日期内的中天时刻,结果保持输入 `date` 的时区。
|
||||||
|
// Returns the culmination time of the target on the supplied local civil day. The result keeps the timezone of `date`.
|
||||||
func CulminationTime(date time.Time, elements Elements, observerLon, observerLat, observerHeight float64) time.Time {
|
func CulminationTime(date time.Time, elements Elements, observerLon, observerLat, observerHeight float64) time.Time {
|
||||||
if date.Hour() > 12 {
|
if date.Hour() > 12 {
|
||||||
date = date.Add(-12 * time.Hour)
|
date = date.Add(-12 * time.Hour)
|
||||||
@@ -201,6 +229,7 @@ func CulminationTime(date time.Time, elements Elements, observerLon, observerLat
|
|||||||
// RiseTime 升起时刻 / rise time.
|
// RiseTime 升起时刻 / rise time.
|
||||||
//
|
//
|
||||||
// 返回目标在给定当地日期内的升起时刻;`aero=true` 时加入标准大气折射修正。
|
// 返回目标在给定当地日期内的升起时刻;`aero=true` 时加入标准大气折射修正。
|
||||||
|
// Returns the rise time of the target on the supplied local civil day. When `aero` is true, standard atmospheric refraction is included.
|
||||||
func RiseTime(date time.Time, elements Elements, observerLon, observerLat, observerHeight float64, aero bool) (time.Time, error) {
|
func RiseTime(date time.Time, elements Elements, observerLon, observerLat, observerHeight float64, aero bool) (time.Time, error) {
|
||||||
var aeroFloat float64
|
var aeroFloat float64
|
||||||
if aero {
|
if aero {
|
||||||
@@ -218,6 +247,7 @@ func RiseTime(date time.Time, elements Elements, observerLon, observerLat, obser
|
|||||||
// SetTime 落下时刻 / set time.
|
// SetTime 落下时刻 / set time.
|
||||||
//
|
//
|
||||||
// 返回目标在给定当地日期内的落下时刻;`aero=true` 时加入标准大气折射修正。
|
// 返回目标在给定当地日期内的落下时刻;`aero=true` 时加入标准大气折射修正。
|
||||||
|
// Returns the set time of the target on the supplied local civil day. When `aero` is true, standard atmospheric refraction is included.
|
||||||
func SetTime(date time.Time, elements Elements, observerLon, observerLat, observerHeight float64, aero bool) (time.Time, error) {
|
func SetTime(date time.Time, elements Elements, observerLon, observerLat, observerHeight float64, aero bool) (time.Time, error) {
|
||||||
var aeroFloat float64
|
var aeroFloat float64
|
||||||
if aero {
|
if aero {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
// ParallacticAngle 轨道目标视差角(天顶方向角) / orbit-target parallactic angle.
|
// ParallacticAngle 轨道目标视差角(天顶方向角) / orbit-target parallactic angle.
|
||||||
//
|
//
|
||||||
// 返回轨道目标在观测者所在地的视差角,单位度;`observerLon` 东经为正,`observerLat` 北纬为正,`observerHeight` 单位米。
|
// 返回轨道目标在观测者所在地的视差角,单位度;`observerLon` 东经为正,`observerLat` 北纬为正,`observerHeight` 单位米。
|
||||||
|
// Returns the parallactic angle of the orbital target for the observing site, in degrees. `observerLon` is east-positive, `observerLat` is north-positive, and `observerHeight` is in meters.
|
||||||
func ParallacticAngle(date time.Time, elements Elements, observerLon, observerLat, observerHeight float64) float64 {
|
func ParallacticAngle(date time.Time, elements Elements, observerLon, observerLat, observerHeight float64) float64 {
|
||||||
position := ApparentTopocentricEquatorial(date, elements, observerLon, observerLat, observerHeight)
|
position := ApparentTopocentricEquatorial(date, elements, observerLon, observerLat, observerHeight)
|
||||||
return basic.ParallacticAngleByHourAngle(
|
return basic.ParallacticAngleByHourAngle(
|
||||||
|
|||||||
@@ -8,7 +8,10 @@ import (
|
|||||||
const visualBinaryDeg = 180 / math.Pi
|
const visualBinaryDeg = 180 / math.Pi
|
||||||
const visualBinaryRad = math.Pi / 180
|
const visualBinaryRad = math.Pi / 180
|
||||||
|
|
||||||
// VisualBinaryElements 视双星轨道要素,采用《天文算法》第 55 章的经典口径。
|
// VisualBinaryElements 视双星轨道要素 / visual-binary orbital elements.
|
||||||
|
//
|
||||||
|
// 采用《天文算法》第 55 章的经典口径。
|
||||||
|
// Uses the classical convention described in Chapter 55 of Astronomical Algorithms.
|
||||||
type VisualBinaryElements struct {
|
type VisualBinaryElements struct {
|
||||||
PeriodYears float64 // 周期 P,单位平太阳年 / orbital period in mean solar years.
|
PeriodYears float64 // 周期 P,单位平太阳年 / orbital period in mean solar years.
|
||||||
PeriastronYear float64 // 过近星点时刻 T,采用带小数的年 / epoch of periastron as a decimal year.
|
PeriastronYear float64 // 过近星点时刻 T,采用带小数的年 / epoch of periastron as a decimal year.
|
||||||
@@ -19,7 +22,7 @@ type VisualBinaryElements struct {
|
|||||||
PeriastronArgument float64 // 近星点角距 ω,单位度 / argument of periastron in degrees.
|
PeriastronArgument float64 // 近星点角距 ω,单位度 / argument of periastron in degrees.
|
||||||
}
|
}
|
||||||
|
|
||||||
// VisualBinaryPosition 视双星在天球上的计算结果。
|
// VisualBinaryPosition 视双星在天球上的计算结果 / computed sky-plane position of a visual binary.
|
||||||
type VisualBinaryPosition struct {
|
type VisualBinaryPosition struct {
|
||||||
Year float64 // 计算使用的小数年 / decimal year used for the evaluation.
|
Year float64 // 计算使用的小数年 / decimal year used for the evaluation.
|
||||||
MeanAnomaly float64 // 平近点角 M,单位度 / mean anomaly in degrees.
|
MeanAnomaly float64 // 平近点角 M,单位度 / mean anomaly in degrees.
|
||||||
@@ -41,6 +44,7 @@ func VisualBinary(date time.Time, elements VisualBinaryElements) VisualBinaryPos
|
|||||||
// VisualBinaryByYear 视双星位置(按小数年) / visual binary position by decimal year.
|
// VisualBinaryByYear 视双星位置(按小数年) / visual binary position by decimal year.
|
||||||
//
|
//
|
||||||
// 返回给定小数年对应的视双星位置角和角距离。
|
// 返回给定小数年对应的视双星位置角和角距离。
|
||||||
|
// Returns the position angle and apparent separation for the supplied decimal year.
|
||||||
func VisualBinaryByYear(year float64, elements VisualBinaryElements) VisualBinaryPosition {
|
func VisualBinaryByYear(year float64, elements VisualBinaryElements) VisualBinaryPosition {
|
||||||
if !validVisualBinaryElements(year, elements) {
|
if !validVisualBinaryElements(year, elements) {
|
||||||
return invalidVisualBinaryPosition(year)
|
return invalidVisualBinaryPosition(year)
|
||||||
|
|||||||
@@ -208,6 +208,7 @@ func SetTime(date time.Time, lon, lat, height float64, aero bool) (time.Time, er
|
|||||||
// LastConjunction 上一次合日 / previous conjunction with the Sun.
|
// LastConjunction 上一次合日 / previous conjunction with the Sun.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之前最近一次与太阳的合日时刻,结果保持 date 的时区。
|
// 返回 date 当前或之前最近一次与太阳的合日时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest conjunction with the Sun at or before date, keeping date's time zone.
|
||||||
func LastConjunction(date time.Time) time.Time {
|
func LastConjunction(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.LastSaturnConjunction(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.LastSaturnConjunction(jde), date.Location(), false)
|
||||||
@@ -216,6 +217,7 @@ func LastConjunction(date time.Time) time.Time {
|
|||||||
// NextConjunction 下一次合日 / next conjunction with the Sun.
|
// NextConjunction 下一次合日 / next conjunction with the Sun.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之后最近一次与太阳的合日时刻,结果保持 date 的时区。
|
// 返回 date 当前或之后最近一次与太阳的合日时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest conjunction with the Sun at or after date, keeping date's time zone.
|
||||||
func NextConjunction(date time.Time) time.Time {
|
func NextConjunction(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.NextSaturnConjunction(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.NextSaturnConjunction(jde), date.Location(), false)
|
||||||
@@ -224,6 +226,7 @@ func NextConjunction(date time.Time) time.Time {
|
|||||||
// LastOpposition 上一次冲日 / previous opposition.
|
// LastOpposition 上一次冲日 / previous opposition.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之前最近一次冲日时刻,结果保持 date 的时区。
|
// 返回 date 当前或之前最近一次冲日时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest opposition at or before date, keeping date's time zone.
|
||||||
func LastOpposition(date time.Time) time.Time {
|
func LastOpposition(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.LastSaturnOpposition(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.LastSaturnOpposition(jde), date.Location(), false)
|
||||||
@@ -232,6 +235,7 @@ func LastOpposition(date time.Time) time.Time {
|
|||||||
// NextOpposition 下一次冲日 / next opposition.
|
// NextOpposition 下一次冲日 / next opposition.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之后最近一次冲日时刻,结果保持 date 的时区。
|
// 返回 date 当前或之后最近一次冲日时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest opposition at or after date, keeping date's time zone.
|
||||||
func NextOpposition(date time.Time) time.Time {
|
func NextOpposition(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.NextSaturnOpposition(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.NextSaturnOpposition(jde), date.Location(), false)
|
||||||
@@ -240,6 +244,7 @@ func NextOpposition(date time.Time) time.Time {
|
|||||||
// LastProgradeToRetrograde 上一次顺行转逆行留 / previous station from prograde to retrograde.
|
// LastProgradeToRetrograde 上一次顺行转逆行留 / previous station from prograde to retrograde.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之前最近一次由顺行转为逆行的留时刻,结果保持 date 的时区。
|
// 返回 date 当前或之前最近一次由顺行转为逆行的留时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest station at or before date where motion changes from prograde to retrograde, keeping date's time zone.
|
||||||
func LastProgradeToRetrograde(date time.Time) time.Time {
|
func LastProgradeToRetrograde(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.LastSaturnProgradeToRetrograde(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.LastSaturnProgradeToRetrograde(jde), date.Location(), false)
|
||||||
@@ -248,6 +253,7 @@ func LastProgradeToRetrograde(date time.Time) time.Time {
|
|||||||
// NextProgradeToRetrograde 下一次顺行转逆行留 / next station from prograde to retrograde.
|
// NextProgradeToRetrograde 下一次顺行转逆行留 / next station from prograde to retrograde.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之后最近一次由顺行转为逆行的留时刻,结果保持 date 的时区。
|
// 返回 date 当前或之后最近一次由顺行转为逆行的留时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest station at or after date where motion changes from prograde to retrograde, keeping date's time zone.
|
||||||
func NextProgradeToRetrograde(date time.Time) time.Time {
|
func NextProgradeToRetrograde(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.NextSaturnProgradeToRetrograde(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.NextSaturnProgradeToRetrograde(jde), date.Location(), false)
|
||||||
@@ -256,6 +262,7 @@ func NextProgradeToRetrograde(date time.Time) time.Time {
|
|||||||
// LastRetrogradeToPrograde 上一次逆行转顺行留 / previous station from retrograde to prograde.
|
// LastRetrogradeToPrograde 上一次逆行转顺行留 / previous station from retrograde to prograde.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之前最近一次由逆行转为顺行的留时刻,结果保持 date 的时区。
|
// 返回 date 当前或之前最近一次由逆行转为顺行的留时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest station at or before date where motion changes from retrograde to prograde, keeping date's time zone.
|
||||||
func LastRetrogradeToPrograde(date time.Time) time.Time {
|
func LastRetrogradeToPrograde(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.LastSaturnRetrogradeToPrograde(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.LastSaturnRetrogradeToPrograde(jde), date.Location(), false)
|
||||||
@@ -264,6 +271,7 @@ func LastRetrogradeToPrograde(date time.Time) time.Time {
|
|||||||
// NextRetrogradeToPrograde 下一次逆行转顺行留 / next station from retrograde to prograde.
|
// NextRetrogradeToPrograde 下一次逆行转顺行留 / next station from retrograde to prograde.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之后最近一次由逆行转为顺行的留时刻,结果保持 date 的时区。
|
// 返回 date 当前或之后最近一次由逆行转为顺行的留时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest station at or after date where motion changes from retrograde to prograde, keeping date's time zone.
|
||||||
func NextRetrogradeToPrograde(date time.Time) time.Time {
|
func NextRetrogradeToPrograde(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.NextSaturnRetrogradeToPrograde(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.NextSaturnRetrogradeToPrograde(jde), date.Location(), false)
|
||||||
@@ -272,6 +280,7 @@ func NextRetrogradeToPrograde(date time.Time) time.Time {
|
|||||||
// LastEasternQuadrature 上一次东方照 / previous eastern quadrature.
|
// LastEasternQuadrature 上一次东方照 / previous eastern quadrature.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之前最近一次东方照时刻,结果保持 date 的时区。
|
// 返回 date 当前或之前最近一次东方照时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest eastern quadrature at or before date, keeping date's time zone.
|
||||||
func LastEasternQuadrature(date time.Time) time.Time {
|
func LastEasternQuadrature(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.LastSaturnEasternQuadrature(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.LastSaturnEasternQuadrature(jde), date.Location(), false)
|
||||||
@@ -280,6 +289,7 @@ func LastEasternQuadrature(date time.Time) time.Time {
|
|||||||
// NextEasternQuadrature 下一次东方照 / next eastern quadrature.
|
// NextEasternQuadrature 下一次东方照 / next eastern quadrature.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之后最近一次东方照时刻,结果保持 date 的时区。
|
// 返回 date 当前或之后最近一次东方照时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest eastern quadrature at or after date, keeping date's time zone.
|
||||||
func NextEasternQuadrature(date time.Time) time.Time {
|
func NextEasternQuadrature(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.NextSaturnEasternQuadrature(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.NextSaturnEasternQuadrature(jde), date.Location(), false)
|
||||||
@@ -288,6 +298,7 @@ func NextEasternQuadrature(date time.Time) time.Time {
|
|||||||
// LastWesternQuadrature 上一次西方照 / previous western quadrature.
|
// LastWesternQuadrature 上一次西方照 / previous western quadrature.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之前最近一次西方照时刻,结果保持 date 的时区。
|
// 返回 date 当前或之前最近一次西方照时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest western quadrature at or before date, keeping date's time zone.
|
||||||
func LastWesternQuadrature(date time.Time) time.Time {
|
func LastWesternQuadrature(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.LastSaturnWesternQuadrature(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.LastSaturnWesternQuadrature(jde), date.Location(), false)
|
||||||
@@ -296,6 +307,7 @@ func LastWesternQuadrature(date time.Time) time.Time {
|
|||||||
// NextWesternQuadrature 下一次西方照 / next western quadrature.
|
// NextWesternQuadrature 下一次西方照 / next western quadrature.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之后最近一次西方照时刻,结果保持 date 的时区。
|
// 返回 date 当前或之后最近一次西方照时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest western quadrature at or after date, keeping date's time zone.
|
||||||
func NextWesternQuadrature(date time.Time) time.Time {
|
func NextWesternQuadrature(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.NextSaturnWesternQuadrature(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.NextSaturnWesternQuadrature(jde), date.Location(), false)
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ import (
|
|||||||
//
|
//
|
||||||
// ra/dec 为瞬时赤经赤纬,单位度;lon/lat 为观测者经纬度,东正西负、北正南负。
|
// ra/dec 为瞬时赤经赤纬,单位度;lon/lat 为观测者经纬度,东正西负、北正南负。
|
||||||
// 返回值为有符号视差角,单位度。
|
// 返回值为有符号视差角,单位度。
|
||||||
|
// ra/dec are apparent equatorial coordinates in degrees; lon/lat are east-positive and north-positive.
|
||||||
|
// Returns the signed parallactic angle in degrees.
|
||||||
func ParallacticAngle(date time.Time, ra, dec, lon, lat float64) float64 {
|
func ParallacticAngle(date time.Time, ra, dec, lon, lat float64) float64 {
|
||||||
jde := basic.Date2JDE(date)
|
jde := basic.Date2JDE(date)
|
||||||
_, loc := date.Zone()
|
_, loc := date.Zone()
|
||||||
|
|||||||
@@ -100,6 +100,8 @@ func DownTime(date time.Time, lon, lat, height float64, aero bool) (time.Time, e
|
|||||||
|
|
||||||
// DownTimeN 截断项日落时刻别名 / deprecated truncated sunset alias.
|
// DownTimeN 截断项日落时刻别名 / deprecated truncated sunset alias.
|
||||||
//
|
//
|
||||||
|
// Deprecated: use SetTimeN instead.
|
||||||
|
//
|
||||||
// 参数与 SetTimeN 相同,仅为兼容旧接口保留。
|
// 参数与 SetTimeN 相同,仅为兼容旧接口保留。
|
||||||
// Same as SetTimeN and kept only for backward compatibility.
|
// Same as SetTimeN and kept only for backward compatibility.
|
||||||
func DownTimeN(date time.Time, lon, lat, height float64, aero bool, n int) (time.Time, error) {
|
func DownTimeN(date time.Time, lon, lat, height float64, aero bool, n int) (time.Time, error) {
|
||||||
|
|||||||
+43
-1
@@ -15,6 +15,12 @@ import (
|
|||||||
//
|
//
|
||||||
// 坐标系沿本章通用约定:x 轴位于盘面内且保持水平,y 轴沿盘面最大坡度向上,
|
// 坐标系沿本章通用约定:x 轴位于盘面内且保持水平,y 轴沿盘面最大坡度向上,
|
||||||
// x 正向为右侧,y 正向为上坡方向。
|
// x 正向为右侧,y 正向为上坡方向。
|
||||||
|
// Latitude is geographic latitude, north positive. PlaneNormalAzimuth is the azimuth of the dial-plane normal,
|
||||||
|
// measured from north toward east. PlaneNormalZenithDistance is the zenith distance of the plane normal:
|
||||||
|
// 0 degrees for a horizontal dial and 90 degrees for a vertical dial. StylusLength is the length of the direct stylus normal to the plane.
|
||||||
|
//
|
||||||
|
// The plane coordinates follow the chapter convention: the x axis lies in the plane and remains horizontal,
|
||||||
|
// the y axis follows the steepest upward direction in the plane, x positive points to the right, and y positive points upslope.
|
||||||
type PlanarDial struct {
|
type PlanarDial struct {
|
||||||
Latitude float64
|
Latitude float64
|
||||||
PlaneNormalAzimuth float64
|
PlaneNormalAzimuth float64
|
||||||
@@ -27,6 +33,9 @@ type PlanarDial struct {
|
|||||||
// X/Y 为影尖在盘面坐标系中的坐标;DenominatorQ 对应书中公式里的 Q;
|
// X/Y 为影尖在盘面坐标系中的坐标;DenominatorQ 对应书中公式里的 Q;
|
||||||
// SunAboveHorizon 表示太阳在地平线上方;PlaneIlluminated 表示盘面被太阳照亮;
|
// SunAboveHorizon 表示太阳在地平线上方;PlaneIlluminated 表示盘面被太阳照亮;
|
||||||
// Illuminated 为前两者同时满足。
|
// Illuminated 为前两者同时满足。
|
||||||
|
// X/Y are the shadow-tip coordinates in the dial-plane coordinate system. DenominatorQ is the Q term from the book formula.
|
||||||
|
// SunAboveHorizon reports whether the Sun is above the horizon. PlaneIlluminated reports whether sunlight reaches the dial plane.
|
||||||
|
// Illuminated is true only when both conditions are satisfied.
|
||||||
type PlanarShadowPoint struct {
|
type PlanarShadowPoint struct {
|
||||||
X float64
|
X float64
|
||||||
Y float64
|
Y float64
|
||||||
@@ -41,6 +50,9 @@ type PlanarShadowPoint struct {
|
|||||||
// CenterX/CenterY 为日晷中心(极轴晷针固定点)坐标;PolarStylusLength 为极轴晷针长度;
|
// CenterX/CenterY 为日晷中心(极轴晷针固定点)坐标;PolarStylusLength 为极轴晷针长度;
|
||||||
// PolarStylusPlaneAngle 为极轴晷针与盘面的夹角。HasFiniteCenter 为 false 时,
|
// PolarStylusPlaneAngle 为极轴晷针与盘面的夹角。HasFiniteCenter 为 false 时,
|
||||||
// 表示极轴晷针与盘面平行,中心退化到无穷远处。
|
// 表示极轴晷针与盘面平行,中心退化到无穷远处。
|
||||||
|
// CenterX/CenterY are the coordinates of the dial center, where the polar stylus is fixed. PolarStylusLength is the polar-stylus length.
|
||||||
|
// PolarStylusPlaneAngle is the angle between the polar stylus and the dial plane. When HasFiniteCenter is false,
|
||||||
|
// the polar stylus is parallel to the plane and the center degenerates to infinity.
|
||||||
type PlanarGeometry struct {
|
type PlanarGeometry struct {
|
||||||
CenterX float64
|
CenterX float64
|
||||||
CenterY float64
|
CenterY float64
|
||||||
@@ -53,6 +65,8 @@ type PlanarGeometry struct {
|
|||||||
//
|
//
|
||||||
// Start/End 均为有符号太阳时角,单位度,满足 Start <= End。
|
// Start/End 均为有符号太阳时角,单位度,满足 Start <= End。
|
||||||
// 约定取值范围为 [-180, 180],用于表达一天中的一段连续时角。
|
// 约定取值范围为 [-180, 180],用于表达一天中的一段连续时角。
|
||||||
|
// Start and End are signed solar hour angles in degrees, with Start <= End.
|
||||||
|
// The intended range is [-180, 180], representing one continuous hour-angle span within a day.
|
||||||
type HourAngleInterval struct {
|
type HourAngleInterval struct {
|
||||||
Start float64
|
Start float64
|
||||||
End float64
|
End float64
|
||||||
@@ -61,6 +75,7 @@ type HourAngleInterval struct {
|
|||||||
// DeclinationCurveSample 赤纬曲线采样点 / sampled point on a declination curve.
|
// DeclinationCurveSample 赤纬曲线采样点 / sampled point on a declination curve.
|
||||||
//
|
//
|
||||||
// HourAngle 为采样点的太阳时角;Point 为该时角下的影尖位置与照明状态。
|
// HourAngle 为采样点的太阳时角;Point 为该时角下的影尖位置与照明状态。
|
||||||
|
// HourAngle is the solar hour angle of the sample. Point gives the shadow-tip position and illumination state at that hour angle.
|
||||||
type DeclinationCurveSample struct {
|
type DeclinationCurveSample struct {
|
||||||
HourAngle float64
|
HourAngle float64
|
||||||
Point PlanarShadowPoint
|
Point PlanarShadowPoint
|
||||||
@@ -69,6 +84,7 @@ type DeclinationCurveSample struct {
|
|||||||
// DeclinationCurveSegment 赤纬曲线分段 / one illuminated segment of a declination curve.
|
// DeclinationCurveSegment 赤纬曲线分段 / one illuminated segment of a declination curve.
|
||||||
//
|
//
|
||||||
// Interval 给出该段对应的连续受光时角范围;Samples 为该段内部的采样点。
|
// Interval 给出该段对应的连续受光时角范围;Samples 为该段内部的采样点。
|
||||||
|
// Interval gives the continuous illuminated hour-angle span for the segment. Samples contains the sampled points within that segment.
|
||||||
type DeclinationCurveSegment struct {
|
type DeclinationCurveSegment struct {
|
||||||
Declination float64
|
Declination float64
|
||||||
Interval HourAngleInterval
|
Interval HourAngleInterval
|
||||||
@@ -80,6 +96,9 @@ type DeclinationCurveSegment struct {
|
|||||||
// Date 为该采样点对应的绝对时刻;其日期来自输入 date,钟面时间由调用参数指定。
|
// Date 为该采样点对应的绝对时刻;其日期来自输入 date,钟面时间由调用参数指定。
|
||||||
// Declination 为该采样瞬时的太阳赤纬;HourAngle 为换算后的视太阳时角;
|
// Declination 为该采样瞬时的太阳赤纬;HourAngle 为换算后的视太阳时角;
|
||||||
// Point 为该时角下的影尖位置与照明状态。
|
// Point 为该时角下的影尖位置与照明状态。
|
||||||
|
// Date is the absolute instant of the sample. Its date comes from the input date, while the clock reading comes from the call parameters.
|
||||||
|
// Declination is the solar declination at that instant. HourAngle is the derived apparent-solar hour angle.
|
||||||
|
// Point gives the shadow-tip position and illumination state at that hour angle.
|
||||||
type TimeLineSample struct {
|
type TimeLineSample struct {
|
||||||
Date time.Time
|
Date time.Time
|
||||||
Declination float64
|
Declination float64
|
||||||
@@ -90,6 +109,7 @@ type TimeLineSample struct {
|
|||||||
// EquatorialNorthDial 北面赤道日晷 / north-face equatorial dial.
|
// EquatorialNorthDial 北面赤道日晷 / north-face equatorial dial.
|
||||||
//
|
//
|
||||||
// 北半球时用于春夏半年(太阳赤纬为正);南半球也可直接按公式使用。
|
// 北半球时用于春夏半年(太阳赤纬为正);南半球也可直接按公式使用。
|
||||||
|
// In the northern hemisphere this face is used during the spring and summer half-year, when solar declination is positive. The same formula can also be used directly in the southern hemisphere.
|
||||||
func EquatorialNorthDial(latitude, stylusLength float64) PlanarDial {
|
func EquatorialNorthDial(latitude, stylusLength float64) PlanarDial {
|
||||||
return PlanarDial{
|
return PlanarDial{
|
||||||
Latitude: latitude,
|
Latitude: latitude,
|
||||||
@@ -102,6 +122,7 @@ func EquatorialNorthDial(latitude, stylusLength float64) PlanarDial {
|
|||||||
// EquatorialSouthDial 南面赤道日晷 / south-face equatorial dial.
|
// EquatorialSouthDial 南面赤道日晷 / south-face equatorial dial.
|
||||||
//
|
//
|
||||||
// 北半球时用于秋冬半年(太阳赤纬为负);南半球也可直接按公式使用。
|
// 北半球时用于秋冬半年(太阳赤纬为负);南半球也可直接按公式使用。
|
||||||
|
// In the northern hemisphere this face is used during the autumn and winter half-year, when solar declination is negative. The same formula can also be used directly in the southern hemisphere.
|
||||||
func EquatorialSouthDial(latitude, stylusLength float64) PlanarDial {
|
func EquatorialSouthDial(latitude, stylusLength float64) PlanarDial {
|
||||||
return PlanarDial{
|
return PlanarDial{
|
||||||
Latitude: latitude,
|
Latitude: latitude,
|
||||||
@@ -114,6 +135,7 @@ func EquatorialSouthDial(latitude, stylusLength float64) PlanarDial {
|
|||||||
// HorizontalDial 水平日晷 / horizontal dial.
|
// HorizontalDial 水平日晷 / horizontal dial.
|
||||||
//
|
//
|
||||||
// 该构造器采用经典水平日晷的坐标约定:x 轴向东,y 轴向北。
|
// 该构造器采用经典水平日晷的坐标约定:x 轴向东,y 轴向北。
|
||||||
|
// This constructor follows the classical horizontal-dial coordinate convention: the x axis points east and the y axis points north.
|
||||||
func HorizontalDial(latitude, stylusLength float64) PlanarDial {
|
func HorizontalDial(latitude, stylusLength float64) PlanarDial {
|
||||||
return PlanarDial{
|
return PlanarDial{
|
||||||
Latitude: latitude,
|
Latitude: latitude,
|
||||||
@@ -127,6 +149,8 @@ func HorizontalDial(latitude, stylusLength float64) PlanarDial {
|
|||||||
//
|
//
|
||||||
// planeNormalAzimuth 为盘面法线方位角,按正北为 0°、向东增加。
|
// planeNormalAzimuth 为盘面法线方位角,按正北为 0°、向东增加。
|
||||||
// 例如:朝南墙面取 180°,朝东墙面取 90°。
|
// 例如:朝南墙面取 180°,朝东墙面取 90°。
|
||||||
|
// planeNormalAzimuth is the azimuth of the plane normal, measured from north toward east.
|
||||||
|
// For example, use 180 degrees for a south-facing wall and 90 degrees for an east-facing wall.
|
||||||
func VerticalDial(latitude, planeNormalAzimuth, stylusLength float64) PlanarDial {
|
func VerticalDial(latitude, planeNormalAzimuth, stylusLength float64) PlanarDial {
|
||||||
return PlanarDial{
|
return PlanarDial{
|
||||||
Latitude: latitude,
|
Latitude: latitude,
|
||||||
@@ -136,7 +160,10 @@ func VerticalDial(latitude, planeNormalAzimuth, stylusLength float64) PlanarDial
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Geometry 返回平面日晷的中心与极轴晷针几何量 / returns the derived planar geometry.
|
// Geometry 平面日晷中心与极轴晷针几何量 / derived planar-dial center and polar-stylus geometry.
|
||||||
|
//
|
||||||
|
// 返回平面日晷的中心与极轴晷针几何量。
|
||||||
|
// Returns the derived center and polar-stylus geometry of the planar dial.
|
||||||
func (dial PlanarDial) Geometry() PlanarGeometry {
|
func (dial PlanarDial) Geometry() PlanarGeometry {
|
||||||
geometry := PlanarGeometry{
|
geometry := PlanarGeometry{
|
||||||
CenterX: math.NaN(),
|
CenterX: math.NaN(),
|
||||||
@@ -167,6 +194,7 @@ func (dial PlanarDial) Geometry() PlanarGeometry {
|
|||||||
// ShadowPointByHourAngleDeclination 影尖坐标(按时角与赤纬) / shadow point from hour angle and declination.
|
// ShadowPointByHourAngleDeclination 影尖坐标(按时角与赤纬) / shadow point from hour angle and declination.
|
||||||
//
|
//
|
||||||
// hourAngle 为有符号太阳时角,上午为负,下午为正;declination 为太阳赤纬,单位度。
|
// hourAngle 为有符号太阳时角,上午为负,下午为正;declination 为太阳赤纬,单位度。
|
||||||
|
// hourAngle is the signed solar hour angle, negative in the morning and positive in the afternoon. declination is solar declination in degrees.
|
||||||
func (dial PlanarDial) ShadowPointByHourAngleDeclination(hourAngle, declination float64) PlanarShadowPoint {
|
func (dial PlanarDial) ShadowPointByHourAngleDeclination(hourAngle, declination float64) PlanarShadowPoint {
|
||||||
point := PlanarShadowPoint{
|
point := PlanarShadowPoint{
|
||||||
X: math.NaN(),
|
X: math.NaN(),
|
||||||
@@ -194,6 +222,7 @@ func (dial PlanarDial) ShadowPointByHourAngleDeclination(hourAngle, declination
|
|||||||
// ShadowPointAt 影尖坐标(按绝对时刻) / shadow point at an instant.
|
// ShadowPointAt 影尖坐标(按绝对时刻) / shadow point at an instant.
|
||||||
//
|
//
|
||||||
// 直接读取该时刻对应的视太阳时角和瞬时太阳赤纬,并返回平面日晷上的影尖位置。
|
// 直接读取该时刻对应的视太阳时角和瞬时太阳赤纬,并返回平面日晷上的影尖位置。
|
||||||
|
// Uses the apparent-solar hour angle and instantaneous solar declination at the supplied instant, and returns the shadow-tip position on the planar dial.
|
||||||
func (dial PlanarDial) ShadowPointAt(date time.Time, lon float64) PlanarShadowPoint {
|
func (dial PlanarDial) ShadowPointAt(date time.Time, lon float64) PlanarShadowPoint {
|
||||||
return dial.ShadowPointByHourAngleDeclination(HourAngle(date, lon), sun.ApparentDec(date))
|
return dial.ShadowPointByHourAngleDeclination(HourAngle(date, lon), sun.ApparentDec(date))
|
||||||
}
|
}
|
||||||
@@ -202,6 +231,8 @@ func (dial PlanarDial) ShadowPointAt(date time.Time, lon float64) PlanarShadowPo
|
|||||||
//
|
//
|
||||||
// date 应处于目标地点的地方平太阳时区,例如 `MeanSolarTime` 的返回值;其原有钟面时间会被忽略。
|
// date 应处于目标地点的地方平太阳时区,例如 `MeanSolarTime` 的返回值;其原有钟面时间会被忽略。
|
||||||
// meanSolarHours 为地方平太阳时钟面读数,单位小时,例如 9.5 表示 09:30。
|
// meanSolarHours 为地方平太阳时钟面读数,单位小时,例如 9.5 表示 09:30。
|
||||||
|
// date should already be expressed in the local mean-solar timezone of the site, for example a value returned by `MeanSolarTime`; its original clock fields are ignored.
|
||||||
|
// meanSolarHours is the local mean-solar clock reading in hours, for example 9.5 for 09:30.
|
||||||
func (dial PlanarDial) MeanSolarTimePoint(date time.Time, meanSolarHours float64) PlanarShadowPoint {
|
func (dial PlanarDial) MeanSolarTimePoint(date time.Time, meanSolarHours float64) PlanarShadowPoint {
|
||||||
sampleTime := dateWithClockHours(date, meanSolarHours)
|
sampleTime := dateWithClockHours(date, meanSolarHours)
|
||||||
declination := sun.ApparentDec(sampleTime)
|
declination := sun.ApparentDec(sampleTime)
|
||||||
@@ -211,6 +242,7 @@ func (dial PlanarDial) MeanSolarTimePoint(date time.Time, meanSolarHours float64
|
|||||||
// ZoneTimePoint 区时影尖位置 / shadow point for zone time.
|
// ZoneTimePoint 区时影尖位置 / shadow point for zone time.
|
||||||
//
|
//
|
||||||
// date 提供民用日期和时区,原有钟面时间会被忽略;zoneTimeHours 为该时区下的区时钟面读数。
|
// date 提供民用日期和时区,原有钟面时间会被忽略;zoneTimeHours 为该时区下的区时钟面读数。
|
||||||
|
// date provides the civil date and timezone; its original clock fields are ignored. zoneTimeHours is the civil clock reading in that timezone.
|
||||||
func (dial PlanarDial) ZoneTimePoint(date time.Time, lon, zoneTimeHours float64) PlanarShadowPoint {
|
func (dial PlanarDial) ZoneTimePoint(date time.Time, lon, zoneTimeHours float64) PlanarShadowPoint {
|
||||||
sampleTime := dateWithClockHours(date, zoneTimeHours)
|
sampleTime := dateWithClockHours(date, zoneTimeHours)
|
||||||
declination := sun.ApparentDec(sampleTime)
|
declination := sun.ApparentDec(sampleTime)
|
||||||
@@ -221,6 +253,8 @@ func (dial PlanarDial) ZoneTimePoint(date time.Time, lon, zoneTimeHours float64)
|
|||||||
//
|
//
|
||||||
// dates 由调用者自行决定取样日期密度,例如每月或每日;每个 date 都应处于目标地点的地方平太阳时区,
|
// dates 由调用者自行决定取样日期密度,例如每月或每日;每个 date 都应处于目标地点的地方平太阳时区,
|
||||||
// 例如先通过 `MeanSolarTime` 得到对应地点的地方平太阳时再取其年月日。meanSolarHours 为地方平太阳时钟面读数。
|
// 例如先通过 `MeanSolarTime` 得到对应地点的地方平太阳时再取其年月日。meanSolarHours 为地方平太阳时钟面读数。
|
||||||
|
// dates define the sampling cadence, for example monthly or daily. Each date should already be in the site's local mean-solar timezone,
|
||||||
|
// for example by first calling `MeanSolarTime` and then keeping its year, month, and day. meanSolarHours is the local mean-solar clock reading.
|
||||||
func (dial PlanarDial) MeanSolarTimeLine(dates []time.Time, meanSolarHours float64) []TimeLineSample {
|
func (dial PlanarDial) MeanSolarTimeLine(dates []time.Time, meanSolarHours float64) []TimeLineSample {
|
||||||
if !isFinite(meanSolarHours) {
|
if !isFinite(meanSolarHours) {
|
||||||
return nil
|
return nil
|
||||||
@@ -244,6 +278,8 @@ func (dial PlanarDial) MeanSolarTimeLine(dates []time.Time, meanSolarHours float
|
|||||||
//
|
//
|
||||||
// dates 由调用者自行决定取样日期密度;zoneTimeHours 为 date 所在时区的区时钟面读数。
|
// dates 由调用者自行决定取样日期密度;zoneTimeHours 为 date 所在时区的区时钟面读数。
|
||||||
// 每个 date 的原有钟面时间都会被 zoneTimeHours 替换。
|
// 每个 date 的原有钟面时间都会被 zoneTimeHours 替换。
|
||||||
|
// dates define the sampling cadence. zoneTimeHours is the civil clock reading in the timezone carried by each date.
|
||||||
|
// The original clock fields of every date are replaced by zoneTimeHours.
|
||||||
func (dial PlanarDial) ZoneTimeLine(dates []time.Time, lon, zoneTimeHours float64) []TimeLineSample {
|
func (dial PlanarDial) ZoneTimeLine(dates []time.Time, lon, zoneTimeHours float64) []TimeLineSample {
|
||||||
if !isFinite(zoneTimeHours) || !isFinite(lon) {
|
if !isFinite(zoneTimeHours) || !isFinite(lon) {
|
||||||
return nil
|
return nil
|
||||||
@@ -266,6 +302,7 @@ func (dial PlanarDial) ZoneTimeLine(dates []time.Time, lon, zoneTimeHours float6
|
|||||||
// PlaneIlluminatedHourAngleIntervals 盘面受光时角区间 / plane-illuminated hour-angle intervals.
|
// PlaneIlluminatedHourAngleIntervals 盘面受光时角区间 / plane-illuminated hour-angle intervals.
|
||||||
//
|
//
|
||||||
// declination 为太阳赤纬,单位度。返回的区间只考虑盘面受光,不判断太阳是否在地平线上方。
|
// declination 为太阳赤纬,单位度。返回的区间只考虑盘面受光,不判断太阳是否在地平线上方。
|
||||||
|
// declination is solar declination in degrees. The returned intervals consider only whether the dial plane is illuminated and do not test whether the Sun is above the horizon.
|
||||||
func (dial PlanarDial) PlaneIlluminatedHourAngleIntervals(declination float64) []HourAngleInterval {
|
func (dial PlanarDial) PlaneIlluminatedHourAngleIntervals(declination float64) []HourAngleInterval {
|
||||||
if !dial.isFinite() || !isFinite(declination) {
|
if !dial.isFinite() || !isFinite(declination) {
|
||||||
return nil
|
return nil
|
||||||
@@ -277,6 +314,7 @@ func (dial PlanarDial) PlaneIlluminatedHourAngleIntervals(declination float64) [
|
|||||||
// IlluminatedHourAngleIntervals 可见且受光时角区间 / illuminated hour-angle intervals.
|
// IlluminatedHourAngleIntervals 可见且受光时角区间 / illuminated hour-angle intervals.
|
||||||
//
|
//
|
||||||
// declination 为太阳赤纬,单位度。结果可直接用于日晷绘图时筛掉无效时线。
|
// declination 为太阳赤纬,单位度。结果可直接用于日晷绘图时筛掉无效时线。
|
||||||
|
// declination is solar declination in degrees. The result can be used directly to discard invalid hour-line segments in sundial plotting.
|
||||||
func (dial PlanarDial) IlluminatedHourAngleIntervals(declination float64) []HourAngleInterval {
|
func (dial PlanarDial) IlluminatedHourAngleIntervals(declination float64) []HourAngleInterval {
|
||||||
aboveHorizon := SunAboveHorizonHourAngleIntervals(dial.Latitude, declination)
|
aboveHorizon := SunAboveHorizonHourAngleIntervals(dial.Latitude, declination)
|
||||||
planeLit := dial.PlaneIlluminatedHourAngleIntervals(declination)
|
planeLit := dial.PlaneIlluminatedHourAngleIntervals(declination)
|
||||||
@@ -287,6 +325,8 @@ func (dial PlanarDial) IlluminatedHourAngleIntervals(declination float64) []Hour
|
|||||||
//
|
//
|
||||||
// declination 为太阳赤纬,单位度;hourAngleStep 为采样步长,单位度,常用值是 15°(每小时一格)。
|
// declination 为太阳赤纬,单位度;hourAngleStep 为采样步长,单位度,常用值是 15°(每小时一格)。
|
||||||
// 返回值按受光区间分段,每段都带有精确的时角范围;Samples 只包含区间内部的有效采样点。
|
// 返回值按受光区间分段,每段都带有精确的时角范围;Samples 只包含区间内部的有效采样点。
|
||||||
|
// declination is solar declination in degrees. hourAngleStep is the sampling step in degrees; 15 degrees is a common one-hour spacing.
|
||||||
|
// The return value is split by illuminated intervals. Each segment carries the exact hour-angle bounds, and Samples contains only valid interior sample points.
|
||||||
func (dial PlanarDial) DeclinationCurve(declination, hourAngleStep float64) []DeclinationCurveSegment {
|
func (dial PlanarDial) DeclinationCurve(declination, hourAngleStep float64) []DeclinationCurveSegment {
|
||||||
if !dial.isFinite() || !isFinite(declination) || !isFinite(hourAngleStep) || hourAngleStep <= 0 {
|
if !dial.isFinite() || !isFinite(declination) || !isFinite(hourAngleStep) || hourAngleStep <= 0 {
|
||||||
return nil
|
return nil
|
||||||
@@ -315,6 +355,7 @@ func (dial PlanarDial) DeclinationCurve(declination, hourAngleStep float64) []De
|
|||||||
// DeclinationCurveAt 瞬时赤纬曲线采样 / declination-curve samples at an instant.
|
// DeclinationCurveAt 瞬时赤纬曲线采样 / declination-curve samples at an instant.
|
||||||
//
|
//
|
||||||
// 用 date 对应瞬时太阳赤纬生成日晷分段曲线采样。
|
// 用 date 对应瞬时太阳赤纬生成日晷分段曲线采样。
|
||||||
|
// Builds the segmented declination-curve samples from the instantaneous solar declination at date.
|
||||||
func (dial PlanarDial) DeclinationCurveAt(date time.Time, hourAngleStep float64) []DeclinationCurveSegment {
|
func (dial PlanarDial) DeclinationCurveAt(date time.Time, hourAngleStep float64) []DeclinationCurveSegment {
|
||||||
return dial.DeclinationCurve(sun.ApparentDec(date), hourAngleStep)
|
return dial.DeclinationCurve(sun.ApparentDec(date), hourAngleStep)
|
||||||
}
|
}
|
||||||
@@ -323,6 +364,7 @@ func (dial PlanarDial) DeclinationCurveAt(date time.Time, hourAngleStep float64)
|
|||||||
//
|
//
|
||||||
// latitude 为地理纬度,declination 为太阳赤纬,单位度。结果只反映太阳是否升到地平线上方,
|
// latitude 为地理纬度,declination 为太阳赤纬,单位度。结果只反映太阳是否升到地平线上方,
|
||||||
// 不包含盘面朝向的影响。
|
// 不包含盘面朝向的影响。
|
||||||
|
// latitude is geographic latitude and declination is solar declination, both in degrees. The result reflects only whether the Sun is above the horizon and does not include dial-plane orientation.
|
||||||
func SunAboveHorizonHourAngleIntervals(latitude, declination float64) []HourAngleInterval {
|
func SunAboveHorizonHourAngleIntervals(latitude, declination float64) []HourAngleInterval {
|
||||||
if !isFinite(latitude) || !isFinite(declination) {
|
if !isFinite(latitude) || !isFinite(declination) {
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -39,6 +39,9 @@ func HourAngle(date time.Time, lon float64) float64 {
|
|||||||
// date 负责提供地方平太阳时日期与时区,原有钟面时间会被 meanSolarHours 替换;
|
// date 负责提供地方平太阳时日期与时区,原有钟面时间会被 meanSolarHours 替换;
|
||||||
// meanSolarHours 为地方平太阳时钟面读数,单位小时,例如 9.5 表示地方平太阳时 09:30。
|
// meanSolarHours 为地方平太阳时钟面读数,单位小时,例如 9.5 表示地方平太阳时 09:30。
|
||||||
// 返回对应的视太阳时角,单位度,上午为负,下午为正。
|
// 返回对应的视太阳时角,单位度,上午为负,下午为正。
|
||||||
|
// date provides the local mean-solar date and timezone, while its clock fields are replaced by meanSolarHours.
|
||||||
|
// meanSolarHours is the local mean-solar clock reading in hours, for example 9.5 for 09:30.
|
||||||
|
// Returns the corresponding apparent-solar hour angle in degrees, negative in the morning and positive in the afternoon.
|
||||||
func MeanSolarHourAngle(date time.Time, meanSolarHours float64) float64 {
|
func MeanSolarHourAngle(date time.Time, meanSolarHours float64) float64 {
|
||||||
if !isFinite(meanSolarHours) {
|
if !isFinite(meanSolarHours) {
|
||||||
return math.NaN()
|
return math.NaN()
|
||||||
@@ -52,6 +55,9 @@ func MeanSolarHourAngle(date time.Time, meanSolarHours float64) float64 {
|
|||||||
// zoneTimeHours 为 date 所在时区下的钟面读数,单位小时;lon 为当地经度,东正西负。
|
// zoneTimeHours 为 date 所在时区下的钟面读数,单位小时;lon 为当地经度,东正西负。
|
||||||
// 返回该区时在给定经度上对应的视太阳时角,单位度,上午为负,下午为正。
|
// 返回该区时在给定经度上对应的视太阳时角,单位度,上午为负,下午为正。
|
||||||
// date 提供民用日期和时区;其原有钟面时间会被 zoneTimeHours 替换。
|
// date 提供民用日期和时区;其原有钟面时间会被 zoneTimeHours 替换。
|
||||||
|
// zoneTimeHours is the civil clock reading in the timezone carried by date, in hours; lon is east-positive longitude.
|
||||||
|
// Returns the apparent-solar hour angle for that civil time and longitude, in degrees, negative in the morning and positive in the afternoon.
|
||||||
|
// date provides the civil date and timezone, and its original clock fields are replaced by zoneTimeHours.
|
||||||
func ZoneTimeHourAngle(date time.Time, lon, zoneTimeHours float64) float64 {
|
func ZoneTimeHourAngle(date time.Time, lon, zoneTimeHours float64) float64 {
|
||||||
if !isFinite(zoneTimeHours) || !isFinite(lon) {
|
if !isFinite(zoneTimeHours) || !isFinite(lon) {
|
||||||
return math.NaN()
|
return math.NaN()
|
||||||
@@ -79,6 +85,7 @@ func HorizontalHourLineAngle(lat, hourAngle float64) float64 {
|
|||||||
// HorizontalHourLineAngleAt 水平日晷时线角 / horizontal sundial hour-line angle.
|
// HorizontalHourLineAngleAt 水平日晷时线角 / horizontal sundial hour-line angle.
|
||||||
//
|
//
|
||||||
// 先按给定时刻和经度求瞬时视太阳时角,再结合纬度返回水平日晷的时线角。
|
// 先按给定时刻和经度求瞬时视太阳时角,再结合纬度返回水平日晷的时线角。
|
||||||
|
// First derives the apparent-solar hour angle for the supplied instant and longitude, then returns the horizontal-dial hour-line angle for the given latitude.
|
||||||
func HorizontalHourLineAngleAt(date time.Time, lon, lat float64) float64 {
|
func HorizontalHourLineAngleAt(date time.Time, lon, lat float64) float64 {
|
||||||
return HorizontalHourLineAngle(lat, HourAngle(date, lon))
|
return HorizontalHourLineAngle(lat, HourAngle(date, lon))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -208,6 +208,7 @@ func SetTime(date time.Time, lon, lat, height float64, aero bool) (time.Time, er
|
|||||||
// LastConjunction 上一次合日 / previous conjunction with the Sun.
|
// LastConjunction 上一次合日 / previous conjunction with the Sun.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之前最近一次与太阳的合日时刻,结果保持 date 的时区。
|
// 返回 date 当前或之前最近一次与太阳的合日时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest conjunction with the Sun at or before date, keeping date's time zone.
|
||||||
func LastConjunction(date time.Time) time.Time {
|
func LastConjunction(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.LastUranusConjunction(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.LastUranusConjunction(jde), date.Location(), false)
|
||||||
@@ -216,6 +217,7 @@ func LastConjunction(date time.Time) time.Time {
|
|||||||
// NextConjunction 下一次合日 / next conjunction with the Sun.
|
// NextConjunction 下一次合日 / next conjunction with the Sun.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之后最近一次与太阳的合日时刻,结果保持 date 的时区。
|
// 返回 date 当前或之后最近一次与太阳的合日时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest conjunction with the Sun at or after date, keeping date's time zone.
|
||||||
func NextConjunction(date time.Time) time.Time {
|
func NextConjunction(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.NextUranusConjunction(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.NextUranusConjunction(jde), date.Location(), false)
|
||||||
@@ -224,6 +226,7 @@ func NextConjunction(date time.Time) time.Time {
|
|||||||
// LastOpposition 上一次冲日 / previous opposition.
|
// LastOpposition 上一次冲日 / previous opposition.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之前最近一次冲日时刻,结果保持 date 的时区。
|
// 返回 date 当前或之前最近一次冲日时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest opposition at or before date, keeping date's time zone.
|
||||||
func LastOpposition(date time.Time) time.Time {
|
func LastOpposition(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.LastUranusOpposition(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.LastUranusOpposition(jde), date.Location(), false)
|
||||||
@@ -232,6 +235,7 @@ func LastOpposition(date time.Time) time.Time {
|
|||||||
// NextOpposition 下一次冲日 / next opposition.
|
// NextOpposition 下一次冲日 / next opposition.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之后最近一次冲日时刻,结果保持 date 的时区。
|
// 返回 date 当前或之后最近一次冲日时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest opposition at or after date, keeping date's time zone.
|
||||||
func NextOpposition(date time.Time) time.Time {
|
func NextOpposition(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.NextUranusOpposition(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.NextUranusOpposition(jde), date.Location(), false)
|
||||||
@@ -240,6 +244,7 @@ func NextOpposition(date time.Time) time.Time {
|
|||||||
// LastProgradeToRetrograde 上一次顺行转逆行留 / previous station from prograde to retrograde.
|
// LastProgradeToRetrograde 上一次顺行转逆行留 / previous station from prograde to retrograde.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之前最近一次由顺行转为逆行的留时刻,结果保持 date 的时区。
|
// 返回 date 当前或之前最近一次由顺行转为逆行的留时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest station at or before date where motion changes from prograde to retrograde, keeping date's time zone.
|
||||||
func LastProgradeToRetrograde(date time.Time) time.Time {
|
func LastProgradeToRetrograde(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.LastUranusProgradeToRetrograde(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.LastUranusProgradeToRetrograde(jde), date.Location(), false)
|
||||||
@@ -248,6 +253,7 @@ func LastProgradeToRetrograde(date time.Time) time.Time {
|
|||||||
// NextProgradeToRetrograde 下一次顺行转逆行留 / next station from prograde to retrograde.
|
// NextProgradeToRetrograde 下一次顺行转逆行留 / next station from prograde to retrograde.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之后最近一次由顺行转为逆行的留时刻,结果保持 date 的时区。
|
// 返回 date 当前或之后最近一次由顺行转为逆行的留时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest station at or after date where motion changes from prograde to retrograde, keeping date's time zone.
|
||||||
func NextProgradeToRetrograde(date time.Time) time.Time {
|
func NextProgradeToRetrograde(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.NextUranusProgradeToRetrograde(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.NextUranusProgradeToRetrograde(jde), date.Location(), false)
|
||||||
@@ -256,6 +262,7 @@ func NextProgradeToRetrograde(date time.Time) time.Time {
|
|||||||
// LastRetrogradeToPrograde 上一次逆行转顺行留 / previous station from retrograde to prograde.
|
// LastRetrogradeToPrograde 上一次逆行转顺行留 / previous station from retrograde to prograde.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之前最近一次由逆行转为顺行的留时刻,结果保持 date 的时区。
|
// 返回 date 当前或之前最近一次由逆行转为顺行的留时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest station at or before date where motion changes from retrograde to prograde, keeping date's time zone.
|
||||||
func LastRetrogradeToPrograde(date time.Time) time.Time {
|
func LastRetrogradeToPrograde(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.LastUranusRetrogradeToPrograde(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.LastUranusRetrogradeToPrograde(jde), date.Location(), false)
|
||||||
@@ -264,6 +271,7 @@ func LastRetrogradeToPrograde(date time.Time) time.Time {
|
|||||||
// NextRetrogradeToPrograde 下一次逆行转顺行留 / next station from retrograde to prograde.
|
// NextRetrogradeToPrograde 下一次逆行转顺行留 / next station from retrograde to prograde.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之后最近一次由逆行转为顺行的留时刻,结果保持 date 的时区。
|
// 返回 date 当前或之后最近一次由逆行转为顺行的留时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest station at or after date where motion changes from retrograde to prograde, keeping date's time zone.
|
||||||
func NextRetrogradeToPrograde(date time.Time) time.Time {
|
func NextRetrogradeToPrograde(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.NextUranusRetrogradeToPrograde(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.NextUranusRetrogradeToPrograde(jde), date.Location(), false)
|
||||||
@@ -272,6 +280,7 @@ func NextRetrogradeToPrograde(date time.Time) time.Time {
|
|||||||
// LastEasternQuadrature 上一次东方照 / previous eastern quadrature.
|
// LastEasternQuadrature 上一次东方照 / previous eastern quadrature.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之前最近一次东方照时刻,结果保持 date 的时区。
|
// 返回 date 当前或之前最近一次东方照时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest eastern quadrature at or before date, keeping date's time zone.
|
||||||
func LastEasternQuadrature(date time.Time) time.Time {
|
func LastEasternQuadrature(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.LastUranusEasternQuadrature(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.LastUranusEasternQuadrature(jde), date.Location(), false)
|
||||||
@@ -280,6 +289,7 @@ func LastEasternQuadrature(date time.Time) time.Time {
|
|||||||
// NextEasternQuadrature 下一次东方照 / next eastern quadrature.
|
// NextEasternQuadrature 下一次东方照 / next eastern quadrature.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之后最近一次东方照时刻,结果保持 date 的时区。
|
// 返回 date 当前或之后最近一次东方照时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest eastern quadrature at or after date, keeping date's time zone.
|
||||||
func NextEasternQuadrature(date time.Time) time.Time {
|
func NextEasternQuadrature(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.NextUranusEasternQuadrature(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.NextUranusEasternQuadrature(jde), date.Location(), false)
|
||||||
@@ -288,6 +298,7 @@ func NextEasternQuadrature(date time.Time) time.Time {
|
|||||||
// LastWesternQuadrature 上一次西方照 / previous western quadrature.
|
// LastWesternQuadrature 上一次西方照 / previous western quadrature.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之前最近一次西方照时刻,结果保持 date 的时区。
|
// 返回 date 当前或之前最近一次西方照时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest western quadrature at or before date, keeping date's time zone.
|
||||||
func LastWesternQuadrature(date time.Time) time.Time {
|
func LastWesternQuadrature(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.LastUranusWesternQuadrature(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.LastUranusWesternQuadrature(jde), date.Location(), false)
|
||||||
@@ -296,6 +307,7 @@ func LastWesternQuadrature(date time.Time) time.Time {
|
|||||||
// NextWesternQuadrature 下一次西方照 / next western quadrature.
|
// NextWesternQuadrature 下一次西方照 / next western quadrature.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之后最近一次西方照时刻,结果保持 date 的时区。
|
// 返回 date 当前或之后最近一次西方照时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest western quadrature at or after date, keeping date's time zone.
|
||||||
func NextWesternQuadrature(date time.Time) time.Time {
|
func NextWesternQuadrature(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.NextUranusWesternQuadrature(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.NextUranusWesternQuadrature(jde), date.Location(), false)
|
||||||
|
|||||||
@@ -208,6 +208,7 @@ func SetTime(date time.Time, lon, lat, height float64, aero bool) (time.Time, er
|
|||||||
// LastConjunction 上一次合日 / previous conjunction with the Sun.
|
// LastConjunction 上一次合日 / previous conjunction with the Sun.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之前最近一次与太阳的合日时刻,结果保持 date 的时区。
|
// 返回 date 当前或之前最近一次与太阳的合日时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest conjunction with the Sun at or before date, keeping date's time zone.
|
||||||
func LastConjunction(date time.Time) time.Time {
|
func LastConjunction(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.LastVenusConjunction(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.LastVenusConjunction(jde), date.Location(), false)
|
||||||
@@ -216,6 +217,7 @@ func LastConjunction(date time.Time) time.Time {
|
|||||||
// NextConjunction 下一次合日 / next conjunction with the Sun.
|
// NextConjunction 下一次合日 / next conjunction with the Sun.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之后最近一次与太阳的合日时刻,结果保持 date 的时区。
|
// 返回 date 当前或之后最近一次与太阳的合日时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest conjunction with the Sun at or after date, keeping date's time zone.
|
||||||
func NextConjunction(date time.Time) time.Time {
|
func NextConjunction(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.NextVenusConjunction(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.NextVenusConjunction(jde), date.Location(), false)
|
||||||
@@ -224,6 +226,7 @@ func NextConjunction(date time.Time) time.Time {
|
|||||||
// LastInferiorConjunction 上一次下合 / previous inferior conjunction.
|
// LastInferiorConjunction 上一次下合 / previous inferior conjunction.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之前最近一次下合时刻,结果保持 date 的时区。
|
// 返回 date 当前或之前最近一次下合时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest inferior conjunction at or before date, keeping date's time zone.
|
||||||
func LastInferiorConjunction(date time.Time) time.Time {
|
func LastInferiorConjunction(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.LastVenusInferiorConjunctionInclusive(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.LastVenusInferiorConjunctionInclusive(jde), date.Location(), false)
|
||||||
@@ -232,6 +235,7 @@ func LastInferiorConjunction(date time.Time) time.Time {
|
|||||||
// NextInferiorConjunction 下一次下合 / next inferior conjunction.
|
// NextInferiorConjunction 下一次下合 / next inferior conjunction.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之后最近一次下合时刻,结果保持 date 的时区。
|
// 返回 date 当前或之后最近一次下合时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest inferior conjunction at or after date, keeping date's time zone.
|
||||||
func NextInferiorConjunction(date time.Time) time.Time {
|
func NextInferiorConjunction(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.NextVenusInferiorConjunctionInclusive(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.NextVenusInferiorConjunctionInclusive(jde), date.Location(), false)
|
||||||
@@ -240,6 +244,7 @@ func NextInferiorConjunction(date time.Time) time.Time {
|
|||||||
// LastSuperiorConjunction 上一次上合 / previous superior conjunction.
|
// LastSuperiorConjunction 上一次上合 / previous superior conjunction.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之前最近一次上合时刻,结果保持 date 的时区。
|
// 返回 date 当前或之前最近一次上合时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest superior conjunction at or before date, keeping date's time zone.
|
||||||
func LastSuperiorConjunction(date time.Time) time.Time {
|
func LastSuperiorConjunction(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.LastVenusSuperiorConjunctionInclusive(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.LastVenusSuperiorConjunctionInclusive(jde), date.Location(), false)
|
||||||
@@ -248,6 +253,7 @@ func LastSuperiorConjunction(date time.Time) time.Time {
|
|||||||
// NextSuperiorConjunction 下一次上合 / next superior conjunction.
|
// NextSuperiorConjunction 下一次上合 / next superior conjunction.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之后最近一次上合时刻,结果保持 date 的时区。
|
// 返回 date 当前或之后最近一次上合时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest superior conjunction at or after date, keeping date's time zone.
|
||||||
func NextSuperiorConjunction(date time.Time) time.Time {
|
func NextSuperiorConjunction(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.NextVenusSuperiorConjunctionInclusive(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.NextVenusSuperiorConjunctionInclusive(jde), date.Location(), false)
|
||||||
@@ -256,6 +262,7 @@ func NextSuperiorConjunction(date time.Time) time.Time {
|
|||||||
// LastRetrograde 上一次留 / previous stationary point.
|
// LastRetrograde 上一次留 / previous stationary point.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之前最近一次留时刻,不区分顺转逆还是逆转顺,结果保持 date 的时区。
|
// 返回 date 当前或之前最近一次留时刻,不区分顺转逆还是逆转顺,结果保持 date 的时区。
|
||||||
|
// Returns the nearest stationary point at or before date, regardless of the direction change, keeping date's time zone.
|
||||||
func LastRetrograde(date time.Time) time.Time {
|
func LastRetrograde(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.LastVenusRetrogradeInclusive(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.LastVenusRetrogradeInclusive(jde), date.Location(), false)
|
||||||
@@ -264,6 +271,7 @@ func LastRetrograde(date time.Time) time.Time {
|
|||||||
// NextRetrograde 下一次留 / next stationary point.
|
// NextRetrograde 下一次留 / next stationary point.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之后最近一次留时刻,不区分顺转逆还是逆转顺,结果保持 date 的时区。
|
// 返回 date 当前或之后最近一次留时刻,不区分顺转逆还是逆转顺,结果保持 date 的时区。
|
||||||
|
// Returns the nearest stationary point at or after date, regardless of the direction change, keeping date's time zone.
|
||||||
func NextRetrograde(date time.Time) time.Time {
|
func NextRetrograde(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.NextVenusRetrogradeInclusive(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.NextVenusRetrogradeInclusive(jde), date.Location(), false)
|
||||||
@@ -272,6 +280,7 @@ func NextRetrograde(date time.Time) time.Time {
|
|||||||
// LastProgradeToRetrograde 上一次顺行转逆行留 / previous station from prograde to retrograde.
|
// LastProgradeToRetrograde 上一次顺行转逆行留 / previous station from prograde to retrograde.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之前最近一次由顺行转为逆行的留时刻,结果保持 date 的时区。
|
// 返回 date 当前或之前最近一次由顺行转为逆行的留时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest station at or before date where motion changes from prograde to retrograde, keeping date's time zone.
|
||||||
func LastProgradeToRetrograde(date time.Time) time.Time {
|
func LastProgradeToRetrograde(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.LastVenusProgradeToRetrogradeInclusive(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.LastVenusProgradeToRetrogradeInclusive(jde), date.Location(), false)
|
||||||
@@ -280,6 +289,7 @@ func LastProgradeToRetrograde(date time.Time) time.Time {
|
|||||||
// NextProgradeToRetrograde 下一次顺行转逆行留 / next station from prograde to retrograde.
|
// NextProgradeToRetrograde 下一次顺行转逆行留 / next station from prograde to retrograde.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之后最近一次由顺行转为逆行的留时刻,结果保持 date 的时区。
|
// 返回 date 当前或之后最近一次由顺行转为逆行的留时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest station at or after date where motion changes from prograde to retrograde, keeping date's time zone.
|
||||||
func NextProgradeToRetrograde(date time.Time) time.Time {
|
func NextProgradeToRetrograde(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.NextVenusProgradeToRetrogradeInclusive(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.NextVenusProgradeToRetrogradeInclusive(jde), date.Location(), false)
|
||||||
@@ -288,6 +298,7 @@ func NextProgradeToRetrograde(date time.Time) time.Time {
|
|||||||
// LastRetrogradeToPrograde 上一次逆行转顺行留 / previous station from retrograde to prograde.
|
// LastRetrogradeToPrograde 上一次逆行转顺行留 / previous station from retrograde to prograde.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之前最近一次由逆行转为顺行的留时刻,结果保持 date 的时区。
|
// 返回 date 当前或之前最近一次由逆行转为顺行的留时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest station at or before date where motion changes from retrograde to prograde, keeping date's time zone.
|
||||||
func LastRetrogradeToPrograde(date time.Time) time.Time {
|
func LastRetrogradeToPrograde(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.LastVenusRetrogradeToProgradeInclusive(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.LastVenusRetrogradeToProgradeInclusive(jde), date.Location(), false)
|
||||||
@@ -296,6 +307,7 @@ func LastRetrogradeToPrograde(date time.Time) time.Time {
|
|||||||
// NextRetrogradeToPrograde 下一次逆行转顺行留 / next station from retrograde to prograde.
|
// NextRetrogradeToPrograde 下一次逆行转顺行留 / next station from retrograde to prograde.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之后最近一次由逆行转为顺行的留时刻,结果保持 date 的时区。
|
// 返回 date 当前或之后最近一次由逆行转为顺行的留时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest station at or after date where motion changes from retrograde to prograde, keeping date's time zone.
|
||||||
func NextRetrogradeToPrograde(date time.Time) time.Time {
|
func NextRetrogradeToPrograde(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.NextVenusRetrogradeToProgradeInclusive(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.NextVenusRetrogradeToProgradeInclusive(jde), date.Location(), false)
|
||||||
@@ -304,6 +316,7 @@ func NextRetrogradeToPrograde(date time.Time) time.Time {
|
|||||||
// LastGreatestElongation 上一次大距 / previous greatest elongation.
|
// LastGreatestElongation 上一次大距 / previous greatest elongation.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之前最近一次大距时刻,不区分东西大距,结果保持 date 的时区。
|
// 返回 date 当前或之前最近一次大距时刻,不区分东西大距,结果保持 date 的时区。
|
||||||
|
// Returns the nearest greatest elongation at or before date, regardless of east or west, keeping date's time zone.
|
||||||
func LastGreatestElongation(date time.Time) time.Time {
|
func LastGreatestElongation(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.LastVenusGreatestElongationInclusive(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.LastVenusGreatestElongationInclusive(jde), date.Location(), false)
|
||||||
@@ -312,6 +325,7 @@ func LastGreatestElongation(date time.Time) time.Time {
|
|||||||
// NextGreatestElongation 下一次大距 / next greatest elongation.
|
// NextGreatestElongation 下一次大距 / next greatest elongation.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之后最近一次大距时刻,不区分东西大距,结果保持 date 的时区。
|
// 返回 date 当前或之后最近一次大距时刻,不区分东西大距,结果保持 date 的时区。
|
||||||
|
// Returns the nearest greatest elongation at or after date, regardless of east or west, keeping date's time zone.
|
||||||
func NextGreatestElongation(date time.Time) time.Time {
|
func NextGreatestElongation(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.NextVenusGreatestElongationInclusive(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.NextVenusGreatestElongationInclusive(jde), date.Location(), false)
|
||||||
@@ -320,6 +334,7 @@ func NextGreatestElongation(date time.Time) time.Time {
|
|||||||
// LastGreatestElongationEast 上一次东大距 / previous greatest eastern elongation.
|
// LastGreatestElongationEast 上一次东大距 / previous greatest eastern elongation.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之前最近一次东大距时刻,结果保持 date 的时区。
|
// 返回 date 当前或之前最近一次东大距时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest eastern greatest elongation at or before date, keeping date's time zone.
|
||||||
func LastGreatestElongationEast(date time.Time) time.Time {
|
func LastGreatestElongationEast(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.LastVenusGreatestElongationEastInclusive(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.LastVenusGreatestElongationEastInclusive(jde), date.Location(), false)
|
||||||
@@ -328,6 +343,7 @@ func LastGreatestElongationEast(date time.Time) time.Time {
|
|||||||
// NextGreatestElongationEast 下一次东大距 / next greatest eastern elongation.
|
// NextGreatestElongationEast 下一次东大距 / next greatest eastern elongation.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之后最近一次东大距时刻,结果保持 date 的时区。
|
// 返回 date 当前或之后最近一次东大距时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest eastern greatest elongation at or after date, keeping date's time zone.
|
||||||
func NextGreatestElongationEast(date time.Time) time.Time {
|
func NextGreatestElongationEast(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.NextVenusGreatestElongationEastInclusive(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.NextVenusGreatestElongationEastInclusive(jde), date.Location(), false)
|
||||||
@@ -336,6 +352,7 @@ func NextGreatestElongationEast(date time.Time) time.Time {
|
|||||||
// LastGreatestElongationWest 上一次西大距 / previous greatest western elongation.
|
// LastGreatestElongationWest 上一次西大距 / previous greatest western elongation.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之前最近一次西大距时刻,结果保持 date 的时区。
|
// 返回 date 当前或之前最近一次西大距时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest western greatest elongation at or before date, keeping date's time zone.
|
||||||
func LastGreatestElongationWest(date time.Time) time.Time {
|
func LastGreatestElongationWest(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.LastVenusGreatestElongationWestInclusive(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.LastVenusGreatestElongationWestInclusive(jde), date.Location(), false)
|
||||||
@@ -344,6 +361,7 @@ func LastGreatestElongationWest(date time.Time) time.Time {
|
|||||||
// NextGreatestElongationWest 下一次西大距 / next greatest western elongation.
|
// NextGreatestElongationWest 下一次西大距 / next greatest western elongation.
|
||||||
//
|
//
|
||||||
// 返回 date 当前或之后最近一次西大距时刻,结果保持 date 的时区。
|
// 返回 date 当前或之后最近一次西大距时刻,结果保持 date 的时区。
|
||||||
|
// Returns the nearest western greatest elongation at or after date, keeping date's time zone.
|
||||||
func NextGreatestElongationWest(date time.Time) time.Time {
|
func NextGreatestElongationWest(date time.Time) time.Time {
|
||||||
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
|
||||||
return basic.JDE2DateByZone(basic.NextVenusGreatestElongationWestInclusive(jde), date.Location(), false)
|
return basic.JDE2DateByZone(basic.NextVenusGreatestElongationWestInclusive(jde), date.Location(), false)
|
||||||
|
|||||||
Reference in New Issue
Block a user