sas.qtgui.Calculators package

Subpackages

Submodules

sas.qtgui.Calculators.DataOperationUtilityPanel module

class sas.qtgui.Calculators.DataOperationUtilityPanel.DataOperationUtilityPanel(parent=None)

Bases: QDialog, Ui_DataOperationUtility

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

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

__module__ = 'sas.qtgui.Calculators.DataOperationUtilityPanel'
_extractData(key_id)

Extract data from file with id contained in list of filenames

_findId(name)

find id of name in list of filenames

newPlot(graph, layout)

Create template for graphs with default ‘?’ layout

onCheckChosenData()

check that data1 and data2 are compatible

onCheckOutputName()

Check that name of output does not already exist

onClose()

Close dialog

onCompute()

perform calculation

onHelp()

Bring up the Data Operation Utility Documentation whenever the HELP button is clicked. Calls Documentation Window with the path of the location within the documentation tree (after /doc/ ….”.

onInputCoefficient()

Check input of number when a coefficient is required for operation

onPrepareOutputData()

Prepare datasets to be added to DataExplorer and DataManager

onReset()

Reset Panel to its initial state (default values) keeping the names of loaded data

onSelectData1()

Plot for selection of Data1

onSelectData2()

Plot for selection of Data2

onSelectOperator()

Change GUI when operator changed

prepareSubgraphWithData(data)

Create graphics view containing scene with string

staticMetaObject = PySide6.QtCore.QMetaObject("DataOperationUtilityPanel" inherits "QDialog": )
updateCombobox(filenames)

Function to fill comboboxes with names of datafiles loaded in DataExplorer. For Data2, there is the additional option of choosing a number to apply to data1

updatePlot(graph, layout, data)

plot data in graph after clearing its layout

sas.qtgui.Calculators.DensityPanel module

class sas.qtgui.Calculators.DensityPanel.DensityPanel(parent=None)

Bases: QDialog

__annotations__ = {}
__doc__ = None
__init__(self, parent: PySide6.QtWidgets.QWidget | None = None, f: PySide6.QtCore.Qt.WindowType = Default(Qt.WindowFlags)) None

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

__module__ = 'sas.qtgui.Calculators.DensityPanel'
_updateDensity()
_updateVolume()
dataChanged(top, bottom)
displayHelp()
formulaChanged(current_text)
massChanged(current_text)
modelReset()
setMode(mode)
setupMapper()
setupModel()
setupUi()
staticMetaObject = PySide6.QtCore.QMetaObject("DensityPanel" inherits "QDialog": )
volumeChanged(current_text)
sas.qtgui.Calculators.DensityPanel.toMolarMass(formula)

sas.qtgui.Calculators.GenericScatteringCalculator module

class sas.qtgui.Calculators.GenericScatteringCalculator.GenericScatteringCalculator(parent=None)

Bases: QDialog, Ui_GenericScatteringCalculator

TEXTBOX_DEFAULT_STYLESTRING = 'background-color: rgb(255, 255, 255);'
TEXTBOX_ERROR_STYLESTRING = 'background-color: rgb(255, 182, 193);'
TEXTBOX_WARNING_STYLESTRING = 'background-color: rgb(255, 226, 110);'
__annotations__ = {}
__doc__ = None
__init__(self, parent: PySide6.QtWidgets.QWidget | None = None, f: PySide6.QtCore.Qt.WindowType = Default(Qt.WindowFlags)) None

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

__module__ = 'sas.qtgui.Calculators.GenericScatteringCalculator'
_create_default_1d_data()

Create the 1D data range for q

Copied from previous version Create 1D data by default

Warning

This data is never plotted.

residuals.x = data_copy.x[index] residuals.dy = numpy.ones(len(residuals.y)) residuals.dx = None residuals.dxl = None residuals.dxw = None

_create_default_2d_data()

Create the 2D data range for qx,qy

Copied from previous version Create 2D data by default

Warning

This data is never plotted.

_create_default_sld_data()

Creates default sld data for use if no file has been loaded

Copied from previous version

Warning

deprecated

_update(time=None, percentage=None)

Copied from previous version

calculateComplete(d)

Notify the main thread

calculateFailed(reason)
calculationFinishedSignal
change_data_type()

Adjusts the GUI for the enabled nuclear/magnetic data files

When different combinations of nuclear and magnetic data files are loaded various options must be enabled/disabled or hidden/made visible. This function controls that behaviour and is called whenever the checkboxes for enabling files are altered. If the data file for a given type of data is not loaded then the average value textbox is enabled to allow the user to give a constant value for all points. If no data files are loaded then the node and stepsize textboxes are enabled to allow the user to specify a simple rectangular lattice.

change_is_avg()

Adjusts the GUI for whether 1D averaging is enabled

If the user has chosen to carry out Debye full averaging then the magnetic sld values must be set to 0, and made uneditable - because the calculator in geni.py is incapable of averaging systems with non-zero magnetic slds or polarisation.

This function is called whenever different files are enabled or the user edits the averaging combobox.

change_qValidator()
check_for_magnetic_controls()
check_units()

Check if the units from the OMF file correspond to the default ones displayed on the interface. If not, modify the GUI with the correct units

closeEvent(event)

Overwrite the close event and hide the window instead of closing it

complete(input, update=None)

Carry out the compuation of I(qx, qy) in a new thread

Gen compute complete function

This function separates the range of q or (qx,qy) into chunks and then calculates each chunk with calls to the model.

Parameters:

input (list) – input list [qx_data, qy_data, i_out]

complete_loading(data=None, load_nuc=True)

Function which handles the datafiles once they have been loaded in - used in GenRead

Once the data has been loaded in by the required reader it is necessary to do a small amount of final processing to put them in the required form. This involves converting all the data to instances of MagSLD and reporting any errors. Additionally, verification of the newly loaded file is carried out.

Parameters:
  • data (OMFData, MagSLD depending on filetype) – The data loaded from the requested file.

  • load_nuc (bool) – Specifies whether the loaded file is nuclear or magnetic data. Defaults to True. load_nuc=True gives nuclear sld data. load_nuc=False gives magnetic sld data.

complete_loading_ex(data=None, load_nuc=True)

Send the finish message from calculate threads to main thread

Parameters:
  • data (OMFData, MagSLD depending on filetype) – The data loaded from the requested file.

  • load_nuc (bool) – Specifies whether the loaded file is nuclear or magnetic data. Defaults to True. load_nuc=True gives nuclear sld data. load_nuc=False gives magnetic sld data.

create_full_sld_data()

Create the sld data to be used in the final calculation

This function creates an instance of MagSLD which contains the required data for sas_gen and 3D plotting. It is the suitable combination of data from the magnetic data, nuclear data and set GUI parameters. Where nuclear and magnetic files are enabled it sometimes has to make a choice regarding which version of a parameter to keep. This is usually the nuclear data version, as in the case of .pdb files being used this version will contain more complete data.

Returns:

The full sld data created from the various different sources

Return type:

MagSLD

create_rotation_matrices()

Create the rotation matrices between different coordinate systems

UVW coords: beamline coords uvw coords: environment coords xyz coords: sample coords

The GUI contains values of yaw, pitch and roll from uvw to xyz coordinates and from UVW to uvw. These are right handed coordinate systems with UVW being the beamline coordinate system with:

U: horizonatal axis

V: vertical axis

W: axis back from detector to sample

The rotation given by the user transforms the BASIS VECTORS - the user gives the trasformation from beamline coords to samplecoords for example - so from there perspective the beamline is the fixed object and the environment and sample rotate. The rotation is first a yaw angle about the V axis (UVW -> U’V’W’) then a pitch angle about the U’ axis (U’V’W’ -> U’’V’’W’’) and finally a roll rotation abot the W’’ axis (U’’V’’W’’ -> uvw).

This function expects that the textbox values are correct.

Returns:

two rotations, the first from UVW to xyz coords, the second from UVW to uvw coords

Return type:

tuple of scipy.spatial.transform.Rotation

eventFilter(target, event)

Catches the event that a textbox has been enabled/disabled

file_name()

Creates a suitable filename for display on graphs depending on which files are enabled

Returns:

the filename

Return type:

str

getFileName()
gui_text_changed(sender)

check whether lineEdit values are valid

This function checks whether lineEdits are valid, and if not highlights them and calls for functionality to be disabled. It checks for both errors and warnings. Error states highlight red and disable functionality. These are ‘intermediate’ states which do not match the regex. Warning states are highlighted orange and warn the user the value may be problematic. Warnings were previously checked for in the check_value() method.

For warnings this checks that QMax and the number of Qbins is suitable given the user chosen values. Unlike the hard limits imposed by the regex, this does not prevent the user using the given value, but warns them that it may be unsuitable with a backcolour.

Parameters:

sender (QWidget) – The QLineEdit in question

gui_text_changed_slot()

Catches the signal that a textbox has beeen altered

hideWindow()

Hide the window when the close button is clicked

loadFile()

Opens a menu to choose the datafile to load

Opens a file dialog to allow the user to select a datafile to be loaded. If a nuclear sld datafile is loaded then the allowed file types are: .SLD .sld .PDB .pdb If a magnetic sld datafile is loaded then the allowed file types are: .SLD .sld .OMF .omf This function then loads in the requested datafile, but does not enable it. If no previous datafile of this type was loaded then the checkbox to enable this file is enabled.

Parameters:

load_nuc (bool) – Specifies whether the loaded file is nuclear or magnetic data. Defaults to True. load_nuc=True gives nuclear sld data. load_nuc=False gives magnetic sld data.

load_update()

Legacy function used in GenRead

loadingFinishedSignal
onCancel()

Notify the calculation thread that the user has cancelled the calculation.

onCompute()

Execute the computation of I(qx, qy)

Copied from previous version

onHelp()

Bring up the Generic Scattering calculator Documentation whenever the HELP button is clicked. Calls Documentation Window with the path of the location within the documentation tree (after /doc/ ….”.

onReset()

Reset the GUI to its default state

This resets all GUI parameters to their default values and also resets all GUI states such as loaded files, stored data, verification and disabled/enabled widgets.

onSaveFile()

Save data as .sld file

plot3d(has_arrow=False)

Generate 3D plot in real space with or without arrows

Parameters:

has_arrow (bool) – Whether to plot arrows for the magnetic field on the plot. Defaults to False

plot_1_2d()

Generate 1D or 2D plot, called in Compute

reset_camera()
selectedshapechange()

TODO Temporary solution to display information about option ‘Ellipsoid’

set_polarisation_visible(visible)

This function updates the visibility of the polarisation vector This is one of four functions affecting the coordinate system visualisation which should be updated if a new 3D rendering library is used: setup_display(), update_coords(), update_polarisation_coords(), set_polarisation_visible().

setup_display()

This function sets up the GUI display of the different coordinate systems. Since these cannot be set in the .ui file they should be QWidgets added to the self.coord_display layout. This is one of four functions affecting the coordinate system visualisation which should be updated if a new 3D rendering library is used: setup_display(), update_coords(), update_polarisation_coords(), set_polarisation_visible().

staticMetaObject = PySide6.QtCore.QMetaObject("GenericScatteringCalculator" inherits "QDialog": Methods:   #42 type=Signal, signature=trigger_plot_3d()   #43 type=Signal, signature=calculationFinishedSignal()   #44 type=Signal, signature=loadingFinishedSignal(QVariantList,bool), parameters=QVariantList, bool )
toggle_error_functionality()

Disables/Enables some functionality if the state of the GUI means calculation cannot proceed

This function is called during any process whenever there is a risk that the state of the GUI will make the data invalid for plotting, drawing or saving. If that is the case then this functionality is disabled. This function is currently called when two files are being verified for compatibility, and when textboxes enter ‘intermediate’ states.

trigger_plot_3d
update_Rg()
update_cbOptionsCalc_visibility()
update_coords()

This function rotates the visualisation of the coordinate systems This is one of four functions affecting the coordinate system visualisation which should be updated if a new 3D rendering library is used: setup_display(), update_coords(), update_polarisation_coords(), set_polarisation_visible().

update_file_name()
update_geometry_effects()

This function updates the number of pixels and total volume when the number of nodes/stepsize is changed

This function only has an effect if no files are enabled otherwise the number of pixels and total volume may be set differently by the data from the file.

update_gui()

Update the interface and model with values from loaded data

This function updates the model parameter ‘total_volume’ with values from the loaded data and then updates all values in the gui with either model paramters or paramaters from the loaded data.

update_polarisation_coords()

This function rotates the visualisation of the polarisation vector This is one of four functions affecting the coordinate system visualisation which should be updated if a new 3D rendering library is used: setup_display(), update_coords(), update_polarisation_coords(), set_polarisation_visible().

write_new_values_from_gui()

Update parameters in model using modified inputs from GUI

Before the model is used to calculate any scattering patterns it needs to be updated with values from the gui. This does not affect any fixed values, whose textboxes are disabled, and means that any user chosen changes are made. It also ensure that at all times the values in the GUI reflect the data output.

class sas.qtgui.Calculators.GenericScatteringCalculator.Plotter3D(gsc_instance: GenericScatteringCalculator | None, parent=None, graph_title='')

Bases: QDialog, Plotter3DWidget

__annotations__ = {}
__doc__ = None
__init__(self, parent: PySide6.QtWidgets.QWidget | None = None, f: PySide6.QtCore.Qt.WindowType = Default(Qt.WindowFlags)) None

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

__module__ = 'sas.qtgui.Calculators.GenericScatteringCalculator'
closeEvent(self, arg__1: PySide6.QtGui.QCloseEvent) None
staticMetaObject = PySide6.QtCore.QMetaObject("Plotter3D" inherits "QDialog": )
class sas.qtgui.Calculators.GenericScatteringCalculator.Plotter3DWidget(parent=None, parent_window=None, manager=None)

Bases: PlotterBase

__annotations__ = {}
__doc__ = None
__init__(self, parent: PySide6.QtWidgets.QWidget | None = None, f: PySide6.QtCore.Qt.WindowType = Default(Qt.WindowFlags)) None

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

__module__ = 'sas.qtgui.Calculators.GenericScatteringCalculator'
closeEvent(event)

Overwrite the close event adding helper notification

createContextMenu()

Define common context menu and associated actions for the MPL widget

createContextMenuQuick()

Define context menu and associated actions for the quickplot MPL widget

property data

data getter

plot(data=None, has_arrow=False)

Plot 3D self._data

showPlot(data, has_arrow=False)

Render and show the current data

staticMetaObject = PySide6.QtCore.QMetaObject("Plotter3DWidget" inherits "PlotterBase": )

sas.qtgui.Calculators.KiessigPanel module

class sas.qtgui.Calculators.KiessigPanel.KiessigPanel(parent=None)

Bases: QDialog, Ui_KiessigPanel

__annotations__ = {}
__doc__ = None
__init__(self, parent: PySide6.QtWidgets.QWidget | None = None, f: PySide6.QtCore.Qt.WindowType = Default(Qt.WindowFlags)) None

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

__module__ = 'sas.qtgui.Calculators.KiessigPanel'
onClose()

close the window containing this panel

onCompute()

Execute the computation of thickness

onHelp()

Bring up the Kiessig fringe calculator Documentation whenever the HELP button is clicked. Calls DocumentationWindow with the path of the location within the documentation tree (after /doc/ ….”.

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

sas.qtgui.Calculators.ResolutionCalculatorPanel module

This object is a small tool to allow user to quickly determine the variance in q from the instrumental parameters.

class sas.qtgui.Calculators.ResolutionCalculatorPanel.ResolutionCalculatorPanel(parent=None)

Bases: QDialog, Ui_ResolutionCalculatorPanel

__annotations__ = {}
__doc__ = None
__init__(self, parent: PySide6.QtWidgets.QWidget | None = None, f: PySide6.QtCore.Qt.WindowType = Default(Qt.WindowFlags)) None

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

__module__ = 'sas.qtgui.Calculators.ResolutionCalculatorPanel'
_str2longlist(input_string)

Change NNN, NNN,… to list, NNN - NNN ; NNN to list, or float to list : return new_string: string like list

_string2inputlist(input_string)

Change NNN, NNN,… to list,ie. [NNN, NNN,…] where NNN is a number : return new_list: string like list

_string2list(input_string)

Change NNN, NNN to list,ie. [NNN, NNN] where NNN is a number

_validate_q_input(qx, qy)

Check if q inputs are valid : params qx: qx as a list : params qy: qy as a list : return: True/False

calc_func(qx, qy, qx_min, qx_max, qy_min, qy_max)

Perform the calculation for a given set of Q values. : return: image (numpy array)

calculateFailed(reason)
checkAperture()

Validator for Sample and Source apertures

checkPixels()

Validator for detector pixel size and number

checkQx_y()

Validator for qx and qy inputs

checkWavelength()

Validator for Wavelength if TOF, wavelength = min - max else only one number

checkWavelengthSpread()

Validator for WavelengthSpread Input can be a ‘number or min - max (; Number of bins)’

complete(image)

Complete computation

createTemplate2DPlot()

Create a template for 2D data

drawLines()

Draw lines in image if applicable

formatNumber(value=None)

Return a float in a standardized, human-readable formatted string

map_wrapper(func, qx, qy, qx_min, qx_max, qy_min, qy_max)

Prepare the Mapping for the computation : params qx, qy, qx_min, qx_max, qy_min, qy_max: : return: image (numpy array)

new2DPlot()

Create a new 2D data instance based on computing results

onCompute()

Execute the computation of resolution

onHelp()

Bring up the Resolution Calculator Documentation whenever the HELP button is clicked. Calls Documentation Window with the path of the location within the documentation tree (after /doc/ ….”.

onReset()
onSelectCustomSpectrum()

On Spectrum Combobox event

onSelectWaveColor()

Modify layout of GUI when TOF selected: add elements and modify default entry of Wavelength

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

sas.qtgui.Calculators.SldPanel module

class sas.qtgui.Calculators.SldPanel.NeutronSldResult(neutron_wavelength, neutron_sld_real, neutron_sld_imag, neutron_inc_xs, neutron_abs_xs, neutron_length)

Bases: object

__dict__ = mappingproxy({'__module__': 'sas.qtgui.Calculators.SldPanel', '__init__': <function NeutronSldResult.__init__>, '__dict__': <attribute '__dict__' of 'NeutronSldResult' objects>, '__weakref__': <attribute '__weakref__' of 'NeutronSldResult' objects>, '__doc__': None, '__annotations__': {}})
__doc__ = None
__init__(neutron_wavelength, neutron_sld_real, neutron_sld_imag, neutron_inc_xs, neutron_abs_xs, neutron_length)
__module__ = 'sas.qtgui.Calculators.SldPanel'
__weakref__

list of weak references to the object

class sas.qtgui.Calculators.SldPanel.SldPanel(parent=None)

Bases: QDialog

__annotations__ = {}
__doc__ = None
__init__(self, parent: PySide6.QtWidgets.QWidget | None = None, f: PySide6.QtCore.Qt.WindowType = Default(Qt.WindowFlags)) None

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

__module__ = 'sas.qtgui.Calculators.SldPanel'
_getOutputs()
calculateSLD()
closePanel()

close the window containing this panel

dataChanged(top, bottom)
displayHelp()
modelReset()
recalculateSLD()
setupMapper()
setupModel()
setupUi()
staticMetaObject = PySide6.QtCore.QMetaObject("SldPanel" inherits "QDialog": )
class sas.qtgui.Calculators.SldPanel.XraySldResult(xray_wavelength, xray_sld_real, xray_sld_imag)

Bases: object

__dict__ = mappingproxy({'__module__': 'sas.qtgui.Calculators.SldPanel', '__init__': <function XraySldResult.__init__>, '__dict__': <attribute '__dict__' of 'XraySldResult' objects>, '__weakref__': <attribute '__weakref__' of 'XraySldResult' objects>, '__doc__': None, '__annotations__': {}})
__doc__ = None
__init__(xray_wavelength, xray_sld_real, xray_sld_imag)
__module__ = 'sas.qtgui.Calculators.SldPanel'
__weakref__

list of weak references to the object

sas.qtgui.Calculators.SldPanel.neutronSldAlgorithm(molecular_formula, mass_density, neutron_wavelength)
sas.qtgui.Calculators.SldPanel.xraySldAlgorithm(molecular_formula, mass_density, xray_wavelength)

sas.qtgui.Calculators.SlitSizeCalculator module

Slit Size Calculator Panel

class sas.qtgui.Calculators.SlitSizeCalculator.SlitSizeCalculator(parent=None)

Bases: QDialog, Ui_SlitSizeCalculator

__annotations__ = {}
__doc__ = None
__init__(self, parent: PySide6.QtWidgets.QWidget | None = None, f: PySide6.QtCore.Qt.WindowType = Default(Qt.WindowFlags)) None

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

__module__ = 'sas.qtgui.Calculators.SlitSizeCalculator'
calculateSlitSize(data=None)

Computes slit lenght from given 1D data

chooseFile()

Shows the Open file dialog and returns the chosen path(s)

clearResults()

Clear the content of output LineEdits

onBrowse()

Browse the file and calculate slit lenght upon loading

onClose()

close the window containing this panel

onHelp()

Bring up the Slit Size Calculator calculator Documentation whenever the HELP button is clicked. Calls DocumentationWindow with the path of the location within the documentation tree (after /doc/ ….”.

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

Module contents