From d4721d7b672ee424fabc8659185bdce4307a2d8f Mon Sep 17 00:00:00 2001 From: "Timur A. Fatkhullin" Date: Fri, 27 Mar 2026 12:25:36 +0300 Subject: [PATCH] ... --- include/mcc/mcc_pcm_construct.h | 4 +++ tests/mcc_pcm_z1000_test.cpp | 46 +++++++++++++++++++++++++++++++-- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/include/mcc/mcc_pcm_construct.h b/include/mcc/mcc_pcm_construct.h index 17a468e..d65beb3 100644 --- a/include/mcc/mcc_pcm_construct.h +++ b/include/mcc/mcc_pcm_construct.h @@ -114,6 +114,7 @@ public: std::vector model_colon{}, model_colat{}; // fitting model values std::vector colon_res{}, colat_res{}; // target - model + std::vector colon_weight{}, colat_weight; // Tukey's weights #ifdef USE_BSPLINE_PCM int bspline_fit_err{}; // bivariate B-spline fitting exit code (see FITPACK) @@ -576,6 +577,9 @@ protected: 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 diff --git a/tests/mcc_pcm_z1000_test.cpp b/tests/mcc_pcm_z1000_test.cpp index bda506c..38d2c06 100644 --- a/tests/mcc_pcm_z1000_test.cpp +++ b/tests/mcc_pcm_z1000_test.cpp @@ -16,6 +16,23 @@ int main(int narg, char* argv[]) MccDefaultPCM::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); // [0, 360] + for (size_t i = 0; i < haM; ++i) { + fit_pcm_data.bspline.knotsX[i] = i * ha_step; + } + + 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"; @@ -63,7 +80,7 @@ int main(int narg, char* argv[]) return 1; } - std::println("\n\n{:*^40}\n", " FITTED RESULT "); + std::println("\n\n{:*^40}\n", " FITTED RESULT (TYPE = GEOMETRY) "); std::println("\tNUM OF ITERS: {}", r.final_iter); std::println("FITTED COEFFS:"); @@ -80,11 +97,36 @@ int main(int narg, char* argv[]) 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("{}\t {} {} {:6.2f}%\t{} {} {:6.2f}%", i, MccAngleFancyString(tab.colon_res[i]), + std::println("{} {} {} {:6.2f}% ({:5.3f}) {} {} {:6.2f}% ({:5.3f})", i, + MccAngleFancyString(tab.colon_res[i]), MccAngleFancyString(r.model_colon[i]), + std::abs(r.colon_res[i] / tab.colon_res[i]) * 100.0, r.colon_weight[i], + MccAngleFancyString(tab.colat_res[i]), MccAngleFancyString(r.model_colat[i]), + std::abs(r.colat_res[i] / tab.colat_res[i]) * 100.0, r.colat_weight[i]); + } + + + + 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); + + if (r.error) { + std::println("error: {}", r.error.message()); + std::println("b-spline error: {}", r.bspline_fit_err); + return 1; + } + + std::println("\n\n{:*^40}\n", " FITTED DIFFS "); + for (size_t i = 0; i < pcm_cstr.numberOfPoints(); ++i) { + std::println("{} {} {} {:6.2f}% {} {} {:6.2f}%", i, MccAngleFancyString(tab.colon_res[i]), MccAngleFancyString(r.model_colon[i]), std::abs(r.colon_res[i] / tab.colon_res[i]) * 100.0, MccAngleFancyString(tab.colat_res[i]), MccAngleFancyString(r.model_colat[i]), std::abs(r.colat_res[i] / tab.colat_res[i]) * 100.0); } + + return 0; } \ No newline at end of file