transform module

Transform the solution, e.g. by PlotOverLine or Calculator.

sapphireppplot.transform.create_extractor(solution, filename, file_format='pvtp', plot_properties=None)

Create a extractor of the solution.

Important

This function only prepares the extracts, it does not save them. To save the extracts call save_extracts().

This function assumes that the solution is already an extract of the full data, e.g. as a result of slice_plane().

Parameters:
  • solution (SourceProxy) – The extract of the full solution to save.

  • filename (str) – The base name for the extracts (without extension).

  • file_format (Literal['pvtu', 'pvtp']) – Format to save the extract to. Use “pvtp” for sliced planes with crinkle_slice=False.

  • plot_properties (Optional[TypeVar(PlotPropertiesVar, bound= PlotProperties)]) – Properties of the solution.

Return type:

Proxy

Returns:

extractor (Proxy) – The extractor to VTP/VTU files.

Raises:

ValueError – If file_format is not supported.

sapphireppplot.transform.save_extracts(results_folder, animation_scene, subfolder='extracts', frame_window=None, plot_properties=None)

Save the extracts of the solution created with create_extractor().

Note, this function is expensive as it iterates over all time steps. Note, sets the animation time to the last time step.

Parameters:
  • results_folder (str) – The parent directory path where the extracts will be saved.

  • animation_scene (Proxy) – The ParaView AnimationScene.

  • subfolder (str) – The subfolder to save the extracts.

  • frame_window (Optional[tuple[int, int]]) – The range of timesteps to extract.

  • plot_properties (Optional[TypeVar(PlotPropertiesVar, bound= PlotProperties)]) – Properties of the solution.

Return type:

None

sapphireppplot.transform.calculator(solution, quantity, formula, label=None, plot_properties_in=None)

Create a ParaView Calculator and add the new quantity to the PlotProperties.

Parameters:
  • solution (SourceProxy) – The data source.

  • quantity (str) – Name of the quantity to compute.

  • formula (str) – Formula to compute the quantity as ParaView Function.

  • label (Optional[str]) – Label for the quantity. Default to quantity.

  • plot_properties_in (Optional[TypeVar(PlotPropertiesVar, bound= PlotProperties)]) – Properties of the solution.

Return type:

tuple[SourceProxy, TypeVar(PlotPropertiesVar, bound= PlotProperties)]

Returns:

  • calculator_source (SourceProxy) – The calculator source.

  • plot_properties (PlotPropertiesVar) – The PlotProperties including the new quantity.

See also

paraview.simple.Calculator

ParaView Calculator filter.

sapphireppplot.transform.point_data_to_cell_data(solution, plot_properties_in=None)

Convert point data to cell data.

Parameters:
  • solution (SourceProxy) – The data source with point data.

  • plot_properties_in (Optional[TypeVar(PlotPropertiesVar, bound= PlotProperties)]) – Properties of the solution.

Return type:

tuple[SourceProxy, TypeVar(PlotPropertiesVar, bound= PlotProperties)]

Returns:

  • cell_data (SourceProxy) – The solution as cell data.

  • plot_properties (PlotPropertiesVar) – The PlotProperties for the cell data.

See also

paraview.simple.PointDatatoCellData

ParaView filter to convert point data to cell data.

sapphireppplot.plot_properties.PlotProperties.data_type

Solution data type.

sapphireppplot.transform.plot_over_line(solution, direction='x', offset=None, x_range=None, x_axes_scale=None, results_folder='', filename=None, plot_properties=None)

Create and configure plot over line from solution.

Parameters:
  • solution (SourceProxy) – The data source.

  • direction (Union[Literal['x', 'y', 'z', 'd'], tuple[tuple[float, float, float], tuple[float, float, float]]]) –

    Direction of the line for the line-out. Can be either:

    • "x", "y", "z" for a line along coordinate axes.

    • "d" for a line along the diagonal.

    • Tuple with start and end points: ((x_1,y_1,z_1), (x_2,y_2,z_2)).

  • offset (Optional[tuple[float, float, float]]) – Offset of the line-out. Only used for direction = "x"/"y"/"z".

  • x_range (Optional[tuple[float, float]]) – Start (x_range[0]) and end-coordinate (x_range[1]) for line-out along the coordinate axes. Only used for direction = "x"/"y"/"z".

  • x_axes_scale (Optional[float]) – Divide the x-axes coordinate by this scale. The scaled axes will be stored in a variable scaled_axes.

  • results_folder (str) – The directory path where the data will be saved as .csv.

  • filename (Optional[str]) – The base name for the saved data file (without extension). If no filename is given, the data is not saved.

  • plot_properties (Optional[TypeVar(PlotPropertiesVar, bound= PlotProperties)]) – Properties of the solution, like the sampling pattern.

Return type:

SourceProxy

Returns:

plot_over_line_source (SourceProxy) – The PlotOverLine source.

sapphireppplot.transform.slice_plane(solution, normal, origin=(0.0, 0.0, 0.0), crinkle_slice=False, plot_properties=None)

Slice a 2D plane from a 3D solution.

Parameters:
  • solution (SourceProxy) – The data source.

  • normal (tuple[float, float, float]) – Normal of the plane.

  • origin (tuple[float, float, float]) – Origin of the plane.

  • crinkle_slice (bool) – This parameter controls whether to extract the entire cells that are sliced by the region or just extract a triangulated surface of that region. If postprocessing is to be done on the data, e.g. using the sapphireppplot.numpyify module, crinkle_slice=True is recommended.

  • plot_properties (Optional[TypeVar(PlotPropertiesVar, bound= PlotProperties)]) – Properties of the solution.

Return type:

SourceProxy

Returns:

slice_plane (SourceProxy) – The 2D slice of the solution.

See also

paraview.simple.Slice

ParaView Slice filter.

Note

When using the sapphireppplot.pvplot.plot_render_view_2d() function to visualize the slice, the camera_direction parameter can be used to adjust set the view in the normal direction.

sapphireppplot.transform.probe_location(solution, point, plot_properties_in=None)

Probe location at one point.

Parameters:
  • solution (SourceProxy) – The data source.

  • point (tuple[float, float, float]) – The point where to evaluate the time evolution.

  • plot_properties_in (Optional[TypeVar(PlotPropertiesVar, bound= PlotProperties)]) – Properties of the solution, like the sampling resolution.

Return type:

tuple[SourceProxy, TypeVar(PlotPropertiesVar, bound= PlotProperties)]

Returns:

  • probe_location_source (SourceProxy) – The ProbeLocation source.

  • plot_properties (PlotPropertiesVar) – The PlotProperties for ProbeLocation.

sapphireppplot.transform.integrate_variables(solution, plot_properties_in=None)

Integrate variables over the grid.

The integrated quantities are divided by the grid volume/area. For this, the solution is converted to cell data.

Parameters:
  • solution (SourceProxy) – The data source.

  • plot_properties_in (Optional[TypeVar(PlotPropertiesVar, bound= PlotProperties)]) – Properties of the solution.

Return type:

tuple[SourceProxy, TypeVar(PlotPropertiesVar, bound= PlotProperties)]

Returns:

  • integrate_variables_source (SourceProxy) – The IntegrateVariables source.

  • plot_properties (PlotPropertiesVar) – The PlotProperties for IntegrateVariables.

See also

paraview.simple.IntegrateVariables

ParaView filter to integrate variables.

point_data_to_cell_data

Convert point data to cell data.

sapphireppplot.transform.plot_over_time(solution, t_axes_scale=None, results_folder='', filename=None, plot_properties_in=None)

Get temporal evolution of the solution.

Assumes that the solution only contains one point. I.e. that the solution is either a result of probe_location() or integrate_variables().

Parameters:
  • solution (SourceProxy) – The data source. Should one contain one data point.

  • t_axes_scale (Optional[float]) – Divide the time-axes by this scale. The scaled axes will be stored in a variable scaled_t_axes.

  • results_folder (str) – The directory path where the data will be saved as .csv.

  • filename (Optional[str]) – The base name for the saved data file (without extension). If no filename is given, the data is not saved.

  • plot_properties_in (Optional[TypeVar(PlotPropertiesVar, bound= PlotProperties)]) – Properties of the solution.

Return type:

tuple[SourceProxy, TypeVar(PlotPropertiesVar, bound= PlotProperties)]

Returns:

  • plot_over_time_source (SourceProxy) – The PlotOverTime source.

  • plot_properties (PlotPropertiesVar) – The PlotProperties for PlotOverTime.

See also

paraview.simple.PlotDataOverTime

ParaView PlotDataOverTime filter.

sapphireppplot.transform.clip_area(solution, x_range=None, y_range=None, z_range=None, plot_properties=None)

Clip area from solution.

Parameters:
  • solution (SourceProxy) – The data source.

  • x_range (Optional[tuple[float, float]]) – Clip range in x, x_range = [x_min, x_max].

  • y_range (Optional[tuple[float, float]]) – Clip range in y, y_range = [y_min, y_max].

  • z_range (Optional[tuple[float, float]]) – Clip range in z, z_range = [z_min, z_max].

  • plot_properties (Optional[TypeVar(PlotPropertiesVar, bound= PlotProperties)]) – Properties of the solution, like the sampling pattern.

Return type:

SourceProxy

Returns:

clipped_solution (SourceProxy) – The clipped source.

See also

paraview.simple.Clip

ParaView Clip filter.

sapphireppplot.transform.contour_lines(solution, quantity, isosurfaces, plot_properties_in=None)

Create contour lines of a quantity from the solution.

The contour_lines can be added to an existing render_view using pvplot.show_overlay_2d().

Parameters:
  • solution (SourceProxy) – The data source.

  • quantity (str) – Name of the quantity for contour lines.

  • isosurfaces (Sequence[float]) – The value of the isosurfaces.

  • plot_properties – Properties of the solution.

Return type:

tuple[SourceProxy, TypeVar(PlotPropertiesVar, bound= PlotProperties)]

Returns:

  • contour_source (SourceProxy) – The Contour source.

  • plot_properties (PlotPropertiesVar) – The PlotProperties for contour lines.

See also

paraview.simple.Contour

ParaView Contour filter.

sapphireppplot.transform.stream_tracer(solution, quantity, direction='x', offset=None, x_range=None, n_lines=30, plot_properties_in=None)

Create stream tracer of a quantity from the solution.

The stream_tracer can be added to an existing render_view using pvplot.show_overlay_2d().

Parameters:
  • solution (SourceProxy) – The data source.

  • quantity (str) – Name of the quantity for the stream tracer.

  • direction (Union[Literal['x', 'y', 'z', 'd'], tuple[tuple[float, float, float], tuple[float, float, float]]]) –

    Direction of the tracer seed line. Can be either:

    • "x", "y", "z" for a line along coordinate axes.

    • "d" for a line along the diagonal.

    • Tuple with start and end points: ((x_1,y_1,z_1), (x_2,y_2,z_2)).

  • offset (Optional[tuple[float, float, float]]) – Offset of the tracer seed line. Only used for direction = "x"/"y"/"z".

  • x_range (Optional[tuple[float, float]]) – Start (x_range[0]) and end-coordinate (x_range[1]) for tracer seed line along the coordinate axes. Only used for direction = "x"/"y"/"z".

  • n_lines (int) – Number of stream lines.

  • plot_properties – Properties of the solution.

Return type:

tuple[SourceProxy, TypeVar(PlotPropertiesVar, bound= PlotProperties)]

Returns:

  • stream_tracer_source (SourceProxy) – The StreamTracer source.

  • plot_properties (PlotPropertiesVar) – The PlotProperties for StreamTracer.