From c3c3970f1952d93352fc16d1aa7eedc8f91e586c Mon Sep 17 00:00:00 2001 From: froejdh_e Date: Wed, 28 Jan 2026 15:13:15 +0100 Subject: [PATCH 1/3] added 16bit 1 counter and 16bit 4 counters --- pyctbgui/pyctbgui/services/Plot.py | 20 ++++++++++++--- pyctbgui/pyctbgui/services/Transceiver.py | 5 +++- pyctbgui/pyctbgui/ui/plot.ui | 12 ++++++++- pyctbgui/pyctbgui/utils/decoder.py | 1 + pyctbgui/pyctbgui/utils/defines.py | 10 +++++++- pyctbgui/pyctbgui/utils/pixelmap.py | 31 +++++++++++++++++++++++ 6 files changed, 73 insertions(+), 6 deletions(-) diff --git a/pyctbgui/pyctbgui/services/Plot.py b/pyctbgui/pyctbgui/services/Plot.py index 0dfedd205..b172f8102 100644 --- a/pyctbgui/pyctbgui/services/Plot.py +++ b/pyctbgui/pyctbgui/services/Plot.py @@ -1,5 +1,6 @@ import logging from functools import partial +import pyctbgui.utils.pixelmap as pm import random from pathlib import Path @@ -415,13 +416,26 @@ class PlotTab(QtWidgets.QWidget): self.mainWindow.read_timer.start(Defines.Time_Plot_Refresh_ms) def setPixelMap(self): - if self.view.comboBoxPlot.currentText() == "Matterhorn": - self.mainWindow.nTransceiverRows = Defines.Matterhorn.nRows - self.mainWindow.nTransceiverCols = Defines.Matterhorn.nCols + if self.view.comboBoxPlot.currentText() == "Matterhorn02": + print("Setting pixel map for Matterhorn02") + 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 + self.mainWindow.nTransceiverCols = Defines.Matterhorn1.nCols + self.mainWindow.pixel_map = pm.matterhorn1_transceiver_16bit_4_counters() elif self.view.comboBoxPlot.currentText() == "Moench04": self.mainWindow.nAnalogRows = Defines.Moench04.nRows self.mainWindow.nAnalogCols = Defines.Moench04.nCols + def showPatternViewer(self, enable): if enable: self.mainWindow.framePatternViewer.show() diff --git a/pyctbgui/pyctbgui/services/Transceiver.py b/pyctbgui/pyctbgui/services/Transceiver.py index 98c8fc541..124de5d0b 100644 --- a/pyctbgui/pyctbgui/services/Transceiver.py +++ b/pyctbgui/pyctbgui/services/Transceiver.py @@ -133,7 +133,10 @@ class TransceiverTab(QtWidgets.QWidget): nbitsPerDBit += (8 - (dSamples % 8)) transceiverOffset += nDBitEnabled * (nbitsPerDBit // 8) trans_array = np.array(np.frombuffer(data, offset=transceiverOffset, dtype=np.uint16)) - return decoder.decode(trans_array, pm.matterhorn_transceiver()) + print(f'{trans_array.shape=}') + tmp = decoder.decode(trans_array, self.mainWindow.pixel_map) + print(f'{tmp.shape=}') + return tmp def processImageData(self, data, dSamples): """ diff --git a/pyctbgui/pyctbgui/ui/plot.ui b/pyctbgui/pyctbgui/ui/plot.ui index b01bc3e71..edebb4548 100644 --- a/pyctbgui/pyctbgui/ui/plot.ui +++ b/pyctbgui/pyctbgui/ui/plot.ui @@ -165,7 +165,17 @@ - Matterhorn + Matterhorn02 + + + + + Matterhorn1_16bit_4_counters + + + + + Matterhorn1_16bit_1_counter diff --git a/pyctbgui/pyctbgui/utils/decoder.py b/pyctbgui/pyctbgui/utils/decoder.py index 6197f811c..ca254b175 100644 --- a/pyctbgui/pyctbgui/utils/decoder.py +++ b/pyctbgui/pyctbgui/utils/decoder.py @@ -49,3 +49,4 @@ def matterhorn(trans_buffer): offset += nSamples return transceiver_frame + diff --git a/pyctbgui/pyctbgui/utils/defines.py b/pyctbgui/pyctbgui/utils/defines.py index 51c6ac1cb..413285185 100644 --- a/pyctbgui/pyctbgui/utils/defines.py +++ b/pyctbgui/pyctbgui/utils/defines.py @@ -50,7 +50,7 @@ class Defines: Matterhorn = 0 Moench04 = 1 - class Matterhorn: + class Matterhorn02: nRows = 48 nHalfCols = 24 nCols = 48 @@ -58,6 +58,14 @@ class Defines: tranceiverEnable = 0x3 nPixelsPerTransceiver = 4 + class Matterhorn1: + nRows = 256 + nHalfCols = 24 + nCols = 256 + nTransceivers = 2 + tranceiverEnable = 0x3 + nPixelsPerTransceiver = 4 + class Moench04: nRows = 400 nCols = 400 diff --git a/pyctbgui/pyctbgui/utils/pixelmap.py b/pyctbgui/pyctbgui/utils/pixelmap.py index 6cfa28a14..1dd533964 100644 --- a/pyctbgui/pyctbgui/utils/pixelmap.py +++ b/pyctbgui/pyctbgui/utils/pixelmap.py @@ -59,3 +59,34 @@ def matterhorn_transceiver(): offset += nSamples 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,n_counters), 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 \ No newline at end of file From 8a0191e3f6c40e8ad0948b9c98cea32a865d3382 Mon Sep 17 00:00:00 2001 From: froejdh_e Date: Wed, 28 Jan 2026 15:54:27 +0100 Subject: [PATCH 2/3] using np.take and updated pixel map --- pyctbgui/pyctbgui/services/Plot.py | 2 +- pyctbgui/pyctbgui/services/Transceiver.py | 3 ++- pyctbgui/pyctbgui/utils/pixelmap.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pyctbgui/pyctbgui/services/Plot.py b/pyctbgui/pyctbgui/services/Plot.py index b172f8102..318a00317 100644 --- a/pyctbgui/pyctbgui/services/Plot.py +++ b/pyctbgui/pyctbgui/services/Plot.py @@ -428,7 +428,7 @@ class PlotTab(QtWidgets.QWidget): 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 + 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": diff --git a/pyctbgui/pyctbgui/services/Transceiver.py b/pyctbgui/pyctbgui/services/Transceiver.py index 124de5d0b..e478587f5 100644 --- a/pyctbgui/pyctbgui/services/Transceiver.py +++ b/pyctbgui/pyctbgui/services/Transceiver.py @@ -134,7 +134,8 @@ class TransceiverTab(QtWidgets.QWidget): transceiverOffset += nDBitEnabled * (nbitsPerDBit // 8) trans_array = np.array(np.frombuffer(data, offset=transceiverOffset, dtype=np.uint16)) print(f'{trans_array.shape=}') - tmp = decoder.decode(trans_array, self.mainWindow.pixel_map) + # tmp = decoder.decode(trans_array, self.mainWindow.pixel_map) + tmp = np.take(trans_array, self.mainWindow.pixel_map) print(f'{tmp.shape=}') return tmp diff --git a/pyctbgui/pyctbgui/utils/pixelmap.py b/pyctbgui/pyctbgui/utils/pixelmap.py index 1dd533964..72fbcc385 100644 --- a/pyctbgui/pyctbgui/utils/pixelmap.py +++ b/pyctbgui/pyctbgui/utils/pixelmap.py @@ -79,7 +79,7 @@ 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,n_counters), np.uint32) + pixel_map = np.zeros((n_rows*n_counters,n_cols), np.uint32) for row in range(n_rows): for counter in range(n_counters): From c500891eb5e4de332df3aba6787a26aafc342f7f Mon Sep 17 00:00:00 2001 From: froejdh_e Date: Wed, 28 Jan 2026 16:43:43 +0100 Subject: [PATCH 3/3] removed comments --- pyctbgui/pyctbgui/services/Transceiver.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/pyctbgui/pyctbgui/services/Transceiver.py b/pyctbgui/pyctbgui/services/Transceiver.py index e478587f5..ecaf64282 100644 --- a/pyctbgui/pyctbgui/services/Transceiver.py +++ b/pyctbgui/pyctbgui/services/Transceiver.py @@ -133,10 +133,7 @@ class TransceiverTab(QtWidgets.QWidget): nbitsPerDBit += (8 - (dSamples % 8)) transceiverOffset += nDBitEnabled * (nbitsPerDBit // 8) trans_array = np.array(np.frombuffer(data, offset=transceiverOffset, dtype=np.uint16)) - print(f'{trans_array.shape=}') - # tmp = decoder.decode(trans_array, self.mainWindow.pixel_map) tmp = np.take(trans_array, self.mainWindow.pixel_map) - print(f'{tmp.shape=}') return tmp def processImageData(self, data, dSamples):