This commit is contained in:
Timur A. Fatkhullin 2025-03-26 16:37:33 +03:00
parent b3fb445557
commit 91477e2d53
2 changed files with 43 additions and 3 deletions

View File

@ -55,6 +55,7 @@ template <traits::mcc_real_scalar_or_real_range_c ResT, traits::mcc_time_duratio
static int mcc_julday(traits::mcc_systime_c auto const& start_time,
ResT& mjd,
const DT& step = std::chrono::milliseconds(100))
requires(!std::is_pointer_v<std::decay_t<ResT>>)
{
size_t mjd_size = 0;
if constexpr (std::ranges::range<ResT>) {
@ -101,7 +102,7 @@ static int mcc_julday(traits::mcc_systime_c auto const& start_time,
constexpr size_t reg_size = xsimd::batch<double>::size;
size_t vec_size = mjd_size - mjd_size % reg_size;
xsimd::batch<double> res_reg{mjd_float};
xsimd::batch<double> res_reg(mjd_float);
xsimd::batch<double> step_reg = [d_step]<size_t... Is>(std::index_sequence<Is...>) {
return xsimd::batch<double>{(Is * d_step)...};
}(std::make_index_sequence<reg_size>{});
@ -111,7 +112,7 @@ static int mcc_julday(traits::mcc_systime_c auto const& start_time,
auto ptr = mjd.begin();
// vectorized part
for (; i < vec_size; i += vec_size) {
for (; i < vec_size; i += reg_size) {
res_reg += step_reg;
if constexpr (std::ranges::contiguous_range<ResT>) {
@ -143,6 +144,18 @@ static int mcc_julday(traits::mcc_systime_c auto const& start_time,
return 0;
}
template <typename ResT, traits::mcc_time_duration_c DT = std::chrono::milliseconds>
static int mcc_julday(traits::mcc_systime_c auto const& start_time,
ResT& mjd,
const DT& step = std::chrono::milliseconds(100))
requires std::is_pointer_v<std::decay_t<ResT>>
{
auto sp = std::span(mjd);
int ret = mcc_julday(start_time, sp, step);
return ret;
}
/*
* angles are in degrees or sexagimal string form
* RA and DEC are apparent!

View File

@ -68,12 +68,39 @@ int main(int argc, char* argv[])
// const double rr = 180.0 / std::numbers::pi * 60.0;
// std::cout << "A(arcmin) = " << A * rr << "; B(arcmin) = " << B * rr << "\n";
float alt_lim = 10.0;
std::string_view ra_str = "06:30:00.0", dec_str = "00:00:00.0";
std::cout << "\n\nTimes to object (RA = " << ra_str << ", DEC = " << dec_str << ") sets to given altitude ("
<< alt_lim << " degrees):\n";
using namespace std::chrono_literals;
double stm = mcc::astrom::mcc_time_to_alt_limit(10.0, "06:30:00.0", "00:00:00.0", 43.646711, 41.440732,
double stm = mcc::astrom::mcc_time_to_alt_limit(alt_lim, ra_str, dec_str, 43.646711, 41.440732,
std::chrono::system_clock::now(), 0.041s, 32.184s, 37.0s);
// auto stm_d = mcc::astrom::mcc_chrono_radians{stm};
std::cout << "STM: " << stm * 12.0 / std::numbers::pi * 60.0 << " minutes\n";
std::cout << "\n\n\n";
const size_t N = 1000;
double mjds[N];
now = std::chrono::system_clock::now();
st = mcc::astrom::mcc_julday(now, mjds, std::chrono::milliseconds(100));
std::cout << std::format("comp time for {} MJDs = {}\n", N, std::chrono::system_clock::now() - now);
std::cout << std::format("MIN MJD: {:.16f}; \nMAX MJD: {:.16f}\n", mjds[0], mjds[N - 1]);
double elong = 43.646711 * std::numbers::pi / 180.0;
double phi = 41.440732 * std::numbers::pi / 180.0;
double aob, zob, hob, dob, rob, eo;
now = std::chrono::system_clock::now();
for (auto& el : mjds) {
st = erfa::eraAtco13(1.343523, 0.32352345, 0.0, 0.0, 0.0, 0.0, ERFA_DJM0, el, 0.041, elong, phi, 2100.0, 0.0,
0.0, 700.0, 10.0, 0.8, 0.5, &aob, &zob, &hob, &dob, &rob, &eo);
}
std::cout << std::format(
"comp time for {} coordinate transf = {}\n", N,
std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - now));
return ecode;
}