added correct decoder for ADC-SAR-05-06-07-08 ASIC (#266)

Adding function to correctly decode the ADC-SAR-05-06-07-08 Chip. 

Co-authored-by: Erik Fröjdh <erik.frojdh@psi.ch>
This commit is contained in:
siebsi
2026-01-20 16:38:06 +01:00
committed by GitHub
parent f79ee55430
commit 31f3a60cd3
4 changed files with 66 additions and 1 deletions

View File

@@ -27,6 +27,30 @@ using namespace ::aare;
void define_ctb_raw_file_io_bindings(py::module &m) {
m.def("adc_sar_05_06_07_08decode64to16", [](py::array_t<uint8_t> input) {
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) /
static_cast<ssize_t>(bits_per_byte)};
py::array_t<uint16_t> output(shape);
// Create a view of the input and output arrays
NDView<uint64_t, 2> input_view(
reinterpret_cast<uint64_t *>(input.mutable_data()),
{output.shape(0), output.shape(1)});
NDView<uint16_t, 2> output_view(output.mutable_data(),
{output.shape(0), output.shape(1)});
adc_sar_05_06_07_08decode64to16(input_view, output_view);
return output;
});
m.def("adc_sar_05_decode64to16", [](py::array_t<uint8_t> input) {
if (input.ndim() != 2) {
throw std::runtime_error(