Documentation
ΒΆ
Overview ΒΆ
Package astronomy is an observer-aware Go astronomy library: sun, moon, star, and constellation positions with twilight bands, arc tracks, and moon phases.
This root package holds the shared domain types (Observer, Horizontal, Position, AngularDiameter) used across the body-specific packages. The heavy math lives in unexported internal packages built on the meeus ephemeris algorithms.
Index ΒΆ
Constants ΒΆ
const ( // CodeInvalidLatitude marks an observer latitude outside [-90, 90]. CodeInvalidLatitude = 7001 // CodeInvalidLongitude marks an observer longitude outside [-180, 180]. CodeInvalidLongitude = 7002 // CodeInvalidSegmentation marks a Segmentation whose levels are empty or not // in strictly ascending altitude order. CodeInvalidSegmentation = 7003 // CodeInvalidMagnitudeRange marks a stellar magnitude query whose bright // bound is fainter than its faint bound, which can select no star. CodeInvalidMagnitudeRange = 7004 // CodeInvalidCanvas marks a screen projection whose canvas width or height is // not positive, so it spans no pixels. CodeInvalidCanvas = 7005 // CodeInvalidHorizonFraction marks a viewport whose horizon fraction is // outside [0, 1], so the horizon line would fall off the canvas. CodeInvalidHorizonFraction = 7006 // CodeInvalidPeakAltitude marks a NormalizedByPeak projection whose peak // altitude is not positive, which cannot normalize an arch. CodeInvalidPeakAltitude = 7007 // CodeInvalidFieldOfView marks an azimuth-based projection whose field of view // (Directional) or sunrise-to-sunset azimuth span (FullArc) is not positive. CodeInvalidFieldOfView = 7008 // CodeInvalidElevationScale marks a Geometric projection whose elevation // degrees-per-pixel is not positive. CodeInvalidElevationScale = 7009 // CodeXModeNotAzimuth marks a column-to-azimuth inverse query on a projection // whose horizontal mode is not azimuth-based, so no azimuth axis exists. CodeXModeNotAzimuth = 7010 )
Stable numeric error codes for the module. Each error-returning function wraps its cause with one of these via go-apperr, so a caller can recover the code with apperr.Code and branch on it without matching error strings. The values are part of the public contract: never renumber a code, only add new ones.
const ErrorServiceDigit = 7
ErrorServiceDigit is the leading digit that every go-astronomy error code shares, so a code is attributable to this module at a glance. It is the go-apperr service prefix for the module's code namespace.
Variables ΒΆ
This section is empty.
Functions ΒΆ
func Errors ΒΆ
Errors returns the module's go-apperr registry: the stable code table plus the presentation and logging policy around it. A consumer renders a coded error at its edge with Registry.Present (or PresentContext, which also drives the wired go-log logger) to obtain a sanitized, quotable message, looks a code up with Registry.Describe, or emits the whole table as Markdown with Registry.Markdown. The registry is built once and is safe for concurrent use.
Types ΒΆ
type AngularDiameter ΒΆ
type AngularDiameter float64
AngularDiameter is the apparent angular size of a body's disc, in degrees.
func (AngularDiameter) Radius ΒΆ
func (a AngularDiameter) Radius() float64
Radius returns half the angular diameter, in degrees.
type Horizontal ΒΆ
Horizontal is a direction in the local horizontal (alt-az) frame. Azimuth is measured clockwise from true north and Altitude is the angle above the horizon; both are in degrees. A negative Altitude is below the horizon.
func (Horizontal) AboveHorizon ΒΆ
func (h Horizontal) AboveHorizon() bool
AboveHorizon reports whether the direction is above the geometric horizon.
type Observer ΒΆ
type Observer struct {
// Lat is the geographic latitude in degrees, positive north, in [-90, 90].
Lat float64
// Lng is the geographic longitude in degrees, positive east, in [-180, 180].
Lng float64
// TZ is the observer's local time zone. A nil value is treated as UTC.
TZ *time.Location
}
Observer is a location on the Earth's surface for which celestial positions are computed. Time is never captured here; it is always supplied as a parameter to the calculation functions, keeping the library stateless.
type Position ΒΆ
type Position struct {
Horizontal
Diameter AngularDiameter
}
Position is the apparent placement of a body: the direction to the center of its disc paired with the disc's apparent angular size. Pairing the center with the angular diameter lets a consumer size and place the disc and reason about alignment and overlap between bodies.
Directories
ΒΆ
| Path | Synopsis |
|---|---|
|
Package constellation identifies which of the 88 IAU constellations a celestial position falls in, and lists the constellations.
|
Package constellation identifies which of the 88 IAU constellations a celestial position falls in, and lists the constellations. |
|
Package earth adds Earth-bound conventions on top of the universal solar geometry in the sun package: named twilight bands, sunrise and sunset, solar noon, polar states, and atmospheric refraction.
|
Package earth adds Earth-bound conventions on top of the universal solar geometry in the sun package: named twilight bands, sunrise and sunset, solar noon, polar states, and atmospheric refraction. |
|
moon
Package moon provides the Earth vantage on Luna, the Earth's moon: its topocentric horizontal position and apparent size, its phase and illumination, its rise and set for an observer, and an arc track over a time span.
|
Package moon provides the Earth vantage on Luna, the Earth's moon: its topocentric horizontal position and apparent size, its phase and illumination, its rise and set for an observer, and an arc track over a time span. |
|
internal
|
|
|
angles
Package angles provides small, dependency-free helpers for working with angles expressed in degrees: conversion to and from radians, normalization into the range [0, 360), and clamping of declinations to [-90, 90].
|
Package angles provides small, dependency-free helpers for working with angles expressed in degrees: conversion to and from radians, normalization into the range [0, 360), and clamping of declinations to [-90, 90]. |
|
coordinates
Package coordinates converts celestial positions between the ecliptic, equatorial, and local horizontal (alt-az) frames.
|
Package coordinates converts celestial positions between the ecliptic, equatorial, and local horizontal (alt-az) frames. |
|
ephemeris
Package ephemeris implements the astronomical series this library needs, ported directly rather than pulled in as a dependency.
|
Package ephemeris implements the astronomical series this library needs, ported directly rather than pulled in as a dependency. |
|
julian
Package julian converts civil instants into the time quantities the ephemeris math depends on: the Julian Date, Greenwich and local mean sidereal time, and the mean obliquity of the ecliptic.
|
Package julian converts civil instants into the time quantities the ephemeris math depends on: the Julian Date, Greenwich and local mean sidereal time, and the mean obliquity of the ecliptic. |
|
Package project maps already-computed celestial positions, expressed in degrees, to canvas pixels.
|
Package project maps already-computed celestial positions, expressed in degrees, to canvas pixels. |
|
Package star provides a universal, observer-independent catalog of stars: the quantities that belong to a star itself, not to any vantage.
|
Package star provides a universal, observer-independent catalog of stars: the quantities that belong to a star itself, not to any vantage. |
|
Package sun provides universal Sun physics: quantities that depend only on the Sun itself, not on any observer, atmosphere, or vantage body.
|
Package sun provides universal Sun physics: quantities that depend only on the Sun itself, not on any observer, atmosphere, or vantage body. |