vfp module
Module for VFP specific plotting.
- sapphireppplot.vfp.load_solution(plot_properties, path_prefix='', results_folder='', base_file_name='', animation_time=None)
Load solution for VFP module.
This function performs the following steps:
Retrieves the folder containing simulation results.
Loads the parameter file.
Loads the solution data from the files in the results folder.
Adds time step information if necessary.
Updates the animation scene to the specified animation time.
- Parameters:
plot_properties (
PlotPropertiesVFP) – Properties of the solution to load.path_prefix (
str) – Prefix for relative path.results_folder (
str) – The path to the results folder.base_file_name (
str) – Overwrite base name of the solutions files.animation_time (
Optional[float]) – Set the time at which the animation scene is displayed. Defaults to the last time step.
- Return type:
tuple[str,Dict[str,Any],SourceProxy,Proxy]- Returns:
results_folder (str) – The path to the results folder.
prm (ParamDict) – Dictionary of the parameters.
solution (SourceProxy) – A ParaView reader object with selected point arrays enabled.
animation_scene (Proxy) – The ParaView AnimationScene.
- Raises:
ValueError – If no matching files are found.
See also
sapphireppplot.pvloadModule to load ParaView files.
sapphireppplot.utils.get_results_folderPrompt for results folder.
sapphireppplot.plot_properties.PlotProperties.series_namesSeries names list to load.
- sapphireppplot.vfp.load_probe_location_surface(results_folder, prm, point_id=0, plot_properties_in=PlotProperties(series_names=[], labels={}, data_type='POINTS', representation_type='UnstructuredGridRepresentation', use_legacy_pvtu_reader=True, preview_size_1d=(1280, 720), preview_size_2d=(1024, 1024), camera_view_2d=(False, 0.9), preview_size_3d=(1024, 1024), camera_view_3d=(False, 0.9), background_color=(1.0, 1.0, 1.0), screenshot_transparent_background=True, animation_transparent_background=False, animation_frame_stride=1, extracts_frame_stride=1, extracts_compressor='ZLib', extracts_compression_level=5, font_family='Arial', text_color=(0.5, 0.5, 0.5), label_size=18, text_size=24, title_size=30, line_colors={}, line_styles={}, line_widths={}, default_line_width=2.0, legend_location='TopRight', legend_symbol_width=30, left_axis_labels={}, bottom_axis_labels={}, show_grid=False, grid_labels=('$x$', '$y$', '$z$'), grid_color=(0.5, 0.5, 0.5), color_map='Viridis (matplotlib)', color_bar_label_format='', color_bar_range_labels=True, color_bar_range_label_format='%-#6.1e', color_bar_orientation='Vertical', color_bar_position='Lower Right Corner', color_bar_length=0.25, color_bar_thickness=16, axes_scale=(1.0, 1.0, 1.0), axes_stretch=(1.0, 1.0, 1.0), axes_ticks=(None, None, None), time_format='$t = {time:.2f}$', time_location='Upper Left Corner', sampling_pattern='center', sampling_resolution=None, stream_tracer_maximum_error=1e-06, stream_tracer_minimum_step=0.01, stream_tracer_initial_step=0.2, stream_tracer_maximum_step=0.5, export_precision=5))
Load surface plot of phase space distribution at a probed location.
Assumes that the phase space distribution was reconstructed in Sapphire++ using
Probe location.- Parameters:
results_folder (
str) – The path to the results folder.prm (
Dict[str,Any]) – Dictionary of the parameters.point_id (
int) – Index of the probed point.
- Return type:
tuple[SourceProxy,list[float],PlotProperties]- Returns:
solution (SourceProxy) – ParaView source for the phase space surface plot.
coordinates (list[float]) – Coordinate of the point in reduced phase space.
plot_properties (PlotProperties) – Properties of the surface plot.
- Raises:
ValueError – If no matching files are found.
See also
sapphireppplot.pvloadModule to load ParaView files.
- paraview.simple.TableToPoints
Convert table to point data.
- paraview.simple.PointVolumeInterpolator
Convert point cloud to grid data.
- sapphireppplot.vfp.load_probe_location_spherical_density(results_folder, prm, point_id=0, resolution=100, plot_properties_in=PlotProperties(series_names=[], labels={}, data_type='POINTS', representation_type='UnstructuredGridRepresentation', use_legacy_pvtu_reader=True, preview_size_1d=(1280, 720), preview_size_2d=(1024, 1024), camera_view_2d=(False, 0.9), preview_size_3d=(1024, 1024), camera_view_3d=(False, 0.9), background_color=(1.0, 1.0, 1.0), screenshot_transparent_background=True, animation_transparent_background=False, animation_frame_stride=1, extracts_frame_stride=1, extracts_compressor='ZLib', extracts_compression_level=5, font_family='Arial', text_color=(0.5, 0.5, 0.5), label_size=18, text_size=24, title_size=30, line_colors={}, line_styles={}, line_widths={}, default_line_width=2.0, legend_location='TopRight', legend_symbol_width=30, left_axis_labels={}, bottom_axis_labels={}, show_grid=False, grid_labels=('$x$', '$y$', '$z$'), grid_color=(0.5, 0.5, 0.5), color_map='Viridis (matplotlib)', color_bar_label_format='', color_bar_range_labels=True, color_bar_range_label_format='%-#6.1e', color_bar_orientation='Vertical', color_bar_position='Lower Right Corner', color_bar_length=0.25, color_bar_thickness=16, axes_scale=(1.0, 1.0, 1.0), axes_stretch=(1.0, 1.0, 1.0), axes_ticks=(None, None, None), time_format='$t = {time:.2f}$', time_location='Upper Left Corner', sampling_pattern='center', sampling_resolution=None, stream_tracer_maximum_error=1e-06, stream_tracer_minimum_step=0.01, stream_tracer_initial_step=0.2, stream_tracer_maximum_step=0.5, export_precision=5))
Load spherical density map of phase space distribution at a probed location.
Assumes that the phase space distribution was reconstructed in Sapphire++ using
Probe location.Note, this function is very inefficient and should be avoided. In order to get a solid surface, this function first creates a full 3D volume and then slices out a sphere.
- Parameters:
results_folder (
str) – The path to the results folder.prm (
Dict[str,Any]) – Dictionary of the parameters.point_id (
int) – Index of the probed point.resolution (
int) – Resolution for the sphere.
- Return type:
tuple[SourceProxy,list[float],PlotProperties]- Returns:
solution (SourceProxy) – ParaView source for the phase space spherical density map.
coordinates (list[float]) – Coordinate of the point in reduced phase space.
plot_properties (PlotProperties) – Properties of the spherical density map.
- Raises:
ValueError – If no matching files are found.
See also
sapphireppplot.pvloadModule to load ParaView files.
- paraview.simple.TableToPoints
Convert table to point data.
- paraview.simple.PointVolumeInterpolator
Convert point cloud to grid data.
- paraview.simple.Slice
Slice sphere from volume data.
- sapphireppplot.vfp.scale_distribution_function(solution, plot_properties_in, lms_indices=None, spectral_index=4.0)
Scales the distribution function to the desired spectral index \(s\).
This will create a number of calculator objects, each scaling one specific lms_index.
- Parameters:
solution (
SourceProxy) – The the data to scale.plot_properties_in (
PlotPropertiesVFP) – Properties of the source.lms_indices (
Optional[Sequence[tuple[int,int,int]]]) – The list of indices[(l_1,m_1,s_1), (l_2,m_2,s_2)]to scale. Only these indices will be active in the new solution.spectral_index (
float) – Spectral index to scale the distributions function f.
- Return type:
tuple[SourceProxy,PlotPropertiesVFP]- Returns:
solution_scaled (SourceProxy) – The scaled distribution function \(p^s f_{lms}\) for lms_indices.
plot_properties (PlotPropertiesVFP) – Solution properties for the scaled distribution function.
- sapphireppplot.vfp.merge_input_function_vectors(solution, plot_properties_in, prefix='func_')
Merge the magnetic field and velocity field into ParaView vectors.
This enables the use vector specific functionality, e.g. the stream tracer.
- Parameters:
solution (
SourceProxy) – The the data with the vector components as scalars.plot_properties_in (
PlotPropertiesVFP) – Properties of the source.prefix (
str) – Prefix for theseries_names.
- Return type:
tuple[SourceProxy,PlotPropertiesVFP]- Returns:
solution_scaled (SourceProxy) – Solution with the merged vectors.
plot_properties (PlotPropertiesVFP) – Solution properties for the merged vectors.
See also
- paraview.simple.MergeVectorComponents
ParaView MergeVectorComponents filter.
- sapphireppplot.vfp.plot_f_lms_1d(solution, results_folder, name, plot_properties, lms_indices=None, x_label=None, x_range=None, value_range=None, log_x_scale=False, log_y_scale=False, show_time=False, save_animation=False, layout=None)
Plot and save visualization of the specified f_lms in 2D.
- Parameters:
solution (
SourceProxy) – The simulation or computation result containing the data to plot.results_folder (
str) – Path to the folder where results (images/animations) will be saved.name (
str) – Name of the layout and image/animation files.plot_properties (
PlotPropertiesVFP) – Properties for plotting.lms_indices (
Optional[Sequence[tuple[int,int,int]]]) – The list of indices[(l_1,m_1,s_1), (l_2,m_2,s_2)]to plot.x_label (
Optional[str]) – Label for the bottom axis of the chart.x_range (
Optional[tuple[float,float]]) – Minimal (x_range[0]) and maximal (x_range[1]) value for the x-axes.value_range (
Optional[tuple[float,float]]) – Minimal (value_range[0]) and maximal (value_range[1]) value for the y-axes.log_x_scale (
bool) – Use a logarithmic x-scale?log_y_scale (
bool) – Use a logarithmic y-scale?show_time (
bool) – Display the simulation time in the line chart view.save_animation (
bool) – Save an animation of the plot.layout (
Optional[ViewLayoutProxy]) – The layout object where the plot should be added as new view. Will create a new one if none if provided.
- Return type:
tuple[ViewLayoutProxy,Proxy]- Returns:
layout (ViewLayoutProxy) – The layout object used for the plot.
line_chart_view (XYChartViewProxy) – The configured XY chart view.
See also
sapphireppplot.pvplot.plot_line_chart_viewPlot LineChartView.
- sapphireppplot.vfp.plot_f_lms_2d(solution, results_folder, name, plot_properties, lms_index=None, prefix='', value_range=None, log_scale=True, camera_direction=None, show_time=False, save_animation=False, layout=None)
Plot and save visualization of the specified f_lms in 2D.
- Parameters:
solution (
SourceProxy) – The simulation or computation result containing the data to plot.results_folder (
str) – Path to the folder where results (images/animations) will be saved.name (
str) – Name of the layout and image/animation files.plot_properties (
PlotPropertiesVFP) – Properties for plotting.lms_index (
Optional[tuple[int,int,int]]) – The index(l,m,s)to plot.prefix (
str) – Prefix for quantity name.value_range (
Optional[tuple[float,float]]) – Minimal (value_range[0]) and maximal (value_range[1]) value for the y-axes.log_scale (
bool) – Use a logarithmic color scale?camera_direction (
Optional[list[float]]) – Direction of the camera.show_time (
bool) – Display the simulation time in the render view.save_animation (
bool) – Save an animation of the plot.layout (
Optional[ViewLayoutProxy]) – The layout object where the plot should be added as new view. Will create a new one if none if provided.
- Return type:
tuple[ViewLayoutProxy,Proxy]- Returns:
layout (ViewLayoutProxy) – The layout object used for the plot.
render_view (RenderViewProxy) – The configured 2D render view.
See also
sapphireppplot.pvplot.plot_render_view_2dPlot 2D RenderView.
sapphireppplot.pvplot.display_timeDisplay time.
- sapphireppplot.vfp.plot_f_lms_3d(solution, results_folder, name, plot_properties, lms_index=None, prefix='', value_range=None, log_scale=True, camera_direction=None, show_time=False, save_animation=False, layout=None)
Plot and save visualization of the specified f_lms in 3D.
- Parameters:
solution (
SourceProxy) – The simulation or computation result containing the data to plot.results_folder (
str) – Path to the folder where results (images/animations) will be saved.name (
str) – Name of the layout and image/animation files.plot_properties (
PlotPropertiesVFP) – Properties for plotting.lms_index (
Optional[tuple[int,int,int]]) – The index(l,m,s)to plot.prefix (
str) – Prefix for quantity name.value_range (
Optional[tuple[float,float]]) – Minimal (value_range[0]) and maximal (value_range[1]) value for the y-axes.log_scale (
bool) – Use a logarithmic color scale?camera_direction (
Optional[list[float]]) – Direction of the camera.show_time (
bool) – Display the simulation time in the render view.save_animation (
bool) – Save an animation of the plot.layout (
Optional[ViewLayoutProxy]) – The layout object where the plot should be added as new view. Will create a new one if none if provided.
- Return type:
tuple[ViewLayoutProxy,Proxy]- Returns:
layout (ViewLayoutProxy) – The layout object used for the plot.
render_view (RenderViewProxy) – The configured 3D render view.
See also
sapphireppplot.pvplot.plot_render_view_3dPlot 3D RenderView.
sapphireppplot.pvplot.display_timeDisplay time.
- sapphireppplot.vfp.plot_f_lms_over_x(solution, results_folder, name, plot_properties, lms_indices=None, direction='x', offset=None, x_axes_scale=None, x_label=None, x_range=None, value_range=None, log_x_scale=False, log_y_scale=False, save_animation=False, layout=None)
Take and plot slice along a spatial dimension of the solution.
- Parameters:
solution (
SourceProxy) – The simulation or computation result containing the data to plot.results_folder (
str) – Path to the folder where results (images/animations) will be saved.name (
str) – Name of the layout and image/animation files.plot_properties (
PlotPropertiesVFP) – Properties for plotting.lms_indices (
Optional[Sequence[tuple[int,int,int]]]) – The list of indices[(l_1,m_1,s_1), (l_2,m_2,s_2)]to plot.direction (
Union[Literal['x','y','z','d'],tuple[tuple[float,float,float],tuple[float,float,float]]]) – Direction of the line.offset (
Optional[tuple[float,float,float]]) – Offset of the line.x_axes_scale (
Optional[float]) – Divide the x-axes coordinate by this scale.x_label (
Optional[str]) – Label for the bottom axis of the chart.x_range (
Optional[tuple[float,float]]) – Minimal (x_range[0]) and maximal (x_range[1]) value for the x-axes.value_range (
Optional[tuple[float,float]]) – Minimal (value_range[0]) and maximal (value_range[1]) value for the y-axes.log_x_scale (
bool) – Use a logarithmic x-scale?log_y_scale (
bool) – Use a logarithmic y-scale?save_animation (
bool) – Save an animation of the plot.layout (
Optional[ViewLayoutProxy]) – The layout object where the plot should be added as new view. Will create a new one if none if provided.
- Return type:
tuple[SourceProxy,ViewLayoutProxy,Proxy]- Returns:
plot_over_line_x (SourceProxy) – The PlotOverLine source.
layout (ViewLayoutProxy) – The layout object used for the plot.
line_chart_view (XYChartViewProxy) – The configured XY chart view.
See also
sapphireppplot.transform.plot_over_lineCreate PlotOverLine.
sapphireppplot.pvplot.plot_line_chart_viewPlot LineChartView.
- sapphireppplot.vfp.plot_f_lms_over_p(solution, results_folder, name, plot_properties, lms_indices=None, direction='', offset=None, x_range=None, value_range=None, log_x_scale=False, log_y_scale=True, save_animation=False, layout=None)
Take and plot slice along the p direction of the solution.
- Parameters:
solution (
SourceProxy) – The simulation or computation result containing the data to plot.results_folder (
str) – Path to the folder where results (images/animations) will be saved.name (
str) – Name of the layout and image/animation files.plot_properties (
PlotPropertiesVFP) – Properties for plotting.lms_indices (
Optional[Sequence[tuple[int,int,int]]]) – The list of indices[(l_1,m_1,s_1), (l_2,m_2,s_2)]to plot.direction (
Union[Literal[''],tuple[tuple[float,float,float],tuple[float,float,float]]]) – Direction of the line.offset (
Optional[tuple[float,float,float]]) – Offset of the line.x_range (
Optional[tuple[float,float]]) – Minimal (x_range[0]) and maximal (x_range[1]) value for the x-axes.value_range (
Optional[tuple[float,float]]) – Minimal (value_range[0]) and maximal (value_range[1]) value for the y-axes.log_x_scale (
bool) – Use a logarithmic x-scale?log_y_scale (
bool) – Use a logarithmic y-scale?save_animation (
bool) – Save an animation of the plot.layout (
Optional[ViewLayoutProxy]) – The layout object where the plot should be added as new view. Will create a new one if none if provided.
- Return type:
tuple[SourceProxy,ViewLayoutProxy,Proxy]- Returns:
plot_over_line_x (SourceProxy) – The PlotOverLine source.
layout (ViewLayoutProxy) – The layout object used for the plot.
line_chart_view (XYChartViewProxy) – The configured XY chart view.
See also
sapphireppplot.transform.plot_over_lineCreate PlotOverLine.
sapphireppplot.pvplot.plot_line_chart_viewPlot LineChartView.
- sapphireppplot.vfp.plot_phase_space_surface(solution, results_folder, name, plot_properties, value_range=None, log_scale=True, show_time=False, save_animation=False, layout=None)
Plot and save a \(\cos(\theta) - \phi\) plot of the phase space distribution.
- Parameters:
solution (
SourceProxy) – The simulation or computation result containing the data to plot.results_folder (
str) – Path to the folder where results (images/animations) will be saved.name (
str) – Name of the layout and image/animation files.plot_properties (
PlotProperties) – Properties for plotting.value_range (
Optional[tuple[float,float]]) – Minimal (value_range[0]) and maximal (value_range[1]) value for the color bar.log_scale (
bool) – Use a logarithmic color scale?show_time (
bool) – Display the simulation time in the render view.save_animation (
bool) – Save an animation of the plot.layout (
Optional[ViewLayoutProxy]) – The layout object where the plot should be added as new view. Will create a new one if none if provided.
- Return type:
tuple[ViewLayoutProxy,Proxy]- Returns:
layout (ViewLayoutProxy) – The layout object used for the plot.
render_view (RenderViewProxy) – The configured 2D render view.
See also
load_probe_location_surfaceLoad phase space surface.
sapphireppplot.pvplot.plot_render_view_2dPlot 2D RenderView.
sapphireppplot.pvplot.display_timeDisplay time.
- sapphireppplot.vfp.plot_elevated_phase_space_surface(solution, results_folder, name, plot_properties, scale_factor=1.0, value_range=None, log_scale=False, save_animation=False, layout=None)
Plot and save an elevated surface plot of the phase space distribution.
- Parameters:
solution (
SourceProxy) – The simulation or computation result containing the data to plot.results_folder (
str) – Path to the folder where results (images/animations) will be saved.name (
str) – Name of the layout and image/animation files.plot_properties (
PlotProperties) – Properties for plotting.scale_factor (
float) – Scaling factor for the warp in z-direction.value_range (
Optional[tuple[float,float]]) – Minimal (value_range[0]) and maximal (value_range[1]) value for the color bar.log_scale (
bool) – Use a logarithmic color scale?save_animation (
bool) – Save an animation of the plot.layout (
Optional[ViewLayoutProxy]) – The layout object where the plot should be added as new view. Will create a new one if none if provided.
- Return type:
tuple[ViewLayoutProxy,Proxy]- Returns:
layout (ViewLayoutProxy) – The layout object used for the plot.
render_view (RenderViewProxy) – The configured 3D render view.
See also
load_probe_location_surfaceLoad phase space surface.
sapphireppplot.pvplot.plot_render_view_3dPlot 3D RenderView.
sapphireppplot.pvplot.display_timeDisplay time.
- sapphireppplot.vfp.plot_phase_space_spherical_density_map(solution, results_folder, name, plot_properties, value_range=None, log_scale=True, camera_direction=None, show_time=False, save_animation=False, layout=None)
Plot and save a spherical density map of the phase space distribution.
- Parameters:
solution (
SourceProxy) – The simulation or computation result containing the data to plot.results_folder (
str) – Path to the folder where results (images/animations) will be saved.name (
str) – Name of the layout and image/animation files.plot_properties (
PlotProperties) – Properties for plotting.value_range (
Optional[tuple[float,float]]) – Minimal (value_range[0]) and maximal (value_range[1]) value for the color bar.log_scale (
bool) – Use a logarithmic color scale?camera_direction (
Optional[list[float]]) – Direction of the camera.show_time (
bool) – Display the simulation time in the render view.save_animation (
bool) – Save an animation of the plot.layout (
Optional[ViewLayoutProxy]) – The layout object where the plot should be added as new view. Will create a new one if none if provided.
- Return type:
tuple[ViewLayoutProxy,Proxy]- Returns:
layout (ViewLayoutProxy) – The layout object used for the plot.
render_view (RenderViewProxy) – The configured 3D render view.
See also
load_probe_location_surfaceLoad phase space surface.
sapphireppplot.pvplot.plot_render_view_3dPlot 3D RenderView.
sapphireppplot.pvplot.display_timeDisplay time.