MJ P
Jun 11
General Discussion
Today I noticed with our student's new install of SMAK 3.0.9 (although this was also happening with my 3.0.8 version originally before I fixed my .cfg file) the defaultPyMCAConfig.cfg file has a line that causes peak fitting to crash when performing MCA peak-fitting. The error that comes back from SMAK is:
ValueError Exception in Tk callback
Function: <bound method Main.testMCAfitdata of <__main__.Main object at 0x000002EAA3173370>> (type: <class 'method'>)
Args: ()
Traceback (innermost last):
File "C:\ProgramData\Miniconda3\envs\smakenv\lib\site-packages\Pmw\Pmw_2_1_1\lib\PmwBase.py", line 1761, in __call__
return self.func(*args)
File "c:\Users\Jake\AppData\Local\SMAK3.0-main\src\smak\smak.py", line 3909, in testMCAfitdata
mcaWrap=pyMcaFitWrapper.Wrapper(pkm=cf)
File "c:\Users\Jake\AppData\Local\SMAK3.0-main\src\smak\pyMcaFitWrapper.py", line 56, in __init__
self.mcafit = MCAT.McaTheory(initdict=pkm,maxiter=maxiter,sumflag=sumflag,
File "C:\ProgramData\Miniconda3\envs\smakenv\lib\site-packages\PyMca5\PyMcaPhysics\xrf\ClassMcaTheory.py", line 108, in __init__
self.__configure()
File "C:\ProgramData\Miniconda3\envs\smakenv\lib\site-packages\PyMca5\PyMcaPhysics\xrf\ClassMcaTheory.py", line 590, in __configure
coeffs = thickness * numpy.array(Elements.getMaterialMassAttenuationCoefficients(formula,1.0,transmissionenergies)['total'])
File "C:\ProgramData\Miniconda3\envs\smakenv\lib\site-packages\PyMca5\PyMcaPhysics\xrf\Elements.py", line 2390, in getMaterialMassAttenuationCoefficients
raise ValueError("Compound '%s' not understood" % compound)
ValueError: Compound '--' not understood
In the Attenuators tab for the PyMCA Parameter Configuration the material for the "Detector" appears to be undefined, hence the "Compound --" in the error message. The culprit appears to be the following line near the top of the defaultPyMCAConfig.cfg file in the [attenuators] section:
Detector = 1, Si1, 2.33, 0.5, 1
Since there's no "Si1" material type SMAK just defaults to "--", which is the first thing in the list of materials. I selected "Silicon" from the dropdown menu (or one can change Si1 to Silicon in the .cfg file and reload it) allowed peak fitting to work again.
A separate issue in the latest versions (at least since 3.0.8) with peak fitting is that SMAK throws errors when peaks are removed from the "Active Peaks" list. This seems like it's perhaps an indexing issue. For example I have peaks for P_K, S_K, Cl_K, Ar_K, etc. If I remove S_K, for example I get:
KeyError Exception in Tk callback
Function: <bound method PyMcaParameterDialog.clearCurPeakLine of <pyMcaParamGUI.PyMcaParameterDialog object at 0x000002D91E2FC340>> (type: <class 'method'>)
Args: ()
Traceback (innermost last):
File "C:\ProgramData\Miniconda3\envs\smakenv\lib\site-packages\Pmw\Pmw_2_1_1\lib\PmwBase.py", line 1761, in __call__
return self.func(*args)
File "c:\Users\Jake\AppData\Local\SMAK3.0-main\src\smak\pyMcaParamGUI.py", line 1278, in clearCurPeakLine
self.atomDict[el][1]=2
KeyError: 'P_K'
If I try to add peaks to the list they appear to populate the Peak list, but if I click anything in the current Peak list SMAK throws the following error:
IndexError Exception in Tk callback
Function: <bound method ScrolledTreeViewBox.item_selected of <ScrollTree.ScrolledTreeViewBox object .!toplevel7.!canvas.!frame.!frame2.!scrolledtreeviewbox>> (type: <class 'method'>)
Args: (<VirtualEvent event x=0 y=0>,)
Event type: VirtualEvents (type num: 35)
Traceback (innermost last):
File "C:\ProgramData\Miniconda3\envs\smakenv\lib\site-packages\Pmw\Pmw_2_1_1\lib\PmwBase.py", line 1761, in __call__
return self.func(*args)
File "c:\Users\Jake\AppData\Local\SMAK3.0-main\src\smak\ScrollTree.py", line 319, in item_selected
self.selectCB(self.curselection())
File "c:\Users\Jake\AppData\Local\SMAK3.0-main\src\smak\pyMcaParamGUI.py", line 1225, in choosePeak
[ele,trans] = self.peaks[arg[0]][0].split('_')
File "c:\Users\Jake\AppData\Local\SMAK3.0-main\src\smak\SortedCollection.py", line 109, in __getitem__
return self._items[i]
IndexError: list index out of range
================================================
Event contents:
char: ??
delta: 0
height: ??
keycode: ??
keysym: ??
keysym_num: ??
num: ??
send_event: False
serial: 20177
state: 0
time: 0
type: 35
widget: .!toplevel7.!canvas.!frame.!frame2.!scrolledtreeviewbox.!treeview
width: ??
x: 0
x_root: 0
y: 0
y_root: 0
My workaround is to re-load a .cfg file that I know has the peaks I want (and in a pinch I manually edit the [peaks] list in the .cfg file to get the desired series of peaks I want).
Hope this helps someone.
J