# sas.sascalc.realspace package

## Submodules

## sas.sascalc.realspace.VolumeCanvas module

Volume Canvas

Simulation canvas for real-space simulation of SAS scattering intensity. The user can create an arrangement of basic shapes and estimate I(q) and I(q_x, q_y). Error estimates on the simulation are also available.

Example:

import sas.sascalc.realspace.VolumeCanvas as VolumeCanvas canvas = VolumeCanvas.VolumeCanvas() canvas.setParam(‘lores_density’, 0.01)

sphere = SphereDescriptor() handle = canvas.addObject(sphere)

output, error = canvas.getIqError(q=0.1) output, error = canvas.getIq2DError(0.1, 0.1)

or alternatively: iq = canvas.run(0.1) i2_2D = canvas.run([0.1, 1.57])

class sas.sascalc.realspace.VolumeCanvas.CylinderDescriptor

  Bases: `ShapeDescriptor`

  Descriptor for a cylinder Orientation: Default cylinder is along Y

  Parameters:

    - Length [default = 40 A]

    - Radius [default = 10 A]

    - Contrast [default = 1 A-2]

  create()

    Create an instance of the shape @return: instance of the shape

class sas.sascalc.realspace.VolumeCanvas.EllipsoidDescriptor

  Bases: `ShapeDescriptor`

  Descriptor for an ellipsoid

  Parameters:

    - Radius_x along the x-axis [default = 30 A]

    - Radius_y along the y-axis [default = 20 A]

    - Radius_z along the z-axis [default = 10 A]

    - contrast [default = 1 A-2]

  create()

    Create an instance of the shape @return: instance of the shape

class sas.sascalc.realspace.VolumeCanvas.HelixDescriptor

  Bases: `ShapeDescriptor`

  Descriptor for an helix

  Parameters:

    -radius_helix: the radius of the helix [default = 10 A] -radius_tube: radius of the “tube” that forms the helix [default = 3 A] -pitch: distance between two consecutive turns of the helix [default = 34 A] -turns: number of turns of the helix [default = 3] -contrast: contrast parameter [default = 1 A-2]

  create()

    Create an instance of the shape @return: instance of the shape

class sas.sascalc.realspace.VolumeCanvas.PDBDescriptor(filename)

  Bases: `ShapeDescriptor`

  Descriptor for a PDB set of points

  Parameter:

    - file = name of the PDB file

  create()

    Create an instance of the shape @return: instance of the shape

class sas.sascalc.realspace.VolumeCanvas.ShapeDescriptor

  Bases: `object`

  Class to hold the information about a shape The descriptor holds a dictionary of parameters.

  Note: if shape parameters are accessed directly from outside VolumeCanvas. The getPr method should be called before evaluating I(q).

  create()

    Create an instance of the shape

class sas.sascalc.realspace.VolumeCanvas.SphereDescriptor

  Bases: `ShapeDescriptor`

  Descriptor for a sphere

  The parameters are:

    - radius [Angstroem] [default = 20 A]

    - Contrast [A-2] [default = 1 A-2]

  create()

    Create an instance of the shape @return: instance of the shape

class sas.sascalc.realspace.VolumeCanvas.VolumeCanvas

  Bases: `BaseComponent`

  Class representing an empty space volume to add geometrical object to.

  For 1D I(q) simulation, getPr() is called internally for the first call to getIq().

  add(shape, id=None)

    The intend of this method is to eventually be able to use it as a factory for the canvas and unify the simulation with the analytical solutions. For instance, if one adds a cylinder and it is the only shape on the canvas, the analytical solution could be called. If multiple shapes are involved, then simulation has to be performed.

    This function is deprecated, use addObject().

    @param shape: name of the object to add to the canvas [string] @param id: string handle for the object [string] [optional] @return: string handle for the object

  addObject(shapeDesc, id=None)

    Adds a real-space object to the canvas.

    @param shapeDesc: object to add to the canvas [ShapeDescriptor] @param id: string handle for the object [string] [optional] @return: string handle for the object

  delete(id)

    Delete a shape. The ID for the shape is required. @param id: string handle for the object [string] [optional]

  getError(q)

    Returns the error of I(q) for a given q-value @param q: q-value [float] @return: I(q) [float]

  getIq(q)

    Returns the value of I(q) for a given q-value

    This method should remain internal to the class and the run() method should be used instead.

    @param q: q-value [float] @return: I(q) [float]

  getIq2D(qx, qy)

    Returns simulate I(q) for given q_x and q_y values. @param qx: q_x [A-1] @param qy: q_y [A-1] @return: I(q) [cm-1]

  getIq2DError(qx, qy)

    Return the simulated value along with its estimated error for a given q-value

    Propagation of errors is used to evaluate the uncertainty.

    @param qx: qx-value [float] @param qy: qy-value [float] @return: mean, error [float, float]

  getIqError(q)

    Return the simulated value along with its estimated error for a given q-value

    Propagation of errors is used to evaluate the uncertainty.

    @param q: q-value [float] @return: mean, error [float, float]

  getParam(name)

    @param name: name of the parameter to change

  getParamList(shapeid=None)
    …. return a full list of all available parameters from

      self.params.keys(). If a key in self.params is a instance of ShapeDescriptor, extend the return list to:

      [param1,param2,shapeid.param1,shapeid.param2…….]

      If shapeid is provided, return the list of parameters that belongs to that shape id only : [shapeid.param1, shapeid.param2…]

  getPr()

    Calculate P(r) from the objects on the canvas. This method should always be called after the shapes on the VolumeCanvas have changed.

    @return: calculation output flag

  getPrData()

    Write P(r) to an output file @param filename: file name for P(r) output

  getShapeList()

    Return a list of the shapes

  run(q=0)

    Returns the value of I(q) for a given q-value @param q: q-value ([float] or [list]) ([A-1] or [[A-1], [rad]]) @return: I(q) [float] [cm-1]

  runXY(q=0)

    Standard run command for the canvas. Redirects to the correct method according to the input type. @param q: q-value [float] or [list] [A-1] @return: I(q) [float] [cm-1]

  setParam(name, value)

    Function to set the value of a parameter. Both VolumeCanvas parameters and shape parameters are accessible.

    Note: if shape parameters are accessed directly from outside VolumeCanvas. The getPr method should be called before evaluating I(q).

    TODO: implemented a check method to protect against that.

    @param name: name of the parameter to change @param value: value to give the parameter

  write_pr(filename)

    Write P(r) to an output file @param filename: file name for P(r) output

## Module contents

Real-Space Modeling for SAS