Sources module¶
A module containing objects that wrap CUDS objects and files to Mayavi
compatible sources. Please use the simphony_mayavi.sources.api
module to access the provided tools.
Classes
CUDSSource ([cuds, point_scalars, ...]) |
A mayavi source of a SimPhoNy CUDS container. |
CUDSFileSource (**traits) |
A mayavi source of a SimPhoNy CUDS File. |
EngineSource ([engine, dataset, ...]) |
A mayavi source for reading data from a SimPhoNy Engine |
Description¶
-
class
simphony_mayavi.sources.cuds_source.
CUDSSource
(cuds=None, point_scalars=None, point_vectors=None, cell_scalars=None, cell_vectors=None, **traits)[source]¶ Bases:
mayavi.sources.vtk_data_source.VTKDataSource
A mayavi source of a SimPhoNy CUDS container.
- cuds : instance of ABCParticle/ABCMesh/ABCLattice/H5Mesh
- The CUDS container to be wrapped as VTK data source
The
cuds
attribute holds a reference to the CUDS instance it is assigned to, as oppose to making a copy. Therefore in any given time after settingcuds
, the CUDS container could be modified internally and divert from the VTK data source. Theupdate
function can be called to update the visualisation.Examples
>>> cuds = Particles("test") # the container is empty >>> source = CUDSSource(cuds=cuds)
>>> from mayavi import mlab >>> mlab.pipeline.glyph(source) # scene is empty
>>> # Add content to cuds after the source is initialised >>> cuds.add_particles([...])
>>> # update the scene! >>> source.update()
Constructor
- cuds : ABCParticles, ABCLattice, ABCMesh or H5Mesh
- The CUDS dataset to be wrapped as VTK data source
- point_scalars : str
- CUBA name of the data to be selected as point scalars. Default is the first available point scalars.
- point_vectors : str
- CUBA name of the data to be selected as point vectors. Default is the first available point vectors.
- cell_scalars : str
- CUBA name of the data to be selected as cell scalars. Default is the first available cell scalars.
- cell_vectors : str
- CUBA name of the data to be selected as cell vectors. Default is the first available cell vectors.
Note
To turn off visualisation for a point/cell scalar/vector data, assign the attribute to an empty string (i.e. point_scalars=””)
Other optional keyword parameters are parsed to VTKDataSource.
Examples
>>> cuds = Particles("test")
>>> # Say each particle has scalars "TEMPERATURE" and "MASS" >>> # and vector data: "VELOCITY" >>> cuds.add_particles([...])
>>> # Initialise the source and specify scalar data to visualise >>> # but turn off the visualisation for point vectors >>> source = CUDSSource(cuds=cuds, point_scalars="MASS", point_vectors="")
>>> # Show it in Mayavi! >>> from mayavi import mlab >>> mlab.pipeline.glyph(source)
-
cuds
= Property(depends_on='_cuds')¶ The CUDS container
-
output_info
= PipelineInfo(datasets=['image_data', 'poly_data', 'unstructured_grid'], attribute_types=['any'], attributes=['scalars', 'vectors'])¶ Output information for the processing pipeline.
-
class
simphony_mayavi.sources.cuds_file_source.
CUDSFileSource
(**traits)[source]¶ Bases:
simphony_mayavi.sources.cuds_source.CUDSSource
A mayavi source of a SimPhoNy CUDS File.
Create a CUDSFileSource instance
Example
>>> source = CUDSFileSource() >>> source.initialize("path/to/cuds_file.cuds")
-
dataset
= DEnum(values_name='datasets')¶ The name of the CUDS container that is currently loaded.
-
datasets
= ListStr¶ The names of the contained datasets.
-
file_path
= Instance(FilePath, '', desc='the current file name')¶ The file path of the cuds file to read.
-
-
class
simphony_mayavi.sources.engine_source.
EngineSource
(engine=None, dataset=None, point_scalars=None, point_vectors=None, cell_scalars=None, cell_vectors=None, **traits)[source]¶ Bases:
simphony_mayavi.sources.cuds_source.CUDSSource
A mayavi source for reading data from a SimPhoNy Engine
-
engine
= ABCModelingEngine¶ The SimPhoNy Modeling Engine where dataset is loaded from.
-
engine_name
= str¶ Name of the engine, if provided, it is use for representation purpose in the Mayavi pipeline GUI
-
dataset
= str¶ Name of the dataset currently selected from the engine
- datasets : list of str
- The list of datasets in the engine
Examples
>>> source = EngineSource(engine=some_engine) >>> source.datasets ["particles", "lattice"] >>> source.dataset = "particles"
>>> # Alternatively >>> source = EngineSource(engine=some_engine, dataset="particles")
>>> from mayavi import mlab >>> mlab.pipline.glypy(source)
Constructor
Parameters: - engine (ABCModelingEngine) – The SimPhoNy Modeling Engine where dataset is loaded from. Default is None.
- dataset (str) – Name of the dataset to be extracted from engine. Default is the first available dataset if engine is defined, otherwise it is an empty string
- point_scalars (str) – CUBA name of the data to be selected as point scalars. Default is the first available point scalars.
- point_vectors (str) – CUBA name of the data to be selected as point vectors. Default is the first available point vectors.
- cell_scalars (str) – CUBA name of the data to be selected as cell scalars. Default is the first available cell scalars.
- cell_vectors (str) – CUBA name of the data to be selected as cell vectors. Default is the first available cell vectors.
Note
To turn off visualisation for a point/cell scalar/vector data, assign the attribute to an empty string (i.e. point_scalars=””)
Other optional keyword parameters are parsed to CUDSSource
-
update
()¶ Recalculate the VTK data from the CUDS dataset Useful when
cuds
is modified after assignment
-