Merge pull request #1376 from slsdetectorgroup/dev/mh1decode
All checks were successful
Build on local RHEL9 / build (push) Successful in 1m25s
Build on RHEL9 / build (push) Successful in 3m16s
Build on local RHEL8 / build (push) Successful in 3m33s
Build on RHEL8 / build (push) Successful in 4m40s

pyctbgui decoder for Matterhorn1 16 bits (1 and 4 counters)
This commit is contained in:
2026-01-29 14:06:16 +01:00
committed by GitHub
6 changed files with 71 additions and 6 deletions

View File

@@ -1,5 +1,6 @@
import logging import logging
from functools import partial from functools import partial
import pyctbgui.utils.pixelmap as pm
import random import random
from pathlib import Path from pathlib import Path
@@ -415,13 +416,26 @@ class PlotTab(QtWidgets.QWidget):
self.mainWindow.read_timer.start(Defines.Time_Plot_Refresh_ms) self.mainWindow.read_timer.start(Defines.Time_Plot_Refresh_ms)
def setPixelMap(self): def setPixelMap(self):
if self.view.comboBoxPlot.currentText() == "Matterhorn": if self.view.comboBoxPlot.currentText() == "Matterhorn02":
self.mainWindow.nTransceiverRows = Defines.Matterhorn.nRows print("Setting pixel map for Matterhorn02")
self.mainWindow.nTransceiverCols = Defines.Matterhorn.nCols self.mainWindow.nTransceiverRows = Defines.Matterhorn02.nRows
self.mainWindow.nTransceiverCols = Defines.Matterhorn02.nCols
self.mainWindow.pixel_map = pm.matterhorn_transceiver()
elif self.view.comboBoxPlot.currentText() == "Matterhorn1_16bit_1_counter":
print("Setting pixel map for Matterhorn1")
self.mainWindow.nTransceiverRows = Defines.Matterhorn1.nRows
self.mainWindow.nTransceiverCols = Defines.Matterhorn1.nCols
self.mainWindow.pixel_map = pm.matterhorn1_transceiver_16bit_1_counter()
elif self.view.comboBoxPlot.currentText() == "Matterhorn1_16bit_4_counters":
print("Setting pixel map for Matterhorn1 with 4 counters")
self.mainWindow.nTransceiverRows = Defines.Matterhorn1.nRows*4
self.mainWindow.nTransceiverCols = Defines.Matterhorn1.nCols
self.mainWindow.pixel_map = pm.matterhorn1_transceiver_16bit_4_counters()
elif self.view.comboBoxPlot.currentText() == "Moench04": elif self.view.comboBoxPlot.currentText() == "Moench04":
self.mainWindow.nAnalogRows = Defines.Moench04.nRows self.mainWindow.nAnalogRows = Defines.Moench04.nRows
self.mainWindow.nAnalogCols = Defines.Moench04.nCols self.mainWindow.nAnalogCols = Defines.Moench04.nCols
def showPatternViewer(self, enable): def showPatternViewer(self, enable):
if enable: if enable:
self.mainWindow.framePatternViewer.show() self.mainWindow.framePatternViewer.show()

View File

@@ -133,7 +133,8 @@ class TransceiverTab(QtWidgets.QWidget):
nbitsPerDBit += (8 - (dSamples % 8)) nbitsPerDBit += (8 - (dSamples % 8))
transceiverOffset += nDBitEnabled * (nbitsPerDBit // 8) transceiverOffset += nDBitEnabled * (nbitsPerDBit // 8)
trans_array = np.array(np.frombuffer(data, offset=transceiverOffset, dtype=np.uint16)) trans_array = np.array(np.frombuffer(data, offset=transceiverOffset, dtype=np.uint16))
return decoder.decode(trans_array, pm.matterhorn_transceiver()) tmp = np.take(trans_array, self.mainWindow.pixel_map)
return tmp
def processImageData(self, data, dSamples): def processImageData(self, data, dSamples):
""" """

View File

@@ -165,7 +165,17 @@
</property> </property>
<item> <item>
<property name="text"> <property name="text">
<string>Matterhorn</string> <string>Matterhorn02</string>
</property>
</item>
<item>
<property name="text">
<string>Matterhorn1_16bit_4_counters</string>
</property>
</item>
<item>
<property name="text">
<string>Matterhorn1_16bit_1_counter</string>
</property> </property>
</item> </item>
<item> <item>

View File

@@ -49,3 +49,4 @@ def matterhorn(trans_buffer):
offset += nSamples offset += nSamples
return transceiver_frame return transceiver_frame

View File

@@ -50,7 +50,7 @@ class Defines:
Matterhorn = 0 Matterhorn = 0
Moench04 = 1 Moench04 = 1
class Matterhorn: class Matterhorn02:
nRows = 48 nRows = 48
nHalfCols = 24 nHalfCols = 24
nCols = 48 nCols = 48
@@ -58,6 +58,14 @@ class Defines:
tranceiverEnable = 0x3 tranceiverEnable = 0x3
nPixelsPerTransceiver = 4 nPixelsPerTransceiver = 4
class Matterhorn1:
nRows = 256
nHalfCols = 24
nCols = 256
nTransceivers = 2
tranceiverEnable = 0x3
nPixelsPerTransceiver = 4
class Moench04: class Moench04:
nRows = 400 nRows = 400
nCols = 400 nCols = 400

View File

@@ -59,3 +59,34 @@ def matterhorn_transceiver():
offset += nSamples offset += nSamples
return out return out
def matterhorn1_transceiver_16bit_1_counter():
pixel_map = np.zeros((256,256), np.uint32)
n_cols = 256
n_rows = 256
for row in range(n_rows):
col = 0
for offset in range(0,64,4):
for pkg in range(offset,256,64):
for pixel in range(4):
pixel_map[row, col] = pixel+pkg+row*n_cols
col += 1
return pixel_map
def matterhorn1_transceiver_16bit_4_counters():
n_counters = 4
n_cols = 256
n_rows = 256
pixel_map = np.zeros((n_rows*n_counters,n_cols), np.uint32)
for row in range(n_rows):
for counter in range(n_counters):
col = 0
for offset in range(0,64,4):
for pkg in range(offset,256,64):
for pixel in range(4):
pixel_map[row+n_rows*counter, col] = pixel+pkg+row*n_cols*n_counters+n_cols*counter
col += 1
return pixel_map