diff --git a/generate/template/astronomy.go b/generate/template/astronomy.go
index 3902a7a7..54d789b1 100644
--- a/generate/template/astronomy.go
+++ b/generate/template/astronomy.go
@@ -444,6 +444,17 @@ type Spherical struct {
Dist float64 // a distance expressed in astronomical units
}
+type EclipseKind int
+
+// The different kinds of lunar/solar eclipses.
+const (
+ NoEclipse = iota // no eclipse found
+ PenumbralEclipse // A penumbral lunar eclipse. (Never used for a solar eclipse.)
+ PartialEclipse // A partial lunar/solar eclipse.
+ AnnularEclipse // An annular solar eclipse. (Never used for a lunar eclipse.)
+ TotalEclipse // A total lunar/solar eclipse.
+)
+
type Body int
const (
@@ -1347,6 +1358,8 @@ func GeoMoon(time AstroTime) AstroVector {
return mpos2
}
+//--- Eclipse/transit code begins
+
type shadowInfo struct {
time AstroTime
u float64 // dot product of (heliocentric earth) and (geocentric moon): defines the shadow plane where the Moon is
@@ -1368,6 +1381,18 @@ func calcShadow(bodyRadiusKm float64, time AstroTime, target AstroVector, dir As
return shadowInfo{time, u, r, k, p, target, dir}
}
+func eclipseKindFromUmbra(k float64) EclipseKind {
+ // The umbra radius tells us what kind of eclipse the observer sees.
+ // If the umbra radius is positive, this is a total eclipse. Otherwise, it's annular.
+ // HACK: I added a tiny bias (14 meters) to match Espenak test data.
+ if k > 0.014 {
+ return TotalEclipse
+ }
+ return AnnularEclipse
+}
+
+//--- Eclipse/transit code ends
+
func jupiterMoonElemToPv(time AstroTime, mu, A, AL, K, H, Q, P float64) StateVector {
// Translation of FORTRAN subroutine ELEM2PV from:
// https://ftp.imcce.fr/pub/ephem/satel/galilean/L1/L1.2/
@@ -1482,6 +1507,22 @@ func JupiterMoons(time AstroTime) JupiterMoonsInfo {
}
}
+//--- Pluto calc begins
+
+func clampIndex(frac float64, nsteps int) int {
+ var index int
+ index = int(math.Floor(frac))
+ if index < 0 {
+ return 0
+ }
+ if index >= nsteps {
+ return nsteps - 1
+ }
+ return index
+}
+
+//--- Pluto calc ends
+
//--- Generated code begins here ------------------------------------------------------------------
//$ASTRO_CONSTEL()
diff --git a/source/golang/README.md b/source/golang/README.md
index 6ff9ae1e..df356e0b 100644
--- a/source/golang/README.md
+++ b/source/golang/README.md
@@ -38,6 +38,7 @@ It provides a suite of well\-tested functions for calculating positions of the S
- [type CalendarDateTime](<#CalendarDateTime>)
- [func CalendarFromDays\(ut float64\) \(\*CalendarDateTime, error\)](<#CalendarFromDays>)
- [type DeltaTimeFunc](<#DeltaTimeFunc>)
+- [type EclipseKind](<#EclipseKind>)
- [type Ecliptic](<#Ecliptic>)
- [type Equatorial](<#Equatorial>)
- [type JupiterMoonsInfo](<#JupiterMoonsInfo>)
@@ -102,6 +103,18 @@ const (
)
```
+The different kinds of lunar/solar eclipses.
+
+```go
+const (
+ NoEclipse = iota // no eclipse found
+ PenumbralEclipse // A penumbral lunar eclipse. (Never used for a solar eclipse.)
+ PartialEclipse // A partial lunar/solar eclipse.
+ AnnularEclipse // An annular solar eclipse. (Never used for a lunar eclipse.)
+ TotalEclipse // A total lunar/solar eclipse.
+)
+```
+
```go
@@ -142,7 +155,7 @@ const (
```
-## func [AngleBetween]()
+## func [AngleBetween]()
```go
func AngleBetween(avec AstroVector, bvec AstroVector) float64
@@ -160,7 +173,7 @@ func DaysFromCalendar(year, month, day, hour, minute int, second float64) float6
-## func [DefineStar]()
+## func [DefineStar]()
```go
func DefineStar(body Body, ra, dec, distanceLightYears float64) error
@@ -169,7 +182,7 @@ func DefineStar(body Body, ra, dec, distanceLightYears float64) error
-## func [DegreesFromRadians]()
+## func [DegreesFromRadians]()
```go
func DegreesFromRadians(radians float64) float64
@@ -187,7 +200,7 @@ func Dot(a, b AstroVector) float64
Returns the scalar dot product of two vectors.
-## func [RadiansFromDegrees]()
+## func [RadiansFromDegrees]()
```go
func RadiansFromDegrees(degrees float64) float64
@@ -196,7 +209,7 @@ func RadiansFromDegrees(degrees float64) float64
RadiansFromDegrees converts an angle expressed in degrees to an angle expressed in radians.
-## func [SiderealTime]()
+## func [SiderealTime]()
```go
func SiderealTime(time *AstroTime) float64
@@ -205,7 +218,7 @@ func SiderealTime(time *AstroTime) float64
Given a date and time, SiderealTime calculates the rotation of the Earth, represented by the equatorial angle of the Greenwich prime meridian with respect to distant stars \(not the Sun, which moves relative to background stars by almost one degree per day\). This angle is called Greenwich Apparent Sidereal Time \(GAST\). GAST is measured in sidereal hours in the half\-open range \[0, 24\). When GAST = 0, it means the prime meridian is aligned with the of\-date equinox, corrected at that time for precession and nutation of the Earth's axis. In this context, the "equinox" is the direction in space where the Earth's orbital plane \(the ecliptic\) intersects with the plane of the Earth's equator, at the location on the Earth's orbit of the \(seasonal\) March equinox. As the Earth rotates, GAST increases from 0 up to 24 sidereal hours, then starts over at 0. To convert to degrees, multiply the return value by 15. As an optimization, this function caches the sidereal time value in the time parameter. The value is reused later as needed, to avoid redundant calculations.
-## type [AstroMoonQuarter]()
+## type [AstroMoonQuarter]()
@@ -217,7 +230,7 @@ type AstroMoonQuarter struct {
```
-## type [AstroSearchFunc]()
+## type [AstroSearchFunc]()
@@ -324,7 +337,7 @@ type AstroVector struct {
```
-### func [GeoMoon]()
+### func [GeoMoon]()
```go
func GeoMoon(time AstroTime) AstroVector
@@ -333,7 +346,7 @@ func GeoMoon(time AstroTime) AstroVector
GeoMoon calculates the equatorial geocentric position of the Moon at a given time. The returned vector indicates the Moon's center relative to the Earth's center. The vector components are expressed in AU \(astronomical units\). The coordinates are oriented with respect to the Earth's equator at the J2000 epoch. In Astronomy Engine, this orientation is called EQJ.
-### func [RotateVector]()
+### func [RotateVector]()
```go
func RotateVector(rotation RotationMatrix, vector AstroVector) AstroVector
@@ -351,7 +364,7 @@ func (vec AstroVector) Length() float64
Returns the length of vec expressed in the same distance units as vec's components.
-## type [AtmosphereInfo]()
+## type [AtmosphereInfo]()
AtmosphereInfo contains information about idealized atmospheric variables at a given elevation.
@@ -373,7 +386,7 @@ func Atmosphere(elevationMeters float64) (AtmosphereInfo, error)
Atmosphere calculates U.S. Standard Atmosphere \(1976\) variables as a function of elevation. elevationMeters is the elevation above sea level at which to calculate atmospheric variables. It must be in the range \-500 to \+100000 or an error will occur. 1. COESA, U.S. Standard Atmosphere, 1976, U.S. Government Printing Office, Washington, DC, 1976. 2. Jursa, A. S., Ed., Handbook of Geophysics and the Space Environment, Air Force Geophysics Laboratory, 1985. See: https://hbcp.chemnetbase.com/faces/documents/14_12/14_12_0001.xhtml https://ntrs.nasa.gov/api/citations/19770009539/downloads/19770009539.pdf https://www.ngdc.noaa.gov/stp/space-weather/online-publications/miscellaneous/us-standard-atmosphere-1976/us-standard-atmosphere_st76-1562_noaa.pdf
-## type [AxisInfo]()
+## type [AxisInfo]()
@@ -387,7 +400,7 @@ type AxisInfo struct {
```
-## type [Body]()
+## type [Body]()
@@ -421,7 +434,7 @@ func CalendarFromDays(ut float64) (*CalendarDateTime, error)
CalendarFromDays converts a J2000 day value to a Gregorian calendar date and time.
-## type [DeltaTimeFunc]()
+## type [DeltaTimeFunc]()
@@ -429,8 +442,17 @@ CalendarFromDays converts a J2000 day value to a Gregorian calendar date and tim
type DeltaTimeFunc func(ut float64) float64
```
+
+## type [EclipseKind]()
+
+
+
+```go
+type EclipseKind int
+```
+
-## type [Ecliptic]()
+## type [Ecliptic]()
A location of a body expressed in angular coordinates relative to the plane of the Earth's orbit around the Sun
@@ -443,7 +465,7 @@ type Ecliptic struct {
```
-## type [Equatorial]()
+## type [Equatorial]()
A location of a body expressed in angular coordinates relative to the Earth's equator
@@ -457,7 +479,7 @@ type Equatorial struct {
```
-## type [JupiterMoonsInfo]()
+## type [JupiterMoonsInfo]()
@@ -471,7 +493,7 @@ type JupiterMoonsInfo struct {
```
-### func [JupiterMoons]()
+### func [JupiterMoons]()
```go
func JupiterMoons(time AstroTime) JupiterMoonsInfo
@@ -480,7 +502,7 @@ func JupiterMoons(time AstroTime) JupiterMoonsInfo
Calculates Jovicentric positoins and velocities of Jupiter's largest 4 moons. Calculates position and velocity vectors for Jupiter's moons Io, Europa, Ganymede, and Callisto, at the given date and time. The vectors are jovicentric \(relative to the center of Jupiter\). Their orientation is the Earth's equatorial system at the J2000 epoch \(EQJ\). The position components are expressed in astronomical units \(AU\), and the velocity components are in AU/day. To convert to heliocentric position vectors, call HelioVector with Jupiter as the body to get Jupiter's heliocentric position, then add the jovicentric moon positions. Likewise, you can call \#Astronomy.GeoVector to convert to geocentric positions; however, you will have to manually correct for light travel time from the Jupiter system to Earth to figure out what time to pass to \`JupiterMoons\` to get an accurate picture of how Jupiter and its moons look from Earth.
-## type [LibrationInfo]()
+## type [LibrationInfo]()
@@ -496,7 +518,7 @@ type LibrationInfo struct {
```
-## type [NodeEventInfo]()
+## type [NodeEventInfo]()
@@ -508,7 +530,7 @@ type NodeEventInfo struct {
```
-## type [NodeEventKind]()
+## type [NodeEventKind]()
@@ -517,7 +539,7 @@ type NodeEventKind int
```
-## type [Observer]()
+## type [Observer]()
The location of a point on or near the surface of the Earth
@@ -530,7 +552,7 @@ type Observer struct {
```
-## type [Refraction]()
+## type [Refraction]()
@@ -549,7 +571,7 @@ const (
```
-## type [RotationMatrix]()
+## type [RotationMatrix]()
RotationMatrix is a 3x3 matrix used to convert a vector from one orientation system to another.
@@ -560,7 +582,7 @@ type RotationMatrix struct {
```
-### func [CombineRotation]()
+### func [CombineRotation]()
```go
func CombineRotation(a, b RotationMatrix) RotationMatrix
@@ -569,7 +591,7 @@ func CombineRotation(a, b RotationMatrix) RotationMatrix
CombineRotation combines the effects of two consecutive rotation matrices into a single rotation matrix.
-### func [IdentityMatrix]()
+### func [IdentityMatrix]()
```go
func IdentityMatrix() RotationMatrix
@@ -578,7 +600,7 @@ func IdentityMatrix() RotationMatrix
Creates a rotation matrix that represents no rotation at all.
-### func [InverseRotation]()
+### func [InverseRotation]()
```go
func InverseRotation(rotation RotationMatrix) RotationMatrix
@@ -587,7 +609,7 @@ func InverseRotation(rotation RotationMatrix) RotationMatrix
Calculates the inverse of a rotation matrix. Given a rotation matrix that performs some coordinate transform, this function returns the matrix that reverses that transform.
-### func [RotationEqdEqj]()
+### func [RotationEqdEqj]()
```go
func RotationEqdEqj(time *AstroTime) RotationMatrix
@@ -596,7 +618,7 @@ func RotationEqdEqj(time *AstroTime) RotationMatrix
Calculates a rotation matrix that converts equator\-of\-date \(EQD\) to J2000 mean equator \(EQJ\).
-## type [SeasonsInfo]()
+## type [SeasonsInfo]()
@@ -640,7 +662,7 @@ type StateVector struct {
```
-### func [RotateState]()
+### func [RotateState]()
```go
func RotateState(rotation RotationMatrix, state StateVector) StateVector
@@ -667,7 +689,7 @@ func (state StateVector) Velocity() AstroVector
Position returns the velocity vector inside a state vector.
-## type [TimeFormat]()
+## type [TimeFormat]()
@@ -687,7 +709,7 @@ const (
```
-## type [Topocentric]()
+## type [Topocentric]()
A location of a body as seen from an observer's point of view on or near the surface of the Earth. The topocentric position can optionally be corrected for atmospheric refraction.
diff --git a/source/golang/astronomy.go b/source/golang/astronomy.go
index a8d5ca83..ec0ba268 100644
--- a/source/golang/astronomy.go
+++ b/source/golang/astronomy.go
@@ -444,6 +444,17 @@ type Spherical struct {
Dist float64 // a distance expressed in astronomical units
}
+type EclipseKind int
+
+// The different kinds of lunar/solar eclipses.
+const (
+ NoEclipse = iota // no eclipse found
+ PenumbralEclipse // A penumbral lunar eclipse. (Never used for a solar eclipse.)
+ PartialEclipse // A partial lunar/solar eclipse.
+ AnnularEclipse // An annular solar eclipse. (Never used for a lunar eclipse.)
+ TotalEclipse // A total lunar/solar eclipse.
+)
+
type Body int
const (
@@ -1347,6 +1358,8 @@ func GeoMoon(time AstroTime) AstroVector {
return mpos2
}
+//--- Eclipse/transit code begins
+
type shadowInfo struct {
time AstroTime
u float64 // dot product of (heliocentric earth) and (geocentric moon): defines the shadow plane where the Moon is
@@ -1368,6 +1381,18 @@ func calcShadow(bodyRadiusKm float64, time AstroTime, target AstroVector, dir As
return shadowInfo{time, u, r, k, p, target, dir}
}
+func eclipseKindFromUmbra(k float64) EclipseKind {
+ // The umbra radius tells us what kind of eclipse the observer sees.
+ // If the umbra radius is positive, this is a total eclipse. Otherwise, it's annular.
+ // HACK: I added a tiny bias (14 meters) to match Espenak test data.
+ if k > 0.014 {
+ return TotalEclipse
+ }
+ return AnnularEclipse
+}
+
+//--- Eclipse/transit code ends
+
func jupiterMoonElemToPv(time AstroTime, mu, A, AL, K, H, Q, P float64) StateVector {
// Translation of FORTRAN subroutine ELEM2PV from:
// https://ftp.imcce.fr/pub/ephem/satel/galilean/L1/L1.2/
@@ -1482,6 +1507,22 @@ func JupiterMoons(time AstroTime) JupiterMoonsInfo {
}
}
+//--- Pluto calc begins
+
+func clampIndex(frac float64, nsteps int) int {
+ var index int
+ index = int(math.Floor(frac))
+ if index < 0 {
+ return 0
+ }
+ if index >= nsteps {
+ return nsteps - 1
+ }
+ return index
+}
+
+//--- Pluto calc ends
+
//--- Generated code begins here ------------------------------------------------------------------
var constelNames = [...]constelInfo{