sas.qtgui.Perspectives.Fitting package

Subpackages

Submodules

sas.qtgui.Perspectives.Fitting.AssociatedComboBox module

class sas.qtgui.Perspectives.Fitting.AssociatedComboBox.AssociatedComboBox(item: QtGui.QStandardItem, idx_as_value: bool = False, parent: QtWidgets.QWidget = None)

Bases: 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.

__doc__ = "Just a regular combo box, but associated with a particular QStandardItem so that it can be used to display and\n    select an item's current text and a restricted list of other possible text.\n\n    When the combo box's current text is changed, the change is immediately reflected in the associated item; either\n    the text itself is set as the item's data, or the current index is used; see constructor."
__init__(item: QtGui.QStandardItem, idx_as_value: bool = False, parent: QtWidgets.QWidget = None) None

Initialize widget. idx_as_value indicates whether to use the combo box’s current index (otherwise, current text) as the associated item’s new data.

__module__ = 'sas.qtgui.Perspectives.Fitting.AssociatedComboBox'
_onIndexChanged(idx: int) None

Callback for combo box’s currentIndexChanged. Set associated item’s data to the new index.

_onTextChanged(text: str) None

Callback for combo box’s currentTextChanged. Set associated item’s data to the new text.

item: QtGui.QStandardItem = None
staticMetaObject = PySide6.QtCore.QMetaObject("AssociatedComboBox" inherits "QComboBox": )

sas.qtgui.Perspectives.Fitting.ComplexConstraint module

Widget for multi-model constraints.

class sas.qtgui.Perspectives.Fitting.ComplexConstraint.ComplexConstraint(parent=None, tabs=None)

Bases: QDialog, Ui_ComplexConstraintUI

__doc__ = None
__init__(self, /, parent: PySide6.QtWidgets.QWidget | None = None, f: PySide6.QtCore.Qt.WindowType = Default(Qt.WindowFlags), *, sizeGripEnabled: bool | None = None, modal: bool | None = None) None

Initialize self. See help(type(self)) for accurate signature.

__module__ = 'sas.qtgui.Perspectives.Fitting.ComplexConstraint'
applyAcrossTabs(tabs, param, expr)

Apply constraints across tabs, e.g. all scale parameters constrained to an expression. tabs is a list of active fit tabs for which the parameter string param will be constrained to the expr string.

constraint()

Return the generated constraint

constraintIsRedefined(cons_tuple)

Warn the user when a constraint is being redefined

constraintReadySignal
onApply()

Respond to Add constraint action. Send a signal that the constraint is ready to be applied

onHelp()

Display related help section

onModelIndexChange(index)

Respond to mode combo box changes

onOperatorChange(index)

Respond to operator combo box changes

onParamIndexChange(index)

Respond to parameter combo box changes

onSetAll()

Set constraints on all identically named parameters between two fitpages

setupData()

Digs into self.tabs and pulls out relevant info

setupMenu()
setupParamWidgets()

Fill out comboboxes and set labels with non-constrained parameters

setupSignals()

Signals from various elements

setupTooltip()

Tooltip for txtConstraint

setupWidgets()

Setup widgets based on current parameters

staticMetaObject = PySide6.QtCore.QMetaObject("ComplexConstraint" inherits "QDialog": Methods:   #41 type=Signal, signature=constraintReadySignal(PyObject), parameters=PyObject )
validateConstraint(constraint_text)

Ensure the constraint has proper form

validateFormula()

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)

Bases: FitHandler

Print progress to the console.

__doc__ = '\n    Print progress to the console.\n    '
__init__(parent, manager=None, quiet=False, progress_delta=60, improvement_delta=5)

If quiet is true, only print out final summary, not progress and improvements.

Attr parent:

the object that handle the messages

__module__ = 'sas.qtgui.Perspectives.Fitting.ConsoleUpdate'
abort()
error(msg)

Model had an error; print traceback

finalize()
get_result()
improvement()

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()

Print result object

progress(k, n)

Report on progress.

progress_delta = 60

Number of seconds between progress updates

set_result(result)
stop(msg)

Post event msg and stop

update_fit(last=False)

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='=')

Bases: object

Internal representation of a single parameter constraint Currently just a data structure, might get expanded with more functionality, hence made into a class.

__dict__ = mappingproxy({'__module__': 'sas.qtgui.Perspectives.Fitting.Constraint', '__doc__': '\n    Internal representation of a single parameter constraint\n    Currently just a data structure, might get expanded with more functionality,\n    hence made into a class.\n    ', '__init__': <function Constraint.__init__>, 'value': <property object>, 'value_ex': <property object>, 'param': <property object>, 'func': <property object>, 'min': <property object>, 'max': <property object>, 'operator': <property object>, 'model': <property object>, '__dict__': <attribute '__dict__' of 'Constraint' objects>, '__weakref__': <attribute '__weakref__' of 'Constraint' objects>, '__annotations__': {}})
__doc__ = '\n    Internal representation of a single parameter constraint\n    Currently just a data structure, might get expanded with more functionality,\n    hence made into a class.\n    '
__init__(parent=None, param=None, value=0.0, min=None, max=None, func=None, value_ex=None, operator='=')
__module__ = 'sas.qtgui.Perspectives.Fitting.Constraint'
__weakref__

list of weak references to the object

property func
property max
property min
property model
property operator
property param
property value
property value_ex

sas.qtgui.Perspectives.Fitting.ConstraintWidget module

class sas.qtgui.Perspectives.Fitting.ConstraintWidget.ConstraintWidget(parent=None)

Bases: QWidget, Ui_ConstraintWidgetUI

Constraints Dialog to select the desired parameter/model constraints.

__doc__ = '\n    Constraints Dialog to select the desired parameter/model constraints.\n    '
__init__(self, /, parent: PySide6.QtWidgets.QWidget | None = None, f: PySide6.QtCore.Qt.WindowType = Default(Qt.WindowFlags), *, modal: bool | None = None, windowModality: PySide6.QtCore.Qt.WindowModality | None = None, enabled: bool | None = None, geometry: PySide6.QtCore.QRect | None = None, frameGeometry: PySide6.QtCore.QRect | None = None, normalGeometry: PySide6.QtCore.QRect | None = None, x: int | None = None, y: int | None = None, pos: PySide6.QtCore.QPoint | None = None, frameSize: PySide6.QtCore.QSize | None = None, size: PySide6.QtCore.QSize | None = None, width: int | None = None, height: int | None = None, rect: PySide6.QtCore.QRect | None = None, childrenRect: PySide6.QtCore.QRect | None = None, childrenRegion: PySide6.QtGui.QRegion | None = None, sizePolicy: PySide6.QtWidgets.QSizePolicy | None = None, minimumSize: PySide6.QtCore.QSize | None = None, maximumSize: PySide6.QtCore.QSize | None = None, minimumWidth: int | None = None, minimumHeight: int | None = None, maximumWidth: int | None = None, maximumHeight: int | None = None, sizeIncrement: PySide6.QtCore.QSize | None = None, baseSize: PySide6.QtCore.QSize | None = None, palette: PySide6.QtGui.QPalette | None = None, font: PySide6.QtGui.QFont | None = None, cursor: PySide6.QtGui.QCursor | None = None, mouseTracking: bool | None = None, tabletTracking: bool | None = None, isActiveWindow: bool | None = None, focusPolicy: PySide6.QtCore.Qt.FocusPolicy | None = None, focus: bool | None = None, contextMenuPolicy: PySide6.QtCore.Qt.ContextMenuPolicy | None = None, updatesEnabled: bool | None = None, visible: bool | None = None, minimized: bool | None = None, maximized: bool | None = None, fullScreen: bool | None = None, sizeHint: PySide6.QtCore.QSize | None = None, minimumSizeHint: PySide6.QtCore.QSize | None = None, acceptDrops: bool | None = None, windowTitle: str | None = None, windowIcon: PySide6.QtGui.QIcon | None = None, windowIconText: str | None = None, windowOpacity: float | None = None, windowModified: bool | None = None, toolTip: str | None = None, toolTipDuration: int | None = None, statusTip: str | None = None, whatsThis: str | None = None, accessibleName: str | None = None, accessibleDescription: str | None = None, accessibleIdentifier: str | None = None, layoutDirection: PySide6.QtCore.Qt.LayoutDirection | None = None, autoFillBackground: bool | None = None, styleSheet: str | None = None, locale: PySide6.QtCore.QLocale | None = None, windowFilePath: str | None = None, inputMethodHints: PySide6.QtCore.Qt.InputMethodHint | None = None) None

Initialize self. See help(type(self)) for accurate signature.

__module__ = 'sas.qtgui.Perspectives.Fitting.ConstraintWidget'
acceptsData()

Tells the caller this widget doesn’t accept data

batchComplete(result)

Respond to the successful batch fit complete signal

batchCompleteSignal
createPageForParameters(parameters=None)

Update the page with passed parameter values

deleteConstraint()

Delete all selected constraints.

deselectConstraints()

Selected constraints are removed for fitting

deselectModels()

Selected models are removed for fitting

fitComplete(result)

Respond to the successful fit complete signal

fitCompleteSignal
fitFailed(reason)

Respond to fitting failure.

fitFailedSignal
getFitModel()

Retrieves current model

getFitPage()

Retrieves the state of this page

getObjectByName(name)

Given name of the fit, returns associated fit object

getReport()

Wrapper for non-existent functionality. Tell the user to use the reporting tool on separate fit pages.

getTabsForFit()

Returns list of tab names selected for fitting

initializeFitList(row=0, model_key='standard')

Fill the list of model/data sets for fitting/constraining

initializeSignals()

Set up signals/slots for this widget

initializeWidgets()

Set up various widget states

isTabImportable(tab)

Determines if the tab can be imported and included in the widget

onAcceptConstraint(con_tuple)

Receive constraint tuple from the ComplexConstraint dialog and adds constraint. Checks the constraints for errors and displays a warning message interrupting flow if any are found

onBatchFitComplete(result)

Send the fit complete signal to main thread

onChainFit(is_checked)

Respond to selecting the Chain Fit checkbox

onConstraintChange(row, column)

Modify the constraint when the user edits the constraint list. If the user changes the constrained parameter, the constraint is erased and a new one is created. Checking is performed on the constrained entered by the user. In case of an error during checking, a warning message box is shown and the constraint is cancelled by reloading the view. View is also reloaded when the user is finished for consistency.

onFit()

Perform the constrained/simultaneous fit

onFitComplete(result)

Send the fit complete signal to main thread

onFitFailed(reason)

Send the fit failed signal to main thread

onFitTypeChange(checked)

Respond to the fit type change single fit/batch fit

onHelp()

Show the “Fitting” section of help

onSpecialCaseChange(index)

Respond to the combobox change for special case constraint sets

onTabCellEdit(row, column)

Respond to check/uncheck and to modify the model moniker and weighting actions

onTabCellEntered(row, column)

Remember the original tab list cell data. Needed for reverting back on bad validation

onWeightModify(is_checked)

Respond to selecting the Modify weighting checkbox

orderedSublist(order_list, target_list)

Orders the target_list such that any elements present in order_list show up first and in the order from order_list.

selectConstraints()

Selected constraints are chosen for fitting

selectModels()

Selected models are chosen for fitting

selectedParameters(widget)

Returns list of selected (highlighted) parameters

setRowSelection(widget, status=CheckState.Unchecked)

Selected models are chosen for fitting

showConstrContextMenu(position)

Show context specific menu in the tab table widget.

showModelContextMenu(position)

Show context specific menu in the tab table widget.

showMultiConstraint()

Invoke the complex constraint editor

staticMetaObject = PySide6.QtCore.QMetaObject("ConstraintWidget" inherits "QWidget": Methods:   #33 type=Signal, signature=fitCompleteSignal(PyObject), parameters=PyObject   #34 type=Signal, signature=batchCompleteSignal(PyObject), parameters=PyObject   #35 type=Signal, signature=fitFailedSignal(PyObject), parameters=PyObject )
uncheckConstraint(name)

Unchecks the constraint in tblConstraint with name slave parameter and deactivates the constraint.

uneditableItem(data='')

Returns an uneditable Table Widget Item

updateFitLine(tab, model_key='standard')

Update a single line of the table widget with tab info

updateSignalsFromTab(tab=None)

Intercept update signals from fitting tabs

validateMoniker(new_moniker=None)

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)

Bases: QTableWidget

__doc__ = None
__init__(self, /, parent: PySide6.QtWidgets.QWidget | None = None, *, rowCount: int | None = None, columnCount: int | None = None) None
__init__(self, rows: int, columns: int, /, parent: PySide6.QtWidgets.QWidget | None = None, *, rowCount: int | None = None, columnCount: int | None = None) None

Initialize self. See help(type(self)) for accurate signature.

__module__ = 'sas.qtgui.Perspectives.Fitting.ConstraintWidget'
dragEnterEvent(event)

Called automatically on a drag in the TableWidget

dragLeaveEvent(event)

Called automatically on a drag stop

dropEvent(self, event: PySide6.QtGui.QDropEvent, /) None
drop_on(event)
isDragged()

Return the drag status

is_below(pos, index)
staticMetaObject = PySide6.QtCore.QMetaObject("DnDTableWidget" inherits "QTableWidget": )

sas.qtgui.Perspectives.Fitting.FitPage module

Container class for fitting widget state storage

class sas.qtgui.Perspectives.Fitting.FitPage.FitPage

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
__dict__ = mappingproxy({'__module__': 'sas.qtgui.Perspectives.Fitting.FitPage', '__doc__': '\n    Container for all data related to the current fit page\n    ', 'MIN_RANGE': 0, 'MAX_RANGE': 1, 'NPTS': 2, 'NPTS_FIT': 3, 'LOG_POINTS': 4, 'WEIGHTING': 5, 'SMEARING_OPTION': 6, 'SMEARING_ACCURACY': 7, 'SMEARING_MIN': 8, 'SMEARING_MAX': 9, '__init__': <function FitPage.__init__>, 'save': <function FitPage.save>, 'load': <function FitPage.load>, 'saveAsXML': <function FitPage.saveAsXML>, '__dict__': <attribute '__dict__' of 'FitPage' objects>, '__weakref__': <attribute '__weakref__' of 'FitPage' objects>, '__annotations__': {}})
__doc__ = '\n    Container for all data related to the current fit page\n    '
__init__()

Define the dictionary

__module__ = 'sas.qtgui.Perspectives.Fitting.FitPage'
__weakref__

list of weak references to the object

load(location)

Retrieve serialized state from specified location

save()

Serialize the current state

saveAsXML()

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)

Bases: CalcThread

Thread performing the fit

__doc__ = 'Thread performing the fit '
__init__(fn, page_id, handler, batch_outputs, batch_inputs=None, pars=None, completefn=None, updatefn=None, yieldtime=0.03, worktime=0.03, reset_flag=False)
__module__ = 'sas.qtgui.Perspectives.Fitting.FitThread'
compute()

Perform a fit

isquit()
Raises:

KeyboardInterrupt – when the thread is interrupted

sas.qtgui.Perspectives.Fitting.FitThread.map_apply(arguments)
sas.qtgui.Perspectives.Fitting.FitThread.map_getattr(classInstance, classFunc, *args)

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)

Bases: object

All the data-related logic. This class deals exclusively with Data1D/2D No QStandardModelIndex here.

__dict__ = mappingproxy({'__module__': 'sas.qtgui.Perspectives.Fitting.FittingLogic', '__doc__': '\n    All the data-related logic. This class deals exclusively with Data1D/2D\n    No QStandardModelIndex here.\n    ', '__init__': <function FittingLogic.__init__>, 'data': <property object>, 'isLoadedData': <function FittingLogic.isLoadedData>, 'setDataProperties': <function FittingLogic.setDataProperties>, 'createDefault1dData': <function FittingLogic.createDefault1dData>, 'createDefault2dData': <function FittingLogic.createDefault2dData>, '_create1DPlot': <function FittingLogic._create1DPlot>, 'new1DPlot': <function FittingLogic.new1DPlot>, 'new2DPlot': <function FittingLogic.new2DPlot>, 'new1DProductPlots': <function FittingLogic.new1DProductPlots>, 'getScalarIntermediateResults': <function FittingLogic.getScalarIntermediateResults>, 'computeDataRange': <function FittingLogic.computeDataRange>, 'computeRangeFromData': <function FittingLogic.computeRangeFromData>, '__dict__': <attribute '__dict__' of 'FittingLogic' objects>, '__weakref__': <attribute '__weakref__' of 'FittingLogic' objects>, '__annotations__': {}})
__doc__ = '\n    All the data-related logic. This class deals exclusively with Data1D/2D\n    No QStandardModelIndex here.\n    '
__init__(data=None)
__module__ = 'sas.qtgui.Perspectives.Fitting.FittingLogic'
__weakref__

list of weak references to the object

_create1DPlot(tab_id, x, y, model, data, component=None)

For internal use: create a new 1D data instance based on fitting results. ‘component’ is a string indicating the model component, e.g. “P(Q)”

computeDataRange()

Wrapper for calculating the data range based on local dataset

computeRangeFromData(data)

Compute the minimum and the maximum range of the data return the npts contains in data

createDefault1dData(interval, tab_id=0)

Create default data for fitting perspective Only when the page is on theory mode.

createDefault2dData(qmax, qstep, tab_id=0)

Create 2D data by default Only when the page is on theory mode.

property data
getScalarIntermediateResults(return_data)

Returns a dict of scalar-only intermediate results from the return data.

isLoadedData()

accessor

new1DPlot(return_data, tab_id)

Create a new 1D data instance based on fitting results

new1DProductPlots(return_data, tab_id)

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)

Create a new 2D data instance based on fitting results

setDataProperties()

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(config=None)

Bases: PreferencesWidget, 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)]
__doc__ = '\n    Hard-coded version of the fit options dialog available from BUMPS.\n    This should be make more "dynamic".\n    bumps.options.FIT_FIELDS gives mapping between parameter names, parameter strings and field type\n    (double line edit, integer line edit, combo box etc.), e.g.::\n\n        FIT_FIELDS = dict(\n            samples = ("Samples", parse_int),\n            xtol = ("x tolerance", float),\n        )\n\n    bumps.fitters.<algorithm>.settings gives mapping between algorithm, parameter name and default value, e.g.::\n\n        >>> settings = [(\'steps\', 1000), (\'starts\', 1), (\'radius\', 0.15), (\'xtol\', 1e-6), (\'ftol\', 1e-8)]\n    '
__init__(self, /, parent: PySide6.QtWidgets.QWidget | None = None, f: PySide6.QtCore.Qt.WindowType = Default(Qt.WindowFlags), *, modal: bool | None = None, windowModality: PySide6.QtCore.Qt.WindowModality | None = None, enabled: bool | None = None, geometry: PySide6.QtCore.QRect | None = None, frameGeometry: PySide6.QtCore.QRect | None = None, normalGeometry: PySide6.QtCore.QRect | None = None, x: int | None = None, y: int | None = None, pos: PySide6.QtCore.QPoint | None = None, frameSize: PySide6.QtCore.QSize | None = None, size: PySide6.QtCore.QSize | None = None, width: int | None = None, height: int | None = None, rect: PySide6.QtCore.QRect | None = None, childrenRect: PySide6.QtCore.QRect | None = None, childrenRegion: PySide6.QtGui.QRegion | None = None, sizePolicy: PySide6.QtWidgets.QSizePolicy | None = None, minimumSize: PySide6.QtCore.QSize | None = None, maximumSize: PySide6.QtCore.QSize | None = None, minimumWidth: int | None = None, minimumHeight: int | None = None, maximumWidth: int | None = None, maximumHeight: int | None = None, sizeIncrement: PySide6.QtCore.QSize | None = None, baseSize: PySide6.QtCore.QSize | None = None, palette: PySide6.QtGui.QPalette | None = None, font: PySide6.QtGui.QFont | None = None, cursor: PySide6.QtGui.QCursor | None = None, mouseTracking: bool | None = None, tabletTracking: bool | None = None, isActiveWindow: bool | None = None, focusPolicy: PySide6.QtCore.Qt.FocusPolicy | None = None, focus: bool | None = None, contextMenuPolicy: PySide6.QtCore.Qt.ContextMenuPolicy | None = None, updatesEnabled: bool | None = None, visible: bool | None = None, minimized: bool | None = None, maximized: bool | None = None, fullScreen: bool | None = None, sizeHint: PySide6.QtCore.QSize | None = None, minimumSizeHint: PySide6.QtCore.QSize | None = None, acceptDrops: bool | None = None, windowTitle: str | None = None, windowIcon: PySide6.QtGui.QIcon | None = None, windowIconText: str | None = None, windowOpacity: float | None = None, windowModified: bool | None = None, toolTip: str | None = None, toolTipDuration: int | None = None, statusTip: str | None = None, whatsThis: str | None = None, accessibleName: str | None = None, accessibleDescription: str | None = None, accessibleIdentifier: str | None = None, layoutDirection: PySide6.QtCore.Qt.LayoutDirection | None = None, autoFillBackground: bool | None = None, styleSheet: str | None = None, locale: PySide6.QtCore.QLocale | None = None, windowFilePath: str | None = None, inputMethodHints: PySide6.QtCore.Qt.InputMethodHint | None = None) None

Initialize self. See help(type(self)) for accurate signature.

__module__ = 'sas.qtgui.Perspectives.Fitting.FittingOptions'
_addAllWidgets()

A private pseudo-abstract class that children should override. Widgets with their own UI file should pass.

_algorithm_change(index)

Change the page in response to combo box index. Can also be called programmatically.

_restoreFromConfig()

A pseudo-abstract class that children should override. Recalls all config values and restores the GUI.

_toggleBlockAllSignaling(toggle: bool)

A pseudo-abstract class that children should override. Toggles signalling for all elements.

addSignals()
applyNonConfigValues()

Applies values that aren’t stored in config. Only widgets that require this need to override this method.

assignValidators()

Use options.FIT_FIELDS to assert which line edit gets what validator

check_state(*args, **kwargs)
fit_option_changed
getResults()

Sends back the current choice of parameters

name: str = 'Fit Optimizers'
onAlgorithmChange(index)

Triggered method when the index of the combo box changes.

onDefaultAlgorithmChange()
onHelp()

Show the “Fitting options” section of help

staticMetaObject = PySide6.QtCore.QMetaObject("FittingOptions" inherits "PreferencesWidget": Methods:   #33 type=Signal, signature=fit_option_changed(QString), parameters=QString )
updateWidgetFromBumps(fitter_id)

Given the ID of the current optimizer, fetch the values and update the widget

widgetFromOption(option_id, current_fitter=None)

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)

Bases: QTabWidget, Perspective

__doc__ = '\n    '
__init__(self, /, parent: PySide6.QtWidgets.QWidget | None = None, *, tabPosition: PySide6.QtWidgets.QTabWidget.TabPosition | None = None, tabShape: PySide6.QtWidgets.QTabWidget.TabShape | None = None, currentIndex: int | None = None, count: int | None = None, iconSize: PySide6.QtCore.QSize | None = None, elideMode: PySide6.QtCore.Qt.TextElideMode | None = None, usesScrollButtons: bool | None = None, documentMode: bool | None = None, tabsClosable: bool | None = None, movable: bool | None = None, tabBarAutoHide: bool | None = None) None

Initialize self. See help(type(self)) for accurate signature.

__module__ = 'sas.qtgui.Perspectives.Fitting.FittingPerspective'
addClosedTab()

Recover the deleted tab. The tab is held in self.lastTabClosed

addConstraintTab()

Add a new C&S fitting tab

addFit(data, is_batch=False, tab_index=None)

Add a new tab for passed data

allowBatch()

Tell the caller that we accept multiple data instances

allowSwap()

Tell the caller that you can swap data

clipboard_copy()

Called by copy menu item

clipboard_paste()

Called by paste menu item

closeEvent(event)

Overwrite QDialog close method to allow for custom widget close

closeTabByIndex(index)

Close/delete a tab with the given index. No checks on validity of the index.

closeTabByName(tab_name)

Given name of the fitting tab - close it

property currentFittingWidget: FittingWidget | None
property currentTab

Returns the tab widget currently shown

currentTabDataId()

Returns the data ID of the current tab

dataDeleted(index_list)

Delete fit tabs referencing given data

eventFilter(self, watched: PySide6.QtCore.QObject, event: PySide6.QtCore.QEvent, /) bool
excel_clipboard_copy()

Called by copy excel menu item

ext = 'fitv'
fittingStartedSignal
fittingStoppedSignal
getActiveConstraintList()

Returns a list of the constraints for all fitting tabs. Constraints are a tuple of strings (parameter, expression) e.g. (‘M1.scale’, ‘M2.scale + 2’)

getCSTabName()

Get the new tab name, based on the number of fitting tabs so far

getConstraintTab()

Returns the constraint tab, or None if no constraint tab is active

getCurrentStateAsXml()

Returns an XML version of the current state

getFitTabs()

Returns the list of fitting tabs

getReport() ReportData | None

Get the report from the current tab

getSerializedFitpage(tab)

get serialize requested fit tab

getSymbolDictForConstraints()

Returns a dictionary containing all the symbols in all constrained tabs and their values.

getTabByName(name)

Returns the tab with with attribute name name

getTabName(is_batch=False)

Get the new tab name, based on the number of fitting tabs so far

isSerializable()

Tell the caller that this perspective writes its state

latex_clipboard_copy()

Called by copy latex menu item

name = 'Fitting'
nextAvailableTabIndex()

Returns the index of the next available tab

onFittingOptionsChange(fit_engine)

React to the fitting algorithm change by modifying window title

onFittingStarted(tabs_for_fitting=None)

Notify tabs listed in tabs_for_fitting that the fitting thread started

onFittingStopped(tabs_for_fitting=None)

Notify tabs listed in tabs_for_fitting that the fitting thread stopped

property preferences

Return a list of widgets that should be added to the preferences panel.

resetTab(index)

Adds a new tab and removes the last tab as a way of resetting the fit tabs

save_parameters()

Save parameters to a file

serializeAll()
serializeAllFitpage()
serializeCurrentPage()
setClosable(value=True)

Allow outsiders to close this widget

setData(data_item=None, is_batch=False, tab_index=None)

Assign new dataset to the fitting instance Obtain a QStandardItem object and dissect it to get Data1D/2D Pass it over to the calculator

staticMetaObject = PySide6.QtCore.QMetaObject("FittingWindow" inherits "QTabWidget": Methods:   #39 type=Signal, signature=tabsModifiedSignal()   #40 type=Signal, signature=fittingStartedSignal(QVariantList), parameters=QVariantList   #41 type=Signal, signature=fittingStoppedSignal(QVariantList), parameters=QVariantList )
property supports_copy: bool

Does this perspective support copy functionality?

property supports_copy_excel: bool

Does this perspective support copy functionality?

property supports_copy_latex: bool

Does this perspective support copy functionality?

property supports_fitting_menu: bool

Should the fitting menu be shown when using this perspective (unless its Fitting, probably not)

property supports_paste: bool

Does this perspective allow pasting?

property supports_reports: bool

Does this perspective have a report functionality (currently used by menus and toolbar)

swapData(data)

Replace the data from the current fitting tab

tabCloses(index)

Update local bookkeeping on tab close

tabsModifiedSignal
property title

Window title

updateFitDict(item_key, tab_name)

Create a list if none exists and append if there’s already a list

updateFromConstraints(constraint_dict)

Updates all tabs with constraints present in constraint_dict, where constraint_dict keys are the fit page name, and the value is a list of constraints. A constraint is represented by a list [value, param, value_ex, validate, function] of attributes of a Constraint object

updateFromParameters(parameters)

Pass the update parameters to the current fit page

updateWindowTitle()

Update the window title with the current optimizer name

sas.qtgui.Perspectives.Fitting.FittingUtilities module

class sas.qtgui.Perspectives.Fitting.FittingUtilities.ToolTippedItemModel(parent=None)

Bases: QStandardItemModel

Subclass from QStandardItemModel to allow displaying tooltips in QTableView model.

__doc__ = '\n    Subclass from QStandardItemModel to allow displaying tooltips in\n    QTableView model.\n    '
__init__(self, /, parent: PySide6.QtCore.QObject | None = None, *, sortRole: int | None = None) None
__init__(self, rows: int, columns: int, /, parent: PySide6.QtCore.QObject | None = None, *, sortRole: int | None = None) None

Initialize self. See help(type(self)) for accurate signature.

__module__ = 'sas.qtgui.Perspectives.Fitting.FittingUtilities'
headerData(section, orientation, role=ItemDataRole.DisplayRole)

Displays tooltip for each column’s header :param section: :param orientation: :param role: :return:

staticMetaObject = PySide6.QtCore.QMetaObject("ToolTippedItemModel" inherits "QStandardItemModel": )
sas.qtgui.Perspectives.Fitting.FittingUtilities.addCheckedListToModel(model, param_list)

Add a QItem to model. Makes the QItem checkable

sas.qtgui.Perspectives.Fitting.FittingUtilities.addErrorHeadersToModel(model)

Adds predefined headers to the model

sas.qtgui.Perspectives.Fitting.FittingUtilities.addErrorPolyHeadersToModel(model)

Adds predefined headers to the model

sas.qtgui.Perspectives.Fitting.FittingUtilities.addHeadersToModel(model)

Adds predefined headers to the model

sas.qtgui.Perspectives.Fitting.FittingUtilities.addHeadingRowToModel(model, name)

adds a non-interactive top-level row to the model

sas.qtgui.Perspectives.Fitting.FittingUtilities.addParametersToModel(parameters, kernel_module, is2D, model=None, view=None)

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)

Adds predefined headers to the model

sas.qtgui.Perspectives.Fitting.FittingUtilities.addShellsToModel(parameters, model, index, row_num=None, view=None)

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)

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)
sas.qtgui.Perspectives.Fitting.FittingUtilities.calcWeightIncrease(weights, ratios, flag=False)
Calculate the weights to be passed to bumps in order to ensure

that each data set contributes to the total residual with a relative weight roughly proportional to the ratios defined by the user when the “Modify weighting” option is employed.

The influence of each data set in the global fit is approximately proportional to the number of points and to (1/sigma^2), or probably better to (1/relative_error^2) = (intensity/sigma)^2.

Therefore in order to try to give equal weights to each data set in the global fitting, we can compute the total relative weight of each data set as the sum (y_i/dy_i**2) over all the points in the data set and then renormalize them using:

user_weight[dataset] * sqrt(min(relative_weights) / relative_weights[dataset])

If all user weights are one (the default), this will decrease the weight of the data sets initially contributing more to the global fit, while keeping the weight of the initially smaller contributor equal to one.

These weights are stored for each data set (FitPage) in a dictionary that will be then used by bumps to modify the weights of each set.

Warning: As bumps uses the data set weights to multiply the residuals calculated as (y-f(x))/sigma, it would probably make sense to include the value of user_weight[dataset] in the square root, but as in any case this is just a qualitative way of increasing/decreasing the weight of some datasets and there is not a real mathematical justification behind, this provides a more intuitive behaviour for the user, who will see that the final weights of the data sets vary proportionally to changes in the input user weights.

Parameters:
  • weights (dict of numpy.ndarray) – Dictionary of data for the statistical weight, typical the y axis error

  • ratios (dict) – Desired relative statistical weight ratio between the different datasets.

  • flag (bool) – Boolean indicating if the weight of the datasets should be modified or not, which depends on the “Modify weighting” box in the Simultaneous Fit tab being checked or not

Returns:

Weight multiplier for each dataset

Return type:

dict

sas.qtgui.Perspectives.Fitting.FittingUtilities.calculateChi2(reference_data, current_data, weight)

Calculate Chi2 value between two sets of data

sas.qtgui.Perspectives.Fitting.FittingUtilities.checkConstraints(symtab: Dict[str, float], constraints: Sequence[Tuple[str, str]]) str

Compile and evaluate the constraints in the context of the initial values and return the list of errors.

Errors are returned as an html string where errors are tagged with <b> markups: Unknown symbol: tags unknown symbols in constraints Syntax error: tags the beginning of a syntax error in constraints Cyclic dependency: tags comma separated parameters that have cyclic dependency

The errors are wrapped in a <div class = “error”> and a style header is added

sas.qtgui.Perspectives.Fitting.FittingUtilities.createFixedChoiceComboBox(param, item_row)

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: list, entry_sep=',', line_sep=':')

Prepare the parameter string in the standard SasView layout

sas.qtgui.Perspectives.Fitting.FittingUtilities.formatParametersExcel(parameters: list)

Prepare the parameter string in the Excel format (tab delimited)

sas.qtgui.Perspectives.Fitting.FittingUtilities.formatParametersLatex(parameters: list)

Prepare the parameter string in latex

sas.qtgui.Perspectives.Fitting.FittingUtilities.getIterParams(model)

Returns a list of all multi-shell parameters in ‘model’

sas.qtgui.Perspectives.Fitting.FittingUtilities.getMultiplicity(model)

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)

Get the dictionary with orientation parameters

sas.qtgui.Perspectives.Fitting.FittingUtilities.getRelativeError(data, is2d, flag=None)

Return dy/y.

sas.qtgui.Perspectives.Fitting.FittingUtilities.getStandardParam(model=None)

Returns a list with standard parameters for the current model

sas.qtgui.Perspectives.Fitting.FittingUtilities.getWeight(data, is2d, flag=None)

Received flag and compute error on data. :param flag: flag to transform error of data.

sas.qtgui.Perspectives.Fitting.FittingUtilities.isNumber(s)

Checks if string ‘s’ is an int/float

sas.qtgui.Perspectives.Fitting.FittingUtilities.isParamPolydisperse(param_name, kernel_params, is2D=False)

Simple lookup for polydispersity for the given param name

sas.qtgui.Perspectives.Fitting.FittingUtilities.markParameterDisabled(model, row)

Given the QModel row number, format to show it is not available for fitting

sas.qtgui.Perspectives.Fitting.FittingUtilities.plotPolydispersities(model)
sas.qtgui.Perspectives.Fitting.FittingUtilities.plotResiduals(reference_data, current_data, weights)

Create Data1D/Data2D with residuals, ready for plotting

sas.qtgui.Perspectives.Fitting.FittingUtilities.replaceShellName(param_name, value)

Updates parameter name from <param_name>[n_shell] to <param_name>value

sas.qtgui.Perspectives.Fitting.FittingUtilities.residualsData1D(reference_data, current_data, weights)

Calculate the residuals for difference of two Data1D sets

sas.qtgui.Perspectives.Fitting.FittingUtilities.residualsData2D(reference_data, current_data, weight)

Calculate the residuals for difference of two Data2D sets

sas.qtgui.Perspectives.Fitting.FittingUtilities.setTableProperties(table)

Setting table properties

sas.qtgui.Perspectives.Fitting.FittingUtilities.updateKernelWithResults(kernel, results)

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: QWidget | None = None, data: Any | None = None, tab_id: int = 1)

Bases: QWidget, 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: str | None, structure_factor: str | None = None) None

Setting model parameters into table based on selected category

__doc__ = '\n    Main widget for selecting form and structure factor models\n    '
__init__(self, /, parent: PySide6.QtWidgets.QWidget | None = None, f: PySide6.QtCore.Qt.WindowType = Default(Qt.WindowFlags), *, modal: bool | None = None, windowModality: PySide6.QtCore.Qt.WindowModality | None = None, enabled: bool | None = None, geometry: PySide6.QtCore.QRect | None = None, frameGeometry: PySide6.QtCore.QRect | None = None, normalGeometry: PySide6.QtCore.QRect | None = None, x: int | None = None, y: int | None = None, pos: PySide6.QtCore.QPoint | None = None, frameSize: PySide6.QtCore.QSize | None = None, size: PySide6.QtCore.QSize | None = None, width: int | None = None, height: int | None = None, rect: PySide6.QtCore.QRect | None = None, childrenRect: PySide6.QtCore.QRect | None = None, childrenRegion: PySide6.QtGui.QRegion | None = None, sizePolicy: PySide6.QtWidgets.QSizePolicy | None = None, minimumSize: PySide6.QtCore.QSize | None = None, maximumSize: PySide6.QtCore.QSize | None = None, minimumWidth: int | None = None, minimumHeight: int | None = None, maximumWidth: int | None = None, maximumHeight: int | None = None, sizeIncrement: PySide6.QtCore.QSize | None = None, baseSize: PySide6.QtCore.QSize | None = None, palette: PySide6.QtGui.QPalette | None = None, font: PySide6.QtGui.QFont | None = None, cursor: PySide6.QtGui.QCursor | None = None, mouseTracking: bool | None = None, tabletTracking: bool | None = None, isActiveWindow: bool | None = None, focusPolicy: PySide6.QtCore.Qt.FocusPolicy | None = None, focus: bool | None = None, contextMenuPolicy: PySide6.QtCore.Qt.ContextMenuPolicy | None = None, updatesEnabled: bool | None = None, visible: bool | None = None, minimized: bool | None = None, maximized: bool | None = None, fullScreen: bool | None = None, sizeHint: PySide6.QtCore.QSize | None = None, minimumSizeHint: PySide6.QtCore.QSize | None = None, acceptDrops: bool | None = None, windowTitle: str | None = None, windowIcon: PySide6.QtGui.QIcon | None = None, windowIconText: str | None = None, windowOpacity: float | None = None, windowModified: bool | None = None, toolTip: str | None = None, toolTipDuration: int | None = None, statusTip: str | None = None, whatsThis: str | None = None, accessibleName: str | None = None, accessibleDescription: str | None = None, accessibleIdentifier: str | None = None, layoutDirection: PySide6.QtCore.Qt.LayoutDirection | None = None, autoFillBackground: bool | None = None, styleSheet: str | None = None, locale: PySide6.QtCore.QLocale | None = None, windowFilePath: str | None = None, inputMethodHints: PySide6.QtCore.Qt.InputMethodHint | None = None) None

Initialize self. See help(type(self)) for accurate signature.

__module__ = 'sas.qtgui.Perspectives.Fitting.FittingWidget'
_appendPlotsPolyDisp(new_plots: list[Any], return_data: dict, fitted_data: Data1D | Data2D) None

Internal helper for 1D and 2D for creating plots of the polydispersity distribution for parameters which have a polydispersity enabled

_requestPlots(item_name: str, item_model: Any) Any | None

Emits plotRequestedSignal for all plots found in the given model under the provided item name.

_volfraction_hack(s_kernel: Any) tuple[ParameterTable, ParameterTable | None]

Only show volfraction once if it appears in both P and S models. Issues SV:1280, SV:1295, SM:219, SM:199, SM:101

acceptsData() bool

Tells the caller this widget can accept new dataset

addBackgroundToModel(model: QStandardItemModel) None

Adds background parameter with default values to the model

addConstraintToRow(constraint: Constraint | None = None, row: int = 0, model_key: str = 'standard') None

Adds the constraint object to requested row. The constraint is first checked for errors, and a message box interrupting flow is displayed, with the reason of the failure.

addExtraShells() None

Add a combobox for multiple shell display

addScaleToModel(model: QStandardItemModel) None

Adds scale parameter with default values to the model

addSimpleConstraint() None

Adds a constraint on a single parameter.

addWeightingToData(data: Data1D | Data2D) Data1D | Data2D

Adds weighting contribution to fitting data

allParamNames() list[str]

Returns a list of all parameter names defined on the current model

batchFitComplete(result: tuple) None

Receive and display batch fitting results

batchFittingCompleted(result: tuple | None) None

Send the finish message from calculate threads to main thread

batchFittingFinishedSignal
calcException(etype: Any, value: Any, tb: Any) None

Thread threw an exception.

calculateDataFailed(reason: Any) None

Thread returned error

calculateQGridForModel() None

Prepare the fitting data object, based on current ModelModel

calculateQGridForModelExt(data: Data1D | Data2D | None = None, model: Any | None = None, completefn: Any | None = None, use_threads: bool = True) None

Wrapper for Calc1D/2D calls

calculateResiduals(fitted_data: Data1D | Data2D) Data1D | Data2D | None

Calculate and print Chi2 and display chart of residuals. Returns residuals plot object.

canHaveMagnetism() bool

Checks if the current model has magnetic scattering implemented

changeCheckboxStatus(row: int, checkbox_status: bool, model_key: str = 'standard') None

Checks/unchecks the checkbox at given row

checkboxSelected(item: QStandardItem, model_key: str = 'standard') None
checkedListFromModel(model_key: str) list[str]

Returns list of checked parameters for given model

clipboard_copy() None
clipboard_copy_excel() None
clipboard_copy_latex() None
clipboard_paste() None

Use the clipboard to update fit state

complete1D(return_data: dict) None

Plot the current 1D data

complete2D(return_data: dict) None

Plot the current 2D data

completed1D(return_data: dict) None
completed2D(return_data: dict) None
constraintAddedSignal
createDefaultDataset() None

Generate default Dataset 1D/2D for the given model

createNewIndex(fitted_data: Data1D | Data2D) None

Create a model or theory index with passed Data1D/Data2D

createPageForParameters(line_dict: dict[str, list[str]]) None

Sets up page with requested model/str factor and fills it up with sent parameters

createTheoryIndex(fitted_data: Data1D | Data2D) None

Create a QStandardModelIndex containing model data

currentState() FitPage

Return fit page with current state

classmethod customModels() dict[str, Any]

Reads in file names in the custom plugin directory

property data: Data1D | Data2D
dataFromItems(value: QStandardItem | list[QStandardItem]) None

data setter

deleteConstraint() None

Delete constraints from selected parameters.

deleteConstraintOnParameter(param: str | None = None, model_key: str = 'standard') None

Delete the constraint on model parameter ‘param’

deselectParameters() None

Selected parameters are removed for fitting

disableBackgroundParameter(set_value: float | None = None) None

Disable the background parameter. Optionally set at a specified value.

disableInteractiveElements() None

Set button caption on fitting/calculate start Disable the param table(s)

disableInteractiveElementsOnCalculate() None

Set button caption on fitting/calculate start Disable the param table(s)

disableModelCombo() None

Disable the combobox

disableStructureCombo() None

Disable the combobox

editConstraint() None

Edit constraints for selected parameters.

enableBackgroundParameter(set_value: float | None = None) None

Enable the background parameter. Optionally set at a specified value.

enableInteractiveElements() None

Set button caption on fitting/calculate finish Enable the param table(s)

enableModelCombo() None

Enable the combobox

enableStructureCombo() None

Enable the combobox

enableStructureFactorControl(structure_factor: str | None) None

Add structure factors to the list of parameters

eventFilter(self, watched: PySide6.QtCore.QObject, event: PySide6.QtCore.QEvent, /) bool
excel_copy_data() str

Excel format data destined for the clipboard

fitComplete(result: tuple) None

Receive and display fitting results “result” is a tuple of actual result list and the fit time in seconds

fitFailed(reason: Any) None
fittingCompleted(result: tuple | None) None

Send the finish message from calculate threads to main thread

fittingFinishedSignal
fromModelToQModel(model_name: str) None

Setting model parameters into QStandardItemModel based on selected model

fromStructureFactorToQModel(structure_factor: str) None

Setting model parameters into QStandardItemModel based on selected structure factor

full_copy_data() str

Data destined for the clipboard when copy clicked

getComplexConstraintsForAllModels() list[tuple[str, str]]

Returns a list of tuples containing all the constraints defined for a given FitPage

getComplexConstraintsForModel(model_key: str) list[tuple[str, str]]

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: int, model_key: str = 'standard') Constraint | None

For the given row, return its constraint, if any (otherwise None)

getConstraintObjectsForAllModels() list[Constraint]

Returns a list of the constraint object for a given FitPage

getConstraintObjectsForModel(model_key: str) list[Constraint]

Returns Constraint objects present on the whole model

getConstraintsForAllModels() list[tuple[str, str]]

Return a list of tuples. Each tuple contains constraints mapped as (‘constrained parameter’, ‘function to constrain’) e.g. [(‘sld’,’5*sld_solvent’)]

getConstraintsForFitting() list[tuple[str, str]]

Return a list of constraints in format ready for use in fiting

getCurrentFitState(state: Any | None = None) None

Store current state for fit_page

getFitModel() list[list[str]]

serializes combobox state

getFitPage() list[list[str]]

serializes full state of this fit page

getFitParameters() list[list[str | tuple]]

serializes current parameters

getFullConstraintNameListForModel(model_key: str) list[tuple[str, str]]

Return a list of tuples. Each tuple contains constraints mapped as (‘constrained parameter’, ‘function to constrain’) e.g. [(‘sld’,’5*M2.sld_solvent’)]. Returns a list of all constraints, not only active ones

getHelpLocation(tree_base: Path) Path
getModelKey(constraint: Constraint) str | None

Given parameter name get the model index.

getModelKeyFromName(name: str) str

Given parameter name, get the model index.

getParamNames() list[str]

Return list of all active parameters for the current model

getParamNamesMagnet() list[str]

Return list of magnetic parameters for the current model

getParamNamesMain() list[str]

Return list of main parameters for the current model

getParameterDict() dict[str, list[str]]

Gather current fitting parameters as dict

getReport() list[str]

Create and return HTML report with parameters and charts

getRowFromName(name: str) int | None

Given parameter name, get the row number in a model. The model is the main _model_model by default

getSymbolDict() dict[str, float]

Return a dict containing a list of all the symbols used for fitting and their values, e.g. {‘M1.scale’:1, ‘M1.background’: 0.001}

haveParamsToFit() bool

Finds out if there are any parameters ready to be fitted

info(type: Any, value: Any, tb: Any) None
initializeCategoryCombo() None

Model category combo setup

initializeControls() None

Set initial control enablement

initializeGlobals() None

Initialize global variables used in this class

initializeModels() None

Set up models and views

initializeSignals() None

Connect GUI element signals

initializeWidgets() None

Initialize widgets for tabs

isCheckable(row: int, model_key: str = 'standard') bool
isConstraintMultimodel(constraint: str) bool

Check if the constraint function text contains current model name

iterateOverModel(func: Any) None

Take func and throw it inside the model row loop

keyPressEvent(self, event: PySide6.QtGui.QKeyEvent, /) None
keyPressedSignal
latex_copy_data() str

Latex format data destined for the clipboard

loadAnalysisFile() str

Called when the “Open Project” menu item chosen.

loadPageState(pagestate: Any | None = None) None

Load the PageState object and update the current widget

loadPageStateCallback(state: Any | None = None, datainfo: Any | None = None, format: Any | None = None) None

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.

property logic: FittingLogic
methodCalculateForData() Any

return the method for data calculation

methodCompleteForData() Any

return the method for result parsin on calc complete

modelContextMenu(rows: list[int]) QMenu

Create context menu for the parameter selection

modelName() str

Returns model name, by default M<tab#>, e.g. M1, M2

modifyShellsInList(text: str) None

Add/remove additional multishell parameters

modifyViewOnRow(row: int, font: QFont | None = None, brush: QBrush | None = None, model_key: str = 'standard') None

Change how the given row of the main model is shown

nameForFittedData(name: str) str

Generate name for the current fit

nameFromData(fitted_data: Data1D | Data2D) str

Return name for the dataset. Terribly impure function.

newModelSignal
onCategoriesChanged() None

Reload the category/model comboboxes

onColumnWidthUpdate(index: int, old_size: int, new_size: int) None

Simple state update of the current column widths in the param list

onCustomModelChange() None

Reload the custom model combobox

onFit() None

Perform fitting on the current data

onHelp()

Show the “Fitting” section of help

onKey(event: QKeyEvent) None
onMainParamsChange(top: QModelIndex, bottom: QModelIndex) None

Callback method for updating the sasmodel parameters with the GUI values

onMaskedData() None

A mask has been applied to current data. Update the Q ranges.

onOptionsUpdate() None

Update local option values and replot

onPlot() None

Plot the current set of data

onSelectBatchFilename(data_index: int) None

Update the logic based on the selected file in batch fitting

onSelectCategory() None

Select Category from list

onSelectModel() None

Respond to select Model from list event

onSelectStructureFactor() None

Select Structure Factor from list

onSelectionChanged() None

React to parameter selection

onSesansData() None

Updates the fitting widget format when SESANS data is loaded.

onShowSLDProfile() None

Show a quick plot of SLD profile

onSmearingOptionsUpdate() None

React to changes in the smearing widget

paramDictFromResults(results: Any) dict[str, tuple[float, float]] | None

Given the fit results structure, pull out optimized parameters and return them as nicely formatted dict

paramHasConstraint(param: str | None = None) bool

Finds out if the given parameter in all the models has a constraint child

popFitPage() None

Remove top fit page from stack

prepareFitters(fitter: BumpsFit | None = None, fit_id: int = 0, weight_increase: int = 1) tuple[list[BumpsFit], int]

Prepare the Fitter object for use in fitting

processEffectiveRadius() None

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: FitPage) None

Add a new fit page object with current state

readCategoryInfo() None

Reads the categories in from file

readCustomCategoryInfo() None

Reads the custom model category

readFitPage(fp: FitPage) None

Read in state from a fitpage object and update GUI

recalculatePlotData() None

Generate a new dataset for model

regenerateModelDict() None

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: str, new_name: str = '') None

Replace names of models in defined constraints

resetParametersToFit() None

Clears the list of parameters to be fitted

respondToModelStructure(model: str | None = None, structure_factor: str | None = None) None
rowHasActiveComplexConstraint(row: int, model_key: str = 'standard') bool

Finds out if row of the main model has an active, nontrivial constraint child

rowHasActiveConstraint(row: int, model_key: str = 'standard') bool

Finds out if row of the main model has an active constraint child

rowHasConstraint(row: int, model_key: str = 'standard') bool

Finds out if row of the main model has a constraint child

saveToFitPage(fp: FitPage) None

Write current state to the given fitpage

save_parameters() None

Save parameters to a file

selectParameters() None

Selected parameter is chosen for fitting

selectedParameters(model_key: str = 'standard') list[int]

Returns list of selected (highlighted) parameters

setDefaultStructureCombo() None

Fill in the structure factors combo box with defaults

setEnablementOnDataLoad() None

Enable/disable various UI elements based on data loaded

setInteractiveElements(enabled: bool = True) None

Switch interactive GUI elements on/off

setParamEditableByRow(row: int, editable: bool = True) None

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: CheckState = CheckState.Unchecked, item: QStandardItem | None = None, model_key: str = 'standard') None

Selected parameters are chosen for fitting

setTheoryItem(item: Any) None

Reset the theory item based on the data explorer update

set_clipboard(data: str) None

Set the data in the clipboard

shellNamesList() list[str]

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]

showModelContextMenu(position: QPoint) None

Show context specific menu in the parameter table. When clicked on parameter(s): fitting/constraints options When clicked on white space: model description

showModelDescription() QMenu

Creates a window with model description, when right-clicked in the treeview

showMultiConstraint(current_list: QTreeView | None = None) None

Show the constraint widget and receive the expression

showPlot() None

Show the current plot in MPL

showTheoryPlot() None

Show the current theory plot in MPL

staticMetaObject = PySide6.QtCore.QMetaObject("FittingWidget" inherits "QWidget": Methods:   #33 type=Signal, signature=constraintAddedSignal(QVariantList,QString), parameters=QVariantList, QString   #34 type=Signal, signature=newModelSignal()   #35 type=Signal, signature=fittingFinishedSignal(PyObject), parameters=PyObject   #36 type=Signal, signature=batchFittingFinishedSignal(PyObject), parameters=PyObject   #37 type=Signal, signature=Calc1DFinishedSignal(QVariantMap), parameters=QVariantMap   #38 type=Signal, signature=Calc2DFinishedSignal(QVariantMap), parameters=QVariantMap   #39 type=Signal, signature=keyPressedSignal(QEvent*), parameters=QEvent* )
stopFit() None

Attempt to stop the fitting thread

toggle2D(isChecked: bool) None

Enable/disable the controls dependent on 1D/2D data instance

toggleChainFit(isChecked: bool) None

Enable/disable chain fitting

toggleMagnetism(isChecked: bool) None

Enable/disable the magnetism tab

togglePoly(isChecked: bool) None

Enable/disable the polydispersity tab

updateData() None

Helper function for recalculation of data used in plotting

updateEffectiveRadius(return_data: dict) None

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() None
updateFullModel(param_dict: dict[str, list[str]]) None

Update the model with new parameters

updateFunctionCaption(row)
updateKernelModelWithExtraParams(model: Any | None = None) None

Updates kernel model ‘model’ with extra parameters from the polydisp and magnetism tab, if the tabs are enabled

updateModelFromList(param_dict: dict[str, tuple[float, float]]) None

Update the model with new parameters, create the errors column

updateModelIndex(fitted_data: Data1D | Data2D) None

Update a QStandardModelIndex containing model data

updateMultiplicityCombo(multip: int) None

Find and update the multiplicity combobox

updatePageWithParameters(line_dict: dict[str, list[str]], warn_user: bool = True) None

Update FitPage with parameters in line_dict

updateQRange() None

Updates Q Range display

updateUndo() None

Create a new state page and add it to the stack

sas.qtgui.Perspectives.Fitting.FittingWidget.get_weights(self: Any, name: str) tuple[ndarray, ndarray]

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

Bases: PreferencesWidget, Ui_GPUOptions

OpenCL Dialog to select the desired OpenCL driver

__doc__ = '\n    OpenCL Dialog to select the desired OpenCL driver\n    '
__init__(self, /, parent: PySide6.QtWidgets.QWidget | None = None, f: PySide6.QtCore.Qt.WindowType = Default(Qt.WindowFlags), *, modal: bool | None = None, windowModality: PySide6.QtCore.Qt.WindowModality | None = None, enabled: bool | None = None, geometry: PySide6.QtCore.QRect | None = None, frameGeometry: PySide6.QtCore.QRect | None = None, normalGeometry: PySide6.QtCore.QRect | None = None, x: int | None = None, y: int | None = None, pos: PySide6.QtCore.QPoint | None = None, frameSize: PySide6.QtCore.QSize | None = None, size: PySide6.QtCore.QSize | None = None, width: int | None = None, height: int | None = None, rect: PySide6.QtCore.QRect | None = None, childrenRect: PySide6.QtCore.QRect | None = None, childrenRegion: PySide6.QtGui.QRegion | None = None, sizePolicy: PySide6.QtWidgets.QSizePolicy | None = None, minimumSize: PySide6.QtCore.QSize | None = None, maximumSize: PySide6.QtCore.QSize | None = None, minimumWidth: int | None = None, minimumHeight: int | None = None, maximumWidth: int | None = None, maximumHeight: int | None = None, sizeIncrement: PySide6.QtCore.QSize | None = None, baseSize: PySide6.QtCore.QSize | None = None, palette: PySide6.QtGui.QPalette | None = None, font: PySide6.QtGui.QFont | None = None, cursor: PySide6.QtGui.QCursor | None = None, mouseTracking: bool | None = None, tabletTracking: bool | None = None, isActiveWindow: bool | None = None, focusPolicy: PySide6.QtCore.Qt.FocusPolicy | None = None, focus: bool | None = None, contextMenuPolicy: PySide6.QtCore.Qt.ContextMenuPolicy | None = None, updatesEnabled: bool | None = None, visible: bool | None = None, minimized: bool | None = None, maximized: bool | None = None, fullScreen: bool | None = None, sizeHint: PySide6.QtCore.QSize | None = None, minimumSizeHint: PySide6.QtCore.QSize | None = None, acceptDrops: bool | None = None, windowTitle: str | None = None, windowIcon: PySide6.QtGui.QIcon | None = None, windowIconText: str | None = None, windowOpacity: float | None = None, windowModified: bool | None = None, toolTip: str | None = None, toolTipDuration: int | None = None, statusTip: str | None = None, whatsThis: str | None = None, accessibleName: str | None = None, accessibleDescription: str | None = None, accessibleIdentifier: str | None = None, layoutDirection: PySide6.QtCore.Qt.LayoutDirection | None = None, autoFillBackground: bool | None = None, styleSheet: str | None = None, locale: PySide6.QtCore.QLocale | None = None, windowFilePath: str | None = None, inputMethodHints: PySide6.QtCore.Qt.InputMethodHint | None = None) None

Initialize self. See help(type(self)) for accurate signature.

__module__ = 'sas.qtgui.Perspectives.Fitting.GPUOptions'
_addAllWidgets()

A private pseudo-abstract class that children should override. Widgets with their own UI file should pass.

_restoreFromConfig()

A pseudo-abstract class that children should override. Recalls all config values and restores the GUI.

_stage_sas_open_cl(checked)
_toggleBlockAllSignaling(toggle: bool)

A pseudo-abstract class that children should override. Toggles signalling for all elements.

_unStageChange(key: str)

A private class method to unstage a single configuration change. Typically when the value is not valid.

accept()

Close the window after modifying the SAS_OPENCL value

add_options()

Populate the window with a list of OpenCL options

applyNonConfigValues()

Applies values that aren’t stored in config. Only widgets that require this need to override this method.

cl_options = None
closeEvent(event)

Overwrite QDialog close method to allow for custom widget close

get_sas_open_cl()

Set SAS_OPENCL value when tests run or OK button clicked

helpButtonClicked()

Open the help menu when the help button is clicked

name: str = 'GPU Options'
reject()

Close the window without modifying SAS_OPENCL

set_sas_open_cl()
staticMetaObject = PySide6.QtCore.QMetaObject("GPUOptions" inherits "PreferencesWidget": Methods:   #33 type=Signal, signature=testingDoneSignal(QString), parameters=QString   #34 type=Signal, signature=testingFailedSignal(QString), parameters=QString )
testButtonClicked()

Run sasmodels check from here and report results from

testComplete(msg)

Testing done: send signal to main thread with update

testCompleted(msg)

Respond to successful test completion

testFail(msg)

Testing failed: log the reason

testFailed(msg)

Testing failed: log the reason

testThread(no_opencl_msg)

Testing in another thread

testingDoneSignal
testingFailedSignal
updateCounter(step)

Update progress bar with current value

class sas.qtgui.Perspectives.Fitting.GPUOptions.GPUTestResults(parent, msg)

Bases: QDialog, Ui_GPUTestResults

OpenCL Dialog to modify the OpenCL options

__doc__ = '\n    OpenCL Dialog to modify the OpenCL options\n    '
__init__(self, /, parent: PySide6.QtWidgets.QWidget | None = None, f: PySide6.QtCore.Qt.WindowType = Default(Qt.WindowFlags), *, sizeGripEnabled: bool | None = None, modal: bool | None = None) None

Initialize self. See help(type(self)) for accurate signature.

__module__ = 'sas.qtgui.Perspectives.Fitting.GPUOptions'
staticMetaObject = PySide6.QtCore.QMetaObject("GPUTestResults" inherits "QDialog": )
sas.qtgui.Perspectives.Fitting.GPUOptions._fromUtf8(s)
sas.qtgui.Perspectives.Fitting.GPUOptions._get_clinfo()

Read in information about available OpenCL infrastructure

sas.qtgui.Perspectives.Fitting.GPUOptions._translate(context, text, disambig)

sas.qtgui.Perspectives.Fitting.MagnetismWidget module

Widget/logic for magnetism.

class sas.qtgui.Perspectives.Fitting.MagnetismWidget.MagnetismWidget(parent: QWidget | None = None, logic: Any | None = None)

Bases: QWidget, Ui_MagnetismWidgetUI

__doc__ = None
__init__(self, /, parent: PySide6.QtWidgets.QWidget | None = None, f: PySide6.QtCore.Qt.WindowType = Default(Qt.WindowFlags), *, modal: bool | None = None, windowModality: PySide6.QtCore.Qt.WindowModality | None = None, enabled: bool | None = None, geometry: PySide6.QtCore.QRect | None = None, frameGeometry: PySide6.QtCore.QRect | None = None, normalGeometry: PySide6.QtCore.QRect | None = None, x: int | None = None, y: int | None = None, pos: PySide6.QtCore.QPoint | None = None, frameSize: PySide6.QtCore.QSize | None = None, size: PySide6.QtCore.QSize | None = None, width: int | None = None, height: int | None = None, rect: PySide6.QtCore.QRect | None = None, childrenRect: PySide6.QtCore.QRect | None = None, childrenRegion: PySide6.QtGui.QRegion | None = None, sizePolicy: PySide6.QtWidgets.QSizePolicy | None = None, minimumSize: PySide6.QtCore.QSize | None = None, maximumSize: PySide6.QtCore.QSize | None = None, minimumWidth: int | None = None, minimumHeight: int | None = None, maximumWidth: int | None = None, maximumHeight: int | None = None, sizeIncrement: PySide6.QtCore.QSize | None = None, baseSize: PySide6.QtCore.QSize | None = None, palette: PySide6.QtGui.QPalette | None = None, font: PySide6.QtGui.QFont | None = None, cursor: PySide6.QtGui.QCursor | None = None, mouseTracking: bool | None = None, tabletTracking: bool | None = None, isActiveWindow: bool | None = None, focusPolicy: PySide6.QtCore.Qt.FocusPolicy | None = None, focus: bool | None = None, contextMenuPolicy: PySide6.QtCore.Qt.ContextMenuPolicy | None = None, updatesEnabled: bool | None = None, visible: bool | None = None, minimized: bool | None = None, maximized: bool | None = None, fullScreen: bool | None = None, sizeHint: PySide6.QtCore.QSize | None = None, minimumSizeHint: PySide6.QtCore.QSize | None = None, acceptDrops: bool | None = None, windowTitle: str | None = None, windowIcon: PySide6.QtGui.QIcon | None = None, windowIconText: str | None = None, windowOpacity: float | None = None, windowModified: bool | None = None, toolTip: str | None = None, toolTipDuration: int | None = None, statusTip: str | None = None, whatsThis: str | None = None, accessibleName: str | None = None, accessibleDescription: str | None = None, accessibleIdentifier: str | None = None, layoutDirection: PySide6.QtCore.Qt.LayoutDirection | None = None, autoFillBackground: bool | None = None, styleSheet: str | None = None, locale: PySide6.QtCore.QLocale | None = None, windowFilePath: str | None = None, inputMethodHints: PySide6.QtCore.Qt.InputMethodHint | None = None) None

Initialize self. See help(type(self)) for accurate signature.

__module__ = 'sas.qtgui.Perspectives.Fitting.MagnetismWidget'
addCheckedMagneticListToModel(param: Any, value: float) None

Wrapper for model update with a subset of magnetic parameters

cmdFitSignal
gatherMagnetParams(row)

Create list of magnetic parameters based on _magnet_model

getParamNamesMagnet() list[str]

Return list of magnetic parameters for the current model

iterateOverMagnetModel(func: Any) None

Take func and throw it inside the magnet model row loop

iterateOverModelSignal
onDisplayMagneticAngles() None

Display a simple image showing direction of magnetic angles

onMagnetModelChange(top: QModelIndex, bottom: QModelIndex) None

Callback method for updating the sasmodel magnetic parameters with the GUI values

setMagneticModel() None

Set magnetism values on model

staticMetaObject = PySide6.QtCore.QMetaObject("MagnetismWidget" inherits "QWidget": Methods:   #33 type=Signal, signature=cmdFitSignal()   #34 type=Signal, signature=updateDataSignal()   #35 type=Signal, signature=iterateOverModelSignal() )
updateDataSignal
updateFullMagnetModel(param_dict: dict[str, list[str]]) None

Update the magnetism model with new parameters, create the errors column

updateMagnetModelFromList(param_dict: dict[str, tuple[float, float]]) None

Update the magnetic model with new parameters, create the errors column

updateModel(model: Any | None = None) None

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)

Bases: CalcThread

Compute 1D data

__annotations__ = {}
__doc__ = '\n    Compute 1D data\n    '
__init__(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)
__module__ = 'sas.qtgui.Perspectives.Fitting.ModelThread'
compute()

Compute model 1d value given qmin , qmax , x value

results()

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)

Bases: 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.

__annotations__ = {}
__doc__ = '\n    Compute 2D model\n    This calculation assumes a 2-fold symmetry of the model\n    where points are computed for one half of the detector\n    and I(qx, qy) = I(-qx, -qy) is assumed.\n    '
__init__(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)
__module__ = 'sas.qtgui.Perspectives.Fitting.ModelThread'
compute()

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)

Bases: QDialog, Ui_MultiConstraintUI

Logic class for interacting with MultiConstrainedUI view

__doc__ = '\n    Logic class for interacting with MultiConstrainedUI view\n    '
__init__(parent=None, params=None, constraint=None)

parent: ConstraintWidget object params: tuple of strings describing model parameters

__module__ = 'sas.qtgui.Perspectives.Fitting.MultiConstraint'
onHelp()

Display related help section

revert()

Swap parameters in the view

setupLabels()

Setup labels based on current parameters

setupTooltip()

Tooltip for txtConstraint

staticMetaObject = PySide6.QtCore.QMetaObject("MultiConstraint" inherits "QDialog": )
validateConstraint(constraint_text)

Ensure the constraint has proper form

validateFormula()

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

Bases: QDataWidgetMapper

Custom version of the standard QDataWidgetMapper allowing for proper response to index change in comboboxes

__doc__ = '\n    Custom version of the standard QDataWidgetMapper allowing for proper\n    response to index change in comboboxes\n    '
__module__ = 'sas.qtgui.Perspectives.Fitting.OptionsWidget'
addMapping(self, widget: PySide6.QtWidgets.QWidget, section: int, /) None
addMapping(self, widget: PySide6.QtWidgets.QWidget, section: int, propertyName: PySide6.QtCore.QByteArray | bytes | bytearray | memoryview, /) None
staticMetaObject = PySide6.QtCore.QMetaObject("DataWidgetMapper" inherits "QDataWidgetMapper": )
class sas.qtgui.Perspectives.Fitting.OptionsWidget.OptionsWidget(parent=None, logic=None)

Bases: QWidget, Ui_tabOptions

MODEL = ['MIN_RANGE', 'MAX_RANGE', 'NPTS', 'NPTS_FIT']
NPTS_DEFAULT = 150
QMAX_DEFAULT = 0.5
QMIN_DEFAULT = 0.0005
__doc__ = None
__init__(self, /, parent: PySide6.QtWidgets.QWidget | None = None, f: PySide6.QtCore.Qt.WindowType = Default(Qt.WindowFlags), *, modal: bool | None = None, windowModality: PySide6.QtCore.Qt.WindowModality | None = None, enabled: bool | None = None, geometry: PySide6.QtCore.QRect | None = None, frameGeometry: PySide6.QtCore.QRect | None = None, normalGeometry: PySide6.QtCore.QRect | None = None, x: int | None = None, y: int | None = None, pos: PySide6.QtCore.QPoint | None = None, frameSize: PySide6.QtCore.QSize | None = None, size: PySide6.QtCore.QSize | None = None, width: int | None = None, height: int | None = None, rect: PySide6.QtCore.QRect | None = None, childrenRect: PySide6.QtCore.QRect | None = None, childrenRegion: PySide6.QtGui.QRegion | None = None, sizePolicy: PySide6.QtWidgets.QSizePolicy | None = None, minimumSize: PySide6.QtCore.QSize | None = None, maximumSize: PySide6.QtCore.QSize | None = None, minimumWidth: int | None = None, minimumHeight: int | None = None, maximumWidth: int | None = None, maximumHeight: int | None = None, sizeIncrement: PySide6.QtCore.QSize | None = None, baseSize: PySide6.QtCore.QSize | None = None, palette: PySide6.QtGui.QPalette | None = None, font: PySide6.QtGui.QFont | None = None, cursor: PySide6.QtGui.QCursor | None = None, mouseTracking: bool | None = None, tabletTracking: bool | None = None, isActiveWindow: bool | None = None, focusPolicy: PySide6.QtCore.Qt.FocusPolicy | None = None, focus: bool | None = None, contextMenuPolicy: PySide6.QtCore.Qt.ContextMenuPolicy | None = None, updatesEnabled: bool | None = None, visible: bool | None = None, minimized: bool | None = None, maximized: bool | None = None, fullScreen: bool | None = None, sizeHint: PySide6.QtCore.QSize | None = None, minimumSizeHint: PySide6.QtCore.QSize | None = None, acceptDrops: bool | None = None, windowTitle: str | None = None, windowIcon: PySide6.QtGui.QIcon | None = None, windowIconText: str | None = None, windowOpacity: float | None = None, windowModified: bool | None = None, toolTip: str | None = None, toolTipDuration: int | None = None, statusTip: str | None = None, whatsThis: str | None = None, accessibleName: str | None = None, accessibleDescription: str | None = None, accessibleIdentifier: str | None = None, layoutDirection: PySide6.QtCore.Qt.LayoutDirection | None = None, autoFillBackground: bool | None = None, styleSheet: str | None = None, locale: PySide6.QtCore.QLocale | None = None, windowFilePath: str | None = None, inputMethodHints: PySide6.QtCore.Qt.InputMethodHint | None = None) None

Initialize self. See help(type(self)) for accurate signature.

__module__ = 'sas.qtgui.Perspectives.Fitting.OptionsWidget'
initMapper()

Initialize model item <-> UI element mapping

initModel()

Initialize the state

npts2fit(data=None, qmin=None, qmax=None, npts=None)

return numbers of data points within qrange :Note: This is to normalize chisq by Npts of fit

onMaskEdit()

Callback for running the mask editor

onModelChange(top, bottom)

Respond to model change by updating the plot

onRangeReset()

Callback for resetting qmin/qmax

onWeightingChoice(button)

Update weighting in the fit state

plot_signal
setEnablementOnDataLoad()

Enable/disable various UI elements based on data loaded

setLogScale(log_scale)
state()

Returns current state of controls

staticMetaObject = PySide6.QtCore.QMetaObject("OptionsWidget" inherits "QWidget": Methods:   #33 type=Signal, signature=plot_signal() )
toggleLogData(isChecked)

Toggles between log and linear data sets

updateMaxQ(q_max=None)
updateMinQ(q_min=None)
updateQRange(q_range_min, q_range_max, npts)

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)

Bases: QWidget, Ui_OrderWidgetUI

__doc__ = None
__init__(self, /, parent: PySide6.QtWidgets.QWidget | None = None, f: PySide6.QtCore.Qt.WindowType = Default(Qt.WindowFlags), *, modal: bool | None = None, windowModality: PySide6.QtCore.Qt.WindowModality | None = None, enabled: bool | None = None, geometry: PySide6.QtCore.QRect | None = None, frameGeometry: PySide6.QtCore.QRect | None = None, normalGeometry: PySide6.QtCore.QRect | None = None, x: int | None = None, y: int | None = None, pos: PySide6.QtCore.QPoint | None = None, frameSize: PySide6.QtCore.QSize | None = None, size: PySide6.QtCore.QSize | None = None, width: int | None = None, height: int | None = None, rect: PySide6.QtCore.QRect | None = None, childrenRect: PySide6.QtCore.QRect | None = None, childrenRegion: PySide6.QtGui.QRegion | None = None, sizePolicy: PySide6.QtWidgets.QSizePolicy | None = None, minimumSize: PySide6.QtCore.QSize | None = None, maximumSize: PySide6.QtCore.QSize | None = None, minimumWidth: int | None = None, minimumHeight: int | None = None, maximumWidth: int | None = None, maximumHeight: int | None = None, sizeIncrement: PySide6.QtCore.QSize | None = None, baseSize: PySide6.QtCore.QSize | None = None, palette: PySide6.QtGui.QPalette | None = None, font: PySide6.QtGui.QFont | None = None, cursor: PySide6.QtGui.QCursor | None = None, mouseTracking: bool | None = None, tabletTracking: bool | None = None, isActiveWindow: bool | None = None, focusPolicy: PySide6.QtCore.Qt.FocusPolicy | None = None, focus: bool | None = None, contextMenuPolicy: PySide6.QtCore.Qt.ContextMenuPolicy | None = None, updatesEnabled: bool | None = None, visible: bool | None = None, minimized: bool | None = None, maximized: bool | None = None, fullScreen: bool | None = None, sizeHint: PySide6.QtCore.QSize | None = None, minimumSizeHint: PySide6.QtCore.QSize | None = None, acceptDrops: bool | None = None, windowTitle: str | None = None, windowIcon: PySide6.QtGui.QIcon | None = None, windowIconText: str | None = None, windowOpacity: float | None = None, windowModified: bool | None = None, toolTip: str | None = None, toolTipDuration: int | None = None, statusTip: str | None = None, whatsThis: str | None = None, accessibleName: str | None = None, accessibleDescription: str | None = None, accessibleIdentifier: str | None = None, layoutDirection: PySide6.QtCore.Qt.LayoutDirection | None = None, autoFillBackground: bool | None = None, styleSheet: str | None = None, locale: PySide6.QtCore.QLocale | None = None, windowFilePath: str | None = None, inputMethodHints: PySide6.QtCore.Qt.InputMethodHint | None = None) None

Initialize self. See help(type(self)) for accurate signature.

__module__ = 'sas.qtgui.Perspectives.Fitting.OrderWidget'
ordering()

Returns the current ordering of the datasets

setupTable()

Populate the widget with dataset names in original order

staticMetaObject = PySide6.QtCore.QMetaObject("OrderWidget" inherits "QWidget": )
updateData(all_data)

Read in new datasets and update the view

sas.qtgui.Perspectives.Fitting.PolydispersityWidget module

Widget/logic for polydispersity.

class sas.qtgui.Perspectives.Fitting.PolydispersityWidget.PolydispersityWidget(parent: QWidget | None = None)

Bases: QWidget, Ui_PolydispersityWidgetUI

__doc__ = None
__init__(self, /, parent: PySide6.QtWidgets.QWidget | None = None, f: PySide6.QtCore.Qt.WindowType = Default(Qt.WindowFlags), *, modal: bool | None = None, windowModality: PySide6.QtCore.Qt.WindowModality | None = None, enabled: bool | None = None, geometry: PySide6.QtCore.QRect | None = None, frameGeometry: PySide6.QtCore.QRect | None = None, normalGeometry: PySide6.QtCore.QRect | None = None, x: int | None = None, y: int | None = None, pos: PySide6.QtCore.QPoint | None = None, frameSize: PySide6.QtCore.QSize | None = None, size: PySide6.QtCore.QSize | None = None, width: int | None = None, height: int | None = None, rect: PySide6.QtCore.QRect | None = None, childrenRect: PySide6.QtCore.QRect | None = None, childrenRegion: PySide6.QtGui.QRegion | None = None, sizePolicy: PySide6.QtWidgets.QSizePolicy | None = None, minimumSize: PySide6.QtCore.QSize | None = None, maximumSize: PySide6.QtCore.QSize | None = None, minimumWidth: int | None = None, minimumHeight: int | None = None, maximumWidth: int | None = None, maximumHeight: int | None = None, sizeIncrement: PySide6.QtCore.QSize | None = None, baseSize: PySide6.QtCore.QSize | None = None, palette: PySide6.QtGui.QPalette | None = None, font: PySide6.QtGui.QFont | None = None, cursor: PySide6.QtGui.QCursor | None = None, mouseTracking: bool | None = None, tabletTracking: bool | None = None, isActiveWindow: bool | None = None, focusPolicy: PySide6.QtCore.Qt.FocusPolicy | None = None, focus: bool | None = None, contextMenuPolicy: PySide6.QtCore.Qt.ContextMenuPolicy | None = None, updatesEnabled: bool | None = None, visible: bool | None = None, minimized: bool | None = None, maximized: bool | None = None, fullScreen: bool | None = None, sizeHint: PySide6.QtCore.QSize | None = None, minimumSizeHint: PySide6.QtCore.QSize | None = None, acceptDrops: bool | None = None, windowTitle: str | None = None, windowIcon: PySide6.QtGui.QIcon | None = None, windowIconText: str | None = None, windowOpacity: float | None = None, windowModified: bool | None = None, toolTip: str | None = None, toolTipDuration: int | None = None, statusTip: str | None = None, whatsThis: str | None = None, accessibleName: str | None = None, accessibleDescription: str | None = None, accessibleIdentifier: str | None = None, layoutDirection: PySide6.QtCore.Qt.LayoutDirection | None = None, autoFillBackground: bool | None = None, styleSheet: str | None = None, locale: PySide6.QtCore.QLocale | None = None, windowFilePath: str | None = None, inputMethodHints: PySide6.QtCore.Qt.InputMethodHint | None = None) None

Initialize self. See help(type(self)) for accurate signature.

__module__ = 'sas.qtgui.Perspectives.Fitting.PolydispersityWidget'
addNameToPolyModel(param_name: str) None

Creates a checked row in the poly model with param_name

checkedListFromModel() list[str]

Returns list of checked parameters for given model

cmdFitSignal
gatherPolyParams(row: int) list[list[str]]

Create list of polydisperse parameters based on _poly_model

getParamNamesPoly() list[str]

Return list of polydisperse parameters for the current model

iterateOverModelSignal
iterateOverPolyModel(func: Any) None

Take func and throw it inside the poly model row loop

loadPolydispArray(row_index: int) None

Show the load file dialog and loads requested data into state

onPolyComboIndexChange(combo_string: str, row_index: int) None

Modify polydisp. defaults on function choice

onPolyFilenameChange(row_index: int) None

Respond to filename_updated signal from the delegate

onPolyModelChange(top: QModelIndex) None

Callback method for updating the main model and sasmodel parameters with the GUI values in the polydispersity view

polyModel() ToolTippedItemModel

Return the polydispersity model

static polyNameToParam(param_name: str) str

Translate polydisperse QTable representation into parameter name

resetParameters() None

Reset polydispersity parameters

setPolyModel() None

Set polydispersity values

setPolyModelParameters(i: int, param: Any) None

Standard of multishell poly parameter driver

staticMetaObject = PySide6.QtCore.QMetaObject("PolydispersityWidget" inherits "QWidget": Methods:   #33 type=Signal, signature=cmdFitSignal()   #34 type=Signal, signature=updateDataSignal()   #35 type=Signal, signature=iterateOverModelSignal() )
togglePoly(isChecked: bool = True) None

Toggle polydispersity

updateDataSignal
updateFullPolyModel(param_dict: dict[str, list[str]]) None

Update the polydispersity model with new parameters, create the errors column

updateModel(model: Any | None = None) None
updatePolyModelFromList(param_dict: dict[str, tuple[float, float]]) None

Update the polydispersity model with new parameters, create the errors column

sas.qtgui.Perspectives.Fitting.ReportPageLogic module

class sas.qtgui.Perspectives.Fitting.ReportPageLogic.ReportPageLogic(parent=None, kernel_module=None, data=None, index=None, params=None)

Bases: object

Logic for the Report Page functionality. Refactored from FittingWidget.

__dict__ = mappingproxy({'__module__': 'sas.qtgui.Perspectives.Fitting.ReportPageLogic', '__doc__': '\n    Logic for the Report Page functionality. Refactored from FittingWidget.\n    ', '__init__': <function ReportPageLogic.__init__>, 'reportList': <function ReportPageLogic.reportList>, 'reportHeader': <function ReportPageLogic.reportHeader>, 'buildPlotsForReport': <function ReportPageLogic.buildPlotsForReport>, 'reportParams': <function ReportPageLogic.reportParams>, 'getImages': <function ReportPageLogic.getImages>, '__dict__': <attribute '__dict__' of 'ReportPageLogic' objects>, '__weakref__': <attribute '__weakref__' of 'ReportPageLogic' objects>, '__annotations__': {}})
__doc__ = '\n    Logic for the Report Page functionality. Refactored from FittingWidget.\n    '
__init__(parent=None, kernel_module=None, data=None, index=None, params=None)
__module__ = 'sas.qtgui.Perspectives.Fitting.ReportPageLogic'
__weakref__

list of weak references to the object

buildPlotsForReport(images)

Convert Matplotlib figure ‘fig’ into a <img> tag for HTML use using base64 encoding.

getImages() list[PlotterBase]

Create MPL figures for the current fit

reportHeader()

Look at widget state and extract report header info

reportList() ReportData

Return the HTML version of the full report

reportParams()

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

Bases: QDataWidgetMapper

Custom version of the standard QDataWidgetMapper allowing for proper response to index change in comboboxes

__doc__ = '\n    Custom version of the standard QDataWidgetMapper allowing for proper\n    response to index change in comboboxes\n    '
__module__ = 'sas.qtgui.Perspectives.Fitting.SmearingWidget'
addMapping(self, widget: PySide6.QtWidgets.QWidget, section: int, /) None
addMapping(self, widget: PySide6.QtWidgets.QWidget, section: int, propertyName: PySide6.QtCore.QByteArray | bytes | bytearray | memoryview, /) None
staticMetaObject = PySide6.QtCore.QMetaObject("DataWidgetMapper" inherits "QDataWidgetMapper": )
class sas.qtgui.Perspectives.Fitting.SmearingWidget.SmearingWidget(parent=None)

Bases: QWidget, Ui_SmearingWidgetUI

__doc__ = None
__init__(self, /, parent: PySide6.QtWidgets.QWidget | None = None, f: PySide6.QtCore.Qt.WindowType = Default(Qt.WindowFlags), *, modal: bool | None = None, windowModality: PySide6.QtCore.Qt.WindowModality | None = None, enabled: bool | None = None, geometry: PySide6.QtCore.QRect | None = None, frameGeometry: PySide6.QtCore.QRect | None = None, normalGeometry: PySide6.QtCore.QRect | None = None, x: int | None = None, y: int | None = None, pos: PySide6.QtCore.QPoint | None = None, frameSize: PySide6.QtCore.QSize | None = None, size: PySide6.QtCore.QSize | None = None, width: int | None = None, height: int | None = None, rect: PySide6.QtCore.QRect | None = None, childrenRect: PySide6.QtCore.QRect | None = None, childrenRegion: PySide6.QtGui.QRegion | None = None, sizePolicy: PySide6.QtWidgets.QSizePolicy | None = None, minimumSize: PySide6.QtCore.QSize | None = None, maximumSize: PySide6.QtCore.QSize | None = None, minimumWidth: int | None = None, minimumHeight: int | None = None, maximumWidth: int | None = None, maximumHeight: int | None = None, sizeIncrement: PySide6.QtCore.QSize | None = None, baseSize: PySide6.QtCore.QSize | None = None, palette: PySide6.QtGui.QPalette | None = None, font: PySide6.QtGui.QFont | None = None, cursor: PySide6.QtGui.QCursor | None = None, mouseTracking: bool | None = None, tabletTracking: bool | None = None, isActiveWindow: bool | None = None, focusPolicy: PySide6.QtCore.Qt.FocusPolicy | None = None, focus: bool | None = None, contextMenuPolicy: PySide6.QtCore.Qt.ContextMenuPolicy | None = None, updatesEnabled: bool | None = None, visible: bool | None = None, minimized: bool | None = None, maximized: bool | None = None, fullScreen: bool | None = None, sizeHint: PySide6.QtCore.QSize | None = None, minimumSizeHint: PySide6.QtCore.QSize | None = None, acceptDrops: bool | None = None, windowTitle: str | None = None, windowIcon: PySide6.QtGui.QIcon | None = None, windowIconText: str | None = None, windowOpacity: float | None = None, windowModified: bool | None = None, toolTip: str | None = None, toolTipDuration: int | None = None, statusTip: str | None = None, whatsThis: str | None = None, accessibleName: str | None = None, accessibleDescription: str | None = None, accessibleIdentifier: str | None = None, layoutDirection: PySide6.QtCore.Qt.LayoutDirection | None = None, autoFillBackground: bool | None = None, styleSheet: str | None = None, locale: PySide6.QtCore.QLocale | None = None, windowFilePath: str | None = None, inputMethodHints: PySide6.QtCore.Qt.InputMethodHint | None = None) None

Initialize self. See help(type(self)) for accurate signature.

__module__ = 'sas.qtgui.Perspectives.Fitting.SmearingWidget'
initMapper()

Initialize model item <-> UI element mapping

initModel()

Initialize the state

onDQSmear()

Create a custom dQ smear object that will change the way residuals are compute when fitting

onIndexChange(index)

Callback for smearing combobox index change

onModelChange()

Respond to model change by notifying any listeners

onPinholeSmear()

Create a custom pinhole smear object that will change the way residuals are compute when fitting

onSlitSmear()

Create a custom slit smear object that will change the way residuals are compute when fitting

resetSmearer()
setAccuracyVisibility()

Accuracy combobox visibility

setDQLabels()

Use appropriate labels

setElementsVisibility(visible)

Labels and linedits visibility control

setPinholeLabels()

Use pinhole labels

setSlitLabels()

Use pinhole labels

setSmearInfo()

Set default smear_type, dq_l, and dq_r based on the q-resolution information found in the data.

setState(smearing, accuracy, d_down, d_up)

Sets new values for the controls

smearer()

Returns the current smearer

smearingChangedSignal
state()

Returns current state of controls

staticMetaObject = PySide6.QtCore.QMetaObject("SmearingWidget" inherits "QWidget": Methods:   #33 type=Signal, signature=smearingChangedSignal() )
updateData(data=None)

Update control elements based on data and model passed

updateKernelModel(kernel_model=None, keep_order=False, old_index=None)

Update the model

sas.qtgui.Perspectives.Fitting.ViewDelegate module

class sas.qtgui.Perspectives.Fitting.ViewDelegate.MagnetismViewDelegate(parent=None)

Bases: QStyledItemDelegate

Custom delegate for appearance and behavior control of the magnetism view

__doc__ = '\n    Custom delegate for appearance and behavior control of the magnetism view\n    '
__init__(parent=None)

Overwrite generic constructor to allow for some globals

__module__ = 'sas.qtgui.Perspectives.Fitting.ViewDelegate'
addErrorColumn()

Modify local column pointers Note: the reverse is never required!

createEditor(self, parent: PySide6.QtWidgets.QWidget, option: PySide6.QtWidgets.QStyleOptionViewItem, index: PySide6.QtCore.QModelIndex | PySide6.QtCore.QPersistentModelIndex, /) PySide6.QtWidgets.QWidget
editableParameters()
paint(painter, option, index)

Overwrite generic painter for certain columns

staticMetaObject = PySide6.QtCore.QMetaObject("MagnetismViewDelegate" inherits "QStyledItemDelegate": )
class sas.qtgui.Perspectives.Fitting.ViewDelegate.ModelViewDelegate(parent=None)

Bases: QStyledItemDelegate

Custom delegate for appearance and behavior control of the model view

__doc__ = '\n    Custom delegate for appearance and behavior control of the model view\n    '
__init__(parent=None)

Overwrite generic constructor to allow for some globals

__module__ = 'sas.qtgui.Perspectives.Fitting.ViewDelegate'
addErrorColumn()

Modify local column pointers Note: the reverse is never required!

createEditor(widget, option, index)

Overwrite generic editor for certain columns

fancyColumns()
paint(painter, option, index)

Overwrite generic painter for certain columns

setModelData(editor, model, index)

Overwrite generic model update method for certain columns

staticMetaObject = PySide6.QtCore.QMetaObject("ModelViewDelegate" inherits "QStyledItemDelegate": )
class sas.qtgui.Perspectives.Fitting.ViewDelegate.PolyViewDelegate(parent=None)

Bases: QStyledItemDelegate

Custom delegate for appearance and behavior control of the polydispersity view

POLYDISPERSE_FUNCTIONS = ['rectangle', 'array', 'lognormal', 'gaussian', 'schulz']
__doc__ = '\n    Custom delegate for appearance and behavior control of the polydispersity view\n    '
__init__(parent=None)

Overwrite generic constructor to allow for some globals

__module__ = 'sas.qtgui.Perspectives.Fitting.ViewDelegate'
addErrorColumn()

Modify local column pointers Note: the reverse is never required!

columnDict()
combo_updated
createEditor(self, parent: PySide6.QtWidgets.QWidget, option: PySide6.QtWidgets.QStyleOptionViewItem, index: PySide6.QtCore.QModelIndex | PySide6.QtCore.QPersistentModelIndex, /) PySide6.QtWidgets.QWidget
editableParameters()
filename_updated
paint(painter, option, index)

Overwrite generic painter for certain columns

staticMetaObject = PySide6.QtCore.QMetaObject("PolyViewDelegate" inherits "QStyledItemDelegate": Methods:   #9 type=Signal, signature=combo_updated(QString,int), parameters=QString, int   #10 type=Signal, signature=filename_updated(int), parameters=int )

Module contents