Package schrodinger :: Package analysis :: Package visanalysis :: Module volumedata :: Class VolumeData
[hide private]
[frames] | no frames]

Class VolumeData

object --+
         |
        VolumeData

The VolumeData class is responsible for handling the underlying storage as well as marrying together the concepts of array-coordinates and world-coordinates. The class itself is a fairly simple aggregation of the Numpy array class (to handle the basic storage and provide a huge library of functionality) and the _VDCoordinateFrame class (to marry up the concept of array-coordinates and world-coordinates).

Instance Methods [hide private]
 
__init__(self, N=None, resolution=None, origin=None)
This function creates a new VolumeData object.
 
_get_CoordinateFrame(self)
 
CoordinateFrame(self)
bool
IsCompatible(self, vd)
This function can be used to test whether vd is compatible with this VolumeData.
iterable< float, 3 >
ToArrayCoordinate(self, world)
Converts the specified world-coordinate to the corresponding array-coordinate.
iterable< iterable< float, 3 > >
ToArrayCoordinateL(self, worldCoordinates)
Converts the specified set of world-coordinates to the corresponding array-coordinates.
iterable< float, 3 >
ToWorldCoordinate(self, array)
Converts the specified array-coordinate to the corresponding world-coordinate.
iterable< iterable< float, 3 > >
ToWorldCoordinateL(self, arrayCoordinates)
Converts the specified set of array-coordinates to the corresponding world-coordinates.
bool
InBounds(self, world)
Tests whether the world-coordinate corresponds to a position that is within the bounds of the array-coordinates.
iterator< iterable< int, 3 > >
ArrayCoordinates(self)
This function returns an iterator which allows the array-coordinates corresponding to this VolumeData to be traversed.
iterable< iterable< int, 3 > >
getAllArrayCoordinates(self)
This function returns an object of the class iterable< iterable< int, 3 > >.
iterator< iterable< float, 3 > >
WorldCoordinates(self)
This function returns an iterator which allows the world-coordinates corresponding to this VolumeData to be traversed.
iterable< iterable< float, 3 > >
getAllWorldCoordinates(self)
This function returns an object of the class iterable< iterable< float, 3 > >.
iterator< tuple< iterable< int, 3 >, iterable< float, 3 > > >
Coordinates(self)
This function returns an iterator which allows the array-coordinates and world-coordinates corresponding to this VolumeData to be traversed.
numpy.array
getData(self)
This function allows access to the underlying data.
 
setData(self, data)
This function allows the underlying data to be set.
 
__iadd__(self, rhs)
__iadd__, __isub__, __imul__, __idiv__: These functions perform the standard mathematic operations on this VolumeData.
 
__isub__(self, rhs)
see __iadd__ docstring
 
__imul__(self, rhs)
see __iadd__ docstring
 
__idiv__(self, rhs)
see __iadd__ docstring
float
getAtArrayCoordinate(self, array, interpolationOrder=0, oobMethod="constant", oobConstant=0.0)
This function is used to retrieve values from this VolumeData object using array-coordinates.
iterable< float >
getAtArrayCoordinateL(self, arrayCoordinates, interpolationOrder=0, oobMethod="constant", oobConstant=0.0)
This function can be used to retrieve a large number of values at specified array-coordinates.
float
getAtWorldCoordinate(self, world, interpolationOrder=0, oobMethod="constant", oobConstant=0.0)
This function is used to retrieve values from this VolumeData object using world-coordinates.
iterable< float >
getAtWorldCoordinateL(self, worldCoordinates, interpolationOrder=0, oobMethod="constant", oobConstant=0.0)
This function can be used to retrieve a large number of values at specified world-coordinates.

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, N=None, resolution=None, origin=None)
(Constructor)

 

This function creates a new VolumeData object. The object represents a three-dimensional volume with the specified resolution, origin and dimensions.

The underlying _VDCoordinateFrame is exposed via the CoordinateFrame property.

Parameters:
  • N (iterable< int, 3 >) - The number of array-coordinates along the X, Y and Z axes respectively.
  • resolution (iterable< float, 3 >) - The resolution of the X, Y and Z axes respectively. Specified in world-coordinate units
  • origin (iterable< float, 3 >) - The origin of the X, Y and Z axes respectively. Specified in world-coordinates
Overrides: object.__init__

IsCompatible(self, vd)

 

This function can be used to test whether vd is compatible with this VolumeData. Compatible VolumeData objects have compatible coordinate-frames.

Parameters:
  • vd (VolumeData) - The volume-data to be tested for compatibility with this VolumeData
Returns: bool
True if vd is compatible with this VolumeData

ToArrayCoordinate(self, world)

 

Converts the specified world-coordinate to the corresponding array-coordinate.

Parameters:
  • world (iterable< float, 3>) - The world-coordinate to be converted X, Y, Z
Returns: iterable< float, 3 >
The array-coordinate corresponding to world. This need not be a valid array-coordinate

ToArrayCoordinateL(self, worldCoordinates)

 

Converts the specified set of world-coordinates to the corresponding array-coordinates.

Parameters:
  • worldCoordinates (iterable< iterable< float, 3 > >) - The set of world-coordinates to be converted
Returns: iterable< iterable< float, 3 > >
The array-coordinates corresponding to worldCoordinates

ToWorldCoordinate(self, array)

 

Converts the specified array-coordinate to the corresponding world-coordinate.

Parameters:
  • array (iterable< float, 3 >) - The array-coordinate to be converted X, Y, Z
Returns: iterable< float, 3 >
The world-coordinate corresponding to array

ToWorldCoordinateL(self, arrayCoordinates)

 

Converts the specified set of array-coordinates to the corresponding world-coordinates.

Parameters:
  • arrayCoordinates (iterable< iterable< float, 3 > >) - The set of array-coordinates to be converted
Returns: iterable< iterable< float, 3 > >
The world-coordinates corresponding to arrayCoordinates

InBounds(self, world)

 

Tests whether the world-coordinate corresponds to a position that is within the bounds of the array-coordinates.

Parameters:
  • world (iterable< float, 3 >) - The world-coordinate to be tested X, Y, Z
Returns: bool
True if the world-coordinate is in bounds.

ArrayCoordinates(self)

 

This function returns an iterator which allows the array-coordinates corresponding to this VolumeData to be traversed. The order of the traversal is not specified. The de-referenced iterator provides an object of the form iterable< int, 3 >, the X, Y and Z array-coordinates.

Returns: iterator< iterable< int, 3 > >
Array-coordinate iterator.

getAllArrayCoordinates(self)

 

This function returns an object of the class iterable< iterable< int, 3 > >. This contains all of the valid array-coordinates. The ordering of entries in this object is guaranteed to be the same as that returned by self.getAllWorldCoordinates().

Returns: iterable< iterable< int, 3 > >
The array-coordinates

WorldCoordinates(self)

 

This function returns an iterator which allows the world-coordinates corresponding to this VolumeData to be traversed. The order of traversal is not specified. The de-referenced iterator provides an object of the form iterable< float, 3 >, the X, Y and Z world-coordinates.

Returns: iterator< iterable< float, 3 > >
World-coordinate iterator

getAllWorldCoordinates(self)

 

This function returns an object of the class iterable< iterable< float, 3 > >. This contains all of the world-coordinates. The ordering of entries in this object is guaranteed to be the same as that returned by self.getAllArrayCoordinates().

Returns: iterable< iterable< float, 3 > >
The world-coordinates

Coordinates(self)

 

This function returns an iterator which allows the array-coordinates and world-coordinates corresponding to this VolumeData to be traversed. The order of traversal is not specified. The de-referenced iterator returns an object of the form tuple< iterable< int, 3 >, iterable< float, 3 > >, the X, Y, Z coordinates of the array and world respectively.

Returns: iterator< tuple< iterable< int, 3 >, iterable< float, 3 > > >
Array and world-coordinate iterator

getData(self)

 

This function allows access to the underlying data. The object returned by this function may be used anywhere a Numpy array object would be used. This is the fastest method accessing values from this VolumeData object, however, the access is restricted to valid array-coordinates only.

Returns: numpy.array
The underlying volume-data

setData(self, data)

 

This function allows the underlying data to be set. The function makes a copy of data.

Parameters:
  • data (numpy.array) - The data to be assigned to this VolumeData's underlying data. The size of this three-dimensional array should be the same as this VolumeData

__iadd__(self, rhs)

 

__iadd__, __isub__, __imul__, __idiv__: These functions perform the standard mathematic operations on this VolumeData.

Parameters:
  • rhs (VolumeData or numerical) - If rhs is numerical the appropriate operation will be performed on every element of the data. If rhs is a VolumeData instance each element of this VolumeData will be modified with the corresponding element of rhs. This implies that the two VolumeData objects must be compatible.

getAtArrayCoordinate(self, array, interpolationOrder=0, oobMethod="constant", oobConstant=0.0)

 

This function is used to retrieve values from this VolumeData object using array-coordinates. The function is capable of retrieving values at invalid array-coordinates using a mixture of interpolation and OOB-handling.

Parameters:
  • array (iterable< float, 3 >) - The array-coordinates to retrieve. Need not be valid array-coordinates
  • interpolationOrder (int) - The degree of interpolation to use when retrieving the values. 0-5
  • oobMethod (string) - What to do with requests that lie outside of the bounds of this VolumeData object. The options are "constant", which returns the value of oobConstant. "nearest" which returns the value of the nearest valid point or "wrap", which effectively tiles the data into an infinite repeating lattice.
  • oobConstant (float) - Of the class float. The value to return if the request is OOB and the oobMethod is "constant"
Returns: float
The value stored at the requested array-coordinate

getAtArrayCoordinateL(self, arrayCoordinates, interpolationOrder=0, oobMethod="constant", oobConstant=0.0)

 

This function can be used to retrieve a large number of values at specified array-coordinates. It is similar to the getAtArrayCoordinate function, however, in this case the array-coordinates are specified as a list rather than a single coordinate.

Parameters:
  • arrayCoordinates (iterable< iterable< float, 3 > >) - The array-coordinates whose values are to be retrieved
  • interpolationOrder (int) - The degree of interpolation to use when retrieving the values. 0-5
  • oobMethod (string) - What to do with requests that lie outside of the bounds of this VolumeData object. The options are "constant", which returns the value of oobConstant. "nearest" which returns the value of the nearest valid point or "wrap", which effectively tiles the data into an infinite repeating lattice.
  • oobConstant (float) - Of the class float. The value to return if the request is OOB and the oobMethod is "constant"
Returns: iterable< float >
The value stored at the requested array-coordinates. The values are returned in an order that is equivalent to arrayCoordinates

getAtWorldCoordinate(self, world, interpolationOrder=0, oobMethod="constant", oobConstant=0.0)

 

This function is used to retrieve values from this VolumeData object using world-coordinates. The function is capable of retrieving values at any world-coordinate using a mixture of interpolation and OOB-handling

Parameters:
  • world (iterable< float, 3 >) - The world-coordinates to retrieve
  • interpolationOrder (int) - The degree of interpolation to use when retrieving the values. 0-5
  • oobMethod (string) - What to do with requests that lie outside of the bounds of this VolumeData object. The options are "constant", which returns the value of oobConstant. "nearest" which returns the value of the nearest valid point or "wrap", which effectively tiles the data into an infinite repeating lattice.
  • oobConstant (float) - Of the class float. The value to return if the request is OOB and the oobMethod is "constant"
Returns: float
The value stored at the requested world-coordinate

getAtWorldCoordinateL(self, worldCoordinates, interpolationOrder=0, oobMethod="constant", oobConstant=0.0)

 

This function can be used to retrieve a large number of values at specified world-coordinates. It is similar to the getAtWorldCoordinate function, however, in this case the world-coordinates are specified as a list rather than a single coordinate.

Parameters:
  • worldCoordinates (iterable< iterable< float, 3 > >) - The world-coordinates whose values are to be retrieved
  • interpolationOrder (int) - The degree of interpolation to use when retrieving the values. 0-5
  • oobMethod (string) - What to do with requests that lie outside of the bounds of this VolumeData object. The options are "constant", which returns the value of oobConstant. "nearest" which returns the value of the nearest valid point or "wrap", which effectively tiles the data into an infinite repeating lattice.
  • oobConstant (float) - Of the class float. The value to return if the request is OOB and the oobMethod is "constant"
Returns: iterable< float >
The value stored at the requested world-coordinates. The values are returned in an order that is equivalent to worldCoordinates