python bindings

This commit is contained in:
froejdh_e
2025-04-16 18:08:47 +02:00
parent 73f46e4d2b
commit 3760fd5ed0
4 changed files with 149 additions and 1 deletions

View File

@@ -10,6 +10,8 @@
#include "aare/decode.hpp"
// #include "aare/fClusterFileV2.hpp"
#include "np_helper.hpp"
#include <cstdint>
#include <filesystem>
#include <pybind11/iostream.h>
@@ -65,6 +67,27 @@ m.def("adc_sar_04_decode64to16", [](py::array_t<uint8_t> input) {
return output;
});
m.def("apply_custom_weights", [](py::array_t<uint16_t> input, py::array_t<double> weights) {
if (input.ndim() != 2) {
throw std::runtime_error("Only 2D arrays are supported at this moment");
}
// Create a 2D output array with the same shape as the input
std::vector<ssize_t> shape{input.shape(0), input.shape(1)};
py::array_t<double> output(shape);
auto weights_view = make_view_1d(weights);
// Create a view of the input and output arrays
NDView<uint16_t, 2> input_view(input.mutable_data(), {input.shape(0), input.shape(1)});
NDView<double, 2> output_view(output.mutable_data(), {output.shape(0), output.shape(1)});
apply_custom_weights(input_view, output_view, weights_view);
return output;
});
py::class_<CtbRawFile>(m, "CtbRawFile")
.def(py::init<const std::filesystem::path &>())
.def("read_frame",