Ignore:
Timestamp:
Sep 17, 2018 8:17:08 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:
5990185
Parents:
9f4eaeb
Message:

plot the polydispersity SASVIEW-1035

File:
1 edited

Legend:

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

    r305114c r3ae70f9  
    571571    return residuals 
    572572 
     573def plotPolydispersities(model, disp_models): 
     574    plots = [] 
     575    if model is None: 
     576        return plots 
     577    # test for model being a sasmodels.sasview_model.SasviewModel? 
     578    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) 
     591        # create Data1D as in residualsData1D() and fill x/y members 
     592        # similar to FittingLogic._create1DPlot() but different data/axes 
     593        data1d = Data1D(x = arr[0], y = arr[1]) 
     594        data1d.xaxis('\\rm{{{}}} '.format(name.replace('_', '\_')), 'A') # correct unit? 
     595        data1d.yaxis('\\rm{{{weight}}}', 'normalized') 
     596        data1d.scale = 'linear' 
     597        data1d.symbol = 'Line' 
     598        data1d.name = "{} polydispersity".format(name) 
     599        data1d.id = data1d.name # placeholder, has to be completed later 
     600        data1d.plot_role = Data1D.ROLE_DELETABLE 
     601        plots.append(data1d) 
     602    return plots 
     603 
    573604def binary_encode(i, digits): 
    574605    return [i >> d & 1 for d in range(digits)] 
Note: See TracChangeset for help on using the changeset viewer.