Documentation
¶
Index ¶
- Variables
- func Aberration(position, velocity [3]float64, lightTime float64) [3]float64
- func Altaz(posICRF [3]float64, latDeg, lonDeg, jdUT1 float64) (altDeg, azDeg, distKm float64)
- func Deflection(position, pe [3]float64, rmass float64) [3]float64
- func EarthRotationAngle(jdUT1 float64) float64
- func Elongation(targetLonDeg, referenceLonDeg float64) float64
- func FractionIlluminated(phaseAngleDeg float64) float64
- func GAST(jdUT1 float64) float64
- func GMST(jdUT1 float64) float64
- func GeodeticToICRF(latDeg, lonDeg, jdUT1 float64) (x, y, z float64)
- func HourAngleDec(posICRF [3]float64, lonDeg, jdUT1 float64) (haDeg, decDeg float64)
- func ICRFToEcliptic(x, y, z float64) (latDeg, lonDeg float64)
- func ICRFToGalactic(x, y, z float64) (latDeg, lonDeg float64)
- func ITRFToGeodetic(x, y, z float64) (latDeg, lonDeg, heightKm float64)
- func IsBehindEarth(observerPosKm, targetPosKm [3]float64) bool
- func IsSunlit(posKm, sunPosKm [3]float64) bool
- func PhaseAngle(obsToTarget, sunToTarget [3]float64) float64
- func PositionAngle(ra1Hours, dec1Deg, ra2Hours, dec2Deg float64) float64
- func RADecToICRF(raHours, decDeg float64) (x, y, z float64)
- func Refract(altDeg, tempC, pressureMbar float64) float64
- func Refraction(altDeg, tempC, pressureMbar float64) float64
- func SeparationAngle(a, b [3]float64) float64
- func SetNutationPrecision(p NutationPrecision)
- func TEMEToICRF(posKmTEME [3]float64, jdUT1 float64) [3]float64
- type InertialFrame
- type Location
- type NutationPrecision
- type TimeBasedFrame
Constants ¶
This section is empty.
Variables ¶
var ( Galactic = InertialFrame{Name: "Galactic", Matrix: GalacticMatrix} B1950 = InertialFrame{Name: "B1950", Matrix: B1950Matrix} // Ecliptic is the J2000 mean ecliptic frame. This rotates ICRF around the // X-axis by the J2000 mean obliquity (23.4393°). Ecliptic = InertialFrame{ Name: "Ecliptic", Matrix: [3][3]float64{ {1, 0, 0}, {0, obliquityCos, obliquitySin}, {0, -obliquitySin, obliquityCos}, }, } )
Predefined InertialFrame instances for common reference frames.
var B1950Matrix = [3][3]float64{
{0.99992570795236291, 0.011178938126427691, 0.0048590038414544293},
{-0.011178938137770135, 0.9999375133499887, -2.715792625851078e-05},
{-0.0048590038153592712, -2.7162594714247048e-05, 0.9999881946023742},
}
B1950Matrix is the rotation matrix from ICRF (J2000) to the mean equator and equinox of B1950 (FK4). Apply as v_B1950 = B1950Matrix * v_icrf. Source: SPICE Toolkit / Skyfield.
var GalacticMatrix = [3][3]float64{
{-0.054875539395742523, -0.87343710472759606, -0.48383499177002515},
{0.49410945362774389, -0.44482959429757496, 0.74698224869989183},
{-0.86766613568337381, -0.19807638961301985, 0.45598379452141991},
}
GalacticMatrix is the rotation matrix from ICRF (J2000) to Galactic System II (IAU 1958). Apply as v_gal = GalacticMatrix * v_icrf. Source: SPICE Toolkit / Skyfield.
var ICRSToJ2000Matrix [3][3]float64
ICRSToJ2000Matrix is the frame bias matrix from ICRS to the dynamical mean equator and equinox of J2000. The bias is a few milliarcseconds. Source: IERS Conventions 2003, Chapter 5.
Functions ¶
func Aberration ¶
Aberration applies special-relativistic stellar aberration to an astrometric position vector. Uses the full Lorentz transformation (not the classical v/c approximation). Matches Skyfield's add_aberration() in relativity.py.
position is the observer-to-target vector in km (astrometric position). velocity is the observer's barycentric velocity in km/day. lightTime is the light travel time to the target in days.
Returns the apparent position in km.
func Altaz ¶
Altaz converts a geocentric ICRF position vector to altitude and azimuth for a ground observer at the given geodetic latitude and longitude. jdUT1 is the UT1 Julian date (needed for Earth rotation).
The position should be a geocentric or topocentric vector in km (typically from SPK.Apparent). For distant bodies (Sun, planets), geocentric and topocentric directions agree to <0.01°. For the Moon, topocentric positions are needed for arcsecond-level accuracy (parallax ~1°).
Returns altitude (degrees, positive above horizon, geometric — no refraction), azimuth (degrees, 0=North, 90=East), and distance (km).
The rotation chain is: ICRF → mean equator of date (precession) → true equator of date (nutation) → ITRF (Earth rotation via GAST) → local horizon (lat/lon). Matches Skyfield's rotation_at() + altaz() pipeline.
func Deflection ¶
Deflection computes the gravitational deflection of light by a single body. Returns the deflection correction vector in km (to be added to the position).
position is the observer-to-target vector in km (astrometric position). pe is the observer-to-deflector vector in km (same sign convention as Skyfield). rmass is the reciprocal mass: GM_sun / GM_deflector (1.0 for the Sun).
Matches Skyfield's _compute_deflection() in relativity.py.
func EarthRotationAngle ¶
EarthRotationAngle returns the Earth Rotation Angle in degrees for a given UT1 Julian date. Uses the formula from IAU Resolution B1.8 of 2000. This is the modern replacement for GMST.
func Elongation ¶
Elongation returns the elongation of a target from a reference body, given their ecliptic longitudes in degrees. Returns degrees in [0, 360). For moon phase, pass the Moon's ecliptic longitude as target and the Sun's as reference: 0°=new moon, 90°=first quarter, 180°=full, 270°=last quarter.
func FractionIlluminated ¶
FractionIlluminated returns the fraction of a spherical body's disc that is illuminated, given the phase angle in degrees. Returns a value in [0, 1].
func GAST ¶
GAST returns Greenwich Apparent Sidereal Time in degrees, which includes the nutation correction (equation of equinoxes).
func GMST ¶
GMST returns Greenwich Mean Sidereal Time in degrees for a given UT1 Julian date. Uses the IAU 1982 formula (Meeus).
func GeodeticToICRF ¶
GeodeticToICRF converts geodetic coordinates (lat/lon in degrees) to an ICRF direction vector at the given UT1 Julian date. Uses the full transformation: ICRF = P^T * N^T * Rz(GAST) * ITRF
func HourAngleDec ¶
HourAngleDec computes the hour angle and declination of a geocentric ICRF position vector for an observer at the given longitude. jdUT1 is the UT1 Julian date.
Hour angle is measured westward from the local meridian (0° = on meridian, positive = west of meridian). Declination is measured from the true equator of date.
Returns hour angle (degrees, 0–360) and declination (degrees, -90 to +90).
func ICRFToEcliptic ¶
ICRFToEcliptic converts an ICRF Cartesian vector to ecliptic latitude and longitude (degrees). Uses the J2000 mean ecliptic (matching Skyfield's default ecliptic_latlon()).
func ICRFToGalactic ¶
ICRFToGalactic converts an ICRF Cartesian vector to Galactic latitude and longitude in degrees. Longitude is in [0, 360).
func ITRFToGeodetic ¶
ITRFToGeodetic converts ITRF Cartesian coordinates (km) to geodetic latitude, longitude (degrees), and height above the WGS84 ellipsoid (km).
Uses Bowring's iterative method (converges in 2-3 iterations for terrestrial positions, and handles all cases including poles and equator).
func IsBehindEarth ¶
IsBehindEarth returns true if the target position is geometrically behind Earth as seen from the observer position.
Both positions are geocentric ICRF vectors in km. The target is "behind Earth" if the line of sight from observer to target passes through Earth's sphere.
func IsSunlit ¶
IsSunlit returns true if a position (in km, ICRF, relative to Earth center) is illuminated by the Sun.
posKm is the object's geocentric position in km (e.g., a satellite). sunPosKm is the Sun's geocentric position in km (from SPK.Observe or SPK.Apparent).
Uses geometric shadow test: the object is in shadow if the line from the object to the Sun intersects Earth's sphere.
func PhaseAngle ¶
PhaseAngle returns the phase angle in degrees given two direction vectors: obsToTarget (observer to target) and sunToTarget (Sun to target). The phase angle is 0° when fully illuminated and 180° when fully in shadow.
To compute sunToTarget from goeph's SPK package:
obsToTarget := spk.Observe(targetID, tdb)
obsToSun := spk.Observe(spk.Sun, tdb)
sunToTarget := [3]float64{obsToTarget[0]-obsToSun[0], obsToTarget[1]-obsToSun[1], obsToTarget[2]-obsToSun[2]}
func PositionAngle ¶
PositionAngle returns the position angle from one sky position to another, measured North through East (counterclockwise on the sky), in degrees [0, 360). Both positions are given as RA (hours) and Dec (degrees).
func RADecToICRF ¶
RADecToICRF converts J2000 RA (hours) and Dec (degrees) to an ICRF unit vector.
func Refract ¶
Refract returns the apparent altitude in degrees after atmospheric refraction, given a true (geometric) altitude. Uses iterative convergence of Bennett's formula (within 3e-5 degrees, ~0.1 arcsecond).
Parameters:
- altDeg: true (geometric) altitude in degrees
- tempC: temperature in degrees Celsius
- pressureMbar: atmospheric pressure in millibars
func Refraction ¶
Refraction returns the atmospheric refraction correction in degrees for a given apparent (observed) altitude. Uses Bennett's formula (1982). Returns 0 for altitudes below -1° or above 89.9°.
Parameters:
- altDeg: apparent altitude in degrees
- tempC: temperature in degrees Celsius
- pressureMbar: atmospheric pressure in millibars
func SeparationAngle ¶
SeparationAngle returns the angular separation in degrees between two Cartesian vectors. Uses Kahan's numerically stable formula. See: https://people.eecs.berkeley.edu/~wkahan/Mindless.pdf Section 12.
func SetNutationPrecision ¶
func SetNutationPrecision(p NutationPrecision)
SetNutationPrecision sets the nutation precision for the coord package. Default is NutationStandard (30 terms, fast). Not safe for concurrent use — call once at program startup.
func TEMEToICRF ¶
TEMEToICRF converts a TEME (True Equator, Mean Equinox) position vector from SGP4 propagation to ICRF/GCRS coordinates.
posKmTEME is the satellite position in km from SGP4 (TEME frame). jdUT1 is the UT1 Julian date (used for Earth rotation via nutation/precession).
The TEME frame is the output frame of SGP4. It uses the true equator of date but a "mean" equinox that differs from the classical mean equinox by the equation of the equinoxes. The conversion chain is:
TEME → true equator of date (via equation of equinoxes rotation)
→ mean equator of date (via nutation inverse)
→ ICRF/J2000 (via precession inverse)
Types ¶
type InertialFrame ¶
InertialFrame is a static (time-independent) reference frame defined by a rotation matrix from ICRF. Examples include the Galactic frame, B1950, and the ecliptic. Apply the rotation matrix to an ICRF vector to get coordinates in this frame.
func (InertialFrame) LatLon ¶
func (f InertialFrame) LatLon(posICRF [3]float64) (latDeg, lonDeg float64)
LatLon applies the frame rotation to an ICRF position vector, returning latitude and longitude in degrees. Longitude is in [0, 360).
func (InertialFrame) XYZ ¶
func (f InertialFrame) XYZ(posICRF [3]float64) [3]float64
XYZ applies the frame rotation to an ICRF position vector, returning Cartesian coordinates in this frame.
type Location ¶
type Location struct {
Name string
Lat float64 // degrees, positive north
Lon float64 // degrees, positive east
}
Location represents a ground location with WGS84 coordinates.
type NutationPrecision ¶
type NutationPrecision int
NutationPrecision controls the number of terms used in the IAU 2000A nutation series.
const ( // NutationStandard uses the 30 largest luni-solar terms (~1 arcsec precision). // This is ~45x faster than NutationFull and sufficient for most applications, // since other error sources (light-time ~20 arcsec, GMST formula ~0.3 arcsec/century) // dominate the overall accuracy budget. NutationStandard NutationPrecision = iota // NutationFull uses all 678 luni-solar + 687 planetary terms (~0.001 arcsec precision). // Matches Skyfield's default IAU 2000A nutation model. Use for high-precision // single-point computations or when exact Skyfield parity is required. NutationFull )
func GetNutationPrecision ¶
func GetNutationPrecision() NutationPrecision
GetNutationPrecision returns the current nutation precision setting.
type TimeBasedFrame ¶
type TimeBasedFrame struct {
Name string
MatrixAt func(jd float64) [3][3]float64 // ICRF → frame rotation matrix at time jd
}
TimeBasedFrame is a time-dependent reference frame defined by a function that returns a rotation matrix from ICRF at a given Julian date. Examples include the true equator of date and the ITRF (Earth-fixed frame).
func ITRFFrame ¶
func ITRFFrame() TimeBasedFrame
ITRFFrame returns a TimeBasedFrame for the International Terrestrial Reference Frame (Earth-fixed). The jd argument is UT1 Julian date.