Skip to content

Commit 3e3a4db

Browse files
authored
Merge pull request #1151 from silx-kit/bfilter
[XRF] Support three beam filters.
2 parents fc11c61 + 242f1d6 commit 3e3a4db

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

src/PyMca5/PyMcaGui/physics/xrf/AttenuatorsTable.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# The PyMca X-Ray Fluorescence Toolkit
44
#
5-
# Copyright (c) 2004-2023 European Synchrotron Radiation Facility
5+
# Copyright (c) 2004-2025 European Synchrotron Radiation Facility
66
#
77
# This file is part of the PyMca X-ray Fluorescence Toolkit developed at
88
# the ESRF.
@@ -94,11 +94,11 @@ def __init__(self, parent=None, name="Attenuators Tab",
9494
if rheight > 40:
9595
self.table.setMinimumHeight(10*rheight)
9696
else:
97-
self.table.setMinimumHeight(13*rheight)
97+
self.table.setMinimumHeight(14*rheight)
9898
else:
9999
self.editor = MaterialEditor.MaterialEditor(graph=graph)
100-
self.table.setMinimumHeight(13*rheight)
101-
self.table.setMaximumHeight(13*rheight)
100+
self.table.setMinimumHeight(14*rheight)
101+
self.table.setMaximumHeight(14*rheight)
102102
self.userAttenuators = TransmissionTableGui.TransmissionTableGui()
103103
self.mainTab.addTab(self.editor, "Material Editor")
104104
self.mainTab.addTab(self.userAttenuators, "User Attenuators")
@@ -322,9 +322,12 @@ class AttenuatorsTableWidget(QTable):
322322
def __init__(self, parent=None, name="Attenuators Table",
323323
attenuators=None, matrixmode=None, compoundmode=None,
324324
layerindex=0, funnyfilters=False):
325+
326+
beamFilters0 = ["BeamFilter1", "BeamFilter2", "BeamFilter3"] # this needs to be synchronized with FitParam.py
325327
attenuators0 = ["Atmosphere", "Air", "Window", "Contact", "DeadLayer",
326-
"Filter5", "Filter6", "Filter7", "BeamFilter1",
327-
"BeamFilter2", "Detector", "Matrix"]
328+
"Filter5", "Filter6", "Filter7"] + beamFilters0 + ["Detector", "Matrix"]
329+
self.__attenuators0 = attenuators0
330+
self.__beamFilters0 = beamFilters0
328331

329332
QTable.__init__(self, parent)
330333
self.setWindowTitle(name)
@@ -385,12 +388,12 @@ def __init__(self, parent=None, name="Attenuators Table",
385388

386389
self.sigValueChanged[int,int].connect(self.mySlot)
387390

388-
def __build(self, nfilters=12):
391+
def __build(self, nfilters=13):
389392
n = 0
390393
if (not self.matrixMode) and (not self.compoundMode):
391-
n = 4
394+
n = len(self.__beamFilters0) + 2
392395
#self.setNumRows(nfilters+n)
393-
self.setRowCount(12)
396+
self.setRowCount(len(self.__attenuators0))
394397
else:
395398
self.setRowCount(nfilters)
396399
rheight = self.horizontalHeader().sizeHint().height()
@@ -457,10 +460,11 @@ def __build(self, nfilters=12):
457460
#self.setItem(idx,2,combo)
458461
combo.sigMaterialComboBoxSignal.connect(self._comboSlot)
459462

460-
for i in range(2):
463+
nBeamFilters = len(self.__beamFilters0)
464+
for i in range(nBeamFilters):
461465
#BeamFilter(i)
462466
item = qt.QCheckBox(self)
463-
idx = self.rowCount() - (4 - i)
467+
idx = self.rowCount() - (n - i)
464468
self.setCellWidget(idx, 0, item)
465469
text = "BeamFilter%d" % i
466470
item.setText(text)

src/PyMca5/PyMcaGui/physics/xrf/FitParam.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# The PyMca X-Ray Fluorescence Toolkit
44
#
5-
# Copyright (c) 2004-2023 European Synchrotron Radiation Facility
5+
# Copyright (c) 2004-2025 European Synchrotron Radiation Facility
66
#
77
# This file is part of the PyMca X-ray Fluorescence Toolkit developed at
88
# the ESRF.
@@ -69,7 +69,7 @@
6969

7070
class FitParamWidget(FitParamForm):
7171
attenuators= ["Filter 0", "Filter 1", "Filter 2", "Filter 3", "Filter 4", "Filter 5",
72-
"Filter 6","Filter 7","BeamFilter0", "BeamFilter1","Detector", "Matrix"]
72+
"Filter 6","Filter 7","BeamFilter0", "BeamFilter1", "BeamFilter2","Detector", "Matrix"]
7373
def __init__(self, parent=None):
7474
FitParamForm.__init__(self, parent)
7575
self._channels = None
@@ -616,12 +616,9 @@ def __setAttPar(self, pardict):
616616
else:
617617
current['AlphaScatteringFlag'] = 0
618618
self.matrixGeometry.setParameters(current)
619-
elif att.upper() == "BEAMFILTER0":
619+
elif att.upper().startswith("BEAMFILTER"):
620620
attpar= self.__get("attenuators", att, [0, "-", 0., 0.], None)
621-
row = self.attTable.rowCount() - 4
622-
elif att.upper() == "BEAMFILTER1":
623-
attpar= self.__get("attenuators", att, [0, "-", 0., 0.], None)
624-
row = self.attTable.rowCount() - 3
621+
row = self.attTable.rowCount() - 2 - (3 - int(att[-1])) # maximum 3 BeamFilter
625622
elif att.upper() == "DETECTOR":
626623
attpar= self.__get("attenuators", att, [0, "-", 0., 0.], None)
627624
row = self.attTable.rowCount() - 2
@@ -645,7 +642,7 @@ def __setAttPar(self, pardict):
645642
attpar.append(1.0)
646643
self.attTable.setText(row, 3, str(attpar[2]))
647644
self.attTable.setText(row, 4, str(attpar[3]))
648-
if att.upper() not in ["MATRIX", "DETECTOR", "BEAMFILTER1", "BEAMFILTER2"]:
645+
if not (att.upper() in ["MATRIX", "DETECTOR"] or att.upper().startswith("BEAMFILTER")):
649646
self.attTable.setText(row, 5, str(attpar[4]))
650647
else:
651648
self.attTable.setText(row, 5, "1.0")

0 commit comments

Comments
 (0)