mirror of
https://github.com/slsdetectorgroup/aare.git
synced 2026-08-13 05:20:29 +02:00
Dev/matterhorn decoder (#324)
- 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:
@@ -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:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user