View Source Astro.Solar (Astro v1.1.0)
Implements sunrise and sunset according to the US NOAA algorithm which is based upon Astronomical Algorithms by Jean Meeus.
Summary
Functions
Returns the earth orbit eccentricity.
Returns the equation of time in minutes.
Returns the datetime of an equinox or solstice
Return approximate moment at or before tee when solar longitude just exceeded lambda degrees.
Returns the mean obliquity of the ecliptic in degrees.
Returns the obliquity correction in degrees.
Returns the solar declination in degrees.
Returns the solar longitude in degrees.
Return the moment UT of the first time at or after moment, tee, when the solar longitude will be lambda degrees.
Returns solar noon as minutes since midnight UTC.
Returns the suns apparent longitude in degrees.
Return the sun's equation of the center in degrees.
Returns the suns geometric mean anomoly in degrees.
Returns the sun's geometric mean longitude in degrees.
Returns the suns true longitude in degrees.
Returns the UTC time of sun's position for a given location as a float time-of-day.
Functions
Returns the earth orbit eccentricity.
Arguments
julian_centuries
is the any moment in time expressed as julian centuries.
Returns
- a unitless value of eccentricity as a
float
. A value of0
is a circular orbit, values between0
and1
form an elliptic orbit,1
is a parabolic escape orbit, and greater than1
is a hyperbola.
Notes
The orbital eccentricity of earth - and any astronomical object - is a dimensionless parameter that determines the amount by which its orbit around another body deviates from a perfect circle. The term derives its name from the parameters of conic sections, as every Kepler orbit is a conic section.
Returns the equation of time in minutes.
Arguments
julian_centuries
is the any moment in time expressed as julian centuries.
Returns
- The discrepency between apparent time and
mean solar time in minutes as a
float
.
Notes
The equation of time describes the discrepancy between two kinds of solar time. The word equation is used in the medieval sense of "reconcile a difference". The two times that differ are the apparent solar time, which directly tracks the diurnal motion of the Sun, and mean solar time, which tracks a theoretical mean Sun with uniform motion. Apparent solar time can be obtained by measurement of the current position (hour angle) of the Sun, as indicated (with limited accuracy) by a sundial. Mean solar time, for the same place, would be the time indicated by a steady clock set so that over the year its differences from apparent solar time would have a mean of zero.
During a year the equation of time varies as shown on the graph; its change from one year to the next is slight. Apparent time, and the sundial, can be ahead (fast) by as much as 16 min 33 s (around 3 November), or behind (slow) by as much as 14 min 6 s (around 11 February). The equation of time has zeros near 15 April, 13 June, 1 September, and 25 December. Ignoring very slow changes in the Earth's orbit and rotation, these events are repeated at the same times every tropical year. However, due to the non-integral number of days in a year, these dates can vary by a day or so from year to year.
The graph of the equation of time is closely approximated by the sum of two sine curves, one with a period of a year and one with a period of half a year. The curves reflect two astronomical effects, each causing a different non-uniformity in the apparent daily motion of the Sun relative to the stars:
the obliquity of the ecliptic (the plane of the Earth's annual orbital motion around the Sun), which is inclined by about 23.44 degrees relative to the plane of the Earth's equator; and
the eccentricity of the Earth's orbit around the Sun, which is about 0.0167.
The equation of time is constant only for a planet with zero axial tilt and zero orbital eccentricity. On Mars the difference between sundial time and clock time can be as much as 50 minutes, due to the considerably greater eccentricity of its orbit. The planet Uranus, which has an extremely large axial tilt, has an equation of time that makes its days start and finish several hours earlier or later depending on where it is in its orbit.
@spec equinox_and_solstice(pos_integer(), :march | :june | :september | :december) :: {:ok, DateTime.t()}
Returns the datetime of an equinox or solstice
Return approximate moment at or before tee when solar longitude just exceeded lambda degrees.
Returns the mean obliquity of the ecliptic in degrees.
Arguments
julian_centuries
is the any moment in time expressed as julian centuries.
Returns
- the mean obliquity of the ecliptic in
degrees as a
float
.
Notes
Obliquity, also known as tilt, is the angle between the rotation access of the earth from the orbital plane of the earth around the sun.
Earth's obliquity angle is measured from the imaginary line that runs perpendicular to another imaginary line; Earth's ecliptic plane or orbital plane . At the moment, Earth's obliquity is about 23.4 degrees and decreasing. We say 'at the moment' because the obliquity changes over time, although very, very slowly.
Returns the obliquity correction in degrees.
Arguments
julian_centuries
is the any moment in time expressed as julian centuries.
Returns
- the obliquity correction in
degrees as a
float
.
Returns the solar declination in degrees.
Arguments
julian_centuries
is the any moment in time expressed as julian centuries.
Returns
- the solar declination in degrees as
a
float
.
Notes
The solar declination is the angle between the direction of the center of the solar disk measured from Earth's center and the equatorial plane.
Returns the solar longitude in degrees.
Arguments
julian_centuries
is the any moment in time expressed as julian centuries.
Returns
- the solar longitude in degrees as
a
float
.
Notes
The solar longitude is the position of the sun on the celestial sphere along the ecliptic.
It is also an effective measure of the position of the earth (or any other sun-orbiting body) in its orbit around the sun, usually taken as zero at the moment of the vernal equinox.
Since it is based on how far the earth has moved in its orbit since the equinox, it is a measure of what time of the tropical year (the year of seasons) the planet is in, but without the inaccuracies of a calendar date, which is perturbed by leap years and calendar imperfections.
@spec solar_longitude_after(number(), Astro.Time.time()) :: Astro.Time.time()
Return the moment UT of the first time at or after moment, tee, when the solar longitude will be lambda degrees.
@spec solar_noon_utc(float(), Astro.longitude()) :: float()
Returns solar noon as minutes since midnight UTC.
Arguments
julian_centuries
is the any moment in time expressed as julian centuries.longitude
is the longitude in degrees of the location from which solar noon is to be measured.
Returns
- solar noon as a
float
number of minutes since midnight UTC.
Notes
Solar noon is the moment when the Sun passes a location's meridian and reaches its highest position in the sky. In most cases, it doesn't happen at 12 o'clock.
At solar noon, the Sun reaches its highest position in the sky as it passes the local meridian.
@spec sun_apparent_longitude(Astro.Time.julian_centuries()) :: float()
Returns the suns apparent longitude in degrees.
Arguments
julian_centuries
is the any moment in time expressed as julian centuries.
Returns
- equation of the center in degrees
as a
float
.
Notes
The apparent longitude is the sun's celestial longitude corrected for aberration and nutation as opposed to mean longitude.
An equinox is the instant when the Sun's apparent geocentric longitude is 0° (northward equinox) or 180° (southward equinox).
Return the sun's equation of the center in degrees.
Arguments
julian_centuries
is the any moment in time expressed as julian centuries.
Returns
- equation of the center in degrees
as a
float
.
Notes
In two-body, Keplerian orbital mechanics, the equation of the center is the angular difference between the actual position of a body in its elliptical orbit and the position it would occupy if its motion were uniform, in a circular orbit of the same period.
It is defined as the difference true anomaly, ν, minus mean anomaly, M, and is typically expressed a function of mean anomaly, M, and orbital eccentricity, e.
Returns the suns geometric mean anomoly in degrees.
Arguments
julian_centuries
is the any moment in time expressed as julian centuries.
Returns
- the mean anomoly in degrees as a
float
Notes
In celestial mechanics, the mean anomaly is the fraction of an elliptical orbit's period that has elapsed since the orbiting body passed periapsis, expressed as an angle which can be used in calculating the position of that body in the classical two-body problem.
It is the angular distance from the pericenter which a fictitious body would have if it moved in a circular orbit, with constant speed, in the same orbital period as the actual body in its elliptical orbit.
Returns the sun's geometric mean longitude in degrees.
Arguments
julian_centuries
is the any moment in time expressed as julian centuries.
Returns
- the mean solar longitude in degrees as a float.
Notes
Mean longitude, like mean anomaly, does not measure an angle between any physical objects. It is simply a convenient uniform measure of how far around its orbit a body has progressed since passing the reference direction. While mean longitude measures a mean position and assumes constant speed, true longitude measures the actual longitude and assumes the body has moved with its actual speed, which varies around its elliptical orbit.
The difference between the two is known as the equation of the center.
Returns the suns true longitude in degrees.
Arguments
julian_centuries
is the any moment in time expressed as julian centuries.
Returns
- the suns true longitude in degrees
as a
float
.
Notes
In celestial mechanics true longitude is the ecliptic longitude at which an orbiting body could actually be found if its inclination were zero.
Together with the inclination and the ascending node, the true longitude can tell us the precise direction from the central object at which the body would be located at a particular time.
@spec utc_sun_position(DateTime.t(), Geo.PointZ.t(), float(), :sunrise | :sunset) :: {:ok, float()} | {:error, :no_time}
Returns the UTC time of sun's position for a given location as a float time-of-day.
Arguments
date
is aDateTime.t()
in the UTC time zone.location
is anyGeo.PointZ.t/0
location.solar_elevation
is the required solar elevation in degrees (90 degrees for sunrise and sunset).mode
is:sunrise
or:sunset
.
Returns
{:ok, moment}
wheremoment
is float representing the number of hours after midnight for sunrise or sunset or{:error, :no_time}
if there is no sunrise/sunset for the given date at the given location. This can occur for very high latitudes in winter and summer.
Notes
This implementation is based on equations from Astronomical Algorithms, by Jean Meeus. The sunrise and sunset results are theoretically accurate to within a minute for locations between +/- 72° latitude, and within 10 minutes outside of those latitudes. However, due to variations in atmospheric composition, temperature, pressure and conditions, observed values may vary from calculations.