sas.qtgui.Calculators package¶
Subpackages¶
- sas.qtgui.Calculators.UI package
- Submodules
- sas.qtgui.Calculators.UI.DataOperationUtilityUI module
- sas.qtgui.Calculators.UI.DensityPanel module
- sas.qtgui.Calculators.UI.GenericScatteringCalculator module
- sas.qtgui.Calculators.UI.KiessigPanel module
- sas.qtgui.Calculators.UI.ResolutionCalculatorPanelUI module
- sas.qtgui.Calculators.UI.SldPanel module
- sas.qtgui.Calculators.UI.SlitSizeCalculator module
- Module contents
Submodules¶
sas.qtgui.Calculators.DataOperationUtilityPanel module¶
- class sas.qtgui.Calculators.DataOperationUtilityPanel.DataOperationUtilityPanel(parent=None)[source]¶
Bases:
QDialog
,Ui_DataOperationUtility
- __doc__ = None¶
- __module__ = 'sas.qtgui.Calculators.DataOperationUtilityPanel'¶
- 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/ ….”.
- onReset()[source]¶
Reset Panel to its initial state (default values) keeping the names of loaded data
sas.qtgui.Calculators.DensityPanel module¶
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¶
- __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
- 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_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:
- 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
- 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
- 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.
- loadingFinishedSignal¶
- 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.
- 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
- 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_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¶
- __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 '¶
- __module__ = 'sas.qtgui.Calculators.GenericScatteringCalculator'¶
- createContextMenuQuick()[source]¶
Define context menu and associated actions for the quickplot MPL widget
- property data¶
data getter
sas.qtgui.Calculators.KiessigPanel module¶
- class sas.qtgui.Calculators.KiessigPanel.KiessigPanel(parent=None)[source]¶
Bases:
QDialog
,Ui_KiessigPanel
- __doc__ = None¶
- __module__ = 'sas.qtgui.Calculators.KiessigPanel'¶
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 '¶
- __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
- _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)
- 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)’
- 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)
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¶
- __module__ = 'sas.qtgui.Calculators.SldPanel'¶
- 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¶
- __module__ = 'sas.qtgui.Calculators.SldPanel'¶
- __weakref__¶
list of weak references to the object (if defined)
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 '¶
- __module__ = 'sas.qtgui.Calculators.SlitSizeCalculator'¶