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]

__doc__ = '\n        Descriptor for a cylinder\n        Orientation: Default cylinder is along Y\n\n        Parameters:\n            - Length [default = 40 A]\n            - Radius [default = 10 A]\n            - Contrast [default = 1 A-2]\n    '
__init__()

Initialization

__module__ = 'sas.sascalc.realspace.VolumeCanvas'
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]

__annotations__ = {}
__doc__ = '\n        Descriptor for an ellipsoid\n\n        Parameters:\n            - Radius_x along the x-axis [default = 30 A]\n            - Radius_y along the y-axis [default = 20 A]\n            - Radius_z along the z-axis [default = 10 A]\n            - contrast [default = 1 A-2]\n    '
__init__()

Initialization

__module__ = 'sas.sascalc.realspace.VolumeCanvas'
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]

__annotations__ = {}
__doc__ = '\n        Descriptor for an helix\n\n        Parameters:\n            -radius_helix: the radius of the helix [default = 10 A]\n            -radius_tube: radius of the "tube" that forms the helix [default = 3 A]\n            -pitch: distance between two consecutive turns of the helix [default = 34 A]\n            -turns: number of turns of the helix [default = 3]\n            -contrast: contrast parameter [default = 1 A-2]\n    '
__init__()

Initialization

__module__ = 'sas.sascalc.realspace.VolumeCanvas'
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

__annotations__ = {}
__doc__ = '\n        Descriptor for a PDB set of points\n\n        Parameter:\n            - file = name of the PDB file\n    '
__init__(filename)

Initialization @param filename: name of the PDB file to load

__module__ = 'sas.sascalc.realspace.VolumeCanvas'
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).

__annotations__ = {}
__dict__ = mappingproxy({'__module__': 'sas.sascalc.realspace.VolumeCanvas', '__doc__': '\n        Class to hold the information about a shape\n        The descriptor holds a dictionary of parameters.\n\n        Note: if shape parameters are accessed directly\n        from outside VolumeCanvas. The getPr method\n        should be called before evaluating I(q).\n\n    ', '__init__': <function ShapeDescriptor.__init__>, 'create': <function ShapeDescriptor.create>, '__dict__': <attribute '__dict__' of 'ShapeDescriptor' objects>, '__weakref__': <attribute '__weakref__' of 'ShapeDescriptor' objects>, '__annotations__': {}})
__doc__ = '\n        Class to hold the information about a shape\n        The descriptor holds a dictionary of parameters.\n\n        Note: if shape parameters are accessed directly\n        from outside VolumeCanvas. The getPr method\n        should be called before evaluating I(q).\n\n    '
__init__()

Initialization

__module__ = 'sas.sascalc.realspace.VolumeCanvas'
__weakref__

list of weak references to the object

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]

__annotations__ = {}
__doc__ = '\n        Descriptor for a sphere\n\n        The parameters are:\n            - radius [Angstroem] [default = 20 A]\n            - Contrast [A-2] [default = 1 A-2]\n\n    '
__init__()

Initialization

__module__ = 'sas.sascalc.realspace.VolumeCanvas'
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().

__annotations__ = {}
__doc__ = '\n        Class representing an empty space volume to add\n        geometrical object to.\n\n        For 1D I(q) simulation, getPr() is called internally for the\n        first call to getIq().\n\n    '
__init__()

Initialization

__module__ = 'sas.sascalc.realspace.VolumeCanvas'
_addSingleShape(shapeDesc)

create shapeobject based on shapeDesc @param shapeDesc: shape description

_createVolumeFromList()

Create a new lores model with all the shapes in our internal list Whenever we change a parameter of a shape, we have to re-create the whole thing.

Items with higher ‘order’ number take precedence for regions of space that are shared with other objects. Points in the overlapping region belonging to objects with lower ‘order’ will be ignored.

Items are added in decreasing ‘order’ number. The item with the highest ‘order’ will be added first. [That conventions is prescribed by the realSpaceModeling module]

_create_modelObject()

Create the simulation model obejct from the list of shapes.

This method needs to be called each time a parameter changes because of the way the underlying library was (badly) written. It is impossible to change a parameter, or remove a shape without having to refill the space points.

TODO: improve that.

_model_changed()

Reset internal data members to reflect the fact that the real-space model has changed

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