Changeset 3ae70f9 in sasview


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

Location:
src/sas/qtgui
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/MainWindow/DataExplorer.py

    r9f4eaeb r3ae70f9  
    579579            # Don't plot intermediate results, e.g. P(Q), S(Q) 
    580580            match = GuiUtils.theory_plot_ID_pattern.match(plot.id) 
    581             # 2nd match group contains the identifier for the intermediate result, if present (e.g. "[P(Q)]") 
     581            # 2nd match group contains the identifier for the intermediate 
     582            # result, if present (e.g. "[P(Q)]") 
    582583            if match and match.groups()[1] != None: 
    583584                continue 
    584             # Don't include plots from different fitpages, but always include the original data 
    585             if fitpage_name in plot.name or filename in plot.name or filename == plot.filename: 
     585            # Don't include plots from different fitpages, 
     586            # but always include the original data 
     587            if (fitpage_name in plot.name 
     588                    or filename in plot.name 
     589                    or filename == plot.filename): 
    586590                # Residuals get their own plot 
    587591                if plot.plot_role == Data1D.ROLE_RESIDUAL: 
  • 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)] 
  • src/sas/qtgui/Perspectives/Fitting/FittingWidget.py

    r305114c r3ae70f9  
    24352435            new_plots.append(residuals) 
    24362436 
     2437        model = return_data.get('model', None) 
     2438        for plot in FittingUtilities.plotPolydispersities( 
     2439                                        model, POLYDISPERSITY_MODELS): 
     2440            data_id = fitted_data.id.split() 
     2441            plot.id = " ".join([data_id[0], plot.name] + data_id[1:]) 
     2442            data_name = fitted_data.name.split() 
     2443            plot.name = " ".join([data_name[0], plot.name] + data_name[1:]) 
     2444            self.createNewIndex(plot) 
     2445            new_plots.append(plot) 
     2446 
    24372447        if self.data_is_loaded: 
    2438             # delete any plots associated with the data that were not updated (e.g. to remove beta(Q), S_eff(Q)) 
     2448            # delete any plots associated with the data that were not updated 
     2449            # (e.g. to remove beta(Q), S_eff(Q)) 
    24392450            GuiUtils.deleteRedundantPlots(self.all_data[self.data_index], new_plots) 
    24402451            pass 
    24412452        else: 
    2442             # delete theory items for the model, in order to get rid of any redundant items, e.g. beta(Q), S_eff(Q) 
     2453            # delete theory items for the model, in order to get rid of any 
     2454            # redundant items, e.g. beta(Q), S_eff(Q) 
    24432455            self.communicate.deleteIntermediateTheoryPlotsSignal.emit(self.kernel_module.id) 
    24442456 
Note: See TracChangeset for help on using the changeset viewer.