|
| ||||||||||
Class PAThis is a Python class for reading/writing/modifying SIMION potential arrays. |
||||||||||
| Method Summary | |
|---|---|
Checks whether the given combination of attributes is valid. | |
Checks whether the given field type is valid. | |
Checks whether the given max voltage values is valid. | |
Check whether the given mirroring string is valid. | |
Checks whether the given mode is valid. | |
Checks whether the given ng magnetic scaling factor is valid. | |
Checks whether the given grid dimension in the x direction is valid. | |
Checks whether the given grid dimension in the y direction is valid. | |
Checks whether the given grid dimension in the z direction is valid. | |
Checks whether the given set of grid dimensions in the x, y, and z directions is valid as a whole. | |
Checks whether the given symmetry is valid. | |
Get last error message generated by one of the check calls. | |
Gets or sets the PA# associated with this PA0 (if any). | |
| Construction and Serialization | |
Constructor. | |
Returns a string containing PATXT-formatted header for the current array. | |
Loads a potential array from a file. | |
Saves potential array to file. | |
| Attribute Getters/Setters | |
Gets or sets the field type as a string. | |
Gets or sets whether the array is fast adjustable. | |
Gets or sets the max voltage value. | |
Gets or sets the full mirroring information. | |
Gets or sets a Boolean indicating whether the mirroring is enabled in the x direction. | |
Gets or sets a Boolean indicating whether the mirroring is enabled in the y direction. | |
Gets or sets a Boolean indicating whether the mirroring is enabled in the z direction. | |
Gets or sets the mode number. | |
Gets or sets the ng magnetic scaling factor. | |
Gets the number of grid points. | |
Gets the number of voxels (2D or 3D pixels). | |
Gets or sets the number of grid points in the x direction. | |
Gets or sets the number of grid points in the y direction. | |
Gets or sets the number of grid points in the z direction. | |
Sets multiple attributes at once. | |
Gets or sets the size for the array in grid points. | |
Gets or sets the symmetry. | |
| Boundary and Coordinates | |
Returns a Boolean indicating whether the given integer point is located within the array. | |
Returns a Boolean indicating whether the given real (i.e. | |
Returns a Boolean indicating whether the given integer voxel is located within the array. | |
| Point Setters/Getters | |
clear_points(self)
| |
Gets or sets the Boolean electrode state at the given integer point. | |
Gets or sets the field (potential gradient) vector at the given point. | |
Gets the electrostatic or magnetic field vector (ex, ey, ez) at the given real point, taking symmetry and mirroring into account. | |
Gets or sets the Boolean electrode state and the potential at the given integer point. | |
Gets or sets the potential at the given integer point. | |
Get the potential at the given real point, taking symmetry and mirroring into account. | |
Gets or sets the solid electrode state for the given integer voxel. | |
Gets or sets the raw value at the given integer point. | |
| Method Details |
|---|
__init__(self,
mode=None,
symmetry=None,
max_voltage=None,
nx=None,
ny=None,
nz=None,
mirror=None,
mirror_x=None,
mirror_y=None,
mirror_z=None,
field_type=None,
ng=None,
fast_adjustable=None,
enable_points=None,
file=None)
|
header_string(self)Returns a string containing PATXT-formatted header for the current array. For example, for SIMION's QUAD.PA# file, the result is as such:
begin_header
mode -1
symmetry planar
max_voltage 20000
nx 77
ny 39
nz 1
mirror_x 0
mirror_y 1
mirror_z 0
field_type electrostatic
ng 100
fast_adjustable 1
end_header
This method is also very useful for debugging to quickly display the
information on a given potential array.
|
load(self, filepath)Loads a potential array from a file. Note: Arrays can also be loaded in the new method. Example:
>>> pa.load('myfile.pa#')
|
save(self, filepath)Saves potential array to file.
>>> pa.save('myfile.pa#')
|
field_type(self, field_type=None)Gets or sets the field type as a string. This is either "electrostatic" or "magnetic".
>>> pa.field_type('magnetic')
>>> print pa.field_type()
|
fast_adjustable(self, fast_adjustable=None)Gets or sets whether the array is fast adjustable.
>>> pa.fast_adjustable(1)
>>> print pa.fast_adjustable()
|
max_voltage(self, max_voltage=None)Gets or sets the max voltage value.
>>> pa.max_voltage(100000)
>>> print pa.max_voltage()
|
mirror(self, mirror=None)Gets or sets the full mirroring information.
>>> pa.mirror('yz')
>>> print pa.mirror()
The above is equivalent to
>>> pa.set(mirror_y = 1, mirror_z = 1)
|
mirror_x(self, mirror_x=None)Gets or sets a Boolean indicating whether the mirroring is enabled in the x direction.
>>> pa.mirror_x(1)
>>> print pa.mirror_x()
|
mirror_y(self, mirror_y=None)Gets or sets a Boolean indicating whether the mirroring is enabled in the y direction.
>>> pa.mirror_y(1)
>>> print pa.mirror_y()
|
mirror_z(self, mirror_z=None)Gets or sets a Boolean indicating whether the mirroring is enabled in the z direction.
>>> pa.mirror_z(1)
>>> print pa.mirror_z()
|
mode(self, mode=None)Gets or sets the mode number. Currently, this is always -1.
>>> pa.mode(-1)
>>> print pa.mode()
|
ng(self, ng=None)Gets or sets the ng magnetic scaling factor.
>>> pa.ng(100)
>>> print pa.ng()
|
num_points(self)Gets the number of grid points. This is nx() * ny() * nz().
>>> pa = PA(nx = 3, ny = 4)
>>> print pa.num_points() # prints 12
|
num_voxels(self)Gets the number of voxels (2D or 3D pixels). Each voxel is surrounded by four (2D arrays) or eight (3D arrays) grid points. For 2D arrays, this is (nx()-1) * (ny()-1). For 3D arrays, this is (nx()-1) * (ny()-1) * (nz()-1).
>>> pa = PA(nx = 3, ny = 4)
>>> print pa.num_voxels() # prints 6
|
nx(self, nx=None)Gets or sets the number of grid points in the x direction. Point data is cleared on resizing.
>>> pa.nx(100)
>>> print pa.nx()
|
ny(self, ny=None)Gets or sets the number of grid points in the y direction. Point data is cleared on resizing.
>>> pa.ny(100)
>>> print pa.ny()
|
nz(self, nz=None)Gets or sets the number of grid points in the z direction. Point data is cleared on resizing.
>>> pa.nz(100)
>>> print pa.nz()
|
set(self, mode=None, symmetry=None, max_voltage=None, nx=None, ny=None, nz=None, mirror=None, mirror_x=None, mirror_y=None, mirror_z=None, field_type=None, ng=None, fast_adjustable=None, enable_points=None, file=None)Sets multiple attributes at once. This can take the same set of parameters as the new() method. This method is useful when the attributes are interdependent. Asserts on error.
>>> pa.set(nz = 1, symmetry = 'cylindrical')
See the individual setter methods for details on each parameter.
|
size(self, nx=None, ny=None, nz=None)Gets or sets the size for the array in grid points. Point data is cleared on resizing.
>>> pa.size(10, 20, 30)
>>> (nx, ny, nz) = pa.size()
|
symmetry(self, symmetry=None)Gets or sets the symmetry.
>>> pa.symmetry('cylindrical')
>>> print pa.symmetry()
|
inside(self, x, y, z)Returns a Boolean indicating whether the given integer point is located within the array.
>>> if pa.inside(10, 20, 30): print 'inside'
|
inside_real(self, x, y, z)Returns a Boolean indicating whether the given real (i.e. floating-point) point is located within the array, taking symmetry and mirroring into account. Note that inside($x, $y, $z) implies inside_real($x, $y, $z), although the converse is not necessarily true.
>>> if pa.inside(-10.1, 20.2, 30.3): print 'inside'
|
voxel_inside(self, x, y, z)Returns a Boolean indicating whether the given integer voxel is located within the array. The voxel is specified by its most negative grid point corner--for example, (2, 3, 4) represents the voxel contained in the box [2..3, 3..4, 4..5]. Note that voxel_inside(x, y, z) implies inside(x, y, z), although the converse is not necessarily true.
>>> if pa.voxel_inside(10, 20, 30): print 'inside'
|
electrode(self, x, y, z=0, is_electrode=None)Gets or sets the Boolean electrode state at the given integer point.
>>> pa.electrode(10, 20, 30, 1)
>>> print pa.electrode(10, 20, 30)
|
field(self, x, y, z=0, ex=None, ey=None, ez=None)Gets or sets the field (potential gradient) vector at the given point. The setting function internally performs the numerical integration on the given field vectors to generate the corresponding scalar potentials that must be stored in the PA file. Dies on error. Warning: The setting function has some special calling requirements. First, the all points must initially be zero volt, nonelectrodes. Second, the field setting method must be called for all points in the array in lexographic order (e.g. (0,0,0), (0,0,1), ... (0,0,nx()-1), (0,1,0), (0,1,1), (0,1,nx()-1), ...).
>>> # set
>>> for z in range(0,pa.nz()):
... for y in range(0,pa.ny()):
... for x in range(0,pa.nx()):
... ex = x
... ey = y**2
... ez = 0
... pa.field(x, y, z, ex, ey, ez)
>>> (ex, ey, ez) = pa.field(10, 20, 30) # get
|
field_real(self, x, y, z=0)Gets the electrostatic or magnetic field vector (ex, ey, ez) at the given real point, taking symmetry and mirroring into account.
>>> # assuming mirror_x
>>> (ex, ey, ez) = pa.field_real(-10.3, 20.2, 30.7)
|
point(self, x, y, z=0, is_electrode=None, potential=None)Gets or sets the Boolean electrode state and the potential at the given integer point. This is identical to calls to both the potential and electrode methods. Dies on error.
>>> pa.point(10, 20, 30, 1, 2.15)
>>> (is_electrode, potential) = pa.point(10, 20, 30)
The first line above is the same as
>>> pa.electrode(10, 20, 30, 1)
>>> pa.potential(10, 20, 30, 2.15)
|
potential(self, x, y, z=0, potential=None)Gets or sets the potential at the given integer point.
>>> pa.potential(10, 20, 30, 2.15)
>>> print pa.potential(10, 20, 30)
|
potential_real(self, x, y, z=0)Get the potential at the given real point, taking symmetry and mirroring into account. Interpolation is applied between grid points, as described on page E-7 os the SIMION 7.0 manual, except that the current version of this module does not perform special handling near electrode edges.
>>> print pa.potential(10.3, 20.2, 30.7)
|
solid(self, x, y, z=0, is_electrode=None)Gets or sets the solid electrode state for the given integer voxel. For a voxel to be a solid electrode (rather than a ideal grid electrode), all four (for 2D arrays) or eight (for 3D arrays) surrounding grid points must be electrode points. Dies on error.
>>> pa.solid(10, 20, 30, 1)
>>> print pa.solid(10, 20, 30)
|
raw(self, x, y, z=0, val=None)Gets or sets the raw value at the given integer point. The raw value is what is stored internally in the array at each data point and is not normally used directly. It is defined as potential(x,y,z) + is_electrode(x,y,z) ? 2 * max_voltage() : 0.
>>> pa.raw(10, 20, 30, 100002.15)
>>> print pa.raw(10, 20, 30)
|
check(self, mode=None, field_type=None, symmetry=None, mirror=None, mirror_x=None, mirror_y=None, mirror_z=None, nx=None, ny=None, nz=None, fast_adjustable=None, max_voltage=None, ng=None, enable_points=None, file=None)Checks whether the given combination of attributes is valid. Any subset of the above named parameters may be specified, and the named parameter 'mirror' containing a subset of the string 'xyz' may be specified as an alternative to the mirror_x, mirror_y, and mirror_z named parameters. The set method is useful in cases when the attributes are interdependent. For example, all of these fail:>>> if not util.check(symmetry = 'cylindrical', nz = 2): ... print util.error() >>> if not util.check(mirror_z = 1, nz = 1): ... print util.error() >>> if not util.check(symmetry = 'cylindrical, mirror = 'xz'): /// print util.error()Refer to the individual 'check' functions for details on the parameters.
|
check_field_type(self, field_type)Checks whether the given field type is valid. Example:
>>> if not util.check_field_type("magnetic"): print util.error()
|
check_max_voltage(self, max_voltage)Checks whether the given max voltage values is valid. Example:
>>> if not util.check_max_voltage(100000): print util.error()
|
check_mirror(self, mirror)Check whether the given mirroring string is valid.
>>> if not util.check_mirror("yz"): print util.error()
|
check_mode(self, mode)Checks whether the given mode is valid. Currently, the only valid mode is -1. Example:
>>> if not util.check_mode(-1): print util.error()
|
check_ng(self, ng)Checks whether the given ng magnetic scaling factor is valid. Example:
>>> if not util.check_ng(100): print util.error()
|
check_nx(self, nx)Checks whether the given grid dimension in the x direction is valid. Example:
>>> if not util.check_nx(100): print util.error()
|
check_ny(self, ny)Checks whether the given grid dimension in the y direction is valid. Example:
>>> if not util.check_ny(100): print util.error()
|
check_nz(self, nz)Checks whether the given grid dimension in the z direction is valid. Example:
>>> if not util.check_nz(100): print util.error()
|
check_size(self, nx, ny, nz=1)Checks whether the given set of grid dimensions in the x, y, and z directions is valid as a whole. Note that check_nx(nx) and check_ny(ny) and check_nz(nz) implies check_size(nx, ny, nz), although the converse is not necessarily true. Example:
>>> if not util.check_size(3, 3, 1): print util.error()
|
check_symmetry(self, symmetry)Checks whether the given symmetry is valid. Example:
>>> if not util.check_symmetry("cylindrical"): print util.error()
|
error(self)Get last error message generated by one of the check calls. |
pasharp(self, pasharp=None)Gets or sets the PA# associated with this PA0 (if any). None if none. This is only intended for PA0 arrays. The PA# information is needed to properly save a PA0 file.
>>> pasharp = PA(file = "test.pa#")
>>> pa0 = PA()
>>> # ... add code to create pa0 array here.
>>> pa0.pasharp(pasharp)
>>> pa0.save("test.pa0")
|
| Home | Trees | Index | Help |
|---|
| Generated by Epydoc 2.1 on Mon Nov 8 17:23:15 2004 | http://epydoc.sf.net |
