mountcontrol/cxx/tests/astrom_test.cpp
2025-03-19 17:31:03 +03:00

58 lines
1.3 KiB
C++

#include <fstream>
#include <iostream>
#include "../mount_astrom.h"
int main(int argc, char* argv[])
{
int ecode = 0;
if (argc < 2) {
std::cerr << "Usage: " << argv[0] << " bulletinA-filename\n";
exit(1);
}
std::ifstream ist(argv[1]);
if (!ist) {
std::cerr << "Invalid filename!\n";
exit(1);
}
mcc::astrom::MccIersBulletinA bullA;
bullA.dump(std::cout);
std::cout << "\n\n";
mcc::astrom::MccLeapSeconds lps;
lps.dump(std::cout);
std::cout << "\n\n";
bool ok = bullA.load(ist);
bullA.dump(std::cerr);
ist.close();
std::cout << "\n\n\n------------------\n";
auto now = std::chrono::system_clock::now();
std::cout << "LEAP SECS for now: " << lps[now].value_or(std::numeric_limits<double>::quiet_NaN()) << "\n";
std::cout << "DUT1 for now: " << bullA.DUT1(now).value_or(std::numeric_limits<double>::quiet_NaN()) << " (" << now
<< ")\n";
double mjd = 61077.4;
std::cout << "DUT1 for MJD = " << mjd << ": " << bullA.DUT1(mjd).value_or(std::numeric_limits<double>::quiet_NaN())
<< "\n";
auto st = mcc::astrom::mcc_julday(now, mjd);
std::cout << "MJD for now: " << std::setprecision(19) << mjd << " (" << now << ")\n";
return ecode;
}