sas.qtgui.Perspectives.SizeDistribution package

Subpackages

Submodules

sas.qtgui.Perspectives.SizeDistribution.SizeDistributionLogic module

class sas.qtgui.Perspectives.SizeDistribution.SizeDistributionLogic.SizeDistributionLogic(data: Data1D | None = None)

Bases: object

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

computeBackground(constant: float, scale: float, power: float) → None
computeDataRange() → tuple[float, float]

Compute the minimum and the maximum range of the data.

computeTrustRange(qmin: float, qmax: float) → list[float]

Compute the trusted range (green area in Irena).

property data: Data1D | None

Return the data.

fitBackground(power: float | None, qmin: float, qmax: float) → list[float] | None

Estimate the background power law, given by: scale * q^(power).

Parameters:

power – if a float is given, the power is fixed; if None, the power is fitted

Returns:

fit parameters; [scale] if power is fixed, or [scale, power] if power is fitted

isLoadedData() → bool

Return whether data is loaded.

newDataPlot() → tuple[Data1D, Data1D, Data1D | None]

Create a new 1D data instance.

newSizeDistrPlot(result: MaxEntResult, qmin: float, qmax: float) → tuple[Data1D, Data1D]

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

setDataProperties() → None

Analyze data and set up some properties important for the presentation layer.

sas.qtgui.Perspectives.SizeDistribution.SizeDistributionPerspective module

class sas.qtgui.Perspectives.SizeDistribution.SizeDistributionPerspective.SizeDistributionWindow(parent: QWidget | None = None)

Bases: QDialog, Ui_SizeDistribution, Perspective

The main window for the Size Distribution perspective.

allowBatch() → bool

Tell the caller we don’t accept batch data.

allowSwap() → bool

Tell the caller we don’t accept swapping data.

clearStatistics() → None

Clear the output box.

closeEvent(event: QCloseEvent) → None

Overwrite QDialog close method to allow for custom widget close.

data_plot_signal
enableButtons() → None

Enable buttons when data is present, else disable them.

eventFilter(widget: QObject, event: QEvent) → bool

Catch enter key presses and update data plot.

ext: str = 'ps'
fitComplete(result: MaxEntResult) → None

Receive and display fitting results.

Parameters:

result – MaxEnt fitting result object containing the calculated statistics and fitted data used to update the plots and output.

fittingCompleted(result: MaxEntResult | None) → None

Send the finish message from calculate threads to main thread.

fittingError(etype: type[BaseException], value: BaseException, traceback: TracebackType | None) → None

Handle error in the calculation thread.

fittingFinishedSignal
getBackgroundParams() → tuple[float, float, float]

Collect background parameters from the GUI state.

getFlatBackgroundRange() → tuple[float, float]

Collect background range from the GUI state.

getMaxEntParams() → MaxEntParameters

Collect Max Ent parameters from the GUI state.

getPage() → dict[str, str | bool]

Serializes full state of this fit page into a dictionary.

Returns:

a dictionary of {param_name: value}

getPowerLawBackgroundRange() → tuple[float, float]

Collect power law range from the GUI state.

getState() → dict[str, str | bool]

Collects all active params into a dictionary.

Returns:

a dictionary of {name: value}

getWeightType() → WeightType | None

Return the weight type based on the checked radio button.

help() → None

Open the Size Distribution help.

isClosable() → bool

Return whether this widget is currently closable.

isSerializable() → bool

Tell the caller that this perspective writes its state.

name: str = 'SizeDistribution'
onFitFlatBackground() → None

Fit flat background and update plot.

onFitPowerLaw() → None

Fit background power law and update plot.

onFullFit() → None

Perform a full fit of the size distribution.

onLowQStateChanged(state: int) → None

Slot for state change of the subtract power law checkbox.

onQuickFit() → None

Perform a quick fit of the size distribution.

onRangeReset() → None

Callback for resetting qmin/qmax.

plotData() → None

Plot data, background and background subtracted data.

removeData(data_list: list | None = None) → None

Remove the existing data reference from the Size Distribution Perspective.

reset() → None

Reset the size distribution perspective to an empty state.

resetWindow() → None

Reset the state of input widgets and data structures to default values.

serializeAll() → dict

Serialize the size distribution state so data can be saved. Size distribution is not batch-ready so this will only effect a single page.

Returns:

a dictionary of {data-id: {self.name: {inversion-state}}}

serializeCurrentPage() → dict

Serialize and return a dictionary representing the current state of the size distribution page. Return empty dictionary if no data.

Returns:

a dictionary of {data-id: {self.name: {invariant - state}}}

setClosable(value: bool = True) → None

Allow outsiders close this widget.

setData(data_item: list | None = None, is_batch: bool = False) → None

Obtain a QStandardItem object and parse it to get Data1D/2D Pass it over to the calculator

setupMapper() → None

Set up the mapper.

setupModel() → None

Update boxes with initial values.

setupSlots() → None

Connect the use controls to their appropriate methods.

setupValidators() → None

Apply validators to editable line edits.

setupWindow() → None

Initialize base window state on startup.

staticMetaObject = PySide6.QtCore.QMetaObject("SizeDistributionWindow" inherits "QDialog": Methods:   #41 type=Signal, signature=fittingFinishedSignal(PyObject), parameters=PyObject   #42 type=Signal, signature=data_plot_signal() )
property title: str

Return the window title.

updateBackground() → None

Update the background data.

updateFromParameters(params: dict) → None

Update the GUI state based on a dictionary of parameters. Called by Open Project, Open Analysis, and removeData.

Parameters:

params – a dictionary of {param_name: value}; default values used if not valid

updateQRange(q_range_min: float, q_range_max: float) → None

Update the local model based on calculated values.

updateStatistics(result: MaxEntResult) → None

Update the output box with statistics.

sas.qtgui.Perspectives.SizeDistribution.SizeDistributionThread module

class sas.qtgui.Perspectives.SizeDistribution.SizeDistributionThread.SizeDistributionThread(data: Data1D, background: Data1D, params: MaxEntParameters, completefn: Callable[[MaxEntResult], None] | None = None, updatefn: Callable | None = None, yieldtime: float = 0.01, worktime: float = 0.01, exception_handler: Callable | None = None)

Bases: CalcThread

Thread performing the fit.

compute(*args, **kwargs) → None

Perform the size distribution fit.

sas.qtgui.Perspectives.SizeDistribution.SizeDistributionUtils module

class sas.qtgui.Perspectives.SizeDistribution.SizeDistributionUtils.MaxEntParameters(qmin: float = 0.0, qmax: float = 0.1, dmin: float = 10.0, dmax: float = 1000.0, num_bins: int = 100, log_binning: bool = True, model: str = 'ellipsoid', aspect_ratio: float = 1.0, contrast: float = 1.0, sky_background: float = 1e-06, max_iterations: int = 100, use_weights: bool = True, weight_type: WeightType | None = WeightType.DI, weight_factor: float = 1.0, weight_percent: float = 1.0, full_fit: bool = True)

Bases: object

Parameters for the maximum entropy size distribution fit.

aspect_ratio: float = 1.0
contrast: float = 1.0
dmax: float = 1000.0
dmin: float = 10.0
full_fit: bool = True
log_binning: bool = True
max_iterations: int = 100
model: str = 'ellipsoid'
num_bins: int = 100
qmax: float = 0.1
qmin: float = 0.0
sky_background: float = 1e-06
use_weights: bool = True
weight_factor: float = 1.0
weight_percent: float = 1.0
weight_type: WeightType | None = 'dI'
class sas.qtgui.Perspectives.SizeDistribution.SizeDistributionUtils.MaxEntResult(convergences: list[bool], num_iters: list[int], chisq: float, bins: list[float], bin_mag: list[float], bin_diff: list[float], bin_err: list[float], data_max_ent: Data1D, statistics: dict)

Bases: object

Results of the maximum entropy size distribution fit.

bin_diff: list[float]
bin_err: list[float]
bin_mag: list[float]
bins: list[float]
chisq: float
convergences: list[bool]
data_max_ent: Data1D
num_iters: list[int]
statistics: dict
class sas.qtgui.Perspectives.SizeDistribution.SizeDistributionUtils.WeightType(*values)

Bases: StrEnum

Enumeration of weight types for the size distribution fit.

DI = 'dI'
NONE = 'None'
PERCENT_I = 'percentI'
SQRT_I = 'sqrt(I Data)'

Module contents