# sas.qtgui.Perspectives.Inversion package

## Subpackages

- sas.qtgui.Perspectives.Inversion.UI package
  - Submodules
  - sas.qtgui.Perspectives.Inversion.UI.DMaxExplorer module
    - `Ui_DmaxExplorer`
      - `Ui_DmaxExplorer.retranslateUi()`
      - `Ui_DmaxExplorer.setupUi()`
  - sas.qtgui.Perspectives.Inversion.UI.TabbedInversionUI module
    - `Ui_PrInversion`
      - `Ui_PrInversion.retranslateUi()`
      - `Ui_PrInversion.setupUi()`
  - Module contents

## 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, nfunc, parent=None)

  Bases: `QDialog`, `Ui_DmaxExplorer`

  closeEvent(event)

    Override close event

  modelChanged(item)
  name = 'Dmax Explorer'
  setupMapper()
  setupModel()
  setupSlots()
  setupValidators()

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

  Bases: `object`

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

  add_errors(sigma=0.05)

    Adds errors to data set is they are not available.

  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

  property data: Data1D
  property data_item: QStandardItem | None
  isLoadedData()

    accessor

  new1DPlot(tab_id=1, out=None, pr=None, q=None)

    Create a new 1D data instance based on fitting results

  newPRPlot(out, pr, cov=None)

## 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=None, is_batch=False, tab_index=None)

    Add a new tab for passed data

  allowBatch()

    Tell the caller we accept batch mode

  allowSwap()

    Tell the caller we accept swapping data

  closeBatchResults()
  closeDMax()
  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 tab - close it

  communicator()
  property currentTab: InversionWidget

    Returns the tab widget currently shown

  currentTabDataId()

    Returns the data ID of the current tab

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

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

  getTabName(is_batch=False)

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

  help()

    Open the P(r) Inversion help browser

  isClosable()

    Allow outsiders close this widget

  isSerializable()

    Tell the caller that this perspective writes its state

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

    Remove data from

  resetTab(index)

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

  serializeAll()

    Serialize the inversion state so data can be saved serialize all active inversion pages and return a dictionary: {data-id: {self.name: {inversion-state}}}

  serializeCurrentPage()
  setClosable(value=True)

    Allow outsiders close this widget

  setData(data_item=None, is_batch=False, tab_index=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
  property supports_reports

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

  swapData(data=None, tab_index=None)

    Replace the data from the current tab

  tabCloses(index)

    Update local bookkeeping on tab close

  property title

    Window title

  updateFromParameters(params)

    Update the perspective using a dictionary of parameters e.g. those loaded via open project or open analysis menu items

## 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
  calculationComplete
  calculationCompleted(out, cov, pr, elapsed)
  changeBackgroundMode
  clearGuiValues()
  property currentData: Data1D | None
  property currentDataIndex: int
  property currentDataItem: QStandardItem | None
  property currentResult: InversionResult
  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
  property is_batch: bool
  makePlots(out, cov, pr, elapsed, result=None)
  onHelp()
  onNewData()
  openExplorerWindow()
  property q_max: float
  property q_min: float
  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=None, tab_id=None, error_func=None, completefn=None, updatefn=None, yieldtime=0.01, worktime=0.01)

  Bases: `CalcThread`

  compute()

    Perform a work unit. The subclass will provide details of the arguments.

class sas.qtgui.Perspectives.Inversion.Thread.CalcPr(pr, nfunc=5, tab_id=None, error_func=None, completefn=None, updatefn=None, yieldtime=0.01, worktime=0.01)

  Bases: `CalcThread`

  Compute P(r)

  compute()

    Perform P(r) inversion

class sas.qtgui.Perspectives.Inversion.Thread.EstimateNT(pr, nfunc=5, error_func=None, completefn=None, updatefn=None, yieldtime=0.01, worktime=0.01)

  Bases: `CalcThread`

  compute()

    Calculates the estimate

  isquit()

class sas.qtgui.Perspectives.Inversion.Thread.EstimatePr(pr, nfunc=5, error_func=None, completefn=None, updatefn=None, yieldtime=0.01, worktime=0.01)

  Bases: `CalcThread`

  Estimate P(r)

  compute()

    Calculates the estimate

## Module contents