sas.qtgui.Perspectives.Fitting package
Subpackages
- sas.qtgui.Perspectives.Fitting.UI package
- Submodules
- sas.qtgui.Perspectives.Fitting.UI.ComplexConstraintUI module
- sas.qtgui.Perspectives.Fitting.UI.ConstraintWidgetUI module
- sas.qtgui.Perspectives.Fitting.UI.FittingOptionsUI module
- sas.qtgui.Perspectives.Fitting.UI.FittingWidgetUI module
- sas.qtgui.Perspectives.Fitting.UI.GPUOptionsUI module
- sas.qtgui.Perspectives.Fitting.UI.GPUTestResultsUI module
- sas.qtgui.Perspectives.Fitting.UI.MultiConstraintUI module
- sas.qtgui.Perspectives.Fitting.UI.OptionsWidgetUI module
- sas.qtgui.Perspectives.Fitting.UI.OrderWidgetUI module
- sas.qtgui.Perspectives.Fitting.UI.SmearingWidgetUI module
- Module contents
Submodules
sas.qtgui.Perspectives.Fitting.AssociatedComboBox module
-
class
sas.qtgui.Perspectives.Fitting.AssociatedComboBox.
AssociatedComboBox
(item, idx_as_value=False, parent=None)[source] Bases:
sphinx.ext.autodoc.importer._MockObject
Just a regular combo box, but associated with a particular QStandardItem so that it can be used to display and select an item’s current text and a restricted list of other possible text.
When the combo box’s current text is changed, the change is immediately reflected in the associated item; either the text itself is set as the item’s data, or the current index is used; see constructor.
-
item
= None
-
sas.qtgui.Perspectives.Fitting.ComplexConstraint module
sas.qtgui.Perspectives.Fitting.ConsoleUpdate module
-
class
sas.qtgui.Perspectives.Fitting.ConsoleUpdate.
ConsoleUpdate
(parent, manager=None, quiet=False, progress_delta=60, improvement_delta=5)[source] Bases:
sas.sascalc.fit.AbstractFitEngine.FitHandler
Print progress to the console.
-
abort
()[source]
-
error
(msg)[source] Model had an error; print traceback
-
finalize
()[source]
-
get_result
()[source]
-
improvement
()[source] Called when a result is observed which is better than previous results from the fit.
-
improvement_delta
= 5 Number of seconds between improvement updates
-
isbetter
= False Record whether results improved since last update
-
print_result
()[source] Print result object
-
progress
(k, n)[source] Report on progress.
-
progress_delta
= 60 Number of seconds between progress updates
-
set_result
(result)[source]
-
stop
(msg)[source] Post event msg and stop
-
update_fit
(last=False)[source]
-
sas.qtgui.Perspectives.Fitting.Constraint module
-
class
sas.qtgui.Perspectives.Fitting.Constraint.
Constraint
(parent=None, param=None, value=0.0, min=None, max=None, func=None, value_ex=None, operator='=')[source] Bases:
object
Internal representation of a single parameter constraint Currently just a data structure, might get expaned with more functionality, hence made into a class.
-
func
-
max
-
min
-
operator
-
param
-
value
-
value_ex
-
sas.qtgui.Perspectives.Fitting.ConstraintWidget module
sas.qtgui.Perspectives.Fitting.FitPage module
Container class for fitting widget state storage
-
class
sas.qtgui.Perspectives.Fitting.FitPage.
FitPage
[source] Bases:
object
Container for all data related to the current fit page
-
LOG_POINTS
= 4
-
MAX_RANGE
= 1
-
MIN_RANGE
= 0
-
NPTS
= 2
-
NPTS_FIT
= 3
-
SMEARING_ACCURACY
= 7
-
SMEARING_MAX
= 9
-
SMEARING_MIN
= 8
-
SMEARING_OPTION
= 6
-
WEIGHTING
= 5
-
load
(location)[source] Retrieve serialized state from specified location
-
save
()[source] Serialize the current state
-
saveAsXML
()[source] Serialize the current state
-
sas.qtgui.Perspectives.Fitting.FitThread module
-
class
sas.qtgui.Perspectives.Fitting.FitThread.
FitThread
(fn, page_id, handler, batch_outputs, batch_inputs=None, pars=None, completefn=None, updatefn=None, yieldtime=0.03, worktime=0.03, reset_flag=False)[source] Bases:
sas.sascalc.data_util.calcthread.CalcThread
Thread performing the fit
-
compute
()[source] Perform a fit
-
isquit
()[source] Raises: KeyboardInterrupt – when the thread is interrupted
-
-
sas.qtgui.Perspectives.Fitting.FitThread.
map_apply
(arguments)[source]
-
sas.qtgui.Perspectives.Fitting.FitThread.
map_getattr
(classInstance, classFunc, *args)[source] Take an instance of a class and a function name as a string. Execute class.function and return result
sas.qtgui.Perspectives.Fitting.FittingLogic module
-
class
sas.qtgui.Perspectives.Fitting.FittingLogic.
FittingLogic
(data=None)[source] Bases:
object
All the data-related logic. This class deals exclusively with Data1D/2D No QStandardModelIndex here.
-
computeDataRange
()[source] Wrapper for calculating the data range based on local dataset
-
computeRangeFromData
(data)[source] Compute the minimum and the maximum range of the data return the npts contains in data
-
createDefault1dData
(interval, tab_id=0)[source] Create default data for fitting perspective Only when the page is on theory mode.
-
createDefault2dData
(qmax, qstep, tab_id=0)[source] Create 2D data by default Only when the page is on theory mode.
-
data
-
getScalarIntermediateResults
(return_data)[source] Returns a dict of scalar-only intermediate results from the return data.
-
isLoadedData
()[source] accessor
-
new1DPlot
(return_data, tab_id)[source] Create a new 1D data instance based on fitting results
-
new1DProductPlots
(return_data, tab_id)[source] If return_data contains separated P(Q) and/or S(Q) data, create 1D plots for each and return as the tuple (pq_plot, sq_plot). If either are unavailable, the corresponding plot is None.
-
new2DPlot
(return_data)[source] Create a new 2D data instance based on fitting results
-
setDataProperties
()[source] Analyze data and set up some properties important for the Presentation layer
-
sas.qtgui.Perspectives.Fitting.FittingOptions module
sas.qtgui.Perspectives.Fitting.FittingPerspective module
sas.qtgui.Perspectives.Fitting.FittingUtilities module
-
sas.qtgui.Perspectives.Fitting.FittingUtilities.
addCheckedListToModel
(model, param_list)[source] Add a QItem to model. Makes the QItem checkable
-
sas.qtgui.Perspectives.Fitting.FittingUtilities.
addErrorHeadersToModel
(model)[source] Adds predefined headers to the model
-
sas.qtgui.Perspectives.Fitting.FittingUtilities.
addErrorPolyHeadersToModel
(model)[source] Adds predefined headers to the model
-
sas.qtgui.Perspectives.Fitting.FittingUtilities.
addHeadersToModel
(model)[source] Adds predefined headers to the model
-
sas.qtgui.Perspectives.Fitting.FittingUtilities.
addHeadingRowToModel
(model, name)[source] adds a non-interactive top-level row to the model
-
sas.qtgui.Perspectives.Fitting.FittingUtilities.
addParametersToModel
(parameters, kernel_module, is2D, model=None, view=None)[source] Update local ModelModel with sasmodel parameters. Actually appends to model, if model and view params are not None. Always returns list of lists of QStandardItems.
-
sas.qtgui.Perspectives.Fitting.FittingUtilities.
addPolyHeadersToModel
(model)[source] Adds predefined headers to the model
-
sas.qtgui.Perspectives.Fitting.FittingUtilities.
addShellsToModel
(parameters, model, index, row_num=None, view=None)[source] Find out multishell parameters and update the model with the requested number of them. Inserts them after the row at row_num, if not None; otherwise, appends to end. If view param is not None, supports fixed-choice params. Returns a list of lists of QStandardItem objects.
-
sas.qtgui.Perspectives.Fitting.FittingUtilities.
addSimpleParametersToModel
(parameters, is2D, parameters_original=None, model=None, view=None, row_num=None)[source] Update local ModelModel with sasmodel parameters (non-dispersed, non-magnetic) Actually appends to model, if model and view params are not None. Always returns list of lists of QStandardItems.
parameters_original: list of parameters before any tagging on their IDs, e.g. for product model (so that those are the display names; see below)
-
sas.qtgui.Perspectives.Fitting.FittingUtilities.
binary_encode
(i, digits)[source]
-
sas.qtgui.Perspectives.Fitting.FittingUtilities.
calculateChi2
(reference_data, current_data, weight)[source] Calculate Chi2 value between two sets of data
-
sas.qtgui.Perspectives.Fitting.FittingUtilities.
createFixedChoiceComboBox
(param, item_row)[source] Determines whether param is a fixed-choice parameter, modifies items in item_row appropriately and returns a combo box containing the fixed choices. Returns None if param is not fixed-choice.
item_row is a list of QStandardItem objects for insertion into the parameter table.
-
sas.qtgui.Perspectives.Fitting.FittingUtilities.
formatParameters
(parameters, Check=True)[source] Prepare the parameter string in the standard SasView layout
-
sas.qtgui.Perspectives.Fitting.FittingUtilities.
formatParametersExcel
(parameters)[source] Prepare the parameter string in the Excel format (tab delimited)
-
sas.qtgui.Perspectives.Fitting.FittingUtilities.
formatParametersLatex
(parameters)[source] Prepare the parameter string in latex
-
sas.qtgui.Perspectives.Fitting.FittingUtilities.
getIterParams
(model)[source] Returns a list of all multi-shell parameters in ‘model’
-
sas.qtgui.Perspectives.Fitting.FittingUtilities.
getMultiplicity
(model)[source] Finds out if ‘model’ has multishell parameters. If so, returns the name of the counter parameter and the number of shells
-
sas.qtgui.Perspectives.Fitting.FittingUtilities.
getOrientationParam
(kernel_module=None)[source] Get the dictionary with orientation parameters
-
sas.qtgui.Perspectives.Fitting.FittingUtilities.
getStandardParam
(model=None)[source] Returns a list with standard parameters for the current model
-
sas.qtgui.Perspectives.Fitting.FittingUtilities.
getWeight
(data, is2d, flag=None)[source] Received flag and compute error on data. :param flag: flag to transform error of data.
-
sas.qtgui.Perspectives.Fitting.FittingUtilities.
isNumber
(s)[source] Checks if string ‘s’ is an int/float
-
sas.qtgui.Perspectives.Fitting.FittingUtilities.
isParamPolydisperse
(param_name, kernel_params, is2D=False)[source] Simple lookup for polydispersity for the given param name
-
sas.qtgui.Perspectives.Fitting.FittingUtilities.
markParameterDisabled
(model, row)[source] Given the QModel row number, format to show it is not available for fitting
-
sas.qtgui.Perspectives.Fitting.FittingUtilities.
plotPolydispersities
(model)[source]
-
sas.qtgui.Perspectives.Fitting.FittingUtilities.
plotResiduals
(reference_data, current_data, weights)[source] Create Data1D/Data2D with residuals, ready for plotting
-
sas.qtgui.Perspectives.Fitting.FittingUtilities.
replaceShellName
(param_name, value)[source] Updates parameter name from <param_name>[n_shell] to <param_name>value
-
sas.qtgui.Perspectives.Fitting.FittingUtilities.
residualsData1D
(reference_data, current_data, weights)[source] Calculate the residuals for difference of two Data1D sets
-
sas.qtgui.Perspectives.Fitting.FittingUtilities.
residualsData2D
(reference_data, current_data, weight)[source] Calculate the residuals for difference of two Data2D sets
-
sas.qtgui.Perspectives.Fitting.FittingUtilities.
updateKernelWithResults
(kernel, results)[source] Takes model kernel and applies results dict to its parameters, returning the modified (deep) copy of the kernel.
sas.qtgui.Perspectives.Fitting.FittingWidget module
sas.qtgui.Perspectives.Fitting.GPUOptions module
sas.qtgui.Perspectives.Fitting.ModelThread module
Calculation thread for modeling
-
class
sas.qtgui.Perspectives.Fitting.ModelThread.
Calc1D
(model, page_id, data, fid=None, qmin=None, qmax=None, weight=None, smearer=None, toggle_mode_on=False, state=None, completefn=None, update_chisqr=True, source='model', updatefn=None, yieldtime=0.01, worktime=0.01, exception_handler=None)[source] Bases:
sas.sascalc.data_util.calcthread.CalcThread
Compute 1D data
-
compute
()[source] Compute model 1d value given qmin , qmax , x value
-
results
()[source] Send resuts of the computation
-
-
class
sas.qtgui.Perspectives.Fitting.ModelThread.
Calc2D
(data, model, smearer, qmin, qmax, page_id, state=None, weight=None, fid=None, toggle_mode_on=False, completefn=None, updatefn=None, update_chisqr=True, source='model', yieldtime=0.04, worktime=0.04, exception_handler=None)[source] Bases:
sas.sascalc.data_util.calcthread.CalcThread
Compute 2D model This calculation assumes a 2-fold symmetry of the model where points are computed for one half of the detector and I(qx, qy) = I(-qx, -qy) is assumed.
-
compute
()[source] Compute the data given a model function
-
sas.qtgui.Perspectives.Fitting.MultiConstraint module
sas.qtgui.Perspectives.Fitting.OptionsWidget module
sas.qtgui.Perspectives.Fitting.OrderWidget module
sas.qtgui.Perspectives.Fitting.ReportPageLogic module
-
class
sas.qtgui.Perspectives.Fitting.ReportPageLogic.
ReportPageLogic
(parent=None, kernel_module=None, data=None, index=None, params=None)[source] Bases:
object
Logic for the Report Page functionality. Refactored from FittingWidget.
-
buildPlotsForReport
(images)[source] Convert Matplotlib figure ‘fig’ into a <img> tag for HTML use using base64 encoding.
-
static
cleanhtml
(raw_html)[source] Remove html tags from a document
-
getImages
()[source] Create MPL figures for the current fit
-
reportHeader
()[source] Look at widget state and extract report header info
-
reportList
()[source] Return the HTML version of the full report
-
reportParams
()[source] Look at widget state and extract parameters
-
sas.qtgui.Perspectives.Fitting.SmearingWidget module
sas.qtgui.Perspectives.Fitting.ViewDelegate module
-
class
sas.qtgui.Perspectives.Fitting.ViewDelegate.
MagnetismViewDelegate
(parent=None)[source] Bases:
sphinx.ext.autodoc.importer._MockObject
Custom delegate for appearance and behavior control of the magnetism view
-
addErrorColumn
()[source] Modify local column pointers Note: the reverse is never required!
-
createEditor
(widget, option, index)[source]
-
editableParameters
()[source]
-
paint
(painter, option, index)[source] Overwrite generic painter for certain columns
-
-
class
sas.qtgui.Perspectives.Fitting.ViewDelegate.
ModelViewDelegate
(parent=None)[source] Bases:
sphinx.ext.autodoc.importer._MockObject
Custom delegate for appearance and behavior control of the model view
-
addErrorColumn
()[source] Modify local column pointers Note: the reverse is never required!
-
createEditor
(widget, option, index)[source] Overwrite generic editor for certain columns
-
fancyColumns
()[source]
-
paint
(painter, option, index)[source] Overwrite generic painter for certain columns
-
setModelData
(editor, model, index)[source] Overwrite generic model update method for certain columns
-
-
class
sas.qtgui.Perspectives.Fitting.ViewDelegate.
PolyViewDelegate
(parent=None)[source] Bases:
sphinx.ext.autodoc.importer._MockObject
Custom delegate for appearance and behavior control of the polydispersity view
-
POLYDISPERSE_FUNCTIONS
= ['rectangle', 'array', 'lognormal', 'gaussian', 'schulz']
-
addErrorColumn
()[source] Modify local column pointers Note: the reverse is never required!
-
columnDict
()[source]
-
combo_updated
Used by autodoc_mock_imports.
-
createEditor
(widget, option, index)[source]
-
editableParameters
()[source]
-
filename_updated
Used by autodoc_mock_imports.
-
paint
(painter, option, index)[source] Overwrite generic painter for certain columns
-