iota.render
Description
This module provides functionalities to create scenes to render in 3D the data in simulation datasets. It also provides methods to create screenshots and videos from 3D render of the scenes.
Scene class object. This object contains the settings of a scene to generate a 3D render
Parameters
dataset
: (iota.dataset.Dataset) a dataset object to use as the base to create a scene with default settings (Default: None)pac_file
: (str) path and file name to a .pac file that contains the scene settings to be loaded (Default: None)
Example
Creating a scene with the default settings based on a fluent dataset
Creating a scene based on the settings stored in a pac file
Methods
Display a scene as 3D interactive render on the working notebook
Parameters
step
: (int) index of timestep for the scene (Default: 0)width
: (int) width of the display of the scene in pixels (Default: 800)height
: (int) height of the video display of the scene in pixels (Default: 600)
Example
Displaying a scene
Displaying a scene for the 5th step of the scene dataset and with a with equal to 1000 pixels and a height equal to 800 pixels
Set the view of the scene so that x-axis is perpendicular to the screen
Parameters
positive
: (bool) If True the positive x-axis point inwards (Default: True)
Example
Setting the view of the scene with the positive x-axis being perpendicular to the the screen and pointing inwards
Setting the view of the scene with the positive x-axis being perpendicular to the the screen and pointing outwards
Set the view of the scene so that y-axis is perpendicular to the screen
Parameters
positive
: (bool) If True the positive y-axis point inwards (Default: True)
Example
Setting the view of the scene with the positive y-axis being perpendicular to the the screen and pointing inwards
Setting the view of the scene with the positive y-axis being perpendicular to the the screen and pointing outwards
Set the view of the scene so that z-axis is perpendicular to the screen
Parameters
positive
: (bool) If True the positive z-axis point inwards (Default: True)
Example
Setting the view of the scene with the positive z-axis being perpendicular to the the screen and pointing inwards
Setting the view of the scene with the positive z-axis being perpendicular to the the screen and pointing outwards
Set the view of the scene to isometric
Parameters
positive
: (bool) If True the positive parts of the axis point inwards (Default: True)
Example
Setting the view of the scene to isometric view
Setting the view of the scene to isometric with the positive part of the axis pointing outwards
Set a result-analysis to be rendered for a mesh (or all meshes) in the scene
Parameters
mesh
: (str) name of the mesh to set with a result. If mesh=None, the result is set for all the meshes in the sceneresult
: (str) name of the result to be renderedanalysis
: (str) name of the analysis to be renderedcomponent
: (int) index of the component of the result to be rendered (Default: 0)minmax
: ([float, float]) min and max value for the colorbar of the scene. If not provided, the min and max values of the colorbar are automatically set to the min and max values of the result to be rendered (Default: None)colouring
: (str) colormap for the colorbar of the scene (Default: 'jet')
Example
Setting the mesh called 'my_mesh' to be rendered with the magnitude of the velocity of the analysis 'phase-1' and colorbar using the default colormap, with min and max value set to the min and max value of the result
Setting all meshes to be rendered with the magnitude of the velocity of the analysis 'phase-1' and colorbar using the default colormap, with min and max value set to the min and max value of the result
Setting all meshes to be rendered with the magnitude of the velocity of the analysis 'phase-1' and colorbar using the default colormap, with min value equal to 0.1 and max value equal to 0.8
Setting all meshes to be rendered with the magnitude of the velocity of the analysis 'phase-1' and colorbar using the 'volcano' colormap, with min value equal to 0.1 and max value equal to 0.8
Shows the colourmaps available, ordered alphabetically
Set the behaviour with contour regions outside the minmax range
Parameters
outofrange_rule
: (int) behaviour. 0: empty; 1: colour using outofrange_colour; 2: extrapolate from colourmap (Default: 0)outofrange_colour
: (tuple of three floats) normalised RGB triplet for the desired colour when outofrange_rule is 1 (Default: (0.5, 0.5, 0.5) )
Example
Colour the values outside of the minmax range in black
Colour the values outside of the minmax range extrapolating from the colourmap
Set the render mode for a mesh in the scene
Parameters
mesh
: (str) name of the meshmode
: (iota.render.MeshMode) render mode for the mesh (Default: iota.render.MeshMode.SOLID)visibility
: (float) level of opacity between 0.0 and 1.0 (Defaut: 1.0)
Example
Setting the mesh called 'my_mesh' to be rendered as a solid a level of opacity equal to 0.5
Setting the mesh called 'my_mesh' to be rendered as a solid with wireframe a level of opacity equal to 1.0
Setting the mesh called 'my_mesh' to invisible
Export the scene setting to pac file on disk and/or a Scene object
Parameters
filename
: (str) name for the pac file where the scene settings will be exported to (Default: None)
Returns
A iota.render.Scene object with the settings of the scene
Example
Exporting the scene setting to a pac file
Generate a screenshot or a set of screenshots based on the scene settings
Parameters
filename
: (str) name for the files of the screenshots to be generatedtsart
: (int) index of the step that defines the start of the steps interval for the screenshot generationtend
: (int) index of the step that defines the end of the steps interval for the screenshot generationtimestep_frequency
: (int) defines the frequency of the steps within the defined interval that will be used for the screenshot generation
Returns
A list of iota.medio.IotaImage objects that corresponds to the screenshots generated
Example
Generating a screenshot based on the scene settings and for the 2nd step of the dataset in the scene
Generating a sequence of screenshot based on the scene settings for every step within the interval defined from the 2nd step to the 5th step of the dataset in the scene
Generating a sequence of screenshot based on the scene settings with a step frequency equal to 2 (i.e., a step every 2 steps) within the interval defined from the 2nd step to the 5th step of the dataset in the scene
Generate a video based on the scene settings
Parameters
filename
: (str) name for the files of the screenshots to be generatedframe_rate
: (int) frame rate for the video, i.e, frames per second (Default: 5)format
: (iota.render.VideoFormat) format for the video file (Default: iota.render.MP4)tsart
: (int) index of the step that defines the start of the steps interval for the video generation. If None, the interval starts from the first step in the dataset (Default: None)tend
: (int) index of the step that defines the end of the steps interval for the video generation. If None, the interval goes up to the last step in the dataset (Default: None)
Returns
A iota.medio.IotaVideo objects that corresponds to the video generated
Example
Generating a video based on the scene settings and for all the step of the dataset in the scene
Generating a video in AVI format and based on the scene settings using the frame rate of 10 frames per second. The video will includes the dataset steps going from the 3rd step to 50th step
Mesh render mode class object. It is usually used to the define the render mode of the meshes in a scene (see Scene.set_mesh() method)
Attributes
iota.render.MeshMode.SOLID
: the mesh is rendered as a solidiota.render.MeshMode.WIREFRAME
: only the wireframe of the mesh is renderediota.render.MeshMode.WIREFRAME2
: the mesh is rendered as a solid with its wireframe
Class object to define the video format. It is usually used as an input parameter for the video generation methods (see the methods Scene.create_video() and iota.render.create_video())
Attributes
iota.render.VideoFormat.MPEG
: H.264 format. File extension: .mpgiota.render.VideoFormat.AVI
: Audio Video Interleave format . File extension: .aviiota.render.MeshMode.MP4
: MPEG-4 Part 14 format. File extension: .mp4iota.render.MeshMode.WEBM
: WebM format. File extension: .webm
Display a 3D interactive render on the working notebook given a set of scene settings
Parameters
scene
: (iota.render.Scene) a scene object that contains the settings for the renderdataset
: (iota.dataset.Dataset) a dataset object to be rendered. If provided, it overwrites the dataset from the given scene object for the render settings (Default: None)step
: (int) index of the timestep in the dataset to be rendered (Default: None) (Default: 0)result
: (str) name of the result in the dataset to be rendered. If provided, it overwrites the result from the given scene object for the render settings (Default: None)analysis
: (str) name of the analysis in the dataset to be rendered. If provided, it overwrites the analysis from the given scene object for the render settings (Default: None)component
: (int) index of the component of the result-analysis in the dataset to be rendered. If provided, it overwrites the component from the given scene object for the render settings (Default: None)minmax
: ([float, float]) min and max value for the colorbar to be rendered. If provided, it overwrites the min and max values from the given scene object for the render settings (Default: None)width
: (int) width of the display of the scene in pixels (Default: 800)height
: (int) height of the video display of the scene in pixels (Default: 600)
Example
Displaying a 3D render using an existing scene settings but using a new dataset and setting the step to the 3rd one in the dataset
Displaying a 3D render using an existing scene settings but rendering the magnitude of the velocity of the analysis 'phase-1' at the 5th step of the dataset and setting the min and max values of the colorbar to 0.2 and 0.8 respectively
Generate a screenshot or a set of screenshots based on a given set of scene settings
Parameters
scene
: (iota.render.Scene) a scene object that contains the settings for the renderdataset
: (iota.dataset.Dataset) a dataset object to be rendered. If provided, it overwrites the dataset from the given scene object for the render settings (Default: None)filename
: (str) name for the files of the screenshots to be generatedtsart
: (int) index of the step that defines the start of the steps interval for the screenshot generationtend
: (int) index of the step that defines the end of the steps interval for the screenshot generationtimestep_frequency
: (int) defines the frequency of the steps within the defined interval that will be used for the screenshot generation
Returns
A list of iota.medio.IotaImage objects that corresponds to the screenshots generated
Example
Generating a screenshot based on an existing scene settings but using a new dataset and setting the screenshot for the 3rd step in the dataset
Generating a sequence of screenshot based on an existing scene settings but using a new dataset and setting the screenshots for every step within the interval defined from the 2nd step to the 5th step in the dataset
Generating a sequence of screenshot based on an existing scene settings but using a new dataset and setting the screenshots to be generated with a step frequency equal to 2 (i.e., a step every 2 steps) within the interval defined from the 2nd step to the 5th step in the dataset
Generate a video based on a given set of scene settings
Parameters
scene
: (iota.render.Scene) a scene object that contains the settings for the renderdataset
: (iota.dataset.Dataset) a dataset object to be rendered. If provided, it overwrites the dataset from the given scene object for the render settings (Default: None)filename
: (str) name for the files of the screenshots to be generatedframe_rate
: (int) frame rate for the video, i.e, frames per second (Default: 5)format
: (iota.render.VideoFormat) format for the video file (Default: iota.render.MP4)tsart
: (int) index of the step that defines the start of the steps interval for the video generation. If None, the interval starts from the first step in the dataset (Default: None)tend
: (int) index of the step that defines the end of the steps interval for the video generation. If None, the interval goes up to the last step in the dataset (Default: None)
Returns
A iota.medio.IotaVideo objects that corresponds to the video generated
Example
Generating a video based on an existing scene settings but using a new dataset and including all the steps in the dataset
Generating a video in AVI format and based on an existing scene settings but using a new dataset and setting the frame rate of 10 frames per second. The video will includes the steps within the interval defined from the 3rd to 50th step in the dataset
Last updated
Was this helpful?