mirror of
https://github.com/slsdetectorgroup/aare.git
synced 2025-12-29 08:21:28 +01:00
@@ -169,6 +169,14 @@ Coordinate2D Interpolator::transform_eta_values(const Eta2<T> &eta) const {
|
||||
auto ix = last_smaller(m_etabinsx, eta.x);
|
||||
auto iy = last_smaller(m_etabinsy, eta.y);
|
||||
|
||||
if (static_cast<ssize_t>(ix) >= m_etabinsx.size() - 1 ||
|
||||
static_cast<ssize_t>(iy) >= m_etabinsy.size() - 1 ||
|
||||
static_cast<ssize_t>(ie) >= m_energy_bins.size() - 1)
|
||||
throw std::runtime_error(
|
||||
fmt::format("Eta values out of bounds of eta distribution: eta.x = "
|
||||
"{:.4f}, eta.y = {:.4f}, energy = {:.4f}",
|
||||
eta.x, eta.y, eta.sum));
|
||||
|
||||
// TODO: bilinear interpolation only works if all bins have a size > 1 -
|
||||
// otherwise bilinear interpolation with zero values which skew the
|
||||
// results
|
||||
|
||||
@@ -11,9 +11,9 @@ using namespace aare;
|
||||
|
||||
TEST_CASE("Test new Interpolation API", "[Interpolation]") {
|
||||
|
||||
NDArray<double, 1> energy_bins(std::array<ssize_t, 1>{2});
|
||||
NDArray<double, 1> etax_bins(std::array<ssize_t, 1>{4}, 0.0);
|
||||
NDArray<double, 1> etay_bins(std::array<ssize_t, 1>{4}, 0.0);
|
||||
NDArray<double, 1> energy_bins(std::array<double, 2>{0.0, 100.0});
|
||||
NDArray<double, 1> etax_bins(std::array<double, 4>{0.0, 0.3, 0.6, 1.0});
|
||||
NDArray<double, 1> etay_bins(std::array<double, 4>{0.0, 0.3, 0.6, 1.0});
|
||||
NDArray<double, 3> eta_distribution(std::array<ssize_t, 3>{3, 3, 1}, 0.0);
|
||||
|
||||
Interpolator interpolator(eta_distribution.view(), etax_bins.view(),
|
||||
|
||||
Reference in New Issue
Block a user