# sas.qtgui.Perspectives.ParticleEditor package

## Subpackages

- sas.qtgui.Perspectives.ParticleEditor.ParameterFunctionality package
  - Submodules
  - sas.qtgui.Perspectives.ParticleEditor.ParameterFunctionality.ParameterEntries module
    - `MagneticParameterEntry`
      - `MagneticParameterEntry.staticMetaObject`
    - `ParameterEntry`
      - `ParameterEntry.staticMetaObject`
  - sas.qtgui.Perspectives.ParticleEditor.ParameterFunctionality.ParameterTable module
    - `ParameterTable`
      - `ParameterTable.build()`
      - `ParameterTable.clean()`
      - `ParameterTable.clear()`
      - `ParameterTable.rebuild()`
      - `ParameterTable.staticMetaObject`
      - `ParameterTable.update_contents()`
    - `main()`
  - sas.qtgui.Perspectives.ParticleEditor.ParameterFunctionality.ParameterTableButtons module
    - `ParameterTableButtons`
      - `ParameterTableButtons.staticMetaObject`
  - sas.qtgui.Perspectives.ParticleEditor.ParameterFunctionality.ParameterTableModel module
    - `LinkingImpossible`
    - `ParameterTableModel`
      - `ParameterTableModel.calculation_parameters()`
      - `ParameterTableModel.can_link()`
      - `ParameterTableModel.clean()`
      - `ParameterTableModel.magnetism_parameters`
      - `ParameterTableModel.set_link_status()`
      - `ParameterTableModel.sld_parameters`
      - `ParameterTableModel.update_from_code()`
    - `main()`
  - Module contents
- sas.qtgui.Perspectives.ParticleEditor.datamodel package
  - Submodules
  - sas.qtgui.Perspectives.ParticleEditor.datamodel.calculation module
    - `AngularDistribution`
      - `AngularDistribution.n_points`
      - `AngularDistribution.name()`
      - `AngularDistribution.parameters()`
      - `AngularDistribution.sample_points_and_weights()`
    - `MagnetismDefinition`
      - `MagnetismDefinition.magnetism_function`
      - `MagnetismDefinition.to_cartesian_conversion`
    - `ParticleDefinition`
      - `ParticleDefinition.magnetism`
      - `ParticleDefinition.sld`
    - `QSample`
    - `QSpaceScattering`
      - `QSpaceScattering.abscissa`
      - `QSpaceScattering.lower_error`
      - `QSpaceScattering.ordinate`
      - `QSpaceScattering.upper_error`
    - `RealSpaceScattering`
      - `RealSpaceScattering.abscissa`
      - `RealSpaceScattering.ordinate`
    - `SLDDefinition`
      - `SLDDefinition.sld_function`
      - `SLDDefinition.to_cartesian_conversion`
    - `SamplingDistribution`
      - `SamplingDistribution.bin_edges`
      - `SamplingDistribution.counts`
      - `SamplingDistribution.name`
    - `ScatteringCalculation`
      - `ScatteringCalculation.angular_sampling`
      - `ScatteringCalculation.bin_count`
      - `ScatteringCalculation.bounding_surface_sld_check`
      - `ScatteringCalculation.parameter_settings`
      - `ScatteringCalculation.particle_definition`
      - `ScatteringCalculation.polarisation_vector`
      - `ScatteringCalculation.q_sampling`
      - `ScatteringCalculation.sample_chunk_size_hint`
      - `ScatteringCalculation.seed`
      - `ScatteringCalculation.spatial_sampling_method`
    - `ScatteringOutput`
      - `ScatteringOutput.calculation_time`
      - `ScatteringOutput.q_space`
      - `ScatteringOutput.seed_used`
    - `SpatialDistribution`
      - `SpatialDistribution.allows_bootstrap`
      - `SpatialDistribution.bounding_surface_check_points()`
      - `SpatialDistribution.generate()`
      - `SpatialDistribution.info`
  - sas.qtgui.Perspectives.ParticleEditor.datamodel.parameters module
    - `Background`
    - `CalculationParameters`
      - `CalculationParameters.background`
      - `CalculationParameters.magnetism_parameters`
      - `CalculationParameters.scale`
      - `CalculationParameters.sld_parameters`
      - `CalculationParameters.solvent_sld`
    - `FunctionParameter`
      - `FunctionParameter.in_use`
      - `FunctionParameter.is_function_parameter`
    - `MagnetismParameterContainer`
      - `MagnetismParameterContainer.linked`
      - `MagnetismParameterContainer.parameter`
    - `Parameter`
      - `Parameter.in_use`
      - `Parameter.is_function_parameter`
    - `Scale`
    - `SolventSLD`
    - `ValueSource`
      - `ValueSource.CODE`
      - `ValueSource.DEFAULT`
      - `ValueSource.FIT`
      - `ValueSource.MANUAL`
  - sas.qtgui.Perspectives.ParticleEditor.datamodel.types module
    - `CoordinateSystemTransform`
    - `MagnetismFunction`
    - `SLDFunction`
  - Module contents
- sas.qtgui.Perspectives.ParticleEditor.sampling package
  - Submodules
  - sas.qtgui.Perspectives.ParticleEditor.sampling.angles module
    - `Uniform`
      - `Uniform.n_points`
      - `Uniform.name()`
      - `Uniform.parameters()`
      - `Uniform.sample_points_and_weights()`
    - `ZDelta`
      - `ZDelta.n_points`
      - `ZDelta.name()`
      - `ZDelta.parameters()`
      - `ZDelta.sample_points_and_weights()`
  - sas.qtgui.Perspectives.ParticleEditor.sampling.chunking module
    - `Chunker`
    - `Chunks`
    - `InputLengthMismatch`
    - `SingleChunk`
    - `pairwise_chunk_iterator()`
    - `sublist_lengths()`
  - sas.qtgui.Perspectives.ParticleEditor.sampling.geodesic module
    - `Geodesic`
      - `Geodesic.by_divisions()`
      - `Geodesic.by_point_count()`
      - `Geodesic.minimal_divisions_for_points()`
      - `Geodesic.points_for_division_amount()`
    - `GeodesicDivisions`
  - sas.qtgui.Perspectives.ParticleEditor.sampling.points module
    - `BoundedByCube`
    - `Grid`
      - `Grid.generate()`
      - `Grid.info`
    - `PointGeneratorStepper`
    - `RandomCube`
      - `RandomCube.allows_bootstrap()`
      - `RandomCube.generate()`
  - Module contents

## Submodules

## sas.qtgui.Perspectives.ParticleEditor.AngularSamplingMethodSelector module

class sas.qtgui.Perspectives.ParticleEditor.AngularSamplingMethodSelector.AngularSamplingMethodSelector(parent=None)

  Bases: `QWidget`

  Selects the method for doing angular sampling, and provides access to the parameters

  generate_sampler() → AngularDistribution

    Create the angular distribution sampler spectified by the current settings

  on_update()
  staticMetaObject = PySide6.QtCore.QMetaObject("AngularSamplingMethodSelector" inherits "QWidget": )

class sas.qtgui.Perspectives.ParticleEditor.AngularSamplingMethodSelector.ParametersForm(sampling_class: type, parent=None)

  Bases: `QWidget`

  Form that displays the parameters associated with the class (also responsible for generating the sampler)

  generate_sampler() → AngularDistribution

    Generate a sampler based on the selected parameters

  staticMetaObject = PySide6.QtCore.QMetaObject("ParametersForm" inherits "QWidget": )

sas.qtgui.Perspectives.ParticleEditor.AngularSamplingMethodSelector.main()

  Show a demo

## sas.qtgui.Perspectives.ParticleEditor.CodeToolBar module

class sas.qtgui.Perspectives.ParticleEditor.CodeToolBar.CodeToolBar(parent=None)

  Bases: `QWidget`, `Ui_CodeToolBar`

  staticMetaObject = PySide6.QtCore.QMetaObject("CodeToolBar" inherits "QWidget": )

## sas.qtgui.Perspectives.ParticleEditor.DesignWindow module

class sas.qtgui.Perspectives.ParticleEditor.DesignWindow.DesignWindow(parent=None)

  Bases: `QDialog`, `Ui_DesignWindow`

  Main window for the particle editor

  angularDistribution() → AngularDistribution

    Get the AngularDistribution object that represents the GUI selected orientational distribution

  codeError(text)

    Show an error concerning input code

  codeText(text)

    Show info about input code / code stdout

  codeWarning(text)

    Show a warning about input code

  currentSeed()
  display_calculation_result(scattering_result: ScatteringOutput)

    Update graphs and select tab

  doBuild()

    Build functionality requested

  doScatter()

    Scatter functionality requested

  magnetismDefinition() → MagnetismDefinition | None
  onFit()

    Fit functionality requested

  onLoad()
  onRadiusChanged()
  onSave()
  onTimeEstimateParametersChanged()

    Called when the number of samples changes

  parametersForCalculation() → CalculationParameters
  particleDefinition() → ParticleDefinition

    Get the ParticleDefinition object that contains the SLD and magnetism functions

  polarisationVector() → ndarray

    Get a numpy vector representing the GUI specified polarisation vector

  qSampling() → QSample

    Calculate the q sampling object based on current gui settings

  scatteringCalculation() → ScatteringCalculation

    Get the ScatteringCalculation object that represents the calculation that is to be passed to the solver

  sldDefinition() → SLDDefinition
  spatialSampling() → SpatialDistribution

    Calculate the spatial sampling object based on current gui settings

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

sas.qtgui.Perspectives.ParticleEditor.DesignWindow.main()

  Demo/testing window

sas.qtgui.Perspectives.ParticleEditor.DesignWindow.safe_float(text: str)

## sas.qtgui.Perspectives.ParticleEditor.FunctionViewer module

class sas.qtgui.Perspectives.ParticleEditor.FunctionViewer.FunctionViewer(parent=None)

  Bases: `QWidget`

  drawAxes(im)

    Draw a small xyz axis on an image

  drawScale(im)

    Draw a scalebar

  eventFilter(source, event)

    Event filter intercept, grabs mouse drags on the images

  onDepthChanged()

    Callback for cross section depth slider

  onDisplayTypeSelected()

    Switch between SLD and magnetism view

  onMagPhiChanged()

    Magnetic field phi angle changed

  onMagThetaChanged()

    Magnetic field theta angle changed

  onRadiusChanged()

    Draw radius changed

  setAngles(alpha_deg, beta_deg)

    Set the viewer angles

  setSLDFunction(fun, coordinate_mapping)

    Set the function to be plotted

  staticMetaObject = PySide6.QtCore.QMetaObject("FunctionViewer" inherits "QWidget": )
  updateImage(mag_only=True)

    Update the images in the viewer

sas.qtgui.Perspectives.ParticleEditor.FunctionViewer.cross_section_coordinates(radius: float, alpha: float, beta: float, plane_distance: float, n_points: int)

sas.qtgui.Perspectives.ParticleEditor.FunctionViewer.draw_line_in_place(im, x0, y0, dx, dy, channel)

  Simple line drawing (otherwise need to import something heavyweight)

sas.qtgui.Perspectives.ParticleEditor.FunctionViewer.main()

  Show a demo of the function viewer

sas.qtgui.Perspectives.ParticleEditor.FunctionViewer.rotation_matrix(alpha: float, beta: float)

## sas.qtgui.Perspectives.ParticleEditor.GeodesicSampleSelector module

class sas.qtgui.Perspectives.ParticleEditor.GeodesicSampleSelector.GeodesicSamplingSpinBox(parent: QWidget | None = None)

  Bases: `QSpinBox`

  SpinBox that only takes values that corresponds to the number of vertices on a geodesic sphere

  getNDivisions()
  onEditingFinished()
  staticMetaObject = PySide6.QtCore.QMetaObject("GeodesicSamplingSpinBox" inherits "QSpinBox": )
  stepBy(steps: int)
  updateDisplayValue()

sas.qtgui.Perspectives.ParticleEditor.GeodesicSampleSelector.main()

  Show a demo of the spinner

## sas.qtgui.Perspectives.ParticleEditor.LabelledSlider module

class sas.qtgui.Perspectives.ParticleEditor.LabelledSlider.LabelledSlider(name: str, min_value: int, max_value: int, value: int, tick_interval: int = 10, name_width=10, value_width=30, value_units='°')

  Bases: `QWidget`

  Slider with labels and value text

  staticMetaObject = PySide6.QtCore.QMetaObject("LabelledSlider" inherits "QWidget": )
  value() → int
  property valueChanged

## sas.qtgui.Perspectives.ParticleEditor.OutputViewer module

class sas.qtgui.Perspectives.ParticleEditor.OutputViewer.OutputViewer(parent=None)

  Bases: `QTextEdit`

  Python text editor window

  addError(text)
  addText(text)
  addWarning(text)
  appendAndMove(text)
  keyPressEvent(e)

    Itercepted key press event

  reset()
  staticMetaObject = PySide6.QtCore.QMetaObject("OutputViewer" inherits "QTextEdit": )

sas.qtgui.Perspectives.ParticleEditor.OutputViewer.main()

## sas.qtgui.Perspectives.ParticleEditor.PythonViewer module

class sas.qtgui.Perspectives.ParticleEditor.PythonViewer.PythonViewer(parent=None)

  Bases: `QTextEdit`

  Python text editor window

  build_trigger
  insertFromMimeData(source)

    Keep own highlighting

  keyPressEvent(e)

    Itercepted key press event

  staticMetaObject = PySide6.QtCore.QMetaObject("PythonViewer" inherits "QTextEdit": Methods: #73 type=Signal, signature=build_trigger() )

sas.qtgui.Perspectives.ParticleEditor.PythonViewer.main()

  Demo/testing window

## sas.qtgui.Perspectives.ParticleEditor.RadiusSelection module

class sas.qtgui.Perspectives.ParticleEditor.RadiusSelection.RadiusSelection(text: str | None = None, parent=None)

  Bases: `QWidget`, `Ui_RadiusSelection`

  radius()
  staticMetaObject = PySide6.QtCore.QMetaObject("RadiusSelection" inherits "QWidget": )

## sas.qtgui.Perspectives.ParticleEditor.SLDMagnetismOption module

class sas.qtgui.Perspectives.ParticleEditor.SLDMagnetismOption.SLDMagnetismOption(parent=None)

  Bases: `QWidget`, `Ui_SLDMagnetismOption`

  staticMetaObject = PySide6.QtCore.QMetaObject("SLDMagnetismOption" inherits "QWidget": )

## sas.qtgui.Perspectives.ParticleEditor.ViewerButtons module

class sas.qtgui.Perspectives.ParticleEditor.ViewerButtons.AxisButtons(set_angles_function: Callable[[float, float], None])

  Bases: `QWidget`, `Ui_AxisSelection`

  X, Y, Z axis selection buttons, sets angles

  staticMetaObject = PySide6.QtCore.QMetaObject("AxisButtons" inherits "QWidget": )

class sas.qtgui.Perspectives.ParticleEditor.ViewerButtons.PlaneButtons(set_angles_function: Callable[[float, float], None])

  Bases: `QWidget`, `Ui_PlaneSelection`

  XY, XZ, YZ plane selection buttons, sets angles

  staticMetaObject = PySide6.QtCore.QMetaObject("PlaneButtons" inherits "QWidget": )

## sas.qtgui.Perspectives.ParticleEditor.defaults module

sas.qtgui.Perspectives.ParticleEditor.defaults.default_text = '"""\n\nHere\'s a new perspective. It calculates the scattering based on real-space description of a particle.\n\nBasically, define your SLD as a function of either cartesian or polar coordinates and click scatter\n\n def sld(x,y,z)\n def sld(r,theta,phi)\n\nThe display on the right shows your particle, both as a total projected density (top) and as a slice (bottom).\n\nThis is a minimal working system. Currently magnetism doesn\'t work, neither do extra parameters for your functions,\nnor structure factors, nor fitting, nor 2D plots.\n\nHere\'s a simple example: """\n\ndef sld_cube(x,y,z):\n """ A cube with 100Ang side length"""\n\n return rect(0.02*x)*rect(0.02*y)*rect(0.02*z)\n\n\ndef sld_sphere(r, theta, phi):\n """ Sphere r=50Ang"""\n\n return rect(0.02*r)\n\nsld = sld_sphere\n\n'

  Press shift-return to build and update views Click scatter to show the scattering profile

sas.qtgui.Perspectives.ParticleEditor.defaults.sld(r, theta, phi)

## sas.qtgui.Perspectives.ParticleEditor.function_processor module

exception sas.qtgui.Perspectives.ParticleEditor.function_processor.FunctionDefinitionFailed(*args)

  Bases: `Exception`

sas.qtgui.Perspectives.ParticleEditor.function_processor.cartesian_converter(x, y, z)

  Converter from calculation coordinates to function definition

  For functions specified in cartesian coordinates

sas.qtgui.Perspectives.ParticleEditor.function_processor.default_callback(string: str)

  Just for default

sas.qtgui.Perspectives.ParticleEditor.function_processor.main()

sas.qtgui.Perspectives.ParticleEditor.function_processor.process_code(input_text: str, solvent_sld: float = 0.0, text_callback: ~collections.abc.Callable[[str], None] = <function default_callback>, warning_callback: ~collections.abc.Callable[[str], None] = <function default_callback>, error_callback: ~collections.abc.Callable[[str], None] = <function default_callback>)

  Process the code for generating functions that specify sld/magnetism

sas.qtgui.Perspectives.ParticleEditor.function_processor.spherical_converter(x, y, z)

  Converter from calculation coordinates to function definition

  For functions specified in spherical coordinates

## sas.qtgui.Perspectives.ParticleEditor.helper_functions module

Functions that get automatically included in the build window

sas.qtgui.Perspectives.ParticleEditor.helper_functions.rect(x: ndarray)

  Rectangle function, zero if mod(input) > 1, 1 otherwise

sas.qtgui.Perspectives.ParticleEditor.helper_functions.step(x: ndarray)

  Step function, 0 if input < 0, 1 if input >= 0

## sas.qtgui.Perspectives.ParticleEditor.syntax_highlight module

Modified from: art1415926535/PyQt5-syntax-highlighting on github

It’s not great, should all really be implemented as a finite state machine with a stack

class sas.qtgui.Perspectives.ParticleEditor.syntax_highlight.PythonHighlighter(document)

  Bases: `QSyntaxHighlighter`

  Syntax highlighter for the Python language.

  braces = ['\\{', '\\}', '\\(', '\\)', '\\[', '\\]']
  highlightBlock(text)

    Apply syntax highlighting to the given block of text.

  keywords = ['and', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'exec', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'not', 'or', 'pass', 'print', 'raise', 'return', 'try', 'while', 'yield', 'None', 'True', 'False']
  operators = ['=', '==', '!=', '<', '<=', '>', '>=', '\\+', '-', '\\*', '/', '//', '\\%', '\\*\\*', '\\+=', '-=', '\\*=', '/=', '\\%=', '\\^', '\\|', '\\&', '\\~', '>>', '<<']
  special = ['sld', 'solvent_sld', 'magnetism']
  staticMetaObject = PySide6.QtCore.QMetaObject("PythonHighlighter" inherits "QSyntaxHighlighter": )

sas.qtgui.Perspectives.ParticleEditor.syntax_highlight.format(color, style='')

  Return a QTextCharFormat with the given attributes.

## sas.qtgui.Perspectives.ParticleEditor.util module

sas.qtgui.Perspectives.ParticleEditor.util.format_time_estimate(est_time_seconds)

  Get easily understandable string for a computational time estimate

## sas.qtgui.Perspectives.ParticleEditor.vectorise module

sas.qtgui.Perspectives.ParticleEditor.vectorise.clean_traceback(trace: str)

  Tracebacks from vectorise contain potentially confusing information from the vectorisation infrastructure. Clean it up and replace empty filename with something else

sas.qtgui.Perspectives.ParticleEditor.vectorise.main()

sas.qtgui.Perspectives.ParticleEditor.vectorise.vectorise_magnetism(fun: Callable, warning_callback: Callable[[str], None], *args, **kwargs)

  Check whether a magnetism function can handle numpy arrays properly, if not, create a wrapper that that can

sas.qtgui.Perspectives.ParticleEditor.vectorise.vectorise_sld(fun: Callable, warning_callback: Callable[[str], None], error_callback: Callable[[str], None], *args, **kwargs)

  Check whether an SLD function can handle numpy arrays properly, if not, create a wrapper that that can

## Module contents