Compare commits

...

87 Commits

Author SHA1 Message Date
b51c7c2aad mcc_ccte_iers.h: fix std::regex for parsing IERS Bulletin A data
mcc_coord_test.cpp: add IERS Bulletine A loading testing
2026-10-12 17:08:27 +03:00
33e79075fc update IERS data 2026-10-12 16:14:16 +03:00
2916bd4541 it seems now there is no deadlocks 2026-10-12 16:02:30 +03:00
42f43cc1a1 try to find dead-lock
mcc_telemetry.h: use mutex-free non-timedout implementation
2026-10-12 11:10:40 +03:00
cd97ed875f update mcc_ccte_iers_default.h 2026-06-06 10:55:04 +03:00
b3c7584205 fix 2026-06-05 09:49:18 +03:00
5984bc5204 mcc_keyvalue.h: add fix to prevent GCC compilation crashing 2026-06-05 09:44:30 +03:00
d865e51ffb ... 2026-06-03 12:06:01 +03:00
6e6f230f4d mcc_keyvalue.h: fix "-Wsubobject-linkage" GCC-warning 2026-06-02 12:05:26 +03:00
a1f17f0d76 mcc_keyvalue.h: fix MccKeyValueHolder class coping and moving
mcc_pzone.h: add copy and move constructors and operator=
2026-06-02 10:53:40 +03:00
e1a136a839 mcc_keyvalue.h: fix for working with non-default constructible record
values, more smart 'set' operations for range values
mcc_epoch.h: add constructors
mcc_traits.h: add mcc_fixed_size_range and mcc_non_resizable_range
concepts
mcc_deserializer.h: fixes compilation issues for  mcc_fixed_size_range and
mcc_non_resizable_range ranges
2026-05-28 17:39:30 +03:00
3497850e1f ... 2026-05-27 16:18:11 +03:00
e9c329d88f mcc_bsplines.h: fixes (use right macro names for the Fortran subroutines) 2026-05-23 11:17:51 +03:00
445a029a2f mcc_bsplines.h: use of FC_GLOBAL macro to correct call FITPACK
subroutines mangled names
fitpack/CMakeLists.txt: add non-empty SYMBOL_NAMESPACE to fix generated
'insert' macro (interference with STL containers 'insert' methods) macro
issue
various fixes
2026-05-22 12:51:33 +03:00
8e5e3631ba fixes 2026-05-22 09:28:25 +03:00
304464dbda fixes 2026-05-21 18:27:43 +03:00
4b5a390987 mcc_pzone.h: add serializer/deserializer of the implemented prohibited
zone clases
mcc_pcm.h: add mccGenerateBsplineKnots function
mcc_deserializer.h: fixes
2026-05-21 12:20:32 +03:00
47ba7342e7 fix 2026-05-20 17:57:18 +03:00
c5f17b7403 mcc_pcm.h: add serializer and deserializer of the MccDefaultPCM enum 2026-05-19 17:24:14 +03:00
8d36444c51 mcc_keyvalue.h: worked 2026-05-19 12:16:22 +03:00
d40ecb5df7 ... 2026-05-18 17:19:40 +03:00
d8130cede2 mcc_keyvalue.h: add serial_pars field to mcc_keyvalue_record_c concept,
rewrite MccKeyValueHolder class methods accordinally
2026-05-18 12:21:53 +03:00
056c152d49 mcc_keyvalue.h: worked 2026-05-18 11:24:17 +03:00
Timur A. Fatkhullin
9630751a4d mcc_epoch.h: fix operator=(std::chrono::time_point)
class MccKeyValueHolder: developing ...
2026-05-17 22:33:31 +03:00
3dbe4c12b7 mcc_keyvalue.h: developing ... 2026-05-16 15:08:09 +03:00
537207cd16 add mcc_keyvalue.h: rewrite KEY-VALUE HOLDER class 2026-05-15 18:44:26 +03:00
f314c6a2c5 add mcc_keyvalue.h: rewrite KEY-VALUE HOLDER class 2026-05-15 18:40:02 +03:00
af0268218a mcc_pcm.h: add mccDefaultPCMTypeString free function
mcc_pcm_fit.h: computeModel now accepts PCM data type of MccDefaultPCM-
class descendants
2026-05-14 18:08:29 +03:00
fb70e9099b mcc_utils.h: fix sexagesimalReprRx std::regex 2026-05-13 17:46:08 +03:00
b5d73e54d3 fixes in PCM computing, fitting 2026-04-17 16:15:50 +03:00
4fbe456892 ... 2026-04-17 10:03:55 +03:00
bfe5b4f286 ... 2026-04-17 09:55:37 +03:00
Timur A. Fatkhullin
be8397a0b4 ... 2026-04-16 23:36:24 +03:00
3373bedb39 ... 2026-04-16 18:42:11 +03:00
a8a1d9a763 rewrite PCM fitter algorithm (mcc_pcm_fit.h, MccPcmFitter class) 2026-04-16 12:14:17 +03:00
c21b4c4771 ... 2026-04-13 19:03:42 +03:00
59560704b0 rewrite celestial angles classes (add normalization) 2026-04-10 11:31:49 +03:00
6dc684bb4a add IERS Bulletins updater bash-script 2026-04-03 11:36:20 +03:00
2bc797b9ae ... 2026-04-01 17:34:26 +03:00
9fbd628493 ... 2026-04-01 17:29:46 +03:00
4bd4d156b5 ... 2026-04-01 09:26:22 +03:00
dc77f98db0 force SPDLOG-library fetching (do not use of system one) 2026-04-01 08:46:55 +03:00
f6482edd3f ... 2026-03-30 09:57:15 +03:00
Timur A. Fatkhullin
a4b3a32d94 ... 2026-03-29 22:18:46 +03:00
8116658e0d ... 2026-03-27 17:29:46 +03:00
d4721d7b67 ... 2026-03-27 12:25:36 +03:00
Timur A. Fatkhullin
d3bab396a2 ... 2026-03-26 23:21:20 +03:00
a8275f3786 ... 2026-03-26 17:40:36 +03:00
4b0569bfea ... 2026-03-25 16:10:34 +03:00
2c561f7259 ... 2026-03-24 16:45:37 +03:00
0182844af6 ... 2026-03-24 02:43:17 +03:00
7d327a3276 ... 2026-03-23 23:26:27 +03:00
9959f45b46 ... 2026-03-23 18:06:41 +03:00
48d1bf37f7 ... 2026-03-20 17:20:46 +03:00
Timur A. Fatkhullin
9ad5bfb09b ... 2026-03-18 23:34:46 +03:00
40d36545f3 ... 2026-03-18 19:00:23 +03:00
3dbd68b21c ... 2026-03-17 17:18:11 +03:00
Timur A. Fatkhullin
617bcec1a1 MccDefaultPCM: reverse PCM is computed with using partial derivatives
(start developing)
2026-03-17 00:23:44 +03:00
Timur A. Fatkhullin
28352f6c64 ... 2026-03-12 23:50:47 +03:00
Timur A. Fatkhullin
0ee87ccbf9 ... 2026-03-12 22:20:56 +03:00
f2aad0807d fix addToPath 2026-03-12 10:44:34 +03:00
Timur A. Fatkhullin
de097d6db2 MccMovementPathFile: addToPath(mcc_telemetry_data_c auto const& tdata) add
mount current speed saving
2026-03-11 22:49:24 +03:00
be69df5068 fix trajectory file saving 2026-03-04 14:35:10 +03:00
5d498d47f8 ... 2026-03-02 19:11:41 +03:00
Timur A. Fatkhullin
5e9e8897f0 ... 2026-03-01 23:42:34 +03:00
Timur A. Fatkhullin
f72d0bc3f0 ... 2026-02-28 10:39:49 +03:00
d42fa37a04 rewrite MccGenericMovementControls class (single thread version) 2026-02-27 18:02:02 +03:00
ba03832ce6 add hardwareShutdown method requirement to mcc_hardware_c concept 2026-02-27 14:24:45 +03:00
3bd12bcf6d ... 2026-02-27 12:29:45 +03:00
Timur A. Fatkhullin
6199af6392 ... 2026-02-26 22:13:23 +03:00
4401616d44 ... 2026-02-26 18:28:22 +03:00
2f10fa2796 ... 2026-02-26 14:20:30 +03:00
8aa58b727b ... 2026-02-26 12:13:39 +03:00
d9cb52f755 ... 2026-02-25 18:08:21 +03:00
09a234ddc9 ... 2026-02-25 10:58:01 +03:00
76cebec136 ... 2026-02-24 17:43:38 +03:00
e0b3ef225d ... 2026-02-23 11:38:23 +03:00
32ed709222 ... 2026-02-20 17:39:25 +03:00
f8162779d6 ... 2026-02-20 14:44:14 +03:00
e6004a6c8a ... 2026-02-20 12:08:21 +03:00
099c6056d7 ... 2026-02-19 18:49:30 +03:00
18e6a99267 ... 2026-02-18 18:50:55 +03:00
889d4ff3b2 ... 2026-02-18 16:22:58 +03:00
53245002c5 ... 2026-02-18 14:14:32 +03:00
d11222a07f ... 2026-02-18 12:12:48 +03:00
0ffee8eceb ... 2026-02-18 11:04:35 +03:00
de98ead539 ... 2026-02-18 10:49:27 +03:00
34 changed files with 6513 additions and 1011 deletions

View File

@@ -27,6 +27,12 @@ option(
ON
)
option(
USE_EIGEN3
"Use of Eigen3 library as dependency for implemetation of PCM construction"
ON
)
option(USE_BSPLINE_PCM "Use of FITPACK bivariate splines for PCM" ON)
option(
@@ -42,16 +48,34 @@ find_package(Threads REQUIRED)
include(FetchContent)
include(ExternalProject)
# ******** Eigen3 LIBRARY *******
if(USE_EIGEN3)
find_package(Eigen3 CONFIG)
if(TARGET Eigen3::Eigen)
message(STATUS "Eigen3 library was found!")
else()
message(STATUS \tfetch Eigen3 ...)
FetchContent_Declare(
eigen
GIT_REPOSITORY "https://gitlab.com/libeigen/eigen.git"
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE
OVERRIDE_FIND_PACKAGE
)
FetchContent_MakeAvailable(eigen)
find_package(Eigen3 REQUIRED CONFIG)
endif()
endif()
# ******* SPDLOG LIBRARY *******
if(USE_SPDLOG)
set(SPDLOG_USE_STD_FORMAT ON CACHE INTERNAL "Use of C++20 std::format")
set(SPDLOG_FMT_EXTERNAL OFF CACHE INTERNAL "Turn off external fmt library")
set(USE_SPDLOG_SYSTEM ON)
find_package(spdlog CONFIG)
if(NOT ${spdlog_FOUND})
# find_package(spdlog CONFIG NO_MODULE)
# if(NOT ${spdlog_FOUND})
message(STATUS "\tfetch spdlog-lib ...")
FetchContent_Declare(
spdlog
@@ -66,13 +90,22 @@ if(USE_SPDLOG)
OVERRIDE_FIND_PACKAGE
)
set(SPDLOG_USE_STD_FORMAT ON CACHE INTERNAL "Use of C++20 std::format")
set(SPDLOG_FMT_EXTERNAL OFF CACHE INTERNAL "Turn off external fmt library")
set(SPDLOG_INSTALL ON CACHE BOOL "Enable spdlog installation" FORCE)
FetchContent_MakeAvailable(spdlog)
find_package(spdlog REQUIRED CONFIG)
# find_package(spdlog REQUIRED CONFIG)
set(USE_SPDLOG_SYSTEM OFF)
endif()
# else()
# set(SPDLOG_USE_STD_FORMAT ON CACHE INTERNAL "Use of C++20 std::format")
# set(SPDLOG_FMT_EXTERNAL
# OFF
# CACHE INTERNAL
# "Turn off external fmt library"
# )
# endif()
endif()
# ******* ERFA LIBRARY *******
@@ -215,10 +248,12 @@ set(MCC_SRC
include/mcc/mcc_pcm.h
include/mcc/mcc_telemetry.h
include/mcc/mcc_movement_controls.h
include/mcc/mcc_generic_movecontrols.h
include/mcc/mcc_serialization_common.h
include/mcc/mcc_deserializer.h
include/mcc/mcc_serializer.h
include/mcc/mcc_generic_mount.h
include/mcc/mcc_keyvalue.h
)
if(USE_SPDLOG)
@@ -249,6 +284,14 @@ if(USE_BSPLINE_PCM)
add_subdirectory(fitpack)
endif()
if(USE_EIGEN3)
list(
APPEND MCC_SRC
include/mcc/mcc_pcm_construct.h
include/mcc/mcc_pcm_fit.h
)
endif()
add_library(${PROJECT_NAME} INTERFACE ${MCC_SRC})
target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_23)
target_include_directories(
@@ -265,7 +308,14 @@ endif()
if(USE_BSPLINE_PCM)
target_compile_definitions(${PROJECT_NAME} INTERFACE USE_BSPLINE_PCM)
target_link_libraries(${PROJECT_NAME} INTERFACE fitpack)
target_link_directories(${PROJECT_NAME} INTERFACE "$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/fitpack>")
target_link_directories(
${PROJECT_NAME}
INTERFACE "$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/fitpack>"
)
endif()
if(USE_EIGEN3)
target_link_libraries(${PROJECT_NAME} INTERFACE Eigen3::Eigen)
endif()
if(USE_ASIO)
@@ -273,9 +323,15 @@ if(USE_ASIO)
endif()
if(USE_SPDLOG)
target_compile_definitions(
${PROJECT_NAME}
INTERFACE SPDLOG_USE_STD_FORMAT=1 SPDLOG_FMT_EXTERNAL=0
)
target_link_libraries(${PROJECT_NAME} INTERFACE spdlog::spdlog_header_only)
# target_compile_definitions(${PROJECT_NAME} INTERFACE SPDLOG_USE_STD_FORMAT=1 SPDLOG_FMT_EXTERNAL=0)
target_compile_definitions(${PROJECT_NAME} INTERFACE SPDLOG_USE_STD_FORMAT=1)
# target_compile_definitions(
# ${PROJECT_NAME}
# INTERFACE SPDLOG_USE_STD_FORMAT=1
# )
endif()
if(BUILD_TESTS)
@@ -293,6 +349,15 @@ if(BUILD_TESTS)
add_executable(mcc_fitpack_test tests/mcc_fitpack_test.cpp)
target_link_libraries(mcc_fitpack_test PRIVATE ${PROJECT_NAME})
add_executable(mcc_pcm_test tests/mcc_pcm_test.cpp)
target_link_libraries(mcc_pcm_test PRIVATE ${PROJECT_NAME})
add_executable(mcc_pcm_z1000_test tests/mcc_pcm_z1000_test.cpp)
target_link_libraries(mcc_pcm_z1000_test PRIVATE ${PROJECT_NAME})
add_executable(mcc_keyvalue_test tests/mcc_keyvalue_test.cpp)
target_link_libraries(mcc_keyvalue_test PRIVATE ${PROJECT_NAME})
else()
# This is just a stub to allow access to the path and library settings for the ${PROJECT_NAME} target during development
add_executable(just_stub EXCLUDE_FROM_ALL main.cpp)

View File

@@ -21,31 +21,33 @@ include(FortranCInterface)
FortranCInterface_HEADER(
FortranCInterface.h
MACRO_NAMESPACE "FC_"
# SYMBOL_NAMESPACE "fp_"
SYMBOL_NAMESPACE ""
SYMBOL_NAMESPACE "fitpack_"
#SYMBOL_NAMESPACE ""
# SYMBOLS ${func_str}
SYMBOLS ${func_name}
)
FortranCInterface_VERIFY(CXX)
# set(FITPACK_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE)
# include_directories(${BSPLINES_INCLUDE_DIR})
# set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
# add_library(fitpack_project STATIC EXCLUDE_FROM_ALL ${src_files} mcc_bsplines.h)
# add_library(fitpack_project STATIC EXCLUDE_FROM_ALL ${src_files})
add_library(fitpack_project STATIC ${src_files})
# get_target_property(FP_LIBDIR fitpack_project LIBRARY_OUTPUT_DIRECTORY)
# message(STATUS "FP_LIBDIR: ${FP_LIBDIR}")
add_library(fitpack STATIC IMPORTED GLOBAL)
set_target_properties(
fitpack
PROPERTIES
IMPORTED_LOCATION ${CMAKE_BINARY_DIR}/fitpack/libfitpack_project.a
IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/libfitpack_project.a
# PROPERTIES IMPORTED_LOCATION ${FP_LIBDIR}/libfitpack_project.a
# IMPORTED_LOCATION ${CMAKE_BINARY_DIR}/fitpack/libfitpack_project.a
)
set_target_properties(
fitpack
PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES
"${CMAKE_CURRENT_BINARY_DIR}"
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}"
# "${CMAKE_CURRENT_SOURCE_DIR};${CMAKE_CURRENT_BINARY_DIR}"
)
add_dependencies(fitpack fitpack_project)

View File

@@ -104,6 +104,48 @@ public:
NORM_KIND_90_90, // [-90,90]
};
// varous angle normalization
template <norm_kind_t KIND>
static double normalizeAngle(double ang)
{
ang = std::fmod(ang, MCC_TWO_PI); // to the range of [0, 2*PI]
if constexpr (KIND == NORM_KIND_0_360) {
if (ang < 0.0) {
ang += MCC_TWO_PI;
}
} else if constexpr (KIND == NORM_KIND_0_180) {
if (ang < -std::numbers::pi) {
ang += MCC_TWO_PI;
} else if (ang < 0.0) {
ang = -ang;
} else if (ang > std::numbers::pi) {
ang = MCC_TWO_PI - ang;
}
} else if constexpr (KIND == NORM_KIND_180_180) {
if (ang > std::numbers::pi) {
ang -= MCC_TWO_PI;
} else if (ang < -std::numbers::pi) {
ang += MCC_TWO_PI;
}
} else if constexpr (KIND == NORM_KIND_90_90) {
if (ang >= 1.5 * std::numbers::pi) {
ang -= MCC_TWO_PI;
} else if (ang >= MCC_HALF_PI) {
ang = std::numbers::pi - ang;
} else if (ang <= -1.5 * std::numbers::pi) {
ang += MCC_TWO_PI;
} else if (ang <= -MCC_HALF_PI) {
ang = -(std::numbers::pi + ang);
}
} else {
static_assert(false, "UNKNOWN ANGLE NORMALIZATION TYPE!");
}
return ang;
}
MccAngle() = default;
// by default 'val' is in radians
@@ -179,41 +221,42 @@ public:
template <norm_kind_t KIND>
MccAngle& normalize()
{
_angleInRads = std::fmod(_angleInRads, std::numbers::pi * 2.0);
if constexpr (KIND == NORM_KIND_0_360) {
if (_angleInRads < 0.0) {
_angleInRads += 2.0 * std::numbers::pi;
}
} else if constexpr (KIND == NORM_KIND_0_180) {
if (_angleInRads < -std::numbers::pi) {
// _angleInRads = 2.0 * std::numbers::pi + _angleInRads;
_angleInRads = MCC_TWO_PI + _angleInRads;
} else if (_angleInRads < 0.0) {
_angleInRads = -_angleInRads;
}
} else if constexpr (KIND == NORM_KIND_180_180) {
if (_angleInRads > std::numbers::pi) {
// _angleInRads = 2.0 * std::numbers::pi - _angleInRads;
_angleInRads = MCC_TWO_PI - _angleInRads;
} else if (_angleInRads < -std::numbers::pi) {
// _angleInRads += 2.0 * std::numbers::pi;
_angleInRads += MCC_TWO_PI;
}
} else if constexpr (KIND == NORM_KIND_90_90) {
if (_angleInRads >= 1.5 * std::numbers::pi) {
_angleInRads = _angleInRads - 2.0 * std::numbers::pi;
} else if (_angleInRads >= std::numbers::pi / 2.0) {
_angleInRads = std::numbers::pi - _angleInRads;
} else if (_angleInRads <= -1.5 * std::numbers::pi) {
// _angleInRads += 2.0 * std::numbers::pi;
_angleInRads += MCC_TWO_PI;
} else if (_angleInRads <= -std::numbers::pi / 2.0) {
_angleInRads = -(std::numbers::pi + _angleInRads);
}
}
_angleInRads = MccAngle::normalizeAngle<KIND>(_angleInRads);
return *this;
// _angleInRads = std::fmod(_angleInRads, MCC_TWO_PI);
// if constexpr (KIND == NORM_KIND_0_360) {
// if (_angleInRads < 0.0) {
// _angleInRads += 2.0 * std::numbers::pi;
// }
// } else if constexpr (KIND == NORM_KIND_0_180) {
// if (_angleInRads < -std::numbers::pi) {
// _angleInRads = MCC_TWO_PI + _angleInRads;
// } else if (_angleInRads < 0.0) {
// _angleInRads = -_angleInRads;
// }
// } else if constexpr (KIND == NORM_KIND_180_180) {
// if (_angleInRads > std::numbers::pi) {
// _angleInRads -= MCC_TWO_PI;
// } else if (_angleInRads < -std::numbers::pi) {
// _angleInRads += MCC_TWO_PI;
// }
// } else if constexpr (KIND == NORM_KIND_90_90) {
// if (_angleInRads >= 1.5 * std::numbers::pi) {
// // _angleInRads = _angleInRads - 2.0 * std::numbers::pi;
// _angleInRads -= MCC_TWO_PI;
// } else if (_angleInRads >= std::numbers::pi / 2.0) {
// _angleInRads = std::numbers::pi - _angleInRads;
// } else if (_angleInRads <= -1.5 * std::numbers::pi) {
// _angleInRads += MCC_TWO_PI;
// } else if (_angleInRads <= -std::numbers::pi / 2.0) {
// _angleInRads = -(std::numbers::pi + _angleInRads);
// }
// }
// return *this;
}
MccAngle& normalize()
@@ -433,25 +476,38 @@ static T1 operator/(const T1& v1, const T2& v2)
std::string MccAngleFancyString(std::convertible_to<MccAngle> auto const& ang,
std::format_string<double> val_fmt = "{}")
std::format_string<double> val_fmt = "{:.2f}")
{
using ang_t = std::decay_t<decltype(ang)>;
std::string s;
double abs_ang;
if constexpr (std::is_arithmetic_v<std::decay_t<decltype(ang)>>) {
if constexpr (std::is_arithmetic_v<ang_t>) {
abs_ang = std::abs(ang);
} else {
abs_ang = std::abs(MccAngle{ang});
}
if (abs_ang < 1.0_arcmins) {
if constexpr (std::derived_from<ang_t, MccAngle>) {
std::format_to(std::back_inserter(s), val_fmt, ang.arcsecs());
} else {
std::format_to(std::back_inserter(s), val_fmt, MccAngle{ang}.arcsecs());
}
s += " arcsecs";
} else if (abs_ang < 1.0_degs) {
if constexpr (std::derived_from<ang_t, MccAngle>) {
std::format_to(std::back_inserter(s), val_fmt, ang.arcmins());
} else {
std::format_to(std::back_inserter(s), val_fmt, MccAngle{ang}.arcmins());
}
s += " arcmins";
} else {
if constexpr (std::derived_from<ang_t, MccAngle>) {
std::format_to(std::back_inserter(s), val_fmt, ang.degrees());
} else {
std::format_to(std::back_inserter(s), val_fmt, MccAngle{ang}.degrees());
}
s += " degs";
}
@@ -461,6 +517,115 @@ std::string MccAngleFancyString(std::convertible_to<MccAngle> auto const& ang,
/* HELPER TYPES TO REPERESENT ANGLES ON THE CELESTIAL SPHERE */
template <MccAngle::norm_kind_t NORM_KIND>
class MccNormalizedAngle : public MccAngle
{
public:
template <typename... CtorArgTs>
MccNormalizedAngle(CtorArgTs&&... args) : MccAngle(std::forward<CtorArgTs>(args)...)
{
normalize<NORM_KIND>();
}
MccNormalizedAngle(MccNormalizedAngle const&) = default;
MccNormalizedAngle(MccNormalizedAngle&&) = default;
MccNormalizedAngle& operator=(MccNormalizedAngle const&) = default;
MccNormalizedAngle& operator=(MccNormalizedAngle&&) = default;
template <typename VT>
MccNormalizedAngle& operator=(VT&& value)
requires std::is_arithmetic_v<VT>
{
_angleInRads = value;
normalize<NORM_KIND>();
}
};
class MccAngleRA_ICRS : public MccNormalizedAngle<MccAngle::NORM_KIND_0_360>
{
public:
using MccNormalizedAngle<MccAngle::NORM_KIND_0_360>::MccNormalizedAngle;
};
class MccAngleDEC_ICRS : public MccNormalizedAngle<MccAngle::NORM_KIND_90_90>
{
public:
using MccNormalizedAngle<MccAngle::NORM_KIND_90_90>::MccNormalizedAngle;
};
class MccAngleRA_APP : public MccNormalizedAngle<MccAngle::NORM_KIND_0_360>
{
public:
using MccNormalizedAngle<MccAngle::NORM_KIND_0_360>::MccNormalizedAngle;
};
class MccAngleDEC_APP : public MccNormalizedAngle<MccAngle::NORM_KIND_90_90>
{
public:
using MccNormalizedAngle<MccAngle::NORM_KIND_90_90>::MccNormalizedAngle;
};
class MccAngleRA_OBS : public MccNormalizedAngle<MccAngle::NORM_KIND_0_360>
{
public:
using MccNormalizedAngle<MccAngle::NORM_KIND_0_360>::MccNormalizedAngle;
};
class MccAngleDEC_OBS : public MccNormalizedAngle<MccAngle::NORM_KIND_90_90>
{
public:
using MccNormalizedAngle<MccAngle::NORM_KIND_90_90>::MccNormalizedAngle;
};
class MccAngleHA_APP : public MccNormalizedAngle<MccAngle::NORM_KIND_180_180>
{
public:
using MccNormalizedAngle<MccAngle::NORM_KIND_180_180>::MccNormalizedAngle;
};
class MccAngleHA_OBS : public MccNormalizedAngle<MccAngle::NORM_KIND_180_180>
{
public:
using MccNormalizedAngle<MccAngle::NORM_KIND_180_180>::MccNormalizedAngle;
};
class MccAngleAZ : public MccNormalizedAngle<MccAngle::NORM_KIND_0_360>
{
public:
using MccNormalizedAngle<MccAngle::NORM_KIND_0_360>::MccNormalizedAngle;
};
class MccAngleZD : public MccNormalizedAngle<MccAngle::NORM_KIND_0_180>
{
public:
using MccNormalizedAngle<MccAngle::NORM_KIND_0_180>::MccNormalizedAngle;
};
class MccAngleALT : public MccNormalizedAngle<MccAngle::NORM_KIND_90_90>
{
public:
using MccNormalizedAngle<MccAngle::NORM_KIND_90_90>::MccNormalizedAngle;
};
class MccAngleLON : public MccNormalizedAngle<MccAngle::NORM_KIND_0_360>
{
public:
using MccNormalizedAngle<MccAngle::NORM_KIND_0_360>::MccNormalizedAngle;
};
class MccAngleLAT : public MccNormalizedAngle<MccAngle::NORM_KIND_90_90>
{
public:
using MccNormalizedAngle<MccAngle::NORM_KIND_90_90>::MccNormalizedAngle;
};
/*
class MccNamedAngle : public MccAngle
{
public:
@@ -558,7 +723,7 @@ public:
using MccNamedAngle::MccNamedAngle;
// using MccAngle::MccAngle;
};
*/
class MccAngleX : public MccAngle // some co-longitude coordinate
{
@@ -574,17 +739,17 @@ public:
class MccAngleLAT : public MccAngle
{
public:
using MccAngle::MccAngle;
};
// class MccAngleLAT : public MccAngle
// {
// public:
// using MccAngle::MccAngle;
// };
class MccAngleLON : public MccAngle
{
public:
using MccAngle::MccAngle;
};
// class MccAngleLON : public MccAngle
// {
// public:
// using MccAngle::MccAngle;
// };
class MccAngleUnknown : public MccAngle
{
@@ -648,7 +813,7 @@ static constexpr bool mcc_is_app_coordpair(MccCoordPairKind kind)
};
static constexpr std::string_view MCC_COORDPAIR_KIND_RADEC_ICRS_STR = "RADEC-IRCS";
static constexpr std::string_view MCC_COORDPAIR_KIND_RADEC_ICRS_STR = "RADEC-ICRS";
static constexpr std::string_view MCC_COORDPAIR_KIND_RADEC_APP_STR = "RADEC-APP";
static constexpr std::string_view MCC_COORDPAIR_KIND_RADEC_OBS_STR = "RADEC-OBS";
static constexpr std::string_view MCC_COORDPAIR_KIND_HADEC_APP_STR = "HADEC-APP";

View File

@@ -7,7 +7,12 @@
#include <FortranCInterface.h>
extern "C" {
void surfit(int* iopt,
/* fitting on XY-grid */
void fitpack_surfit(int* iopt,
// void surfit(int* iopt,
int* m,
double* x,
double* y,
@@ -38,7 +43,9 @@ void surfit(int* iopt,
int* kwrk,
int* ier);
void bispev(double* tx,
/* XY-grid */
void fitpack_bispev(double* tx,
// void bispev(double* tx,
int* nx,
double* ty,
int* ny,
@@ -56,7 +63,9 @@ void bispev(double* tx,
int* kwrk,
int* ier);
void parder(double* tx,
/* XY-grid */
void fitpack_parder(double* tx,
// void parder(double* tx,
int* nx,
double* ty,
int* ny,
@@ -76,8 +85,9 @@ void parder(double* tx,
int* kwrk,
int* ier);
void sphere(int* iopt,
/* fitting on sphere */
void fitpack_sphere(int* iopt,
// void sphere(int* iopt,
int* m,
double* teta,
double* phi,
@@ -100,8 +110,46 @@ void sphere(int* iopt,
int* iwrk,
int* kwrk,
int* ier);
}
/* calculation for set of points (not grid) */
void fitpack_bispeu(double* tx,
// void bispeu(double* tx,
int* nx,
double* ty,
int* ny,
double* c,
int* kx,
int* ky,
double* x,
double* y,
double* z,
int* m,
double* wrk,
int* lwrk,
int* ier);
/* calculation for set of points (not grid) */
void fitpack_pardeu(double* tx,
// void pardeu(double* tx,
int* nx,
double* ty,
int* ny,
double* c,
int* kx,
int* ky,
int* nux,
int* nuy,
double* x,
double* y,
double* z,
int* m,
double* wrk,
int* lwrk,
int* iwrk,
int* kwrk,
int* ier);
}
namespace mcc::bsplines
@@ -217,23 +265,15 @@ int fitpack_sphere_smooth(const TethaT& tetha,
if constexpr (std::ranges::contiguous_range<WeightT>) {
auto weight_ptr = const_cast<double*>(std::ranges::data(weight));
sphere(&iopt, &m, tetha_ptr, phi_ptr, func_ptr, weight_ptr, &s_par, &nt, &np, &eps, &ntest, tetha_knots_ptr,
&npest, phi_knots_ptr, std::ranges::data(coeffs), &resi2_sum, wrk1.data(), &lwrk1, wrk2.data(), &lwrk2,
iwrk.data(), &kwrk, &res);
// sphere(&iopt, &m, std::ranges::data(tetha), std::ranges::data(phi), std::ranges::data(func),
// std::ranges::data(weight), &s_par, &ntest, &npest, &eps, &ntest, std::ranges::data(tetha_knots),
// &npest, std::ranges::data(phi_knots), std::ranges::data(coeffs), &resi2_sum, wrk1.data(), &lwrk1,
// wrk2.data(), &lwrk2, iwrk.data(), &kwrk, &res);
fitpack_sphere(&iopt, &m, tetha_ptr, phi_ptr, func_ptr, weight_ptr, &s_par, &nt, &np, &eps, &ntest,
tetha_knots_ptr, &npest, phi_knots_ptr, std::ranges::data(coeffs), &resi2_sum, wrk1.data(),
&lwrk1, wrk2.data(), &lwrk2, iwrk.data(), &kwrk, &res);
} else {
std::vector<double> weight_vec(m, weight);
sphere(&iopt, &m, tetha_ptr, phi_ptr, func_ptr, weight_vec.data(), &s_par, &nt, &np, &eps, &ntest,
tetha_knots_ptr, &npest, phi_knots_ptr, std::ranges::data(coeffs), &resi2_sum, wrk1.data(), &lwrk1,
wrk2.data(), &lwrk2, iwrk.data(), &kwrk, &res);
// res = sphere(&iopt, &m, std::ranges::data(tetha), std::ranges::data(phi), std::ranges::data(func),
// weight_vec.data(), &s_par, &ntest, &npest, &eps, &ntest, std::ranges::data(tetha_knots), &npest,
// std::ranges::data(phi_knots), std::ranges::data(coeffs), &resi2_sum, wrk1.get(), &lwrk1,
// wrk2.get(), &lwrk2, iwrk.get(), &kwrk, &res);
fitpack_sphere(&iopt, &m, tetha_ptr, phi_ptr, func_ptr, weight_vec.data(), &s_par, &nt, &np, &eps, &ntest,
tetha_knots_ptr, &npest, phi_knots_ptr, std::ranges::data(coeffs), &resi2_sum, wrk1.data(),
&lwrk1, wrk2.data(), &lwrk2, iwrk.data(), &kwrk, &res);
}
@@ -275,7 +315,7 @@ template <std::ranges::contiguous_range TXT,
std::ranges::contiguous_range YT,
std::ranges::contiguous_range CoeffT,
std::ranges::contiguous_range FuncT>
int fitpack_eval_spl2d(const TXT& tx,
int fitpack_eval_spl2d_grid(const TXT& tx,
const TYT& ty,
const CoeffT& coeffs,
const XT& x,
@@ -327,13 +367,79 @@ int fitpack_eval_spl2d(const TXT& tx,
auto x_ptr = const_cast<double*>(std::ranges::data(x));
auto y_ptr = const_cast<double*>(std::ranges::data(y));
bispev(tx_ptr, &ntx, ty_ptr, &nty, coeffs_ptr, &kx, &ky, x_ptr, &mx, y_ptr, &my, std::ranges::data(func),
fitpack_bispev(tx_ptr, &ntx, ty_ptr, &nty, coeffs_ptr, &kx, &ky, x_ptr, &mx, y_ptr, &my, std::ranges::data(func),
wrk.data(), &lwrk, iwrk.data(), &kwrk, &ier);
return ier;
}
/* for set of points */
template <std::ranges::contiguous_range TXT,
std::ranges::contiguous_range TYT,
std::ranges::contiguous_range XT,
std::ranges::contiguous_range YT,
std::ranges::contiguous_range CoeffT,
std::ranges::contiguous_range FuncT>
int fitpack_eval_spl2d(const TXT& tx,
const TYT& ty,
const CoeffT& coeffs,
const XT& x,
const YT& y,
FuncT& func,
int kx = 3,
int ky = 3)
{
static_assert(std::same_as<std::ranges::range_value_t<TXT>, double> &&
std::same_as<std::ranges::range_value_t<TYT>, double> &&
std::same_as<std::ranges::range_value_t<XT>, double> &&
std::same_as<std::ranges::range_value_t<YT>, double> &&
std::same_as<std::ranges::range_value_t<CoeffT>, double> &&
std::same_as<std::ranges::range_value_t<FuncT>, double>,
"Input ranges elements type must be double!");
if (kx < 0 || ky < 0) {
return 10;
}
if (std::ranges::size(x) != std::ranges::size(y)) {
return 10;
}
int m = std::ranges::size(x);
int ier = 0;
int ntx = std::ranges::size(tx);
int nty = std::ranges::size(ty);
auto n_coeffs = (ntx - kx - 1) * (nty - ky - 1);
if (std::ranges::size(coeffs) < n_coeffs) {
return 10;
}
if (std::ranges::size(func) < m) {
std::ranges::fill_n(std::back_inserter(func), m - std::ranges::size(func), 0.0);
}
auto tx_ptr = const_cast<double*>(std::ranges::data(tx));
auto ty_ptr = const_cast<double*>(std::ranges::data(ty));
auto coeffs_ptr = const_cast<double*>(std::ranges::data(coeffs));
auto x_ptr = const_cast<double*>(std::ranges::data(x));
auto y_ptr = const_cast<double*>(std::ranges::data(y));
int lwrk = kx + ky + 2;
std::vector<double> wrk(lwrk);
fitpack_bispeu(tx_ptr, &ntx, ty_ptr, &nty, coeffs_ptr, &kx, &ky, x_ptr, y_ptr, std::ranges::data(func), &m,
wrk.data(), &lwrk, &ier);
// bispeu(tx_ptr, &ntx, ty_ptr, &nty, coeffs_ptr, &kx, &ky, x_ptr, y_ptr, std::ranges::data(func), &m, wrk.data(),
// &lwrk, &ier);
return ier;
}
// scalar x,y version
template <std::ranges::contiguous_range TXT,
std::ranges::contiguous_range TYT,
@@ -366,4 +472,179 @@ int fitpack_eval_spl2d(const TXT& tx,
return fitpack_eval_spl2d(tx, ty, coeffs, xv, yv, fv, kx, ky);
}
} // namespace mcc::fitpack
/* partial derivatives */
template <std::ranges::contiguous_range TXT,
std::ranges::contiguous_range TYT,
std::ranges::contiguous_range XT,
std::ranges::contiguous_range YT,
std::ranges::contiguous_range CoeffT,
std::ranges::contiguous_range PderT>
int fitpack_parder_spl2d_grid(const TXT& tx,
const TYT& ty,
const CoeffT& coeffs,
const XT& x,
const YT& y,
PderT& pder,
int dx, // partial derivatives order along X
int dy, // partial derivatives order along Y
int kx = 3,
int ky = 3)
{
static_assert(std::same_as<std::ranges::range_value_t<TXT>, double> &&
std::same_as<std::ranges::range_value_t<TYT>, double> &&
std::same_as<std::ranges::range_value_t<XT>, double> &&
std::same_as<std::ranges::range_value_t<YT>, double> &&
std::same_as<std::ranges::range_value_t<CoeffT>, double> &&
std::same_as<std::ranges::range_value_t<PderT>, double>,
"Input ranges elements type must be double!");
if (kx < 0 || ky < 0 || dx < 0 || dy < 0) {
return 10;
}
int ntx = std::ranges::size(tx);
int nty = std::ranges::size(ty);
auto n_coeffs = (ntx - kx - 1) * (nty - ky - 1);
if (std::ranges::size(coeffs) < n_coeffs) {
return 10;
}
int mx = std::ranges::size(x), my = std::ranges::size(y);
int N = mx * my;
if (std::ranges::size(pder) < N) {
std::ranges::fill_n(std::back_inserter(pder), N - std::ranges::size(pder), 0.0);
}
// mx >=1, my >=1, 0 <= nux < kx, 0 <= nuy < ky, kwrk>=mx+my
// lwrk>=mx*(kx+1-nux)+my*(ky+1-nuy)+(nx-kx-1)*(ny-ky-1),
// compute sizes of working arrays according parder.f
int lwrk = mx * (kx + 1 - dx) + my * (ky + 1 - dy) + (ntx - kx - 1) * (nty - ky - 1);
std::vector<double> wrk(lwrk);
int kwrk = mx + my;
std::vector<int> iwrk(kwrk);
auto tx_ptr = const_cast<double*>(std::ranges::data(tx));
auto ty_ptr = const_cast<double*>(std::ranges::data(ty));
auto coeffs_ptr = const_cast<double*>(std::ranges::data(coeffs));
auto x_ptr = const_cast<double*>(std::ranges::data(x));
auto y_ptr = const_cast<double*>(std::ranges::data(y));
int ier = 0;
fitpack_parder(tx_ptr, &ntx, ty_ptr, &nty, coeffs_ptr, &kx, &ky, &dx, &dy, x_ptr, &mx, y_ptr, &my,
std::ranges::data(pder), wrk.data(), &lwrk, iwrk.data(), &kwrk, &ier);
return ier;
}
template <std::ranges::contiguous_range TXT,
std::ranges::contiguous_range TYT,
std::ranges::contiguous_range XT,
std::ranges::contiguous_range YT,
std::ranges::contiguous_range CoeffT,
std::ranges::contiguous_range PderT>
int fitpack_parder_spl2d(const TXT& tx,
const TYT& ty,
const CoeffT& coeffs,
const XT& x,
const YT& y,
PderT& pder,
int dx, // partial derivatives order along X
int dy, // partial derivatives order along Y
int kx = 3,
int ky = 3)
{
static_assert(std::same_as<std::ranges::range_value_t<TXT>, double> &&
std::same_as<std::ranges::range_value_t<TYT>, double> &&
std::same_as<std::ranges::range_value_t<XT>, double> &&
std::same_as<std::ranges::range_value_t<YT>, double> &&
std::same_as<std::ranges::range_value_t<CoeffT>, double> &&
std::same_as<std::ranges::range_value_t<PderT>, double>,
"Input ranges elements type must be double!");
if (kx < 0 || ky < 0 || dx < 0 || dy < 0) {
return 10;
}
int ntx = std::ranges::size(tx);
int nty = std::ranges::size(ty);
auto n_coeffs = (ntx - kx - 1) * (nty - ky - 1);
if (std::ranges::size(coeffs) < n_coeffs) {
return 10;
}
int m = std::ranges::size(x);
if (std::ranges::size(x) != std::ranges::size(y)) {
return 10;
}
if (std::ranges::size(pder) < m) {
std::ranges::fill_n(std::back_inserter(pder), m - std::ranges::size(pder), 0.0);
}
auto tx_ptr = const_cast<double*>(std::ranges::data(tx));
auto ty_ptr = const_cast<double*>(std::ranges::data(ty));
auto coeffs_ptr = const_cast<double*>(std::ranges::data(coeffs));
auto x_ptr = const_cast<double*>(std::ranges::data(x));
auto y_ptr = const_cast<double*>(std::ranges::data(y));
int ier = 0;
int lwrk = m * (kx + 1 - dx) + m * (ky + 1 - dy) + (ntx - kx - 1) * (nty - ky - 1);
std::vector<double> wrk(lwrk);
int kwrk = 2 * m;
std::vector<int> iwrk(kwrk);
fitpack_pardeu(tx_ptr, &ntx, ty_ptr, &nty, coeffs_ptr, &kx, &ky, &dx, &dy, x_ptr, y_ptr, std::ranges::data(pder),
&m, wrk.data(), &lwrk, iwrk.data(), &kwrk, &ier);
return ier;
}
// scalar version
template <std::ranges::contiguous_range TXT,
std::ranges::contiguous_range TYT,
typename XT,
typename YT,
std::ranges::contiguous_range CoeffT,
typename PderT>
int fitpack_parder_spl2d(const TXT& tx,
const TYT& ty,
const CoeffT& coeffs,
const XT& x,
const YT& y,
PderT& pder,
int dx, // partial derivatives order along X
int dy, // partial derivatives order along Y
int kx = 3,
int ky = 3)
{
static_assert(std::same_as<std::ranges::range_value_t<TXT>, double> &&
std::same_as<std::ranges::range_value_t<TYT>, double> &&
std::same_as<std::ranges::range_value_t<CoeffT>, double>,
"Input ranges elements type must be double!");
static_assert(
std::convertible_to<XT, double> && std::convertible_to<YT, double> && std::convertible_to<PderT, double>,
"XT, YT and FuncT types must be a scalar convertible to double!");
auto xv = std::vector<double>(1, x);
auto yv = std::vector<double>(1, y);
auto pv = std::vector<double>(1, pder);
return fitpack_parder_spl2d(tx, ty, coeffs, xv, yv, pv, dx, dy, kx, ky);
}
} // namespace mcc::bsplines

View File

@@ -479,8 +479,12 @@ private:
inline static const std::regex bull_tab_title_rx{"^ *MJD +x\\(arcsec\\) +y\\(arcsec\\) +UT1-UTC\\(sec\\) *$"};
// inline static const std::regex bull_tab_vals_rx{
// "^ *[0-9]{4,} +[0-9]{1,2} +[0-9]{1,2} +[0-9]{5,} +[0-9]+\\.[0-9]+
// +[0-9]+\\.[0-9]+ +[0-9]+\\.[0-9]+ *$"};
inline static const std::regex bull_tab_vals_rx{
"^ *[0-9]{4,} +[0-9]{1,2} +[0-9]{1,2} +[0-9]{5,} +[0-9]+\\.[0-9]+ +[0-9]+\\.[0-9]+ +[0-9]+\\.[0-9]+ *$"};
"^ *[0-9]{4,} +[0-9]{1,2} +[0-9]{1,2} +[0-9]{5,} +(\\+|\\-)?[0-9]+\\.[0-9]+ +(\\+|\\-)?[0-9]+\\.[0-9]+ "
"+(\\+|\\-)?[0-9]+\\.[0-9]+ *$"};
time_point_t _date;

View File

@@ -15,10 +15,10 @@ static std::string MCC_DEFAULT_LEAP_SECONDS_FILE = R"--(
# Value of TAI-UTC in second valid beetween the initial value until
# the epoch given on the next line. The last line reads that NO
# leap second was introduced since the corresponding date
# Updated through IERS Bulletin 71 issued in January 2026
# Updated through IERS Bulletin 72 issued in July 2026
#
#
# File expires on 28 December 2026
# File expires on 28 June 2027
#
#
# MJD Date TAI-UTC (s)
@@ -67,7 +67,7 @@ static std::string MCC_DEFAULT_IERS_BULLETIN_A_FILE = R"--(
* *
* Rapid Service/Prediction of Earth Orientation *
**********************************************************************
8 January 2026 Vol. XXXIX No. 002
8 October 2026 Vol. XXXIX No. 041
______________________________________________________________________
GENERAL INFORMATION:
MJD = Julian Date - 2 400 000.5 days
@@ -76,14 +76,14 @@ static std::string MCC_DEFAULT_IERS_BULLETIN_A_FILE = R"--(
where pi = 3.14159265... and T is the date in Besselian years.
TT = TAI + 32.184 seconds
DUT1= (UT1-UTC) transmitted with time signals
= +0.1 seconds beginning 10 July 2025 at 0000 UTC
= 0.0 seconds beginning 09 April 2026 at 0000 UTC
Beginning 1 January 2017:
TAI-UTC = 37.000 000 seconds
***********************************************************************
* ANNOUNCEMENTS: *
* *
* There will NOT be a leap second introduced in UTC *
* at the end of June 2026. *
* at the end of December 2026. *
* *
* The primary source for IERS Rapid Service/Prediction Center (RS/PC) *
* data products is the official IERS RS/PC website: *
@@ -116,47 +116,13 @@ static std::string MCC_DEFAULT_IERS_BULLETIN_A_FILE = R"--(
IERS Rapid Service
MJD x error y error UT1-UTC error
" " " " s s
26 1 2 61042 0.10962 .00009 0.33249 .00009 0.074152 0.000020
26 1 3 61043 0.10827 .00009 0.33355 .00009 0.074367 0.000021
26 1 4 61044 0.10690 .00009 0.33455 .00009 0.074487 0.000020
26 1 5 61045 0.10554 .00009 0.33551 .00009 0.074361 0.000015
26 1 6 61046 0.10404 .00009 0.33628 .00009 0.073991 0.000015
26 1 7 61047 0.10253 .00009 0.33692 .00009 0.073470 0.000012
26 1 8 61048 0.10121 .00009 0.33746 .00009 0.072861 0.000008
IERS Final Values
MJD x y UT1-UTC
" " s
25 11 2 60981 0.1750 0.3194 0.09220
25 11 3 60982 0.1735 0.3187 0.09112
25 11 4 60983 0.1718 0.3187 0.09005
25 11 5 60984 0.1699 0.3183 0.08916
25 11 6 60985 0.1679 0.3182 0.08854
25 11 7 60986 0.1659 0.3179 0.08822
25 11 8 60987 0.1640 0.3171 0.08814
25 11 9 60988 0.1630 0.3163 0.08819
25 11 10 60989 0.1625 0.3158 0.08820
25 11 11 60990 0.1615 0.3153 0.08801
25 11 12 60991 0.1602 0.3151 0.08763
25 11 13 60992 0.1583 0.3154 0.08711
25 11 14 60993 0.1564 0.3157 0.08644
25 11 15 60994 0.1545 0.3160 0.08566
25 11 16 60995 0.1530 0.3163 0.08494
25 11 17 60996 0.1511 0.3167 0.08433
25 11 18 60997 0.1491 0.3165 0.08390
25 11 19 60998 0.1474 0.3163 0.08366
25 11 20 60999 0.1456 0.3161 0.08357
25 11 21 61000 0.1437 0.3157 0.08363
25 11 22 61001 0.1419 0.3149 0.08381
25 11 23 61002 0.1398 0.3143 0.08403
25 11 24 61003 0.1380 0.3136 0.08426
25 11 25 61004 0.1373 0.3137 0.08431
25 11 26 61005 0.1360 0.3146 0.08417
25 11 27 61006 0.1351 0.3149 0.08377
25 11 28 61007 0.1343 0.3153 0.08305
25 11 29 61008 0.1334 0.3153 0.08209
25 11 30 61009 0.1325 0.3157 0.08097
25 12 1 61010 0.1316 0.3160 0.07984
26 10 2 61315 0.17334 .00009 0.32459 .00009 -0.023137 0.000021
26 10 3 61316 0.17258 .00009 0.32394 .00009 -0.023648 0.000022
26 10 4 61317 0.17187 .00009 0.32345 .00009 -0.024220 0.000021
26 10 5 61318 0.17095 .00009 0.32294 .00009 -0.025006 0.000022
26 10 6 61319 0.16982 .00009 0.32250 .00009 -0.026011 0.000022
26 10 7 61320 0.16879 .00009 0.32217 .00009 -0.027264 0.000023
26 10 8 61321 0.16813 .00009 0.32221 .00009 -0.028742 0.000022
_______________________________________________________________________
@@ -164,480 +130,423 @@ static std::string MCC_DEFAULT_IERS_BULLETIN_A_FILE = R"--(
The following formulas will not reproduce the predictions given below,
but may be used to extend the predictions beyond the end of this table.
x = 0.1611 - 0.0626 cos A - 0.1221 sin A + 0.0025 cos C + 0.0585 sin C
y = 0.3836 - 0.1091 cos A + 0.0516 sin A + 0.0585 cos C - 0.0025 sin C
UT1-UTC = 0.0617 + 0.00005 (MJD - 61056) - (UT2-UT1)
x = 0.1598 + 0.0465 cos A - 0.1071 sin A - 0.0426 cos C + 0.0358 sin C
y = 0.3762 - 0.0906 cos A - 0.0441 sin A + 0.0358 cos C + 0.0426 sin C
UT1-UTC = -0.1023 - 0.00035 (MJD - 61329) - (UT2-UT1)
where A = 2*pi*(MJD-61048)/365.25 and C = 2*pi*(MJD-61048)/435.
where A = 2*pi*(MJD-61321)/365.25 and C = 2*pi*(MJD-61321)/435.
TAI-UTC(MJD 61049) = 37.0
TAI-UTC(MJD 61322) = 37.0
The accuracy may be estimated from the expressions:
S x,y = 0.00068 (MJD-61048)**0.80 S t = 0.00025 (MJD-61048)**0.75
S x,y = 0.00068 (MJD-61321)**0.80 S t = 0.00025 (MJD-61321)**0.75
Estimated accuracies are: Predictions 10 d 20 d 30 d 40 d
Polar coord's 0.004 0.007 0.010 0.013
UT1-UTC 0.0014 0.0024 0.0032 0.0040
MJD x(arcsec) y(arcsec) UT1-UTC(sec)
2026 1 9 61049 0.1001 0.3380 0.07228
2026 1 10 61050 0.0993 0.3385 0.07180
2026 1 11 61051 0.0985 0.3390 0.07149
2026 1 12 61052 0.0978 0.3396 0.07136
2026 1 13 61053 0.0971 0.3403 0.07142
2026 1 14 61054 0.0964 0.3411 0.07168
2026 1 15 61055 0.0957 0.3418 0.07209
2026 1 16 61056 0.0949 0.3426 0.07260
2026 1 17 61057 0.0942 0.3434 0.07313
2026 1 18 61058 0.0935 0.3442 0.07360
2026 1 19 61059 0.0928 0.3450 0.07391
2026 1 20 61060 0.0921 0.3458 0.07400
2026 1 21 61061 0.0915 0.3466 0.07380
2026 1 22 61062 0.0909 0.3474 0.07332
2026 1 23 61063 0.0903 0.3482 0.07264
2026 1 24 61064 0.0897 0.3490 0.07185
2026 1 25 61065 0.0892 0.3499 0.07110
2026 1 26 61066 0.0886 0.3507 0.07051
2026 1 27 61067 0.0881 0.3516 0.07015
2026 1 28 61068 0.0876 0.3524 0.07004
2026 1 29 61069 0.0872 0.3533 0.07016
2026 1 30 61070 0.0867 0.3542 0.07040
2026 1 31 61071 0.0863 0.3551 0.07062
2026 2 1 61072 0.0858 0.3560 0.07069
2026 2 2 61073 0.0855 0.3569 0.07052
2026 2 3 61074 0.0851 0.3578 0.07011
2026 2 4 61075 0.0847 0.3587 0.06952
2026 2 5 61076 0.0844 0.3596 0.06884
2026 2 6 61077 0.0841 0.3605 0.06818
2026 2 7 61078 0.0838 0.3615 0.06763
2026 2 8 61079 0.0835 0.3624 0.06723
2026 2 9 61080 0.0832 0.3634 0.06700
2026 2 10 61081 0.0830 0.3643 0.06696
2026 2 11 61082 0.0828 0.3653 0.06706
2026 2 12 61083 0.0826 0.3662 0.06727
2026 2 13 61084 0.0824 0.3672 0.06753
2026 2 14 61085 0.0822 0.3682 0.06774
2026 2 15 61086 0.0821 0.3692 0.06784
2026 2 16 61087 0.0820 0.3702 0.06774
2026 2 17 61088 0.0819 0.3711 0.06738
2026 2 18 61089 0.0818 0.3721 0.06675
2026 2 19 61090 0.0818 0.3731 0.06590
2026 2 20 61091 0.0817 0.3741 0.06493
2026 2 21 61092 0.0817 0.3751 0.06395
2026 2 22 61093 0.0817 0.3761 0.06311
2026 2 23 61094 0.0818 0.3771 0.06250
2026 2 24 61095 0.0818 0.3781 0.06215
2026 2 25 61096 0.0819 0.3792 0.06203
2026 2 26 61097 0.0820 0.3802 0.06204
2026 2 27 61098 0.0821 0.3812 0.06206
2026 2 28 61099 0.0823 0.3822 0.06196
2026 3 1 61100 0.0824 0.3832 0.06165
2026 3 2 61101 0.0826 0.3842 0.06111
2026 3 3 61102 0.0828 0.3852 0.06037
2026 3 4 61103 0.0831 0.3862 0.05951
2026 3 5 61104 0.0833 0.3872 0.05864
2026 3 6 61105 0.0836 0.3882 0.05787
2026 3 7 61106 0.0839 0.3893 0.05726
2026 3 8 61107 0.0842 0.3903 0.05686
2026 3 9 61108 0.0846 0.3913 0.05667
2026 3 10 61109 0.0849 0.3922 0.05667
2026 3 11 61110 0.0853 0.3932 0.05681
2026 3 12 61111 0.0857 0.3942 0.05703
2026 3 13 61112 0.0861 0.3952 0.05725
2026 3 14 61113 0.0866 0.3962 0.05737
2026 3 15 61114 0.0870 0.3972 0.05732
2026 3 16 61115 0.0875 0.3981 0.05703
2026 3 17 61116 0.0880 0.3991 0.05647
2026 3 18 61117 0.0886 0.4000 0.05564
2026 3 19 61118 0.0891 0.4010 0.05462
2026 3 20 61119 0.0897 0.4019 0.05355
2026 3 21 61120 0.0903 0.4029 0.05256
2026 3 22 61121 0.0909 0.4038 0.05180
2026 3 23 61122 0.0916 0.4047 0.05132
2026 3 24 61123 0.0922 0.4056 0.05111
2026 3 25 61124 0.0929 0.4065 0.05107
2026 3 26 61125 0.0936 0.4074 0.05108
2026 3 27 61126 0.0943 0.4083 0.05100
2026 3 28 61127 0.0950 0.4092 0.05075
2026 3 29 61128 0.0958 0.4101 0.05028
2026 3 30 61129 0.0966 0.4109 0.04959
2026 3 31 61130 0.0974 0.4118 0.04876
2026 4 1 61131 0.0982 0.4126 0.04787
2026 4 2 61132 0.0990 0.4134 0.04702
2026 4 3 61133 0.0998 0.4142 0.04629
2026 4 4 61134 0.1007 0.4150 0.04574
2026 4 5 61135 0.1016 0.4158 0.04540
2026 4 6 61136 0.1025 0.4166 0.04526
2026 4 7 61137 0.1034 0.4174 0.04528
2026 4 8 61138 0.1044 0.4181 0.04540
2026 4 9 61139 0.1053 0.4188 0.04556
2026 4 10 61140 0.1063 0.4196 0.04566
2026 4 11 61141 0.1073 0.4203 0.04563
2026 4 12 61142 0.1083 0.4210 0.04539
2026 4 13 61143 0.1093 0.4217 0.04489
2026 4 14 61144 0.1103 0.4223 0.04411
2026 4 15 61145 0.1114 0.4230 0.04311
2026 4 16 61146 0.1124 0.4236 0.04198
2026 4 17 61147 0.1135 0.4242 0.04088
2026 4 18 61148 0.1146 0.4248 0.03995
2026 4 19 61149 0.1157 0.4254 0.03929
2026 4 20 61150 0.1168 0.4260 0.03893
2026 4 21 61151 0.1180 0.4265 0.03881
2026 4 22 61152 0.1191 0.4271 0.03879
2026 4 23 61153 0.1203 0.4276 0.03874
2026 4 24 61154 0.1214 0.4281 0.03855
2026 4 25 61155 0.1226 0.4286 0.03815
2026 4 26 61156 0.1238 0.4291 0.03757
2026 4 27 61157 0.1250 0.4295 0.03685
2026 4 28 61158 0.1262 0.4299 0.03606
2026 4 29 61159 0.1275 0.4304 0.03532
2026 4 30 61160 0.1287 0.4308 0.03468
2026 5 1 61161 0.1300 0.4311 0.03422
2026 5 2 61162 0.1312 0.4315 0.03397
2026 5 3 61163 0.1325 0.4318 0.03394
2026 5 4 61164 0.1338 0.4322 0.03410
2026 5 5 61165 0.1350 0.4325 0.03439
2026 5 6 61166 0.1363 0.4327 0.03475
2026 5 7 61167 0.1376 0.4330 0.03509
2026 5 8 61168 0.1389 0.4332 0.03536
2026 5 9 61169 0.1402 0.4335 0.03547
2026 5 10 61170 0.1416 0.4337 0.03538
2026 5 11 61171 0.1429 0.4339 0.03505
2026 5 12 61172 0.1442 0.4340 0.03452
2026 5 13 61173 0.1456 0.4342 0.03383
2026 5 14 61174 0.1469 0.4343 0.03311
2026 5 15 61175 0.1482 0.4344 0.03249
2026 5 16 61176 0.1496 0.4345 0.03211
2026 5 17 61177 0.1509 0.4345 0.03204
2026 5 18 61178 0.1523 0.4345 0.03225
2026 5 19 61179 0.1537 0.4346 0.03262
2026 5 20 61180 0.1550 0.4346 0.03301
2026 5 21 61181 0.1564 0.4345 0.03328
2026 5 22 61182 0.1577 0.4345 0.03336
2026 5 23 61183 0.1591 0.4344 0.03325
2026 5 24 61184 0.1605 0.4343 0.03299
2026 5 25 61185 0.1618 0.4342 0.03268
2026 5 26 61186 0.1632 0.4341 0.03241
2026 5 27 61187 0.1646 0.4339 0.03224
2026 5 28 61188 0.1659 0.4338 0.03225
2026 5 29 61189 0.1673 0.4336 0.03246
2026 5 30 61190 0.1686 0.4333 0.03289
2026 5 31 61191 0.1700 0.4331 0.03352
2026 6 1 61192 0.1713 0.4328 0.03429
2026 6 2 61193 0.1727 0.4326 0.03515
2026 6 3 61194 0.1740 0.4323 0.03602
2026 6 4 61195 0.1754 0.4319 0.03683
2026 6 5 61196 0.1767 0.4316 0.03751
2026 6 6 61197 0.1781 0.4312 0.03801
2026 6 7 61198 0.1794 0.4308 0.03831
2026 6 8 61199 0.1807 0.4304 0.03841
2026 6 9 61200 0.1820 0.4300 0.03835
2026 6 10 61201 0.1833 0.4295 0.03823
2026 6 11 61202 0.1846 0.4291 0.03815
2026 6 12 61203 0.1859 0.4286 0.03824
2026 6 13 61204 0.1872 0.4280 0.03860
2026 6 14 61205 0.1885 0.4275 0.03924
2026 6 15 61206 0.1897 0.4270 0.04009
2026 6 16 61207 0.1910 0.4264 0.04101
2026 6 17 61208 0.1922 0.4258 0.04185
2026 6 18 61209 0.1935 0.4252 0.04250
2026 6 19 61210 0.1947 0.4245 0.04293
2026 6 20 61211 0.1959 0.4239 0.04317
2026 6 21 61212 0.1971 0.4232 0.04333
2026 6 22 61213 0.1983 0.4225 0.04352
2026 6 23 61214 0.1995 0.4218 0.04381
2026 6 24 61215 0.2007 0.4211 0.04428
2026 6 25 61216 0.2018 0.4203 0.04496
2026 6 26 61217 0.2030 0.4195 0.04586
2026 6 27 61218 0.2041 0.4187 0.04695
2026 6 28 61219 0.2052 0.4179 0.04820
2026 6 29 61220 0.2063 0.4171 0.04955
2026 6 30 61221 0.2074 0.4162 0.05092
2026 7 1 61222 0.2085 0.4154 0.05224
2026 7 2 61223 0.2095 0.4145 0.05344
2026 7 3 61224 0.2106 0.4136 0.05447
2026 7 4 61225 0.2116 0.4127 0.05530
2026 7 5 61226 0.2126 0.4118 0.05595
2026 7 6 61227 0.2136 0.4108 0.05644
2026 7 7 61228 0.2146 0.4098 0.05686
2026 7 8 61229 0.2155 0.4088 0.05730
2026 7 9 61230 0.2164 0.4078 0.05787
2026 7 10 61231 0.2174 0.4068 0.05866
2026 7 11 61232 0.2183 0.4058 0.05971
2026 7 12 61233 0.2191 0.4048 0.06099
2026 7 13 61234 0.2200 0.4037 0.06238
2026 7 14 61235 0.2208 0.4026 0.06374
2026 7 15 61236 0.2217 0.4015 0.06490
2026 7 16 61237 0.2225 0.4004 0.06580
2026 7 17 61238 0.2232 0.3993 0.06643
2026 7 18 61239 0.2240 0.3982 0.06686
2026 7 19 61240 0.2247 0.3970 0.06720
2026 7 20 61241 0.2255 0.3959 0.06757
2026 7 21 61242 0.2262 0.3947 0.06804
2026 7 22 61243 0.2268 0.3935 0.06865
2026 7 23 61244 0.2275 0.3923 0.06942
2026 7 24 61245 0.2281 0.3911 0.07035
2026 7 25 61246 0.2287 0.3899 0.07139
2026 7 26 61247 0.2293 0.3887 0.07253
2026 7 27 61248 0.2299 0.3875 0.07369
2026 7 28 61249 0.2304 0.3862 0.07483
2026 7 29 61250 0.2309 0.3849 0.07589
2026 7 30 61251 0.2314 0.3837 0.07681
2026 7 31 61252 0.2319 0.3824 0.07755
2026 8 1 61253 0.2323 0.3811 0.07812
2026 8 2 61254 0.2327 0.3798 0.07854
2026 8 3 61255 0.2331 0.3785 0.07889
2026 8 4 61256 0.2335 0.3772 0.07925
2026 8 5 61257 0.2338 0.3759 0.07972
2026 8 6 61258 0.2342 0.3746 0.08039
2026 8 7 61259 0.2344 0.3733 0.08130
2026 8 8 61260 0.2347 0.3719 0.08241
2026 8 9 61261 0.2350 0.3706 0.08365
2026 8 10 61262 0.2352 0.3692 0.08486
2026 8 11 61263 0.2354 0.3679 0.08590
2026 8 12 61264 0.2355 0.3665 0.08667
2026 8 13 61265 0.2357 0.3652 0.08710
2026 8 14 61266 0.2358 0.3638 0.08724
2026 8 15 61267 0.2359 0.3624 0.08725
2026 8 16 61268 0.2359 0.3611 0.08727
2026 8 17 61269 0.2360 0.3597 0.08741
2026 8 18 61270 0.2360 0.3583 0.08772
2026 8 19 61271 0.2360 0.3570 0.08823
2026 8 20 61272 0.2359 0.3556 0.08889
2026 8 21 61273 0.2359 0.3542 0.08975
2026 8 22 61274 0.2358 0.3528 0.09075
2026 8 23 61275 0.2356 0.3515 0.09173
2026 8 24 61276 0.2355 0.3501 0.09267
2026 8 25 61277 0.2353 0.3487 0.09354
2026 8 26 61278 0.2351 0.3473 0.09418
2026 8 27 61279 0.2349 0.3460 0.09450
2026 8 28 61280 0.2346 0.3446 0.09461
2026 8 29 61281 0.2344 0.3432 0.09454
2026 8 30 61282 0.2340 0.3419 0.09433
2026 8 31 61283 0.2337 0.3405 0.09408
2026 9 1 61284 0.2334 0.3391 0.09392
2026 9 2 61285 0.2330 0.3378 0.09389
2026 9 3 61286 0.2326 0.3364 0.09406
2026 9 4 61287 0.2321 0.3351 0.09437
2026 9 5 61288 0.2317 0.3337 0.09483
2026 9 6 61289 0.2312 0.3324 0.09533
2026 9 7 61290 0.2306 0.3311 0.09572
2026 9 8 61291 0.2301 0.3298 0.09587
2026 9 9 61292 0.2295 0.3285 0.09576
2026 9 10 61293 0.2289 0.3272 0.09541
2026 9 11 61294 0.2283 0.3259 0.09492
2026 9 12 61295 0.2277 0.3246 0.09452
2026 9 13 61296 0.2270 0.3233 0.09420
2026 9 14 61297 0.2263 0.3220 0.09410
2026 9 15 61298 0.2256 0.3208 0.09416
2026 9 16 61299 0.2248 0.3195 0.09433
2026 9 17 61300 0.2241 0.3183 0.09465
2026 9 18 61301 0.2233 0.3170 0.09510
2026 9 19 61302 0.2225 0.3158 0.09562
2026 9 20 61303 0.2216 0.3146 0.09615
2026 9 21 61304 0.2208 0.3134 0.09657
2026 9 22 61305 0.2199 0.3122 0.09690
2026 9 23 61306 0.2190 0.3110 0.09704
2026 9 24 61307 0.2180 0.3099 0.09702
2026 9 25 61308 0.2171 0.3087 0.09681
2026 9 26 61309 0.2161 0.3076 0.09642
2026 9 27 61310 0.2151 0.3065 0.09591
2026 9 28 61311 0.2141 0.3054 0.09537
2026 9 29 61312 0.2130 0.3043 0.09501
2026 9 30 61313 0.2119 0.3032 0.09489
2026 10 1 61314 0.2109 0.3022 0.09500
2026 10 2 61315 0.2097 0.3011 0.09526
2026 10 3 61316 0.2086 0.3001 0.09568
2026 10 4 61317 0.2075 0.2991 0.09602
2026 10 5 61318 0.2063 0.2981 0.09613
2026 10 6 61319 0.2051 0.2971 0.09602
2026 10 7 61320 0.2039 0.2962 0.09573
2026 10 8 61321 0.2027 0.2952 0.09526
2026 10 9 61322 0.2014 0.2943 0.09470
2026 10 10 61323 0.2001 0.2934 0.09420
2026 10 11 61324 0.1989 0.2925 0.09382
2026 10 12 61325 0.1976 0.2917 0.09360
2026 10 13 61326 0.1962 0.2908 0.09354
2026 10 14 61327 0.1949 0.2900 0.09367
2026 10 15 61328 0.1935 0.2892 0.09395
2026 10 16 61329 0.1922 0.2884 0.09436
2026 10 17 61330 0.1908 0.2876 0.09484
2026 10 18 61331 0.1894 0.2869 0.09525
2026 10 19 61332 0.1880 0.2862 0.09550
2026 10 20 61333 0.1865 0.2855 0.09558
2026 10 21 61334 0.1851 0.2848 0.09543
2026 10 22 61335 0.1836 0.2841 0.09503
2026 10 23 61336 0.1821 0.2835 0.09443
2026 10 24 61337 0.1807 0.2829 0.09372
2026 10 25 61338 0.1792 0.2823 0.09295
2026 10 26 61339 0.1776 0.2817 0.09229
2026 10 27 61340 0.1761 0.2812 0.09186
2026 10 28 61341 0.1746 0.2807 0.09174
2026 10 29 61342 0.1730 0.2802 0.09188
2026 10 30 61343 0.1715 0.2797 0.09217
2026 10 31 61344 0.1699 0.2792 0.09250
2026 11 1 61345 0.1683 0.2788 0.09272
2026 11 2 61346 0.1667 0.2784 0.09267
2026 11 3 61347 0.1651 0.2780 0.09243
2026 11 4 61348 0.1635 0.2777 0.09199
2026 11 5 61349 0.1619 0.2773 0.09144
2026 11 6 61350 0.1603 0.2770 0.09088
2026 11 7 61351 0.1587 0.2767 0.09046
2026 11 8 61352 0.1571 0.2765 0.09016
2026 11 9 61353 0.1554 0.2763 0.09004
2026 11 10 61354 0.1538 0.2760 0.09011
2026 11 11 61355 0.1521 0.2759 0.09033
2026 11 12 61356 0.1505 0.2757 0.09067
2026 11 13 61357 0.1488 0.2756 0.09106
2026 11 14 61358 0.1471 0.2755 0.09148
2026 11 15 61359 0.1455 0.2754 0.09178
2026 11 16 61360 0.1438 0.2753 0.09198
2026 11 17 61361 0.1421 0.2753 0.09203
2026 11 18 61362 0.1405 0.2753 0.09194
2026 11 19 61363 0.1388 0.2753 0.09161
2026 11 20 61364 0.1371 0.2754 0.09115
2026 11 21 61365 0.1354 0.2755 0.09063
2026 11 22 61366 0.1338 0.2756 0.09016
2026 11 23 61367 0.1321 0.2757 0.08988
2026 11 24 61368 0.1304 0.2759 0.08982
2026 11 25 61369 0.1287 0.2760 0.09000
2026 11 26 61370 0.1271 0.2762 0.09038
2026 11 27 61371 0.1254 0.2765 0.09073
2026 11 28 61372 0.1237 0.2767 0.09096
2026 11 29 61373 0.1221 0.2770 0.09110
2026 11 30 61374 0.1204 0.2773 0.09103
2026 12 1 61375 0.1188 0.2777 0.09070
2026 12 2 61376 0.1171 0.2780 0.09027
2026 12 3 61377 0.1155 0.2784 0.08987
2026 12 4 61378 0.1139 0.2788 0.08951
2026 12 5 61379 0.1122 0.2793 0.08932
2026 12 6 61380 0.1106 0.2797 0.08929
2026 12 7 61381 0.1090 0.2802 0.08941
2026 12 8 61382 0.1074 0.2807 0.08977
2026 12 9 61383 0.1058 0.2813 0.09031
2026 12 10 61384 0.1042 0.2819 0.09092
2026 12 11 61385 0.1026 0.2824 0.09153
2026 12 12 61386 0.1011 0.2831 0.09210
2026 12 13 61387 0.0995 0.2837 0.09261
2026 12 14 61388 0.0980 0.2844 0.09296
2026 12 15 61389 0.0964 0.2851 0.09308
2026 12 16 61390 0.0949 0.2858 0.09298
2026 12 17 61391 0.0934 0.2865 0.09271
2026 12 18 61392 0.0919 0.2873 0.09223
2026 12 19 61393 0.0904 0.2881 0.09183
2026 12 20 61394 0.0889 0.2889 0.09151
2026 12 21 61395 0.0875 0.2897 0.09140
2026 12 22 61396 0.0860 0.2906 0.09146
2026 12 23 61397 0.0846 0.2914 0.09172
2026 12 24 61398 0.0832 0.2923 0.09217
2026 12 25 61399 0.0818 0.2933 0.09256
2026 12 26 61400 0.0804 0.2942 0.09281
2026 12 27 61401 0.0791 0.2952 0.09278
2026 12 28 61402 0.0777 0.2962 0.09251
2026 12 29 61403 0.0764 0.2972 0.09213
2026 12 30 61404 0.0751 0.2982 0.09173
2026 12 31 61405 0.0738 0.2993 0.09140
2027 1 1 61406 0.0725 0.3004 0.09123
2027 1 2 61407 0.0713 0.3015 0.09132
2027 1 3 61408 0.0700 0.3026 0.09160
2027 1 4 61409 0.0688 0.3037 0.09200
2027 1 5 61410 0.0676 0.3049 0.09264
2027 1 6 61411 0.0665 0.3061 0.09344
2027 1 7 61412 0.0653 0.3072 0.09426
2027 1 8 61413 0.0642 0.3085 0.09509
2026 10 9 61322 0.1672 0.3223 -0.03029
2026 10 10 61323 0.1664 0.3225 -0.03180
2026 10 11 61324 0.1656 0.3226 -0.03321
2026 10 12 61325 0.1646 0.3227 -0.03444
2026 10 13 61326 0.1636 0.3227 -0.03546
2026 10 14 61327 0.1624 0.3225 -0.03625
2026 10 15 61328 0.1614 0.3223 -0.03684
2026 10 16 61329 0.1603 0.3222 -0.03732
2026 10 17 61330 0.1593 0.3221 -0.03778
2026 10 18 61331 0.1583 0.3220 -0.03834
2026 10 19 61332 0.1573 0.3220 -0.03904
2026 10 20 61333 0.1563 0.3220 -0.03991
2026 10 21 61334 0.1553 0.3220 -0.04102
2026 10 22 61335 0.1542 0.3220 -0.04236
2026 10 23 61336 0.1532 0.3221 -0.04389
2026 10 24 61337 0.1521 0.3221 -0.04556
2026 10 25 61338 0.1511 0.3222 -0.04727
2026 10 26 61339 0.1500 0.3222 -0.04888
2026 10 27 61340 0.1489 0.3223 -0.05031
2026 10 28 61341 0.1478 0.3224 -0.05150
2026 10 29 61342 0.1467 0.3225 -0.05251
2026 10 30 61343 0.1456 0.3226 -0.05343
2026 10 31 61344 0.1445 0.3227 -0.05437
2026 11 1 61345 0.1434 0.3228 -0.05546
2026 11 2 61346 0.1423 0.3230 -0.05677
2026 11 3 61347 0.1412 0.3231 -0.05830
2026 11 4 61348 0.1401 0.3233 -0.05999
2026 11 5 61349 0.1390 0.3235 -0.06177
2026 11 6 61350 0.1379 0.3237 -0.06353
2026 11 7 61351 0.1368 0.3239 -0.06518
2026 11 8 61352 0.1357 0.3242 -0.06664
2026 11 9 61353 0.1346 0.3244 -0.06789
2026 11 10 61354 0.1334 0.3247 -0.06892
2026 11 11 61355 0.1323 0.3250 -0.06976
2026 11 12 61356 0.1312 0.3253 -0.07049
2026 11 13 61357 0.1301 0.3256 -0.07117
2026 11 14 61358 0.1290 0.3259 -0.07187
2026 11 15 61359 0.1279 0.3263 -0.07267
2026 11 16 61360 0.1268 0.3266 -0.07362
2026 11 17 61361 0.1257 0.3270 -0.07477
2026 11 18 61362 0.1246 0.3274 -0.07612
2026 11 19 61363 0.1235 0.3278 -0.07765
2026 11 20 61364 0.1224 0.3283 -0.07931
2026 11 21 61365 0.1213 0.3287 -0.08103
2026 11 22 61366 0.1203 0.3292 -0.08270
2026 11 23 61367 0.1192 0.3296 -0.08420
2026 11 24 61368 0.1181 0.3301 -0.08546
2026 11 25 61369 0.1171 0.3306 -0.08647
2026 11 26 61370 0.1160 0.3311 -0.08729
2026 11 27 61371 0.1149 0.3317 -0.08807
2026 11 28 61372 0.1139 0.3322 -0.08895
2026 11 29 61373 0.1129 0.3328 -0.09003
2026 11 30 61374 0.1118 0.3334 -0.09134
2026 12 1 61375 0.1108 0.3340 -0.09284
2026 12 2 61376 0.1098 0.3346 -0.09444
2026 12 3 61377 0.1088 0.3352 -0.09603
2026 12 4 61378 0.1078 0.3359 -0.09752
2026 12 5 61379 0.1068 0.3365 -0.09884
2026 12 6 61380 0.1058 0.3372 -0.09995
2026 12 7 61381 0.1048 0.3379 -0.10085
2026 12 8 61382 0.1038 0.3386 -0.10156
2026 12 9 61383 0.1029 0.3393 -0.10213
2026 12 10 61384 0.1019 0.3400 -0.10261
2026 12 11 61385 0.1010 0.3408 -0.10308
2026 12 12 61386 0.1001 0.3416 -0.10361
2026 12 13 61387 0.0992 0.3423 -0.10426
2026 12 14 61388 0.0983 0.3431 -0.10506
2026 12 15 61389 0.0974 0.3439 -0.10604
2026 12 16 61390 0.0965 0.3447 -0.10718
2026 12 17 61391 0.0956 0.3456 -0.10847
2026 12 18 61392 0.0948 0.3464 -0.10983
2026 12 19 61393 0.0939 0.3473 -0.11117
2026 12 20 61394 0.0931 0.3481 -0.11241
2026 12 21 61395 0.0923 0.3490 -0.11346
2026 12 22 61396 0.0915 0.3499 -0.11427
2026 12 23 61397 0.0907 0.3508 -0.11490
2026 12 24 61398 0.0900 0.3517 -0.11543
2026 12 25 61399 0.0892 0.3527 -0.11604
2026 12 26 61400 0.0885 0.3536 -0.11683
2026 12 27 61401 0.0877 0.3546 -0.11789
2026 12 28 61402 0.0870 0.3555 -0.11917
2026 12 29 61403 0.0863 0.3565 -0.12060
2026 12 30 61404 0.0857 0.3575 -0.12202
2026 12 31 61405 0.0850 0.3585 -0.12334
2027 1 1 61406 0.0844 0.3595 -0.12446
2027 1 2 61407 0.0837 0.3606 -0.12535
2027 1 3 61408 0.0831 0.3616 -0.12600
2027 1 4 61409 0.0825 0.3626 -0.12645
2027 1 5 61410 0.0820 0.3637 -0.12674
2027 1 6 61411 0.0814 0.3647 -0.12694
2027 1 7 61412 0.0809 0.3658 -0.12711
2027 1 8 61413 0.0804 0.3669 -0.12733
2027 1 9 61414 0.0799 0.3680 -0.12767
2027 1 10 61415 0.0794 0.3691 -0.12816
2027 1 11 61416 0.0789 0.3702 -0.12883
2027 1 12 61417 0.0785 0.3713 -0.12967
2027 1 13 61418 0.0781 0.3724 -0.13064
2027 1 14 61419 0.0777 0.3735 -0.13169
2027 1 15 61420 0.0773 0.3747 -0.13273
2027 1 16 61421 0.0769 0.3758 -0.13369
2027 1 17 61422 0.0766 0.3769 -0.13448
2027 1 18 61423 0.0762 0.3781 -0.13506
2027 1 19 61424 0.0759 0.3793 -0.13544
2027 1 20 61425 0.0757 0.3804 -0.13570
2027 1 21 61426 0.0754 0.3816 -0.13596
2027 1 22 61427 0.0752 0.3827 -0.13639
2027 1 23 61428 0.0749 0.3839 -0.13707
2027 1 24 61429 0.0747 0.3851 -0.13803
2027 1 25 61430 0.0746 0.3863 -0.13935
2027 1 26 61431 0.0744 0.3875 -0.14075
2027 1 27 61432 0.0743 0.3887 -0.14210
2027 1 28 61433 0.0742 0.3899 -0.14327
2027 1 29 61434 0.0741 0.3911 -0.14422
2027 1 30 61435 0.0740 0.3923 -0.14491
2027 1 31 61436 0.0740 0.3935 -0.14540
2027 2 1 61437 0.0739 0.3947 -0.14572
2027 2 2 61438 0.0739 0.3959 -0.14595
2027 2 3 61439 0.0740 0.3971 -0.14614
2027 2 4 61440 0.0740 0.3983 -0.14638
2027 2 5 61441 0.0741 0.3995 -0.14674
2027 2 6 61442 0.0742 0.4007 -0.14726
2027 2 7 61443 0.0743 0.4019 -0.14799
2027 2 8 61444 0.0744 0.4031 -0.14890
2027 2 9 61445 0.0746 0.4043 -0.14998
2027 2 10 61446 0.0748 0.4055 -0.15115
2027 2 11 61447 0.0750 0.4067 -0.15235
2027 2 12 61448 0.0752 0.4079 -0.15347
2027 2 13 61449 0.0754 0.4091 -0.15446
2027 2 14 61450 0.0757 0.4103 -0.15526
2027 2 15 61451 0.0760 0.4115 -0.15586
2027 2 16 61452 0.0763 0.4127 -0.15632
2027 2 17 61453 0.0767 0.4139 -0.15676
2027 2 18 61454 0.0770 0.4151 -0.15731
2027 2 19 61455 0.0774 0.4162 -0.15809
2027 2 20 61456 0.0778 0.4174 -0.15917
2027 2 21 61457 0.0783 0.4186 -0.16054
2027 2 22 61458 0.0787 0.4197 -0.16207
2027 2 23 61459 0.0792 0.4209 -0.16363
2027 2 24 61460 0.0797 0.4221 -0.16506
2027 2 25 61461 0.0802 0.4232 -0.16628
2027 2 26 61462 0.0808 0.4243 -0.16724
2027 2 27 61463 0.0814 0.4255 -0.16796
2027 2 28 61464 0.0820 0.4266 -0.16848
2027 3 1 61465 0.0826 0.4277 -0.16888
2027 3 2 61466 0.0832 0.4288 -0.16923
2027 3 3 61467 0.0839 0.4299 -0.16960
2027 3 4 61468 0.0845 0.4310 -0.17006
2027 3 5 61469 0.0853 0.4321 -0.17068
2027 3 6 61470 0.0860 0.4332 -0.17149
2027 3 7 61471 0.0867 0.4342 -0.17250
2027 3 8 61472 0.0875 0.4353 -0.17368
2027 3 9 61473 0.0883 0.4363 -0.17499
2027 3 10 61474 0.0891 0.4373 -0.17634
2027 3 11 61475 0.0899 0.4384 -0.17764
2027 3 12 61476 0.0908 0.4394 -0.17880
2027 3 13 61477 0.0917 0.4404 -0.17976
2027 3 14 61478 0.0925 0.4414 -0.18051
2027 3 15 61479 0.0935 0.4423 -0.18111
2027 3 16 61480 0.0944 0.4433 -0.18163
2027 3 17 61481 0.0954 0.4442 -0.18221
2027 3 18 61482 0.0963 0.4452 -0.18298
2027 3 19 61483 0.0973 0.4461 -0.18401
2027 3 20 61484 0.0983 0.4470 -0.18533
2027 3 21 61485 0.0994 0.4479 -0.18686
2027 3 22 61486 0.1004 0.4488 -0.18850
2027 3 23 61487 0.1015 0.4496 -0.19010
2027 3 24 61488 0.1026 0.4505 -0.19153
2027 3 25 61489 0.1037 0.4513 -0.19271
2027 3 26 61490 0.1048 0.4521 -0.19364
2027 3 27 61491 0.1060 0.4529 -0.19435
2027 3 28 61492 0.1071 0.4537 -0.19490
2027 3 29 61493 0.1083 0.4545 -0.19538
2027 3 30 61494 0.1095 0.4552 -0.19585
2027 3 31 61495 0.1107 0.4560 -0.19639
2027 4 1 61496 0.1119 0.4567 -0.19707
2027 4 2 61497 0.1132 0.4574 -0.19794
2027 4 3 61498 0.1144 0.4581 -0.19902
2027 4 4 61499 0.1157 0.4587 -0.20031
2027 4 5 61500 0.1170 0.4594 -0.20177
2027 4 6 61501 0.1183 0.4600 -0.20334
2027 4 7 61502 0.1196 0.4606 -0.20493
2027 4 8 61503 0.1209 0.4612 -0.20645
2027 4 9 61504 0.1223 0.4618 -0.20783
2027 4 10 61505 0.1237 0.4623 -0.20906
2027 4 11 61506 0.1250 0.4629 -0.21016
2027 4 12 61507 0.1264 0.4634 -0.21122
2027 4 13 61508 0.1278 0.4639 -0.21237
2027 4 14 61509 0.1292 0.4644 -0.21370
2027 4 15 61510 0.1306 0.4648 -0.21529
2027 4 16 61511 0.1321 0.4652 -0.21712
2027 4 17 61512 0.1335 0.4657 -0.21911
2027 4 18 61513 0.1350 0.4661 -0.22114
2027 4 19 61514 0.1364 0.4664 -0.22304
2027 4 20 61515 0.1379 0.4668 -0.22469
2027 4 21 61516 0.1394 0.4671 -0.22598
2027 4 22 61517 0.1409 0.4674 -0.22690
2027 4 23 61518 0.1424 0.4677 -0.22747
2027 4 24 61519 0.1439 0.4680 -0.22778
2027 4 25 61520 0.1454 0.4682 -0.22790
2027 4 26 61521 0.1469 0.4684 -0.22795
2027 4 27 61522 0.1485 0.4686 -0.22799
2027 4 28 61523 0.1500 0.4688 -0.22810
2027 4 29 61524 0.1515 0.4689 -0.22834
2027 4 30 61525 0.1531 0.4691 -0.22872
2027 5 1 61526 0.1547 0.4692 -0.22926
2027 5 2 61527 0.1562 0.4693 -0.22992
2027 5 3 61528 0.1578 0.4693 -0.23065
2027 5 4 61529 0.1594 0.4694 -0.23137
2027 5 5 61530 0.1609 0.4694 -0.23200
2027 5 6 61531 0.1625 0.4694 -0.23246
2027 5 7 61532 0.1641 0.4693 -0.23268
2027 5 8 61533 0.1657 0.4693 -0.23267
2027 5 9 61534 0.1672 0.4692 -0.23249
2027 5 10 61535 0.1688 0.4691 -0.23225
2027 5 11 61536 0.1704 0.4690 -0.23209
2027 5 12 61537 0.1720 0.4688 -0.23211
2027 5 13 61538 0.1736 0.4687 -0.23238
2027 5 14 61539 0.1752 0.4685 -0.23287
2027 5 15 61540 0.1768 0.4683 -0.23350
2027 5 16 61541 0.1783 0.4680 -0.23417
2027 5 17 61542 0.1799 0.4678 -0.23477
2027 5 18 61543 0.1815 0.4675 -0.23522
2027 5 19 61544 0.1831 0.4672 -0.23549
2027 5 20 61545 0.1847 0.4668 -0.23553
2027 5 21 61546 0.1862 0.4665 -0.23532
2027 5 22 61547 0.1878 0.4661 -0.23490
2027 5 23 61548 0.1894 0.4657 -0.23447
2027 5 24 61549 0.1909 0.4653 -0.23402
2027 5 25 61550 0.1925 0.4648 -0.23356
2027 5 26 61551 0.1940 0.4643 -0.23305
2027 5 27 61552 0.1956 0.4638 -0.23271
2027 5 28 61553 0.1971 0.4633 -0.23256
2027 5 29 61554 0.1986 0.4628 -0.23252
2027 5 30 61555 0.2002 0.4622 -0.23259
2027 5 31 61556 0.2017 0.4616 -0.23260
2027 6 1 61557 0.2032 0.4610 -0.23253
2027 6 2 61558 0.2047 0.4604 -0.23231
2027 6 3 61559 0.2062 0.4597 -0.23185
2027 6 4 61560 0.2076 0.4591 -0.23119
2027 6 5 61561 0.2091 0.4584 -0.23032
2027 6 6 61562 0.2106 0.4576 -0.22943
2027 6 7 61563 0.2120 0.4569 -0.22870
2027 6 8 61564 0.2135 0.4561 -0.22819
2027 6 9 61565 0.2149 0.4553 -0.22786
2027 6 10 61566 0.2163 0.4545 -0.22767
2027 6 11 61567 0.2177 0.4537 -0.22763
2027 6 12 61568 0.2191 0.4529 -0.22757
2027 6 13 61569 0.2205 0.4520 -0.22745
2027 6 14 61570 0.2218 0.4511 -0.22711
2027 6 15 61571 0.2232 0.4502 -0.22646
2027 6 16 61572 0.2245 0.4493 -0.22558
2027 6 17 61573 0.2258 0.4483 -0.22449
2027 6 18 61574 0.2271 0.4473 -0.22329
2027 6 19 61575 0.2284 0.4464 -0.22201
2027 6 20 61576 0.2297 0.4453 -0.22078
2027 6 21 61577 0.2309 0.4443 -0.21958
2027 6 22 61578 0.2321 0.4433 -0.21855
2027 6 23 61579 0.2334 0.4422 -0.21767
2027 6 24 61580 0.2346 0.4411 -0.21699
2027 6 25 61581 0.2357 0.4400 -0.21648
2027 6 26 61582 0.2369 0.4389 -0.21610
2027 6 27 61583 0.2380 0.4378 -0.21582
2027 6 28 61584 0.2392 0.4366 -0.21555
2027 6 29 61585 0.2403 0.4354 -0.21520
2027 6 30 61586 0.2413 0.4342 -0.21476
2027 7 1 61587 0.2424 0.4330 -0.21407
2027 7 2 61588 0.2435 0.4318 -0.21326
2027 7 3 61589 0.2445 0.4306 -0.21229
2027 7 4 61590 0.2455 0.4293 -0.21142
2027 7 5 61591 0.2465 0.4281 -0.21066
2027 7 6 61592 0.2474 0.4268 -0.21015
2027 7 7 61593 0.2483 0.4255 -0.20989
2027 7 8 61594 0.2493 0.4242 -0.20984
2027 7 9 61595 0.2501 0.4228 -0.20994
2027 7 10 61596 0.2510 0.4215 -0.20988
2027 7 11 61597 0.2519 0.4202 -0.20959
2027 7 12 61598 0.2527 0.4188 -0.20900
2027 7 13 61599 0.2535 0.4174 -0.20815
2027 7 14 61600 0.2542 0.4160 -0.20703
2027 7 15 61601 0.2550 0.4146 -0.20571
2027 7 16 61602 0.2557 0.4132 -0.20432
2027 7 17 61603 0.2564 0.4118 -0.20294
2027 7 18 61604 0.2571 0.4103 -0.20162
2027 7 19 61605 0.2577 0.4089 -0.20047
2027 7 20 61606 0.2583 0.4074 -0.19943
2027 7 21 61607 0.2589 0.4060 -0.19858
2027 7 22 61608 0.2595 0.4045 -0.19794
2027 7 23 61609 0.2600 0.4030 -0.19744
2027 7 24 61610 0.2605 0.4015 -0.19706
2027 7 25 61611 0.2610 0.4000 -0.19671
2027 7 26 61612 0.2615 0.3985 -0.19636
2027 7 27 61613 0.2619 0.3970 -0.19587
2027 7 28 61614 0.2623 0.3955 -0.19523
2027 7 29 61615 0.2627 0.3940 -0.19436
2027 7 30 61616 0.2631 0.3924 -0.19338
2027 7 31 61617 0.2634 0.3909 -0.19242
2027 8 1 61618 0.2637 0.3893 -0.19156
2027 8 2 61619 0.2639 0.3878 -0.19089
2027 8 3 61620 0.2642 0.3862 -0.19047
2027 8 4 61621 0.2644 0.3847 -0.19032
2027 8 5 61622 0.2646 0.3831 -0.19038
2027 8 6 61623 0.2647 0.3816 -0.19045
2027 8 7 61624 0.2648 0.3800 -0.19036
2027 8 8 61625 0.2649 0.3784 -0.19005
2027 8 9 61626 0.2650 0.3768 -0.18939
2027 8 10 61627 0.2650 0.3753 -0.18850
2027 8 11 61628 0.2650 0.3737 -0.18736
2027 8 12 61629 0.2650 0.3721 -0.18613
2027 8 13 61630 0.2649 0.3706 -0.18490
2027 8 14 61631 0.2649 0.3690 -0.18367
2027 8 15 61632 0.2647 0.3674 -0.18263
2027 8 16 61633 0.2646 0.3658 -0.18175
2027 8 17 61634 0.2644 0.3643 -0.18101
2027 8 18 61635 0.2642 0.3627 -0.18047
2027 8 19 61636 0.2640 0.3611 -0.18006
2027 8 20 61637 0.2638 0.3596 -0.17971
2027 8 21 61638 0.2635 0.3580 -0.17944
2027 8 22 61639 0.2631 0.3565 -0.17920
2027 8 23 61640 0.2628 0.3549 -0.17893
2027 8 24 61641 0.2624 0.3534 -0.17850
2027 8 25 61642 0.2620 0.3518 -0.17787
2027 8 26 61643 0.2616 0.3503 -0.17711
2027 8 27 61644 0.2611 0.3488 -0.17636
2027 8 28 61645 0.2606 0.3472 -0.17574
2027 8 29 61646 0.2601 0.3457 -0.17539
2027 8 30 61647 0.2596 0.3442 -0.17532
2027 8 31 61648 0.2590 0.3427 -0.17563
2027 9 1 61649 0.2584 0.3412 -0.17620
2027 9 2 61650 0.2577 0.3398 -0.17690
2027 9 3 61651 0.2571 0.3383 -0.17757
2027 9 4 61652 0.2564 0.3368 -0.17804
2027 9 5 61653 0.2557 0.3354 -0.17821
2027 9 6 61654 0.2549 0.3339 -0.17804
2027 9 7 61655 0.2541 0.3325 -0.17762
2027 9 8 61656 0.2533 0.3311 -0.17702
2027 9 9 61657 0.2525 0.3297 -0.17639
2027 9 10 61658 0.2516 0.3283 -0.17578
2027 9 11 61659 0.2508 0.3269 -0.17523
2027 9 12 61660 0.2498 0.3255 -0.17482
2027 9 13 61661 0.2489 0.3242 -0.17451
2027 9 14 61662 0.2479 0.3228 -0.17443
2027 9 15 61663 0.2470 0.3215 -0.17454
2027 9 16 61664 0.2459 0.3202 -0.17483
2027 9 17 61665 0.2449 0.3189 -0.17520
2027 9 18 61666 0.2438 0.3176 -0.17547
2027 9 19 61667 0.2427 0.3163 -0.17563
2027 9 20 61668 0.2416 0.3151 -0.17573
2027 9 21 61669 0.2405 0.3138 -0.17562
2027 9 22 61670 0.2393 0.3126 -0.17534
2027 9 23 61671 0.2381 0.3114 -0.17497
2027 9 24 61672 0.2369 0.3102 -0.17466
2027 9 25 61673 0.2356 0.3091 -0.17446
2027 9 26 61674 0.2344 0.3079 -0.17452
2027 9 27 61675 0.2331 0.3068 -0.17491
2027 9 28 61676 0.2318 0.3057 -0.17557
2027 9 29 61677 0.2305 0.3046 -0.17637
2027 9 30 61678 0.2291 0.3035 -0.17727
2027 10 1 61679 0.2277 0.3025 -0.17809
2027 10 2 61680 0.2263 0.3015 -0.17865
2027 10 3 61681 0.2249 0.3005 -0.17894
2027 10 4 61682 0.2235 0.2995 -0.17892
2027 10 5 61683 0.2220 0.2985 -0.17866
2027 10 6 61684 0.2205 0.2976 -0.17834
2027 10 7 61685 0.2190 0.2966 -0.17806
2027 10 8 61686 0.2175 0.2957 -0.17778
These predictions are based on all announced leap seconds.
CELESTIAL POLE OFFSET SERIES:
NEOS Celestial Pole Offset Series
MJD dpsi error deps error
(msec. of arc)
61026 -114.45 1.33 -7.19 0.16
61027 -114.43 1.33 -7.42 0.16
61028 -114.48 1.33 -7.64 0.16
61029 -114.51 1.19 -7.67 0.18
61030 -114.39 1.19 -7.49 0.18
61031 -114.09 1.24 -7.26 0.16
61032 -113.74 1.35 -7.13 0.06
61033 -113.52 1.35 -7.11 0.06
IERS Celestial Pole Offset Final Series
MJD dpsi deps
(msec. of arc)
60981 -117.6 -9.0
60982 -117.8 -8.8
60983 -118.0 -8.6
60984 -117.8 -8.6
60985 -117.5 -8.8
60986 -117.1 -8.9
60987 -116.8 -8.7
60988 -116.9 -8.5
60989 -117.0 -8.6
60990 -116.9 -8.8
60991 -116.6 -8.8
60992 -116.5 -8.5
60993 -116.5 -8.0
60994 -116.6 -7.7
60995 -116.6 -7.6
60996 -116.4 -7.5
60997 -116.1 -7.5
60998 -115.6 -7.8
60999 -115.5 -8.3
61000 -115.9 -8.6
61001 -116.0 -8.6
61002 -115.9 -8.5
61003 -115.7 -8.3
61004 -115.4 -8.2
61005 -115.1 -8.2
61006 -114.7 -8.1
61007 -114.4 -7.9
61008 -114.3 -7.9
61009 -114.6 -7.8
61010 -115.2 -7.6
61292 -123.28 1.24 -11.48 0.12
61293 -123.30 1.24 -11.30 0.12
61294 -123.26 1.24 -11.15 0.12
61295 -123.29 0.32 -11.07 0.16
61296 -123.59 0.32 -11.08 0.16
61297 -124.16 0.32 -11.18 0.16
61298 -124.72 0.32 -11.31 0.16
61299 -124.96 0.32 -11.38 0.16
61300 -124.76 0.32 -11.31 0.16
61301 -124.26 0.32 -11.17 0.16
61302 -123.69 0.32 -11.09 0.16
61303 -123.26 1.03 -11.12 0.11
61304 -123.06 1.03 -11.23 0.11
61305 -123.09 1.03 -11.27 0.11
IAU2000A Celestial Pole Offset Series
MJD dX error dY error
(msec. of arc)
61026 0.512 0.531 -0.092 0.161
61027 0.519 0.531 -0.101 0.161
61028 0.523 0.531 -0.107 0.161
61029 0.527 0.474 -0.112 0.176
61030 0.530 0.474 -0.114 0.176
61031 0.533 0.494 -0.114 0.156
61032 0.536 0.536 -0.113 0.059
61033 0.539 0.536 -0.111 0.059
IAU2000A Celestial Pole Offset Final Series
MJD dX dY
(msec. of arc)
60981 0.40 0.03
60982 0.38 0.02
60983 0.37 0.00
60984 0.42 -0.05
60985 0.41 -0.05
60986 0.34 -0.00
60987 0.33 0.01
60988 0.36 -0.01
60989 0.41 -0.04
60990 0.46 -0.06
60991 0.45 -0.05
60992 0.42 -0.02
60993 0.39 0.01
60994 0.33 0.07
60995 0.29 0.12
60996 0.30 0.14
60997 0.38 0.10
60998 0.59 -0.02
60999 0.62 -0.11
61000 0.51 -0.14
61001 0.41 -0.14
61002 0.35 -0.10
61003 0.32 -0.06
61004 0.33 -0.03
61005 0.38 -0.07
61006 0.47 -0.10
61007 0.57 -0.11
61008 0.57 -0.10
61009 0.48 -0.08
61010 0.35 -0.06
61292 0.457 0.492 -0.206 0.116
61293 0.457 0.492 -0.198 0.116
61294 0.456 0.492 -0.190 0.116
61295 0.455 0.128 -0.182 0.160
61296 0.453 0.128 -0.175 0.160
61297 0.450 0.128 -0.167 0.160
61298 0.447 0.128 -0.160 0.160
61299 0.443 0.128 -0.152 0.160
61300 0.438 0.128 -0.145 0.160
61301 0.434 0.128 -0.138 0.160
61302 0.429 0.128 -0.131 0.160
61303 0.424 0.409 -0.124 0.113
61304 0.419 0.409 -0.117 0.113
61305 0.414 0.409 -0.109 0.113
)--";

View File

@@ -499,10 +499,28 @@ struct mcc_skypoint_interface_t {
{
return std::forward<SelfT>(self).EO(eo);
}
// template <std::derived_from<mcc_skypoint_interface_t> SelfT>
// typename std::remove_cvref_t<SelfT>::dist_result_t distance(this SelfT&& self, auto const& sp)
// {
// return std::forward<SelfT>(self).distance(sp);
// }
// template <std::derived_from<mcc_skypoint_interface_t> SelfT>
// SelfT& operator+=(this SelfT& self, mcc_coord_pair_c auto const& dxy)
// {
// return self.operator+=(dxy);
// }
// template <std::derived_from<mcc_skypoint_interface_t> SelfT>
// SelfT& operator-=(this SelfT& self, mcc_coord_pair_c auto const& dxy)
// {
// return self.operator-=(dxy);
// }
};
template <typename T>
concept mcc_skypoint_c = std::derived_from<T, mcc_skypoint_interface_t> && requires(const T t_const) {
concept mcc_skypoint_c =
std::derived_from<T, mcc_skypoint_interface_t> && requires(const T t_const, const T t_other_const, T t) {
{ t_const.epoch() } -> mcc_coord_epoch_c;
// currently stored coordinates pair kind
@@ -513,7 +531,23 @@ concept mcc_skypoint_c = std::derived_from<T, mcc_skypoint_interface_t> && requi
// currently stored co-latitude coordinate
{ t_const.co_lat() } -> std::convertible_to<double>;
};
requires requires(typename T::dist_result_t res) {
requires mcc_angle_c<decltype(res.dist)>; // distance on sphere
requires mcc_angle_c<decltype(res.dx)>; // difference along co-longitude coordinate
requires mcc_angle_c<decltype(res.dy)>; // difference along co-latitude coordinate
requires mcc_angle_c<decltype(res.x2)>; // co-longitude coordinates of target sky point (in the same
// coordinate system as 'this')
requires mcc_angle_c<decltype(res.y2)>; // co-latitude coordinates of target sky point (in the same
// coordinate system as 'this')
};
// distance on sphere between two sky points
{ t_const.distance(std::declval<const T&>()) } -> std::same_as<typename T::dist_result_t>;
// { t_const - t_other_const } -> mcc_coord_pair_c;
// { t_const + t_other_const } -> mcc_coord_pair_c;
};
@@ -560,9 +594,11 @@ concept mcc_pcm_c = std::derived_from<T, mcc_pcm_interface_t<typename T::error_t
requires mcc_error_c<typename T::error_t>;
// the 'T' class must contain static constexpr member of 'MccMountType' type
requires std::same_as<decltype(T::mountType), const MccMountType>;
requires std::same_as<decltype(T::pcmMountType), const MccMountType>;
// requires std::same_as<decltype(T::mountType), const MccMountType>;
[]() {
[[maybe_unused]] static constexpr MccMountType val = T::mountType;
// [[maybe_unused]] static constexpr MccMountType val = T::mountType;
[[maybe_unused]] static constexpr MccMountType val = T::pcmMountType;
}(); // to ensure 'mountType' can be used in compile-time context
// static const variable with name of PCM
@@ -664,81 +700,18 @@ concept mcc_hardware_c = requires(T t) {
// the 'T' class must contain static constexpr member of 'MccMountType' type
requires std::same_as<decltype(T::mountType), const MccMountType>;
requires std::same_as<decltype(T::hwMountType), const MccMountType>;
[]() {
[[maybe_unused]] static constexpr MccMountType val = T::mountType;
[[maybe_unused]] static constexpr MccMountType val = T::hwMountType;
}(); // to ensure 'mountType' can be used in compile-time context
// a type that defines at least HW_MOVE_ERROR, HW_MOVE_STOPPING, HW_MOVE_STOPPED, HW_MOVE_SLEWING,
// HW_MOVE_ADJUSTING, HW_MOVE_TRACKING and HW_MOVE_GUIDING compile-time constants. The main purpose of this type is
// a possible tunning of hardware hardwareSetState-related commands and detect the stop and error states from
// hardware
//
// e.g. an implementations can be as follows:
// enum class hardware_movement_state_t: int {HW_MOVE_ERROR = -1, HW_MOVE_STOPPED = 0, HW_MOVE_STOPPING,
// HW_MOVE_SLEWING, HW_MOVE_ADJUSTING, HW_MOVE_TRACKING, HW_MOVE_GUIDING}
//
// struct hardware_movement_state_t {
// static constexpr uint16_t HW_MOVE_STOPPED = 0;
// static constexpr uint16_t HW_MOVE_SLEWING = 111;
// static constexpr uint16_t HW_MOVE_ADJUSTING = 222;
// static constexpr uint16_t HW_MOVE_TRACKING = 333;
// static constexpr uint16_t HW_MOVE_GUIDING = 444;
// static constexpr uint16_t HW_MOVE_ERROR = 555;
// static constexpr uint16_t HW_MOVE_STOPPING = 666;
// }
requires mcc_hardware_movement_state_c<typename T::hardware_movement_state_t>;
// requires requires(typename T::hardware_movement_state_t type) {
// []() {
// // mount axes were stopped
// static constexpr auto v0 = T::hardware_movement_state_t::HW_MOVE_STOPPED;
// // hardware was asked for slewing (move to given celestial point)
// static constexpr auto v1 = T::hardware_movement_state_t::HW_MOVE_SLEWING;
// // hardware was asked for adjusting after slewing
// // (adjusting actual mount position to align with target celestial point at the end of slewing process)
// static constexpr auto v2 = T::hardware_movement_state_t::HW_MOVE_ADJUSTING;
// // hardware was asked for tracking (track target celestial point)
// static constexpr auto v3 = T::hardware_movement_state_t::HW_MOVE_TRACKING;
// // hardware was asked for guiding
// // (small corrections to align actual mount position with target celestial point)
// static constexpr auto v4 = T::hardware_movement_state_t::HW_MOVE_GUIDING;
// // to detect possible hardware error
// static constexpr auto v5 = T::hardware_movement_state_t::HW_MOVE_ERROR;
// }();
// };
requires mcc_hardware_state_c<typename T::hardware_state_t> && requires(typename T::hardware_state_t state) {
requires std::same_as<decltype(state.movementState), typename T::hardware_movement_state_t>;
};
// requires requires(typename T::hardware_state_t state) {
// // encoder co-longitude and co-latiitude positions, as well as its measurement time point
// // the given constrains on coordinate pair kind can be used to deduce mount type
// requires mcc_coord_pair_c<decltype(state.XY)> &&
// ( // for equathorial mount:
// decltype(state.XY)::pairKind == impl::MccCoordPairKind::COORDS_KIND_HADEC_OBS ||
// // for alt-azimuthal mount:
// decltype(state.XY)::pairKind == impl::MccCoordPairKind::COORDS_KIND_AZALT ||
// decltype(state.XY)::pairKind == impl::MccCoordPairKind::COORDS_KIND_AZZD);
// // co-longitude and co-latiitude axis angular speeds, as well as its measurement/computation time point
// requires mcc_coord_pair_c<decltype(state.speedXY)> &&
// (decltype(state.XY)::pairKind == impl::MccCoordPairKind::COORDS_KIND_GENERIC ||
// decltype(state.XY)::pairKind == impl::MccCoordPairKind::COORDS_KIND_XY);
// requires std::same_as<typename T::hardware_movement_state_t, decltype(state.movementState)>;
// };
// set hardware state:
{ t.hardwareSetState(std::declval<typename T::hardware_state_t const&>()) } -> std::same_as<typename T::error_t>;
@@ -747,6 +720,8 @@ concept mcc_hardware_c = requires(T t) {
// { t.hardwareStop() } -> std::same_as<typename T::error_t>; // stop any moving
{ t.hardwareInit() } -> std::same_as<typename T::error_t>; // initialize hardware
{ t.hardwareShutdown() } -> std::same_as<typename T::error_t>; // shutdown hardware
};
@@ -832,7 +807,8 @@ struct mcc_telemetry_interface_t {
};
template <typename T>
concept mcc_telemetry_c = std::derived_from<T, mcc_telemetry_interface_t<typename T::error_t>> && requires(T t) {
concept mcc_telemetry_c =
std::derived_from<T, mcc_telemetry_interface_t<typename T::error_t>> && requires(T t, const T t_const) {
// error type
requires mcc_error_c<typename T::error_t>;
@@ -841,7 +817,9 @@ concept mcc_telemetry_c = std::derived_from<T, mcc_telemetry_interface_t<typenam
// get telemetry data
{ t.telemetryData(std::declval<typename T::telemetry_data_t*>()) } -> std::same_as<typename T::error_t>;
};
{ t_const.getPointingTarget() } -> mcc_skypoint_c;
};

View File

@@ -19,6 +19,9 @@ namespace mcc
{
static constexpr double MCC_DEGRESS_TO_RADS = std::numbers::pi / 180.0;
static constexpr double MCC_ARCMINS_TO_RADS = MCC_DEGRESS_TO_RADS / 60.0;
static constexpr double MCC_ARCSECS_TO_RADS = MCC_DEGRESS_TO_RADS / 3600.0;
static constexpr double MCC_RADS_TO_DEGRESS = 1.0 / MCC_DEGRESS_TO_RADS;
static constexpr double MCC_HALF_PI = std::numbers::pi / 2.0;

View File

@@ -69,7 +69,7 @@ public:
template <mcc_coord_epoch_c EpT = MccCelestialCoordEpoch>
MccCoordPair(CO_LON_T const& x, CO_LAT_T const& y, EpT const& epoch = EpT::now()) : _x(x), _y(y), _epoch(epoch)
{
normalize();
// normalize();
}
MccCoordPair(const MccCoordPair&) = default;
@@ -87,8 +87,10 @@ public:
setY((double)other.y());
setEpoch(other.epoch());
if constexpr (T::pairKind != pairKind) {
normalize();
}
}
template <mcc_coord_pair_c T>
@@ -100,8 +102,10 @@ public:
setY((double)other.y());
setEpoch(other.epoch());
if constexpr (T::pairKind != pairKind) {
normalize();
}
}
template <mcc_coord_pair_c T>
@@ -113,8 +117,10 @@ public:
setY((double)other.y());
setEpoch(other.epoch());
if constexpr (T::pairKind != pairKind) {
normalize();
}
}
template <mcc_coord_pair_c T>
@@ -126,8 +132,10 @@ public:
setY((double)other.y());
setEpoch(other.epoch());
if constexpr (T::pairKind != pairKind) {
normalize();
}
}
virtual ~MccCoordPair() = default;
@@ -171,14 +179,14 @@ public:
{
_x = x;
normalize();
// normalize();
}
void setY(const CO_LAT_T& y)
{
_y = y;
normalize();
// normalize();
}
void setEpoch(mcc_coord_epoch_c auto const& ep)
@@ -194,14 +202,23 @@ protected:
void normalize()
{
_x = CO_LON_T{_x};
_y = CO_LAT_T{_y};
/*
if constexpr (pairKind != MccCoordPairKind::COORDS_KIND_GENERIC &&
pairKind != MccCoordPairKind::COORDS_KIND_XY) {
if constexpr (pairKind == MccCoordPairKind::COORDS_KIND_HADEC_APP ||
pairKind == MccCoordPairKind::COORDS_KIND_HADEC_OBS) {
_x = (double)MccAngle(_x).normalize<MccAngle::NORM_KIND_180_180>();
} else { // RA, AZ
// if constexpr (pairKind == MccCoordPairKind::COORDS_KIND_HADEC_APP ||
// pairKind == MccCoordPairKind::COORDS_KIND_HADEC_OBS) {
// _x = (double)MccAngle(_x).normalize<MccAngle::NORM_KIND_180_180>();
// } else { // RA, AZ
// _x = (double)MccAngle(_x).normalize<MccAngle::NORM_KIND_0_360>();
// }
_x = (double)MccAngle(_x).normalize<MccAngle::NORM_KIND_0_360>();
}
// if (utils::isEqual((double)_x, MCC_TWO_PI)) {
// _x = 0.0;
// }
// DEC and ALT is [-90,90] degrees
if constexpr (pairKind != MccCoordPairKind::COORDS_KIND_AZZD) {
@@ -210,6 +227,7 @@ protected:
_y = (double)MccAngle(_y).normalize<MccAngle::NORM_KIND_0_180>();
}
}
*/
}
};
@@ -380,6 +398,14 @@ public:
using error_t = typename CCTE_T::error_t;
struct dist_result_t {
MccAngle dist{};
MccAngle dx{};
MccAngle dy{};
MccAngle x2{};
MccAngle y2{};
};
MccGenericSkyPoint() {}
template <mcc_coord_pair_c PT>
@@ -537,6 +563,78 @@ public:
return error_t{};
}
// 'inner' transformation
error_t to(MccCoordPairKind pair_kind)
{
return to(pair_kind, _epoch);
}
error_t to(MccCoordPairKind pair_kind, mcc_coord_epoch_c auto const& epoch)
{
// do not use here "mcc_coord_epoch_c::operator==" to avoid
// unnecessary computations (astrometrical algorithms mainly use Julian date as input)
if (pair_kind == _pairKind && utils::isEqual(epoch.MJD(), _epoch.MJD())) {
_epoch = epoch;
return error_t{};
}
auto tr_func = [&, this]<mcc_coord_pair_c T>(T& cp) {
if constexpr (T::pairKind != MccCoordPairKind::COORDS_KIND_RADEC_ICRS) {
cp.setEpoch(epoch);
}
auto err = to(cp);
if (!err) {
from(cp);
}
return err;
};
switch (pair_kind) {
case MccCoordPairKind::COORDS_KIND_RADEC_ICRS: {
MccSkyRADEC_ICRS cp;
return tr_func(cp);
} break;
case MccCoordPairKind::COORDS_KIND_RADEC_OBS: {
MccSkyRADEC_OBS cp;
return tr_func(cp);
} break;
case MccCoordPairKind::COORDS_KIND_RADEC_APP: {
MccSkyRADEC_APP cp;
return tr_func(cp);
} break;
case MccCoordPairKind::COORDS_KIND_HADEC_OBS: {
MccSkyHADEC_OBS cp;
return tr_func(cp);
} break;
case MccCoordPairKind::COORDS_KIND_HADEC_APP: {
MccSkyHADEC_APP cp;
return tr_func(cp);
} break;
case MccCoordPairKind::COORDS_KIND_AZZD: {
MccSkyAZZD cp;
return tr_func(cp);
} break;
case MccCoordPairKind::COORDS_KIND_AZALT: {
MccSkyAZALT cp;
return tr_func(cp);
} break;
case MccCoordPairKind::COORDS_KIND_GENERIC:
case MccCoordPairKind::COORDS_KIND_UNKNOWN:
case MccCoordPairKind::COORDS_KIND_LONLAT:
case MccCoordPairKind::COORDS_KIND_XY: {
MccGenXY cp;
return tr_func(cp);
} break;
default:
return error_t{};
}
return error_t{};
}
error_t refractCorrection(mcc_angle_c auto* dZ) const
{
@@ -613,11 +711,34 @@ public:
return cctEngine.equationOrigins(_epoch, eo);
}
dist_result_t distance(MccGenericSkyPoint const& sp) const
// dist_result_t distance(mcc_skypoint_c auto const& sp)
{
double x, y;
if (_pairKind == sp.pairKind() && utils::isEqual(_epoch.MJD(), sp.epoch().MJD())) {
x = sp.co_lon();
y = sp.co_lat();
} else { // convert to the same coordinates kind
MccGenericSkyPoint p{sp};
p.to(_pairKind, _epoch);
x = p.co_lon();
y = p.co_lat();
}
auto d = utils::distanceOnSphere(_x, _y, x, y);
return {.dist = std::get<2>(d), .dx = std::get<0>(d), .dy = std::get<1>(d), .x2 = x, .y2 = y};
}
protected:
double _x{0.0}, _y{0.0};
MccCoordPairKind _pairKind{MccCoordPairKind::COORDS_KIND_RADEC_ICRS};
MccCelestialCoordEpoch _epoch{}; // J2000.0
template <mcc_skypoint_c T>
void fromOtherSkyPoint(T&& other)
{
@@ -751,6 +872,8 @@ protected:
double phi = cctEngine.getStateERFA().lat;
double ra_icrs, dec_icrs, ra, dec, ha, az, zd, alt, lst, eo;
static_assert(PT::pairKind != MccCoordPairKind::COORDS_KIND_LONLAT, "UNSUPPORTED SKY POINT TRANSFORMATION!");
// static_assert(PT::pairKind != MccCoordPairKind::COORDS_KIND_XY, "UNSUPPORTED SKY POINT TRANSFORMATION!");
static_assert(PT::pairKind != MccCoordPairKind::COORDS_KIND_GENERIC, "UNSUPPORTED SKY POINT TRANSFORMATION!");
static_assert(PT::pairKind != MccCoordPairKind::COORDS_KIND_UNKNOWN, "UNSUPPORTED SKY POINT TRANSFORMATION!");
@@ -786,7 +909,8 @@ protected:
// 1) convert stored coordinates to ICRS ones
// 2) convert from the computed ICRS coordinates to required ones
MccCoordPairKind pkind = _pairKind;
if (!utils::isEqual(_epoch.MJD(), cpair.MJD())) { // convert stored pair to ICRS one (ra_icrs, dec_icrs)
if (!utils::isEqual(_epoch.MJD(),
cpair.MJD())) { // convert stored pair to ICRS one (ra_icrs, dec_icrs)
if (_pairKind != MccCoordPairKind::COORDS_KIND_RADEC_ICRS) {
pkind = MccCoordPairKind::COORDS_KIND_RADEC_ICRS;
@@ -955,7 +1079,8 @@ protected:
cpair.setY(dec);
} else {
obj->hadec2azalt(ha, dec, phi, az, alt);
if constexpr (mccIsObsCoordPairKind<PT::pairKind>) { // RADEC_OBS, HADEC_OBS, AZALT, AZZD
if constexpr (mccIsObsCoordPairKind<PT::pairKind>) { // RADEC_OBS, HADEC_OBS,
// AZALT, AZZD
// correct for refraction: alt += dz_refr
double dZ;
ccte_err = cctEngine.refractionInverseCorrection(MCC_HALF_PI - alt, &dZ);
@@ -1008,7 +1133,8 @@ protected:
};
/* MCC-LIBRARY DEFAULT SKY POINT CLASS IMPLEMENTATION BASED ON THE ERFA LIBRARY */
/* MCC-LIBRARY DEFAULT SKY POINT CLASS IMPLEMENTATION BASED ON THE ERFA LIBRARY
*/
typedef MccGenericSkyPoint<mcc::ccte::erfa::MccCCTE_ERFA> MccSkyPoint;

View File

@@ -126,19 +126,23 @@ protected:
return MccDeserializerErrorCode::ERROR_OK;
}
auto r_str = std::views::split(input, params.seq_delim);
// auto r_str = std::views::split(input, params.seq_delim);
auto r_str = std::views::split(input, params.elem_delim);
VT val;
auto it = r.begin();
for (auto const& el : r_str) {
auto err = dsr(el, val, std::forward<DeserParamsT>(params)...);
// auto err = dsr(el, val, std::forward<DeserParamsT>(params)...);
auto err = dsr(el, val, params);
if (err) {
return mcc_deduced_err(err, MccDeserializerErrorCode::ERROR_UNDERLYING_DESERIALIZER);
}
if (it == r.end()) {
if constexpr (!traits::mcc_fixed_size_range<R>) {
std::back_inserter(r) = val;
it = r.end();
}
} else {
*it = val;
++it;
@@ -282,11 +286,15 @@ struct MccDeserializer<VT> : MccDeserializerBase {
// valid format: X<elem-delim>Y[<elem-delim>TIME-POINT<elem-delim>PAIR-KIND]
// X<elem-delim>Y (assumed RADEC_ICRS and J2000.0 epoch)
// valid format: X<elem-delim>Y<elem-delim>PAIRKIND<elem-delim>EPOCH
// X<elem-delim>Y<elem-delim>PAIRKIND (assumed epoch is NOW, or J2000.0 if PAIRKIND == RADEC-ICRS)
// X<elem-delim>Y (assumed RADEC-ICRS and J2000.0 epoch)
bool empty;
auto elems = MccDeserializerBase::splitValueIntoElements(input, params, empty);
if (empty || (elems.size() < 2) || (elems.size() == 3)) {
if (empty || (elems.size() < 2)) {
return MccDeserializerErrorCode::ERROR_INVALID_SERIALIZED_VALUE;
}
@@ -298,19 +306,29 @@ struct MccDeserializer<VT> : MccDeserializerBase {
typename MccDeserializer<MccAngle>::error_t dsr_err;
if (elems.size() > 3) { // full format
if (elems.size() > 2) { // no epoch
// deserialize pair kind string
pair_kind = MccCoordStrToPairKind(elems[3]);
pair_kind = MccCoordStrToPairKind(elems[2]);
if (pair_kind == MccCoordPairKind::COORDS_KIND_UNKNOWN) {
return MccDeserializerErrorCode::ERROR_INVALID_SERIALIZED_VALUE;
}
if (pair_kind != MccCoordPairKind::COORDS_KIND_RADEC_ICRS) {
epoch = MccCelestialCoordEpoch::now();
}
}
if (elems.size() > 3) { // full format
// epoch
bool ok = epoch.fromCharRange(elems[2]);
if (pair_kind != MccCoordPairKind::COORDS_KIND_RADEC_ICRS) { // ignore epoch if PAIRKIND == RADEC-ICRS
bool ok = epoch.fromCharRange(elems[3]);
if (!ok) {
return MccDeserializerErrorCode::ERROR_INVALID_SERIALIZED_VALUE;
}
}
}
// deserialize X and Y
if (params.coordpair_format == MccSerializedCoordPairFormat::MCC_SERIALIZED_FORMAT_SXGM_HOURDEG) {
@@ -375,8 +393,7 @@ struct MccDeserializer<MccCoordPairKind> : MccDeserializerBase {
static constexpr std::string_view deserializerName{"MCC-COORDPAIR-DESERIALIZER"};
template <mcc_serialization_params_c ParamsT = mcc_serialization_params_t>
error_t operator ()(
traits::mcc_input_char_range auto const& input,
error_t operator()(traits::mcc_input_char_range auto const& input,
MccCoordPairKind& value,
ParamsT const& params = mcc_serialization_params_t{})
{
@@ -396,8 +413,7 @@ struct MccDeserializer<MccSerializedAngleFormatPrec> : MccDeserializerBase {
static constexpr std::string_view deserializerName{"MCC-ANGLE-FORMAT-PREC-DESERIALIZER"};
template <mcc_serialization_params_c ParamsT = mcc_serialization_params_t>
error_t operator ()(
traits::mcc_input_char_range auto const& input,
error_t operator()(traits::mcc_input_char_range auto const& input,
MccSerializedAngleFormatPrec& value,
ParamsT const& params = mcc_serialization_params_t{})
{
@@ -433,8 +449,7 @@ struct MccDeserializer<MccSerializedCoordPairFormat> : MccDeserializerBase {
static constexpr std::string_view deserializerName{"MCC-COORDPAIR-FORMAT-DESERIALIZER"};
template <mcc_serialization_params_c ParamsT = mcc_serialization_params_t>
error_t operator ()(
traits::mcc_input_char_range auto const& input,
error_t operator()(traits::mcc_input_char_range auto const& input,
MccSerializedCoordPairFormat& value,
ParamsT const& params = mcc_serialization_params_t{})
{

View File

@@ -62,6 +62,26 @@ public:
fromTimePoint(std::forward<decltype(other)>(other).UTC());
}
MccCelestialCoordEpoch(traits::mcc_input_char_range auto&& str)
{
// ignore possible errors!!!
fromCharRange(std::forward<decltype(str)>(str));
}
template <typename ClockT, typename DurT>
MccCelestialCoordEpoch(std::chrono::time_point<ClockT, DurT> const& tp) : MccCelestialCoordEpoch()
{
fromTimePoint(tp);
}
template <typename VT>
MccCelestialCoordEpoch(VT&& mjd)
requires std::is_arithmetic_v<std::remove_cvref_t<VT>>
{
// ignore possible errors!!!
fromMJD(std::forward<decltype(mjd)>(mjd));
}
MccCelestialCoordEpoch& operator=(mcc_coord_epoch_c auto&& other)
{
fromTimePoint(std::forward<decltype(other)>(other).UTC());
@@ -79,17 +99,17 @@ public:
template <typename ClockT, typename DurT>
MccCelestialCoordEpoch& operator=(std::chrono::time_point<ClockT, DurT>&& tp)
MccCelestialCoordEpoch& operator=(std::chrono::time_point<ClockT, DurT> const& tp)
{
// ignore possible errors!!!
auto ok = fromTimePoint(std::forward<decltype(tp)>(tp));
auto ok = fromTimePoint(tp);
return *this;
}
template <typename VT>
MccCelestialCoordEpoch& operator=(VT&& mjd)
requires std::is_arithmetic_v<VT>
requires std::is_arithmetic_v<std::remove_cvref_t<VT>>
{
// ignore possible errors!!!
auto ok = fromMJD(std::forward<decltype(mjd)>(mjd));
@@ -139,17 +159,17 @@ public:
}
template <typename ClockT, typename DurT>
bool fromTimePoint(std::chrono::time_point<ClockT, DurT>&& tp)
bool fromTimePoint(std::chrono::time_point<ClockT, DurT> const& tp)
{
if constexpr (std::same_as<ClockT, std::chrono::system_clock>) {
_UTC = std::chrono::time_point_cast<decltype(_UTC)::duration>(std::forward<decltype(tp)>(tp));
_UTC = std::chrono::time_point_cast<decltype(_UTC)::duration>(tp);
} else if constexpr (std::same_as<ClockT, std::chrono::utc_clock>) {
auto stp = std::chrono::utc_clock::to_sys(std::forward<decltype(tp)>(tp));
_UTC = std::chrono::time_point_cast<decltype(_UTC)::duration>(std::forward<decltype(tp)>(stp));
auto stp = std::chrono::utc_clock::to_sys(tp);
_UTC = std::chrono::time_point_cast<decltype(_UTC)::duration>(stp);
} else if constexpr (std::same_as<ClockT, std::chrono::tai_clock>) {
return fromTimePoint(ClockT::to_utc(std::forward<decltype(tp)>(tp)));
return fromTimePoint(ClockT::to_utc(tp));
} else if constexpr (std::same_as<ClockT, std::chrono::gps_clock>) {
return fromTimePoint(ClockT::to_utc(std::forward<decltype(tp)>(tp)));
return fromTimePoint(ClockT::to_utc(tp));
} else {
static_assert(false, "UNSUPPORTED CLOCK!!!");
}
@@ -407,6 +427,5 @@ protected:
static_assert(mcc_coord_epoch_c<MccCelestialCoordEpoch>, "!!!");
static_assert(requires(MccCelestialCoordEpoch ep) { ep = std::chrono::system_clock::now(); });
} // namespace mcc::impl

View File

@@ -147,9 +147,9 @@ public:
std::tuple<MoveCntrCtorTs...> move_cntrl_ctor_ars,
std::tuple<LoggerCtorTs...> logger_ctor_args)
: TELEMETRY_T(std::make_from_tuple<TELEMETRY_T>(std::move(telemetry_ctor_args))),
PZONE_CONT_T(std::make_from_tuple<PZONE_CONT_T>(pzone_cont_ctor_ars)),
MOVE_CNTRL_T(std::make_from_tuple<MOVE_CNTRL_T>(move_cntrl_ctor_ars)),
LOGGER_T(std::make_from_tuple<LOGGER_T>(logger_ctor_args))
PZONE_CONT_T(std::make_from_tuple<PZONE_CONT_T>(std::move(pzone_cont_ctor_ars))),
MOVE_CNTRL_T(std::make_from_tuple<MOVE_CNTRL_T>(std::move(move_cntrl_ctor_ars))),
LOGGER_T(std::make_from_tuple<LOGGER_T>(std::move(logger_ctor_args)))
{
// logDebug(std::format("Create MccGenericMount class instance (thread: {})", std::this_thread::get_id()));
logDebug("Create MccGenericMount class instance (thread: {})", std::this_thread::get_id());
@@ -183,18 +183,21 @@ public:
virtual ~MccGenericMount()
{
// auto err = MOVE_CNTRL_T::stopMount();
// if (err) {
// logError(formatError(err));
// }
// WARNING: it is assumed here that mount stopping is performed in a derived class or, it is more logicaly,
// in MOVE_CNTRL_T-class
// logDebug(std::format("Delete MccGenericMount class instance (thread: {})", std::this_thread::get_id()));
logDebug("Delete MccGenericMount class instance (thread: {})", std::this_thread::get_id());
auto err = MOVE_CNTRL_T::stopMount();
if (err) {
logError(formatError(err));
}
}
error_t initMount()
{
logInfo(std::format("Start MccGenericMount class initialization (thread: {}) ...", std::this_thread::get_id()));
logInfo("Start MccGenericMount class initialization (thread: {}) ...", std::this_thread::get_id());
*_mountStatus = mount_status_t::MOUNT_STATUS_IDLE;
@@ -258,7 +261,7 @@ protected:
std::string formatError(error_t const& err, std::string_view prefix = "") const
{
return std::format("{}{} (category: {}, code: {})", prefix, err.message(), err.value(), err.category().name());
return std::format("{}{} (category: {}, code: {})", prefix, err.message(), err.category().name(), err.value());
}
};

View File

@@ -0,0 +1,720 @@
#pragma once
/****************************************************************************************
* *
* MOUNT CONTROL COMPONENTS LIBRARY *
* *
* *
* GENERIC IMPLEMENTATION OF MOUNT MOVEMENT CONTROLS *
* *
****************************************************************************************/
#include <atomic>
#include <fstream>
#include <future>
#include <thread>
#include <type_traits>
#include <print>
#include "mcc_coordinate.h"
#include "mcc_error.h"
namespace mcc::impl
{
// mount movement-related generic errors
enum class MccGenericMovementControlsErrorCode : int {
ERROR_OK,
ERROR_IN_PZONE,
ERROR_NEAR_PZONE,
ERROR_SLEW_TIMEOUT,
ERROR_STOP_TIMEOUT,
ERROR_HARDWARE,
ERROR_TELEMETRY_TIMEOUT
};
} // namespace mcc::impl
namespace std
{
template <>
class is_error_code_enum<mcc::impl::MccGenericMovementControlsErrorCode> : public true_type
{
};
} // namespace std
namespace mcc::impl
{
// error category
struct MccGenericMovementControlsErrorCategory : std::error_category {
const char* name() const noexcept
{
return "MCC-GENERIC-MOVECONTRL";
}
std::string message(int ec) const
{
MccGenericMovementControlsErrorCode err = static_cast<MccGenericMovementControlsErrorCode>(ec);
switch (err) {
case MccGenericMovementControlsErrorCode::ERROR_OK:
return "OK";
case MccGenericMovementControlsErrorCode::ERROR_IN_PZONE:
return "target is in zone";
case MccGenericMovementControlsErrorCode::ERROR_NEAR_PZONE:
return "mount is near zone";
case MccGenericMovementControlsErrorCode::ERROR_SLEW_TIMEOUT:
return "a timeout occured while slewing";
case MccGenericMovementControlsErrorCode::ERROR_STOP_TIMEOUT:
return "a timeout occured while mount stopping";
case MccGenericMovementControlsErrorCode::ERROR_HARDWARE:
return "a hardware error occured";
case MccGenericMovementControlsErrorCode::ERROR_TELEMETRY_TIMEOUT:
return "telemetry data timeout";
default:
return "unknown";
}
}
static const MccGenericMovementControlsErrorCategory& get()
{
static const MccGenericMovementControlsErrorCategory constInst;
return constInst;
}
};
inline std::error_code make_error_code(MccGenericMovementControlsErrorCode ec)
{
return std::error_code(static_cast<int>(ec), MccGenericMovementControlsErrorCategory::get());
}
struct MccGenericMovementControlsParams {
// timeout to telemetry updating
std::chrono::milliseconds telemetryTimeout{3000};
// braking acceleration after execution of mount stopping command (in rads/s^2)
// it must be given as non-negative value!!!
double brakingAccelX{0.0};
double brakingAccelY{0.0};
// ******* slewing mode *******
// coordinates difference to stop slewing (in radians)
double slewToleranceRadius{5.0_arcsecs};
// slewing trajectory file. if empty - just skip saving
std::string slewingPathFilename{};
// ******* tracking mode *******
// maximal target-to-mount difference for tracking process (in arcsecs)
// it it is greater then the current mount coordinates are used as target one
double trackingMaxCoordDiff{20.0};
// tracking trajectory file. if empty - just skip saving
std::string trackingPathFilename{};
};
/* UTILITY CLASS TO HOLD AND SAVE MOUNT MOVING TRAJECTORY */
struct MccMovementPathFile {
static constexpr std::string_view commentSeq{"# "};
static constexpr std::string_view lineDelim{"\n"};
void setCommentSeq(traits::mcc_input_char_range auto const& s)
{
_commentSeq.clear();
std::ranges::copy(s, std::back_inserter(_commentSeq));
}
void setLineDelim(traits::mcc_input_char_range auto const& s)
{
_lineDelim.clear();
std::ranges::copy(s, std::back_inserter(_lineDelim));
}
// add comment string/strings
template <traits::mcc_input_char_range RT, traits::mcc_input_char_range... RTs>
void addComment(RT const& r, RTs const&... rs)
{
std::ranges::copy(_commentSeq, std::back_inserter(_buffer));
if constexpr (std::is_pointer_v<std::decay_t<RT>>) { // const char*, char*, char[]
std::ranges::copy(std::string_view{r}, std::back_inserter(_buffer));
} else {
std::ranges::copy(r, std::back_inserter(_buffer));
}
std::ranges::copy(lineDelim, std::back_inserter(_buffer));
if constexpr (sizeof...(RTs)) {
addComment(rs...);
}
}
// comment corresponded to addToPath(mcc_telemetry_data_c auto const& tdata)
void addDefaultComment()
{
addComment("Format (time is in milliseconds, coordinates are in degrees, speeds are in degrees/s):");
addComment(
" <UNIXTIME> <mount X> <mount Y> <target X> <target Y> <dX_{mount-target}> "
"<dY_{mount-target}> <mount-to-target-distance> <mount X-speed> <mount Y-speed> <moving state>");
}
// general purpose method
// template <std::formattable<char>... ArgTs>
// void addToPath(std::format_string<ArgTs...> fmt, ArgTs&&... args)
// {
// std::format_to(std::back_inserter(_buffer), fmt, std::forward<ArgTs>(args)...);
// std::ranges::copy(lineDelim, std::back_inserter(_buffer));
// }
// general purpose method
template <std::formattable<char>... ArgTs>
void addToPath(std::string_view fmt, ArgTs&&... args)
{
std::vformat_to(std::back_inserter(_buffer), fmt, std::make_format_args(args...));
std::ranges::copy(lineDelim, std::back_inserter(_buffer));
}
// default-implemented method
void addToPath(mcc_telemetry_data_c auto const& tdata)
{
// UNIX-time millisecs, mount X, mount Y, target X, target Y, dX(mount-target), dY(mount-target), dist, speedX,
// speedY, state
auto dist = tdata.mountPos.distance(tdata.targetPos);
using d_t = std::chrono::milliseconds;
auto tp = std::chrono::duration_cast<d_t>(tdata.mountPos.epoch().UTC().time_since_epoch());
const std::string_view d_fmt = "{:14.8f}";
const auto v = std::views::repeat(d_fmt, 9) | std::views::join_with(' ');
std::string fmt = "{} " + std::string(v.begin(), v.end()) + " {}";
int state = (int)tdata.hwState.movementState;
auto tp_val = tp.count();
double mnt_x = MccAngle(tdata.mountPos.co_lon()).degrees(), mnt_y = MccAngle(tdata.mountPos.co_lon()).degrees(),
tag_x = dist.x2.degrees(), tag_y = dist.y2.degrees(), dx = dist.dx.degrees(), dy = dist.dy.degrees(),
dd = dist.dist.degrees();
addToPath(std::string_view(fmt.begin(), fmt.end()), tp_val, mnt_x, mnt_y, tag_x, tag_y, dx, dy, dd,
tdata.hwState.speedXY.x().degrees(), tdata.hwState.speedXY.y().degrees(), state);
}
void clearPath()
{
_buffer.clear();
}
bool saveToFile(std::string const& filename, std::ios_base::openmode mode = std::ios::out | std::ios::trunc)
{
if (filename.empty()) {
return true;
}
std::ofstream fst(filename, mode);
if (fst.is_open()) {
fst << _buffer;
return true;
} else {
return false;
}
}
protected:
std::string _buffer{};
std::string _commentSeq{commentSeq};
std::string _lineDelim{lineDelim};
};
enum class MccGenericMovementControlsPolicy : int { POLICY_ASYNC, POLICY_BLOCKING };
template <std::movable PARAMS_T,
MccGenericMovementControlsPolicy EXEC_POLICY = MccGenericMovementControlsPolicy::POLICY_ASYNC>
class MccGenericMovementControls
{
public:
static constexpr MccGenericMovementControlsPolicy executePolicy = EXEC_POLICY;
static constexpr std::chrono::seconds defaultWaitTimeout{3};
typedef MccError error_t;
typedef PARAMS_T movement_params_t;
template <std::invocable<bool> SLEW_FUNC_T, std::invocable<> TRACK_FUNC_T, std::invocable<> STOP_FUNC_T>
MccGenericMovementControls(SLEW_FUNC_T&& slew_func, TRACK_FUNC_T&& track_func, STOP_FUNC_T&& stop_func)
: _slewFunc(std::forward<SLEW_FUNC_T>(slew_func)),
_trackFunc(std::forward<TRACK_FUNC_T>(track_func)),
_stopFunc(std::forward<STOP_FUNC_T>(stop_func))
{
if constexpr (executePolicy == MccGenericMovementControlsPolicy::POLICY_ASYNC) {
// *_stopMovementRequest = false;
// *_fsmState = STATE_IDLE;
// // start thread of movements
// _fstFuture = std::async(
// [this](std::stop_token stoken) {
// auto do_state = _fsmState->load();
// while (!stoken.stop_requested()) {
// std::println("\n{:*^80}\n", " WAIT LOCK ");
// // wait here ...
// _wakeupRequest->wait(false, std::memory_order_relaxed);
// _wakeupRequest->clear();
// std::println("\n{:*^80}\n", " UNLOCKED ");
// // if (stoken.stop_requested()) {
// // break;
// // }
// do_state = _fsmState->load();
// if (do_state & STATE_STOP) {
// // if (_fsmState->load() & STATE_STOP) {
// *_stopMovementRequest = true;
// _stopFunc();
// }
// if (do_state & STATE_SLEW) {
// // if (_fsmState->load() & STATE_SLEW) {
// *_stopMovementRequest = false;
// _slewFunc(_slewAndStop->load());
// } else if (do_state & STATE_TRACK) {
// // } else if (_fsmState->load() & STATE_TRACK) {
// *_stopMovementRequest = false;
// _trackFunc();
// }
// }
// },
// _fstStopSource.get_token());
startAsyncMovementCycle();
}
}
MccGenericMovementControls(const MccGenericMovementControls&) = delete;
MccGenericMovementControls(MccGenericMovementControls&& other) = default;
MccGenericMovementControls& operator=(const MccGenericMovementControls&) = delete;
MccGenericMovementControls& operator=(MccGenericMovementControls&&) = default;
virtual ~MccGenericMovementControls()
{
if constexpr (executePolicy == MccGenericMovementControlsPolicy::POLICY_ASYNC) {
// *_fsmState = STATE_IDLE;
// _fstStopSource.request_stop();
// _wakeupRequest->test_and_set();
// _wakeupRequest->notify_one();
// std::this_thread::sleep_for(std::chrono::milliseconds(200));
// if (_fstFuture.valid()) {
// auto status = _fstFuture.wait_for(_waitTimeout->load());
// }
stopAsyncMovementCycle();
}
}
template <typename SelfT>
void stopAsyncMovementCycle(this SelfT&& self)
requires(EXEC_POLICY == MccGenericMovementControlsPolicy::POLICY_ASYNC)
{
*self._fsmState = STATE_IDLE;
self._fstStopSource.request_stop();
self._wakeupRequest->test_and_set();
self._wakeupRequest->notify_all();
std::this_thread::sleep_for(std::chrono::milliseconds(200));
if (self._fstFuture.valid()) {
auto status = self._fstFuture.wait_for(self._waitTimeout->load());
}
}
template <typename SelfT>
void startAsyncMovementCycle(this SelfT& self)
requires(EXEC_POLICY == MccGenericMovementControlsPolicy::POLICY_ASYNC)
{
using self_t = std::decay_t<SelfT>;
if (self._fstFuture.valid()) {
self.stopAsyncMovementCycle();
}
*self._stopMovementRequest = false;
self._fstStopSource = std::stop_source{};
*self._fsmState = STATE_IDLE;
// start thread of movements
self._fstFuture = std::async(
std::launch::async,
[&self](std::stop_token stoken) mutable {
auto do_state = self._fsmState->load();
std::string log_str;
while (!stoken.stop_requested()) {
log_str = std::format("\n{:*^80}\n", " WAIT LOCK ");
if constexpr (mcc_generic_mount_c<self_t>) {
self.logTrace(log_str);
} else {
std::println("{}", log_str);
}
// wait here ...
self._wakeupRequest->wait(false, std::memory_order_relaxed);
self._wakeupRequest->clear();
// if (stoken.stop_requested()) {
// break;
// }
do_state = self._fsmState->load();
log_str = std::format(" UNLOCKED WITH STATE (STOP = {} SLEW = {} TRACK = {}) ",
do_state & STATE_STOP, do_state & STATE_SLEW, do_state & STATE_TRACK);
log_str = std::format("\n{:*^80}\n", log_str);
if constexpr (mcc_generic_mount_c<self_t>) {
self.logTrace(log_str);
} else {
std::println("{}", log_str);
}
if (do_state & STATE_STOP) {
// if (_fsmState->load() & STATE_STOP) {
*self._stopMovementRequest = true;
self._stopFunc();
}
if (do_state & STATE_SLEW) {
// if (_fsmState->load() & STATE_SLEW) {
*self._stopMovementRequest = false;
self._slewFunc(self._slewAndStop->load());
} else if (do_state & STATE_TRACK) {
// } else if (_fsmState->load() & STATE_TRACK) {
*self._stopMovementRequest = false;
self._trackFunc();
}
}
},
self._fstStopSource.get_token());
}
error_t slewToTarget(bool slew_and_stop)
{
// *_stopMovementRequest = false;
if constexpr (executePolicy == MccGenericMovementControlsPolicy::POLICY_ASYNC) {
auto prev_state = _fsmState->load();
*_fsmState = STATE_SLEW;
if (prev_state & STATE_SLEW || prev_state & STATE_TRACK) {
*_fsmState |= STATE_STOP;
*_stopMovementRequest = true; // to exit from slewing or tracking
}
*_slewAndStop = slew_and_stop;
_wakeupRequest->test_and_set();
_wakeupRequest->notify_one();
return MccGenericMovementControlsErrorCode::ERROR_OK;
} else if constexpr (executePolicy == MccGenericMovementControlsPolicy::POLICY_BLOCKING) {
return _slewFunc(slew_and_stop);
} else {
static_assert(false, "UNKNOWN EXECUTION POLICY!");
}
}
error_t trackTarget()
{
// *_stopMovementRequest = false;
if constexpr (executePolicy == MccGenericMovementControlsPolicy::POLICY_ASYNC) {
auto prev_state = _fsmState->load();
if (!(prev_state & STATE_TRACK)) {
*_fsmState = STATE_TRACK;
if (prev_state & STATE_SLEW) {
*_fsmState |= STATE_STOP;
*_stopMovementRequest = true; // to exit from slewing
}
_wakeupRequest->test_and_set();
_wakeupRequest->notify_one();
} // already tracking, just ignore
return MccGenericMovementControlsErrorCode::ERROR_OK;
} else if constexpr (executePolicy == MccGenericMovementControlsPolicy::POLICY_BLOCKING) {
return _trackFunc();
} else {
static_assert(false, "UNKNOWN EXECUTION POLICY!");
}
}
error_t stopMount()
{
// *_stopMovementRequest = true;
if constexpr (executePolicy == MccGenericMovementControlsPolicy::POLICY_ASYNC) {
*_fsmState = STATE_STOP;
*_stopMovementRequest = true; // to exit from slewing or tracking
_wakeupRequest->test_and_set();
_wakeupRequest->notify_one();
return MccGenericMovementControlsErrorCode::ERROR_OK;
} else if constexpr (executePolicy == MccGenericMovementControlsPolicy::POLICY_BLOCKING) {
return _stopFunc();
} else {
static_assert(false, "UNKNOWN EXECUTION POLICY!");
}
}
error_t setMovementParams(movement_params_t const& pars)
{
std::lock_guard lock{*_currentMovementParamsMutex};
_currentMovementParams = pars;
return MccGenericMovementControlsErrorCode::ERROR_OK;
}
movement_params_t getMovementParams() const
{
std::lock_guard lock{*_currentMovementParamsMutex};
return _currentMovementParams;
}
protected:
std::unique_ptr<std::mutex> _currentMovementParamsMutex{new std::mutex{}};
PARAMS_T _currentMovementParams{};
std::unique_ptr<std::atomic_bool> _stopMovementRequest{new std::atomic_bool{false}};
std::function<error_t(bool)> _slewFunc{};
std::function<error_t()> _trackFunc{};
std::function<error_t()> _stopFunc{};
std::unique_ptr<std::atomic<std::chrono::nanoseconds>> _waitTimeout{
new std::atomic<std::chrono::nanoseconds>{defaultWaitTimeout}};
std::conditional_t<executePolicy == MccGenericMovementControlsPolicy::POLICY_ASYNC,
std::future<void>,
std::nullptr_t>
_fstFuture{};
std::stop_source _fstStopSource{};
std::unique_ptr<std::atomic_flag> _wakeupRequest{new std::atomic_flag};
std::unique_ptr<std::atomic_bool> _slewAndStop{new std::atomic_bool{false}};
enum { STATE_IDLE = 0x00, STATE_SLEW = 0x01, STATE_TRACK = 0x02, STATE_STOP = 0x04 };
std::unique_ptr<std::atomic_int> _fsmState{new std::atomic_int};
// template <typename SelfT>
// void mainCycle(this SelfT&& self, std::stop_token stoken)
// {
// using self_t = std::decay_t<SelfT>;
// auto do_state = _fsmState->load();
// std::string log_str;
// while (!stoken.stop_requested()) {
// log_str = std::format("\n{:*^80}\n", " WAIT LOCK ");
// if constexpr (mcc_generic_mount_c<self_t>) {
// self.logTrace(log_str);
// } else {
// std::println(log_str);
// }
// // wait here ...
// _wakeupRequest->wait(false, std::memory_order_relaxed);
// _wakeupRequest->clear();
// log_str = std::format("\n{:*^80}\n", " UNLOCKED ");
// if constexpr (mcc_generic_mount_c<self_t>) {
// self.logTrace(log_str);
// } else {
// std::println(log_str);
// }
// // if (stoken.stop_requested()) {
// // break;
// // }
// do_state = _fsmState->load();
// if (do_state & STATE_STOP) {
// // if (_fsmState->load() & STATE_STOP) {
// *_stopMovementRequest = true;
// _stopFunc();
// }
// if (do_state & STATE_SLEW) {
// // if (_fsmState->load() & STATE_SLEW) {
// *_stopMovementRequest = false;
// _slewFunc(_slewAndStop->load());
// } else if (do_state & STATE_TRACK) {
// // } else if (_fsmState->load() & STATE_TRACK) {
// *_stopMovementRequest = false;
// _trackFunc();
// }
// }
// }
// utility methods
// the method calculates the change in coordinates of a point over a given time given the current speed and braking
// acceleration. a position after given 'time' interval is returned
auto coordsAfterTime(mcc_coord_pair_c auto const& cp,
mcc_coord_pair_c auto const& speedXY, // in radians per seconds
mcc_coord_pair_c auto const& braking_accelXY, // in radians per seconds in square
traits::mcc_time_duration_c auto const& time,
mcc_coord_pair_c auto* dxy = nullptr)
{
// time to stop mount with given current speed and constant braking acceleration
double tx_stop = std::abs(speedXY.x()) / braking_accelXY.x();
double ty_stop = std::abs(speedXY.y()) / braking_accelXY.y();
using secs_t = std::chrono::duration<double>; // seconds as double
double tx = std::chrono::duration_cast<secs_t>(time).count();
double ty = std::chrono::duration_cast<secs_t>(time).count();
if (std::isfinite(tx_stop) && (tx > tx_stop)) {
tx = tx_stop;
}
if (std::isfinite(ty_stop) && (ty > ty_stop)) {
ty = ty_stop;
}
// the distance:
// here, one must take into account the sign of the speed!!!
double dx = speedXY.x() * tx - std::copysign(braking_accelXY.x(), speedXY.x()) * tx * tx / 2.0;
double dy = speedXY.y() * ty - std::copysign(braking_accelXY.y(), speedXY.y()) * ty * ty / 2.0;
std::remove_cvref_t<decltype(cp)> cp_res{};
cp_res.setEpoch(cp.epoch() + time);
cp_res.setX((double)cp.x() + dx);
cp_res.setY((double)cp.y() + dy);
if (dxy) {
dxy->setX(dx);
dxy->setY(dy);
dxy->setEpoch(cp_res.epoch());
}
return cp_res;
}
auto coordsAfterTime(mcc_skypoint_c auto const& sp,
mcc_coord_pair_c auto const& speedXY, // in radians per seconds
mcc_coord_pair_c auto const& braking_accelXY, // in radians per seconds in square
traits::mcc_time_duration_c auto const& time,
mcc_coord_pair_c auto* dxy = nullptr)
{
auto run_func = [&, this](auto& cp) {
sp.toAtSameEpoch(cp);
auto new_cp = coordsAfterTime(cp, speedXY, braking_accelXY, time, dxy);
std::remove_cvref_t<decltype(sp)> sp_res{};
sp_res.from(cp);
return sp_res;
};
switch (sp.pairKind()) {
case MccCoordPairKind::COORDS_KIND_RADEC_ICRS: {
MccSkyRADEC_ICRS rd;
return run_func(rd);
};
case MccCoordPairKind::COORDS_KIND_RADEC_OBS: {
MccSkyRADEC_OBS rd;
return run_func(rd);
};
case MccCoordPairKind::COORDS_KIND_RADEC_APP: {
MccSkyRADEC_APP rd;
return run_func(rd);
};
case MccCoordPairKind::COORDS_KIND_HADEC_OBS: {
MccSkyHADEC_OBS hd;
return run_func(hd);
};
case MccCoordPairKind::COORDS_KIND_HADEC_APP: {
MccSkyHADEC_APP hd;
return run_func(hd);
};
case MccCoordPairKind::COORDS_KIND_AZZD: {
MccSkyAZZD azzd;
return run_func(azzd);
};
case MccCoordPairKind::COORDS_KIND_AZALT: {
MccSkyAZALT azalt;
return run_func(azalt);
};
case MccCoordPairKind::COORDS_KIND_GENERIC:
case MccCoordPairKind::COORDS_KIND_XY: {
MccGenXY xy;
return run_func(xy);
};
default:
return sp;
}
}
};
template <std::default_initializable PARAMS_T>
using MccGenericBlockingMovementControls =
MccGenericMovementControls<PARAMS_T, MccGenericMovementControlsPolicy::POLICY_BLOCKING>;
template <std::default_initializable PARAMS_T>
using MccGenericAsyncMovementControls =
MccGenericMovementControls<PARAMS_T, MccGenericMovementControlsPolicy::POLICY_ASYNC>;
static_assert(mcc_movement_controls_c<MccGenericAsyncMovementControls<MccGenericMovementControlsParams>>, "!!!");
} // namespace mcc::impl

615
include/mcc/mcc_keyvalue.h Normal file
View File

@@ -0,0 +1,615 @@
#pragma once
/****************************************************************************************
* *
* MOUNT CONTROL COMPONENTS LIBRARY *
* *
* *
* IMPLEMENTATION OF KEY-VALUE PAIRS HOLDER *
* *
****************************************************************************************/
#include <unordered_map>
#include <unordered_set>
#include "mcc_deserializer.h"
#include "mcc_serializer.h"
#include "mcc_utils.h"
namespace mcc::impl
{
enum class MccKeyValueHolderErrorCode : int {
ERROR_OK,
ERROR_INVALID_KEY,
ERROR_INCOMPATIBLE_TYPE,
ERROR_DESERIAL,
ERROR_SERIAL
};
} // namespace mcc::impl
namespace std
{
template <>
class is_error_code_enum<mcc::impl::MccKeyValueHolderErrorCode> : public true_type
{
};
} // namespace std
namespace mcc::impl
{
// error category
struct MccKeyValueHolderCategory : public std::error_category {
MccKeyValueHolderCategory() : std::error_category() {}
const char* name() const noexcept override
{
return "MCC-KEYVALUEHOLDER-ERR-CATEGORY";
}
std::string message(int ec) const override
{
MccKeyValueHolderErrorCode err = static_cast<MccKeyValueHolderErrorCode>(ec);
switch (err) {
case MccKeyValueHolderErrorCode::ERROR_OK:
return "OK";
case MccKeyValueHolderErrorCode::ERROR_INVALID_KEY:
return "invalid key value";
case MccKeyValueHolderErrorCode::ERROR_INCOMPATIBLE_TYPE:
return "incompatible type";
case MccKeyValueHolderErrorCode::ERROR_DESERIAL:
return "deserialization error";
case MccKeyValueHolderErrorCode::ERROR_SERIAL:
return "serialization error";
default:
return "UNKNOWN";
}
}
static const MccKeyValueHolderCategory& get()
{
static const MccKeyValueHolderCategory constInst;
return constInst;
}
};
inline std::error_code make_error_code(MccKeyValueHolderErrorCode ec)
{
return std::error_code(static_cast<int>(ec), MccKeyValueHolderCategory::get());
}
// to follow std::variant requirements (not references, not array, not void)
template <typename T>
concept mcc_record_value_c = requires { !std::is_array_v<T> && !std::is_void_v<T> && !std::is_reference_v<T>; };
template <typename T>
concept mcc_keyvalue_record_c = requires(T t) {
requires std::same_as<decltype(t.key), const std::string_view>; // key name is immutable!!!
requires mcc_record_value_c<decltype(t.value)>; // value is mutable
requires mcc_record_value_c<decltype(t.default_value)>; // default value is mutable
requires mcc_serialization_params_c<decltype(t.serial_pars)>; // serialization parameters
};
// must be a std::tuple of mcc_keyvalue_record_c
template <typename T>
concept mcc_keyvalue_desc_c = requires(T t) { []<mcc_keyvalue_record_c... Ts>(std::tuple<Ts...>) {}(t); };
// use of 'inline' here to avoid '-Wsubobject-linkage' GCC-warning
inline constexpr char MCC_KV_COMMENT_SEQ_ARR[] = "#";
inline constexpr char MCC_KV_KEY_VALUE_DELIM_SEQ_ARR[] = "=";
inline constexpr char MCC_KV_COMPOSITE_VALUE_DELIM_SEQ_ARR[] = ",";
template <mcc_keyvalue_desc_c DESCR_T,
const char* COMM_SEQ = MCC_KV_COMMENT_SEQ_ARR, // comment char sequence
const char* KV_DELIM = MCC_KV_KEY_VALUE_DELIM_SEQ_ARR // key-value delimiter
>
class MccKeyValueHolder
{
public:
enum OutputPolicy {
OPOLICY_CHANGED_ONLY, // serialize only changed and previously deserialized (by fromCharRange method) key-value
// pairs
OPOLICY_FULL // serialize entire set of key-value pairs
};
static constexpr std::string_view DEFAULT_RECORD_DELIMITER{"\n"};
static constexpr std::string_view COMMENT_SEQ{COMM_SEQ == nullptr ? MCC_KV_COMMENT_SEQ_ARR
: COMM_SEQ[0] == '\0' ? MCC_KV_COMMENT_SEQ_ARR
: COMM_SEQ};
static constexpr std::string_view KEY_VALUE_DELIM{KV_DELIM == nullptr ? MCC_KV_KEY_VALUE_DELIM_SEQ_ARR
: KV_DELIM[0] == '\0' ? MCC_KV_KEY_VALUE_DELIM_SEQ_ARR
: KV_DELIM};
static constexpr size_t NUMBER_OF_RECORDS = std::tuple_size_v<DESCR_T>;
MccKeyValueHolder(DESCR_T desc) : _keyValue(desc)
{
[this]<size_t... I>(std::index_sequence<I...>) {
((_hashes[I] = utils::FNV1aHash(std::get<I>(_keyValue).key)), ...);
}(std::make_index_sequence<NUMBER_OF_RECORDS>());
_changedKey.insert_range(_hashes);
}
MccKeyValueHolder(MccKeyValueHolder const& other) : MccKeyValueHolder(other._keyValue)
{
copyInst(other);
};
MccKeyValueHolder(MccKeyValueHolder&& other)
{
moveInst(std::move(other));
};
MccKeyValueHolder& operator=(MccKeyValueHolder const& other)
{
copyInst(other);
return *this;
};
MccKeyValueHolder& operator=(MccKeyValueHolder&& other)
{
moveInst(std::move(other));
return *this;
};
constexpr std::array<std::string_view, NUMBER_OF_RECORDS> keys() const
{
return [this]<size_t... Is>(std::index_sequence<Is...>) {
return std::array<std::string_view, NUMBER_OF_RECORDS>{std::get<Is>(_keyValue).key...};
}(std::make_index_sequence<NUMBER_OF_RECORDS>{});
}
void setToDefaults()
{
[this]<size_t... Is>(std::index_sequence<Is...>) {
((std::get<Is>(_keyValue).value = std::get<Is>(_keyValue).default_value), ...);
}(std::make_index_sequence<NUMBER_OF_RECORDS>{});
}
template <typename T, std::ranges::contiguous_range R>
std::expected<T, std::error_code> getValue(R const& key) const
{
return getValue<T>(std::string_view{key});
}
template <typename T>
std::expected<T, std::error_code> getValue(std::string_view key) const
{
// ugly, but works for non-default constructible values
alignas(T) unsigned char buff[sizeof(T)];
auto err = forKey(key, [&buff](auto const& rec) -> std::error_code {
using VT = decltype(rec.value);
if constexpr (std::constructible_from<T, VT>) {
new (buff) T(rec.value);
} else {
return MccKeyValueHolderErrorCode::ERROR_INCOMPATIBLE_TYPE;
}
return MccKeyValueHolderErrorCode::ERROR_OK;
});
if (err) {
return std::unexpected(err);
} else {
auto ptr = reinterpret_cast<T*>(&buff[0]);
auto v = std::move(*ptr);
ptr->~T(); // one needs explicitly call destructor here to avvoid side effects!!!
return v;
}
}
// template <typename T>
// std::expected<T, std::error_code> getValue(std::string_view key) const
// {
// T v;
// auto err = forKey(key, [&v](auto const& rec) -> std::error_code {
// using VT = decltype(rec.value);
// if constexpr (std::convertible_to<VT, T>) {
// v = rec.value;
// } else if constexpr (std::constructible_from<T, VT>) {
// v = T(rec.value);
// } else {
// return MccKeyValueHolderErrorCode::ERROR_INCOMPATIBLE_TYPE;
// }
// return MccKeyValueHolderErrorCode::ERROR_OK;
// });
// if (err) {
// return std::unexpected(err);
// } else {
// return v;
// }
// }
template <std::ranges::contiguous_range R, typename T>
std::error_code setValue(R const& key, const T& value)
{
return setValue(std::string_view{key}, value);
}
template <typename T>
std::error_code setValue(std::string_view key, const T& value)
{
const size_t hash = utils::FNV1aHash(key);
auto ec = forHash(hash, [&value](auto& rec) -> std::error_code {
using VT = decltype(rec.value);
if constexpr (requires { rec.value = value; }) {
rec.value = value;
} else if constexpr (std::constructible_from<VT, T>) {
rec.value = VT(value);
} else if constexpr (std::ranges::range<VT> && std::ranges::range<T> &&
requires(std::ranges::range_value_t<VT> v, std::ranges::range_value_t<T> t) {
v = t;
}) {
const auto& val = std::is_pointer_v<std::decay_t<T>> ? std::span{value} : value;
size_t N = std::ranges::distance(rec.value.begin(), rec.value.end());
size_t M = std::ranges::distance(val.begin(), val.end());
auto it = std::ranges::begin(rec.value);
std::ranges::for_each_n(val.begin(), N > M ? M : N, [&it](auto const& el) {
*it = el;
++it;
});
if (N >= M) { // resize to match the size of the input range
if constexpr (!traits::mcc_non_resizable_range<VT>) {
rec.value.resize(M);
}
} else { // append if allowed
if constexpr (!traits::mcc_fixed_size_range<VT>) {
std::ranges::for_each_n(val.begin(), N, [&it](auto const& el) {
*it = el;
++it;
});
std::ranges::for_each(val | std::views::drop(N),
[&rec](auto const& el) { std::back_inserter(rec.value) = el; });
}
}
} else {
return MccKeyValueHolderErrorCode::ERROR_INCOMPATIBLE_TYPE;
}
return MccKeyValueHolderErrorCode::ERROR_OK;
});
if (!ec) {
_changedKey.insert(hash);
}
return ec;
}
template <traits::mcc_input_char_range R,
traits::mcc_input_char_range RecDelimT = std::string_view,
mcc_serialization_params_c SerParamsT = mcc_serialization_params_t>
std::error_code fromCharRange(const R& buffer,
size_t skip_records = 0, // number of skipped records (from the beginning)
RecDelimT rec_delim = DEFAULT_RECORD_DELIMITER // records delimiter
)
requires std::ranges::contiguous_range<R>
{
if constexpr (std::is_array_v<std::decay_t<R>>) { // char*, const char*
if constexpr (std::is_array_v<std::decay_t<RecDelimT>>) {
return fromCharRange(std::string_view{buffer}, std::string_view(rec_delim));
} else {
return fromCharRange(std::string_view{buffer}, std::move(rec_delim));
}
} else {
if constexpr (std::is_array_v<std::decay_t<RecDelimT>>) {
return fromCharRange(buffer, std::string_view(rec_delim));
}
}
std::error_code ec{};
std::string_view rec, key, svalue, inline_comm;
std::vector<std::optional<std::string>> head_comm;
size_t key_hash;
_headComment.clear();
_inlineComment.clear();
_changedKey.clear();
// set values to its defaults
setToDefaults();
auto recs = std::views::split(buffer, std::move(rec_delim)) | std::views::drop(skip_records);
for (auto const& el : recs) {
rec = mcc::utils::trimSpaces(el, utils::TrimType::TRIM_LEFT);
inline_comm = {};
if (rec.size()) {
auto found = std::ranges::search(rec, COMMENT_SEQ);
if (found.begin() != rec.end()) { // there was the comment sequence in record
if (found.begin() != rec.begin()) { // inline comment
inline_comm =
std::string_view{found.begin() + COMMENT_SEQ.size(), rec.end()}; // mark inline comment
} else { // head comment
head_comm.push_back(std::string{found.end(), rec.end()});
}
rec = std::string_view(rec.begin(), found.begin());
}
if (rec.size()) {
found = std::ranges::search(rec, KEY_VALUE_DELIM);
if (found.begin() != rec.begin()) {
key = trimSpaces(std::string_view(rec.begin(), found.begin()), utils::TrimType::TRIM_RIGHT);
svalue = std::string_view(found.end(), rec.end());
key_hash = utils::FNV1aHash(key);
ec = forHash(key_hash, [&key_hash, svalue, this]<typename REC_T>(REC_T& v) {
using VT = decltype(v.value);
auto err = MccDeserializer<VT>{}(svalue, v.value, v.serial_pars);
if (err) {
return MccKeyValueHolderErrorCode::ERROR_DESERIAL;
}
_changedKey.insert(key_hash);
return MccKeyValueHolderErrorCode::ERROR_OK;
});
if (ec) { // exit in the case of error
break;
}
// save head comment
_headComment[key_hash] = head_comm;
head_comm.clear();
_inlineComment[key_hash] = inline_comm;
} else { // an empty key
ec = MccKeyValueHolderErrorCode::ERROR_INVALID_KEY;
break;
}
} // just comment string starting from the beginning, just skip it (no error)
} else { // empty record, just skip it (no error)
// head_comm.push_back({el.begin(), el.end()});
head_comm.push_back(std::nullopt);
}
}
return ec;
}
template <OutputPolicy OPOLICY = MccKeyValueHolder::OPOLICY_CHANGED_ONLY,
traits::mcc_output_char_range R,
traits::mcc_input_char_range RecDelimT = std::string_view>
std::error_code toCharRange(R& output_buffer, RecDelimT rec_delim = DEFAULT_RECORD_DELIMITER)
{
if (std::is_pointer_v<std::decay_t<RecDelimT>>) { // char*, const char*, char[], conat char[]
return toCharRange(output_buffer, std::string_view{rec_delim});
}
std::error_code ec{};
#ifdef __GNUG__
// to fix GCC compilation crash for the versions < 16
#if GCC_VERSION < 160000
auto write_rec = [&output_buffer, &rec_delim, &ec, obj_ptr = this]<size_t I = 0>(this auto& self) -> void {
#else
auto write_rec = [&output_buffer, &rec_delim, &ec, this]<size_t I = 0>(this auto& self) -> void {
#endif
#endif
if constexpr (I < NUMBER_OF_RECORDS) {
if constexpr (OPOLICY == MccKeyValueHolder::OPOLICY_CHANGED_ONLY) {
#ifdef __GNUG__
// to fix GCC compilation crash for the versions < 16
#if GCC_VERSION < 160000
if (obj_ptr->_changedKey.count(obj_ptr->_hashes[I]) == 0) {
#else
if (_changedKey.count(_hashes[I]) == 0) {
#endif
#endif
self.template operator()<I + 1>();
return;
}
}
#ifdef __GNUG__
// to fix GCC compilation crash for the versions < 16
#if GCC_VERSION < 160000
ec = obj_ptr->template formatRecord<I>(output_buffer, rec_delim);
#else
ec = formatRecord<I>(output_buffer, rec_delim);
#endif
#endif
if (ec) {
return;
}
self.template operator()<I + 1>();
}
};
write_rec();
// [&write_rec]<size_t... Is>(std::index_sequence<Is...>) {
// (write_rec.template operator()<Is>(), ...);
// }(std::make_index_sequence<NUMBER_OF_RECORDS>());
return ec;
}
protected:
DESCR_T _keyValue;
std::array<size_t, NUMBER_OF_RECORDS> _hashes{}; // key hashes
std::unordered_map<size_t, std::vector<std::optional<std::string>>>
_headComment{}; // comment string/strings before key
std::unordered_map<size_t, std::string> _inlineComment{}; // inline (after key=value pair) comment
std::unordered_set<size_t> _changedKey{}; // loaded keys (see fromCharRange)
//
// NOTE: deduced this is needed here to use "forKey" method in getter and setter (const and non-const contexts)!!!
//
std::error_code forKey(this auto&& self, std::string_view key, auto&& func)
{
return std::forward<decltype(self)>(self).template forHash<0>(utils::FNV1aHash(key),
std::forward<decltype(func)>(func));
}
//
// 'func' signature:
// std::error func(mcc_keyvalue_record_c&&)
// e.g.:
// [](auto const& rec)->std::error_code {}
// [](auto& rec)->std::error_code {}
//
template <size_t I = 0>
std::error_code forHash(this auto&& self, size_t hash, auto&& func)
{
if constexpr (I < NUMBER_OF_RECORDS) {
if (hash == std::forward<decltype(self)>(self)._hashes[I]) {
return std::forward<decltype(func)>(func)(std::get<I>(std::forward<decltype(self)>(self)._keyValue));
} else {
return std::forward<decltype(self)>(self).template forHash<I + 1>(hash,
std::forward<decltype(func)>(func));
}
}
return MccKeyValueHolderErrorCode::ERROR_INVALID_KEY;
}
template <size_t I = 0, traits::mcc_output_char_range R, traits::mcc_input_char_range RecDelimT>
std::error_code formatRecord(R& output_buffer, RecDelimT rec_delim, bool is_default = false)
{
if constexpr (I < NUMBER_OF_RECORDS) {
auto key = std::get<I>(_keyValue).key;
using val_t = std::remove_cvref_t<decltype(std::get<I>(_keyValue).value)>;
const val_t& val = is_default ? std::get<I>(_keyValue).default_value : std::get<I>(_keyValue).value;
std::string buff;
// auto err = MccSerializer<val_t>{}(buff, std::get<I>(_keyValue).value,
// std::get<I>(_keyValue).serial_pars);
auto err = MccSerializer<val_t>{}(buff, val, std::get<I>(_keyValue).serial_pars);
if (err) {
return MccKeyValueHolderErrorCode::ERROR_SERIAL;
} else {
size_t hash = _hashes[I];
// write head comment
if (_headComment[hash].size()) {
for (auto const& comm : _headComment[hash]) {
if (comm.has_value()) {
std::format_to(std::back_inserter(output_buffer), "{}{}", COMM_SEQ, comm.value());
}
std::ranges::copy(rec_delim, std::back_inserter(output_buffer));
}
}
// key and value
std::format_to(std::back_inserter(output_buffer), "{}{}{}", key, KEY_VALUE_DELIM, buff);
// inline comment
if (_inlineComment[hash].size()) {
std::format_to(std::back_inserter(output_buffer), " {}{}", COMMENT_SEQ, _inlineComment[hash]);
}
// record delimiter
std::ranges::copy(rec_delim, std::back_inserter(output_buffer));
}
}
return MccKeyValueHolderErrorCode::ERROR_OK;
}
template <size_t I = 0>
void copyInst(MccKeyValueHolder const& other)
{
if constexpr (I < NUMBER_OF_RECORDS) {
// here one needs check equality of the keys!!!
if (_hashes[I] == other._hashes[I]) {
auto& orec = std::get<I>(other._keyValue);
std::get<I>(_keyValue).value = orec.value;
std::get<I>(_keyValue).default_value = orec.default_value;
std::get<I>(_keyValue).serial_pars = orec.serial_pars;
if (auto it = other._headComment.find(_hashes[I]); it != other._headComment.end()) {
_headComment[_hashes[I]] = it->second;
}
if (auto it = other._inlineComment.find(_hashes[I]); it != other._inlineComment.end()) {
_inlineComment[_hashes[I]] = it->second;
}
_changedKey.insert(_hashes[I]);
}
copyInst<I + 1>(other);
}
}
template <size_t I = 0>
void moveInst(MccKeyValueHolder&& other)
{
if constexpr (I < NUMBER_OF_RECORDS) {
// here one needs check equality of the keys!!!
if (_hashes[I] == other._hashes[I]) {
auto& orec = std::get<I>(other._keyValue);
std::get<I>(_keyValue).value = std::move(orec.value);
std::get<I>(_keyValue).default_value = std::move(orec.default_value);
std::get<I>(_keyValue).serial_pars = std::move(orec.serial_pars);
if (auto it = other._headComment.find(_hashes[I]); it != other._headComment.end()) {
_headComment[_hashes[I]] = std::move(it->second);
}
if (auto it = other._inlineComment.find(_hashes[I]); it != other._inlineComment.end()) {
_inlineComment[_hashes[I]] = std::move(it->second);
}
_changedKey.insert(_hashes[I]);
}
moveInst<I + 1>(other);
}
}
};
template <mcc_record_value_c T>
struct mcc_simple_kv_record_t {
const std::string_view key;
T value, default_value;
mcc_serialization_params_t serial_pars;
};
template <mcc_record_value_c T>
static mcc_simple_kv_record_t<T> mcc_make_simple_kv_record(
std::string_view key,
T const& def_value,
mcc_serialization_params_t const& spars = mcc_serialization_params_t{})
{
return mcc_simple_kv_record_t<T>{key, def_value, def_value, spars};
}
} // namespace mcc::impl

View File

@@ -29,6 +29,7 @@
#include <atomic>
#include <fstream>
#include <thread>
#include "mcc/mcc_coordinate.h"
#include "mcc_concepts.h"
@@ -48,6 +49,7 @@ enum class MccSimpleMovementControlsErrorCode : int {
ERROR_OK,
ERROR_HW_GETSTATE,
ERROR_HW_SETSTATE,
ERROR_HW_ERROR,
ERROR_PCM_COMP,
ERROR_CCTE_COMP,
ERROR_GET_TELEMETRY,
@@ -99,6 +101,8 @@ struct MccSimpleMovementControlsCategory : public std::error_category {
return "cannot get hardware state";
case MccSimpleMovementControlsErrorCode::ERROR_HW_SETSTATE:
return "cannot set hardware state";
case MccSimpleMovementControlsErrorCode::ERROR_HW_ERROR:
return "hardware error occured";
case MccSimpleMovementControlsErrorCode::ERROR_PCM_COMP:
return "PCM computation error";
case MccSimpleMovementControlsErrorCode::ERROR_CCTE_COMP:
@@ -256,7 +260,7 @@ protected:
return true;
}
fst.open(_filename);
fst.open(_filename, std::ios::app);
if (!fst.is_open()) {
return false;
@@ -311,13 +315,16 @@ public:
using STATUS_T = std::decay_t<traits::mcc_func_arg1_t<CallbackFuncT>>;
auto send_to_hardware = [hardware, logger](typename HARDWARE_T::hardware_state_t const& hw_state) -> error_t {
auto tp =
std::chrono::duration_cast<std::chrono::milliseconds>(hw_state.XY.epoch().UTC().time_since_epoch());
if constexpr (std::derived_from<decltype(hw_state.XY), MccCoordPair<MccAngleX, MccAngleY>>) {
logger->logDebug(std::format("Send to hardware: X = {} degs, Y = {} degs", hw_state.XY.x().degrees(),
hw_state.XY.y().degrees()));
logger->logDebug(std::format("Send to hardware: X = {} degs, Y = {} degs (timepoint: {})",
hw_state.XY.x().degrees(), hw_state.XY.y().degrees(), tp));
} else { // user defined mcc_coord_pair_c
logger->logDebug(std::format("Send to hardware: X = {} degs, Y = {} degs",
logger->logDebug(std::format("Send to hardware: X = {} degs, Y = {} degs (timepoint: {})",
MccAngle((double)hw_state.XY.x()).degrees(),
MccAngle((double)hw_state.XY.y()).degrees()));
MccAngle((double)hw_state.XY.y()).degrees(), tp));
}
auto hw_err = hardware->hardwareSetState(hw_state);
@@ -370,8 +377,8 @@ public:
// calculate coordinates at current speed '_currentParams.minTimeToPZone' seconds ahead
// and check them for getting into the prohibited zones
std::conditional_t<mccIsEquatorialMount(HARDWARE_T::mountType), MccSkyHADEC_OBS,
std::conditional_t<mccIsAltAzMount(HARDWARE_T::mountType), MccSkyAZZD, std::nullptr_t>>
std::conditional_t<mccIsEquatorialMount(HARDWARE_T::hwMountType), MccSkyHADEC_OBS,
std::conditional_t<mccIsAltAzMount(HARDWARE_T::hwMountType), MccSkyAZZD, std::nullptr_t>>
mount_pos;
static_assert(!std::is_null_pointer_v<decltype(mount_pos)>, "UNKNOWn MOUNT TYPE");
@@ -437,20 +444,22 @@ public:
};
auto log_pos = [logger, this](typename TELEMETRY_T::telemetry_data_t const& tdata) -> error_t {
auto log_pos = [logger, this](typename TELEMETRY_T::telemetry_data_t const& tdata,
std::tuple<double, double, double>& dist) -> error_t {
double x_mnt, y_mnt, x_tag, y_tag;
std::conditional_t<mccIsEquatorialMount(HARDWARE_T::mountType), MccSkyHADEC_OBS,
std::conditional_t<mccIsAltAzMount(HARDWARE_T::mountType), MccSkyAZZD, std::nullptr_t>>
std::conditional_t<
mccIsEquatorialMount(HARDWARE_T::hwMountType), MccSkyHADEC_OBS,
std::conditional_t<mccIsAltAzMount(HARDWARE_T::hwMountType), MccSkyAZALT, std::nullptr_t>>
coord_pair;
static_assert(!std::is_null_pointer_v<decltype(coord_pair)>, "UNKNOWN MOUNT TYPE!");
const std::string_view x_str = mccIsEquatorialMount(HARDWARE_T::mountType) ? "HA"
: mccIsAltAzMount(HARDWARE_T::mountType) ? "AZ"
const std::string_view x_str = mccIsEquatorialMount(HARDWARE_T::hwMountType) ? "HA"
: mccIsAltAzMount(HARDWARE_T::hwMountType) ? "AZ"
: "GEN_X";
const std::string_view y_str = mccIsEquatorialMount(HARDWARE_T::mountType) ? "DEC"
: mccIsAltAzMount(HARDWARE_T::mountType) ? "ZD"
const std::string_view y_str = mccIsEquatorialMount(HARDWARE_T::hwMountType) ? "DEC"
: mccIsAltAzMount(HARDWARE_T::hwMountType) ? "ALT"
: "GEN_Y";
;
@@ -463,20 +472,35 @@ public:
x_tag = coord_pair.x();
y_tag = coord_pair.y();
logger->logTrace(std::format(" current target: {} = {}, {} = {}", x_str,
coord_pair.x().sexagesimal(true), y_str, coord_pair.y().sexagesimal()));
logger->logTrace(std::format(" current target: {} = {}, {} = {} (encoders: {} {})", x_str,
coord_pair.x().sexagesimal(true), y_str, coord_pair.y().sexagesimal(),
tdata.targetXY.x().sexagesimal(), tdata.targetXY.y().sexagesimal()));
ccte_err = tdata.mountPos.toAtSameEpoch(coord_pair);
if (ccte_err) {
return mcc_deduced_err(ccte_err, MccSimpleMovementControlsErrorCode::ERROR_CCTE_COMP);
}
logger->logTrace(std::format(" current mount: {} = {}, {} = {}", x_str, coord_pair.x().sexagesimal(true),
y_str, coord_pair.y().sexagesimal()));
logger->logTrace(std::format(" current mount: {} = {}, {} = {} (encoders: {} {})", x_str,
coord_pair.x().sexagesimal(true), y_str, coord_pair.y().sexagesimal(),
tdata.hwState.XY.x().sexagesimal(), tdata.hwState.XY.y().sexagesimal()));
x_mnt = coord_pair.x();
y_mnt = coord_pair.y();
dist = utils::distanceOnSphere(x_tag, y_tag, x_mnt, y_mnt);
_pathFile << tdata.mountPos.epoch().UTC().time_since_epoch().count() << " " << x_tag << " " << y_tag << " "
<< x_mnt << " " << y_mnt << " " << (x_tag - x_mnt) << " " << (y_tag - y_mnt) << " "
<< (int)tdata.hwState.movementState << "\n";
<< x_mnt << " " << y_mnt << " " << std::get<0>(dist) << " " << std::get<1>(dist) << " "
<< std::get<2>(dist) << " " << (int)tdata.hwState.movementState << "\n";
// _pathFile << tdata.mountPos.epoch().UTC().time_since_epoch().count() << " " << x_tag << " " << y_tag << "
// "
// << x_mnt << " " << y_mnt << " " << (x_tag - x_mnt) << " " << (y_tag - y_mnt) << " "
// << (int)tdata.hwState.movementState << "\n";
logger->logTrace(std::format(" target-to-mount distance: {} (dx = {}, dy = {})",
MccAngleFancyString(std::get<2>(dist)), MccAngleFancyString(std::get<0>(dist)),
MccAngleFancyString(std::get<1>(dist))));
return MccSimpleMovementControlsErrorCode::ERROR_OK;
};
@@ -527,9 +551,10 @@ public:
std::chrono::duration_cast<std::chrono::duration<double>>(_currentParams.minTimeToPZone).count();
if (!_currentParams.slewingPathFilename.empty()) { // open slewing trajectory file
logger->logInfo(std::format("Set slewing path filename to {}", _currentParams.slewingPathFilename));
_pathFile.setFilename(_currentParams.slewingPathFilename);
} else {
logger->logError("Slewing path filename is empty! Do not save it!");
logger->logWarn("Slewing path filename is empty! Do not save it!");
}
}
@@ -556,7 +581,7 @@ public:
_pathFile << "# \n";
_pathFile << "# Format (time is in nanoseconds, coordinates are in radians): \n";
_pathFile << "# <UNIXTIME> <target X> <target Y> <mount X> <mount Y> <dX_{target-mount}> "
"<dY_{target-mount}> <moving state>\n";
"<dY_{target-mount}> <taget-mount-distance> <moving state>\n";
typename TELEMETRY_T::telemetry_data_t tdata;
@@ -581,9 +606,12 @@ public:
return;
}
using ep_t = decltype(hw_state.XY.epoch());
hw_state.movementState = HARDWARE_T::hardware_movement_state_t::HW_MOVE_SLEWING;
hw_state.XY.setX(tdata.targetXY.x());
hw_state.XY.setY(tdata.targetXY.y());
hw_state.XY.setEpoch(ep_t::now());
// start slewing ...
@@ -602,7 +630,13 @@ public:
auto start_point = std::chrono::steady_clock::now();
auto last_hw_time = tdata.hwState.XY.epoch().UTC();
mcc_deduced_coord_pair_t<HARDWARE_T::mountType> tag_cp, mnt_cp;
mcc_deduced_coord_pair_t<HARDWARE_T::hwMountType> tag_cp, mnt_cp;
std::tuple<double, double, double> dist;
*_stopMoving = false;
hw_state.movementState = HARDWARE_T::hardware_movement_state_t::HW_MOVE_ADJUSTING;
while (!*_stopMoving) {
t_err = telemetry->telemetryData(&tdata);
@@ -613,7 +647,16 @@ public:
return;
}
log_pos(tdata);
hw_state.XY.setX(tdata.targetXY.x());
hw_state.XY.setY(tdata.targetXY.y());
hw_state.XY.setEpoch(ep_t::now());
log_pos(tdata, dist);
// logger->logInfo("\tMNT.XY {} {}; MNT.HADEC {} {}", (double)tdata.hwState.XY.x(),
// (double)tdata.hwState.XY.y(), tdata.mountPos.co_lon(), tdata.mountPos.co_lat());
// logger->logInfo("\tTAG.XY {} {}; TAG.HADEC {} {}", (double)tdata.targetXY.x(),
// (double)tdata.targetXY.y(), tdata.targetPos.co_lon(), tdata.targetPos.co_lat());
if (*_stopMoving) {
*_lastError = MccSimpleMovementControlsErrorCode::ERROR_STOPPED;
@@ -633,13 +676,62 @@ public:
*_lastError = MccSimpleMovementControlsErrorCode::ERROR_TIMEOUT;
break;
}
if (std::get<2>(dist) <= _currentParams.slewToleranceRadius) {
logger->logInfo("target-to-mount distance is lesser than slew acceptable radius - exit!");
break;
}
// start adjusting (precise pointing) the slewing
if (std::get<2>(dist) <= _currentParams.adjustCoordDiff) {
(*cb_sptr)(STATUS_T::MOUNT_STATUS_ADJUSTING);
*_lastError = send_to_hardware(hw_state);
if (_lastError->load()) {
break;
}
}
if (tdata.hwState.movementState == HARDWARE_T::hardware_movement_state_t::HW_MOVE_STOPPED) {
// the mount stopped but still to far from target position!!!
if (std::get<2>(dist) > _currentParams.slewToleranceRadius) {
(*cb_sptr)(STATUS_T::MOUNT_STATUS_ADJUSTING);
*_lastError = send_to_hardware(hw_state);
if (_lastError->load()) {
break;
}
} else {
break;
}
}
}
if (tdata.hwState.movementState == HARDWARE_T::hardware_movement_state_t::HW_MOVE_ERROR) {
*_lastError = MccSimpleMovementControlsErrorCode::ERROR_HW_ERROR;
break;
}
/*
if (slew_and_stop) { // just wait until the mount stops
if (tdata.hwState.movementState == HARDWARE_T::hardware_movement_state_t::HW_MOVE_STOPPED) {
// if (std::get<2>(dist) > _currentParams.slewToleranceRadius) {
// // resend new position since target coordinates are changed in time
// hw_state.movementState = HARDWARE_T::hardware_movement_state_t::HW_MOVE_SLEWING;
// hw_state.XY.setX(tdata.targetXY.x());
// hw_state.XY.setY(tdata.targetXY.y());
// hw_state.XY.setEpoch(ep_t::now());
// *_lastError = send_to_hardware(hw_state);
// if (_lastError->load()) {
// break;
// }
// } else {
logger->logInfo("mount movement state is STOPPED! Exit from slewing process!");
break;
// }
}
} else {
if (last_hw_time == tdata.hwState.XY.epoch().UTC()) {
@@ -649,22 +741,6 @@ public:
last_hw_time = tdata.hwState.XY.epoch().UTC();
auto ccte_err = tdata.targetPos.to(tag_cp);
if (ccte_err) {
*_lastError = mcc_deduced_err(ccte_err, MccSimpleMovementControlsErrorCode::ERROR_CCTE_COMP);
}
ccte_err = tdata.mountPos.to(mnt_cp);
if (ccte_err) {
*_lastError = mcc_deduced_err(ccte_err, MccSimpleMovementControlsErrorCode::ERROR_CCTE_COMP);
}
auto dist = utils::distanceOnSphere(tag_cp.x(), tag_cp.y(), mnt_cp.x(), mnt_cp.y());
logger->logTrace(std::format(" target-to-mount distance: {} (dx = {}, dy = {})",
MccAngleFancyString(std::get<2>(dist)), std::get<0>(dist),
std::get<1>(dist)));
// stop slewing and exit from the cycle?
if (std::get<2>(dist) <= _currentParams.slewToleranceRadius) {
if (tdata.hwState.movementState == HARDWARE_T::hardware_movement_state_t::HW_MOVE_STOPPED ||
@@ -681,7 +757,6 @@ public:
if (*_stopMoving) {
*_lastError = MccSimpleMovementControlsErrorCode::ERROR_STOPPED;
break;
}
@@ -690,12 +765,25 @@ public:
hw_state.movementState = HARDWARE_T::hardware_movement_state_t::HW_MOVE_SLEWING;
hw_state.XY.setX(tdata.targetXY.x());
hw_state.XY.setY(tdata.targetXY.y());
hw_state.XY.setEpoch(ep_t::now());
*_lastError = send_to_hardware(hw_state);
if (_lastError->load()) {
break;
}
}
*/
// sleep here
std::this_thread::sleep_for(_currentParams.slewingTelemetryInterval);
}
if (_stopMoving->load()) { // external stop
logger->logWarn("Slewing was stopped!");
*_lastError = MccSimpleMovementControlsErrorCode::ERROR_OK;
_pathFile.save();
return;
}
*_stopMoving = true;
@@ -717,23 +805,7 @@ public:
return;
}
auto ccte_err = tdata.targetPos.to(tag_cp);
if (ccte_err) {
*_lastError = mcc_deduced_err(ccte_err, MccSimpleMovementControlsErrorCode::ERROR_CCTE_COMP);
return;
}
ccte_err = tdata.mountPos.to(mnt_cp);
if (ccte_err) {
*_lastError = mcc_deduced_err(ccte_err, MccSimpleMovementControlsErrorCode::ERROR_CCTE_COMP);
return;
}
auto dist = utils::distanceOnSphere(tag_cp.x(), tag_cp.y(), mnt_cp.x(), mnt_cp.y());
log_pos(tdata);
logger->logDebug(
std::format(" target-to-mount distance {}", MccAngleFancyString(std::get<2>(dist))));
log_pos(tdata, dist);
if (!slew_and_stop) { // start tracking
_trackingFunc();
@@ -742,6 +814,178 @@ public:
}
}
};
/* tracking function */
_trackingFunc = [log_pos, check_pzones, send_to_hardware, telemetry, cb_sptr, logger, this]() {
double braking_accelX, braking_accelY;
double min_time_to_pzone_in_secs;
logger->logInfo("Start tracking");
{
// std::lock_guard lock{*_currentParamsMutex};
if (mcc::utils::isEqual(_currentParams.brakingAccelX, 0.0)) {
braking_accelX = std::numeric_limits<double>::min();
} else {
braking_accelX = std::abs(_currentParams.brakingAccelX);
}
if (mcc::utils::isEqual(_currentParams.brakingAccelY, 0.0)) {
braking_accelY = std::numeric_limits<double>::min();
} else {
braking_accelY = std::abs(_currentParams.brakingAccelY);
}
min_time_to_pzone_in_secs =
std::chrono::duration_cast<std::chrono::duration<double>>(_currentParams.minTimeToPZone).count();
if (!_currentParams.trackingPathFilename.empty()) { // open slewing trajectory file
logger->logInfo(
std::format(" Set tracking filename to {}", _currentParams.trackingPathFilename));
_pathFile.setFilename(_currentParams.trackingPathFilename);
} else {
logger->logWarn(" Tracking path filename is empty! Do not save it!");
}
}
logger->logInfo(std::format(" braking acceleration X: {} degs/s^2 (in config: {} rads/s^2)",
MccAngle(braking_accelX).degrees(), _currentParams.brakingAccelX));
logger->logInfo(std::format(" braking acceleration Y: {} degs/s^2 (in config: {} rads/s^2)",
MccAngle(braking_accelY).degrees(), _currentParams.brakingAccelY));
logger->logInfo(std::format(" min time to prohibited zone: {} seconds", min_time_to_pzone_in_secs));
logger->logInfo(
std::format(" max target-to-mount distance: {} arcseconds", _currentParams.trackingMaxCoordDiff));
_pathFile << "# \n";
_pathFile << "# Tracking trajectory, " << std::chrono::system_clock::now() << "\n";
_pathFile << "# \n";
_pathFile << "# Format (time is in nanoseconds, coordinates are in radians): \n";
_pathFile << "# <UNIXTIME> <target X> <target Y> <mount X> <mount Y> <dX_{target-mount}> "
"<dY_{target-mount}> <taget-mount-distance> <moving state>\n";
typename TELEMETRY_T::telemetry_data_t tdata;
typename HARDWARE_T::hardware_state_t hw_state;
std::tuple<double, double, double> dist;
auto t_err = telemetry->telemetryData(&tdata);
if (t_err) {
*_lastError = mcc_deduced_err(t_err, MccSimpleMovementControlsErrorCode::ERROR_GET_TELEMETRY);
(*cb_sptr)(STATUS_T::MOUNT_STATUS_ERROR);
_pathFile.save();
return;
}
log_pos(tdata, dist);
{
std::lock_guard lock{*_currentParamsMutex};
if (_currentParams.trackingMaxCoordDiff < std::get<2>(dist)) {
logger->logInfo(
std::format("The target-to-mount distance {} is greater than allowed one ({})! Track current "
"mount position!",
MccAngleFancyString(std::get<2>(dist)),
MccAngleFancyString(_currentParams.trackingMaxCoordDiff)));
telemetry->setPointingTarget(tdata.mountPos);
}
}
t_err = telemetry->telemetryData(&tdata);
if (t_err) {
*_lastError = mcc_deduced_err(t_err, MccSimpleMovementControlsErrorCode::ERROR_GET_TELEMETRY);
(*cb_sptr)(STATUS_T::MOUNT_STATUS_ERROR);
_pathFile.save();
return;
}
*_lastError = check_pzones(tdata, min_time_to_pzone_in_secs, braking_accelX, braking_accelY);
if (_lastError->load()) {
_pathFile.save();
return;
}
hw_state.movementState = HARDWARE_T::hardware_movement_state_t::HW_MOVE_TRACKING;
auto last_hw_time = tdata.hwState.XY.epoch().UTC();
mcc_deduced_coord_pair_t<HARDWARE_T::hwMountType> tag_cp, mnt_cp;
*_stopMoving = false;
while (!_stopMoving->load()) {
t_err = telemetry->telemetryData(&tdata);
if (t_err) {
*_lastError = mcc_deduced_err(t_err, MccSimpleMovementControlsErrorCode::ERROR_GET_TELEMETRY);
(*cb_sptr)(STATUS_T::MOUNT_STATUS_ERROR);
return;
}
log_pos(tdata, dist);
if (*_stopMoving) {
*_lastError = MccSimpleMovementControlsErrorCode::ERROR_STOPPED;
break;
}
*_lastError = check_pzones(tdata, min_time_to_pzone_in_secs, braking_accelX, braking_accelY);
if (_lastError->load()) {
break;
}
if (last_hw_time == tdata.hwState.XY.epoch().UTC()) {
logger->logTrace("Same hardware timepoint! Just continue to polling!\n\n\n\n");
continue;
}
last_hw_time = tdata.hwState.XY.epoch().UTC();
// resend new position since target coordinates are changed in time
hw_state.movementState = HARDWARE_T::hardware_movement_state_t::HW_MOVE_TRACKING;
hw_state.XY.setX(tdata.targetXY.x());
hw_state.XY.setY(tdata.targetXY.y());
hw_state.XY.setEpoch(tdata.hwState.XY.epoch());
*_lastError = send_to_hardware(hw_state);
if (_lastError->load()) {
break;
}
if (*_stopMoving) {
break;
}
// sleep here
std::this_thread::sleep_for(_currentParams.trackingTelemetryInterval);
}
if (_stopMoving->load()) { // external stop
logger->logWarn("Tracking was stopped!");
*_lastError = MccSimpleMovementControlsErrorCode::ERROR_OK;
} else {
*_stopMoving = true;
logger->logInfo("Tracking finished");
auto err = _lastError->load();
logger->logInfo(
std::format(" exit code: {} {} {}", err.value(), err.category().name(), err.message()));
}
_pathFile.save();
};
}
virtual ~MccSimpleMovementControls() = default;

View File

@@ -967,9 +967,6 @@ public:
return output_msg.template byteRepr<typename base_t::handle_message_func_result_t>();
};
// special functor (used in the destructor)
_stopMountFunc = [mount_ptr]() { mount_ptr->stopMount(); };
}
virtual ~MccGenericMountNetworkServer()
@@ -977,8 +974,6 @@ public:
std::stringstream st;
st << std::this_thread::get_id();
_stopMountFunc();
logInfo(std::format("Delete MccGenericMountNetworkServer class instance (thread ID = {})", st.str()));
}
@@ -987,8 +982,6 @@ protected:
MccSerializedAngleFormatPrec _coordPrec{2, 1, 7};
std::function<void()> _stopMountFunc{};
template <typename RESULT_MSG_T, typename INPUT_MSG_T, mcc_generic_mount_c MountT>
RESULT_MSG_T handleMessage(const INPUT_MSG_T& input_msg, MountT* mount_ptr)
requires(
@@ -1111,7 +1104,7 @@ protected:
impl::MccCoordPairKind pair_kind = impl::MccCoordPairKind::COORDS_KIND_UNKNOWN;
impl::MccSkyPoint sp;
if (input_msg.paramSize()) { // ccordinate pair kind is given
if (input_msg.paramSize()) { // cordinate pair kind is given
auto vp = input_msg.template paramValue<impl::MccCoordPairKind>(0);
if (vp) { // coordinate pair kind is given
pair_kind = vp.value();
@@ -1128,6 +1121,10 @@ protected:
}
}
} else if (input_msg.withKey(MCC_COMMPROTO_KEYWORD_ENTEREDTAG_STR)) {
output_msg.construct(MCC_COMMPROTO_KEYWORD_SERVER_ACK_STR, MCC_COMMPROTO_KEYWORD_ENTEREDTAG_STR,
_coordFormat, _coordPrec, mount_ptr->getPointingTarget());
} else if (input_msg.withKey(MCC_COMMPROTO_KEYWORD_TELEMETRY_STR)) {
typename MountT::telemetry_data_t tdata;
@@ -1240,7 +1237,7 @@ protected:
case impl::MccCoordPairKind::COORDS_KIND_XY: // interpretated as encoder coordinates
case impl::MccCoordPairKind::COORDS_KIND_GENERIC: { // interpretated as encoder coordinates
if (target) {
// WARNING: STILL NOT IMPLEMENTED!!!
sp.from(tdata.targetXY);
} else {
sp.from(tdata.hwState.XY);
}

View File

@@ -146,6 +146,10 @@ static constexpr std::string_view MCC_COMMPROTO_KEYWORD_TARGET_STR = "TARGET";
static constexpr std::string_view MCC_COMMPROTO_KEYWORD_MOUNT_STR = "MOUNT";
// get entered target coordinates:
static constexpr std::string_view MCC_COMMPROTO_KEYWORD_ENTEREDTAG_STR = "ENTEREDTAG";
static constexpr std::string_view MCC_COMMPROTO_KEYWORD_TELEMETRY_STR = "TELEMETRY";
// init mount
@@ -173,18 +177,18 @@ static constexpr std::string_view MCC_COMMPROTO_KEYWORD_TRACK_STR = "TRACK";
static constexpr std::string_view MCC_COMMPROTO_KEYWORD_STATUS_STR = "STATUS";
// valid keywords
static constexpr std::array MCC_COMMPROTO_VALID_KEYS = {
MCC_COMMPROTO_KEYWORD_SERVER_ACK_STR, MCC_COMMPROTO_KEYWORD_SERVER_ERROR_STR, MCC_COMMPROTO_KEYWORD_COORDFMT_STR,
MCC_COMMPROTO_KEYWORD_COORDPREC_STR, MCC_COMMPROTO_KEYWORD_TARGET_STR, MCC_COMMPROTO_KEYWORD_MOUNT_STR,
MCC_COMMPROTO_KEYWORD_TELEMETRY_STR, MCC_COMMPROTO_KEYWORD_INIT_STR, MCC_COMMPROTO_KEYWORD_STOP_STR,
MCC_COMMPROTO_KEYWORD_SLEW_STR, MCC_COMMPROTO_KEYWORD_MOVE_STR, MCC_COMMPROTO_KEYWORD_TRACK_STR,
MCC_COMMPROTO_KEYWORD_STATUS_STR};
// static constexpr std::array MCC_COMMPROTO_VALID_KEYS = {
// MCC_COMMPROTO_KEYWORD_SERVER_ACK_STR, MCC_COMMPROTO_KEYWORD_SERVER_ERROR_STR, MCC_COMMPROTO_KEYWORD_COORDFMT_STR,
// MCC_COMMPROTO_KEYWORD_COORDPREC_STR, MCC_COMMPROTO_KEYWORD_TARGET_STR, MCC_COMMPROTO_KEYWORD_MOUNT_STR,
// MCC_COMMPROTO_KEYWORD_ENTEREDTAG_STR, MCC_COMMPROTO_KEYWORD_TELEMETRY_STR, MCC_COMMPROTO_KEYWORD_INIT_STR,
// MCC_COMMPROTO_KEYWORD_STOP_STR, MCC_COMMPROTO_KEYWORD_SLEW_STR, MCC_COMMPROTO_KEYWORD_MOVE_STR,
// MCC_COMMPROTO_KEYWORD_TRACK_STR, MCC_COMMPROTO_KEYWORD_STATUS_STR};
// hashes of valid keywords
static constexpr std::array MCC_COMMPROTO_VALID_KEYS_HASH = []<size_t... Is>(std::index_sequence<Is...>) {
return std::array{mcc::utils::FNV1aHash(MCC_COMMPROTO_VALID_KEYS[Is])...};
}(std::make_index_sequence<MCC_COMMPROTO_VALID_KEYS.size()>());
// // hashes of valid keywords
// static constexpr std::array MCC_COMMPROTO_VALID_KEYS_HASH = []<size_t... Is>(std::index_sequence<Is...>) {
// return std::array{mcc::utils::FNV1aHash(MCC_COMMPROTO_VALID_KEYS[Is])...};
// }(std::make_index_sequence<MCC_COMMPROTO_VALID_KEYS.size()>());
@@ -213,10 +217,10 @@ struct MccNetMessageValidKeywords {
MCC_COMMPROTO_KEYWORD_SERVER_ACK_STR, MCC_COMMPROTO_KEYWORD_SERVER_ERROR_STR,
MCC_COMMPROTO_KEYWORD_COORDFMT_STR, MCC_COMMPROTO_KEYWORD_COORDPREC_STR,
MCC_COMMPROTO_KEYWORD_TARGET_STR, MCC_COMMPROTO_KEYWORD_MOUNT_STR,
MCC_COMMPROTO_KEYWORD_TELEMETRY_STR, MCC_COMMPROTO_KEYWORD_INIT_STR,
MCC_COMMPROTO_KEYWORD_STOP_STR, MCC_COMMPROTO_KEYWORD_SLEW_STR,
MCC_COMMPROTO_KEYWORD_MOVE_STR, MCC_COMMPROTO_KEYWORD_TRACK_STR,
MCC_COMMPROTO_KEYWORD_STATUS_STR};
MCC_COMMPROTO_KEYWORD_ENTEREDTAG_STR, MCC_COMMPROTO_KEYWORD_TELEMETRY_STR,
MCC_COMMPROTO_KEYWORD_INIT_STR, MCC_COMMPROTO_KEYWORD_STOP_STR,
MCC_COMMPROTO_KEYWORD_SLEW_STR, MCC_COMMPROTO_KEYWORD_MOVE_STR,
MCC_COMMPROTO_KEYWORD_TRACK_STR, MCC_COMMPROTO_KEYWORD_STATUS_STR};
// hashes of valid keywords

View File

@@ -2,9 +2,15 @@
#pragma once
/* MOUNT CONTROL COMPONENTS LIBRARY */
/****************************************************************************************
* *
* MOUNT CONTROL COMPONENTS LIBRARY *
* *
* *
* A REFERENCE "POINTING-CORRECTION-MODEL" CLASS IMPLEMENTATION *
* *
****************************************************************************************/
/* A REFERENCE "POINTING-CORRECTION-MODEL" CLASS IMPLEMENTATION */
#include <mutex>
@@ -15,6 +21,8 @@
#include "mcc_concepts.h"
#include "mcc_coordinate.h"
#include "mcc_deserializer.h"
#include "mcc_serializer.h"
namespace mcc::impl
{
@@ -24,9 +32,11 @@ enum class MccDefaultPCMErrorCode : int {
ERROR_CCTE,
#ifdef USE_BSPLINE_PCM
ERROR_INVALID_INPUTS_BISPLEV,
ERROR_INVALID_BSPLINE_KNOTS,
#endif
ERROR_EXCEED_MAX_ITERS,
ERROR_NULLPTR
ERROR_NULLPTR,
ERROR_JACINV
};
/* error category definition */
@@ -37,7 +47,7 @@ struct MccDefaultPCMCategory : public std::error_category {
const char* name() const noexcept
{
return "ADC_GENERIC_DEVICE";
return "MCC-DEFAULT-PCM-ERROR-CATEGORY";
}
std::string message(int ec) const
@@ -52,11 +62,15 @@ struct MccDefaultPCMCategory : public std::error_category {
#ifdef USE_BSPLINE_PCM
case MccDefaultPCMErrorCode::ERROR_INVALID_INPUTS_BISPLEV:
return "invalid input arguments for bispev";
case MccDefaultPCMErrorCode::ERROR_INVALID_BSPLINE_KNOTS:
return "invalid B-spline knots vector";
#endif
case MccDefaultPCMErrorCode::ERROR_EXCEED_MAX_ITERS:
return "exceed maximum of iterations number";
case MccDefaultPCMErrorCode::ERROR_NULLPTR:
return "nullptr input argument";
case MccDefaultPCMErrorCode::ERROR_JACINV:
return "Jacobian is near singular";
default:
return "UNKNOWN";
}
@@ -92,6 +106,24 @@ class is_error_code_enum<mcc::impl::MccDefaultPCMErrorCode> : public true_type
namespace mcc::impl
{
// The routine generates a sequence of length 'innerN'+2 elements.
// Th e first element is 'start_border' and the last one is 'stop_border'
// (i.e. it returns at least 2-elements std::vector)
// 'innerN' is a number of inner elements
static std::vector<double> mccGenerateBsplineKnots(double start_border, double stop_border, size_t innerN)
{
std::vector<double> res(innerN + 2);
res.front() = start_border;
res.back() = stop_border;
if (innerN) {
const double step = (stop_border - start_border) / (innerN + 1);
std::ranges::for_each(std::views::iota(1, (int)innerN + 1),
[&](auto const& i) { res[i] = start_border + i * step; });
}
return res;
}
// type of PCM corrections (algorithm used):
// PCM_TYPE_GEOMETRY - "classic" geometry-based correction coefficients
@@ -108,11 +140,65 @@ static constexpr std::string_view MccDefaultPCMTypeString =
#endif
: "UNKNOWN";
static constexpr std::string_view mccDefaultPCMTypeString(MccDefaultPCMType type)
{
return type == MccDefaultPCMType::PCM_TYPE_GEOMETRY ? "GEOMETRY"
#ifdef USE_BSPLINE_PCM
: type == MccDefaultPCMType::PCM_TYPE_GEOMETRY_BSPLINE ? "GEOMETRY-BSPLINE"
: type == MccDefaultPCMType::PCM_TYPE_GEOMETRY_BSPLINE ? "BSPLINE"
#endif
: "UNKNOWN";
}
template <>
struct MccSerializer<MccDefaultPCMType> : MccSerializerBase {
constexpr static std::string_view serializerName{"MCC-DEFAULT-PCMTYPE-SERIALIZER"};
template <mcc_serialization_params_c ParamsT = mcc_serialization_params_t>
error_t operator()(traits::mcc_output_char_range auto& output,
MccDefaultPCMType const& value,
ParamsT const& params = mcc_serialization_params_t{})
{
std::ranges::copy(mccDefaultPCMTypeString(value), std::back_inserter(output));
return MccSerializerErrorCode::ERROR_OK;
}
};
template <>
struct MccDeserializer<MccDefaultPCMType> : MccDeserializerBase {
static constexpr std::string_view deserializerName{"MCC-COORD-EPOCH-DESERIALIZER"};
template <mcc_serialization_params_c ParamsT = mcc_serialization_params_t>
error_t operator()(traits::mcc_input_char_range auto const& input,
MccDefaultPCMType& value,
ParamsT const& params = mcc_serialization_params_t{})
{
auto s = mcc::utils::trimSpaces(input);
if (s == mcc::impl::MccDefaultPCMTypeString<mcc::impl::MccDefaultPCMType::PCM_TYPE_GEOMETRY>) {
value = mcc::impl::MccDefaultPCMType::PCM_TYPE_GEOMETRY;
} else if (s == mcc::impl::MccDefaultPCMTypeString<mcc::impl::MccDefaultPCMType::PCM_TYPE_GEOMETRY_BSPLINE>) {
value = mcc::impl::MccDefaultPCMType::PCM_TYPE_GEOMETRY;
} else if (s == mcc::impl::MccDefaultPCMTypeString<mcc::impl::MccDefaultPCMType::PCM_TYPE_BSPLINE>) {
value = mcc::impl::MccDefaultPCMType::PCM_TYPE_BSPLINE;
} else {
return MccDeserializerErrorCode::ERROR_INVALID_SERIALIZED_VALUE;
}
return MccDeserializerErrorCode::ERROR_OK;
}
};
template <MccMountType MOUNT_TYPE>
class MccDefaultPCM : public mcc_pcm_interface_t<std::error_code>
{
public:
static constexpr MccMountType mountType = MOUNT_TYPE;
// static constexpr MccMountType mountType = MOUNT_TYPE;
static constexpr MccMountType pcmMountType = MOUNT_TYPE;
#ifdef USE_BSPLINE_PCM
static constexpr std::string_view pcmName{"MCC-GEOMETRY-BSPLINES-PCM"};
@@ -138,8 +224,8 @@ public:
// alt-azimuthal
coeff_t tubeFlexure;
coeff_t forkFlexure;
coeff_t DECaxisFlexure; // declination axis flexure
coeff_t forkFlexure;
};
#ifdef USE_BSPLINE_PCM
@@ -151,15 +237,20 @@ public:
size_t bsplDegreeX = 3;
size_t bsplDegreeY = 3;
std::vector<knot_t> knotsX{};
std::vector<knot_t> knotsY{};
std::vector<knot_t> knotsX{}; // inner knots vector (at least 2-element)
std::vector<knot_t> knotsY{}; // inner knots vector (at least 2-element)
std::vector<coeff_t> coeffsX{};
std::vector<coeff_t> coeffsY{};
std::vector<coeff_t> coeffsX{}; // B-spline coefficients for relation func(CelestialX - hardwareX)
std::vector<coeff_t> coeffsY{}; // B-spline coefficients for relation func(CelestialY - hardwareY)
std::vector<coeff_t> inverseCoeffsX{}; // B-spline coefficients for relation func(hardwareX - CelestialX)
std::vector<coeff_t> inverseCoeffsY{}; // B-spline coefficients for relation func(hardwareY - CelestialY)
};
#endif
struct pcm_data_t {
typedef MccDefaultPCM pcm_t;
MccDefaultPCMType type{MccDefaultPCMType::PCM_TYPE_GEOMETRY};
double siteLatitude{0.0}; // in radians
@@ -181,7 +272,7 @@ public:
MccDefaultPCM() = default;
MccDefaultPCM(pcm_data_t pdata) : MccDefaultPCM()
{
_pcmData = std::move(pdata);
setPCMData(std::move(pdata));
}
MccDefaultPCM(MccDefaultPCM&& other) = default;
@@ -204,6 +295,36 @@ public:
_cosPhi = std::cos(_pcmData.siteLatitude);
_sinPhi = std::sin(_pcmData.siteLatitude);
#ifdef USE_BSPLINE_PCM
// recompute full set of B-spline knots
if (_pcmData.type == MccDefaultPCMType::PCM_TYPE_GEOMETRY_BSPLINE ||
_pcmData.type == MccDefaultPCMType::PCM_TYPE_BSPLINE) {
if (_pcmData.bspline.knotsX.size() > 1 && _pcmData.bspline.knotsY.size() > 1) {
_knotsX.resize(_pcmData.bspline.knotsX.size() + 6);
_knotsY.resize(_pcmData.bspline.knotsY.size() + 6);
} else {
_knotsX.clear();
_knotsY.clear();
}
// full set of B-spline knots
_knotsX[0] = _knotsX[1] = _knotsX[2] = _pcmData.bspline.knotsX[0];
_knotsX[_knotsX.size() - 1] = _knotsX[_knotsX.size() - 2] = _knotsX[_knotsX.size() - 3] =
_pcmData.bspline.knotsX.back();
_knotsY[0] = _knotsY[1] = _knotsY[2] = _pcmData.bspline.knotsY[0];
_knotsY[_knotsY.size() - 1] = _knotsY[_knotsY.size() - 2] = _knotsY[_knotsY.size() - 3] =
_pcmData.bspline.knotsY.back();
for (size_t i = 0; i < _pcmData.bspline.knotsX.size(); ++i) {
_knotsX[3 + i] = _pcmData.bspline.knotsX[i];
}
for (size_t i = 0; i < _pcmData.bspline.knotsY.size(); ++i) {
_knotsY[3 + i] = _pcmData.bspline.knotsY[i];
}
}
#endif
}
@@ -249,7 +370,8 @@ public:
res->pcmX = 0.0;
res->pcmY = 0.0;
auto ret = _compResult(hw_coord.x(), hw_coord.y(), res, false);
// auto ret = _compResult(hw_coord.x(), hw_coord.y(), res, false);
auto ret = _computeFuncDeriv(hw_coord.x(), hw_coord.y(), res);
if (ret) {
return ret;
}
@@ -315,13 +437,84 @@ public:
std::lock_guard lock(*_pcmDataMutex);
ret = _compResult(x, y, res, true);
if (!ret) {
if (_pcmData.type != MccDefaultPCMType::PCM_TYPE_BSPLINE) { // compute using Newton-Raphson correction
struct {
double pcmX, pcmY;
} dfx, dfy, df; // partial derivatives
ret = _computeFuncDeriv(x, y, res, true, &dfx, &dfy);
if (ret) {
return ret;
}
// are all geometry coeffs equal to 0?
if (utils::isEqual(dfx.pcmX, 0.0) && utils::isEqual(dfy.pcmX, 0.0) && utils::isEqual(dfx.pcmY, 0.0) &&
utils::isEqual(dfy.pcmY, 0.0)) {
if constexpr (mcc_coord_pair_c<T>) {
*hw_pt = MccCoordPair<typename T::x_t, typename T::y_t>{x, y, obs_skycoord.epoch()};
}
return MccDefaultPCMErrorCode::ERROR_OK;
}
dfx.pcmX += 1.0; // a
dfx.pcmY += 1.0; // b
dfy.pcmX += 1.0; // c
dfy.pcmY += 1.0; // d
// Jacobian determinant
auto detJ = dfx.pcmX * dfy.pcmY - dfx.pcmY * dfy.pcmX;
if (utils::isEqual(detJ, 0.0)) {
return MccDefaultPCMErrorCode::ERROR_JACINV;
}
// | a b |
// if A = | c d |, then
//
// -1 | d -b |
// A = 1/detA * | -c a |
//
// and
//
// -1 | pcmX | | d*pcmX - b*pcmY |
// A * | pcmY | = | -c*pcmX + a*pcmY |
//
df.pcmX = (dfy.pcmY * res->pcmX - dfx.pcmY * res->pcmY) / detJ;
df.pcmY = (-dfy.pcmX * res->pcmX + dfx.pcmX * res->pcmY) / detJ;
res->pcmX = -df.pcmX;
res->pcmY = -df.pcmY;
// res->pcmX -= df.pcmX;
// res->pcmY -= df.pcmY;
// if constexpr (mcc_coord_pair_c<T>) {
// *hw_pt = MccCoordPair<typename T::x_t, typename T::y_t>{res->pcmX, res->pcmY, obs_skycoord.epoch()};
// }
if constexpr (mcc_coord_pair_c<T>) {
*hw_pt =
MccCoordPair<typename T::x_t, typename T::y_t>{x + res->pcmX, y + res->pcmY, obs_skycoord.epoch()};
}
} else { // for B-splines the result is computed directly from inverse B-spline coefficients
ret = _computeFuncDeriv(x, y, res, true);
if (!ret) {
if constexpr (mcc_coord_pair_c<T>) {
*hw_pt = MccCoordPair<typename T::x_t, typename T::y_t>{x + res->pcmX, y + res->pcmY,
obs_skycoord.epoch()};
}
}
}
// ret = _compResult(x, y, res, true);
// if (!ret) {
// if constexpr (mcc_coord_pair_c<T>) {
// *hw_pt =
// MccCoordPair<typename T::x_t, typename T::y_t>{x + res->pcmX, y + res->pcmY,
// obs_skycoord.epoch()};
// }
// }
return ret;
}
@@ -381,8 +574,242 @@ private:
pcm_data_t _pcmData{};
double _cosPhi{}, _sinPhi{};
std::vector<double> _knotsX{}, _knotsY{}; // store a full set of B-spline knots
std::unique_ptr<std::mutex> _pcmDataMutex{new std::mutex};
// compute PCM function and its partial derivatives if asked
template <typename DXT = std::nullptr_t, typename DYT = std::nullptr_t>
error_t _computeFuncDeriv(double x,
double y,
mcc_pcm_result_c auto* res,
bool inverse = false,
DXT derivX = nullptr,
DYT derivY = nullptr)
requires((std::is_null_pointer_v<DXT> || mcc_pcm_result_c<std::remove_pointer_t<DXT>>) &&
(std::is_null_pointer_v<DYT> || mcc_pcm_result_c<std::remove_pointer_t<DYT>>))
{
if constexpr (std::is_null_pointer_v<DXT> || std::is_null_pointer_v<DYT>) {
if (_pcmData.type != MccDefaultPCMType::PCM_TYPE_BSPLINE && inverse) {
return MccDefaultPCMErrorCode::ERROR_NULLPTR;
}
}
if constexpr (mcc_is_equatorial_mount<MOUNT_TYPE>) { // HA - DEC system (needs normalization)
if (!inverse) {
x = MccAngleHA_OBS(x);
y = MccAngleDEC_OBS(y);
}
// in the case of inverse PCM it is assumed that angles are already normalized (inputs are celestial
// coordiinates)
}
pcm_geom_coeffs_t* geom_coeffs = &_pcmData.geomCoefficients;
#ifdef USE_BSPLINE_PCM
if (_pcmData.type == MccDefaultPCMType::PCM_TYPE_BSPLINE ||
_pcmData.type == MccDefaultPCMType::PCM_TYPE_GEOMETRY_BSPLINE) {
if (_knotsX.empty() || _knotsY.empty()) {
return MccDefaultPCMErrorCode::ERROR_INVALID_BSPLINE_KNOTS;
}
}
pcm_bspline_t* bspline = &_pcmData.bspline;
// pcm_bspline_t* inv_bspline = &_pcmData.inverseBspline;
#endif
#ifdef USE_BSPLINE_PCM
if (_pcmData.type == MccDefaultPCMType::PCM_TYPE_GEOMETRY ||
_pcmData.type == MccDefaultPCMType::PCM_TYPE_GEOMETRY_BSPLINE) {
#endif
const auto tanY = std::tan(y);
const auto sinX = std::sin(x);
const auto cosX = std::cos(x);
const auto cosY = std::cos(y);
const auto sinY = std::sin(y);
if (utils::isEqual(cosY, 0.0)) {
res->pcmX = _pcmData.geomCoefficients.zeroPointX;
if constexpr (!std::is_null_pointer_v<DXT>) {
derivX->pcmX = 0.0; // dpcmX/dX
derivX->pcmY = 0.0; // dpcmX/dY
}
} else {
res->pcmX = geom_coeffs->zeroPointX + geom_coeffs->collimationErr / cosY +
geom_coeffs->nonperpendErr * tanY - geom_coeffs->misalignErr1 * cosX * tanY +
geom_coeffs->misalignErr2 * sinX * tanY + geom_coeffs->tubeFlexure * _cosPhi * sinX / cosY -
geom_coeffs->DECaxisFlexure * (_cosPhi * cosX + _sinPhi * tanY);
if constexpr (!std::is_null_pointer_v<DXT>) {
auto cos2Y = cosY * cosY;
derivX->pcmX = (geom_coeffs->misalignErr1 * sinX + geom_coeffs->misalignErr2 * cosX) * tanY +
geom_coeffs->tubeFlexure * _cosPhi * cosX / cosY +
geom_coeffs->DECaxisFlexure * _cosPhi * sinX; // dpcmX/dX
derivX->pcmY =
(geom_coeffs->collimationErr * sinY + geom_coeffs->nonperpendErr -
geom_coeffs->misalignErr1 * cosX + geom_coeffs->misalignErr2 * sinX +
geom_coeffs->tubeFlexure * _cosPhi * sinX * sinY - geom_coeffs->DECaxisFlexure * _sinPhi) /
cos2Y; // dpcmX/dY
}
}
res->pcmY = geom_coeffs->zeroPointY + geom_coeffs->misalignErr1 * sinX + geom_coeffs->misalignErr2 * cosX +
geom_coeffs->tubeFlexure * (_cosPhi * cosX * sinY - _sinPhi * cosY);
if constexpr (!std::is_null_pointer_v<DYT>) {
derivY->pcmX = geom_coeffs->misalignErr1 * cosX - geom_coeffs->misalignErr2 * sinX -
geom_coeffs->tubeFlexure * _cosPhi * sinX * sinY; // dpcmY/dX
derivY->pcmY = geom_coeffs->tubeFlexure * (_cosPhi * cosX * cosY + _sinPhi * sinY); // dpcmY/dY
}
if constexpr (pcmMountType == MccMountType::FORK_TYPE) {
if (!utils::isEqual(cosX, 0.0)) {
res->pcmY += geom_coeffs->forkFlexure / cosX;
if constexpr (!std::is_null_pointer_v<DYT>) {
derivY->pcmY += geom_coeffs->forkFlexure * sinX / cosX / cosY; // dpcmY/dY
}
}
}
#ifdef USE_BSPLINE_PCM
}
#endif
#ifdef USE_BSPLINE_PCM
if (_pcmData.type == MccDefaultPCMType::PCM_TYPE_BSPLINE ||
(_pcmData.type == MccDefaultPCMType::PCM_TYPE_GEOMETRY_BSPLINE && !inverse)) {
double spl_valX, spl_valY;
int ret = bsplines::fitpack_eval_spl2d(_knotsX, _knotsY, bspline->coeffsX, x, y, spl_valX,
bspline->bsplDegreeX, bspline->bsplDegreeY);
// int ret = bsplines::fitpack_eval_spl2d(bspline->knotsX, bspline->knotsY, bspline->coeffsX, x, y,
// spl_valX,
// bspline->bsplDegreeX, bspline->bsplDegreeY);
if (ret) {
res->pcmX = std::numeric_limits<double>::quiet_NaN();
res->pcmY = std::numeric_limits<double>::quiet_NaN();
return MccDefaultPCMErrorCode::ERROR_INVALID_INPUTS_BISPLEV;
}
ret = bsplines::fitpack_eval_spl2d(_knotsX, _knotsY, bspline->coeffsY, x, y, spl_valY, bspline->bsplDegreeX,
bspline->bsplDegreeY);
// ret = bsplines::fitpack_eval_spl2d(bspline->knotsX, bspline->knotsY, bspline->coeffsY, x, y, spl_valY,
// bspline->bsplDegreeX, bspline->bsplDegreeY);
if (ret) {
res->pcmX = std::numeric_limits<double>::quiet_NaN();
res->pcmY = std::numeric_limits<double>::quiet_NaN();
return MccDefaultPCMErrorCode::ERROR_INVALID_INPUTS_BISPLEV;
}
res->pcmX += spl_valX;
res->pcmY += spl_valY;
}
// compute partial derivatives of the bivariate B-spline
if (_pcmData.type == MccDefaultPCMType::PCM_TYPE_GEOMETRY_BSPLINE && inverse) {
double dspl_valX, dspl_valY;
int ret = 0;
if constexpr (!std::is_null_pointer_v<DXT>) {
ret = bsplines::fitpack_parder_spl2d(_knotsX, _knotsY, bspline->coeffsX, x, y, dspl_valX, 1, 0,
bspline->bsplDegreeX, bspline->bsplDegreeY);
// ret = bsplines::fitpack_parder_spl2d(bspline->knotsX, bspline->knotsY, bspline->coeffsX, x, y,
// dspl_valX, 1, 0, bspline->bsplDegreeX, bspline->bsplDegreeY);
if (ret) {
return MccDefaultPCMErrorCode::ERROR_INVALID_INPUTS_BISPLEV;
}
derivX->pcmX += dspl_valX; // dpcmX/dX
ret = bsplines::fitpack_parder_spl2d(_knotsX, _knotsY, bspline->coeffsX, x, y, dspl_valX, 0, 1,
bspline->bsplDegreeX, bspline->bsplDegreeY);
// ret = bsplines::fitpack_parder_spl2d(bspline->knotsX, bspline->knotsY, bspline->coeffsX, x, y,
// dspl_valX, 0, 1, bspline->bsplDegreeX, bspline->bsplDegreeY);
if (ret) {
return MccDefaultPCMErrorCode::ERROR_INVALID_INPUTS_BISPLEV;
}
derivX->pcmY += dspl_valX; // dpcmX/dY
}
if constexpr (!std::is_null_pointer_v<DYT>) {
ret = bsplines::fitpack_parder_spl2d(_knotsX, _knotsY, bspline->coeffsY, x, y, dspl_valY, 1, 0,
bspline->bsplDegreeX, bspline->bsplDegreeY);
// ret = bsplines::fitpack_parder_spl2d(bspline->knotsX, bspline->knotsY, bspline->coeffsY, x, y,
// dspl_valY, 1, 0, bspline->bsplDegreeX, bspline->bsplDegreeY);
if (ret) {
return MccDefaultPCMErrorCode::ERROR_INVALID_INPUTS_BISPLEV;
}
derivY->pcmX += dspl_valY; // dpcmY/dX
ret = bsplines::fitpack_parder_spl2d(_knotsX, _knotsY, bspline->coeffsY, x, y, dspl_valY, 0, 1,
bspline->bsplDegreeX, bspline->bsplDegreeY);
// ret = bsplines::fitpack_parder_spl2d(bspline->knotsX, bspline->knotsY, bspline->coeffsY, x, y,
// dspl_valY, 0, 1, bspline->bsplDegreeX, bspline->bsplDegreeY);
if (ret) {
return MccDefaultPCMErrorCode::ERROR_INVALID_INPUTS_BISPLEV;
}
derivY->pcmY += dspl_valY; // dpcmY/dY
}
}
// for inverse PCM the inverse spline coefficients are used (derivatives are not computed)!!!
if (_pcmData.type == MccDefaultPCMType::PCM_TYPE_BSPLINE && inverse) {
double spl_valX, spl_valY;
int ret = bsplines::fitpack_eval_spl2d(_knotsX, _knotsY, bspline->inverseCoeffsX, x, y, spl_valX,
bspline->bsplDegreeX, bspline->bsplDegreeY);
// int ret = bsplines::fitpack_eval_spl2d(bspline->knotsX, bspline->knotsY, bspline->inverseCoeffsX, x, y,
// spl_valX, bspline->bsplDegreeX, bspline->bsplDegreeY);
if (ret) {
res->pcmX = std::numeric_limits<double>::quiet_NaN();
res->pcmY = std::numeric_limits<double>::quiet_NaN();
return MccDefaultPCMErrorCode::ERROR_INVALID_INPUTS_BISPLEV;
}
ret = bsplines::fitpack_eval_spl2d(_knotsX, _knotsY, bspline->inverseCoeffsY, x, y, spl_valY,
bspline->bsplDegreeX, bspline->bsplDegreeY);
// ret = bsplines::fitpack_eval_spl2d(bspline->knotsX, bspline->knotsY, bspline->inverseCoeffsY, x, y,
// spl_valY, bspline->bsplDegreeX, bspline->bsplDegreeY);
if (ret) {
res->pcmX = std::numeric_limits<double>::quiet_NaN();
res->pcmY = std::numeric_limits<double>::quiet_NaN();
return MccDefaultPCMErrorCode::ERROR_INVALID_INPUTS_BISPLEV;
}
res->pcmX = spl_valX;
res->pcmY = spl_valY;
}
#endif
return MccDefaultPCMErrorCode::ERROR_OK;
}
error_t _compResult(double x, double y, mcc_pcm_result_c auto* res, bool inverse)
{
pcm_geom_coeffs_t* geom_coeffs;
@@ -417,7 +844,8 @@ private:
res->pcmY = geom_coeffs->zeroPointY + geom_coeffs->misalignErr1 * sinX + geom_coeffs->misalignErr2 * cosX +
geom_coeffs->tubeFlexure * (_cosPhi * cosX * std::sin(y) - _sinPhi * cosY);
if constexpr (mountType == MccMountType::FORK_TYPE) {
// if constexpr (mountType == MccMountType::FORK_TYPE) {
if constexpr (pcmMountType == MccMountType::FORK_TYPE) {
if (!utils::isEqual(cosX, 0.0)) {
res->pcmY += geom_coeffs->forkFlexure / cosX;
}

View File

@@ -0,0 +1,618 @@
#pragma once
/****************************************************************************************
* *
* MOUNT CONTROL COMPONENTS LIBRARY *
* *
* *
* "POINTING-CORRECTION-MODEL" FITTER *
* *
****************************************************************************************/
#include <eigen3/Eigen/Dense>
#include "mcc_concepts.h"
#include "mcc_coordinate.h"
#include "mcc_pcm.h"
namespace mcc::impl
{
enum class MccDefaultPCMConstructorErrorCode : int {
ERROR_OK,
ERROR_NOT_ENOUGH_DATA,
ERROR_INVALID_INDEX,
#ifdef USE_BSPLINE_PCM
ERROR_INVALID_KNOTS_NUMBER,
ERROR_BSPLINE_FIT
#endif
};
// error category
struct MccDefaultPCMConstructorErrorCategory : std::error_category {
MccDefaultPCMConstructorErrorCategory() = default;
const char* name() const noexcept
{
return "MCC-DEFAULT-PCM-CONSTRUCTOR-ERROR-CATEGORY";
}
std::string message(int ec) const
{
MccDefaultPCMConstructorErrorCode err = static_cast<MccDefaultPCMConstructorErrorCode>(ec);
switch (err) {
case MccDefaultPCMConstructorErrorCode::ERROR_OK:
return "OK";
case MccDefaultPCMConstructorErrorCode::ERROR_NOT_ENOUGH_DATA:
return "not enough data point";
case MccDefaultPCMConstructorErrorCode::ERROR_INVALID_INDEX:
return "invalid index of data point";
#ifdef USE_BSPLINE_PCM
case MccDefaultPCMConstructorErrorCode::ERROR_INVALID_KNOTS_NUMBER:
return "invalid number of B-spline knots";
case MccDefaultPCMConstructorErrorCode::ERROR_BSPLINE_FIT:
return "B-spline fitting error";
#endif
default:
return "UNKNOWN";
}
}
static const MccDefaultPCMConstructorErrorCategory& get()
{
static const MccDefaultPCMConstructorErrorCategory constInst;
return constInst;
}
};
inline std::error_code make_error_code(MccDefaultPCMConstructorErrorCode ec)
{
return std::error_code(static_cast<int>(ec), MccDefaultPCMConstructorErrorCategory::get());
}
} // namespace mcc::impl
namespace std
{
template <>
class is_error_code_enum<mcc::impl::MccDefaultPCMConstructorErrorCode> : public true_type
{
};
} // namespace std
namespace mcc::impl
{
template <MccMountType MOUNT_TYPE>
class MccPCMConstructor
{
public:
using ref_coordpair_t = std::conditional_t<mcc_is_equatorial_mount<MOUNT_TYPE>,
MccSkyHADEC_OBS,
std::conditional_t<mcc_is_altaz_mount<MOUNT_TYPE>, MccSkyAZZD, void>>;
static_assert(!std::is_void_v<ref_coordpair_t>, "UNSUPPORTED MOUNT TYPE!");
struct table_t {
std::vector<double> target_colon{}, target_colat{};
std::vector<double> hw_colon{}, hw_colat{};
std::vector<double> colon_res{}, colat_res{}; // target - hw
};
struct compute_result_t {
MccDefaultPCMType pcm_type;
MccError error{}; // final model computation error
size_t final_iter{}; // number of final iteration
std::vector<double> model_colon{}, model_colat{}; // fitting model values
std::vector<double> colon_res{}, colat_res{}; // target - model
std::vector<double> colon_weight{}, colat_weight; // Tukey's weights
#ifdef USE_BSPLINE_PCM
int bspline_fit_err{}; // bivariate B-spline fitting exit code (see FITPACK)
// quantities below are computed only fo pcm_type == MccDefaultPCMType::PCM_TYPE_BSPLINE
std::vector<double> inv_model_colon, inv_model_colat; // fitted inverse model values
std::vector<double> inv_colon_res, inv_colat_res; // encoder - model
#endif
};
struct compute_params_t {
size_t max_iter{100}; // max number of iterations for robust linear regression method
double c{4.685}; // Tukey's parameter
double tolerance{1.0E-6}; //
};
template <mcc_coord_pair_c TAG_T, mcc_coord_pair_c HW_T>
MccError addPoint(TAG_T target_coords, HW_T const& hw_counts)
requires(TAG_T::pairKind == ref_coordpair_t::pairKind && HW_T::pairKind == MccCoordPairKind::COORDS_KIND_XY)
{
//
// TODO: target_coords.epoch() != hw_counts.epoch() ?!!!!!!!!!
//
_tableEpoch.emplace_back(hw_counts.epoch());
_table.target_colon.emplace_back(target_coords.x());
_table.target_colat.emplace_back(target_coords.y());
_table.hw_colon.emplace_back(hw_counts.x());
_table.hw_colat.emplace_back(hw_counts.y());
_table.colon_res.emplace_back((double)target_coords.x() - (double)hw_counts.x());
_table.colat_res.emplace_back((double)target_coords.y() - (double)hw_counts.y());
return {};
}
MccError addPoint(mcc_skypoint_c auto const& target_coords, mcc_coord_pair_c auto const& hw_counts)
requires(std::decay_t<decltype(hw_counts)>::pairKind == MccCoordPairKind::COORDS_KIND_XY)
{
ref_coordpair_t cp;
cp.setEpoch(hw_counts.epoch());
auto err = target_coords.to(cp);
if (err) {
return mcc_deduced_err(err, MccDefaultPCMErrorCode::ERROR_CCTE);
}
return addPoint(cp, hw_counts);
// auto err = target_coords.to(ref_coordpair_t::pairKind, hw_counts.epoch());
// if (err) {
// return mcc_deduced_err(err, MccDefaultPCMErrorCode::ERROR_CCTE);
// }
// _tableEpoch.emplace_back(hw_counts.epoch());
// _table.target_colon.emplace_back(target_coords.co_lon());
// _table.target_colat.emplace_back(target_coords.co_lat());
// _table.hw_colon.emplace_back(hw_counts.x());
// _table.hw_colat.emplace_back(hw_counts.y());
// _table.colon_res.emplace_back(target_coords.co_lon() - hw_counts.x());
// _table.colat_res.emplace_back(target_coords.co_lat() - hw_counts.y());
// return {};
}
const table_t& getTable() const
{
return _table;
}
template <mcc_coord_pair_c TAG_T, mcc_coord_pair_c HW_T>
MccError getPoint(size_t idx, std::tuple<TAG_T, HW_T>& point)
requires(std::same_as<typename TAG_T::x_t, typename ref_coordpair_t::x_t> &&
std::same_as<typename TAG_T::y_t, typename ref_coordpair_t::y_t> &&
HW_T::pairKind == MccCoordPairKind::COORDS_KIND_XY)
{
if (idx > _table.target_colon.size()) {
return MccDefaultPCMConstructorErrorCode::ERROR_INVALID_INDEX;
}
std::get<0>(point).setX(_table.target_colon[idx]);
std::get<0>(point).setY(_table.target_colat[idx]);
std::get<0>(point).setEpoch(_tableEpoch[idx]);
std::get<1>(point).setX(_table.hw_colon[idx]);
std::get<1>(point).setY(_table.hw_colat[idx]);
std::get<1>(point).setEpoch(_tableEpoch[idx]);
return MccDefaultPCMConstructorErrorCode::ERROR_OK;
}
size_t numberOfPoints() const
{
return _table.colon_res.size();
}
void deletePoints()
{
_tableEpoch.clear();
_table.target_colon.clear();
_table.target_colat.clear();
_table.hw_colon.clear();
_table.hw_colat.clear();
_table.colon_res.clear();
_table.colat_res.clear();
}
//
// for B-splines interior knots along axes must be given in 'pcm_data'
// NOTE: the size of the interior knots array must be at least 2 as
// it are interpretated as border knots and final full knots set is:
// knots = [input_knots[0], input_knots[0], input_knots[0], input_knots[0], input_knots[1], input_knots[2],
// ..., input_knots[N-1], input_knots[N-1], input_knots[N-1], input_knots[N-1]], where N = input_knots.size()
//
// WARNING: the input knots for inverse B-spline are ignored so the direct and inverse B-spline coefficients are
// calculated on the same mesh!
compute_result_t computeModel(MccDefaultPCM<MOUNT_TYPE>::pcm_data_t& pcm_data,
compute_params_t const& comp_params = {})
{
compute_result_t result{.pcm_type = pcm_data.type, .error = MccDefaultPCMConstructorErrorCode::ERROR_OK};
size_t min_data_size = 2; // 2 is for BSPLINE
if (pcm_data.type == MccDefaultPCMType::PCM_TYPE_GEOMETRY
#ifdef USE_BSPLINE_PCM
|| pcm_data.type == MccDefaultPCMType::PCM_TYPE_GEOMETRY_BSPLINE
#endif
) {
if constexpr (MOUNT_TYPE == MccMountType::FORK_TYPE) {
min_data_size = 9;
} else {
min_data_size = 8;
}
if (numberOfPoints() < min_data_size) {
result.error = MccDefaultPCMConstructorErrorCode::ERROR_NOT_ENOUGH_DATA;
return result;
}
// robust linear regression with Tukey's loss function
result = robustLinearRegress(pcm_data, comp_params);
} else {
if (numberOfPoints() < min_data_size) {
result.error = MccDefaultPCMConstructorErrorCode::ERROR_NOT_ENOUGH_DATA;
return result;
}
}
#ifdef USE_BSPLINE_PCM
if (pcm_data.type == MccDefaultPCMType::PCM_TYPE_BSPLINE) {
return bsplineFitting(pcm_data);
} else if (pcm_data.type == MccDefaultPCMType::PCM_TYPE_GEOMETRY_BSPLINE) {
// the fitting for geometrical coefficients is already done above so
// one must fit residuals by bivariate B-splines
std::vector<double> xres = _table.colon_res, yres = _table.colat_res;
for (size_t i = 0; i < numberOfPoints(); ++i) {
_table.colon_res[i] = _table.target_colon[i] - result.model_colon[i];
_table.colat_res[i] = _table.target_colat[i] - result.model_colat[i];
}
auto r = bsplineFitting(pcm_data);
result.error = r.error;
result.bspline_fit_err = r.bspline_fit_err;
if (!r.error) {
for (size_t i = 0; i < numberOfPoints(); ++i) {
result.model_colon[i] += r.model_colon[i];
result.model_colat[i] += r.model_colat[i];
result.colon_res[i] = _table.target_colon[i] - result.model_colon[i];
result.colat_res[i] = _table.target_colat[i] - result.model_colat[i];
}
}
// restore original residuals
_table.colon_res = xres;
_table.colat_res = yres;
}
#endif
return result;
}
protected:
// std::vector<table_elem_t> _table;
table_t _table{};
std::vector<MccCelestialCoordEpoch> _tableEpoch{};
compute_result_t bsplineFitting(MccDefaultPCM<MOUNT_TYPE>::pcm_data_t& pcm_data)
{
compute_result_t result{.pcm_type = pcm_data.type, .error = MccDefaultPCMConstructorErrorCode::ERROR_OK};
// at least border knots must be given ([t_min, t_max])
if (pcm_data.bspline.knotsX.size() < 2 || pcm_data.bspline.knotsY.size() < 2) {
result.error = MccDefaultPCMConstructorErrorCode::ERROR_INVALID_KNOTS_NUMBER;
return result;
}
double resi2x, resi2y; // sum of fitting residuals squares
// full knot vectors: [t_min, t_min, t_min, t_min, ..., t_1, t_2, ..., t_max, t_max, t_max, t_max]
std::vector<double> tx(pcm_data.bspline.knotsX.size() + 6), ty(pcm_data.bspline.knotsY.size() + 6);
std::vector<double> theta_hw(numberOfPoints()), theta_tag(numberOfPoints());
/*
WARNING:
FITPACK B-spline on sphere: in the fitting routines the first angle argument is THETA - co-latitude
coordinate and the second one is PHI - co-longitude!!!
In the fitting routines the first angle argument THETA must be in the range of [0.0, PI]
(while celestial declination is in the range of [-PI/2, PI/2])!!!
*/
for (size_t i = 0; i < numberOfPoints(); ++i) {
theta_hw[i] = _table.hw_colat[i] + MCC_HALF_PI;
}
tx[0] = tx[1] = tx[2] = pcm_data.bspline.knotsX[0];
tx[tx.size() - 1] = tx[tx.size() - 2] = tx[tx.size() - 3] =
pcm_data.bspline.knotsX[pcm_data.bspline.knotsX.size() - 1];
ty[0] = ty[1] = ty[2] = pcm_data.bspline.knotsY[0] + MCC_HALF_PI;
ty[ty.size() - 1] = ty[ty.size() - 2] = ty[ty.size() - 3] =
pcm_data.bspline.knotsY[pcm_data.bspline.knotsY.size() - 1] + MCC_HALF_PI;
for (size_t i = 0; i < pcm_data.bspline.knotsX.size(); ++i) {
tx[3 + i] = pcm_data.bspline.knotsX[i];
}
for (size_t i = 0; i < pcm_data.bspline.knotsY.size(); ++i) {
ty[3 + i] = pcm_data.bspline.knotsY[i] + MCC_HALF_PI;
}
size_t Ncoeffs = (tx.size() - 4) * (ty.size() - 4);
pcm_data.bspline.coeffsX.resize(Ncoeffs);
pcm_data.bspline.coeffsY.resize(Ncoeffs);
// direct (celestial = encoder + pcm)
result.bspline_fit_err = bsplines::fitpack_sphere_fit(theta_hw, _table.hw_colon, _table.colon_res, 1.0, ty, tx,
pcm_data.bspline.coeffsX, resi2x);
if (result.bspline_fit_err > 0) {
result.error = MccDefaultPCMConstructorErrorCode::ERROR_BSPLINE_FIT;
return result;
}
result.bspline_fit_err = bsplines::fitpack_sphere_fit(theta_hw, _table.hw_colon, _table.colat_res, 1.0, ty, tx,
pcm_data.bspline.coeffsY, resi2y);
if (result.bspline_fit_err > 0) {
result.error = MccDefaultPCMConstructorErrorCode::ERROR_BSPLINE_FIT;
return result;
}
bsplines::fitpack_eval_spl2d(ty, tx, pcm_data.bspline.coeffsX, theta_hw, _table.hw_colon,
result.model_colon); // get fitted residuals!!!
bsplines::fitpack_eval_spl2d(ty, tx, pcm_data.bspline.coeffsY, theta_hw, _table.hw_colon,
result.model_colat); // get fitted residuals!!!
result.colon_res.resize(numberOfPoints());
result.colat_res.resize(numberOfPoints());
for (size_t i = 0; i < numberOfPoints(); ++i) {
result.colon_res[i] = _table.colon_res[i] - result.model_colon[i]; // = target - model
result.colat_res[i] = _table.colat_res[i] - result.model_colat[i]; // = target - model
// result.model_colon[i] += _table.hw_colon[i]; // == hw + fitted_pcmX
// result.model_colat[i] += _table.hw_colat[i]; // == hw + fitted_pcmY
}
if (pcm_data.type == MccDefaultPCMType::PCM_TYPE_BSPLINE) {
// here both direct and inverse coefficients will be calculated
pcm_data.inverseBspline.coeffsX.resize(Ncoeffs);
pcm_data.inverseBspline.coeffsY.resize(Ncoeffs);
std::vector<double> theta_tag(numberOfPoints());
// inverse (encoder = celestial + pcm)
std::vector<double> colon_res = _table.colon_res;
std::vector<double> colat_res = _table.colat_res;
for (size_t i = 0; i < colat_res.size(); ++i) {
colon_res[i] = -colon_res[i];
colat_res[i] = -colat_res[i];
theta_tag[i] = _table.target_colat[i] + MCC_HALF_PI;
}
result.bspline_fit_err = bsplines::fitpack_sphere_fit(theta_tag, _table.target_colon, colon_res, 1.0, ty,
tx, pcm_data.bspline.inverseCoeffsX, resi2x);
if (result.bspline_fit_err > 0) {
result.error = MccDefaultPCMConstructorErrorCode::ERROR_BSPLINE_FIT;
return result;
}
result.bspline_fit_err = bsplines::fitpack_sphere_fit(theta_tag, _table.target_colon, colat_res, 1.0, ty,
tx, pcm_data.bspline.inverseCoeffsY, resi2y);
if (result.bspline_fit_err > 0) {
result.error = MccDefaultPCMConstructorErrorCode::ERROR_BSPLINE_FIT;
return result;
}
bsplines::fitpack_eval_spl2d(ty, tx, pcm_data.bspline.inverseCoeffsX, theta_tag, _table.target_colon,
result.inv_model_colon); // get fitted residuals!!!
bsplines::fitpack_eval_spl2d(ty, tx, pcm_data.bspline.inverseCoeffsY, theta_tag, _table.target_colon,
result.inv_model_colat); // get fitted residuals!!!
result.inv_colon_res.resize(numberOfPoints());
result.inv_colat_res.resize(numberOfPoints());
for (size_t i = 0; i < numberOfPoints(); ++i) {
result.inv_colon_res[i] = _table.colon_res[i] - result.inv_model_colon[i]; // = hw - model
result.inv_colat_res[i] = _table.colat_res[i] - result.inv_model_colat[i]; // = hw - model
// result.inv_model_colon[i] += _table.target_colon[i]; // == target +
// fitted_pcmX result.inv_model_colat[i] += _table.target_colat[i]; // == target
// + fitted_pcmY
}
}
return result;
}
compute_result_t robustLinearRegress(MccDefaultPCM<MOUNT_TYPE>::pcm_data_t& pcm_data,
compute_params_t const& comp_params)
{
auto tukey_weight = [](Eigen::VectorXd const& resi, double tukey_c, Eigen::VectorXd& tukey_weight) {
Eigen::ArrayXd u = (resi / tukey_c).cwiseAbs();
auto mask = (u < 1.0);
Eigen::VectorXd r = mask.select(1.0 - u * u, 0.0);
tukey_weight = r.array() * r.array();
};
auto gastwirth_est = [](Eigen::VectorXd const& r) {
// auto gastwirth_est = [](Eigen::VectorXd const& resi) {
auto resi = r;
std::nth_element(resi.begin(), resi.begin() + resi.size() / 2, resi.end());
double md = resi(resi.size() / 2);
resi = resi.array() - md;
// Gastwirth’s estimation: 0.3*Q(1/3) + 0.4*Q(1/2) + 0.3*Q(2/3)
Eigen::ArrayXd arr = resi.cwiseAbs();
std::nth_element(arr.begin(), arr.begin() + 2 * arr.size() / 3, arr.end());
// add 1.0E-8 to avoid 0.0
return (0.3 * arr(arr.size() / 3) + 0.4 * arr(arr.size() / 2) + 0.3 * arr(2 * arr.size() / 3)) / 0.6745 +
1.0E-8;
// std::nth_element(arr.begin(), arr.begin() + arr.size() / 2, arr.end());
// return arr(arr.size() / 2) / 0.6745 + 1.0E-8;
};
compute_result_t result{.pcm_type = pcm_data.type, .error = MccDefaultPCMConstructorErrorCode::ERROR_OK};
const size_t n_coeffs = MOUNT_TYPE == MccMountType::FORK_TYPE ? 9 : 8;
Eigen::MatrixXd X(2 * numberOfPoints(), n_coeffs);
Eigen::VectorXd y(2 * numberOfPoints()), beta = Eigen::VectorXd::Zero(n_coeffs), new_beta(n_coeffs);
Eigen::VectorXd model;
Eigen::RowVectorXd row(n_coeffs);
double tgY, sinY, cosY, rcosY, cosX, sinX, cosPhi = std::cos(pcm_data.siteLatitude),
sinPhi = std::sin(pcm_data.siteLatitude);
// system matrix and right-hand vector
for (size_t i = 0; i < numberOfPoints(); ++i) {
cosY = std::cos(_table.target_colat[i]);
sinY = std::sin(_table.target_colat[i]);
rcosY = 1.0 / cosY;
tgY = std::tan(_table.target_colat[i]);
cosX = std::cos(_table.target_colon[i]);
sinX = std::sin(_table.target_colon[i]);
// [X0, Y0, collim, nonperp, misal1, misal2, tubefl, DECaxfl, forkfl] or
// [X0, Y0, collim, nonperp, misal1, misal2, tubefl, DECaxfl]
if constexpr (MOUNT_TYPE == MccMountType::FORK_TYPE) {
if (utils::isEqual(cosY, 0.0)) {
row << 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0;
} else {
row << 1.0, 0.0, rcosY, tgY, -cosX * tgY, sinX * tgY, cosPhi * sinX * rcosY,
-(cosPhi * cosX + sinPhi * tgY), 0.0;
}
} else {
if (utils::isEqual(cosY, 0.0)) {
row << 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0;
} else {
row << 1.0, 0.0, rcosY, tgY, -cosX * tgY, sinX * tgY, cosPhi * sinX * rcosY,
-(cosPhi * cosX + sinPhi * tgY);
}
}
X.row(i) = row;
if constexpr (MOUNT_TYPE == MccMountType::FORK_TYPE) {
if (utils::isEqual(cosX, 0.0)) {
row << 0.0, 1.0, 0.0, 0.0, sinX, cosX, cosPhi * cosX * sinY - sinPhi * cosY, 0.0, 0.0;
} else {
row << 0.0, 1.0, 0.0, 0.0, sinX, cosX, cosPhi * cosX * sinY - sinPhi * cosY, 0.0, 1.0 / cosX;
}
} else {
row << 0.0, 1.0, 0.0, 0.0, sinX, cosX, cosPhi * cosX * sinY - sinPhi * cosY, 0.0;
}
X.row(i + numberOfPoints()) = row;
y(i) = _table.colon_res[i];
y(i + numberOfPoints()) = _table.colat_res[i];
}
Eigen::VectorXd resi = y;
Eigen::VectorXd weights(2 * numberOfPoints());
double scale;
Eigen::MatrixXd WX;
Eigen::VectorXd Wy;
// initial parameters estimation (least squares)
beta = X.bdcSvd(Eigen::ComputeThinU | Eigen::ComputeThinV).solve(y);
model = X * beta;
resi = y - model;
// resi = y;
for (result.final_iter = 1; result.final_iter <= comp_params.max_iter; ++result.final_iter) {
scale = gastwirth_est(resi);
tukey_weight(resi / scale, comp_params.c, weights);
// Eigen::MatrixXd XtW = X.transpose() * weights.asDiagonal();
// Eigen::MatrixXd XtWX = XtW * X;
// Eigen::VectorXd XtWy = XtW * y;
// new_beta = XtWX.ldlt().solve(XtWy);
WX = weights.asDiagonal() * X;
Wy = weights.asDiagonal() * y;
new_beta = WX.bdcSvd(Eigen::ComputeThinU | Eigen::ComputeThinV).solve(Wy);
if ((new_beta - beta).norm() < comp_params.tolerance) {
break;
}
beta = new_beta;
model = X * beta;
resi = y - model;
}
pcm_data.geomCoefficients.zeroPointX = new_beta(0);
pcm_data.geomCoefficients.zeroPointY = new_beta(1);
pcm_data.geomCoefficients.collimationErr = new_beta(2);
pcm_data.geomCoefficients.nonperpendErr = new_beta(3);
pcm_data.geomCoefficients.misalignErr1 = new_beta(4);
pcm_data.geomCoefficients.misalignErr2 = new_beta(5);
pcm_data.geomCoefficients.tubeFlexure = new_beta(6);
pcm_data.geomCoefficients.DECaxisFlexure = new_beta(7);
if constexpr (MOUNT_TYPE == MccMountType::FORK_TYPE) {
pcm_data.geomCoefficients.forkFlexure = new_beta(8);
}
result.model_colon = {model.begin(), model.begin() + numberOfPoints()};
result.model_colat = {model.begin() + numberOfPoints(), model.end()};
result.colon_res.resize(numberOfPoints());
result.colat_res.resize(numberOfPoints());
result.colon_weight = {weights.begin(), weights.begin() + numberOfPoints()};
result.colat_weight = {weights.begin() + numberOfPoints(), weights.end()};
for (size_t i = 0; i < numberOfPoints(); ++i) {
result.colon_res[i] = _table.colon_res[i] - result.model_colon[i]; // = target - model
result.colat_res[i] = _table.colat_res[i] - result.model_colat[i]; // = target - model
// result.model_colon[i] += _table.hw_colon[i]; // == hw + fitted_pcmX
// result.model_colat[i] += _table.hw_colat[i]; // == hw + fitted_pcmY
}
return result;
}
};
} // namespace mcc::impl

707
include/mcc/mcc_pcm_fit.h Normal file
View File

@@ -0,0 +1,707 @@
#pragma once
/****************************************************************************************
* *
* MOUNT CONTROL COMPONENTS LIBRARY *
* *
* *
* "POINTING-CORRECTION-MODEL" FITTER *
* *
****************************************************************************************/
#include <eigen3/Eigen/Dense>
#include "mcc_concepts.h"
#include "mcc_coordinate.h"
#include "mcc_pcm.h"
namespace mcc::impl
{
enum class MccPCMFitterErrorCode : int {
ERROR_OK,
ERROR_INVALID_EPOCH,
ERROR_NOT_ENOUGH_DATA,
ERROR_INVALID_INDEX,
#ifdef USE_BSPLINE_PCM
ERROR_INVALID_KNOTS_NUMBER,
ERROR_BSPLINE_FIT
#endif
};
// error category
struct MccPCMFitterErrorCategory : std::error_category {
MccPCMFitterErrorCategory() = default;
const char* name() const noexcept
{
return "MCC-DEFAULT-PCM-CONSTRUCTOR-ERROR-CATEGORY";
}
std::string message(int ec) const
{
MccPCMFitterErrorCode err = static_cast<MccPCMFitterErrorCode>(ec);
switch (err) {
case MccPCMFitterErrorCode::ERROR_OK:
return "OK";
case MccPCMFitterErrorCode::ERROR_INVALID_EPOCH:
return "invalid epoch";
case MccPCMFitterErrorCode::ERROR_NOT_ENOUGH_DATA:
return "not enough data point";
case MccPCMFitterErrorCode::ERROR_INVALID_INDEX:
return "invalid index of data point";
#ifdef USE_BSPLINE_PCM
case MccPCMFitterErrorCode::ERROR_INVALID_KNOTS_NUMBER:
return "invalid number of B-spline knots";
case MccPCMFitterErrorCode::ERROR_BSPLINE_FIT:
return "B-spline fitting error";
#endif
default:
return "UNKNOWN";
}
}
static const MccPCMFitterErrorCategory& get()
{
static const MccPCMFitterErrorCategory constInst;
return constInst;
}
};
inline std::error_code make_error_code(MccPCMFitterErrorCode ec)
{
return std::error_code(static_cast<int>(ec), MccPCMFitterErrorCategory::get());
}
} // namespace mcc::impl
namespace std
{
template <>
class is_error_code_enum<mcc::impl::MccPCMFitterErrorCode> : public true_type
{
};
} // namespace std
namespace mcc::impl
{
template <MccMountType MOUNT_TYPE>
class MccPCMFitter
{
public:
using ref_coordpair_t = std::conditional_t<mcc_is_equatorial_mount<MOUNT_TYPE>,
MccSkyHADEC_OBS,
std::conditional_t<mcc_is_altaz_mount<MOUNT_TYPE>, MccSkyAZZD, void>>;
static_assert(!std::is_void_v<ref_coordpair_t>, "UNSUPPORTED MOUNT TYPE!");
struct compute_result_t {
MccDefaultPCMType pcm_type;
MccError error{}; // final model computation error
size_t final_iter{}; // number of final iteration
std::vector<double> model_colonRES{}, model_colatRES{}; // fitting model values: fit(target-hw)
std::vector<double> colon_err{}, colat_err{}; // fitting residuals: (target-hw) - fit
std::vector<double> colon_weight{}, colat_weight; // Tukey's weights
#ifdef USE_BSPLINE_PCM
std::array<int, 4> bspline_fit_err{
0, 0, 0, 0}; // bivariate B-spline fitting exit code (see FITPACK)
// 0 - pcmX(X,Y), 1 - pcmY(X,Y), 2 - revPcmX(COLON, COLAT), 3 - revPcmY(COLON, COLAT)
// quantities below are computed only fo pcm_type == MccDefaultPCMType::PCM_TYPE_BSPLINE
std::vector<double> inv_model_colonRES{}, inv_model_colatRES{}; // fitted inverse model values
std::vector<double> inv_colon_err{}, inv_colat_err{}; // encoder - model
#endif
};
struct compute_params_t {
size_t max_iter{100}; // max number of iterations for robust linear regression method
double c{4.685}; // Tukey's parameter for robust linear regression method
double tolerance{1.0E-6}; // tolerance value for bivariare B-spline fitting
};
struct pcm_table_elem_t {
ref_coordpair_t target{}; // celestial
MccGenXY hw{}; // hardware (encoder)
MccGenXY res{}; // residuals: celestial - hardware
};
typedef std::vector<pcm_table_elem_t> pcm_table_t;
size_t numberOfPoints() const
{
return _targetCOLON.size();
}
void deletePoints()
{
_epoch.clear();
_targetCOLON.clear();
_targetCOLAT.clear();
_colatRES.clear();
_colonRES.clear();
}
template <mcc_coord_pair_c TAG_T, mcc_coord_pair_c HW_T>
MccError addPoint(TAG_T const& target_coords, HW_T const& hw_counts)
requires(TAG_T::pairKind == ref_coordpair_t::pairKind && HW_T::pairKind == MccCoordPairKind::COORDS_KIND_XY)
{
if (hw_counts.epoch() != target_coords.epoch()) {
return MccPCMFitterErrorCode::ERROR_INVALID_EPOCH;
}
_epoch.emplace_back(hw_counts.epoch());
// to ensure the input celestial coordinates are normalized
typename ref_coordpair_t::x_t ang_x{(double)target_coords.x()};
typename ref_coordpair_t::y_t ang_y{(double)target_coords.y()};
_targetCOLON.emplace_back((double)ang_x);
_targetCOLAT.emplace_back((double)ang_y);
// normalize encoder coordinates to the range of corresponding celestial ones
ang_x = (double)hw_counts.x();
ang_y = (double)hw_counts.y();
_hwX.emplace_back((double)ang_x);
_hwY.emplace_back((double)ang_y);
_colonRES.emplace_back(_targetCOLON.back() - _hwX.back());
_colatRES.emplace_back(_targetCOLAT.back() - _hwY.back());
return MccPCMFitterErrorCode::ERROR_OK;
}
MccError addPoint(mcc_skypoint_c auto const& target_coords, mcc_coord_pair_c auto const& hw_counts)
requires(std::decay_t<decltype(hw_counts)>::pairKind == MccCoordPairKind::COORDS_KIND_XY)
{
ref_coordpair_t cp;
cp.setEpoch(hw_counts.epoch());
auto err = target_coords.to(cp);
if (err) {
return mcc_deduced_err(err, MccDefaultPCMErrorCode::ERROR_CCTE);
}
return addPoint(cp, hw_counts);
}
template <typename COLON_T, typename COLAT_T>
MccError addPoint(COLON_T const& colon, COLAT_T const& colat, mcc_coord_pair_c auto const& hw_counts)
requires(std::is_arithmetic_v<COLON_T> && std::is_arithmetic_v<COLAT_T> &&
(std::decay_t<decltype(hw_counts)>::pairKind == MccCoordPairKind::COORDS_KIND_XY))
{
ref_coordpair_t cp{typename ref_coordpair_t::x_t{colon}, typename ref_coordpair_t::y_t{colat},
hw_counts.epoch()};
return addPoint(cp, hw_counts);
}
template <typename COLON_T, typename COLAT_T, typename HW_X_T, typename HW_Y_T>
MccError addPoint(COLON_T const& colon,
COLAT_T const& colat,
HW_X_T const& x,
HW_Y_T const& y,
mcc_coord_epoch_c auto const& epoch)
requires(std::is_arithmetic_v<COLON_T> && std::is_arithmetic_v<COLAT_T> && std::is_arithmetic_v<HW_X_T> &&
std::is_arithmetic_v<HW_Y_T>)
{
ref_coordpair_t cp{typename ref_coordpair_t::x_t{colon}, typename ref_coordpair_t::y_t{colat}, epoch};
MccGenXY hw{x, y, epoch};
return addPoint(cp, hw);
}
template <mcc_coord_pair_c TAG_T, mcc_coord_pair_c HW_T>
MccError getPoint(size_t idx, std::tuple<TAG_T, HW_T>& point)
requires(std::same_as<typename TAG_T::x_t, typename ref_coordpair_t::x_t> &&
std::same_as<typename TAG_T::y_t, typename ref_coordpair_t::y_t> &&
HW_T::pairKind == MccCoordPairKind::COORDS_KIND_XY)
{
if (idx > numberOfPoints()) {
return MccPCMFitterErrorCode::ERROR_INVALID_INDEX;
} else {
std::get<0>(point).setX(_targetCOLON[idx]);
std::get<0>(point).setY(_targetCOLAT[idx]);
std::get<0>(point).setEpoch(_epoch[idx]);
std::get<1>(point).setX(_hwX[idx]);
std::get<1>(point).setY(_hwY[idx]);
std::get<1>(point).setEpoch(_epoch[idx]);
}
return MccPCMFitterErrorCode::ERROR_OK;
}
pcm_table_t getPCMTable() const
{
pcm_table_t tab;
if (numberOfPoints()) {
for (size_t i = 0; i < numberOfPoints(); ++i) {
tab.emplace_back(pcm_table_elem_t{.target{typename ref_coordpair_t::x_t{_targetCOLON[i]},
typename ref_coordpair_t::y_t{_targetCOLAT[i]}, _epoch[i]},
.hw{MccAngleX{_hwX[i]}, MccAngleY{_hwY[i]}, _epoch[i]},
.res{MccAngleX{_colonRES[i]}, MccAngleY{_colatRES[i]}, _epoch[i]}});
}
}
return tab;
}
//
// for B-splines interior knots along axes must be given in 'pcm_data'
// NOTE: the size of the interior knots array must be at least 2 as
// it are interpretated as border knots and final full knots set is:
// knots = [input_knots[0], input_knots[0], input_knots[0], input_knots[0], input_knots[1], input_knots[2],
// ..., input_knots[N-1], input_knots[N-1], input_knots[N-1], input_knots[N-1]], where N = input_knots.size()
//
// WARNING: the input knots for inverse B-spline are ignored so the direct and inverse B-spline coefficients are
// calculated on the same mesh!
template <typename PCM_DATA_T>
compute_result_t computeModel(PCM_DATA_T& pcm_data, compute_params_t const& comp_params = {})
requires(std::derived_from<typename PCM_DATA_T::pcm_t, MccDefaultPCM<MOUNT_TYPE>>)
{
compute_result_t result{.pcm_type = pcm_data.type, .error = MccPCMFitterErrorCode::ERROR_OK};
size_t min_data_size = 2; // 2 is for BSPLINE
if (pcm_data.type == MccDefaultPCMType::PCM_TYPE_GEOMETRY
#ifdef USE_BSPLINE_PCM
|| pcm_data.type == MccDefaultPCMType::PCM_TYPE_GEOMETRY_BSPLINE
#endif
) {
if constexpr (MOUNT_TYPE == MccMountType::FORK_TYPE) {
min_data_size = 9;
} else {
min_data_size = 8;
}
if (numberOfPoints() < min_data_size) {
result.error = MccPCMFitterErrorCode::ERROR_NOT_ENOUGH_DATA;
return result;
}
// robust linear regression with Tukey's loss function
result = robustLinearRegress(pcm_data, comp_params);
} else {
if (numberOfPoints() < min_data_size) {
result.error = MccPCMFitterErrorCode::ERROR_NOT_ENOUGH_DATA;
return result;
}
}
#ifdef USE_BSPLINE_PCM
if (pcm_data.type == MccDefaultPCMType::PCM_TYPE_BSPLINE) {
return bsplineFitting(pcm_data);
} else if (pcm_data.type == MccDefaultPCMType::PCM_TYPE_GEOMETRY_BSPLINE) {
// the fitting for geometrical coefficients is already done above so
// one must fit residuals by bivariate B-splines
std::vector<double> xres = _colonRES, yres = _colatRES;
for (size_t i = 0; i < numberOfPoints(); ++i) {
_colonRES[i] = _targetCOLON[i] - result.model_colonRES[i];
_colatRES[i] = _targetCOLAT[i] - result.model_colatRES[i];
}
auto r = bsplineFitting(pcm_data);
result.error = r.error;
result.bspline_fit_err = r.bspline_fit_err;
if (!r.error) {
for (size_t i = 0; i < numberOfPoints(); ++i) {
result.model_colonRES[i] += r.model_colonRES[i];
result.model_colatRES[i] += r.model_colatRES[i];
result.colon_err[i] = _targetCOLON[i] - result.model_colonRES[i];
result.colat_err[i] = _targetCOLAT[i] - result.model_colatRES[i];
}
}
// restore original residuals
_colonRES = xres;
_colatRES = yres;
}
#endif
return result;
}
protected:
// store coordinates in radians
std::vector<double> _targetCOLON{}, _targetCOLAT{}, _hwX, _hwY;
std::vector<double> _colonRES{}, _colatRES{}; // target - hw
std::vector<MccCelestialCoordEpoch> _epoch{};
// void computeModelResi(compute_result_t& result)
// {
// result.colon_err.resize(numberOfPoints());
// result.colat_err.resize(numberOfPoints());
// for (size_t i = 0; i < numberOfPoints(); ++i) {
// result.colon_err[i] = _colonRES[i] - result.model_colonRES[i]; // = target - model
// result.colat_err[i] = _colatRES[i] - result.model_colatRES[i]; // = target - model
// }
// #ifdef USE_BSPLINE_PCM
// if (result.pcm_type == MccDefaultPCMType::PCM_TYPE_BSPLINE) {
// result.inv_colon_err.resize(numberOfPoints());
// result.inv_colat_err.resize(numberOfPoints());
// for (size_t i = 0; i < numberOfPoints(); ++i) {
// result.inv_colon_err[i] = _colonRES[i] - result.inv_model_colonRES[i]; // = hw - model
// result.inv_colat_err[i] = _colatRES[i] - result.inv_model_colatRES[i]; // = hw - model
// }
// }
// #endif
// }
#ifdef USE_BSPLINE_PCM
compute_result_t bsplineFitting(MccDefaultPCM<MOUNT_TYPE>::pcm_data_t& pcm_data)
{
compute_result_t result{.pcm_type = pcm_data.type, .error = MccPCMFitterErrorCode::ERROR_OK};
// at least border knots must be given ([t_min, t_max])
if (pcm_data.bspline.knotsX.size() < 2 || pcm_data.bspline.knotsY.size() < 2) {
result.error = MccPCMFitterErrorCode::ERROR_INVALID_KNOTS_NUMBER;
return result;
}
double resi2x, resi2y; // sum of fitting residuals squares
// full knot vectors: [t_min, t_min, t_min, t_min, ..., t_1, t_2, ..., t_max, t_max, t_max, t_max]
std::vector<double> tx(pcm_data.bspline.knotsX.size() + 6), ty(pcm_data.bspline.knotsY.size() + 6);
std::vector<double>*theta_hw = &_hwY, *theta_tag = &_targetCOLAT, *phi_hw = &_hwX, *phi_tag = &_targetCOLON;
std::vector<double> theta, phi;
// full set of B-spline knots
tx[0] = tx[1] = tx[2] = pcm_data.bspline.knotsX[0];
tx[tx.size() - 1] = tx[tx.size() - 2] = tx[tx.size() - 3] =
pcm_data.bspline.knotsX[pcm_data.bspline.knotsX.size() - 1];
ty[0] = ty[1] = ty[2] = pcm_data.bspline.knotsY[0];
ty[ty.size() - 1] = ty[ty.size() - 2] = ty[ty.size() - 3] =
pcm_data.bspline.knotsY[pcm_data.bspline.knotsY.size() - 1];
for (size_t i = 0; i < pcm_data.bspline.knotsX.size(); ++i) {
tx[3 + i] = pcm_data.bspline.knotsX[i];
}
for (size_t i = 0; i < pcm_data.bspline.knotsY.size(); ++i) {
ty[3 + i] = pcm_data.bspline.knotsY[i];
}
/*
WARNING:
FITPACK B-spline on sphere: in the fitting routines the first angle argument is THETA - co-latitude
coordinate and the second one is PHI - co-longitude!!!
In the fitting routines the first angle argument THETA must be in the range of [0.0, PI]
(while celestial declination is in the range of [-PI/2, PI/2])!!!
The second angle argument is the PHI and its valid range is [0, 2*PI]
(while celestial hour angle is assumed to be in the range of [-PI, PI])
*/
if constexpr (std::same_as<ref_coordpair_t, MccSkyHADEC_OBS>) {
theta.resize(numberOfPoints());
phi.resize(numberOfPoints());
for (size_t i = 0; i < numberOfPoints(); ++i) {
theta[i] = _hwY[i] + MCC_HALF_PI;
phi[i] = _hwX[i] + std::numbers::pi;
}
theta_hw = &theta;
phi_hw = &phi;
for (size_t i = 0; i < tx.size(); ++i) {
tx[i] += std::numbers::pi;
}
for (size_t i = 0; i < ty.size(); ++i) {
ty[i] += MCC_HALF_PI;
}
}
size_t Ncoeffs = (tx.size() - 4) * (ty.size() - 4);
pcm_data.bspline.coeffsX.resize(Ncoeffs);
pcm_data.bspline.coeffsY.resize(Ncoeffs);
// direct (celestial = encoder + pcm)
result.bspline_fit_err[0] =
bsplines::fitpack_sphere_fit(*theta_hw, *phi_hw, _colonRES, 1.0, ty, tx, pcm_data.bspline.coeffsX, resi2x);
if (result.bspline_fit_err[0] > 0) {
result.error = MccPCMFitterErrorCode::ERROR_BSPLINE_FIT;
return result;
}
result.bspline_fit_err[1] =
bsplines::fitpack_sphere_fit(*theta_hw, *phi_hw, _colatRES, 1.0, ty, tx, pcm_data.bspline.coeffsY, resi2y);
if (result.bspline_fit_err[1] > 0) {
result.error = MccPCMFitterErrorCode::ERROR_BSPLINE_FIT;
return result;
}
bsplines::fitpack_eval_spl2d(ty, tx, pcm_data.bspline.coeffsX, *theta_hw, *phi_hw,
result.model_colonRES); // get fitted residuals!!!
bsplines::fitpack_eval_spl2d(ty, tx, pcm_data.bspline.coeffsY, *theta_hw, *phi_hw,
result.model_colatRES); // get fitted residuals!!!
result.colon_err.resize(numberOfPoints());
result.colat_err.resize(numberOfPoints());
for (size_t i = 0; i < numberOfPoints(); ++i) {
result.colon_err[i] = _colonRES[i] - result.model_colonRES[i]; // = target - model
result.colat_err[i] = _colatRES[i] - result.model_colatRES[i]; // = target - model
}
if (pcm_data.type == MccDefaultPCMType::PCM_TYPE_BSPLINE) {
// here both direct and inverse coefficients will be calculated
pcm_data.inverseBspline.coeffsX.resize(Ncoeffs);
pcm_data.inverseBspline.coeffsY.resize(Ncoeffs);
// inverse (encoder = celestial + pcm)
if constexpr (std::same_as<ref_coordpair_t, MccSkyHADEC_OBS>) {
theta_tag = &theta;
phi_tag = &phi;
}
std::vector<double> colon_res = _colonRES;
std::vector<double> colat_res = _colatRES;
for (size_t i = 0; i < colat_res.size(); ++i) {
colon_res[i] = -colon_res[i];
colat_res[i] = -colat_res[i];
if constexpr (std::same_as<ref_coordpair_t, MccSkyHADEC_OBS>) {
(*theta_tag)[i] = _targetCOLAT[i] + MCC_HALF_PI;
(*phi_tag)[i] = _targetCOLON[i] + std::numbers::pi;
}
}
result.bspline_fit_err[2] = bsplines::fitpack_sphere_fit(*theta_tag, *phi_tag, colon_res, 1.0, ty, tx,
pcm_data.bspline.inverseCoeffsX, resi2x);
if (result.bspline_fit_err[2] > 0) {
result.error = MccPCMFitterErrorCode::ERROR_BSPLINE_FIT;
return result;
}
result.bspline_fit_err[3] = bsplines::fitpack_sphere_fit(*theta_tag, *phi_tag, colat_res, 1.0, ty, tx,
pcm_data.bspline.inverseCoeffsY, resi2y);
if (result.bspline_fit_err[3] > 0) {
result.error = MccPCMFitterErrorCode::ERROR_BSPLINE_FIT;
return result;
}
bsplines::fitpack_eval_spl2d(ty, tx, pcm_data.bspline.inverseCoeffsX, *theta_tag, *phi_tag,
result.inv_model_colonRES); // get fitted residuals!!!
bsplines::fitpack_eval_spl2d(ty, tx, pcm_data.bspline.inverseCoeffsY, *theta_tag, *phi_tag,
result.inv_model_colatRES); // get fitted residuals!!!
result.inv_colon_err.resize(numberOfPoints());
result.inv_colat_err.resize(numberOfPoints());
for (size_t i = 0; i < numberOfPoints(); ++i) {
result.inv_colon_err[i] = colon_res[i] - result.inv_model_colonRES[i]; // = hw - model
result.inv_colat_err[i] = colat_res[i] - result.inv_model_colatRES[i]; // = hw - model
}
}
return result;
}
#endif
compute_result_t robustLinearRegress(MccDefaultPCM<MOUNT_TYPE>::pcm_data_t& pcm_data,
compute_params_t const& comp_params)
{
auto tukey_weight = [](Eigen::VectorXd const& resi, double tukey_c, Eigen::VectorXd& tukey_weight) {
Eigen::ArrayXd u = (resi / tukey_c).cwiseAbs();
auto mask = (u < 1.0);
Eigen::VectorXd r = mask.select(1.0 - u * u, 0.0);
tukey_weight = r.array() * r.array();
};
auto gastwirth_est = [](Eigen::VectorXd const& r) {
// auto gastwirth_est = [](Eigen::VectorXd const& resi) {
auto resi = r;
std::nth_element(resi.begin(), resi.begin() + resi.size() / 2, resi.end());
double md = resi(resi.size() / 2);
resi = resi.array() - md;
// Gastwirth’s estimation: 0.3*Q(1/3) + 0.4*Q(1/2) + 0.3*Q(2/3)
Eigen::ArrayXd arr = resi.cwiseAbs();
std::nth_element(arr.begin(), arr.begin() + 2 * arr.size() / 3, arr.end());
// add 1.0E-8 to avoid 0.0
return (0.3 * arr(arr.size() / 3) + 0.4 * arr(arr.size() / 2) + 0.3 * arr(2 * arr.size() / 3)) / 0.6745 +
1.0E-8;
// std::nth_element(arr.begin(), arr.begin() + arr.size() / 2, arr.end());
// return arr(arr.size() / 2) / 0.6745 + 1.0E-8;
};
compute_result_t result{.pcm_type = pcm_data.type, .error = MccPCMFitterErrorCode::ERROR_OK};
const size_t n_coeffs = MOUNT_TYPE == MccMountType::FORK_TYPE ? 9 : 8;
Eigen::MatrixXd X(2 * numberOfPoints(), n_coeffs);
Eigen::VectorXd y(2 * numberOfPoints()), beta = Eigen::VectorXd::Zero(n_coeffs), new_beta(n_coeffs);
Eigen::VectorXd model;
Eigen::RowVectorXd row(n_coeffs);
double tgY, sinY, cosY, rcosY, cosX, sinX, cosPhi = std::cos(pcm_data.siteLatitude),
sinPhi = std::sin(pcm_data.siteLatitude);
// system matrix and right-hand vector
for (size_t i = 0; i < numberOfPoints(); ++i) {
cosY = std::cos(_targetCOLAT[i]);
sinY = std::sin(_targetCOLAT[i]);
rcosY = 1.0 / cosY;
tgY = std::tan(_targetCOLAT[i]);
cosX = std::cos(_targetCOLON[i]);
sinX = std::sin(_targetCOLON[i]);
// [X0, Y0, collim, nonperp, misal1, misal2, tubefl, DECaxfl, forkfl] or
// [X0, Y0, collim, nonperp, misal1, misal2, tubefl, DECaxfl]
if constexpr (MOUNT_TYPE == MccMountType::FORK_TYPE) {
if (utils::isEqual(cosY, 0.0)) {
row << 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0;
} else {
row << 1.0, 0.0, rcosY, tgY, -cosX * tgY, sinX * tgY, cosPhi * sinX * rcosY,
-(cosPhi * cosX + sinPhi * tgY), 0.0;
}
} else {
if (utils::isEqual(cosY, 0.0)) {
row << 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0;
} else {
row << 1.0, 0.0, rcosY, tgY, -cosX * tgY, sinX * tgY, cosPhi * sinX * rcosY,
-(cosPhi * cosX + sinPhi * tgY);
}
}
X.row(i) = row;
if constexpr (MOUNT_TYPE == MccMountType::FORK_TYPE) {
if (utils::isEqual(cosX, 0.0)) {
row << 0.0, 1.0, 0.0, 0.0, sinX, cosX, cosPhi * cosX * sinY - sinPhi * cosY, 0.0, 0.0;
} else {
row << 0.0, 1.0, 0.0, 0.0, sinX, cosX, cosPhi * cosX * sinY - sinPhi * cosY, 0.0, 1.0 / cosX;
}
} else {
row << 0.0, 1.0, 0.0, 0.0, sinX, cosX, cosPhi * cosX * sinY - sinPhi * cosY, 0.0;
}
X.row(i + numberOfPoints()) = row;
y(i) = _colonRES[i];
y(i + numberOfPoints()) = _colatRES[i];
}
Eigen::VectorXd resi = y;
Eigen::VectorXd weights(2 * numberOfPoints());
double scale;
Eigen::MatrixXd WX;
Eigen::VectorXd Wy;
// initial parameters estimation (least squares)
beta = X.bdcSvd(Eigen::ComputeThinU | Eigen::ComputeThinV).solve(y);
model = X * beta;
resi = y - model;
// resi = y;
for (result.final_iter = 1; result.final_iter <= comp_params.max_iter; ++result.final_iter) {
scale = gastwirth_est(resi);
tukey_weight(resi / scale, comp_params.c, weights);
// Eigen::MatrixXd XtW = X.transpose() * weights.asDiagonal();
// Eigen::MatrixXd XtWX = XtW * X;
// Eigen::VectorXd XtWy = XtW * y;
// new_beta = XtWX.ldlt().solve(XtWy);
WX = weights.asDiagonal() * X;
Wy = weights.asDiagonal() * y;
new_beta = WX.bdcSvd(Eigen::ComputeThinU | Eigen::ComputeThinV).solve(Wy);
if ((new_beta - beta).norm() < comp_params.tolerance) {
break;
}
beta = new_beta;
model = X * beta;
resi = y - model;
}
pcm_data.geomCoefficients.zeroPointX = new_beta(0);
pcm_data.geomCoefficients.zeroPointY = new_beta(1);
pcm_data.geomCoefficients.collimationErr = new_beta(2);
pcm_data.geomCoefficients.nonperpendErr = new_beta(3);
pcm_data.geomCoefficients.misalignErr1 = new_beta(4);
pcm_data.geomCoefficients.misalignErr2 = new_beta(5);
pcm_data.geomCoefficients.tubeFlexure = new_beta(6);
pcm_data.geomCoefficients.DECaxisFlexure = new_beta(7);
if constexpr (MOUNT_TYPE == MccMountType::FORK_TYPE) {
pcm_data.geomCoefficients.forkFlexure = new_beta(8);
}
result.model_colonRES = {model.begin(), model.begin() + numberOfPoints()};
result.model_colatRES = {model.begin() + numberOfPoints(), model.end()};
result.colon_err.resize(numberOfPoints());
result.colat_err.resize(numberOfPoints());
result.colon_weight = {weights.begin(), weights.begin() + numberOfPoints()};
result.colat_weight = {weights.begin() + numberOfPoints(), weights.end()};
result.colon_err.resize(numberOfPoints());
result.colat_err.resize(numberOfPoints());
for (size_t i = 0; i < numberOfPoints(); ++i) {
result.colon_err[i] = _colonRES[i] - result.model_colonRES[i]; // = target - model
result.colat_err[i] = _colatRES[i] - result.model_colatRES[i]; // = target - model
}
return result;
}
};
} // namespace mcc::impl

View File

@@ -13,12 +13,14 @@
#include "mcc_concepts.h"
#include "mcc_constants.h"
#include "mcc_coordinate.h"
#include "mcc_deserializer.h"
#include "mcc_serializer.h"
namespace mcc::impl
{
enum class MccPZoneErrorCode : int { ERROR_OK, ERROR_NULLPTR, ERROR_COORD_TRANSFROM, ERROR_PCM_COMP };
enum class MccPZoneErrorCode : int { ERROR_OK, ERROR_NULLPTR, ERROR_COORD_TRANSFROM, ERROR_NO_PCM, ERROR_PCM_COMP };
} // namespace mcc::impl
@@ -56,6 +58,8 @@ struct MccPZoneCategory : public std::error_category {
return "input argument os nullptr";
case MccPZoneErrorCode::ERROR_COORD_TRANSFROM:
return "coordinate transformation error";
case MccPZoneErrorCode::ERROR_NO_PCM:
return "PCM was not set";
case MccPZoneErrorCode::ERROR_PCM_COMP:
return "PCM computation error";
default:
@@ -89,6 +93,7 @@ public:
MccAltLimitPZ(mcc_angle_c auto const& alt_limit, mcc_angle_c auto const& latitude)
: _altLimit(MccAngle(alt_limit).normalize<MccAngle::NORM_KIND_90_90>()),
_latitude(MccAngle::normalizeAngle<MccAngle::NORM_KIND_90_90>(latitude)),
_cosALim(cos(_altLimit)),
_sinAlim(sin(_altLimit)),
_cosLat(cos(latitude)),
@@ -106,6 +111,32 @@ public:
: KIND == MccAltLimitKind::MAX_ALT_LIMIT ? "MAXALT-ZONE"
: "ALTLIMIT-UNKNOWN";
MccAltLimitPZ& operator=(MccAltLimitPZ&&) = default;
MccAltLimitPZ& operator=(const MccAltLimitPZ&) = default;
template <mcc_angle_c T>
T altLimit() const
requires(!std::derived_from<T, MccAngle>)
{
return _altLimit;
}
MccAngle altLimit() const
{
return _altLimit;
}
template <mcc_angle_c T>
T latitude() const
requires(!std::derived_from<T, MccAngle>)
{
return _latitude;
}
MccAngle latitude() const
{
return _latitude;
}
error_t inPZone(mcc_skypoint_c auto const& coords, bool* result)
{
@@ -230,7 +261,7 @@ public:
protected:
double _altLimit, _cosALim, _sinAlim;
double _cosLat, _sinLat, _absLat, _latLim;
double _latitude, _cosLat, _sinLat, _absLat, _latLim;
bool doesObjectReachZone(const double& dec_app)
{
@@ -321,15 +352,88 @@ protected:
}
};
static_assert(std::is_copy_assignable_v<MccAltLimitPZ<MccAltLimitKind::MIN_ALT_LIMIT>>);
/*
to be serialized in format:
ALT-LIMIT<seq-delim>LATITUDE
*/
template <MccAltLimitKind KIND>
struct MccSerializer<MccAltLimitPZ<KIND>> : MccSerializerBase {
constexpr static std::string_view serializerName{"MCC-ALTITUDE-PZONE-SERIALIZER"};
template <mcc_serialization_params_c ParamsT = mcc_serialization_params_t>
error_t operator()(traits::mcc_output_char_range auto& output,
MccAltLimitPZ<KIND> const& value,
ParamsT const& params = mcc_serialization_params_t{})
{
MccSerializer<MccAngle> aser;
auto err = aser(output, value.altLimit(), params);
if (err) {
return mcc_deduced_err(err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
}
std::format_to(std::back_inserter(output), "{}", params.seq_delim);
err = aser(output, value.latitude(), params);
if (err) {
return mcc_deduced_err(err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
}
return MccSerializerErrorCode::ERROR_OK;
}
};
template <MccAltLimitKind KIND>
struct MccDeserializer<MccAltLimitPZ<KIND>> : MccDeserializerBase {
static constexpr std::string_view deserializerName{"MCC-ALTITUDE-PZONE-DESERIALIZER"};
template <mcc_serialization_params_c ParamsT = mcc_serialization_params_t>
error_t operator()(traits::mcc_input_char_range auto const& input,
MccAltLimitPZ<KIND>& value,
ParamsT const& params = mcc_serialization_params_t{})
{
std::vector<std::string_view> s;
MccDeserializer<MccAngle> ades;
auto seq = std::views::split(input, params.seq_delim);
if (std::ranges::distance(seq.begin(), seq.end()) > 1) {
for (auto const& seq_el : seq) {
s.push_back(utils::trimSpaces(seq_el, utils::TrimType::TRIM_BOTH));
}
MccAngle alt, lat;
auto err = ades(s[0], alt, params);
if (err) {
return MccDeserializerErrorCode::ERROR_UNDERLYING_DESERIALIZER;
}
err = ades(s[1], lat, params);
if (err) {
return MccDeserializerErrorCode::ERROR_UNDERLYING_DESERIALIZER;
}
value = MccAltLimitPZ<KIND>(alt, lat);
} else {
return MccDeserializerErrorCode::ERROR_INVALID_SERIALIZED_VALUE;
}
return MccDeserializerErrorCode::ERROR_OK;
}
};
/* co-longitude axis (HA or AZ) limit switch prohibited zone */
/* co-longitude axis (HA or AZ) and co-latitude (DEC, ZD) limit switch prohibited zone */
template <MccCoordKind AXIS_KIND>
class MccAxisLimitSwitchPZ : public mcc_pzone_interface_t<std::error_code>
{
public:
static_assert(AXIS_KIND == MccCoordKind::COORDS_KIND_AZ || AXIS_KIND == MccCoordKind::COORDS_KIND_HA_OBS,
static_assert(AXIS_KIND == MccCoordKind::COORDS_KIND_AZ || AXIS_KIND == MccCoordKind::COORDS_KIND_HA_OBS ||
AXIS_KIND == MccCoordKind::COORDS_KIND_ZD || AXIS_KIND == MccCoordKind::COORDS_KIND_DEC_OBS,
"UNSUPPORTED AXIS TYPE!");
typedef std::error_code error_t;
@@ -339,13 +443,17 @@ public:
static constexpr MccProhibitedZonePolicy pzPolicy = MccProhibitedZonePolicy::PZ_POLICY_FLIP;
//
// min_limit_val and max_limit_val are hardware encoder angles in radians!
// min_limit_val and max_limit_val are hardware encoder angles!
// pcm is nullptr or pointer to mcc_pcm_c
//
MccAxisLimitSwitchPZ(mcc_angle_c auto const& min_limit_val,
mcc_angle_c auto const& max_limit_val,
mcc_pcm_c auto* pcm)
template <typename PCM_T>
MccAxisLimitSwitchPZ(mcc_angle_c auto const& min_limit_val, mcc_angle_c auto const& max_limit_val, PCM_T pcm)
requires(std::is_null_pointer_v<PCM_T> || mcc_pcm_c<std::remove_pointer_t<PCM_T>>)
: _minLimit(min_limit_val), _maxLimit(max_limit_val)
{
if constexpr (std::is_null_pointer_v<PCM_T>) {
_correctForPCM = [](MccSkyPoint const&, MccGenXY*) -> error_t { return MccPZoneErrorCode::ERROR_NO_PCM; };
} else {
_correctForPCM = [pcm](MccSkyPoint const& skypt, MccGenXY* hw_coords) {
struct pcm_res_t {
double pcmX, pcmY;
@@ -358,14 +466,66 @@ public:
return mcc_deduced_err(err, MccPZoneErrorCode::ERROR_PCM_COMP);
};
}
}
static constexpr std::string_view pzoneName = axisKind == MccCoordKind::COORDS_KIND_AZ ? "AZ_AXIS-LIMITSWITCH_ZONE"
: axisKind == MccCoordKind::COORDS_KIND_HA_OBS
? "HA_AXIS-LIMITSWITCH_ZONE"
static constexpr std::string_view pzoneName =
axisKind == MccCoordKind::COORDS_KIND_AZ ? "AZ-AXIS-LIMITSWITCH-ZONE"
: axisKind == MccCoordKind::COORDS_KIND_HA_OBS ? "HA-AXIS-LIMITSWITCH-ZONE"
: axisKind == MccCoordKind::COORDS_KIND_ZD ? "ZD-AXIS-LIMITSWITCH-ZONE"
: axisKind == MccCoordKind::COORDS_KIND_DEC_OBS ? "DEC-AXIS-LIMITSWITCH-ZONE"
: "UKNOWN";
MccAxisLimitSwitchPZ(const MccAxisLimitSwitchPZ&) = default;
MccAxisLimitSwitchPZ(MccAxisLimitSwitchPZ&&) = default;
MccAxisLimitSwitchPZ& operator=(const MccAxisLimitSwitchPZ&) = default;
MccAxisLimitSwitchPZ& operator=(MccAxisLimitSwitchPZ&&) = default;
template <mcc_angle_c T>
T minLimit() const
requires(!std::derived_from<T, MccAngle>)
{
return _minLimit;
}
MccAngle minLimit() const
{
return _minLimit;
}
template <mcc_angle_c T>
T maxLimit() const
requires(!std::derived_from<T, MccAngle>)
{
return _maxLimit;
}
MccAngle maxLimit() const
{
return _maxLimit;
}
template <typename PCM_T>
void setPCM(PCM_T pcm)
requires(std::is_null_pointer_v<PCM_T> || mcc_pcm_c<std::remove_pointer_t<PCM_T>>)
{
if constexpr (std::is_null_pointer_v<PCM_T>) {
_correctForPCM = [](MccSkyPoint const&, MccGenXY*) -> error_t { return MccPZoneErrorCode::ERROR_NO_PCM; };
} else {
_correctForPCM = [pcm](MccSkyPoint const& skypt, MccGenXY* hw_coords) {
struct pcm_res_t {
double pcmX, pcmY;
};
pcm_res_t res;
auto err = pcm->computeInversePCM(skypt, &res, hw_coords);
return mcc_deduced_err(err, MccPZoneErrorCode::ERROR_PCM_COMP);
};
}
}
error_t inPZone(mcc_skypoint_c auto const& coords, bool* result)
{
@@ -430,15 +590,36 @@ protected:
coords.to(xy);
}
if constexpr (AXIS_KIND == MccCoordKind::COORDS_KIND_HA_OBS) {
double x = xy.x();
if constexpr (AXIS_KIND == MccCoordKind::COORDS_KIND_HA_OBS) {
if (from_time) { // timeFromPZone
time_ang = (_minLimit - x) / MCC_SIDERAL_TO_UT1_RATIO; // to UT1 scale
} else { // timeToPZone
time_ang = (_maxLimit - x) / MCC_SIDERAL_TO_UT1_RATIO; // to UT1 scale
}
} else if constexpr (AXIS_KIND == MccCoordKind::COORDS_KIND_DEC_OBS) {
double y = xy.y();
// TODO: !!!!!!!!!!!!!!!!!!!!!!!!
// assume here sideral speed moving! so, observed DEC is near constant
if (from_time) { // timeFromPZone
if (y < _minLimit || y > _maxLimit) {
time_ang = std::numeric_limits<double>::max();
} else {
time_ang = 0;
}
} else { // timeToPZone
if (y < _minLimit || y > _maxLimit) { // already in the zone
time_ang = 0;
} else {
time_ang = std::numeric_limits<double>::max();
}
}
} else if constexpr (AXIS_KIND == MccCoordKind::COORDS_KIND_AZ) {
static_assert(false, "NOT IMPLEMENTED YET!!!");
} else {
static_assert(false, "NOT IMPLEMENTED YET!!!");
}
std::chrono::nanoseconds ns{
@@ -451,5 +632,81 @@ protected:
}
};
static_assert(std::is_copy_assignable_v<MccAxisLimitSwitchPZ<MccCoordKind::COORDS_KIND_HA_OBS>>);
static_assert(std::is_copy_assignable_v<MccAxisLimitSwitchPZ<MccCoordKind::COORDS_KIND_DEC_OBS>>);
/*
to be serialized in format:
MIN_LIMIT<seq-delim>MAX_LIMIT
*/
template <MccCoordKind AXIS_KIND>
struct MccSerializer<MccAxisLimitSwitchPZ<AXIS_KIND>> : MccSerializerBase {
constexpr static std::string_view serializerName{"MCC-AXIS-LIMIT-SWITCH-SERIALIZER"};
template <mcc_serialization_params_c ParamsT = mcc_serialization_params_t>
error_t operator()(traits::mcc_output_char_range auto& output,
MccAxisLimitSwitchPZ<AXIS_KIND> const& value,
ParamsT const& params = mcc_serialization_params_t{})
{
MccSerializer<MccAngle> aser;
auto err = aser(output, value.minLimit(), params);
if (err) {
return mcc_deduced_err(err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
}
std::format_to(std::back_inserter(output), "{}", params.seq_delim);
err = aser(output, value.maxLimit(), params);
if (err) {
return mcc_deduced_err(err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
}
return MccSerializerErrorCode::ERROR_OK;
}
};
template <MccCoordKind AXIS_KIND>
struct MccDeserializer<MccAxisLimitSwitchPZ<AXIS_KIND>> : MccDeserializerBase {
static constexpr std::string_view deserializerName{"MCC-AXIS-LIMIT-SWITCH-DESERIALIZER"};
template <mcc_serialization_params_c ParamsT = mcc_serialization_params_t>
error_t operator()(traits::mcc_input_char_range auto const& input,
MccAxisLimitSwitchPZ<AXIS_KIND>& value,
ParamsT const& params = mcc_serialization_params_t{})
{
std::vector<std::string_view> s;
MccDeserializer<MccAngle> ades;
auto seq = std::views::split(input, params.seq_delim);
// if (std::ranges::size(seq) < 2) {
if (std::ranges::distance(seq.begin(), seq.end()) > 1) {
for (auto const& seq_el : seq) {
s.push_back(utils::trimSpaces(seq_el, utils::TrimType::TRIM_BOTH));
}
MccAngle minLim, maxLim;
auto err = ades(s[0], minLim, params);
if (err) {
return MccDeserializerErrorCode::ERROR_UNDERLYING_DESERIALIZER;
}
err = ades(s[1], maxLim, params);
if (err) {
return MccDeserializerErrorCode::ERROR_UNDERLYING_DESERIALIZER;
}
// WARNING: the class below is created without the PCM-class pointer!!!
value = MccAxisLimitSwitchPZ<AXIS_KIND>(minLim, maxLim, nullptr);
} else {
return MccDeserializerErrorCode::ERROR_INVALID_SERIALIZED_VALUE;
}
return MccDeserializerErrorCode::ERROR_OK;
}
};
} // namespace mcc::impl

View File

@@ -115,8 +115,10 @@ protected:
PAIRKIND == MccCoordPairKind::COORDS_KIND_XY ||
PAIRKIND == MccCoordPairKind::COORDS_KIND_GENERIC) { // azimuth is in degrees
pars.angle_format = MccSerializedAngleFormat::MCC_SERIALIZED_FORMAT_SXGM_DEGS;
pars.norm_sxgm = true;
} else { // RA or HA
pars.angle_format = MccSerializedAngleFormat::MCC_SERIALIZED_FORMAT_SXGM_HOURS;
pars.norm_sxgm = true;
}
} else {
// !!!!!!!!!!!!!!!!!!
@@ -348,10 +350,10 @@ struct MccSerializer<VT> : MccSerializerBase {
VT const& value,
ParamsT const& params = mcc_serialization_params_t{})
{
// format: X<elem-delim>Y<elem-delim>PAIRKIND<elem-delim>EPOCH
auto pars = params;
// pars.norm_sxgm = true;
// pars.coordpair_format = MccSerializedCoordPairFormat::MCC_SERIALIZED_FORMAT_SXGM_HOURDEG;
// X-coordinate
MccSerializerBase::angleFormatFromCoordPairType<VT::pairKind, MccSerializerBase::CO_LON>(pars);
@@ -363,7 +365,7 @@ struct MccSerializer<VT> : MccSerializerBase {
MccSerializerBase::addElemDelimiter(output, params);
pars.norm_sxgm = false; // do not normalize co-latitude angle
// pars.norm_sxgm = false; // do not normalize co-latitude angle
// Y-coordinate
MccSerializerBase::angleFormatFromCoordPairType<VT::pairKind, MccSerializerBase::CO_LAT>(pars);
@@ -375,6 +377,14 @@ struct MccSerializer<VT> : MccSerializerBase {
MccSerializerBase::addElemDelimiter(output, params);
// pair kind
auto pk_err = MccSerializer<std::string_view>{}(output, MccCoordPairKindToStr(VT::pairKind), params);
if (pk_err) {
return mcc_deduced_err(pk_err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
}
MccSerializerBase::addElemDelimiter(output, params);
// epoch
auto ep = value.epoch();
auto ep_err = MccSerializer<decltype(ep)>{}(output, ep, params);
@@ -383,14 +393,6 @@ struct MccSerializer<VT> : MccSerializerBase {
}
MccSerializerBase::addElemDelimiter(output, params);
// pair kind
auto pk_err = MccSerializer<std::string_view>{}(output, MccCoordPairKindToStr(VT::pairKind), params);
if (pk_err) {
return mcc_deduced_err(pk_err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
}
return MccSerializerErrorCode::ERROR_OK;
}
};
@@ -406,7 +408,7 @@ struct MccSerializer<VT> : MccSerializerBase {
ParamsT const& params = mcc_serialization_params_t{})
{
auto serialize_cpair = [&]<typename T>(T& cp) -> error_t {
auto ccte_err = value.to(cp);
auto ccte_err = value.toAtSameEpoch(cp);
if (ccte_err) {
return mcc_deduced_err(ccte_err, MccSerializerErrorCode::ERROR_COORD_TRANSFORM);
}
@@ -501,7 +503,7 @@ struct MccSerializer<VT> : MccSerializerBase {
// quantities in degree representation
MccSerializerBase::angleFormatFromCoordPairType<MccCoordPairKind::COORDS_KIND_RADEC_ICRS,
MccSerializerBase::CO_LON>(pars_d);
MccSerializerBase::CO_LAT>(pars_d);
MccSerializer<MccAngle> ang_sr;
@@ -518,7 +520,7 @@ struct MccSerializer<VT> : MccSerializerBase {
MccSerializerBase::addElemDelimiter(output, pars_h);
err = ang_sr(output, rd_obs.y(), pars_h);
err = ang_sr(output, rd_obs.y(), pars_d);
if (err) {
return mcc_deduced_err(err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
}

View File

@@ -113,17 +113,17 @@ public:
struct telemetry_data_t {
MccSkyPoint targetPos{};
MccSkyPoint targetPos{}; // celestial coordinates
MccGenXY targetXY{};
MccGenXY targetXY{}; // encoder coordinates
struct {
double pcmX{}, pcmY{};
} pcmReverseCorrection{};
MccSkyPoint mountPos{};
MccSkyPoint mountPos{}; // celestial coordinates
typename HARDWARE_T::hardware_state_t hwState{};
typename HARDWARE_T::hardware_state_t hwState{}; // here encoder coordinates
struct {
double pcmX{}, pcmY{};
@@ -216,8 +216,8 @@ public:
mcc_deduced_err(hw_err, MccTelemetryErrorCode::ERROR_HARDWARE_GETSTATE);
} else {
// compute PCM corrections and observed (corrected for PCM) mount coordinates
auto pcm_err = pcm_ptr->computePCM(_tdataPtr->hwState.XY, &_tdataPtr->pcmCorrection,
&_tdataPtr->mountPos);
auto pcm_err = pcm_ptr->computePCM(_tdataPtr->hwState.XY, &(_tdataPtr->pcmCorrection),
&(_tdataPtr->mountPos));
if (!pcm_err) {
// set target coordinates
@@ -246,8 +246,9 @@ public:
// _tdataPtr->targetPos = _enteredTargetPos;
using pcm_t = std::remove_pointer_t<decltype(pcm_ptr)>;
std::conditional_t<mcc_is_equatorial_mount<pcm_t::mountType>, MccSkyHADEC_OBS,
std::conditional_t<mcc_is_altaz_mount<pcm_t::mountType>,
std::conditional_t<mcc_is_equatorial_mount<pcm_t::pcmMountType>,
MccSkyHADEC_OBS,
std::conditional_t<mcc_is_altaz_mount<pcm_t::pcmMountType>,
MccSkyAZZD, std::nullptr_t>>
cp;
@@ -289,6 +290,85 @@ public:
}
},
_updatingStopSource.get_token(), hardware, pcm);
_updateFunc = [hw=hardware, pcm_ptr=pcm, this](telemetry_data_t* tdata) mutable -> error_t {
_tdataPtr = tdata;
if (_tdataPtr != nullptr && hw && pcm_ptr) {
_lastUpdateError = MccTelemetryErrorCode::ERROR_OK;
// get hardware state (coordinates, speeds and so on)
auto hw_err = hw->hardwareGetState(&_tdataPtr->hwState);
if (hw_err) {
_lastUpdateError = mcc_deduced_err(hw_err, MccTelemetryErrorCode::ERROR_HARDWARE_GETSTATE);
} else {
// compute PCM corrections and observed (corrected for PCM) mount coordinates
auto pcm_err =
pcm_ptr->computePCM(_tdataPtr->hwState.XY, &(_tdataPtr->pcmCorrection), &(_tdataPtr->mountPos));
if (!pcm_err) {
// set target coordinates
if (_enteredTargetPos.pairKind() == MccCoordPairKind::COORDS_KIND_XY) {
// hardware coordinates
MccGenXY xy;
auto ccte_err = _enteredTargetPos.toAtSameEpoch(xy);
if (!ccte_err) {
decltype(_tdataPtr->pcmCorrection) pcm_corr;
pcm_err = pcm_ptr->computePCM(xy, &pcm_corr, &_tdataPtr->targetPos);
if (pcm_err) {
_lastUpdateError = mcc_deduced_err(pcm_err, MccTelemetryErrorCode::ERROR_PCM_COMP);
}
_tdataPtr->pcmReverseCorrection.pcmX = -pcm_corr.pcmX;
_tdataPtr->pcmReverseCorrection.pcmY = -pcm_corr.pcmY;
} else {
_lastUpdateError =
mcc_deduced_err(ccte_err, MccTelemetryErrorCode::ERROR_COORD_TRANSFORM);
}
} else { // observed, apparent or ICRS
// _tdataPtr->targetPos = _enteredTargetPos;
using pcm_t = std::remove_pointer_t<decltype(pcm_ptr)>;
std::conditional_t<
mcc_is_equatorial_mount<pcm_t::pcmMountType>, MccSkyHADEC_OBS,
std::conditional_t<mcc_is_altaz_mount<pcm_t::pcmMountType>, MccSkyAZZD, std::nullptr_t>>
cp;
static_assert(!std::is_null_pointer_v<decltype(cp)>, "UNKNOW MOUNT TYPE!");
// calculate target celestial coordinates (of the same type as .mountPos) at the
// epoch of the current mount position
cp.setEpoch(_tdataPtr->mountPos.epoch());
auto ccte_err = _enteredTargetPos.to(cp);
if (ccte_err) {
_lastUpdateError =
mcc_deduced_err(ccte_err, MccTelemetryErrorCode::ERROR_COORD_TRANSFORM);
} else {
_tdataPtr->targetPos.from(cp);
// calculate reverse PCM corrections for the current target position and
// its encoder XY
auto pcm_err = pcm_ptr->computeInversePCM(
_tdataPtr->targetPos, &_tdataPtr->pcmReverseCorrection, &_tdataPtr->targetXY);
if (pcm_err) {
_lastUpdateError = mcc_deduced_err(pcm_err, MccTelemetryErrorCode::ERROR_PCM_COMP);
}
}
}
} else {
_lastUpdateError = mcc_deduced_err(pcm_err, MccTelemetryErrorCode::ERROR_PCM_COMP);
}
}
} else {
_lastUpdateError = MccTelemetryErrorCode::ERROR_NULLPTR;
}
return _lastUpdateError;
};
}
MccTelemetry(MccTelemetry&&) = default;
@@ -317,20 +397,32 @@ public:
error_t setPointingTarget(mcc_skypoint_c auto const& sp)
{
std::lock_guard lock{*_updateMutex};
_enteredTargetPos = sp;
return MccTelemetryErrorCode::ERROR_OK;
}
error_t getPointingTarget(mcc_skypoint_c auto* sp)
auto getPointingTarget() const
{
sp = _enteredTargetPos;
std::lock_guard lock{*_updateMutex};
return MccTelemetryErrorCode::ERROR_OK;
return _enteredTargetPos;
}
// error_t getPointingTarget(mcc_skypoint_c auto* sp)
// {
// if (sp) {
// *sp = _enteredTargetPos;
// }
// return MccTelemetryErrorCode::ERROR_OK;
// }
//
// blocks the current thread until telemetry data is received.
// the maximum blocking time is equal to the set timeout (see setTelemetryDataTimeout method)
@@ -341,6 +433,11 @@ public:
_lastUpdateError = MccTelemetryErrorCode::ERROR_OK;
// 12.10.2026: try to catch dead-lock
// use here mutex-free non-timedout implementation
return _updateFunc(tdata);
// tdata = _tdataPtr;
_tdataPtr = tdata;
// trigger updating
@@ -393,7 +490,7 @@ private:
// HARDWARE_T* _hardware{nullptr};
MccSkyPoint _enteredTargetPos{};
// std::function<error_t(telemetry_data_t*)> _updateFunc{};
std::function<error_t(telemetry_data_t*)> _updateFunc{};
telemetry_data_t* _tdataPtr;
std::unique_ptr<std::atomic_flag> _dataUpdatingRequested{new std::atomic_flag{}};

View File

@@ -56,7 +56,13 @@ template <typename R>
concept mcc_range_of_output_char_range =
std::ranges::range<R> && traits::mcc_output_char_range<std::ranges::range_value_t<R>>;
// std::array, std::span(v_t, N), std::tuple
template <typename R>
concept mcc_fixed_size_range = std::ranges::range<R> && requires { std::tuple_size<std::remove_cvref_t<R>>::value; };
// non-resizable ranges
template <typename R>
concept mcc_non_resizable_range = std::ranges::range<R> && !requires(R r, std::size_t n) { r.resize(n); };
// https://stackoverflow.com/questions/72430369/how-to-check-that-a-type-is-formattable-using-type-traits-concepts)
template <typename T>

View File

@@ -16,7 +16,8 @@ namespace mcc::utils
{
static const std::regex decimalNumberRx{" *[-+]?([0-9]*[.])?[0-9]+([eE][-+]?[0-9]+)? *"};
static const std::regex sexagesimalReprRx{" *[-+]?[0-9]{1,2}:[0-9]{1,2}:([0-9]{0,2}[.])?[0-9]+ *"};
// static const std::regex sexagesimalReprRx{" *[-+]?[0-9]{1,2}:[0-9]{1,2}:([0-9]{0,2}[.])?[0-9]+ *"};
static const std::regex sexagesimalReprRx{" *[-+]?[0-9]{1,}:[0-9]{1,2}:([0-9]{0,2}[.])?[0-9]+ *"};
constexpr static bool isEqual(std::floating_point auto const& v1, std::floating_point auto const& v2)
@@ -395,16 +396,20 @@ static std::tuple<double, double, double> distanceOnSphere(double co_lon1,
std::get<0>(res) = co_lon1 - co_lon2;
std::get<1>(res) = co_lat1 - co_lat2;
double cosDco_lon = cos(std::get<0>(res));
double cos1 = cos(co_lat1);
double sin1 = sin(co_lat1);
double cos2 = cos(co_lat2);
double sin2 = sin(co_lat2);
double cosDco_lon = std::cos(std::abs(std::get<0>(res)));
double term1 = cos1 * sin(std::get<0>(res));
double term2 = cos2 * sin1 - sin2 * cos1 * cosDco_lon;
double cos1 = std::cos(co_lat1);
double sin1 = std::sin(co_lat1);
std::get<2>(res) = atan2(sqrt(term1 * term1 + term2 * term2), sin2 * sin1 + cos2 * cos1 * cosDco_lon);
double cos2 = std::cos(co_lat2);
double sin2 = std::sin(co_lat2);
double term1 = cos2 * std::sin(std::abs(std::get<0>(res)));
double term2 = cos1 * sin2 - sin1 * cos2 * cosDco_lon;
std::get<2>(res) = std::atan2(sqrt(term1 * term1 + term2 * term2), sin1 * sin2 + cos1 * cos2 * cosDco_lon);
// std::get<2>(res) = acos(sin1 * sin2 + cos1 * cos2 * cosDco_lon);
return res;
}

488
tests/bulletinA.txt Normal file
View File

@@ -0,0 +1,488 @@
**********************************************************************
* *
* I E R S B U L L E T I N - A *
* *
* Rapid Service/Prediction of Earth Orientation *
**********************************************************************
8 October 2026 Vol. XXXIX No. 041
______________________________________________________________________
GENERAL INFORMATION:
MJD = Julian Date - 2 400 000.5 days
UT2-UT1 = 0.022 sin(2*pi*T) - 0.012 cos(2*pi*T)
- 0.006 sin(4*pi*T) + 0.007 cos(4*pi*T)
where pi = 3.14159265... and T is the date in Besselian years.
TT = TAI + 32.184 seconds
DUT1= (UT1-UTC) transmitted with time signals
= 0.0 seconds beginning 09 April 2026 at 0000 UTC
Beginning 1 January 2017:
TAI-UTC = 37.000 000 seconds
***********************************************************************
* ANNOUNCEMENTS: *
* *
* There will NOT be a leap second introduced in UTC *
* at the end of December 2026. *
* *
* The primary source for IERS Rapid Service/Prediction Center (RS/PC) *
* data products is the official IERS RS/PC website: *
* https://maia.usno.navy.mil *
* *
* IERS RS/PC products are also available from: *
* NASA CDDIS: https://cddis.nasa.gov/archive/products/iers/ *
* NASA CDDIS: ftps://gdc.cddis.eosdis.nasa.gov/products/iers/ *
* IERS Central Bureau: https://datacenter.iers.org/eop.php *
* *
* Questions about IERS RS/PC products can be emailed to: *
* eopcp@us.navy.mil *
* *
* Distribution statement A: *
* Approved for public release: distribution unlimited. *
* *
***********************************************************************
________________________________________________________________________
The contributed observations used in the preparation of this Bulletin
are available at <http://www.usno.navy.mil/USNO/earth-orientation/
eo-info/general/input-data>. The contributed analysis results are based
on data from Very Long Baseline Interferometry (VLBI), Satellite Laser
Ranging (SLR), the Global Positioning System (GPS) satellites, Lunar
Laser Ranging (LLR), and meteorological predictions of variations in
Atmospheric Angular Momentum (AAM).
________________________________________________________________________
COMBINED EARTH ORIENTATION PARAMETERS:
IERS Rapid Service
MJD x error y error UT1-UTC error
" " " " s s
26 10 2 61315 0.17334 .00009 0.32459 .00009 -0.023137 0.000021
26 10 3 61316 0.17258 .00009 0.32394 .00009 -0.023648 0.000022
26 10 4 61317 0.17187 .00009 0.32345 .00009 -0.024220 0.000021
26 10 5 61318 0.17095 .00009 0.32294 .00009 -0.025006 0.000022
26 10 6 61319 0.16982 .00009 0.32250 .00009 -0.026011 0.000022
26 10 7 61320 0.16879 .00009 0.32217 .00009 -0.027264 0.000023
26 10 8 61321 0.16813 .00009 0.32221 .00009 -0.028742 0.000022
_______________________________________________________________________
PREDICTIONS:
The following formulas will not reproduce the predictions given below,
but may be used to extend the predictions beyond the end of this table.
x = 0.1598 + 0.0465 cos A - 0.1071 sin A - 0.0426 cos C + 0.0358 sin C
y = 0.3762 - 0.0906 cos A - 0.0441 sin A + 0.0358 cos C + 0.0426 sin C
UT1-UTC = -0.1023 - 0.00035 (MJD - 61329) - (UT2-UT1)
where A = 2*pi*(MJD-61321)/365.25 and C = 2*pi*(MJD-61321)/435.
TAI-UTC(MJD 61322) = 37.0
The accuracy may be estimated from the expressions:
S x,y = 0.00068 (MJD-61321)**0.80 S t = 0.00025 (MJD-61321)**0.75
Estimated accuracies are: Predictions 10 d 20 d 30 d 40 d
Polar coord's 0.004 0.007 0.010 0.013
UT1-UTC 0.0014 0.0024 0.0032 0.0040
MJD x(arcsec) y(arcsec) UT1-UTC(sec)
2026 10 9 61322 0.1672 0.3223 -0.03029
2026 10 10 61323 0.1664 0.3225 -0.03180
2026 10 11 61324 0.1656 0.3226 -0.03321
2026 10 12 61325 0.1646 0.3227 -0.03444
2026 10 13 61326 0.1636 0.3227 -0.03546
2026 10 14 61327 0.1624 0.3225 -0.03625
2026 10 15 61328 0.1614 0.3223 -0.03684
2026 10 16 61329 0.1603 0.3222 -0.03732
2026 10 17 61330 0.1593 0.3221 -0.03778
2026 10 18 61331 0.1583 0.3220 -0.03834
2026 10 19 61332 0.1573 0.3220 -0.03904
2026 10 20 61333 0.1563 0.3220 -0.03991
2026 10 21 61334 0.1553 0.3220 -0.04102
2026 10 22 61335 0.1542 0.3220 -0.04236
2026 10 23 61336 0.1532 0.3221 -0.04389
2026 10 24 61337 0.1521 0.3221 -0.04556
2026 10 25 61338 0.1511 0.3222 -0.04727
2026 10 26 61339 0.1500 0.3222 -0.04888
2026 10 27 61340 0.1489 0.3223 -0.05031
2026 10 28 61341 0.1478 0.3224 -0.05150
2026 10 29 61342 0.1467 0.3225 -0.05251
2026 10 30 61343 0.1456 0.3226 -0.05343
2026 10 31 61344 0.1445 0.3227 -0.05437
2026 11 1 61345 0.1434 0.3228 -0.05546
2026 11 2 61346 0.1423 0.3230 -0.05677
2026 11 3 61347 0.1412 0.3231 -0.05830
2026 11 4 61348 0.1401 0.3233 -0.05999
2026 11 5 61349 0.1390 0.3235 -0.06177
2026 11 6 61350 0.1379 0.3237 -0.06353
2026 11 7 61351 0.1368 0.3239 -0.06518
2026 11 8 61352 0.1357 0.3242 -0.06664
2026 11 9 61353 0.1346 0.3244 -0.06789
2026 11 10 61354 0.1334 0.3247 -0.06892
2026 11 11 61355 0.1323 0.3250 -0.06976
2026 11 12 61356 0.1312 0.3253 -0.07049
2026 11 13 61357 0.1301 0.3256 -0.07117
2026 11 14 61358 0.1290 0.3259 -0.07187
2026 11 15 61359 0.1279 0.3263 -0.07267
2026 11 16 61360 0.1268 0.3266 -0.07362
2026 11 17 61361 0.1257 0.3270 -0.07477
2026 11 18 61362 0.1246 0.3274 -0.07612
2026 11 19 61363 0.1235 0.3278 -0.07765
2026 11 20 61364 0.1224 0.3283 -0.07931
2026 11 21 61365 0.1213 0.3287 -0.08103
2026 11 22 61366 0.1203 0.3292 -0.08270
2026 11 23 61367 0.1192 0.3296 -0.08420
2026 11 24 61368 0.1181 0.3301 -0.08546
2026 11 25 61369 0.1171 0.3306 -0.08647
2026 11 26 61370 0.1160 0.3311 -0.08729
2026 11 27 61371 0.1149 0.3317 -0.08807
2026 11 28 61372 0.1139 0.3322 -0.08895
2026 11 29 61373 0.1129 0.3328 -0.09003
2026 11 30 61374 0.1118 0.3334 -0.09134
2026 12 1 61375 0.1108 0.3340 -0.09284
2026 12 2 61376 0.1098 0.3346 -0.09444
2026 12 3 61377 0.1088 0.3352 -0.09603
2026 12 4 61378 0.1078 0.3359 -0.09752
2026 12 5 61379 0.1068 0.3365 -0.09884
2026 12 6 61380 0.1058 0.3372 -0.09995
2026 12 7 61381 0.1048 0.3379 -0.10085
2026 12 8 61382 0.1038 0.3386 -0.10156
2026 12 9 61383 0.1029 0.3393 -0.10213
2026 12 10 61384 0.1019 0.3400 -0.10261
2026 12 11 61385 0.1010 0.3408 -0.10308
2026 12 12 61386 0.1001 0.3416 -0.10361
2026 12 13 61387 0.0992 0.3423 -0.10426
2026 12 14 61388 0.0983 0.3431 -0.10506
2026 12 15 61389 0.0974 0.3439 -0.10604
2026 12 16 61390 0.0965 0.3447 -0.10718
2026 12 17 61391 0.0956 0.3456 -0.10847
2026 12 18 61392 0.0948 0.3464 -0.10983
2026 12 19 61393 0.0939 0.3473 -0.11117
2026 12 20 61394 0.0931 0.3481 -0.11241
2026 12 21 61395 0.0923 0.3490 -0.11346
2026 12 22 61396 0.0915 0.3499 -0.11427
2026 12 23 61397 0.0907 0.3508 -0.11490
2026 12 24 61398 0.0900 0.3517 -0.11543
2026 12 25 61399 0.0892 0.3527 -0.11604
2026 12 26 61400 0.0885 0.3536 -0.11683
2026 12 27 61401 0.0877 0.3546 -0.11789
2026 12 28 61402 0.0870 0.3555 -0.11917
2026 12 29 61403 0.0863 0.3565 -0.12060
2026 12 30 61404 0.0857 0.3575 -0.12202
2026 12 31 61405 0.0850 0.3585 -0.12334
2027 1 1 61406 0.0844 0.3595 -0.12446
2027 1 2 61407 0.0837 0.3606 -0.12535
2027 1 3 61408 0.0831 0.3616 -0.12600
2027 1 4 61409 0.0825 0.3626 -0.12645
2027 1 5 61410 0.0820 0.3637 -0.12674
2027 1 6 61411 0.0814 0.3647 -0.12694
2027 1 7 61412 0.0809 0.3658 -0.12711
2027 1 8 61413 0.0804 0.3669 -0.12733
2027 1 9 61414 0.0799 0.3680 -0.12767
2027 1 10 61415 0.0794 0.3691 -0.12816
2027 1 11 61416 0.0789 0.3702 -0.12883
2027 1 12 61417 0.0785 0.3713 -0.12967
2027 1 13 61418 0.0781 0.3724 -0.13064
2027 1 14 61419 0.0777 0.3735 -0.13169
2027 1 15 61420 0.0773 0.3747 -0.13273
2027 1 16 61421 0.0769 0.3758 -0.13369
2027 1 17 61422 0.0766 0.3769 -0.13448
2027 1 18 61423 0.0762 0.3781 -0.13506
2027 1 19 61424 0.0759 0.3793 -0.13544
2027 1 20 61425 0.0757 0.3804 -0.13570
2027 1 21 61426 0.0754 0.3816 -0.13596
2027 1 22 61427 0.0752 0.3827 -0.13639
2027 1 23 61428 0.0749 0.3839 -0.13707
2027 1 24 61429 0.0747 0.3851 -0.13803
2027 1 25 61430 0.0746 0.3863 -0.13935
2027 1 26 61431 0.0744 0.3875 -0.14075
2027 1 27 61432 0.0743 0.3887 -0.14210
2027 1 28 61433 0.0742 0.3899 -0.14327
2027 1 29 61434 0.0741 0.3911 -0.14422
2027 1 30 61435 0.0740 0.3923 -0.14491
2027 1 31 61436 0.0740 0.3935 -0.14540
2027 2 1 61437 0.0739 0.3947 -0.14572
2027 2 2 61438 0.0739 0.3959 -0.14595
2027 2 3 61439 0.0740 0.3971 -0.14614
2027 2 4 61440 0.0740 0.3983 -0.14638
2027 2 5 61441 0.0741 0.3995 -0.14674
2027 2 6 61442 0.0742 0.4007 -0.14726
2027 2 7 61443 0.0743 0.4019 -0.14799
2027 2 8 61444 0.0744 0.4031 -0.14890
2027 2 9 61445 0.0746 0.4043 -0.14998
2027 2 10 61446 0.0748 0.4055 -0.15115
2027 2 11 61447 0.0750 0.4067 -0.15235
2027 2 12 61448 0.0752 0.4079 -0.15347
2027 2 13 61449 0.0754 0.4091 -0.15446
2027 2 14 61450 0.0757 0.4103 -0.15526
2027 2 15 61451 0.0760 0.4115 -0.15586
2027 2 16 61452 0.0763 0.4127 -0.15632
2027 2 17 61453 0.0767 0.4139 -0.15676
2027 2 18 61454 0.0770 0.4151 -0.15731
2027 2 19 61455 0.0774 0.4162 -0.15809
2027 2 20 61456 0.0778 0.4174 -0.15917
2027 2 21 61457 0.0783 0.4186 -0.16054
2027 2 22 61458 0.0787 0.4197 -0.16207
2027 2 23 61459 0.0792 0.4209 -0.16363
2027 2 24 61460 0.0797 0.4221 -0.16506
2027 2 25 61461 0.0802 0.4232 -0.16628
2027 2 26 61462 0.0808 0.4243 -0.16724
2027 2 27 61463 0.0814 0.4255 -0.16796
2027 2 28 61464 0.0820 0.4266 -0.16848
2027 3 1 61465 0.0826 0.4277 -0.16888
2027 3 2 61466 0.0832 0.4288 -0.16923
2027 3 3 61467 0.0839 0.4299 -0.16960
2027 3 4 61468 0.0845 0.4310 -0.17006
2027 3 5 61469 0.0853 0.4321 -0.17068
2027 3 6 61470 0.0860 0.4332 -0.17149
2027 3 7 61471 0.0867 0.4342 -0.17250
2027 3 8 61472 0.0875 0.4353 -0.17368
2027 3 9 61473 0.0883 0.4363 -0.17499
2027 3 10 61474 0.0891 0.4373 -0.17634
2027 3 11 61475 0.0899 0.4384 -0.17764
2027 3 12 61476 0.0908 0.4394 -0.17880
2027 3 13 61477 0.0917 0.4404 -0.17976
2027 3 14 61478 0.0925 0.4414 -0.18051
2027 3 15 61479 0.0935 0.4423 -0.18111
2027 3 16 61480 0.0944 0.4433 -0.18163
2027 3 17 61481 0.0954 0.4442 -0.18221
2027 3 18 61482 0.0963 0.4452 -0.18298
2027 3 19 61483 0.0973 0.4461 -0.18401
2027 3 20 61484 0.0983 0.4470 -0.18533
2027 3 21 61485 0.0994 0.4479 -0.18686
2027 3 22 61486 0.1004 0.4488 -0.18850
2027 3 23 61487 0.1015 0.4496 -0.19010
2027 3 24 61488 0.1026 0.4505 -0.19153
2027 3 25 61489 0.1037 0.4513 -0.19271
2027 3 26 61490 0.1048 0.4521 -0.19364
2027 3 27 61491 0.1060 0.4529 -0.19435
2027 3 28 61492 0.1071 0.4537 -0.19490
2027 3 29 61493 0.1083 0.4545 -0.19538
2027 3 30 61494 0.1095 0.4552 -0.19585
2027 3 31 61495 0.1107 0.4560 -0.19639
2027 4 1 61496 0.1119 0.4567 -0.19707
2027 4 2 61497 0.1132 0.4574 -0.19794
2027 4 3 61498 0.1144 0.4581 -0.19902
2027 4 4 61499 0.1157 0.4587 -0.20031
2027 4 5 61500 0.1170 0.4594 -0.20177
2027 4 6 61501 0.1183 0.4600 -0.20334
2027 4 7 61502 0.1196 0.4606 -0.20493
2027 4 8 61503 0.1209 0.4612 -0.20645
2027 4 9 61504 0.1223 0.4618 -0.20783
2027 4 10 61505 0.1237 0.4623 -0.20906
2027 4 11 61506 0.1250 0.4629 -0.21016
2027 4 12 61507 0.1264 0.4634 -0.21122
2027 4 13 61508 0.1278 0.4639 -0.21237
2027 4 14 61509 0.1292 0.4644 -0.21370
2027 4 15 61510 0.1306 0.4648 -0.21529
2027 4 16 61511 0.1321 0.4652 -0.21712
2027 4 17 61512 0.1335 0.4657 -0.21911
2027 4 18 61513 0.1350 0.4661 -0.22114
2027 4 19 61514 0.1364 0.4664 -0.22304
2027 4 20 61515 0.1379 0.4668 -0.22469
2027 4 21 61516 0.1394 0.4671 -0.22598
2027 4 22 61517 0.1409 0.4674 -0.22690
2027 4 23 61518 0.1424 0.4677 -0.22747
2027 4 24 61519 0.1439 0.4680 -0.22778
2027 4 25 61520 0.1454 0.4682 -0.22790
2027 4 26 61521 0.1469 0.4684 -0.22795
2027 4 27 61522 0.1485 0.4686 -0.22799
2027 4 28 61523 0.1500 0.4688 -0.22810
2027 4 29 61524 0.1515 0.4689 -0.22834
2027 4 30 61525 0.1531 0.4691 -0.22872
2027 5 1 61526 0.1547 0.4692 -0.22926
2027 5 2 61527 0.1562 0.4693 -0.22992
2027 5 3 61528 0.1578 0.4693 -0.23065
2027 5 4 61529 0.1594 0.4694 -0.23137
2027 5 5 61530 0.1609 0.4694 -0.23200
2027 5 6 61531 0.1625 0.4694 -0.23246
2027 5 7 61532 0.1641 0.4693 -0.23268
2027 5 8 61533 0.1657 0.4693 -0.23267
2027 5 9 61534 0.1672 0.4692 -0.23249
2027 5 10 61535 0.1688 0.4691 -0.23225
2027 5 11 61536 0.1704 0.4690 -0.23209
2027 5 12 61537 0.1720 0.4688 -0.23211
2027 5 13 61538 0.1736 0.4687 -0.23238
2027 5 14 61539 0.1752 0.4685 -0.23287
2027 5 15 61540 0.1768 0.4683 -0.23350
2027 5 16 61541 0.1783 0.4680 -0.23417
2027 5 17 61542 0.1799 0.4678 -0.23477
2027 5 18 61543 0.1815 0.4675 -0.23522
2027 5 19 61544 0.1831 0.4672 -0.23549
2027 5 20 61545 0.1847 0.4668 -0.23553
2027 5 21 61546 0.1862 0.4665 -0.23532
2027 5 22 61547 0.1878 0.4661 -0.23490
2027 5 23 61548 0.1894 0.4657 -0.23447
2027 5 24 61549 0.1909 0.4653 -0.23402
2027 5 25 61550 0.1925 0.4648 -0.23356
2027 5 26 61551 0.1940 0.4643 -0.23305
2027 5 27 61552 0.1956 0.4638 -0.23271
2027 5 28 61553 0.1971 0.4633 -0.23256
2027 5 29 61554 0.1986 0.4628 -0.23252
2027 5 30 61555 0.2002 0.4622 -0.23259
2027 5 31 61556 0.2017 0.4616 -0.23260
2027 6 1 61557 0.2032 0.4610 -0.23253
2027 6 2 61558 0.2047 0.4604 -0.23231
2027 6 3 61559 0.2062 0.4597 -0.23185
2027 6 4 61560 0.2076 0.4591 -0.23119
2027 6 5 61561 0.2091 0.4584 -0.23032
2027 6 6 61562 0.2106 0.4576 -0.22943
2027 6 7 61563 0.2120 0.4569 -0.22870
2027 6 8 61564 0.2135 0.4561 -0.22819
2027 6 9 61565 0.2149 0.4553 -0.22786
2027 6 10 61566 0.2163 0.4545 -0.22767
2027 6 11 61567 0.2177 0.4537 -0.22763
2027 6 12 61568 0.2191 0.4529 -0.22757
2027 6 13 61569 0.2205 0.4520 -0.22745
2027 6 14 61570 0.2218 0.4511 -0.22711
2027 6 15 61571 0.2232 0.4502 -0.22646
2027 6 16 61572 0.2245 0.4493 -0.22558
2027 6 17 61573 0.2258 0.4483 -0.22449
2027 6 18 61574 0.2271 0.4473 -0.22329
2027 6 19 61575 0.2284 0.4464 -0.22201
2027 6 20 61576 0.2297 0.4453 -0.22078
2027 6 21 61577 0.2309 0.4443 -0.21958
2027 6 22 61578 0.2321 0.4433 -0.21855
2027 6 23 61579 0.2334 0.4422 -0.21767
2027 6 24 61580 0.2346 0.4411 -0.21699
2027 6 25 61581 0.2357 0.4400 -0.21648
2027 6 26 61582 0.2369 0.4389 -0.21610
2027 6 27 61583 0.2380 0.4378 -0.21582
2027 6 28 61584 0.2392 0.4366 -0.21555
2027 6 29 61585 0.2403 0.4354 -0.21520
2027 6 30 61586 0.2413 0.4342 -0.21476
2027 7 1 61587 0.2424 0.4330 -0.21407
2027 7 2 61588 0.2435 0.4318 -0.21326
2027 7 3 61589 0.2445 0.4306 -0.21229
2027 7 4 61590 0.2455 0.4293 -0.21142
2027 7 5 61591 0.2465 0.4281 -0.21066
2027 7 6 61592 0.2474 0.4268 -0.21015
2027 7 7 61593 0.2483 0.4255 -0.20989
2027 7 8 61594 0.2493 0.4242 -0.20984
2027 7 9 61595 0.2501 0.4228 -0.20994
2027 7 10 61596 0.2510 0.4215 -0.20988
2027 7 11 61597 0.2519 0.4202 -0.20959
2027 7 12 61598 0.2527 0.4188 -0.20900
2027 7 13 61599 0.2535 0.4174 -0.20815
2027 7 14 61600 0.2542 0.4160 -0.20703
2027 7 15 61601 0.2550 0.4146 -0.20571
2027 7 16 61602 0.2557 0.4132 -0.20432
2027 7 17 61603 0.2564 0.4118 -0.20294
2027 7 18 61604 0.2571 0.4103 -0.20162
2027 7 19 61605 0.2577 0.4089 -0.20047
2027 7 20 61606 0.2583 0.4074 -0.19943
2027 7 21 61607 0.2589 0.4060 -0.19858
2027 7 22 61608 0.2595 0.4045 -0.19794
2027 7 23 61609 0.2600 0.4030 -0.19744
2027 7 24 61610 0.2605 0.4015 -0.19706
2027 7 25 61611 0.2610 0.4000 -0.19671
2027 7 26 61612 0.2615 0.3985 -0.19636
2027 7 27 61613 0.2619 0.3970 -0.19587
2027 7 28 61614 0.2623 0.3955 -0.19523
2027 7 29 61615 0.2627 0.3940 -0.19436
2027 7 30 61616 0.2631 0.3924 -0.19338
2027 7 31 61617 0.2634 0.3909 -0.19242
2027 8 1 61618 0.2637 0.3893 -0.19156
2027 8 2 61619 0.2639 0.3878 -0.19089
2027 8 3 61620 0.2642 0.3862 -0.19047
2027 8 4 61621 0.2644 0.3847 -0.19032
2027 8 5 61622 0.2646 0.3831 -0.19038
2027 8 6 61623 0.2647 0.3816 -0.19045
2027 8 7 61624 0.2648 0.3800 -0.19036
2027 8 8 61625 0.2649 0.3784 -0.19005
2027 8 9 61626 0.2650 0.3768 -0.18939
2027 8 10 61627 0.2650 0.3753 -0.18850
2027 8 11 61628 0.2650 0.3737 -0.18736
2027 8 12 61629 0.2650 0.3721 -0.18613
2027 8 13 61630 0.2649 0.3706 -0.18490
2027 8 14 61631 0.2649 0.3690 -0.18367
2027 8 15 61632 0.2647 0.3674 -0.18263
2027 8 16 61633 0.2646 0.3658 -0.18175
2027 8 17 61634 0.2644 0.3643 -0.18101
2027 8 18 61635 0.2642 0.3627 -0.18047
2027 8 19 61636 0.2640 0.3611 -0.18006
2027 8 20 61637 0.2638 0.3596 -0.17971
2027 8 21 61638 0.2635 0.3580 -0.17944
2027 8 22 61639 0.2631 0.3565 -0.17920
2027 8 23 61640 0.2628 0.3549 -0.17893
2027 8 24 61641 0.2624 0.3534 -0.17850
2027 8 25 61642 0.2620 0.3518 -0.17787
2027 8 26 61643 0.2616 0.3503 -0.17711
2027 8 27 61644 0.2611 0.3488 -0.17636
2027 8 28 61645 0.2606 0.3472 -0.17574
2027 8 29 61646 0.2601 0.3457 -0.17539
2027 8 30 61647 0.2596 0.3442 -0.17532
2027 8 31 61648 0.2590 0.3427 -0.17563
2027 9 1 61649 0.2584 0.3412 -0.17620
2027 9 2 61650 0.2577 0.3398 -0.17690
2027 9 3 61651 0.2571 0.3383 -0.17757
2027 9 4 61652 0.2564 0.3368 -0.17804
2027 9 5 61653 0.2557 0.3354 -0.17821
2027 9 6 61654 0.2549 0.3339 -0.17804
2027 9 7 61655 0.2541 0.3325 -0.17762
2027 9 8 61656 0.2533 0.3311 -0.17702
2027 9 9 61657 0.2525 0.3297 -0.17639
2027 9 10 61658 0.2516 0.3283 -0.17578
2027 9 11 61659 0.2508 0.3269 -0.17523
2027 9 12 61660 0.2498 0.3255 -0.17482
2027 9 13 61661 0.2489 0.3242 -0.17451
2027 9 14 61662 0.2479 0.3228 -0.17443
2027 9 15 61663 0.2470 0.3215 -0.17454
2027 9 16 61664 0.2459 0.3202 -0.17483
2027 9 17 61665 0.2449 0.3189 -0.17520
2027 9 18 61666 0.2438 0.3176 -0.17547
2027 9 19 61667 0.2427 0.3163 -0.17563
2027 9 20 61668 0.2416 0.3151 -0.17573
2027 9 21 61669 0.2405 0.3138 -0.17562
2027 9 22 61670 0.2393 0.3126 -0.17534
2027 9 23 61671 0.2381 0.3114 -0.17497
2027 9 24 61672 0.2369 0.3102 -0.17466
2027 9 25 61673 0.2356 0.3091 -0.17446
2027 9 26 61674 0.2344 0.3079 -0.17452
2027 9 27 61675 0.2331 0.3068 -0.17491
2027 9 28 61676 0.2318 0.3057 -0.17557
2027 9 29 61677 0.2305 0.3046 -0.17637
2027 9 30 61678 0.2291 0.3035 -0.17727
2027 10 1 61679 0.2277 0.3025 -0.17809
2027 10 2 61680 0.2263 0.3015 -0.17865
2027 10 3 61681 0.2249 0.3005 -0.17894
2027 10 4 61682 0.2235 0.2995 -0.17892
2027 10 5 61683 0.2220 0.2985 -0.17866
2027 10 6 61684 0.2205 0.2976 -0.17834
2027 10 7 61685 0.2190 0.2966 -0.17806
2027 10 8 61686 0.2175 0.2957 -0.17778
These predictions are based on all announced leap seconds.
CELESTIAL POLE OFFSET SERIES:
NEOS Celestial Pole Offset Series
MJD dpsi error deps error
(msec. of arc)
61292 -123.28 1.24 -11.48 0.12
61293 -123.30 1.24 -11.30 0.12
61294 -123.26 1.24 -11.15 0.12
61295 -123.29 0.32 -11.07 0.16
61296 -123.59 0.32 -11.08 0.16
61297 -124.16 0.32 -11.18 0.16
61298 -124.72 0.32 -11.31 0.16
61299 -124.96 0.32 -11.38 0.16
61300 -124.76 0.32 -11.31 0.16
61301 -124.26 0.32 -11.17 0.16
61302 -123.69 0.32 -11.09 0.16
61303 -123.26 1.03 -11.12 0.11
61304 -123.06 1.03 -11.23 0.11
61305 -123.09 1.03 -11.27 0.11
IAU2000A Celestial Pole Offset Series
MJD dX error dY error
(msec. of arc)
61292 0.457 0.492 -0.206 0.116
61293 0.457 0.492 -0.198 0.116
61294 0.456 0.492 -0.190 0.116
61295 0.455 0.128 -0.182 0.160
61296 0.453 0.128 -0.175 0.160
61297 0.450 0.128 -0.167 0.160
61298 0.447 0.128 -0.160 0.160
61299 0.443 0.128 -0.152 0.160
61300 0.438 0.128 -0.145 0.160
61301 0.434 0.128 -0.138 0.160
61302 0.429 0.128 -0.131 0.160
61303 0.424 0.409 -0.124 0.113
61304 0.419 0.409 -0.117 0.113
61305 0.414 0.409 -0.109 0.113

View File

@@ -50,10 +50,11 @@ void deserialize(mcc::traits::mcc_input_char_range auto const& s, VT& value)
}
}
int main()
int main(int argc, char* argv[])
{
skypt_t::cctEngine.setStateERFA(saoras);
skypt_t pt;
MccSkyRADEC_ICRS icrs(0.0, 70.0_degs);
@@ -177,5 +178,18 @@ int main()
<< ", kind = " << MccCoordPairKindToStr(pt.pairKind()) << "\n";
std::cout << "\n\n";
std::string ba_fname = "/tmp/bulletinA.txt";
if (argc > 1) {
ba_fname = argv[1];
}
auto err = skypt_t::cctEngine.updateBulletinA(ba_fname);
if (err) {
std::cout << "Cannot load BulletinA file: '" << ba_fname << "' (err = " << err.message() << ")\n";
} else {
std::cout << "BulletinA file: '" << ba_fname << " was loaded successfully!\n";
}
return 0;
}

178
tests/mcc_keyvalue_test.cpp Normal file
View File

@@ -0,0 +1,178 @@
#include <print>
#include <mcc/mcc_keyvalue.h>
using namespace mcc::impl;
// example of non-default constructible class
struct VT {
VT(int v) : _v(v) {}
void set(int v)
{
_v = v;
}
int v() const
{
return _v;
}
protected:
int _v{};
};
template <>
struct mcc::impl::MccSerializer<VT> : MccSerializerBase {
static constexpr std::string_view serializerName{"MCC-VT-SERIALIZER"};
template <mcc_serialization_params_c ParamsT = mcc_serialization_params_t>
error_t operator()(traits::mcc_output_char_range auto& output,
VT const& value,
ParamsT const& params = mcc_serialization_params_t{})
{
return MccSerializer<int>{}(output, value.v(), params);
}
};
template <>
struct mcc::impl::MccDeserializer<VT> : MccDeserializerBase {
static constexpr std::string_view deserializerName{"MCC-VT-DESERIALIZER"};
template <mcc_serialization_params_c ParamsT = mcc_serialization_params_t>
error_t operator()(traits::mcc_input_char_range auto const& input,
VT& value,
ParamsT const& params = mcc_serialization_params_t{})
{
int v;
auto err = MccDeserializer<int>{}(input, v, params);
if (!err) {
value.set(v);
}
return err;
}
};
static auto kv_desc = std::make_tuple(
mcc_simple_kv_record_t{"bb", MccAngle{11.5_degs}, MccAngle{11.5_degs}, mcc_serialization_params_t{}},
mcc_simple_kv_record_t{"aaa", std::string("AAA"), std::string("AAA"), mcc_serialization_params_t{}},
mcc_simple_kv_record_t{"cc", MccCelestialCoordEpoch{}, MccCelestialCoordEpoch{}, mcc_serialization_params_t{}},
mcc_simple_kv_record_t{
"ddd", MccAngle{11.5_degs}, MccAngle{11.5_degs},
mcc_serialization_params_t{.angle_format = mcc::MccSerializedAngleFormat::MCC_SERIALIZED_FORMAT_SXGM_HOURS}},
mcc_make_simple_kv_record("eee", 1.5),
mcc_make_simple_kv_record("arr", std::vector<int>{1, 2, 3, 4, 5, 6, 7}),
mcc_make_simple_kv_record("vt", VT(77)),
mcc_make_simple_kv_record("sarr", std::array<double, 3>{1, 2, 3}));
static std::string STR = R"--(
aaa = dewl_ewkj23+23998
#
# this is angle
bb=1.24534
cc= 2026-05-15T05:53:20.921723918 # date UTC
)--";
static std::string STR1 = R"--(
aaa = dewl_ewkj23+23998
#
# this is obs date
cc= 2026-05-15T05:53:20.921723918 # date UTC
ddd = 01:02:33.434 # HA in hours:mins:secs
)--";
int main()
{
std::error_code err;
std::string buff;
MccKeyValueHolder kv(kv_desc);
err = kv.toCharRange(buff);
if (err) {
std::println("ERR = {}", err);
return 1;
}
std::println("DEFAULT VALUES:");
std::println("--(\n{})--", buff);
std::println("\n\n");
err = kv.setValue("eee", 15.1515);
if (err) {
std::println("ERR = {}", err);
// return 1;
}
// auto err = kv.fromCharRange(STR);
err = kv.fromCharRange(STR1);
if (err) {
std::println("ERR = {}", err);
return 1;
}
std::println("{} = {}", "bb", kv.getValue<MccAngle>(std::string{"bb"}).value().sexagesimal());
std::println("{} = {}", "cc", kv.getValue<MccCelestialCoordEpoch>("cc").value().UTC());
err = kv.setValue("cc", std::chrono::system_clock::now());
if (err) {
std::println("ERR = {}", err);
// return 1;
}
err = kv.setValue("aaa", "OK");
if (err) {
std::println("ERR = {}", err);
// return 1;
}
err = kv.setValue("ddd", 37.5_degs);
if (err) {
std::println("ERR = {}", err);
// return 1;
}
err = kv.setValue("arr", std::array{10, 20, 30});
if (err) {
std::println("ERR = {}", err);
// return 1;
}
err = kv.setValue("sarr", std::vector{10, 20, 30, 40, 50});
if (err) {
std::println("ERR = {}", err);
// return 1;
}
std::println("------------------------------------");
buff.clear();
err = kv.toCharRange<decltype(kv)::OPOLICY_FULL>(buff);
// err = kv.toCharRange(buff);
if (err) {
std::println("ERR = {}", err);
return 1;
}
std::println("--(\n{}\n)--", buff);
std::print("KEYS: ");
for (auto const& k : kv.keys()) {
std::print("{} ", k);
}
std::println("");
return 0;
}

185
tests/mcc_pcm_test.cpp Normal file
View File

@@ -0,0 +1,185 @@
#include <print>
#include <random>
#include <mcc/mcc_pcm_construct.h>
#include <mcc/mcc_pcm_fit.h>
struct pcm_res_t {
double pcmX, pcmY;
};
static constexpr mcc::MccMountType MOUNT_TYPE{mcc::MccMountType::FORK_TYPE};
int main()
{
using pcm_t = mcc::impl::MccDefaultPCM<MOUNT_TYPE>;
using pcm_const_t = mcc::impl::MccPCMConstructor<MOUNT_TYPE>;
using pcm_fit_t = mcc::impl::MccPCMFitter<MOUNT_TYPE>;
pcm_t pcm;
pcm_const_t pcm_const;
pcm_fit_t pcm_fitter;
pcm_t::pcm_data_t pcm_data{.type = mcc::impl::MccDefaultPCMType::PCM_TYPE_GEOMETRY,
.siteLatitude = 43.6466666667_degs,
// .geomCoefficients = {.zeroPointX = 2.434534_degs,
// .zeroPointY = -3.382549_degs,
.geomCoefficients = {.zeroPointX = 2.434534_arcsecs,
.zeroPointY = -3.382549_arcsecs,
.collimationErr = 10.534_arcsecs,
.nonperpendErr = 21.86834_arcsecs,
.misalignErr1 = 7.345768_arcsecs,
.misalignErr2 = -12.87934_arcsecs,
.tubeFlexure = 5.9083_arcsecs,
.DECaxisFlexure = 3.48379812_arcsecs,
.forkFlexure = 9.342354_arcsecs}};
size_t haM = 10; // number of B-spline inner knots along HA-axis
size_t decM = 10; // number of B-spline inner knots along DEC-axis
double ha_step = 360.0_degs / (haM - 1);
pcm_data.bspline.knotsX.resize(haM);
// for (size_t i = 0; i < haM; ++i) { // [0, 360]
// pcm_data.bspline.knotsX[i] = i * ha_step;
// }
for (size_t i = 0; i < haM; ++i) { // [-180, 180]
pcm_data.bspline.knotsX[i] = i * ha_step - std::numbers::pi;
}
double dec_start = -35.0_degs;
double dec_step = (90.0_degs - dec_start) / (decM - 1);
pcm_data.bspline.knotsY.resize(decM);
for (size_t i = 0; i < decM; ++i) {
pcm_data.bspline.knotsY[i] = dec_start + i * dec_step;
}
pcm.setPCMData(pcm_data);
size_t N = 100; // number of measurements
std::vector<mcc::impl::MccAngle> encX(N), encY(N), ha(N), dec(N), pcmX(N), pcmY(N);
std::vector<mcc::impl::MccAngle> resX(N), resY(N);
pcm_res_t pcm_res;
auto comp_hadec = [&]() {
mcc::impl::MccSkyPoint hadec;
for (size_t i = 0; i < N; ++i) {
auto err = pcm.computePCM(mcc::impl::MccGenXY{(double)encX[i], (double)encY[i]}, &pcm_res, &hadec);
if (err) {
std::println("Error in PCM computing: {}", err.message());
return 1;
}
pcmX[i] = pcm_res.pcmX;
pcmY[i] = pcm_res.pcmY;
ha[i] = hadec.co_lon();
dec[i] = hadec.co_lat();
}
return 0;
};
double start_encX = 1.2423_degs, stop_encX = 354.896124_degs;
double start_encY = -32.2423_degs, stop_encY = 84.896124_degs;
double x_step = (stop_encX - start_encX) / (N - 1), y_step = (stop_encY - start_encY) / (N - 1);
for (size_t i = 0; i < N; ++i) {
encX[i] = start_encX + i * x_step;
encY[i] = start_encY + i * y_step;
}
comp_hadec();
std::println("X Y HA DEC (pcmX pcmY):");
for (size_t i = 0; i < N; ++i) {
std::println("{:12.7f} {:12.7f} {:12.7f} {:12.7f} ({:10.7f} {:10.7f})", encX[i].degrees(), encY[i].degrees(),
ha[i].degrees(), dec[i].degrees(), pcmX[i].degrees(), pcmY[i].degrees());
}
// add 'noise'
// double sigma = 24.3248792_arcsecs / 2.355;
double sigma = 4.3248792_arcsecs;
std::random_device rd{};
std::mt19937 gen{rd()};
std::normal_distribution dist{0.0, sigma};
mcc::impl::MccSkyPoint hadec;
for (size_t i = 0; i < N; ++i) {
ha[i] += dist(gen);
dec[i] += dist(gen);
resX[i] = ha[i] - encX[i];
resY[i] = dec[i] - encY[i];
// hadec.from(mcc::impl::MccSkyHADEC_OBS{(double)ha[i], (double)dec[i]});
// pcm_const.addPoint(hadec, mcc::impl::MccGenXY{(double)encX[i], (double)encY[i]});
pcm_fitter.addPoint((double)ha[i], (double)dec[i], (double)encX[i], (double)encY[i],
mcc::impl::MccCelestialCoordEpoch{});
}
pcm_t::pcm_data_t fit_pcm_data{.type = pcm_data.type, .siteLatitude = pcm_data.siteLatitude};
// auto r = pcm_const.computeModel(fit_pcm_data);
auto r = pcm_fitter.computeModel(fit_pcm_data);
if (r.error) {
std::println("error: {}", r.error.message());
return 1;
}
std::println("FITTED STATUS:");
std::println("\tNUM OF ITERS: {}", r.final_iter);
std::println("FITTED COEFFS:");
std::println("X0 = {} ({}), Y0 = {} ({})", mcc::impl::MccAngleFancyString(fit_pcm_data.geomCoefficients.zeroPointX),
mcc::impl::MccAngleFancyString(pcm_data.geomCoefficients.zeroPointX),
mcc::impl::MccAngleFancyString(fit_pcm_data.geomCoefficients.zeroPointY),
mcc::impl::MccAngleFancyString(pcm_data.geomCoefficients.zeroPointY));
// std::println("X0 = {} ({}), Y0 = {} ({})",
// mcc::impl::MccAngle(fit_pcm_data.geomCoefficients.zeroPointX).degrees(),
// mcc::impl::MccAngle(pcm_data.geomCoefficients.zeroPointX).degrees(),
// mcc::impl::MccAngle(fit_pcm_data.geomCoefficients.zeroPointY).degrees(),
// mcc::impl::MccAngle(pcm_data.geomCoefficients.zeroPointY).degrees());
std::println("collimErr = {} ({})", mcc::impl::MccAngle(fit_pcm_data.geomCoefficients.collimationErr).arcsecs(),
mcc::impl::MccAngle(pcm_data.geomCoefficients.collimationErr).arcsecs());
std::println("nonperpErr = {} ({})", mcc::impl::MccAngle(fit_pcm_data.geomCoefficients.nonperpendErr).arcsecs(),
mcc::impl::MccAngle(pcm_data.geomCoefficients.nonperpendErr).arcsecs());
std::println("misalignErr1 = {} ({}), misalignErr2 = {} ({})",
mcc::impl::MccAngle(fit_pcm_data.geomCoefficients.misalignErr1).arcsecs(),
mcc::impl::MccAngle(pcm_data.geomCoefficients.misalignErr1).arcsecs(),
mcc::impl::MccAngle(fit_pcm_data.geomCoefficients.misalignErr2).arcsecs(),
mcc::impl::MccAngle(pcm_data.geomCoefficients.misalignErr2).arcsecs());
std::println("tubeflexErr = {} ({})", mcc::impl::MccAngle(fit_pcm_data.geomCoefficients.tubeFlexure).arcsecs(),
mcc::impl::MccAngle(pcm_data.geomCoefficients.tubeFlexure).arcsecs());
std::println("DECaxflexErr = {} ({})", mcc::impl::MccAngle(fit_pcm_data.geomCoefficients.DECaxisFlexure).arcsecs(),
mcc::impl::MccAngle(pcm_data.geomCoefficients.DECaxisFlexure).arcsecs());
std::println("forkflexErr = {} ({})", mcc::impl::MccAngle(fit_pcm_data.geomCoefficients.forkFlexure).arcsecs(),
mcc::impl::MccAngle(pcm_data.geomCoefficients.forkFlexure).arcsecs());
// std::println("\n\n{}", r.colon_res);
// std::println("\n\n{}", r.colat_res);
std::println("\n\n{}", r.model_colonRES);
std::println("\n\n{}", r.model_colatRES);
return 0;
}

View File

@@ -0,0 +1,177 @@
#include <fstream>
#include <print>
#include <mcc/mcc_pcm_construct.h>
#include <mcc/mcc_pcm_fit.h>
static constexpr mcc::MccMountType MOUNT_TYPE{mcc::MccMountType::CROSSAXIS_TYPE};
using namespace mcc::impl;
int main(int narg, char* argv[])
{
MccPCMConstructor<MOUNT_TYPE> pcm_cstr;
mcc::impl::MccPCMFitter<MOUNT_TYPE> pcm_fitter;
// MccSkyPoint sp;
MccSkyHADEC_OBS hadec;
MccGenXY xy;
MccDefaultPCM<MOUNT_TYPE>::pcm_data_t fit_pcm_data;
size_t haM = 10; // number of B-spline inner knots along HA-axis
size_t decM = 10; // number of B-spline inner knots along DEC-axis
double ha_step = 360.0_degs / (haM - 1);
fit_pcm_data.bspline.knotsX.resize(haM);
for (size_t i = 0; i < haM; ++i) {
// fit_pcm_data.bspline.knotsX[i] = i * ha_step; // [0, 360]
fit_pcm_data.bspline.knotsX[i] = i * ha_step - std::numbers::pi; // [-180, 180]
}
double dec_start = -25.0_degs;
double dec_step = (90.0_degs - dec_start) / (decM - 1);
fit_pcm_data.bspline.knotsY.resize(decM);
for (size_t i = 0; i < decM; ++i) {
fit_pcm_data.bspline.knotsY[i] = dec_start + i * dec_step;
}
std::ifstream fst;
std::string fname = "z1000_pcm_measu.data";
if (narg > 1) {
fname = argv[1];
}
fst.open(fname);
if (!fst.is_open()) {
std::println("Cannot open file {}", fname);
return 1;
}
double x, y, diff_x, diff_y, tag_ha, tag_dec;
std::println("READ DATA:");
MccCelestialCoordEpoch ep = MccCelestialCoordEpoch::now();
size_t i = 0;
while (!fst.eof()) {
// x - degs, y -degs, diff_x - arcsecs, diff_y - arcsecs
fst >> x >> y >> diff_x >> diff_y;
// std::println("\t{}\t{:10.6f} {:10.6f} {:8.6f} {:8.6f}", i++, x, y, diff_x, diff_y);
std::print("\t{}\t{:10.6f} {:10.6f} {:8.6f} {:8.6f}", i++, x, y, diff_x, diff_y);
tag_ha = x + diff_x / 3600.0;
tag_dec = y + diff_y / 3600.0;
hadec = MccSkyHADEC_OBS{MccAngleHA_OBS(tag_ha, mcc_degrees), MccAngleDEC_OBS(tag_dec, mcc_degrees), ep};
// sp.from(hadec);
xy = MccGenXY(MccAngleX(x, mcc_degrees), MccAngleY(y, mcc_degrees), ep);
std::println("\t[encX = {:10.6f} encY = {:10.6f} HA = {} DEC = {}]", xy.x().degrees(), xy.y().degrees(),
hadec.x().sexagesimal(true), hadec.y().sexagesimal());
// pcm_cstr.addPoint(sp, xy);
pcm_cstr.addPoint(hadec, xy);
pcm_fitter.addPoint(hadec, xy);
}
fst.close();
auto r = pcm_cstr.computeModel(fit_pcm_data);
auto fr = pcm_fitter.computeModel(fit_pcm_data);
// if (r.error) {
// std::println("error: {}", r.error.message());
// return 1;
// }
if (fr.error) {
std::println("error: {}", fr.error.message());
return 1;
}
std::println("\n\n{:*^40}\n", " FITTED RESULT (TYPE = GEOMETRY) ");
// std::println("\tNUM OF ITERS: {}", r.final_iter);
std::println("\tNUM OF ITERS: {}", fr.final_iter);
std::println("FITTED COEFFS:");
std::println("X0 = {}, Y0 = {}", MccAngleFancyString(fit_pcm_data.geomCoefficients.zeroPointX),
MccAngleFancyString(fit_pcm_data.geomCoefficients.zeroPointY));
std::println("collimErr = {}", MccAngleFancyString(fit_pcm_data.geomCoefficients.collimationErr));
std::println("nonperpErr = {}", MccAngleFancyString(fit_pcm_data.geomCoefficients.nonperpendErr));
std::println("misalignErr1 = {}", MccAngleFancyString(fit_pcm_data.geomCoefficients.misalignErr1));
std::println("misalignErr2 = {}", MccAngleFancyString(fit_pcm_data.geomCoefficients.misalignErr2));
std::println("tubeflexErr = {}", MccAngleFancyString(fit_pcm_data.geomCoefficients.tubeFlexure));
std::println("DECaxflexErr = {}", MccAngleFancyString(fit_pcm_data.geomCoefficients.DECaxisFlexure));
std::println("\n\n{:*^40}\n", " FITTED DIFFS ");
auto tab = pcm_cstr.getTable();
// for (size_t i = 0; i < pcm_cstr.numberOfPoints(); ++i) {
// std::println("{} {} {} {:6.2f}% ({:5.3f}) {} {} {:6.2f}% ({:5.3f}) (HA = {} DEC = {})", i,
// MccAngleFancyString(tab.colon_res[i]), MccAngleFancyString(r.model_colon[i]),
// std::abs((tab.colon_res[i] - r.model_colon[i]) / tab.colon_res[i]) * 100.0, r.colon_weight[i],
// MccAngleFancyString(tab.colat_res[i]), MccAngleFancyString(r.model_colat[i]),
// std::abs((tab.colat_res[i] - r.model_colat[i]) / tab.colat_res[i]) * 100.0, r.colat_weight[i],
// MccAngle(tab.hw_colon[i]).sexagesimal(true), MccAngle(tab.hw_colat[i]).sexagesimal());
// }
auto pcm_tab = pcm_fitter.getPCMTable();
for (size_t i = 0; i < pcm_fitter.numberOfPoints(); ++i) {
std::println("{} {} {} {:6.2f}% ({:5.3f}) {} {} {:6.2f}% ({:5.3f}) (HA = {} DEC = {})", i,
MccAngleFancyString(pcm_tab[i].res.x()), MccAngleFancyString(fr.model_colonRES[i]),
std::abs(fr.colon_err[i]) / pcm_tab[i].res.x() * 100.0, fr.colon_weight[i],
MccAngleFancyString(pcm_tab[i].res.y()), MccAngleFancyString(fr.model_colatRES[i]),
std::abs(fr.colat_err[i]) / pcm_tab[i].res.y() * 100.0, fr.colat_weight[i],
pcm_tab[i].hw.x().sexagesimal(true), pcm_tab[i].hw.y().sexagesimal());
}
std::println("\n\n{:*^40}\n", " FITTED RESULT (TYPE = BSPLINE) ");
fit_pcm_data.type = MccDefaultPCMType::PCM_TYPE_BSPLINE;
// r = pcm_cstr.computeModel(fit_pcm_data);
fr = pcm_fitter.computeModel(fit_pcm_data);
// if (r.error) {
// std::println("error: {}", r.error.message());
// std::println("b-spline error: {}", r.bspline_fit_err);
// return 1;
// }
if (fr.error) {
std::println("error: {}", fr.error.message());
std::println("b-spline error: {}", fr.bspline_fit_err);
return 1;
} else {
std::println("b-spline fit exit code: {}", fr.bspline_fit_err);
}
std::println("\n\n{:*^40}\n", " FITTED DIFFS ");
// for (size_t i = 0; i < pcm_cstr.numberOfPoints(); ++i) {
// std::println("{} {} {} {:6.2f}% {} {} {:6.2f}% (HA = {} DEC = {})", i,
// MccAngleFancyString(tab.colon_res[i]), MccAngleFancyString(r.model_colon[i]),
// std::abs((tab.colon_res[i] - r.model_colon[i]) / tab.colon_res[i]) * 100.0,
// MccAngleFancyString(tab.colat_res[i]), MccAngleFancyString(r.model_colat[i]),
// std::abs((tab.colat_res[i] - r.model_colat[i]) / tab.colat_res[i]) * 100.0,
// MccAngle(tab.hw_colon[i]).sexagesimal(true), MccAngle(tab.hw_colat[i]).sexagesimal());
// }
for (size_t i = 0; i < pcm_fitter.numberOfPoints(); ++i) {
std::println("{} {} {} {:6.2f}% {} {} {:6.2f}% (HA = {} DEC = {})", i,
MccAngleFancyString(pcm_tab[i].res.x()), MccAngleFancyString(fr.model_colonRES[i]),
std::abs(fr.colon_err[i]) / pcm_tab[i].res.x() * 100.0, MccAngleFancyString(pcm_tab[i].res.y()),
MccAngleFancyString(fr.model_colatRES[i]), std::abs(fr.colat_err[i]) / pcm_tab[i].res.y() * 100.0,
pcm_tab[i].hw.x().sexagesimal(true), pcm_tab[i].hw.y().sexagesimal());
}
return 0;
}

View File

@@ -14,8 +14,11 @@ static std::uniform_real_distribution<double> y_distrib(1000, 7000);
static std::uniform_real_distribution<double> xs_distrib(100, 700);
static std::uniform_real_distribution<double> ys_distrib(100, 700);
static std::uniform_int_distribution<uint8_t> err_distrib(0, 255);
struct hw_t {
static constexpr mcc::MccMountType mountType{mcc::MccMountType::ALTAZ_TYPE};
static constexpr mcc::MccMountType hwMountType{mcc::MccMountType::ALTAZ_TYPE};
static constexpr std::string_view hardwareName{"HW-TEST"};
typedef int error_t;
@@ -53,13 +56,19 @@ struct hw_t {
*state = hardware_state_t{.XY{x_distrib(gen), y_distrib(gen)}, .speedXY{xs_distrib(gen), ys_distrib(gen)}};
return 0;
// return 0;
return err_distrib(gen) < 5 ? 1 : 0;
}
error_t hardwareInit()
{
return 0;
}
error_t hardwareShutdown()
{
return 0;
}
};
template <>

140
tests/z1000_pcm_measu.data Normal file
View File

@@ -0,0 +1,140 @@
1.520984700000000078e+00 1.232847220000000021e+01 1.402137262519520178e+01 1.397878249028015496e+01
1.567091000000000012e+00 1.232847220000000021e+01 1.424221519655054280e+01 1.437419514622014383e+01
6.264433299999999427e+00 -1.137611109999999925e+01 1.609993788111976443e+01 2.083793765095746053e+01
6.310283200000000647e+00 -1.137611109999999925e+01 1.600192960162873845e+01 2.076926873683415309e+01
1.320332130000000070e+01 -2.892950000000000088e+01 2.286358732164985597e+01 2.038207784249622989e+01
1.324478129999999965e+01 -2.892950000000000088e+01 2.248315269968074404e+01 2.051349697694966778e+01
1.005094109999999930e+01 2.557805600000000013e+00 1.345883399999999952e+01 1.297186102799999929e+01
1.009740339999999925e+01 2.557805600000000013e+00 1.326531023999999981e+01 1.318907880000000077e+01
1.819215270000000118e+01 -1.671441670000000101e+01 1.757270074759864187e+01 2.073781269238157776e+01
1.823382970000000114e+01 -1.671441670000000101e+01 1.719913032287585608e+01 2.159752316061812039e+01
9.454526500000000055e+00 2.196961110000000161e+01 1.482182478753721178e+01 1.522155672575341079e+01
9.504631399999999175e+00 2.196961110000000161e+01 1.482390743949157219e+01 1.546582945276367305e+01
2.858336930000000109e+01 -3.186847219999999936e+01 1.815660005051495318e+01 1.896053456618076893e+01
2.862927249999999901e+01 -3.186847219999999936e+01 1.850526919508024193e+01 1.859472000360627675e+01
2.080040939999999949e+01 -3.467750000000000110e+00 1.427837004000000043e+01 1.049487843600000048e+01
2.084243520000000061e+01 -3.467750000000000110e+00 1.392372287999999969e+01 1.070905834799999923e+01
3.178236109999999925e+01 -1.952702779999999905e+01 2.167696316880000040e+01 7.249305960000000049e+00
3.182417189999999962e+01 -1.952702779999999905e+01 2.107618156799999909e+01 7.154861040000000116e+00
2.025673900000000316e+01 1.231291670000000060e+01 1.436658588000000059e+01 1.183834008000000004e+01
2.030284879999999958e+01 1.231291670000000060e+01 1.484159112000000036e+01 1.183364388000000034e+01
3.314437089999999841e+01 -6.282416699999999743e+00 2.048238615196899914e+01 7.555537013118320822e+00
3.318626649999999501e+01 -6.282416699999999743e+00 2.031546532784667392e+01 7.571803502585704670e+00
8.174148100000000028e+00 3.654522219999999777e+01 1.639438091999999969e+01 1.128399083999999952e+01
8.216073199999998522e+00 3.654522219999999777e+01 1.619869643999999909e+01 1.116389412000000014e+01
4.632874819999999971e+01 -1.946261110000000016e+01 1.886964740984793565e+01 1.896071441598940766e+01
4.637499929999999893e+01 -1.946261110000000016e+01 1.901053297014212262e+01 1.879686615692279261e+01
3.209061599999999714e+01 7.740944400000000059e+00 1.394660492906758975e+01 1.057056646642546838e+01
3.213633280000000525e+01 7.740944400000000059e+00 1.454147081652134155e+01 1.048048837084878748e+01
4.606433260000000018e+01 -6.610166699999999729e+00 2.024269522053099024e+01 7.028883369354944399e+00
4.610631639999999720e+01 -6.610166699999999729e+00 2.008559742574616891e+01 7.285131484084857334e+00
2.557915640000000224e+01 2.401413889999999896e+01 2.206382168907072838e+01 3.091156579791847037e+01
2.562517580000000095e+01 2.401413889999999896e+01 2.185121724273789923e+01 3.089656382159016701e+01
4.441593019999999825e+01 6.551638900000000376e+00 2.138349297490188761e+01 7.594698645765957323e+00
4.446164799999999673e+01 6.551638900000000376e+00 2.124548303456616338e+01 7.418561932720165508e+00
5.938992389999999943e+01 -4.837027800000000433e+00 2.579655702151784524e+01 1.373940562244154151e+01
5.943173099999999920e+01 -4.837027800000000433e+00 2.481252225932640698e+01 1.363269486445296153e+01
3.922132889999999605e+01 2.050424999999999898e+01 1.569271679999999947e+01 1.195416540000000083e+01
3.926743869999999959e+01 2.050424999999999898e+01 1.624694759999999860e+01 1.218877991999999999e+01
5.713390349999999529e+01 8.016138899999999623e+00 2.168379360000000133e+01 6.897207132000000129e+00
5.717997259999999926e+01 8.016138899999999623e+00 2.087569799999999987e+01 6.670144224000000399e+00
2.315225480000000147e+01 3.622719440000000191e+01 1.595990555999999927e+01 1.805808528000000024e+01
2.319800610000000063e+01 3.622719440000000191e+01 1.597561235999999951e+01 1.796384700000000123e+01
7.287439289999998948e+01 -1.305166700000000013e+00 2.576865240000000057e+01 1.750716986400000152e+01
7.292050640000000783e+01 -1.305166700000000013e+00 2.601736560000000154e+01 1.740492781200000039e+01
5.241497720000000271e+01 2.105997220000000070e+01 1.449506880000000031e+01 2.160073476000000170e+01
5.246108759999999904e+01 2.105997220000000070e+01 1.456931520000000013e+01 2.150408664000000059e+01
7.017244069999999567e+01 1.134838889999999978e+01 2.463619680000000045e+01 6.664804199999999845e+00
7.021428889999999967e+01 1.134838889999999978e+01 2.494610279999999847e+01 7.221205079999999832e+00
4.148476039999999898e+01 3.390825000000000244e+01 1.546144920000000056e+01 1.949037948000000142e+01
4.152660319999999672e+01 3.390825000000000244e+01 1.542145320000000019e+01 1.942556112000000113e+01
6.571000529999999173e+01 2.375494439999999940e+01 2.398345559999999921e+01 9.226117079999999859e+00
6.575224749999999574e+01 2.375494439999999940e+01 2.429307359999999960e+01 9.506921399999999522e+00
8.313718609999999387e+01 1.553819440000000007e+01 2.553773400000000038e+01 5.589535320000000418e+00
8.317920920000000251e+01 1.553819440000000007e+01 2.566232640000000131e+01 5.497365959999999774e+00
5.664400189999999924e+01 3.583738890000000055e+01 1.499639400000000045e+01 1.867782131999999962e+01
5.668571370000000087e+01 3.583738890000000055e+01 1.540229760000000070e+01 1.859227848000000094e+01
7.922477899999999806e+01 2.799013890000000160e+01 2.362876560000000126e+01 6.580477799999999711e+00
7.926706470000000593e+01 2.799013890000000160e+01 2.353645799999999966e+01 6.421130640000000334e+00
3.602889239999999660e+01 4.569222220000000334e+01 1.798344795599999912e+01 1.992703824000000168e+01
3.607534499999999866e+01 4.569222220000000334e+01 1.757011147200000067e+01 1.963801223999999834e+01
7.167516279999999540e+01 3.981491669999999772e+01 2.730168000000000106e+01 4.396943160000000184e+00
7.172162199999999643e+01 3.981491669999999772e+01 2.758881600000000134e+01 4.321002960000000392e+00
9.365174939999999992e+01 3.263280559999999753e+01 2.346876719999999850e+01 3.615082919999999866e+00
9.369333170000000166e+01 3.263280559999999753e+01 2.361300479999999880e+01 3.798333720000000024e+00
5.527943479999999710e+01 4.997355559999999741e+01 1.764283680000000132e+01 1.635428664000000154e+01
5.532101030000000463e+01 4.997355559999999741e+01 1.794565079999999924e+01 1.647901475999999832e+01
8.746503839999999741e+01 4.482541669999999812e+01 2.703027600000000064e+01 4.956216480000000146e+00
8.750675139999999885e+01 4.482541669999999812e+01 2.728551960000000065e+01 5.177633039999999909e+00
1.836906730000000110e+01 5.078408329999999893e+01 1.513158156000000076e+01 1.963362311999999932e+01
1.841507449999999935e+01 5.078408329999999893e+01 1.555693991999999959e+01 1.961264051999999936e+01
1.098856539000000083e+02 3.701522219999999663e+01 2.812074120000000121e+01 8.143354439999999528e+00
1.099319399000000033e+02 3.701522219999999663e+01 2.774962800000000129e+01 8.819404920000000203e+00
7.370027499999999065e+01 5.570875000000000199e+01 1.911301560000000066e+01 1.426220711999999935e+01
7.374202760000000012e+01 5.570875000000000199e+01 1.958580359999999843e+01 1.418687820000000066e+01
1.054113698000000028e+02 4.963983329999999938e+01 2.650104359999999915e+01 3.480223679999999931e+00
1.054574365000000000e+02 4.963983329999999938e+01 2.563602840000000072e+01 3.547053360000000044e+00
4.287370680000000078e+01 6.094122219999999857e+01 1.950798104640000119e+01 1.674774251999999919e+01
4.291527359999999902e+01 6.094122219999999857e+01 1.944132720480000032e+01 1.652185980000000143e+01
9.504052040000000545e+01 6.157588890000000248e+01 2.899145160000000132e+01 1.187110224000000080e+01
9.508667239999999765e+01 6.157588890000000248e+01 2.922239880000000056e+01 1.173974544000000009e+01
1.262694429999999954e+02 5.295780560000000037e+01 2.512014479999999850e+01 5.389958880000000008e+00
1.263113367999999923e+02 5.295780560000000037e+01 2.474463959999999929e+01 5.645870279999999575e+00
6.514408500000000402e+01 7.005941669999999988e+01 2.277777599999999936e+01 1.499814287999999962e+01
6.518613349999999684e+01 7.005941669999999988e+01 2.273392079999999993e+01 1.499271264000000059e+01
1.229067255999999873e+02 6.578094439999999565e+01 2.971857960000000176e+01 4.189588200000000207e+00
1.699135779999999940e+01 6.312358329999999995e+01 1.640872511999999972e+01 1.090696175999999973e+01
1.703309279999999859e+01 6.312358329999999995e+01 1.615176684000000051e+01 1.092368160000000010e+01
1.495277770000000146e+02 5.364572220000000158e+01 2.561597640000000098e+01 9.143114759999999563e+00
1.495777611000000036e+02 5.364572220000000158e+01 2.615466239999999942e+01 9.095307840000000255e+00
1.496408456999999999e+02 5.364572220000000158e+01 2.569897800000000032e+01 9.134006039999999160e+00
1.496825650000000110e+02 5.364572220000000158e+01 2.538529559999999918e+01 9.201327479999999781e+00
1.554850708999999824e+02 6.604155559999999525e+01 1.374083279999999974e+01 1.656775620000000160e+01
2.097634289999999879e+01 7.733791669999999385e+01 3.654347508000000033e+01 1.654487531999999916e+01
2.102212970000000070e+01 7.733791669999999385e+01 3.636662867999999804e+01 1.636760591999999903e+01
2.277917999999999887e-01 4.876380559999999775e+01 1.549041624000000006e+01 2.101689756000000031e+01
2.698421999999999765e-01 4.876380559999999775e+01 1.567145015999999913e+01 2.112695172000000099e+01
3.437143795000000068e+02 6.973677779999999871e+01 2.734230528000000149e+01 1.563275916000000088e+01
3.437643578999999932e+02 6.973677779999999871e+01 2.747603627999999887e+01 1.552329648000000084e+01
3.428005334000000062e+02 5.725041670000000238e+01 1.862290619999999919e+01 2.019176136000000099e+01
3.428463540000000194e+02 5.725041670000000238e+01 1.902524400000000071e+01 1.999220255999999907e+01
3.132811045999999919e+02 5.910019439999999946e+01 1.386552672000000008e+01 2.278168667999999997e+01
3.133275363999999854e+02 5.910019439999999946e+01 1.297295568000000010e+01 2.274937272000000021e+01
2.965399057000000198e+02 5.068380559999999946e+01 1.367059320000000078e+01 1.617027119999999840e+01
2.965815953999999692e+02 5.068380559999999946e+01 1.380345480000000080e+01 1.598343335999999937e+01
3.257878496999999811e+02 4.907274999999999920e+01 1.085804279999999977e+01 1.542084984000000070e+01
3.258295864000000392e+02 4.907274999999999920e+01 1.075048776000000039e+01 1.556499203999999992e+01
2.902964226000000281e+02 3.914441670000000073e+01 1.082279879999999928e+01 1.847305116000000069e+01
2.903381570000000238e+02 3.914441670000000073e+01 1.094891400000000026e+01 1.845031463999999843e+01
2.749723357999999962e+02 2.495291669999999939e+01 9.267801453194630668e+00 2.204314769561360876e+01
2.750181547000000251e+02 2.495291669999999939e+01 9.561938187156854951e+00 2.212146414090760160e+01
3.104860874999999965e+02 4.047155560000000207e+01 2.503505160000000007e+00 2.629696320000000043e+01
3.105277801999999951e+02 4.047155560000000207e+01 2.478829680000000035e+00 2.638967832000000158e+01
2.893916831000000229e+02 2.652719439999999906e+01 7.161947999999999759e+00 2.132319744000000128e+01
2.894339892000000418e+02 2.652719439999999906e+01 7.297700400000000087e+00 2.116063008000000067e+01
3.442205288000000110e+02 4.347533330000000262e+01 1.224662507999999939e+01 2.312353152000000023e+01
3.442623588000000154e+02 4.347533330000000262e+01 1.267768799999999985e+01 2.312872199999999978e+01
3.051667480000000410e+02 2.895936109999999886e+01 6.215158800000000205e+00 1.870388495999999989e+01
3.052088808999999969e+02 2.895936109999999886e+01 5.764748400000000217e+00 1.910548547999999869e+01
2.911102161999999680e+02 1.363227780000000067e+01 9.305172000000000665e+00 2.179789488000000119e+01
2.911558619999999564e+02 1.363227780000000067e+01 9.093934799999999541e+00 2.161481724000000071e+01
3.243215236000000345e+02 3.372363889999999742e+01 7.080469199999999574e+00 2.694746879999999933e+01
3.243635280000000307e+02 3.372363889999999742e+01 7.326476640000000096e+00 2.712567239999999913e+01
3.046386173999999869e+02 1.638005559999999861e+01 6.457255199999999640e+00 2.061839772000000082e+01
3.046847496999999976e+02 1.638005559999999861e+01 6.420866400000000418e+00 2.073321108000000024e+01
3.193266790000000128e+02 2.156905559999999866e+01 5.235109200000000129e+00 2.829552083999999823e+01
3.193686405999999920e+02 2.156905559999999866e+01 5.254743600000000292e+00 2.829559031999999874e+01
3.388107006999999840e+02 3.196724999999999994e+01 1.399715531999999918e+01 2.574566423999999998e+01
3.388564878999999905e+02 3.196724999999999994e+01 1.397006387999999966e+01 2.558194991999999957e+01
3.198125034999999912e+02 9.226666700000000887e+00 9.206690399999999386e+00 1.879983248399999951e+01
3.198588174000000208e+02 9.226666700000000887e+00 8.986637520000000379e+00 1.901963516400000032e+01
3.332647567000000208e+02 1.820433329999999827e+01 1.270149407999999980e+01 2.713799159999999944e+01
3.333110732000000098e+02 1.820433329999999827e+01 1.282294367999999984e+01 2.709816479999999927e+01
3.348553427000000511e+02 5.763472199999999823e+00 1.454280083999999995e+01 2.613845635199999862e+01
3.349014428000000407e+02 5.763472199999999823e+00 1.437523739999999961e+01 2.595185341199999840e+01
3.464526741000000243e+02 1.971349999999999980e+01 1.390370039999999996e+01 2.627868923999999851e+01
3.464945554999999899e+02 1.971349999999999980e+01 1.411688015999999912e+01 2.608611155999999909e+01
3.492393445999999813e+02 6.771111099999999716e+00 1.530963359999999973e+01 2.449470556800000054e+01
3.492810100000000375e+02 6.771111099999999716e+00 1.541423123999999945e+01 2.451735334800000032e+01
3.487188694999999825e+02 -1.504255560000000003e+01 1.589037876000000082e+01 2.229864480000000171e+01
3.487647154000000000e+02 -1.504255560000000003e+01 1.546261739999999918e+01 2.259952668000000031e+01

View File

@@ -0,0 +1,5 @@
#
# SAO RAS Zeiss-1000 pointing precision measurements
#
# Format:
# ENCODER_HA(degs) ENCODER_DEC(degs) DIFF_HA(CELESTIAL-ENCODER, arcsecs) DIFF_DEC(CELESTIAL-ENCODER, arcsecs)

36
update_iers_data.sh Executable file
View File

@@ -0,0 +1,36 @@
#!/bin/bash
#
# $1 - output filename
#
if [[ $# -eq 0 ]]; then
res_file="mcc_ccte_iers_default.h"
else
res_file=$1
fi
echo -e '#pragma once\n
#include <string>\n
namespace mcc::ccte::iers::defaults\n
{
// https://hpiers.obspm.fr/iers/bul/bulc/Leap_Second.dat\n
static std::string MCC_DEFAULT_LEAP_SECONDS_FILE = R"--(\n' > $res_file
wget --quiet https://hpiers.obspm.fr/iers/bul/bulc/Leap_Second.dat -O - >> $res_file
echo -e ')--";\n\n' >> $res_file
echo -e '// https://datacenter.iers.org/data/latestVersion/bulletinA.txt\n
static std::string MCC_DEFAULT_IERS_BULLETIN_A_FILE = R"--(\n' >> $res_file
wget --quiet https://datacenter.iers.org/data/latestVersion/bulletinA.txt -O - >> $res_file
echo -e ')--";\n
} // namespace mcc::ccte::iers::defaults\n' >> $res_file