This commit is contained in:
2026-03-27 12:25:36 +03:00
parent d3bab396a2
commit d4721d7b67
2 changed files with 48 additions and 2 deletions

View File

@@ -114,6 +114,7 @@ public:
std::vector<double> model_colon{}, model_colat{}; // fitting model values std::vector<double> model_colon{}, model_colat{}; // fitting model values
std::vector<double> colon_res{}, colat_res{}; // target - model std::vector<double> colon_res{}, colat_res{}; // target - model
std::vector<double> colon_weight{}, colat_weight; // Tukey's weights
#ifdef USE_BSPLINE_PCM #ifdef USE_BSPLINE_PCM
int bspline_fit_err{}; // bivariate B-spline fitting exit code (see FITPACK) int bspline_fit_err{}; // bivariate B-spline fitting exit code (see FITPACK)
@@ -576,6 +577,9 @@ protected:
result.colon_res.resize(numberOfPoints()); result.colon_res.resize(numberOfPoints());
result.colat_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) { for (size_t i = 0; i < numberOfPoints(); ++i) {
result.colon_res[i] = _table.colon_res[i] - result.model_colon[i]; // = target - model 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.colat_res[i] = _table.colat_res[i] - result.model_colat[i]; // = target - model

View File

@@ -16,6 +16,23 @@ int main(int narg, char* argv[])
MccDefaultPCM<MOUNT_TYPE>::pcm_data_t fit_pcm_data; 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); // [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::ifstream fst;
std::string fname = "z1000_pcm_measu.data"; std::string fname = "z1000_pcm_measu.data";
@@ -63,7 +80,7 @@ int main(int narg, char* argv[])
return 1; 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("\tNUM OF ITERS: {}", r.final_iter);
std::println("FITTED COEFFS:"); std::println("FITTED COEFFS:");
@@ -80,11 +97,36 @@ int main(int narg, char* argv[])
std::println("\n\n{:*^40}\n", " FITTED DIFFS "); std::println("\n\n{:*^40}\n", " FITTED DIFFS ");
auto tab = pcm_cstr.getTable(); auto tab = pcm_cstr.getTable();
for (size_t i = 0; i < pcm_cstr.numberOfPoints(); ++i) { 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(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]), MccAngleFancyString(tab.colat_res[i]), MccAngleFancyString(r.model_colat[i]),
std::abs(r.colat_res[i] / tab.colat_res[i]) * 100.0); std::abs(r.colat_res[i] / tab.colat_res[i]) * 100.0);
} }
return 0; return 0;
} }