tempoch-cpp 0.5.3
Header-only C++ wrapper for tempoch
Loading...
Searching...
No Matches
eop.hpp
Go to the documentation of this file.
1#pragma once
2
15#include "ffi_core.hpp"
16#include <cmath>
17#include <optional>
18
19namespace tempoch {
20
21// ============================================================================
22// EopValues
23// ============================================================================
24
37struct EopValues {
39 double mjd_utc;
41 std::optional<double> pm_xp_arcsec;
43 std::optional<double> pm_yp_arcsec;
47 std::optional<double> lod_milliseconds;
49 std::optional<double> dx_milliarcsec;
51 std::optional<double> dy_milliarcsec;
54};
55
56// ============================================================================
57// Free functions
58// ============================================================================
59
66inline bool eop_covers(double mjd_utc) noexcept { return tempoch_eop_covers(mjd_utc); }
67
81inline std::optional<EopValues> eop_at(double mjd_utc) {
82 tempoch_eop_values_t raw{};
83 tempoch_status_t status = tempoch_eop_at(mjd_utc, &raw);
84
85 if (status == TEMPOCH_STATUS_T_UT1_HORIZON_EXCEEDED)
86 return std::nullopt;
87
88 check_status(status, "eop_at");
89
90 auto nan_to_opt = [](double v) -> std::optional<double> {
91 return std::isnan(v) ? std::nullopt : std::optional<double>{v};
92 };
93
94 return EopValues{
95 raw.mjd_utc,
96 nan_to_opt(raw.pm_xp_arcsec),
97 nan_to_opt(raw.pm_yp_arcsec),
98 raw.ut1_minus_utc,
99 nan_to_opt(raw.lod_milliseconds),
100 nan_to_opt(raw.dx_milliarcsec),
101 nan_to_opt(raw.dy_milliarcsec),
102 raw.ut1_observed != 0,
103 };
104}
105
106} // namespace tempoch
Error handling for the tempoch C++ wrapper.
std::optional< EopValues > eop_at(double mjd_utc)
Interpolate IERS EOP values at mjd_utc.
Definition eop.hpp:81
void check_status(tempoch_status_t status, const char *operation)
Check a tempoch_status_t and throw the appropriate exception on error.
Definition ffi_core.hpp:139
bool eop_covers(double mjd_utc) noexcept
Check whether EOP data is available for mjd_utc.
Definition eop.hpp:66
Interpolated IERS Earth Orientation Parameter values.
Definition eop.hpp:37
std::optional< double > dy_milliarcsec
ΔY celestial-pole offset (milliarcseconds). nullopt if absent.
Definition eop.hpp:51
std::optional< double > pm_xp_arcsec
Polar motion X component (arcseconds). nullopt if absent.
Definition eop.hpp:41
std::optional< double > dx_milliarcsec
ΔX celestial-pole offset (milliarcseconds). nullopt if absent.
Definition eop.hpp:49
std::optional< double > pm_yp_arcsec
Polar motion Y component (arcseconds). nullopt if absent.
Definition eop.hpp:43
double ut1_minus_utc
DUT1 = UT1 − UTC (seconds of time).
Definition eop.hpp:45
bool ut1_observed
True when both bracketing rows carry observed (I) data.
Definition eop.hpp:53
std::optional< double > lod_milliseconds
Excess length-of-day (milliseconds of time). nullopt if absent.
Definition eop.hpp:47
double mjd_utc
UTC MJD of the interpolation result.
Definition eop.hpp:39