18using namespace qtty::literals;
21 return (d == CrossingDirection::Rising) ?
"rising" :
"setting";
25 return (k == CulminationKind::Max) ?
"max" :
"min";
29 std::printf(
"%04d-%02u-%02u %02u:%02u:%02u", utc.year, utc.month, utc.day,
30 utc.hour, utc.minute, utc.second);
33static void print_periods(
const char* title,
const std::vector<Period>& periods,
34 std::size_t max_items = 4) {
35 std::printf(
"%s: %zu period(s)\n", title, periods.size());
37 (periods.size() < max_items) ? periods.size() : max_items;
38 for (std::size_t i = 0; i < n; ++i) {
39 const auto s = periods[i].start().to_utc();
40 const auto e = periods[i].end().to_utc();
41 std::printf(
" %zu) ", i + 1);
45 std::printf(
" (%.2f h)\n", periods[i].duration_days() * 24.0);
47 if (periods.size() > n) {
48 std::printf(
" ... (%zu more)\n", periods.size() - n);
53 const std::vector<CrossingEvent>& events,
54 std::size_t max_items = 6) {
55 std::printf(
"%s: %zu event(s)\n", title, events.size());
56 const std::size_t n = (events.size() < max_items) ? events.size() : max_items;
57 for (std::size_t i = 0; i < n; ++i) {
58 const auto t = events[i].time.to_utc();
59 std::printf(
" %zu) ", i + 1);
63 if (events.size() > n) {
64 std::printf(
" ... (%zu more)\n", events.size() - n);
69 const std::vector<CulminationEvent>& events,
70 std::size_t max_items = 6) {
71 std::printf(
"%s: %zu event(s)\n", title, events.size());
72 const std::size_t n = (events.size() < max_items) ? events.size() : max_items;
73 for (std::size_t i = 0; i < n; ++i) {
74 const auto t = events[i].time.to_utc();
75 std::printf(
" %zu) ", i + 1);
77 std::printf(
" alt=%.3f deg kind=%s\n", events[i].altitude.value(),
80 if (events.size() > n) {
81 std::printf(
" ... (%zu more)\n", events.size() - n);
86 std::printf(
"=== Altitude Events Example ===\n\n");
89 const auto start = MJD::from_utc({2026, 7, 15, 0, 0, 0});
90 const auto end = start + 2.0;
91 const Period window(start, end);
93 std::printf(
"Observer: Mauna Kea (lon=%.4f lat=%.4f h=%.0f m)\n",
94 obs.lon.value(), obs.lat.value(), obs.height.value());
95 std::printf(
"Window MJD: %.6f -> %.6f\n\n", start.value(), end.value());
102 const auto sun_cross =
sun::crossings(obs, window, -0.833_deg, opts);
104 print_periods(
"Sun below -18 deg (astronomical night)", sun_night);
119 const auto& vega =
VEGA;
120 const auto vega_above =
122 const auto vega_cross =
132 const auto dir_above =
134 const auto dir_below =
136 print_periods(
"Fixed ICRS direction above +30 deg", dir_above);
137 print_periods(
"Fixed ICRS direction below horizon", dir_below);
static void print_crossings(const char *title, const std::vector< CrossingEvent > &events, std::size_t max_items=6)
static const char * crossing_direction_name(CrossingDirection d)
static void print_periods(const char *title, const std::vector< Period > &periods, std::size_t max_items=4)
static const char * culmination_kind_name(CulminationKind k)
static void print_utc(const UTC &utc)
static void print_culminations(const char *title, const std::vector< CulminationEvent > &events, std::size_t max_items=6)
std::vector< Period > below_threshold(const spherical::direction::ICRS &dir, const Geodetic &obs, const Period &window, qtty::Degree threshold, const SearchOptions &opts={})
Find periods when a fixed ICRS direction is below a threshold.
std::vector< Period > above_threshold(const spherical::direction::ICRS &dir, const Geodetic &obs, const Period &window, qtty::Degree threshold, const SearchOptions &opts={})
Find periods when a fixed ICRS direction is above a threshold.
std::vector< CulminationEvent > culminations(const Geodetic &obs, const Period &window, const SearchOptions &opts={})
Find culmination events for the Moon.
std::vector< CrossingEvent > crossings(const Geodetic &obs, const Period &window, qtty::Degree threshold, const SearchOptions &opts={})
Find threshold-crossing events for the Moon.
std::vector< Period > above_threshold(const Geodetic &obs, const Period &window, qtty::Degree threshold, const SearchOptions &opts={})
Find periods when the Moon is above a threshold altitude.
std::vector< Period > above_threshold(const Star &s, const Geodetic &obs, const Period &window, qtty::Degree threshold, const SearchOptions &opts={})
Find periods when a star is above a threshold altitude.
std::vector< CulminationEvent > culminations(const Star &s, const Geodetic &obs, const Period &window, const SearchOptions &opts={})
Find culmination events for a star.
std::vector< CrossingEvent > crossings(const Star &s, const Geodetic &obs, const Period &window, qtty::Degree threshold, const SearchOptions &opts={})
Find threshold-crossing events for a star.
std::vector< CrossingEvent > crossings(const Geodetic &obs, const Period &window, qtty::Degree threshold, const SearchOptions &opts={})
Find threshold-crossing events for the Sun.
std::vector< Period > below_threshold(const Geodetic &obs, const Period &window, qtty::Degree threshold, const SearchOptions &opts={})
Find periods when the Sun is below a threshold altitude.
std::vector< CulminationEvent > culminations(const Geodetic &obs, const Period &window, const SearchOptions &opts={})
Find culmination events for the Sun.
const Geodetic MAUNA_KEA
Mauna Kea Observatory (Hawaii, USA).
Umbrella header for the siderust C++ wrapper library.
Options for altitude search algorithms.
SearchOptions & with_scan_step(double step)
Set a custom scan step.
SearchOptions & with_tolerance(double tol)
Set time tolerance.
A direction on the celestial sphere, compile-time tagged by frame.