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:
PyQt5.QtWidgets.QComboBox
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
Widget for multi-model constraints.
-
class
sas.qtgui.Perspectives.Fitting.ComplexConstraint.
ComplexConstraint
(parent=None, tabs=None)[source] Bases:
PyQt5.QtWidgets.QDialog
,sas.qtgui.Perspectives.Fitting.UI.ComplexConstraintUI.Ui_ComplexConstraintUI
-
constraint
()[source] Return the generated constraint
-
constraintReadySignal
-
onApply
()[source] Respond to Add constraint action. Send a signal that the constraint is ready to be applied
-
onHelp
()[source] Display related help section
-
onModelIndexChange
(index)[source] Respond to mode combo box changes
-
onOperatorChange
(index)[source] Respond to operator combo box changes
-
onParamIndexChange
(index)[source] Respond to parameter combo box changes
-
onSetAll
()[source] Set constraints on all identically named parameters between two fitpages
-
setupData
()[source] Digs into self.tabs and pulls out relevant info
-
setupMenu
()[source]
-
setupParamWidgets
()[source] Fill out comboboxes and set labels with non-constrained parameters
-
setupSignals
()[source] Signals from various elements
-
setupTooltip
()[source] Tooltip for txtConstraint
-
setupWidgets
()[source] Setup widgets based on current parameters
-
validateConstraint
(constraint_text)[source] Ensure the constraint has proper form
-
validateFormula
()[source] Add visual cues when formula is incorrect
-
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
-
class
sas.qtgui.Perspectives.Fitting.ConstraintWidget.
ConstraintWidget
(parent=None)[source] Bases:
PyQt5.QtWidgets.QWidget
,sas.qtgui.Perspectives.Fitting.UI.ConstraintWidgetUI.Ui_ConstraintWidgetUI
Constraints Dialog to select the desired parameter/model constraints.
-
acceptsData
()[source] Tells the caller this widget doesn’t accept data
-
batchComplete
(result)[source] Respond to the successful batch fit complete signal
-
batchCompleteSignal
-
createPageForParameters
(parameters=None)[source] Update the page with passed parameter values
-
deleteConstraint
()[source] Delete all selected constraints.
-
deselectConstraints
()[source] Selected constraints are removed for fitting
-
deselectModels
()[source] Selected models are removed for fitting
-
fitComplete
(result)[source] Respond to the successful fit complete signal
-
fitCompleteSignal
-
fitFailed
(reason)[source] Respond to fitting failure.
-
fitFailedSignal
-
getFitModel
()[source] Retrieves current model
-
getFitPage
()[source] Retrieves the state of this page
-
getObjectByName
(name)[source] Given name of the fit, returns associated fit object
-
getReport
()[source] Wrapper for non-existent functionality. Tell the user to use the reporting tool on separate fit pages.
-
getTabsForFit
()[source] Returns list of tab names selected for fitting
-
initializeFitList
()[source] Fill the list of model/data sets for fitting/constraining
-
initializeSignals
()[source] Set up signals/slots for this widget
-
initializeWidgets
()[source] Set up various widget states
-
isTabImportable
(tab)[source] Determines if the tab can be imported and included in the widget
-
onAcceptConstraint
(con_tuple)[source] Receive constraint tuple from the ComplexConstraint dialog and adds contraint
-
onBatchFitComplete
(result)[source] Send the fit complete signal to main thread
-
onChainFit
(is_checked)[source] Respond to selecting the Chain Fit checkbox
-
onConstraintChange
(row, column)[source] Modify the constraint’s “active” instance variable.
-
onFit
()[source] Perform the constrained/simultaneous fit
-
onFitComplete
(result)[source] Send the fit complete signal to main thread
-
onFitFailed
(reason)[source] Send the fit failed signal to main thread
-
onFitTypeChange
(checked)[source] Respond to the fit type change single fit/batch fit
-
onHelp
()[source] Show the “Fitting” section of help
-
onSpecialCaseChange
(index)[source] Respond to the combobox change for special case constraint sets
-
onTabCellEdit
(row, column)[source] Respond to check/uncheck and to modify the model moniker actions
-
onTabCellEntered
(row, column)[source] Remember the original tab list cell data. Needed for reverting back on bad validation
-
orderedSublist
(order_list, target_list)[source] Orders the target_list such that any elements present in order_list show up first and in the order from order_list.
-
selectConstraints
()[source] Selected constraints are chosen for fitting
-
selectModels
()[source] Selected models are chosen for fitting
-
selectedParameters
(widget)[source] Returns list of selected (highlighted) parameters
-
setRowSelection
(widget, status=0)[source] Selected models are chosen for fitting
-
showConstrContextMenu
(position)[source] Show context specific menu in the tab table widget.
-
showModelContextMenu
(position)[source] Show context specific menu in the tab table widget.
-
showMultiConstraint
()[source] Invoke the complex constraint editor
-
uneditableItem
(data='')[source] Returns an uneditable Table Widget Item
-
updateFitLine
(tab)[source] Update a single line of the table widget with tab info
-
updateSignalsFromTab
(tab=None)[source] Intercept update signals from fitting tabs
-
validateMoniker
(new_moniker=None)[source] Check new_moniker for correctness. It must be non-empty. It must not be the same as other monikers.
-
-
class
sas.qtgui.Perspectives.Fitting.ConstraintWidget.
DnDTableWidget
(*args, **kwargs)[source] Bases:
PyQt5.QtWidgets.QTableWidget
-
dragEnterEvent
(event)[source] Called automatically on a drag in the TableWidget
-
dragLeaveEvent
(event)[source] Called automatically on a drag stop
-
dropEvent
(self, QDropEvent)[source]
-
drop_on
(event)[source]
-
isDragged
()[source] Return the drag status
-
is_below
(pos, index)[source]
-
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
-
class
sas.qtgui.Perspectives.Fitting.FittingOptions.
FittingOptions
(parent=None, config=None)[source] Bases:
PyQt5.QtWidgets.QDialog
,sas.qtgui.Perspectives.Fitting.UI.FittingOptionsUI.Ui_FittingOptions
Hard-coded version of the fit options dialog available from BUMPS. This should be make more “dynamic”. bumps.options.FIT_FIELDS gives mapping between parameter names, parameter strings and field type (double line edit, integer line edit, combo box etc.), e.g.:
FIT_FIELDS = dict( samples = ("Samples", parse_int), xtol = ("x tolerance", float), )
bumps.fitters.<algorithm>.settings gives mapping between algorithm, parameter name and default value, e.g.:
>>> settings = [('steps', 1000), ('starts', 1), ('radius', 0.15), ('xtol', 1e-6), ('ftol', 1e-8)]
-
assignValidators
()[source] Use options.FIT_FIELDS to assert which line edit gets what validator
-
check_state
(*args, **kwargs)[source]
-
fit_option_changed
-
getResults
()[source] Sends back the current choice of parameters
-
onAlgorithmChange
(index)[source] Change the page in response to combo box index
-
onApply
()[source] Update the fitter object
-
onHelp
()[source] Show the “Fitting options” section of help
-
updateWidgetFromBumps
(fitter_id)[source] Given the ID of the current optimizer, fetch the values and update the widget
-
widgetFromOption
(option_id, current_fitter=None)[source] returns widget’s element linked to the given option_id
-
sas.qtgui.Perspectives.Fitting.FittingPerspective module
-
class
sas.qtgui.Perspectives.Fitting.FittingPerspective.
FittingWindow
(parent=None, data=None)[source] Bases:
PyQt5.QtWidgets.QTabWidget
-
addConstraintTab
()[source] Add a new C&S fitting tab
-
addFit
(data, is_batch=False, tab_index=None)[source] Add a new tab for passed data
-
allowBatch
()[source] Tell the caller that we accept multiple data instances
-
closeEvent
(event)[source] Overwrite QDialog close method to allow for custom widget close
-
closeTabByName
(tab_name)[source] Given name of the fitting tab - close it
-
currentTab
Returns the tab widget currently shown
-
currentTabDataId
()[source] Returns the data ID of the current tab
-
dataDeleted
(index_list)[source] Delete fit tabs referencing given data
-
fittingStartedSignal
-
fittingStoppedSignal
-
getCSTabName
()[source] Get the new tab name, based on the number of fitting tabs so far
-
getCurrentStateAsXml
()[source] Returns an XML version of the current state
-
getSerializedFitpage
(tab)[source] get serialize requested fit tab
-
getTabName
(is_batch=False)[source] Get the new tab name, based on the number of fitting tabs so far
-
isSerializable
()[source] Tell the caller that this perspective writes its state
-
name
= 'Fitting'
-
onExcelCopy
()[source]
-
onFittingOptionsChange
(fit_engine)[source] React to the fitting algorithm change by modifying window title
-
onFittingStarted
(tabs_for_fitting=None)[source] Notify tabs listed in tabs_for_fitting that the fitting thread started
-
onFittingStopped
(tabs_for_fitting=None)[source] Notify tabs listed in tabs_for_fitting that the fitting thread stopped
-
onLatexCopy
()[source]
-
onParamCopy
()[source]
-
onParamPaste
()[source]
-
onParamSave
()[source]
-
resetTab
(index)[source] Adds a new tab and removes the last tab as a way of resetting the fit tabs
-
serializeAllFitpage
()[source]
-
serializeCurrentFitpage
()[source]
-
setClosable
(value=True)[source] Allow outsiders to close this widget
-
setData
(data_item=None, is_batch=False, tab_index=None)[source] Assign new dataset to the fitting instance Obtain a QStandardItem object and dissect it to get Data1D/2D Pass it over to the calculator
-
tabCloses
(index)[source] Update local bookkeeping on tab close
-
tabsModifiedSignal
-
updateFitDict
(item_key, tab_name)[source] Create a list if none exists and append if there’s already a list
-
updateFromParameters
(parameters)[source] Pass the update parameters to the current fit page
-
updateWindowTitle
()[source] Update the window title with the current optimizer name
-
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
-
class
sas.qtgui.Perspectives.Fitting.FittingWidget.
FittingWidget
(parent=None, data=None, tab_id=1)[source] Bases:
PyQt5.QtWidgets.QWidget
,sas.qtgui.Perspectives.Fitting.UI.FittingWidgetUI.Ui_FittingWidgetUI
Main widget for selecting form and structure factor models
-
Calc1DFinishedSignal
-
Calc2DFinishedSignal
-
MAGNETIC_MODELS
= ['sphere', 'core_shell_sphere', 'core_multi_shell', 'cylinder', 'parallelepiped']
-
SASModelToQModel
(model_name, structure_factor=None)[source] Setting model parameters into table based on selected category
-
acceptsData
()[source] Tells the caller this widget can accept new dataset
-
addBackgroundToModel
(model)[source] Adds background parameter with default values to the model
-
addCheckedMagneticListToModel
(param, value)[source] Wrapper for model update with a subset of magnetic parameters
-
addConstraintToRow
(constraint=None, row=0)[source] Adds the constraint object to requested row
-
addExtraShells
()[source] Add a combobox for multiple shell display
-
addNameToPolyModel
(i, param_name)[source] Creates a checked row in the poly model with param_name
-
addScaleToModel
(model)[source] Adds scale parameter with default values to the model
-
addSimpleConstraint
()[source] Adds a constraint on a single parameter.
-
addWeightingToData
(data)[source] Adds weighting contribution to fitting data
-
allParamNames
()[source] Returns a list of all parameter names defined on the current model
-
batchFitComplete
(result)[source] Receive and display batch fitting results
-
batchFittingCompleted
(result)[source] Send the finish message from calculate threads to main thread
-
batchFittingFinishedSignal
-
calcException
(etype, value, tb)[source] Thread threw an exception.
-
calculateDataFailed
(reason)[source] Thread returned error
-
calculateQGridForModel
()[source] Prepare the fitting data object, based on current ModelModel
-
calculateQGridForModelExt
(data=None, model=None, completefn=None, use_threads=True)[source] Wrapper for Calc1D/2D calls
-
calculateResiduals
(fitted_data)[source] Calculate and print Chi2 and display chart of residuals. Returns residuals plot object.
-
canHaveMagnetism
()[source] Checks if the current model has magnetic scattering implemented
-
checkboxSelected
(item)[source]
-
checkedListFromModel
(model)[source] Returns list of checked parameters for given model
-
complete1D
(return_data)[source] Plot the current 1D data
-
complete2D
(return_data)[source] Plot the current 2D data
-
completed1D
(return_data)[source]
-
completed2D
(return_data)[source]
-
constraintAddedSignal
-
createDefaultDataset
()[source] Generate default Dataset 1D/2D for the given model
-
createNewIndex
(fitted_data)[source] Create a model or theory index with passed Data1D/Data2D
-
createPageForParameters
(line_dict)[source] Sets up page with requested model/str factor and fills it up with sent parameters
-
createTheoryIndex
(fitted_data)[source] Create a QStandardModelIndex containing model data
-
currentState
()[source] Return fit page with current state
-
classmethod
customModels
()[source] Reads in file names in the custom plugin directory
-
data
-
deleteConstraint
()[source] Delete constraints from selected parameters.
-
deleteConstraintOnParameter
(param=None)[source] Delete the constraint on model parameter ‘param’
-
deselectParameters
()[source] Selected parameters are removed for fitting
-
disableInteractiveElements
()[source] Set buttion caption on fitting/calculate start Disable the param table(s)
-
disableInteractiveElementsOnCalculate
()[source] Set buttion caption on fitting/calculate start Disable the param table(s)
-
disableModelCombo
()[source] Disable the combobox
-
disableStructureCombo
()[source] Disable the combobox
-
editConstraint
()[source] Delete constraints from selected parameters.
-
enableInteractiveElements
()[source] Set buttion caption on fitting/calculate finish Enable the param table(s)
-
enableModelCombo
()[source] Enable the combobox
-
enableStructureCombo
()[source] Enable the combobox
-
enableStructureFactorControl
(structure_factor)[source] Add structure factors to the list of parameters
-
fitComplete
(result)[source] Receive and display fitting results “result” is a tuple of actual result list and the fit time in seconds
-
fitFailed
(reason)[source]
-
fittingCompleted
(result)[source] Send the finish message from calculate threads to main thread
-
fittingFinishedSignal
-
fromModelToQModel
(model_name)[source] Setting model parameters into QStandardItemModel based on selected model
-
fromStructureFactorToQModel
(structure_factor)[source] Setting model parameters into QStandardItemModel based on selected structure factor
-
getComplexConstraintsForModel
()[source] Return a list of tuples. Each tuple contains constraints mapped as (‘constrained parameter’, ‘function to constrain’) e.g. [(‘sld’,’5*M2.sld_solvent’)]. Only for constraints with defined VALUE
-
getConstraintForRow
(row)[source] For the given row, return its constraint, if any (otherwise None)
-
getConstraintObjectsForModel
()[source] Returns Constraint objects present on the whole model
-
getConstraintsForFitting
()[source] Return a list of constraints in format ready for use in fiting
-
getConstraintsForModel
()[source] Return a list of tuples. Each tuple contains constraints mapped as (‘constrained parameter’, ‘function to constrain’) e.g. [(‘sld’,’5*sld_solvent’)]
-
getCurrentFitState
(state=None)[source] Store current state for fit_page
-
getFitModel
()[source] serializes combobox state
-
getFitPage
()[source] serializes full state of this fit page
-
getFitParameters
()[source] serializes current parameters
-
getParamNames
()[source] Return list of all parameters for the current model
-
getReport
()[source] Create and return HTML report with parameters and charts
-
getRowFromName
(name)[source] Given parameter name get the row number in self._model_model
-
haveParamsToFit
()[source] Finds out if there are any parameters ready to be fitted
-
info
(type, value, tb)[source]
-
initializeCategoryCombo
()[source] Model category combo setup
-
initializeControls
()[source] Set initial control enablement
-
initializeGlobals
()[source] Initialize global variables used in this class
-
initializeModels
()[source] Set up models and views
-
initializeSignals
()[source] Connect GUI element signals
-
initializeWidgets
()[source] Initialize widgets for tabs
-
isCheckable
(row)[source]
-
isConstraintMultimodel
(constraint)[source] Check if the constraint function text contains current model name
-
iterateOverMagnetModel
(func)[source] Take func and throw it inside the magnet model row loop
-
iterateOverModel
(func)[source] Take func and throw it inside the model row loop
-
iterateOverPolyModel
(func)[source] Take func and throw it inside the poly model row loop
-
loadAnalysisFile
()[source] Called when the “Open Project” menu item chosen.
-
loadPageState
(pagestate=None)[source] Load the PageState object and update the current widget
-
loadPageStateCallback
(state=None, datainfo=None, format=None)[source] This is a callback method called from the CANSAS reader. We need the instance of this reader only for writing out a file, so there’s nothing here. Until Load Analysis is implemented, that is.
-
loadPolydispArray
(row_index)[source] Show the load file dialog and loads requested data into state
-
logic
-
methodCalculateForData
()[source] return the method for data calculation
-
methodCompleteForData
()[source] return the method for result parsin on calc complete
-
modelContextMenu
(rows)[source] Create context menu for the parameter selection
-
modelName
()[source] Returns model name, by default M<tab#>, e.g. M1, M2
-
modifyShellsInList
(text)[source] Add/remove additional multishell parameters
-
modifyViewOnRow
(row, font=None, brush=None)[source] Change how the given row of the main model is shown
-
nameForFittedData
(name)[source] Generate name for the current fit
-
nameFromData
(fitted_data)[source] Return name for the dataset. Terribly impure function.
-
newModelSignal
-
onCategoriesChanged
()[source] Reload the category/model comboboxes
-
onColumnWidthUpdate
(index, old_size, new_size)[source] Simple state update of the current column widths in the param list
-
onCopyToClipboard
(format=None)[source] Copy current fitting parameters into the clipboard using requested formatting: plain, excel, latex
-
onCustomModelChange
()[source] Reload the custom model combobox
-
onDisplayMagneticAngles
()[source] Display a simple image showing direction of magnetic angles
-
onFit
()[source] Perform fitting on the current data
-
onHelp
()[source] Show the “Fitting” section of help
-
onMagnetModelChange
(top, bottom)[source] Callback method for updating the sasmodel magnetic parameters with the GUI values
-
onMainParamsChange
(top, bottom)[source] Callback method for updating the sasmodel parameters with the GUI values
-
onMaskedData
()[source] A mask has been applied to current data. Update the Q ranges.
-
onOptionsUpdate
()[source] Update local option values and replot
-
onParameterPaste
()[source] Use the clipboard to update fit state
-
onPlot
()[source] Plot the current set of data
-
onPolyComboIndexChange
(combo_string, row_index)[source] Modify polydisp. defaults on function choice
-
onPolyFilenameChange
(row_index)[source] Respond to filename_updated signal from the delegate
-
onPolyModelChange
(top, bottom)[source] Callback method for updating the main model and sasmodel parameters with the GUI values in the polydispersity view
-
onSelectBatchFilename
(data_index)[source] Update the logic based on the selected file in batch fitting
-
onSelectCategory
()[source] Select Category from list
-
onSelectModel
()[source] Respond to select Model from list event
-
onSelectStructureFactor
()[source] Select Structure Factor from list
-
onSelectionChanged
()[source] React to parameter selection
-
onShowSLDProfile
()[source] Show a quick plot of SLD profile
-
onSmearingOptionsUpdate
()[source] React to changes in the smearing widget
-
paramDictFromResults
(results)[source] Given the fit results structure, pull out optimized parameters and return them as nicely formatted dict
-
paramHasConstraint
(param=None)[source] Finds out if the given parameter in the main model has a constraint child
-
popFitPage
()[source] Remove top fit page from stack
-
prepareFitters
(fitter=None, fit_id=0)[source] Prepare the Fitter object for use in fitting
-
processEffectiveRadius
()[source] Checks the value of radius_effective_mode, if existent, and processes radius_effective as necessary. * mode == 0: This means ‘unconstrained’; ensure use can specify ER. * mode > 0: This means it is constrained to a P(Q)-computed value in sasmodels; prevent user from editing ER.
Note: If ER has been computed, it is passed back to SasView as an intermediate result. That value must be displayed for the user; that is not dealt with here, but in complete1D.
-
pushFitPage
(new_page)[source] Add a new fit page object with current state
-
readCategoryInfo
()[source] Reads the categories in from file
-
readCustomCategoryInfo
()[source] Reads the custom model category
-
readFitPage
(fp)[source] Read in state from a fitpage object and update GUI
-
recalculatePlotData
()[source] Generate a new dataset for model
-
regenerateModelDict
()[source] Regenerates self.by_model_dict which has each model name as the key and the list of categories belonging to that model along with the enabled mapping
-
replaceConstraintName
(old_name, new_name='')[source] Replace names of models in defined constraints
-
resetParametersToFit
()[source] Clears the list of parameters to be fitted
-
respondToModelStructure
(model=None, structure_factor=None)[source]
-
rowHasActiveComplexConstraint
(row)[source] Finds out if row of the main model has an active, nontrivial constraint child
-
rowHasActiveConstraint
(row)[source] Finds out if row of the main model has an active constraint child
-
rowHasConstraint
(row)[source] Finds out if row of the main model has a constraint child
-
saveToFitPage
(fp)[source] Write current state to the given fitpage
-
selectCheckbox
(row)[source] Select the checkbox in given row.
-
selectParameters
()[source] Selected parameter is chosen for fitting
-
selectedParameters
()[source] Returns list of selected (highlighted) parameters
-
setDefaultStructureCombo
()[source] Fill in the structure factors combo box with defaults
-
setEnablementOnDataLoad
()[source] Enable/disable various UI elements based on data loaded
-
setInteractiveElements
(enabled=True)[source] Switch interactive GUI elements on/off
-
setMagneticModel
()[source] Set magnetism values on model
-
setParamEditableByRow
(row, editable=True)[source] Sets whether the user can edit a parameter in the table. If they cannot, the parameter name’s font is changed, the value itself cannot be edited if clicked on, and the parameter may not be fitted.
-
setParameterSelection
(status=0)[source] Selected parameters are chosen for fitting
-
setPolyModel
()[source] Set polydispersity values
-
setPolyModelParameters
(i, param)[source] Standard of multishell poly parameter driver
-
setTableProperties
(table)[source] Setting table properties
-
setTheoryItem
(item)[source] Reset the theory item based on the data explorer update
-
shellNamesList
()[source] Returns list of names of all multi-shell parameters E.g. for sld[n], radius[n], n=1..3 it will return [sld1, sld2, sld3, radius1, radius2, radius3]
-
showHelp
(url)[source] Calls parent’s method for opening an HTML page
-
showModelContextMenu
(position)[source] Show context specific menu in the parameter table. When clicked on parameter(s): fitting/constraints options When clicked on white space: model description
-
showModelDescription
()[source] Creates a window with model description, when right clicked in the treeview
-
showMultiConstraint
()[source] Show the constraint widget and receive the expression
-
showPlot
()[source] Show the current plot in MPL
-
showTheoryPlot
()[source] Show the current theory plot in MPL
-
stopFit
()[source] Attempt to stop the fitting thread
-
toggle2D
(isChecked)[source] Enable/disable the controls dependent on 1D/2D data instance
-
toggleChainFit
(isChecked)[source] Enable/disable chain fitting
-
toggleMagnetism
(isChecked)[source] Enable/disable the magnetism tab
-
togglePoly
(isChecked)[source] Enable/disable the polydispersity tab
-
updateData
()[source] Helper function for recalculation of data used in plotting
-
updateEffectiveRadius
(return_data)[source] Given return data from sasmodels, update the effective radius parameter in the GUI table with the new calculated value as returned by sasmodels (if the value was returned).
-
updateFit
()[source]
-
updateFullMagnetModel
(param_dict)[source] Update the magnetism model with new parameters, create the errors column
-
updateFullModel
(param_dict)[source] Update the model with new parameters
-
updateFullPolyModel
(param_dict)[source] Update the polydispersity model with new parameters, create the errors column
-
updateKernelModelWithExtraParams
(model=None)[source] Updates kernel model ‘model’ with extra parameters from the polydisp and magnetism tab, if the tabs are enabled
-
updateMagnetModelFromList
(param_dict)[source] Update the magnetic model with new parameters, create the errors column
-
updateModelFromList
(param_dict)[source] Update the model with new parameters, create the errors column
-
updateModelIndex
(fitted_data)[source] Update a QStandardModelIndex containing model data
-
updateMultiplicityCombo
(multip)[source] Find and update the multiplicity combobox
-
updatePageWithParameters
(line_dict)[source] Update FitPage with parameters in line_dict
-
updatePolyModelFromList
(param_dict)[source] Update the polydispersity model with new parameters, create the errors column
-
updateQRange
()[source] Updates Q Range display
-
updateUndo
()[source] Create a new state page and add it to the stack
-
-
class
sas.qtgui.Perspectives.Fitting.FittingWidget.
ToolTippedItemModel
(parent=None)[source] Bases:
PyQt5.QtGui.QStandardItemModel
Subclass from QStandardItemModel to allow displaying tooltips in QTableView model.
-
headerData
(section, orientation, role=0)[source] Displays tooltip for each column’s header :param section: :param orientation: :param role: :return:
-
-
sas.qtgui.Perspectives.Fitting.FittingWidget.
get_weights
(self, name)[source] Returns the polydispersity distribution for parameter name as value and weight arrays.
sas.qtgui.Perspectives.Fitting.GPUOptions module
-
class
sas.qtgui.Perspectives.Fitting.GPUOptions.
GPUOptions
(parent=None)[source] Bases:
PyQt5.QtWidgets.QDialog
,sas.qtgui.Perspectives.Fitting.UI.GPUOptionsUI.Ui_GPUOptions
OpenCL Dialog to select the desired OpenCL driver
-
accept
()[source] Close the window after modifying the SAS_OPENCL value
-
addOpenCLOptions
()[source] Populate the window with a list of OpenCL options
-
checked
()[source] Only allow a single check box to be selected. Uncheck others.
-
cl_options
= None
-
clicked
= False
-
closeEvent
(event)[source] Overwrite QDialog close method to allow for custom widget close
-
createLinks
()[source] Link user interactions to function calls
-
helpButtonClicked
()[source] Open the help menu when the help button is clicked
-
reject
()[source] Close the window without modifying SAS_OPENCL
-
sas_open_cl
= None
-
set_sas_open_cl
()[source] Set SAS_OPENCL value when tests run or OK button clicked
-
testButtonClicked
()[source] Run sasmodels check from here and report results from
-
testComplete
(msg)[source] Testing done: send signal to main thread with update
-
testCompleted
(msg)[source] Respond to successful test completion
-
testFail
(msg)[source] Testing failed: log the reason
-
testFailed
(msg)[source] Testing failed: log the reason
-
testThread
(no_opencl_msg)[source] Testing in another thread
-
testingDoneSignal
-
testingFailedSignal
-
updateCounter
(step)[source] Update progress bar with current value
-
-
class
sas.qtgui.Perspectives.Fitting.GPUOptions.
GPUTestResults
(parent, msg)[source] Bases:
PyQt5.QtWidgets.QDialog
,sas.qtgui.Perspectives.Fitting.UI.GPUTestResultsUI.Ui_GPUTestResults
OpenCL Dialog to modify the OpenCL options
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
Widget for parameter constraints.
-
class
sas.qtgui.Perspectives.Fitting.MultiConstraint.
MultiConstraint
(parent=None, params=None, constraint=None)[source] Bases:
PyQt5.QtWidgets.QDialog
,sas.qtgui.Perspectives.Fitting.UI.MultiConstraintUI.Ui_MultiConstraintUI
Logic class for interacting with MultiConstrainedUI view
-
onHelp
()[source] Display related help section
-
revert
()[source] Swap parameters in the view
-
setupLabels
()[source] Setup labels based on current parameters
-
setupTooltip
()[source] Tooltip for txtConstraint
-
validateConstraint
(constraint_text)[source] Ensure the constraint has proper form
-
validateFormula
()[source] Add visual cues when formula is incorrect
-
sas.qtgui.Perspectives.Fitting.OptionsWidget module
Widget/logic for smearing data.
-
class
sas.qtgui.Perspectives.Fitting.OptionsWidget.
DataWidgetMapper
[source] Bases:
PyQt5.QtWidgets.QDataWidgetMapper
Custom version of the standard QDataWidgetMapper allowing for proper response to index change in comboboxes
-
addMapping
(self, QWidget, int)[source] addMapping(self, QWidget, int, Union[QByteArray, bytes, bytearray])
-
-
class
sas.qtgui.Perspectives.Fitting.OptionsWidget.
OptionsWidget
(parent=None, logic=None)[source] Bases:
PyQt5.QtWidgets.QWidget
,sas.qtgui.Perspectives.Fitting.UI.OptionsWidgetUI.Ui_tabOptions
-
MODEL
= ['MIN_RANGE', 'MAX_RANGE', 'NPTS', 'NPTS_FIT', 'LOG_SPACED']
-
NPTS_DEFAULT
= 50
-
QMAX_DEFAULT
= 0.5
-
QMIN_DEFAULT
= 0.0005
-
initMapper
()[source] Initialize model item <-> UI element mapping
-
initModel
()[source] Initialize the state
-
npts2fit
(data=None, qmin=None, qmax=None, npts=None)[source] return numbers of data points within qrange :Note: This is to normalize chisq by Npts of fit
-
onMaskEdit
()[source] Callback for running the mask editor
-
onModelChange
(top, bottom)[source] Respond to model change by updating the plot
-
onRangeReset
()[source] Callback for resetting qmin/qmax
-
onWeightingChoice
(button)[source] Update weighting in the fit state
-
plot_signal
-
setEnablementOnDataLoad
()[source] Enable/disable various UI elements based on data loaded
-
state
()[source] Returns current state of controls
-
toggleLogData
(isChecked)[source] Toggles between log and linear data sets
-
updateQRange
(q_range_min, q_range_max, npts)[source] Update the local model based on calculated values
-
sas.qtgui.Perspectives.Fitting.OrderWidget module
Widget/logic for dataset ordering.
-
class
sas.qtgui.Perspectives.Fitting.OrderWidget.
OrderWidget
(parent=None, all_data=None)[source] Bases:
PyQt5.QtWidgets.QWidget
,sas.qtgui.Perspectives.Fitting.UI.OrderWidgetUI.Ui_OrderWidgetUI
-
ordering
()[source] Returns the current ordering of the datasets
-
setupTable
()[source] Populate the widget with dataset names in original order
-
updateData
(all_data)[source] Read in new datasets and update the view
-
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
Widget/logic for smearing data.
-
class
sas.qtgui.Perspectives.Fitting.SmearingWidget.
DataWidgetMapper
[source] Bases:
PyQt5.QtWidgets.QDataWidgetMapper
Custom version of the standard QDataWidgetMapper allowing for proper response to index change in comboboxes
-
addMapping
(self, QWidget, int)[source] addMapping(self, QWidget, int, Union[QByteArray, bytes, bytearray])
-
-
class
sas.qtgui.Perspectives.Fitting.SmearingWidget.
SmearingWidget
(parent=None)[source] Bases:
PyQt5.QtWidgets.QWidget
,sas.qtgui.Perspectives.Fitting.UI.SmearingWidgetUI.Ui_SmearingWidgetUI
-
getSmearInfo
()[source] Get the smear info from data.
Returns: self.smear_type, self.dq_l and self.dq_r, respectively the type of the smear, the average <dq/q> radial(p) and <dq/q> theta (s)s for 2D pinhole resolution in % (slit is not currently supported in 2D), (dq/q)_min and (dq/q)_max for 1D pinhole smeared data, again in %, and dxl and/or dxw for slit smeared data given in 1/A and assumed constant.
-
initMapper
()[source] Initialize model item <-> UI element mapping
-
initModel
()[source] Initialize the state
-
onIndexChange
(index)[source] Callback for smearing combobox index change
-
onModelChange
()[source] Respond to model change by notifying any listeners
-
onPinholeSmear
()[source] Create a custom pinhole smear object that will change the way residuals are compute when fitting
-
onSlitSmear
()[source] Create a custom slit smear object that will change the way residuals are compute when fitting
-
setAccuracyVisibility
()[source] Accuracy combobox visibility
-
setDQLabels
()[source] Use appropriate labels
-
setElementsVisibility
(visible)[source] Labels and linedits visibility control
-
setPinholeLabels
()[source] Use pinhole labels
-
setSlitLabels
()[source] Use pinhole labels
-
setState
(smearing, accuracy, d_down, d_up)[source] Sets new values for the controls
-
smearer
()[source] Returns the current smearer
-
smearingChangedSignal
-
state
()[source] Returns current state of controls
-
updateData
(data=None)[source] Update control elements based on data and model passed
-
updateKernelModel
(kernel_model=None, keep_order=False)[source] Update the model
-
sas.qtgui.Perspectives.Fitting.ViewDelegate module
-
class
sas.qtgui.Perspectives.Fitting.ViewDelegate.
MagnetismViewDelegate
(parent=None)[source] Bases:
PyQt5.QtWidgets.QStyledItemDelegate
Custom delegate for appearance and behavior control of the magnetism view
-
addErrorColumn
()[source] Modify local column pointers Note: the reverse is never required!
-
createEditor
(self, QWidget, QStyleOptionViewItem, QModelIndex) → QWidget[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:
PyQt5.QtWidgets.QStyledItemDelegate
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:
PyQt5.QtWidgets.QStyledItemDelegate
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
-
createEditor
(self, QWidget, QStyleOptionViewItem, QModelIndex) → QWidget[source]
-
editableParameters
()[source]
-
filename_updated
-
paint
(painter, option, index)[source] Overwrite generic painter for certain columns
-