...
This commit is contained in:
@@ -188,27 +188,23 @@ public:
|
|||||||
}
|
}
|
||||||
} else if constexpr (KIND == NORM_KIND_0_180) {
|
} else if constexpr (KIND == NORM_KIND_0_180) {
|
||||||
if (_angleInRads < -std::numbers::pi) {
|
if (_angleInRads < -std::numbers::pi) {
|
||||||
// _angleInRads = 2.0 * std::numbers::pi + _angleInRads;
|
|
||||||
_angleInRads = MCC_TWO_PI + _angleInRads;
|
_angleInRads = MCC_TWO_PI + _angleInRads;
|
||||||
} else if (_angleInRads < 0.0) {
|
} else if (_angleInRads < 0.0) {
|
||||||
_angleInRads = -_angleInRads;
|
_angleInRads = -_angleInRads;
|
||||||
}
|
}
|
||||||
} else if constexpr (KIND == NORM_KIND_180_180) {
|
} else if constexpr (KIND == NORM_KIND_180_180) {
|
||||||
if (_angleInRads > std::numbers::pi) {
|
if (_angleInRads > std::numbers::pi) {
|
||||||
// _angleInRads = 2.0 * std::numbers::pi - _angleInRads;
|
_angleInRads -= MCC_TWO_PI;
|
||||||
// _angleInRads = MCC_TWO_PI - _angleInRads;
|
|
||||||
_angleInRads = _angleInRads - MCC_TWO_PI;
|
|
||||||
} else if (_angleInRads < -std::numbers::pi) {
|
} else if (_angleInRads < -std::numbers::pi) {
|
||||||
// _angleInRads += 2.0 * std::numbers::pi;
|
|
||||||
_angleInRads += MCC_TWO_PI;
|
_angleInRads += MCC_TWO_PI;
|
||||||
}
|
}
|
||||||
} else if constexpr (KIND == NORM_KIND_90_90) {
|
} else if constexpr (KIND == NORM_KIND_90_90) {
|
||||||
if (_angleInRads >= 1.5 * std::numbers::pi) {
|
if (_angleInRads >= 1.5 * std::numbers::pi) {
|
||||||
_angleInRads = _angleInRads - 2.0 * std::numbers::pi;
|
// _angleInRads = _angleInRads - 2.0 * std::numbers::pi;
|
||||||
|
_angleInRads -= MCC_TWO_PI;
|
||||||
} else if (_angleInRads >= std::numbers::pi / 2.0) {
|
} else if (_angleInRads >= std::numbers::pi / 2.0) {
|
||||||
_angleInRads = std::numbers::pi - _angleInRads;
|
_angleInRads = std::numbers::pi - _angleInRads;
|
||||||
} else if (_angleInRads <= -1.5 * std::numbers::pi) {
|
} else if (_angleInRads <= -1.5 * std::numbers::pi) {
|
||||||
// _angleInRads += 2.0 * std::numbers::pi;
|
|
||||||
_angleInRads += MCC_TWO_PI;
|
_angleInRads += MCC_TWO_PI;
|
||||||
} else if (_angleInRads <= -std::numbers::pi / 2.0) {
|
} else if (_angleInRads <= -std::numbers::pi / 2.0) {
|
||||||
_angleInRads = -(std::numbers::pi + _angleInRads);
|
_angleInRads = -(std::numbers::pi + _angleInRads);
|
||||||
@@ -491,6 +487,14 @@ public:
|
|||||||
|
|
||||||
MccNormalizedAngle& operator=(MccNormalizedAngle const&) = default;
|
MccNormalizedAngle& operator=(MccNormalizedAngle const&) = default;
|
||||||
MccNormalizedAngle& operator=(MccNormalizedAngle&&) = 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>
|
class MccAngleRA_ICRS : public MccNormalizedAngle<MccAngle::NORM_KIND_0_360>
|
||||||
|
|||||||
@@ -427,13 +427,13 @@ protected:
|
|||||||
if constexpr (std::same_as<ref_coordpair_t, MccSkyHADEC_OBS>) {
|
if constexpr (std::same_as<ref_coordpair_t, MccSkyHADEC_OBS>) {
|
||||||
theta.resize(numberOfPoints());
|
theta.resize(numberOfPoints());
|
||||||
phi.resize(numberOfPoints());
|
phi.resize(numberOfPoints());
|
||||||
theta_hw = theta;
|
|
||||||
phi_hw = phi;
|
|
||||||
|
|
||||||
for (size_t i = 0; i < numberOfPoints(); ++i) {
|
for (size_t i = 0; i < numberOfPoints(); ++i) {
|
||||||
theta_hw[i] = _hwY[i] + MCC_HALF_PI;
|
theta[i] = _hwY[i] + MCC_HALF_PI;
|
||||||
phi_hw[i] = _hwX[i] + std::numbers::pi;
|
phi[i] = _hwX[i] + std::numbers::pi;
|
||||||
}
|
}
|
||||||
|
theta_hw = theta;
|
||||||
|
phi_hw = phi;
|
||||||
|
|
||||||
for (size_t i = 0; i < tx.size(); ++i) {
|
for (size_t i = 0; i < tx.size(); ++i) {
|
||||||
tx[i] += std::numbers::pi;
|
tx[i] += std::numbers::pi;
|
||||||
@@ -472,26 +472,31 @@ protected:
|
|||||||
bsplines::fitpack_eval_spl2d(ty, tx, pcm_data.bspline.coeffsY, theta_hw, phi_hw,
|
bsplines::fitpack_eval_spl2d(ty, tx, pcm_data.bspline.coeffsY, theta_hw, phi_hw,
|
||||||
result.model_colatRES); // get fitted residuals!!!
|
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) {
|
if (pcm_data.type == MccDefaultPCMType::PCM_TYPE_BSPLINE) {
|
||||||
// here both direct and inverse coefficients will be calculated
|
// here both direct and inverse coefficients will be calculated
|
||||||
pcm_data.inverseBspline.coeffsX.resize(Ncoeffs);
|
pcm_data.inverseBspline.coeffsX.resize(Ncoeffs);
|
||||||
pcm_data.inverseBspline.coeffsY.resize(Ncoeffs);
|
pcm_data.inverseBspline.coeffsY.resize(Ncoeffs);
|
||||||
|
|
||||||
std::vector<double> theta_tag(numberOfPoints());
|
|
||||||
|
|
||||||
// inverse (encoder = celestial + pcm)
|
// inverse (encoder = celestial + pcm)
|
||||||
|
|
||||||
std::vector<double> colon_err = _colonRES;
|
|
||||||
std::vector<double> colat_err = _colatRES;
|
|
||||||
if constexpr (std::same_as<ref_coordpair_t, MccSkyHADEC_OBS>) {
|
if constexpr (std::same_as<ref_coordpair_t, MccSkyHADEC_OBS>) {
|
||||||
theta_tag = theta;
|
theta_tag = theta;
|
||||||
phi_tag = phi;
|
phi_tag = phi;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < colat_err.size(); ++i) {
|
std::vector<double> colon_res = _colonRES;
|
||||||
colon_err[i] = -colon_err[i];
|
std::vector<double> colat_res = _colatRES;
|
||||||
colat_err[i] = -colat_err[i];
|
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>) {
|
if constexpr (std::same_as<ref_coordpair_t, MccSkyHADEC_OBS>) {
|
||||||
theta_tag[i] = _targetCOLAT[i] + MCC_HALF_PI;
|
theta_tag[i] = _targetCOLAT[i] + MCC_HALF_PI;
|
||||||
@@ -499,14 +504,14 @@ protected:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result.bspline_fit_err[2] = bsplines::fitpack_sphere_fit(theta_tag, phi_tag, colon_err, 1.0, ty, tx,
|
result.bspline_fit_err[2] = bsplines::fitpack_sphere_fit(theta_tag, phi_tag, colon_res, 1.0, ty, tx,
|
||||||
pcm_data.bspline.inverseCoeffsX, resi2x);
|
pcm_data.bspline.inverseCoeffsX, resi2x);
|
||||||
if (result.bspline_fit_err[2] > 0) {
|
if (result.bspline_fit_err[2] > 0) {
|
||||||
result.error = MccPCMFitterErrorCode::ERROR_BSPLINE_FIT;
|
result.error = MccPCMFitterErrorCode::ERROR_BSPLINE_FIT;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
result.bspline_fit_err[3] = bsplines::fitpack_sphere_fit(theta_tag, phi_tag, colat_err, 1.0, ty, tx,
|
result.bspline_fit_err[3] = bsplines::fitpack_sphere_fit(theta_tag, phi_tag, colat_res, 1.0, ty, tx,
|
||||||
pcm_data.bspline.inverseCoeffsY, resi2y);
|
pcm_data.bspline.inverseCoeffsY, resi2y);
|
||||||
if (result.bspline_fit_err[3] > 0) {
|
if (result.bspline_fit_err[3] > 0) {
|
||||||
result.error = MccPCMFitterErrorCode::ERROR_BSPLINE_FIT;
|
result.error = MccPCMFitterErrorCode::ERROR_BSPLINE_FIT;
|
||||||
@@ -518,9 +523,14 @@ protected:
|
|||||||
|
|
||||||
bsplines::fitpack_eval_spl2d(ty, tx, pcm_data.bspline.inverseCoeffsY, theta_tag, phi_tag,
|
bsplines::fitpack_eval_spl2d(ty, tx, pcm_data.bspline.inverseCoeffsY, theta_tag, phi_tag,
|
||||||
result.inv_model_colatRES); // get fitted residuals!!!
|
result.inv_model_colatRES); // get fitted residuals!!!
|
||||||
}
|
|
||||||
|
|
||||||
computeModelResi(result);
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -678,7 +688,14 @@ protected:
|
|||||||
result.colon_weight = {weights.begin(), weights.begin() + numberOfPoints()};
|
result.colon_weight = {weights.begin(), weights.begin() + numberOfPoints()};
|
||||||
result.colat_weight = {weights.begin() + numberOfPoints(), weights.end()};
|
result.colat_weight = {weights.begin() + numberOfPoints(), weights.end()};
|
||||||
|
|
||||||
computeModelResi(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
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,9 +23,10 @@ int main(int narg, char* argv[])
|
|||||||
size_t decM = 10; // number of B-spline inner knots along DEC-axis
|
size_t decM = 10; // number of B-spline inner knots along DEC-axis
|
||||||
|
|
||||||
double ha_step = 360.0_degs / (haM - 1);
|
double ha_step = 360.0_degs / (haM - 1);
|
||||||
fit_pcm_data.bspline.knotsX.resize(haM); // [0, 360]
|
fit_pcm_data.bspline.knotsX.resize(haM);
|
||||||
for (size_t i = 0; i < haM; ++i) {
|
for (size_t i = 0; i < haM; ++i) {
|
||||||
fit_pcm_data.bspline.knotsX[i] = i * ha_step;
|
// 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_start = -25.0_degs;
|
||||||
@@ -162,11 +163,10 @@ int main(int narg, char* argv[])
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
for (size_t i = 0; i < pcm_fitter.numberOfPoints(); ++i) {
|
for (size_t i = 0; i < pcm_fitter.numberOfPoints(); ++i) {
|
||||||
std::println("{} {} {} {:6.2f}% ({:5.3f}) {} {} {:6.2f}% ({:5.3f}) (HA = {} DEC = {})", i,
|
std::println("{} {} {} {:6.2f}% {} {} {:6.2f}% (HA = {} DEC = {})", i,
|
||||||
MccAngleFancyString(pcm_tab[i].res.x()), MccAngleFancyString(fr.model_colonRES[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],
|
std::abs(fr.colon_err[i]) / pcm_tab[i].res.x() * 100.0, MccAngleFancyString(pcm_tab[i].res.y()),
|
||||||
MccAngleFancyString(pcm_tab[i].res.y()), MccAngleFancyString(fr.model_colatRES[i]),
|
MccAngleFancyString(fr.model_colatRES[i]), std::abs(fr.colat_err[i]) / pcm_tab[i].res.y() * 100.0,
|
||||||
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());
|
pcm_tab[i].hw.x().sexagesimal(true), pcm_tab[i].hw.y().sexagesimal());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user