Changeset a98014ab in sasview for src/sas


Ignore:
Timestamp:
Oct 3, 2018 5:00:21 AM (6 years ago)
Author:
Piotr Rozyczko <piotr.rozyczko@…>
Branches:
ESS_GUI, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
Children:
34e5170
Parents:
672c0e97
Message:

Enabled weird instantiation of initial values for certain parameters in
magnetism. Fixed handling of the magnetism state in GUI. SASVIEW-1199

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/Perspectives/Fitting/FittingWidget.py

    r672c0e97 ra98014ab  
    999999        return menu 
    10001000 
     1001    def canHaveMagnetism(self): 
     1002        """ 
     1003        Checks if the current model has magnetic scattering implemented 
     1004        """ 
     1005        current_model = self.cbModel.currentText() 
     1006        return self.is2D and current_model in self.MAGNETIC_MODELS 
     1007 
    10011008    def onSelectModel(self): 
    10021009        """ 
     
    10111018        if not model: 
    10121019            return 
    1013         self.chkMagnetism.setEnabled(self.is2D and model in self.MAGNETIC_MODELS) 
     1020        self.chkMagnetism.setEnabled(self.canHaveMagnetism()) 
     1021        self.tabFitting.setTabEnabled(TAB_MAGNETISM, self.chkMagnetism.isChecked() and self.canHaveMagnetism()) 
     1022 
    10141023        # Reset parameters to fit 
    10151024        self.resetParametersToFit() 
     
    15841593        if self.chkPolydispersity.isChecked(): 
    15851594            params_to_fit += self.poly_params_to_fit 
    1586         if self.chkMagnetism.isChecked(): 
     1595        if self.chkMagnetism.isChecked() and self.canHaveMagnetism(): 
    15871596            params_to_fit += self.magnet_params_to_fit 
    15881597        if not params_to_fit: 
     
    22592268        if self.chkPolydispersity.isChecked() and self.poly_params_to_fit: 
    22602269            return True 
    2261         if self.chkMagnetism.isChecked() and self.magnet_params_to_fit: 
     2270        if self.chkMagnetism.isChecked() and self.canHaveMagnetism() and self.magnet_params_to_fit: 
    22622271            return True 
    22632272        return False 
     
    24932502                model.setParam(key, value) 
    24942503        # add magnetic params if asked 
    2495         if self.chkMagnetism.isChecked() and self._magnet_model.rowCount() > 0: 
     2504        if self.chkMagnetism.isChecked() and self.canHaveMagnetism() and self._magnet_model.rowCount() > 0: 
    24962505            for key, value in self.magnet_params.items(): 
    24972506                model.setParam(key, value) 
     
    29662975            return 
    29672976        self._magnet_model.clear() 
    2968         [self.addCheckedMagneticListToModel(param, self._magnet_model) for param in \ 
    2969             self.model_parameters.call_parameters if param.type == 'magnetic'] 
     2977        # default initial value 
     2978        m0 = 0.5e-06 
     2979        for param in self.model_parameters.call_parameters: 
     2980            if param.type != 'magnetic': continue 
     2981            if "M0" in param.name: 
     2982                m0 += 0.5e-06 
     2983                value = m0 
     2984            else: 
     2985                value = param.default 
     2986            self.addCheckedMagneticListToModel(param, value) 
     2987 
    29702988        FittingUtilities.addHeadersToModel(self._magnet_model) 
    29712989 
     
    29843002        return shell_names 
    29853003 
    2986     def addCheckedMagneticListToModel(self, param, model): 
     3004    def addCheckedMagneticListToModel(self, param, value): 
    29873005        """ 
    29883006        Wrapper for model update with a subset of magnetic parameters 
     
    29993017 
    30003018        checked_list = [param.name, 
    3001                         str(param.default), 
     3019                        str(value), 
    30023020                        str(param.limits[0]), 
    30033021                        str(param.limits[1]), 
    30043022                        param.units] 
    30053023 
    3006         self.magnet_params[param.name] = param.default 
    3007  
    3008         FittingUtilities.addCheckedListToModel(model, checked_list) 
     3024        self.magnet_params[param.name] = value 
     3025 
     3026        FittingUtilities.addCheckedListToModel(self._magnet_model, checked_list) 
    30093027 
    30103028    def enableStructureFactorControl(self, structure_factor): 
     
    35173535        if self.chkPolydispersity.isChecked(): 
    35183536            self.iterateOverPolyModel(gatherPolyParams) 
    3519         if self.chkMagnetism.isChecked() and self.chkMagnetism.isEnabled(): 
     3537        if self.chkMagnetism.isChecked() and self.canHaveMagnetism(): 
    35203538            self.iterateOverMagnetModel(gatherMagnetParams) 
    35213539 
Note: See TracChangeset for help on using the changeset viewer.