...
This commit is contained in:
@@ -7,7 +7,6 @@
|
||||
*********************************/
|
||||
|
||||
#include <chrono>
|
||||
#include <unordered_map>
|
||||
#include <xsimd/xsimd.hpp>
|
||||
#include "utils.h"
|
||||
|
||||
@@ -136,6 +135,9 @@ static int mcc_julday(const std::chrono::system_clock::time_point& start_time,
|
||||
|
||||
/*
|
||||
* angles are in degrees or sexagimal string form
|
||||
*
|
||||
* returns
|
||||
* NaN if object is non-rising or "alt_limit" < 0, Inf is circumpolar
|
||||
*/
|
||||
template <traits::mcc_real_or_char_range AT,
|
||||
traits::mcc_real_or_char_range RT,
|
||||
@@ -159,6 +161,10 @@ double mcc_time_to_alt_limit(const AT& alt_limit,
|
||||
alt *= utils::deg2radCoeff;
|
||||
}
|
||||
|
||||
if (alt < 0.0) {
|
||||
return std::numeric_limits<double>::quiet_NaN();
|
||||
}
|
||||
|
||||
if constexpr (std::floating_point<RT>) {
|
||||
ra = RA * utils::deg2radCoeff;
|
||||
} else {
|
||||
@@ -180,6 +186,16 @@ double mcc_time_to_alt_limit(const AT& alt_limit,
|
||||
lat *= utils::deg2radCoeff;
|
||||
}
|
||||
|
||||
if (lat >= 0.0) { // north hemisphere
|
||||
if (dec < (lat - std::numbers::pi / 2.0)) { // never rises above horizont
|
||||
return std::numeric_limits<double>::quiet_NaN();
|
||||
}
|
||||
} else { // south hemisphere
|
||||
if (dec > (lat + std::numbers::pi / 2.0)) { // never rises above horizont
|
||||
return std::numeric_limits<double>::quiet_NaN();
|
||||
}
|
||||
}
|
||||
|
||||
double cos_ha = (std::sin(alt) - std::sin(dec) * std::sin(lat)) / std::cos(dec) / std::cos(lat);
|
||||
if (std::abs(cos_ha) > 1.0) { // circumpolar (it never sets below horizon)
|
||||
return std::numeric_limits<double>::infinity();
|
||||
@@ -199,6 +215,8 @@ double mcc_time_to_alt_limit(const AT& alt_limit,
|
||||
*
|
||||
*/
|
||||
|
||||
enum iers_db_state_t { IERS_DB_STATE_UNINITIALIZED, IERS_DB_STATE_OK, IERS_DB_STATE_PARSE_ERROR };
|
||||
|
||||
struct leapsecond_db_elem_t {
|
||||
double mjd;
|
||||
unsigned day, month;
|
||||
@@ -207,30 +225,13 @@ struct leapsecond_db_elem_t {
|
||||
double tai_utc; // TAI-UTC in seconds
|
||||
};
|
||||
|
||||
// typedef std::vector<leapsecond_db_elem_t> leapsecond_db_t;
|
||||
|
||||
struct leapsecond_db_t {
|
||||
std::chrono::system_clock::time_point expireDate;
|
||||
std::vector<leapsecond_db_elem_t> db;
|
||||
iers_db_state_t state = IERS_DB_STATE_UNINITIALIZED;
|
||||
std::chrono::system_clock::time_point expireDate{};
|
||||
std::vector<leapsecond_db_elem_t> db{};
|
||||
};
|
||||
|
||||
|
||||
// init to some known state
|
||||
static leapsecond_db_t CURRENT_LEAPSECONDS_DB;
|
||||
// = {
|
||||
// {41317.0, 1, 1, 1972, 10}, {41499.0, 1, 7, 1972, 11}, {41683.0, 1, 1, 1973, 12},
|
||||
// {42048.0, 1, 1, 1974, 13}, {42413.0, 1, 1, 1975, 14}, {42778.0, 1, 1, 1976, 15},
|
||||
// {43144.0, 1, 1, 1977, 16}, {43509.0, 1, 1, 1978, 17}, {43874.0, 1, 1, 1979, 18},
|
||||
// {44239.0, 1, 1, 1980, 19}, {44786.0, 1, 7, 1981, 20}, {45151.0, 1, 7, 1982, 21},
|
||||
// {45516.0, 1, 7, 1983, 22}, {46247.0, 1, 7, 1985, 23}, {47161.0, 1, 1, 1988, 24},
|
||||
// {47892.0, 1, 1, 1990, 25}, {48257.0, 1, 1, 1991, 26}, {48804.0, 1, 7, 1992, 27},
|
||||
// {49169.0, 1, 7, 1993, 28}, {49534.0, 1, 7, 1994, 29}, {50083.0, 1, 1, 1996, 30},
|
||||
// {50630.0, 1, 7, 1997, 31}, {51179.0, 1, 1, 1999, 32}, {53736.0, 1, 1, 2006, 33},
|
||||
// {54832.0, 1, 1, 2009, 34}, {56109.0, 1, 7, 2012, 35}, {57204.0, 1, 7, 2015, 36},
|
||||
// {57754.0, 1, 1, 2017, 37}
|
||||
|
||||
// };
|
||||
|
||||
|
||||
struct earth_orient_db_elem_t {
|
||||
int year;
|
||||
@@ -242,19 +243,23 @@ struct earth_orient_db_elem_t {
|
||||
|
||||
|
||||
struct earth_orient_db_t {
|
||||
iers_db_state_t state = IERS_DB_STATE_UNINITIALIZED;
|
||||
std::chrono::system_clock::time_point bulletinDate{};
|
||||
double tt_tai = 0.0; // TT-TAI
|
||||
std::vector<earth_orient_db_elem_t> db{};
|
||||
};
|
||||
|
||||
|
||||
static earth_orient_db_t CURRENT_EARTH_ORIENT_DB;
|
||||
|
||||
static bool mcc_parse_bulletinA(std::derived_from<std::basic_istream<char>> auto& stream, char comment_sym = '*')
|
||||
static earth_orient_db_t mcc_parse_bulletinA(std::derived_from<std::basic_istream<char>> auto& stream,
|
||||
char comment_sym = '*')
|
||||
{
|
||||
const std::regex bull_date_rx{
|
||||
"^ *[0-9]{1,2} +(January|February|March|April|May|June|July|August|September|October|November|December) "
|
||||
"+[0-9]{4,} +Vol\\. +[XMLCDVI]+ +No\\. +[0-9]+ *$"};
|
||||
|
||||
const std::regex bull_tt_tai_rx{"^ *TT += +TAI +\\+ +[0-9]+\\.[0-9]+ +seconds *$"};
|
||||
|
||||
const std::regex bull_tab_title_rx{"^ *MJD +x\\(arcsec\\) +y\\(arcsec\\) +UT1-UTC\\(sec\\) *$"};
|
||||
|
||||
// 2025 3 7 60741 0.0663 0.3341 0.04348
|
||||
@@ -302,6 +307,13 @@ static bool mcc_parse_bulletinA(std::derived_from<std::basic_istream<char>> auto
|
||||
continue;
|
||||
}
|
||||
|
||||
if (std::regex_match(sv.begin(), sv.end(), bull_tt_tai_rx)) {
|
||||
is.str({sv.begin(), sv.end()});
|
||||
std::string dummy;
|
||||
is >> dummy >> dummy >> dummy >> dummy >> db.tt_tai;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (std::regex_match(sv.begin(), sv.end(), bull_tab_title_rx)) {
|
||||
tab_state = TAB_STATE_START;
|
||||
continue;
|
||||
@@ -313,16 +325,17 @@ static bool mcc_parse_bulletinA(std::derived_from<std::basic_istream<char>> auto
|
||||
}
|
||||
|
||||
if (db.db.empty()) {
|
||||
return false;
|
||||
db.state = IERS_DB_STATE_PARSE_ERROR;
|
||||
} else {
|
||||
db.state = IERS_DB_STATE_OK;
|
||||
}
|
||||
|
||||
CURRENT_EARTH_ORIENT_DB = std::move(db);
|
||||
|
||||
return true;
|
||||
return db;
|
||||
}
|
||||
|
||||
|
||||
static bool mcc_parse_leapsecs(std::derived_from<std::basic_istream<char>> auto& stream, char comment_sym = '#')
|
||||
static leapsecond_db_t mcc_parse_leapsecs(std::derived_from<std::basic_istream<char>> auto& stream,
|
||||
char comment_sym = '#')
|
||||
{
|
||||
// # File expires on 28 December 2025
|
||||
const std::regex expr_date_rx{
|
||||
@@ -369,12 +382,12 @@ static bool mcc_parse_leapsecs(std::derived_from<std::basic_istream<char>> auto&
|
||||
}
|
||||
|
||||
if (db.db.empty()) {
|
||||
return false;
|
||||
db.state = IERS_DB_STATE_PARSE_ERROR;
|
||||
} else {
|
||||
db.state = IERS_DB_STATE_OK;
|
||||
}
|
||||
|
||||
CURRENT_LEAPSECONDS_DB = std::move(db);
|
||||
|
||||
return true;
|
||||
return db;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user