sas.qtgui.Perspectives.Fitting package

Subpackages

Submodules

sas.qtgui.Perspectives.Fitting.AssociatedComboBox module

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

Bases: PyQt5.QtWidgets.QComboBox

Just a regular combo box, but associated with a particular QStandardItem so that it can be used to display and select an item’s current text and a restricted list of other possible text.

When the combo box’s current text is changed, the change is immediately reflected in the associated item; either the text itself is set as the item’s data, or the current index is used; see constructor.

__annotations__ = {}
__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: PyQt5.QtGui.QStandardItem, idx_as_value: bool = False, parent: Optional[PyQt5.QtWidgets.QWidget] = None) None[source]

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[source]

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

_onTextChanged(text: str) None[source]

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

item: PyQt5.QtGui.QStandardItem = None

sas.qtgui.Perspectives.Fitting.ComplexConstraint module

Widget for multi-model constraints.

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

Bases: PyQt5.QtWidgets.QDialog, sas.qtgui.Perspectives.Fitting.UI.ComplexConstraintUI.Ui_ComplexConstraintUI

__annotations__ = {}
__doc__ = None
__init__(parent=None, tabs=None)[source]
__module__ = 'sas.qtgui.Perspectives.Fitting.ComplexConstraint'
applyAcrossTabs(tabs, param, expr)[source]

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()[source]

Return the generated constraint

constraintIsRedefined(cons_tuple)[source]

Warn the user when a constraint is being redefined

constraintReadySignal

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

onApply()[source]

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

onHelp()[source]

Display related help section

onModelIndexChange(index)[source]

Respond to mode combo box changes

onOperatorChange(index)[source]

Respond to operator combo box changes

onParamIndexChange(index)[source]

Respond to parameter combo box changes

onSetAll()[source]

Set constraints on all identically named parameters between two fitpages

setupData()[source]

Digs into self.tabs and pulls out relevant info

setupMenu()[source]
setupParamWidgets()[source]

Fill out comboboxes and set labels with non-constrained parameters

setupSignals()[source]

Signals from various elements

setupTooltip()[source]

Tooltip for txtConstraint

setupWidgets()[source]

Setup widgets based on current parameters

validateConstraint(constraint_text)[source]

Ensure the constraint has proper form

validateFormula()[source]

Add visual cues when formula is incorrect

sas.qtgui.Perspectives.Fitting.ConsoleUpdate module

class sas.qtgui.Perspectives.Fitting.ConsoleUpdate.ConsoleUpdate(parent, manager=None, quiet=False, progress_delta=60, improvement_delta=5)[source]

Bases: sas.sascalc.fit.AbstractFitEngine.FitHandler

Print progress to the console.

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

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()[source]
error(msg)[source]

Model had an error; print traceback

finalize()[source]
get_result()[source]
improvement()[source]

Called when a result is observed which is better than previous results from the fit.

improvement_delta = 5

Number of seconds between improvement updates

isbetter = False

Record whether results improved since last update

print_result()[source]

Print result object

progress(k, n)[source]

Report on progress.

progress_delta = 60

Number of seconds between progress updates

set_result(result)[source]
stop(msg)[source]

Post event msg and stop

update_fit(last=False)[source]

sas.qtgui.Perspectives.Fitting.Constraint module

class sas.qtgui.Perspectives.Fitting.Constraint.Constraint(parent=None, param=None, value=0.0, min=None, max=None, func=None, value_ex=None, operator='=')[source]

Bases: object

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

__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 expaned 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>, '__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 expaned 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='=')[source]
__module__ = 'sas.qtgui.Perspectives.Fitting.Constraint'
__weakref__

list of weak references to the object (if defined)

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

sas.qtgui.Perspectives.Fitting.ConstraintWidget module

sas.qtgui.Perspectives.Fitting.FitPage module

Container class for fitting widget state storage

class sas.qtgui.Perspectives.Fitting.FitPage.FitPage[source]

Bases: object

Container for all data related to the current fit page

LOG_POINTS = 4
MAX_RANGE = 1
MIN_RANGE = 0
NPTS = 2
NPTS_FIT = 3
SMEARING_ACCURACY = 7
SMEARING_MAX = 9
SMEARING_MIN = 8
SMEARING_OPTION = 6
WEIGHTING = 5
__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__()[source]

Define the dictionary

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

list of weak references to the object (if defined)

load(location)[source]

Retrieve serialized state from specified location

save()[source]

Serialize the current state

saveAsXML()[source]

Serialize the current state

sas.qtgui.Perspectives.Fitting.FitThread module

class sas.qtgui.Perspectives.Fitting.FitThread.FitThread(fn, page_id, handler, batch_outputs, batch_inputs=None, pars=None, completefn=None, updatefn=None, yieldtime=0.03, worktime=0.03, reset_flag=False)[source]

Bases: sas.sascalc.data_util.calcthread.CalcThread

Thread performing the fit

__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)[source]

Prepare the calculator

__module__ = 'sas.qtgui.Perspectives.Fitting.FitThread'
compute()[source]

Perform a fit

isquit()[source]
Raises

KeyboardInterrupt – when the thread is interrupted

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

Take an instance of a class and a function name as a string. Execute class.function and return result

sas.qtgui.Perspectives.Fitting.FittingLogic module

class sas.qtgui.Perspectives.Fitting.FittingLogic.FittingLogic(data=None)[source]

Bases: object

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

__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)[source]
__module__ = 'sas.qtgui.Perspectives.Fitting.FittingLogic'
__weakref__

list of weak references to the object (if defined)

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

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()[source]

Wrapper for calculating the data range based on local dataset

computeRangeFromData(data)[source]

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

createDefault1dData(interval, tab_id=0)[source]

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

createDefault2dData(qmax, qstep, tab_id=0)[source]

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

property data
getScalarIntermediateResults(return_data)[source]

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

isLoadedData()[source]

accessor

new1DPlot(return_data, tab_id)[source]

Create a new 1D data instance based on fitting results

new1DProductPlots(return_data, tab_id)[source]

If return_data contains separated P(Q) and/or S(Q) data, create 1D plots for each and return as the tuple (pq_plot, sq_plot). If either are unavailable, the corresponding plot is None.

new2DPlot(return_data)[source]

Create a new 2D data instance based on fitting results

setDataProperties()[source]

Analyze data and set up some properties important for the Presentation layer

sas.qtgui.Perspectives.Fitting.FittingOptions module

class sas.qtgui.Perspectives.Fitting.FittingOptions.FittingOptions(parent=None, config=None)[source]

Bases: PyQt5.QtWidgets.QDialog, sas.qtgui.Perspectives.Fitting.UI.FittingOptionsUI.Ui_FittingOptions

Hard-coded version of the fit options dialog available from BUMPS. This should be make more “dynamic”. bumps.options.FIT_FIELDS gives mapping between parameter names, parameter strings and field type (double line edit, integer line edit, combo box etc.), e.g.:

FIT_FIELDS = dict(
    samples = ("Samples", parse_int),
    xtol = ("x tolerance", float),
)

bumps.fitters.<algorithm>.settings gives mapping between algorithm, parameter name and default value, e.g.:

>>> settings = [('steps', 1000), ('starts', 1), ('radius', 0.15), ('xtol', 1e-6), ('ftol', 1e-8)]
__annotations__ = {}
__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__(parent=None, config=None)[source]
__module__ = 'sas.qtgui.Perspectives.Fitting.FittingOptions'
assignValidators()[source]

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

check_state(*args, **kwargs)[source]
fit_option_changed

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

getResults()[source]

Sends back the current choice of parameters

onAlgorithmChange(index)[source]

Change the page in response to combo box index

onApply()[source]

Update the fitter object

onHelp()[source]

Show the “Fitting options” section of help

updateWidgetFromBumps(fitter_id)[source]

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

widgetFromOption(option_id, current_fitter=None)[source]

returns widget’s element linked to the given option_id

sas.qtgui.Perspectives.Fitting.FittingPerspective module

sas.qtgui.Perspectives.Fitting.FittingUtilities module

sas.qtgui.Perspectives.Fitting.FittingUtilities.addCheckedListToModel(model, param_list)[source]

Add a QItem to model. Makes the QItem checkable

sas.qtgui.Perspectives.Fitting.FittingUtilities.addErrorHeadersToModel(model)[source]

Adds predefined headers to the model

sas.qtgui.Perspectives.Fitting.FittingUtilities.addErrorPolyHeadersToModel(model)[source]

Adds predefined headers to the model

sas.qtgui.Perspectives.Fitting.FittingUtilities.addHeadersToModel(model)[source]

Adds predefined headers to the model

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

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

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

Update local ModelModel with sasmodel parameters. Actually appends to model, if model and view params are not None. Always returns list of lists of QStandardItems.

sas.qtgui.Perspectives.Fitting.FittingUtilities.addPolyHeadersToModel(model)[source]

Adds predefined headers to the model

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

Find out multishell parameters and update the model with the requested number of them. Inserts them after the row at row_num, if not None; otherwise, appends to end. If view param is not None, supports fixed-choice params. Returns a list of lists of QStandardItem objects.

sas.qtgui.Perspectives.Fitting.FittingUtilities.addSimpleParametersToModel(parameters, is2D, parameters_original=None, model=None, view=None, row_num=None)[source]

Update local ModelModel with sasmodel parameters (non-dispersed, non-magnetic) Actually appends to model, if model and view params are not None. Always returns list of lists of QStandardItems.

parameters_original: list of parameters before any tagging on their IDs, e.g. for product model (so that those are the display names; see below)

sas.qtgui.Perspectives.Fitting.FittingUtilities.binary_encode(i, digits)[source]
sas.qtgui.Perspectives.Fitting.FittingUtilities.calculateChi2(reference_data, current_data, weight)[source]

Calculate Chi2 value between two sets of data

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

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)[source]

Determines whether param is a fixed-choice parameter, modifies items in item_row appropriately and returns a combo box containing the fixed choices. Returns None if param is not fixed-choice.

item_row is a list of QStandardItem objects for insertion into the parameter table.

sas.qtgui.Perspectives.Fitting.FittingUtilities.formatParameters(parameters, Check=True)[source]

Prepare the parameter string in the standard SasView layout

sas.qtgui.Perspectives.Fitting.FittingUtilities.formatParametersExcel(parameters)[source]

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

sas.qtgui.Perspectives.Fitting.FittingUtilities.formatParametersLatex(parameters)[source]

Prepare the parameter string in latex

sas.qtgui.Perspectives.Fitting.FittingUtilities.getIterParams(model)[source]

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

sas.qtgui.Perspectives.Fitting.FittingUtilities.getMultiplicity(model)[source]

Finds out if ‘model’ has multishell parameters. If so, returns the name of the counter parameter and the number of shells

sas.qtgui.Perspectives.Fitting.FittingUtilities.getOrientationParam(kernel_module=None)[source]

Get the dictionary with orientation parameters

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

Returns a list with standard parameters for the current model

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

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

sas.qtgui.Perspectives.Fitting.FittingUtilities.isNumber(s)[source]

Checks if string ‘s’ is an int/float

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

Simple lookup for polydispersity for the given param name

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

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

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

Create Data1D/Data2D with residuals, ready for plotting

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

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

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

Calculate the residuals for difference of two Data1D sets

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

Calculate the residuals for difference of two Data2D sets

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

Takes model kernel and applies results dict to its parameters, returning the modified (deep) copy of the kernel.

sas.qtgui.Perspectives.Fitting.FittingWidget module

sas.qtgui.Perspectives.Fitting.GPUOptions module

class sas.qtgui.Perspectives.Fitting.GPUOptions.GPUOptions(parent=None)[source]

Bases: PyQt5.QtWidgets.QDialog, sas.qtgui.Perspectives.Fitting.UI.GPUOptionsUI.Ui_GPUOptions

OpenCL Dialog to select the desired OpenCL driver

__annotations__ = {}
__doc__ = '\n    OpenCL Dialog to select the desired OpenCL driver\n    '
__init__(parent=None)[source]
__module__ = 'sas.qtgui.Perspectives.Fitting.GPUOptions'
accept()[source]

Close the window after modifying the SAS_OPENCL value

addOpenCLOptions()[source]

Populate the window with a list of OpenCL options

checked()[source]

Only allow a single check box to be selected. Uncheck others.

cl_options = None
clicked = False
closeEvent(event)[source]

Overwrite QDialog close method to allow for custom widget close

Link user interactions to function calls

helpButtonClicked()[source]

Open the help menu when the help button is clicked

reject()[source]

Close the window without modifying SAS_OPENCL

sas_open_cl = None
set_sas_open_cl()[source]

Set SAS_OPENCL value when tests run or OK button clicked

testButtonClicked()[source]

Run sasmodels check from here and report results from

testComplete(msg)[source]

Testing done: send signal to main thread with update

testCompleted(msg)[source]

Respond to successful test completion

testFail(msg)[source]

Testing failed: log the reason

testFailed(msg)[source]

Testing failed: log the reason

testThread(no_opencl_msg)[source]

Testing in another thread

testingDoneSignal

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

testingFailedSignal

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

updateCounter(step)[source]

Update progress bar with current value

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

Bases: PyQt5.QtWidgets.QDialog, sas.qtgui.Perspectives.Fitting.UI.GPUTestResultsUI.Ui_GPUTestResults

OpenCL Dialog to modify the OpenCL options

__annotations__ = {}
__doc__ = '\n    OpenCL Dialog to modify the OpenCL options\n    '
__init__(parent, msg)[source]
__module__ = 'sas.qtgui.Perspectives.Fitting.GPUOptions'
sas.qtgui.Perspectives.Fitting.GPUOptions._fromUtf8(s)[source]
sas.qtgui.Perspectives.Fitting.GPUOptions._get_clinfo()[source]

Read in information about available OpenCL infrastructure

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

sas.qtgui.Perspectives.Fitting.ModelThread module

Calculation thread for modeling

class sas.qtgui.Perspectives.Fitting.ModelThread.Calc1D(model, page_id, data, fid=None, qmin=None, qmax=None, weight=None, smearer=None, toggle_mode_on=False, state=None, completefn=None, update_chisqr=True, source='model', updatefn=None, yieldtime=0.01, worktime=0.01, exception_handler=None)[source]

Bases: sas.sascalc.data_util.calcthread.CalcThread

Compute 1D data

__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)[source]
__module__ = 'sas.qtgui.Perspectives.Fitting.ModelThread'
compute()[source]

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

results()[source]

Send resuts of the computation

class sas.qtgui.Perspectives.Fitting.ModelThread.Calc2D(data, model, smearer, qmin, qmax, page_id, state=None, weight=None, fid=None, toggle_mode_on=False, completefn=None, updatefn=None, update_chisqr=True, source='model', yieldtime=0.04, worktime=0.04, exception_handler=None)[source]

Bases: sas.sascalc.data_util.calcthread.CalcThread

Compute 2D model This calculation assumes a 2-fold symmetry of the model where points are computed for one half of the detector and I(qx, qy) = I(-qx, -qy) is assumed.

__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)[source]

Prepare the calculator

__module__ = 'sas.qtgui.Perspectives.Fitting.ModelThread'
compute()[source]

Compute the data given a model function

sas.qtgui.Perspectives.Fitting.MultiConstraint module

Widget for parameter constraints.

class sas.qtgui.Perspectives.Fitting.MultiConstraint.MultiConstraint(parent=None, params=None, constraint=None)[source]

Bases: PyQt5.QtWidgets.QDialog, sas.qtgui.Perspectives.Fitting.UI.MultiConstraintUI.Ui_MultiConstraintUI

Logic class for interacting with MultiConstrainedUI view

__annotations__ = {}
__doc__ = '\n    Logic class for interacting with MultiConstrainedUI view\n    '
__init__(parent=None, params=None, constraint=None)[source]

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

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

Display related help section

revert()[source]

Swap parameters in the view

setupLabels()[source]

Setup labels based on current parameters

setupTooltip()[source]

Tooltip for txtConstraint

validateConstraint(constraint_text)[source]

Ensure the constraint has proper form

validateFormula()[source]

Add visual cues when formula is incorrect

sas.qtgui.Perspectives.Fitting.OptionsWidget module

Widget/logic for smearing data.

class sas.qtgui.Perspectives.Fitting.OptionsWidget.DataWidgetMapper[source]

Bases: PyQt5.QtWidgets.QDataWidgetMapper

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

__annotations__ = {}
__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, QWidget, int)[source]
addMapping(self, QWidget, int, Union[QByteArray, bytes, bytearray]) None
class sas.qtgui.Perspectives.Fitting.OptionsWidget.OptionsWidget(parent=None, logic=None)[source]

Bases: PyQt5.QtWidgets.QWidget, sas.qtgui.Perspectives.Fitting.UI.OptionsWidgetUI.Ui_tabOptions

MODEL = ['MIN_RANGE', 'MAX_RANGE', 'NPTS', 'NPTS_FIT', 'LOG_SPACED']
NPTS_DEFAULT = 50
QMAX_DEFAULT = 0.5
QMIN_DEFAULT = 0.0005
__annotations__ = {}
__doc__ = None
__init__(parent=None, logic=None)[source]
__module__ = 'sas.qtgui.Perspectives.Fitting.OptionsWidget'
initMapper()[source]

Initialize model item <-> UI element mapping

initModel()[source]

Initialize the state

npts2fit(data=None, qmin=None, qmax=None, npts=None)[source]

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

onMaskEdit()[source]

Callback for running the mask editor

onModelChange(top, bottom)[source]

Respond to model change by updating the plot

onRangeReset()[source]

Callback for resetting qmin/qmax

onWeightingChoice(button)[source]

Update weighting in the fit state

plot_signal

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

setEnablementOnDataLoad()[source]

Enable/disable various UI elements based on data loaded

state()[source]

Returns current state of controls

toggleLogData(isChecked)[source]

Toggles between log and linear data sets

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

Update the local model based on calculated values

sas.qtgui.Perspectives.Fitting.OrderWidget module

Widget/logic for dataset ordering.

class sas.qtgui.Perspectives.Fitting.OrderWidget.OrderWidget(parent=None, all_data=None)[source]

Bases: PyQt5.QtWidgets.QWidget, sas.qtgui.Perspectives.Fitting.UI.OrderWidgetUI.Ui_OrderWidgetUI

__annotations__ = {}
__doc__ = None
__init__(parent=None, all_data=None)[source]
__module__ = 'sas.qtgui.Perspectives.Fitting.OrderWidget'
ordering()[source]

Returns the current ordering of the datasets

setupTable()[source]

Populate the widget with dataset names in original order

updateData(all_data)[source]

Read in new datasets and update the view

sas.qtgui.Perspectives.Fitting.ReportPageLogic module

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

Bases: object

Logic for the Report Page functionality. Refactored from FittingWidget.

__dict__ = mappingproxy({'__module__': 'sas.qtgui.Perspectives.Fitting.ReportPageLogic', '__doc__': '\n    Logic for the Report Page functionality. Refactored from FittingWidget.\n    ', '__init__': <function ReportPageLogic.__init__>, 'cleanhtml': <staticmethod(<function ReportPageLogic.cleanhtml>)>, '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)[source]
__module__ = 'sas.qtgui.Perspectives.Fitting.ReportPageLogic'
__weakref__

list of weak references to the object (if defined)

buildPlotsForReport(images)[source]

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

static cleanhtml(raw_html)[source]

Remove html tags from a document

getImages()[source]

Create MPL figures for the current fit

reportHeader()[source]

Look at widget state and extract report header info

reportList()[source]

Return the HTML version of the full report

reportParams()[source]

Look at widget state and extract parameters

sas.qtgui.Perspectives.Fitting.SmearingWidget module

Widget/logic for smearing data.

class sas.qtgui.Perspectives.Fitting.SmearingWidget.DataWidgetMapper[source]

Bases: PyQt5.QtWidgets.QDataWidgetMapper

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

__annotations__ = {}
__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, QWidget, int)[source]
addMapping(self, QWidget, int, Union[QByteArray, bytes, bytearray]) None
class sas.qtgui.Perspectives.Fitting.SmearingWidget.SmearingWidget(parent=None)[source]

Bases: PyQt5.QtWidgets.QWidget, sas.qtgui.Perspectives.Fitting.UI.SmearingWidgetUI.Ui_SmearingWidgetUI

__annotations__ = {}
__doc__ = None
__init__(parent=None)[source]
__module__ = 'sas.qtgui.Perspectives.Fitting.SmearingWidget'
initMapper()[source]

Initialize model item <-> UI element mapping

initModel()[source]

Initialize the state

onDQSmear()[source]

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

onIndexChange(index)[source]

Callback for smearing combobox index change

onModelChange()[source]

Respond to model change by notifying any listeners

onPinholeSmear()[source]

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

onSlitSmear()[source]

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

resetSmearer()[source]
setAccuracyVisibility()[source]

Accuracy combobox visibility

setDQLabels()[source]

Use appropriate labels

setElementsVisibility(visible)[source]

Labels and linedits visibility control

setPinholeLabels()[source]

Use pinhole labels

setSlitLabels()[source]

Use pinhole labels

setSmearInfo()[source]

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)[source]

Sets new values for the controls

smearer()[source]

Returns the current smearer

smearingChangedSignal

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

state()[source]

Returns current state of controls

updateData(data=None)[source]

Update control elements based on data and model passed

updateKernelModel(kernel_model=None, keep_order=False, old_index=None)[source]

Update the model

sas.qtgui.Perspectives.Fitting.ViewDelegate module

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

Bases: PyQt5.QtWidgets.QStyledItemDelegate

Custom delegate for appearance and behavior control of the magnetism view

__annotations__ = {}
__doc__ = '\n    Custom delegate for appearance and behavior control of the magnetism view\n    '
__init__(parent=None)[source]

Overwrite generic constructor to allow for some globals

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

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

createEditor(self, QWidget, QStyleOptionViewItem, QModelIndex) QWidget[source]
editableParameters()[source]
paint(painter, option, index)[source]

Overwrite generic painter for certain columns

class sas.qtgui.Perspectives.Fitting.ViewDelegate.ModelViewDelegate(parent=None)[source]

Bases: PyQt5.QtWidgets.QStyledItemDelegate

Custom delegate for appearance and behavior control of the model view

__annotations__ = {}
__doc__ = '\n    Custom delegate for appearance and behavior control of the model view\n    '
__init__(parent=None)[source]

Overwrite generic constructor to allow for some globals

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

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

createEditor(widget, option, index)[source]

Overwrite generic editor for certain columns

fancyColumns()[source]
paint(painter, option, index)[source]

Overwrite generic painter for certain columns

setModelData(editor, model, index)[source]

Overwrite generic model update method for certain columns

class sas.qtgui.Perspectives.Fitting.ViewDelegate.PolyViewDelegate(parent=None)[source]

Bases: PyQt5.QtWidgets.QStyledItemDelegate

Custom delegate for appearance and behavior control of the polydispersity view

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

Overwrite generic constructor to allow for some globals

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

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

columnDict()[source]
combo_updated

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

createEditor(self, QWidget, QStyleOptionViewItem, QModelIndex) QWidget[source]
editableParameters()[source]
filename_updated

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

paint(painter, option, index)[source]

Overwrite generic painter for certain columns

Module contents