This commit is contained in:
2026-03-24 16:45:37 +03:00
parent 0182844af6
commit 2c561f7259
2 changed files with 63 additions and 18 deletions

View File

@@ -409,7 +409,7 @@ protected:
Eigen::VectorXd r = mask.select(1.0 - u * u, 0.0);
tukey_weight = r * r;
tukey_weight = r.array() * r.array();
};
auto gastwirth_est = [](Eigen::VectorXd const& resi) {
@@ -422,6 +422,10 @@ protected:
// 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};
@@ -429,15 +433,16 @@ protected:
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(n_coeffs), new_beta(n_coeffs);
Eigen::VectorXd y(2 * numberOfPoints()), beta = Eigen::VectorXd::Zero(n_coeffs), new_beta(n_coeffs);
Eigen::RowVectorXd row(n_coeffs);
double tgY, cosY, rcosY, cosX, sinX, cosPhi = std::cos(pcm_data.siteLatitude),
sinPhi = std::sin(pcm_data.siteLatitude);
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]);
@@ -466,15 +471,12 @@ protected:
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 * std::sin(_table.target_colat[i]) - sinPhi * cosY, 0.0, 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 * std::sin(_table.target_colat[i]) - sinPhi * cosY, 0.0, 1.0 / cosX;
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 * std::sin(_table.target_colat[i]) - sinPhi * cosY,
0.0;
row << 0.0, 1.0, 0.0, 0.0, sinX, cosX, cosPhi * cosX * sinY - sinPhi * cosY, 0.0;
}
X.row(i + numberOfPoints()) = row;
@@ -504,6 +506,8 @@ protected:
}
beta = new_beta;
resi = y - X * beta;
}
pcm_data.geomCoefficients.zeroPointX = new_beta(0);
@@ -521,6 +525,8 @@ protected:
Eigen::VectorXd model = X * new_beta;
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());
for (size_t i = 0; i < numberOfPoints(); ++i) {
result.colon_res[i] = _table.colon_res[i] - result.model_colon[i]; // = target - model