fractaldna.structure_models.voxelisation.VoxelisedFractal¶
- class fractaldna.structure_models.voxelisation.VoxelisedFractal¶
Bases:
object
Class containing a voxelised representation of a fractal
Typically created using the VoxelisedFractal.fromSeed class method
fractal = VoxelisedFractal.fromSeed(‘X’, 1) fractal.fractal contains a list of ‘Voxels’ representing the DNA Path
- __init__()¶
Constructor
Methods
__init__
()Constructor
Center the fractal around (x, y, z) = (0, 0, 0)
fromLString
(lstring[, pbar])Convert an L-String into a VoxelisedFractal
fromSeed
(seed, iterations[, distance])Make a voxelised fractal from an L-String seed.
from_path
(path[, pbar])Convert a path (a list of xyz positions) to a voxelised representation
to_frame
([suppress_hash])Convert voxelised representation to data frame
to_plot
([refine, batch])Create a matplotlib figure instance of this fractal
to_pretty_plot
([refine, mayavi, mask])Create a matplotlib figure instance of this fractal, with curved lines rather than hard corners
to_text
([sep, comment])Return a textual representation of the fractal as
- center_fractal()¶
Center the fractal around (x, y, z) = (0, 0, 0)
- Return type:
None
- classmethod fromLString(lstring, pbar=False)¶
Convert an L-String into a VoxelisedFractal
- Parameters:
lstring (
str
) – L-String to convertpbar (
bool
) – Show a progress bar for generating path and voxels
- Returns:
Voxelised Fractal representation
- classmethod fromSeed(seed, iterations, distance=1)¶
Make a voxelised fractal from an L-String seed.
The available L-Strings are described in fractaldna.structure_models.hilbert
- Parameters:
seed (
str
) – Seed L-Stringiterations (
int
) – number of times to iterate seeddistance (
float
) – distance between voxels
- Returns:
Voxelised Fractal representation
- classmethod from_path(path, pbar=False)¶
Convert a path (a list of xyz positions) to a voxelised representation
- Parameters:
path (
Union
[List
[array
],List
[List
],array
]) – path to convertpbar (
bool
) – show a progress bar if true
- Returns:
Voxelised Fractal representation
- to_frame(suppress_hash=False)¶
Convert voxelised representation to data frame
- Parameters:
suppress_hash (
bool
) – Hide the hash in front of the ‘IDX’ column which is kept for compatibiilty with the Geant4 DNA simulation format- Returns:
Voxelised fractal as a data frame
- to_plot(refine=0, batch=False)¶
Create a matplotlib figure instance of this fractal
fig = toPlot(refine=0, batch=False) :type refine:
int
:param refine: points to plot in between voxels (more points = clearer path) :type batch:bool
:param batch: True to suppress automatic display of the figure- Return type:
figure
- to_pretty_plot(refine=10, mayavi=False, mask=None)¶
Create a matplotlib figure instance of this fractal, with curved lines rather than hard corners
fig = to_pretty_plot(refine=10, batch=False)
- Parameters:
refine (
int
) – points to plot in between voxels (more points = clearer path)mayavi (
bool
) – make plot with MayaVImask (
Optional
[Callable
]) – Callable function that returns true for voxels that should be plotted. mask is a function that should take a position three vector and return boolean True/False for any position.
- to_text(sep=' ', comment='#')¶
- Return a textual representation of the fractal as
KIND POS_X POS_Y POS_Z EUL_PSI EUL_THETA EUL_PHI
- Parameters:
sep (
str
) – string to use to separate fields (default space)comment (
str
) – string to use to denote comment in first line (default hash: #)