sas.qtgui.Perspectives.Inversion package

Subpackages

Submodules

sas.qtgui.Perspectives.Inversion.DMaxExplorerWidget module

Dialog panel to explore the P(r) inversion results for a range of D_max value. User picks a number of points and a range of distances, then can toggle between inversion outputs and see their distribution as a function of D_max.

class sas.qtgui.Perspectives.Inversion.DMaxExplorerWidget.DmaxWindow(pr_state: Invertor, nfunc: int, parent=None)

Bases: QDialog, Ui_DmaxExplorer

The controller which is responsible for managing signal slot connections for the GUI and providing an interface to the data model.

closeEvent(event: QEvent) → None

Override close event to clear the parent’s reference to this window.

modelChanged(item: QStandardItem | None) → None

Recompute and replot the D_max exploration results when the model changes.

name = 'Dmax Explorer'
setupMapper() → None

Configure the data widget mapper to bind model items to UI widgets.

setupModel() → None

Populate the model with initial values derived from the current P(r) state.

setupSlots() → None

Connect UI signals to their corresponding slots.

setupValidators() → None

Add validators on relevant line edits.

staticMetaObject = PySide6.QtCore.QMetaObject("DmaxWindow" inherits "QDialog": )

sas.qtgui.Perspectives.Inversion.InversionLogic module

class sas.qtgui.Perspectives.Inversion.InversionLogic.InversionLogic(data_item: QStandardItem | None = None)

Bases: object

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

add_errors(sigma: float = 0.05) → ndarray

Add errors to the data set if they are not available.

computeDataRange() → tuple[float | None, float | None]

Compute the data range based on the local dataset.

computeRangeFromData(data: Data1D) → tuple[float | None, float | None]

Compute the minimum and maximum range of the data. Returns the (qmin, qmax) tuple.

property data: Data1D

Return the Data1D object extracted from the current data item.

property data_item: QStandardItem | None

Return the raw QStandardItem held by this logic instance.

isLoadedData() → bool

Return whether data has been loaded into this logic instance.

new1DPlot(tab_id: int = 1, out: ndarray | None = None, pr: Invertor | None = None, q: ndarray | None = None) → Data1D

Create a new 1D data instance based on fitting results.

newPRPlot(out: ndarray, pr: Invertor, cov: ndarray | None = None) → Data1D

Create a new P(r) plot from the inversion results.

sas.qtgui.Perspectives.Inversion.InversionPerspective module

class sas.qtgui.Perspectives.Inversion.InversionPerspective.InversionWindow(parent=None, data=None)

Bases: QTabWidget, Perspective

The main window for the P(r) Inversion perspective. This is the main window where the tabs for each of the widgets are shown.

addData(data: QStandardItem | None = None, is_batch: bool = False, tab_index: int | None = None) → None

Add a new tab for passed data.

allowBatch()

Tell the caller perspective accepts batch mode.

allowSwap() → bool

Tell the caller perspective accepts swapping data.

closeBatchResults() → None
closeDMax() → None
closeEvent(event: QEvent) → None

Overwrite QDialog close method to allow for custom widget close.

closeTabByIndex(index: int) → None

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

closeTabByName(tab_name: str) → None

Given name of the tab - close it.

property currentTab: InversionWidget

Returns the tab widget currently shown.

currentTabDataId() → list

Returns the data ID of the current tab.

ext = 'pr'
getSerializePage(index: int | None = None) → tuple[dict, bool]

Serialize and return a dictionary of {tab_id: inversion-state}. Return original dictionary if no data.

getTabName(is_batch: bool = False) → str

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

help() → None

Open the P(r) Inversion help browser.

isClosable() → bool

Tell the caller if the widget can be closed.

isSerializable() → bool

Tell the caller that this perspective writes its state.

name = 'Inversion'
removeData(data_list: list[QStandardItem]) → None

Remove data from the perspective for requested data items.

reset() → None

Reset the Inversion perspective to an empty state.

resetTab(index: int) → None

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

serializeAll() → dict

Serialize the inversion state for all active inversion pages.

Returns a dictionary mapping data IDs to inversion state: {data-id: {self.name: {inversion-state}}}.

serializeCurrentPage() → tuple[dict, bool]

Serialize current (active) page.

setClosable(value: bool = True) → None

Set the closability flag.

setData(data_item: list[QStandardItem] | None = None, is_batch: bool = False, tab_index: int | None = None) → None

Assign new data set(s) to the P(r) perspective. Obtain a QStandardItem object and parse it to get Data1D/2D. Pass it over to the calculator.

staticMetaObject = PySide6.QtCore.QMetaObject("InversionWindow" inherits "QTabWidget": )
property supports_fitting: bool

Tell caller perspective does not support fitting.

property supports_reports: bool

Tell caller perspective supports reports.

swapData(data: QStandardItem | None = None, tab_index: int | None = None) → None

Replace the data from the current tab.

tabCloses(index: int) → None

Update local bookkeeping on tab close.

property title: str

Returns the title of the perspective.

updateFromParameters(params: dict) → None

Update the current tab from parameters

sas.qtgui.Perspectives.Inversion.InversionUtils module

sas.qtgui.Perspectives.Inversion.InversionWidget module

class sas.qtgui.Perspectives.Inversion.InversionWidget.CalculatedOutputs(rg: float, iq0: float, background: float, calc_time: float, chi2: float, oscillations: float, pos_frac: float, pos_err: float)

Bases: object

background: float
calc_time: float
chi2: float
iq0: float
oscillations: float
pos_err: float
pos_frac: float
rg: float
class sas.qtgui.Perspectives.Inversion.InversionWidget.EstimatedParameters(reg_constant: float, nterms: int)

Bases: object

nterms: int
reg_constant: float
class sas.qtgui.Perspectives.Inversion.InversionWidget.InversionResult(logic: sas.qtgui.Perspectives.Inversion.InversionLogic.InversionLogic, calculator: sas.sascalc.pr.invertor.Invertor, pr_plot: sas.qtgui.Plotting.PlotterData.Data1D | None, data_plot: sas.qtgui.Plotting.PlotterData.Data1D | None, outputs: sas.qtgui.Perspectives.Inversion.InversionWidget.CalculatedOutputs | None, estimated_parameters: sas.qtgui.Perspectives.Inversion.InversionWidget.EstimatedParameters | None)

Bases: object

calculator: Invertor
data_plot: Data1D | None
estimated_parameters: EstimatedParameters | None
logic: InversionLogic
outputs: CalculatedOutputs | None
pr_plot: Data1D | None
class sas.qtgui.Perspectives.Inversion.InversionWidget.InversionWidget(window, parent=None, data=None, tab_id=1, tab_name='')

Bases: QWidget, Ui_PrInversion

acceptsData() → bool
applyNumTermsEstimate()
applyRegConstantEstimate()
batchCalculationComplete(totalElapsed)
batchCalculationOutput
batchResultsWindow: BatchInversionOutputPanel | None
batch_dict: dict[str, Any] | None
calculationComplete
calculationCompleted(out, cov, pr, elapsed)
changeBackgroundMode
clearGuiValues()
communicator: Communicate
property currentData: Data1D | None
property currentDataIndex: int
property currentDataItem: QStandardItem | None
property currentResult: InversionResult
dmaxWindow: DmaxWindow | None
enableButtons()

Enable buttons when data is present, else disable them

endEstimateParameters(nterms, alpha, message, elapsed)
estimateAvailable()
estimationComplete
events()
getPage() → dict[str, Any]
handleBackgroundModeChange()
handleCurrentDataChanged()
handleRemove()
handleShowResults()
initResult() → InversionResult
isCalculating: bool
property is_batch: bool
makePlots(out, cov, pr, elapsed, result=None)
onHelp()
onNewData()
openExplorerWindow()
property q_max: float
property q_min: float
results: list[InversionResult]
serialiseResult(result: InversionResult) → dict[str, Any]
setupValidators()

Apply validators to editable line edits

showBatchCalculationWindow(batch_dict)
showCurrentPlots()
showPlots(result: InversionResult)
startEstimateParameters()
startThread()
startThreadAll()
staticMetaObject = PySide6.QtCore.QMetaObject("InversionWidget" inherits "QWidget": Methods:   #33 type=Signal, signature=calculationComplete()   #34 type=Signal, signature=batchCalculationOutput(PyObject), parameters=PyObject   #35 type=Signal, signature=estimationComplete()   #36 type=Signal, signature=changeBackgroundMode() )
threadError(error: str)
updateFromParameters(params: dict[str, Any])
updateGuiSuggested(nterms, alpha)
updateGuiValues()
updateMaxQ(new_q_max: float)
updateMinQ(new_q_min: float)
updateParams()
updateTab(data: HashableStandardItem | list[HashableStandardItem], tab_id: int)
sas.qtgui.Perspectives.Inversion.InversionWidget.format_float(f: float)
sas.qtgui.Perspectives.Inversion.InversionWidget.format_float_scientific(f: float)

Formats a float in scientific notation with 3 significant figures.

sas.qtgui.Perspectives.Inversion.InversionWidget.get_outputs(invertor: Invertor, elapsed: float)

sas.qtgui.Perspectives.Inversion.Thread module

class sas.qtgui.Perspectives.Inversion.Thread.CalcBatchPr(prs: list[Invertor], nfuncs: list[int] | None = None, tab_id: int | None = None, error_func: Callable | None = None, completefn: Callable | None = None, updatefn: Callable | None = None, yieldtime: float = 0.01, worktime: float = 0.01)

Bases: CalcThread

Compute P(r) inversion for a batch of data sets in a background thread.

compute() → None

Perform P(r) inversion for each invertor in the batch.

class sas.qtgui.Perspectives.Inversion.Thread.CalcPr(pr: Invertor, nfunc: int = 5, tab_id: int | None = None, error_func: Callable | None = None, completefn: Callable | None = None, updatefn: Callable | None = None, yieldtime: float = 0.01, worktime: float = 0.01)

Bases: CalcThread

Compute P(r) inversion in a background thread.

compute() → None

Perform P(r) inversion.

class sas.qtgui.Perspectives.Inversion.Thread.EstimateNT(pr: Invertor, nfunc: int = 5, error_func: Callable | None = None, completefn: Callable | None = None, updatefn: Callable | None = None, yieldtime: float = 0.01, worktime: float = 0.01)

Bases: CalcThread

Estimate the number of terms for P(r) inversion in a background thread.

compute() → None

Calculate the estimated number of terms and optimal alpha.

isquit() → None

Check for quit signal and throttle with a short sleep if needed.

class sas.qtgui.Perspectives.Inversion.Thread.EstimatePr(pr: Invertor, nfunc: int = 5, error_func: Callable | None = None, completefn: Callable | None = None, updatefn: Callable | None = None, yieldtime: float = 0.01, worktime: float = 0.01)

Bases: CalcThread

Estimate the regularisation parameter alpha for P(r) in a background thread.

compute() → None

Calculate the alpha estimate.

Module contents