Dev/matterhorn decoder (#324)
Build on RHEL9 / build (push) Successful in 2m49s
Build on RHEL8 / build (push) Successful in 3m35s
Run tests using data on local RHEL8 / build (push) Successful in 4m1s
Build on local RHEL8 / build (push) Successful in 3m9s

- reshape image directly in decoder such that first dimension is num
counters
- take into account chip artefact in decoder.

---------

Co-authored-by: Erik Fröjdh <erik.frojdh@psi.ch>
This commit is contained in:
2026-06-11 15:04:20 +02:00
committed by GitHub
co-authored by Erik Fröjdh
parent 2041c7310a
commit ee7503082d
4 changed files with 24 additions and 14 deletions
+8 -4
View File
@@ -81,6 +81,10 @@ class Matterhorn10Transform:
A matterhorn chip has 256 columns and 256 rows.
A matterhornchip with dynamic range 16 and 2 counters thus requires
256*256*16*2/(2*64) = 1024 transceiver samples. (Per default 2 channels are enabled per transceiver sample, each channel storing 64 bits)
.. note::
Due to an artefact in the chip, the transformation only fully supports 2 or 4 counters. Also if you enable 2 counters you can only select counter 1 and 2 or 0, 3 to get reasonable results.
Otherwise only the first half of the image is correct.
"""
def __init__(self, dynamic_range : int, num_counters : int):
self.pixel_map = _aare.GenerateMatterhorn10PixelMap(dynamic_range, num_counters)
@@ -105,7 +109,7 @@ class Matterhorn10Transform:
checks if data is compatible for transformation
:param data: data to be transformed, expected to be a 1D numpy array of uint8
:type data: np.ndarray
:type data: np.ndarray(n_counters, n_rows, n_cols)
:raises ValueError: if not compatible
"""
expected_size = (Matterhorn10.nRows*Matterhorn10.nCols*self.num_counters*self.dynamic_range)//8 # read_frame returns data in uint8_t
@@ -118,11 +122,11 @@ class Matterhorn10Transform:
def __call__(self, data):
self.data_compatibility(data)
if self.dynamic_range == 16:
return np.take(data.view(np.uint16), self.pixel_map)
return np.take(data.view(np.uint16), self.pixel_map).reshape(self.num_counters, Matterhorn10.nRows, Matterhorn10.nCols)
elif self.dynamic_range == 8:
return np.take(data.view(np.uint8), self.pixel_map)
return np.take(data.view(np.uint8), self.pixel_map).reshape(self.num_counters, Matterhorn10.nRows, Matterhorn10.nCols)
else: #dynamic range 4
return np.take(_aare.expand4to8bit(data.view(np.uint8)), self.pixel_map)
return np.take(_aare.expand4to8bit(data.view(np.uint8)), self.pixel_map).reshape(self.num_counters, Matterhorn10.nRows, Matterhorn10.nCols)
class Mythen302Transform:
"""