Changeset aa82f54 in sasview


Ignore:
Timestamp:
Sep 18, 2018 4:33:43 AM (6 years ago)
Author:
ibressler
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:
16287f3
Parents:
db500cb
git-author:
Ingo Breßler <dev@…> (09/18/18 04:33:38)
git-committer:
Ingo Breßler <dev@…> (09/18/18 04:33:43)
Message:

plotPolydispersities(): use precalc. weights from SasviewModel?

Location:
src/sas/qtgui/Perspectives/Fitting
Files:
2 edited

Legend:

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

    rdb500cb raa82f54  
    577577    # test for model being a sasmodels.sasview_model.SasviewModel? 
    578578    for name, pars in model.dispersion.items(): 
    579         if 0 == pars['width']: 
    580             continue # no actual polydispersity 
    581         disp_args = pars.copy() 
    582         disp_type = disp_args.pop('type', None) 
    583         if disp_type is None: 
    584             continue # show an error? "poly type ... not found" 
    585         disp_func = disp_models[disp_type](**disp_args) 
    586         center = model.params[name] 
    587         # same as in sasmodels.weights.Dispersion 
    588         lb = center - disp_args['nsigmas']*disp_args['width']*center 
    589         ub = center + disp_args['nsigmas']*disp_args['width']*center 
    590         arr = disp_func.get_weights(center, lb, ub, relative = True) 
     579        if 0 == pars['width']: # no actual polydispersity 
     580            continue 
     581        _, xarr, yarr = model.get_weights(name) 
     582        if xarr is None or yarr is None: # param name not found 
     583            continue 
    591584        # create Data1D as in residualsData1D() and fill x/y members 
    592585        # similar to FittingLogic._create1DPlot() but different data/axes 
    593         data1d = Data1D(x = arr[0], y = arr[1]) 
     586        data1d = Data1D(x = xarr, y = yarr) 
    594587        xunit = "" 
    595588        if name in model.details and len(model.details[name]): 
  • src/sas/qtgui/Perspectives/Fitting/FittingWidget.py

    r3ae70f9 raa82f54  
    5858DEFAULT_POLYDISP_FUNCTION = 'gaussian' 
    5959 
     60# CRUFT: remove when new release of sasmodels is available 
     61# https://github.com/SasView/sasview/pull/181#discussion_r218135162 
     62from sasmodels.sasview_model import SasviewModel 
     63if not hasattr(SasviewModel, 'get_weights'): 
     64    def get_weights(self, name): 
     65        """Returns model weights by parameter name. 
     66        type: (str) -> Tuple(float, np.ndarray, np.ndarray) 
     67        Supposed to be a member of SasviewModel.""" 
     68        p = [p for p in self._model_info.parameters.call_parameters 
     69                        if name is p.name] 
     70        if not len(p): 
     71            return None, None, None 
     72        return self._get_weights(p[0]) 
     73 
     74    SasviewModel.get_weights = get_weights 
    6075 
    6176logger = logging.getLogger(__name__) 
Note: See TracChangeset for help on using the changeset viewer.