CelestialCalendar 1.0.0 · unreleased development @ 67a7c4c79a4a4a6aa7e703c9e6f0039ae34bee82
Loading...
Searching...
No Matches
rise_set.hpp File Reference
#include <algorithm>
#include <array>
#include <chrono>
#include <cmath>
#include <concepts>
#include <cstddef>
#include <cstdint>
#include <format>
#include <optional>
#include <stdexcept>
#include <string_view>
#include <type_traits>
#include <vector>
#include "geolocation.hpp"
#include "toolbox.hpp"
#include "datetime.hpp"
#include "julian_day.hpp"
#include "coord_transform.hpp"
#include "sidereal_time.hpp"
#include "sun.hpp"
#include "moon.hpp"
#include "earth.hpp"
#include "earth/refraction.hpp"

Classes

struct  astro::rise_set::Result
 The result of a rise/transit/set calculation for one date. More...
struct  astro::rise_set::detail::BodyLocal
 A body's local hour angle and equatorial position at one instant. More...
struct  astro::rise_set::detail::AltitudeExtremum
 A refined local extremum of the altitude curve: its instant, kind, and value. More...
struct  astro::rise_set::detail::Solved
 A refined crossing and the |altitude − h₀| residual it left, in degrees. More...
struct  astro::rise_set::detail::DayWindow
 The TT endpoints of one half-open UT1 calendar day. More...

Namespaces

namespace  astro::rise_set
 Body-agnostic rise/transit/set engine.
namespace  astro
namespace  astro::rise_set::detail
namespace  astro::rise_set::sun
 Solar conventions and entry points: standard altitudes, twilight constants, and the transit-centered API wired to the Sun's ephemeris.
namespace  astro::rise_set::moon
 Lunar conventions and entry points: the Ch.15 standard altitude and the UT-day (almanac-style) API wired to the ELP2000-82B ephemeris.

Concepts

concept  astro::rise_set::BodyProvider
 A body position provider: apparent equatorial coordinates at one instant.

Typedefs

using astro::rise_set::GeoLocation
 Backward-compatible name for the common observer location type.
using astro::rise_set::detail::AltitudeGrid

Enumerations

enum class  astro::rise_set::Polar : uint8_t { astro::rise_set::NONE , astro::rise_set::DAY , astro::rise_set::NIGHT }
 The whole-day topology of a date: whether the body crosses h₀ at all, and if not, which side of h₀ it stays on. More...

Functions

auto astro::rise_set::detail::validate (const GeoLocation &location) -> void
 Validate an observer location, throwing on out-of-range or non-finite coordinates.
auto astro::rise_set::detail::jde_tt_to_jd_ut1 (const double jde_tt) -> double
 Convert a JDE (TT) to the JD (UT1) of the same instant.
template<BodyProvider P>
auto astro::rise_set::detail::body_local (const double jde_tt, const GeoLocation &location, const P &provider) -> BodyLocal
 Compute a body's local hour angle and equatorial coordinates for an observer.
template<BodyProvider P>
auto astro::rise_set::detail::altitude (const double jde_tt, const GeoLocation &location, const P &provider) -> toolbox::AngleDeg
 Compute a body's geometric altitude for an observer at one instant.
template<typename Func>
requires std::invocable<const Func&, double> and std::convertible_to<std::invoke_result_t<const Func&, double>, double>
auto astro::rise_set::detail::golden_section_argmin (const Func &f, const double a, const double b, const double tolerance=EXTREMUM_SEARCH_TOLERANCE_DAYS) -> double
 Find the argmin of a unimodal function on [a, b] by golden-section search.
template<typename Func>
auto astro::rise_set::detail::altitude_grid (const Func &f, const double start_jde_tt, const double step_days) -> AltitudeGrid
 Sample every grid endpoint in increasing TT order, including both window ends.
template<typename Func>
auto astro::rise_set::detail::interior_extrema (const Func &f, const double start_jde_tt, const double step_days, const AltitudeGrid &values) -> std::vector< AltitudeExtremum >
 Refine strict direction changes; a flat plateau does not define an interior extremum.
template<typename Func>
auto astro::rise_set::detail::append_edge_extrema (const Func &f, const double lo_jde_tt, const double hi_jde_tt, std::vector< AltitudeExtremum > &extrema) -> void
 Probe a cell with a missing outer grid neighbor for an interior minimum and maximum.
template<typename Func>
requires std::invocable<const Func&, double> and std::convertible_to<std::invoke_result_t<const Func&, double>, double>
auto astro::rise_set::detail::find_extrema (const Func &f, const double a, const double b) -> std::vector< AltitudeExtremum >
 Find every local extremum of the altitude curve on [a, b], in time order.
template<BodyProvider P>
auto astro::rise_set::detail::min_altitude_jde (const double transit, const bool before, const GeoLocation &location, const P &provider) -> double
 Find the instant of minimum altitude in the half-arc adjacent to a transit.
auto astro::rise_set::detail::validate_pm90 (const char *name, const double angle_deg) -> void
 Reject a named non-finite angle or one outside [-90°, 90°].
auto astro::rise_set::detail::validate_rise_set_inputs (const double transit_jde_tt, const GeoLocation &location, const toolbox::AngleDeg &h0) -> void
 Validate rise_set_jde's inputs.
template<typename Func>
requires std::invocable<const Func&, double> and std::convertible_to<std::invoke_result_t<const Func&, double>, double>
auto astro::rise_set::detail::crossing_in_bracket (const Func &f, const double lo_jde, const double hi_jde, const bool rising) -> std::optional< Solved >
 Try to solve one altitude crossing inside a bracket.
template<BodyProvider P>
auto astro::rise_set::detail::polish_transit (const double estimate_jde, const GeoLocation &location, const P &provider) -> double
 Polish a transit estimate into the instant of upper culmination (H = 0).
auto astro::rise_set::detail::day_window (const std::chrono::year_month_day &ymd_ut1) -> DayWindow
 Convert both UT1 midnights independently; a UT1 day is not exactly one TT day.
auto astro::rise_set::detail::crossing_error (const std::string_view caller, const bool rising, const Solved &solved, const double lo_jde_tt, const double hi_jde_tt) -> std::runtime_error
 Describe a bracketed altitude crossing that failed its caller's residual guard.
template<typename Func>
auto astro::rise_set::detail::scan_day_crossings (const Func &f, const DayWindow &window, const std::vector< AltitudeExtremum > &extrema, Result &result) -> void
 Scan monotone segments in time order, trying rise before set and keeping later crossings.
template<typename Func>
auto astro::rise_set::detail::day_polar (const Func &h, const DayWindow &window, const std::vector< AltitudeExtremum > &extrema, const toolbox::AngleDeg &h0) -> Polar
 Classify a crossing-free day from its global altitude bounds, including the window ends.
auto astro::rise_set::hour_angle_at_altitude (const toolbox::AngleDeg &δ, const toolbox::AngleDeg &φ, const toolbox::AngleDeg &h0) -> std::optional< toolbox::AngleDeg >
 Compute the hour angle at which a body of declination δ reaches altitude h₀, as seen from latitude φ.
template<BodyProvider P>
auto astro::rise_set::rise_set_jde (const double transit_jde_tt, const bool is_rise, const GeoLocation &location, const toolbox::AngleDeg &h0, const P &provider) -> std::optional< double >
 Compute the instant at which a body crosses altitude h₀, before (rise) or after (set) a given transit.
template<BodyProvider P>
auto astro::rise_set::calculate_around_transit (const double transit_jde_tt, const GeoLocation &location, const toolbox::AngleDeg &h0, const P &provider) -> Result
 Compute rise, transit, and set around a known transit (transit-centered window).
template<BodyProvider P>
auto astro::rise_set::transit_in_window (const double t0_jde_tt, const double t1_jde_tt, const GeoLocation &location, const P &provider) -> std::optional< double >
 Find a body's first upper culmination inside a time window, if there is one.
template<BodyProvider P>
auto astro::rise_set::calculate_day (const std::chrono::year_month_day &ymd_ut1, const GeoLocation &location, const toolbox::AngleDeg &h0, const P &provider) -> Result
 Compute rise, transit, and set for one UT1 calendar day (almanac semantics).
auto astro::rise_set::sun::h0_from (const astro::earth::refraction::Params &p={}) -> toolbox::AngleDeg
 Convert atmospheric conditions to the sunrise/sunset altitude convention.
auto astro::rise_set::sun::transit_jde (const std::chrono::year_month_day &ymd_ut1, const GeoLocation &location) -> double
 Compute the instant of the Sun's upper culmination (solar transit / solar noon) on a date.
auto astro::rise_set::sun::rise_set_jde (const double transit_jde_tt, const bool is_rise, const GeoLocation &location, const toolbox::AngleDeg &h0=STANDARD_ALTITUDE) -> std::optional< double >
 Compute the instant at which the Sun crosses altitude h₀, before (sunrise) or after (sunset) a given transit.
auto astro::rise_set::sun::calculate (const std::chrono::year_month_day &ymd_ut1, const GeoLocation &location, const toolbox::AngleDeg &h0=STANDARD_ALTITUDE) -> Result
 Compute sunrise, transit, and sunset for a date and location.
auto astro::rise_set::moon::horizontal_parallax (const double jde_tt) -> toolbox::AngleRad
 The Moon's equatorial horizontal parallax Π at one instant.
auto astro::rise_set::moon::h0 (const toolbox::AngleRad &Π, const astro::earth::refraction::Params &p={}) -> toolbox::AngleDeg
 The standard altitude of the Moon's center at rise/set: 0.7275·Π − refraction.
auto astro::rise_set::moon::calculate (const std::chrono::year_month_day &ymd_ut1, const GeoLocation &location, const astro::earth::refraction::Params &p={}) -> Result
 Compute moonrise, lunar transit, and moonset for one UT1 calendar day.

Variables

constexpr double astro::rise_set::COS_H0_CLAMP_TOLERANCE
 How far past ±1 cos(H₀) may land and still count as a grazing event rather than a polar day/night verdict.
constexpr double astro::rise_set::POLAR_DENOMINATOR_EPSILON
 Below this |cos φ · cos δ| the hour-angle equation is treated as degenerate (observer at a geographic pole, or the body at a celestial pole).
constexpr double astro::rise_set::TRANSIT_BRACKET_HALF_WIDTH_DAYS
 The half-width of the root bracket around a transit estimate, in days.
constexpr double astro::rise_set::RISE_SET_BRACKET_HALF_WIDTH_DAYS
 The half-width of the first-try root bracket around the rise/set estimate, in days.
constexpr double astro::rise_set::LOWER_CULMINATION_OFFSET_DAYS
 The nominal offset of the adjacent lower culmination from a transit, in days — the mean-time estimate used to center the altitude-minimum search window.
constexpr double astro::rise_set::MIN_SEARCH_HALF_WIDTH_DAYS
 The half-width of the altitude-minimum search window around the nominal lower culmination, in days.
constexpr double astro::rise_set::TRANSIT_RESIDUAL_GUARD_DEG
 The residual guard on a transit root, in degrees of hour angle.
constexpr double astro::rise_set::RISE_SET_RESIDUAL_GUARD_DEG
 The residual guard on a rise/set root, in degrees of altitude.
constexpr double astro::rise_set::EXTREMUM_SEARCH_TOLERANCE_DAYS
 Convergence tolerance for the golden-section extremum searches, in days.
constexpr double astro::rise_set::EDGE_PROBE_TOLERANCE_DAYS
 Coarser tolerance for the edge-cell probes of find_extrema, in days.
constexpr std::size_t astro::rise_set::detail::EXTREMUM_SCAN_CELLS
constexpr auto astro::rise_set::sun::STANDARD_ALTITUDE
 The standard altitude of the Sun's center at rise/set: -0°50' = -0.8333…°.
constexpr toolbox::AngleDeg astro::rise_set::sun::CIVIL_TWILIGHT
 The Sun's altitude at civil twilight: -6°.
constexpr toolbox::AngleDeg astro::rise_set::sun::NAUTICAL_TWILIGHT
 The Sun's altitude at nautical twilight: -12°.
constexpr toolbox::AngleDeg astro::rise_set::sun::ASTRONOMICAL_TWILIGHT
 The Sun's altitude at astronomical twilight: -18°.
constexpr auto astro::rise_set::sun::provider
 The Sun's position provider: apparent equatorial coordinates at one instant (TT).
constexpr auto astro::rise_set::moon::apparent_equatorial
 The Moon's position provider: apparent geocentric equatorial coordinates at one instant (TT) — an alias of astro::moon::equatorial_coord::apparent, the lunar counterpart of the solar provider.