sas.qtgui.Calculators package

Subpackages

Submodules

sas.qtgui.Calculators.DataOperationUtilityPanel module

class sas.qtgui.Calculators.DataOperationUtilityPanel.DataOperationUtilityPanel(parent=None)[source]

Bases: QDialog, Ui_DataOperationUtility

__doc__ = None
__init__(parent=None)[source]
__module__ = 'sas.qtgui.Calculators.DataOperationUtilityPanel'
_extractData(key_id)[source]

Extract data from file with id contained in list of filenames

_findId(name)[source]

find id of name in list of filenames

newPlot(graph, layout)[source]

Create template for graphs with default ‘?’ layout

onCheckChosenData()[source]

check that data1 and data2 are compatible

onCheckOutputName()[source]

Check that name of output does not already exist

onClose()[source]

Close dialog

onCompute()[source]

perform calculation

onHelp()[source]

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

Check input of number when a coefficient is required for operation

onPrepareOutputData()[source]

Prepare datasets to be added to DataExplorer and DataManager

onReset()[source]

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

onSelectData1()[source]

Plot for selection of Data1

onSelectData2()[source]

Plot for selection of Data2

onSelectOperator()[source]

Change GUI when operator changed

prepareSubgraphWithData(data)[source]

Create graphics view containing scene with string

updateCombobox(filenames)[source]

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

plot data in graph after clearing its layout

sas.qtgui.Calculators.DensityPanel module

class sas.qtgui.Calculators.DensityPanel.DensityPanel(parent=None)[source]

Bases: QDialog

__doc__ = None
__init__(parent=None)[source]
__module__ = 'sas.qtgui.Calculators.DensityPanel'
_updateDensity()[source]
_updateVolume()[source]
dataChanged(top, bottom)[source]
displayHelp()[source]
formulaChanged(current_text)[source]
massChanged(current_text)[source]
modelReset()[source]
setMode(mode)[source]
setupMapper()[source]
setupModel()[source]
setupUi()[source]
volumeChanged(current_text)[source]
sas.qtgui.Calculators.DensityPanel.toMolarMass(formula)[source]

sas.qtgui.Calculators.GenericScatteringCalculator module

class sas.qtgui.Calculators.GenericScatteringCalculator.GenericScatteringCalculator(parent=None)[source]

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);'
__doc__ = None
__init__(parent=None)[source]
__module__ = 'sas.qtgui.Calculators.GenericScatteringCalculator'
_create_default_1d_data()[source]

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

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

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

Copied from previous version

Warning

deprecated

_update(time=None, percentage=None)[source]

Copied from previous version

calculateComplete(d)[source]

Notify the main thread

calculateFailed(reason)[source]
calculationFinishedSignal
change_data_type()[source]

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

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.

check_for_magnetic_controls()[source]
check_units()[source]

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

complete(input, update=None)[source]

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

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

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

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

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

Catches the event that a textbox has been enabled/disabled

file_name()[source]

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

Returns:

the filename

Return type:

str

gui_text_changed(sender)[source]

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

Catches the signal that a textbox has beeen altered

loadFile()[source]

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

Legacy function used in GenRead

loadingFinishedSignal
onCancel()[source]

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

onCompute()[source]

Execute the computation of I(qx, qy)

Copied from previous version

onHelp()[source]

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

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

Save data as .sld file

plot3d(has_arrow=False)[source]

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

Generate 1D or 2D plot, called in Compute

reset_camera()[source]
selectedshapechange()[source]

TODO Temporary solution to display information about option ‘Ellipsoid’

set_polarisation_visible(visible)[source]

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

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().

toggle_error_functionality()[source]

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

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

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

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

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

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(parent=None, graph_title='')[source]

Bases: QDialog, Plotter3DWidget

__doc__ = None
__init__(parent=None, graph_title='')[source]
__module__ = 'sas.qtgui.Calculators.GenericScatteringCalculator'
class sas.qtgui.Calculators.GenericScatteringCalculator.Plotter3DWidget(parent=None, manager=None)[source]

Bases: PlotterBase

3D Plot widget for use with a QDialog

__doc__ = '\n    3D Plot widget for use with a QDialog\n    '
__init__(parent=None, manager=None)[source]
__module__ = 'sas.qtgui.Calculators.GenericScatteringCalculator'
closeEvent(event)[source]

Overwrite the close event adding helper notification

createContextMenu()[source]

Define common context menu and associated actions for the MPL widget

createContextMenuQuick()[source]

Define context menu and associated actions for the quickplot MPL widget

property data

data getter

plot(data=None, has_arrow=False)[source]

Plot 3D self._data

showPlot(data, has_arrow=False)[source]

Render and show the current data

sas.qtgui.Calculators.KiessigPanel module

class sas.qtgui.Calculators.KiessigPanel.KiessigPanel(parent=None)[source]

Bases: QDialog, Ui_KiessigPanel

__doc__ = None
__init__(parent=None)[source]
__module__ = 'sas.qtgui.Calculators.KiessigPanel'
onClose()[source]

close the window containing this panel

onCompute()[source]

Execute the computation of thickness

onHelp()[source]

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/ ….”.

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

Bases: QDialog, Ui_ResolutionCalculatorPanel

compute resolution in 2D

__doc__ = '\n    compute resolution in 2D\n    '
__init__(parent=None)[source]
__module__ = 'sas.qtgui.Calculators.ResolutionCalculatorPanel'
_str2longlist(input_string)[source]

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

_string2inputlist(input_string)[source]

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

_string2list(input_string)[source]

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

_validate_q_input(qx, qy)[source]

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

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

calculateFailed(reason)[source]
checkAperture()[source]

Validator for Sample and Source apertures

checkPixels()[source]

Validator for detector pixel size and number

checkQx_y()[source]

Validator for qx and qy inputs

checkWavelength()[source]

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

checkWavelengthSpread()[source]

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

complete(image)[source]

Complete computation

createTemplate2DPlot()[source]

Create a template for 2D data

drawLines()[source]

Draw lines in image if applicable

formatNumber(value=None)[source]

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

map_wrapper(func, qx, qy, qx_min, qx_max, qy_min, qy_max)[source]

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

new2DPlot()[source]

Create a new 2D data instance based on computing results

onCompute()[source]

Execute the computation of resolution

onHelp()[source]

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

On Spectrum Combobox event

onSelectWaveColor()[source]

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

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

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)[source]
__module__ = 'sas.qtgui.Calculators.SldPanel'
__weakref__

list of weak references to the object (if defined)

class sas.qtgui.Calculators.SldPanel.SldPanel(parent=None)[source]

Bases: QDialog

__doc__ = None
__init__(parent=None)[source]
__module__ = 'sas.qtgui.Calculators.SldPanel'
_getOutputs()[source]
calculateSLD()[source]
closePanel()[source]

close the window containing this panel

dataChanged(top, bottom)[source]
displayHelp()[source]
modelReset()[source]
recalculateSLD()[source]
setupMapper()[source]
setupModel()[source]
setupUi()[source]
class sas.qtgui.Calculators.SldPanel.XraySldResult(xray_wavelength, xray_sld_real, xray_sld_imag)[source]

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)[source]
__module__ = 'sas.qtgui.Calculators.SldPanel'
__weakref__

list of weak references to the object (if defined)

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

sas.qtgui.Calculators.SlitSizeCalculator module

Slit Size Calculator Panel

class sas.qtgui.Calculators.SlitSizeCalculator.SlitSizeCalculator(parent=None)[source]

Bases: QDialog, Ui_SlitSizeCalculator

Provides the slit length calculator GUI.

__doc__ = '\n    Provides the slit length calculator GUI.\n    '
__init__(parent=None)[source]
__module__ = 'sas.qtgui.Calculators.SlitSizeCalculator'
calculateSlitSize(data=None)[source]

Computes slit lenght from given 1D data

chooseFile()[source]

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

clearResults()[source]

Clear the content of output LineEdits

onBrowse()[source]

Browse the file and calculate slit lenght upon loading

onClose()[source]

close the window containing this panel

onHelp()[source]

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/ ….”.

Module contents