Julian-Hochhaus / LG4X-V2

A graphical user interface of Python lmfit package was developed for standard X-ray photoemission spectroscopy (XPS) curve fitting analysis. The interface streamlines the fitting procedures for validating results and their consistency.
https://julian-hochhaus.github.io/LG4X-V2/
Other
20 stars 9 forks source link

Crash: TypeError: 'NoneType' object is not iterable #62

Closed kevinsmia1939 closed 1 year ago

kevinsmia1939 commented 1 year ago

I experience crashing when I check "keep background fixed" and try to fit two or more peaks.

  File "/home/kevin/Desktop/software/LG4X-V2/Python/main.py", line 1928, in eva
    self.ana('eva')
  File "/home/kevin/Desktop/software/LG4X-V2/Python/main.py", line 3007, in ana
    temp_res = self.BGModCreator(x, y, mode=mode)
  File "/home/kevin/Desktop/software/LG4X-V2/Python/main.py", line 2914, in BGModCreator
    temp_res = self.bgSelector(x, y, mode=mode, idx_bg=self.idx_bg[0])
  File "/home/kevin/Desktop/software/LG4X-V2/Python/main.py", line 2214, in bgSelector
    for par in pars:
TypeError: 'NoneType' object is not iterable
Aborted (core dumped)
Julian-Hochhaus commented 1 year ago

Which kind of background are you using? Seems working fine with tougaard as well as with tougaard+ polynomial as well as with using active shirley.

I assume, that the problem occurs using static backgrounds? For static backgrounds, the concept of keeping the background fixed does not make so much sense, because using static backgrounds calculates the background and removes it before starting the actual fitting procedure.

However, I assume the error needs to be catched and we need explanation for that. If you want to try out a set of shirley parameters, you could use the active shirley and then tick the 'keep backgorund fixed' option as a workaround :)

kevinsmia1939 commented 1 year ago

I think I might have chosen static shirley bg which crash it. So I think simple grey out the fixed bg check box should be fine.

I found that if I add this,

    def clickOnBtnBG(self):
        checked_actions = [action for action in self.bgMenu.actions() if action.isChecked()]
        idx_bg = set()
        for checked_action in checked_actions:
            if checked_action.text() == '&Static &Shirley BG':
                idx_bg.add(0)
                self.fixedBG.setChecked(False)
                self.fixedBG.setEnabled(False)

The fixed bg button is disable when static sherley is selected, but I don't know how to enable when select back to active.

Julian-Hochhaus commented 1 year ago

Solved for now, but I think about fixing the problem using a different approach in the future. The crash is caused by the params being None if only static backgrounds were used. Maybe its much more elegant if we check whether the params are None and if yes ignore the given condition and only apply the fixed background to all other background parameters.

Julian-Hochhaus commented 1 year ago

We need to check btw if both static backgrounds are checked and take care if such a case occurs. Saving it for later here because it's closely connected to the topic.