numpyify module

Convert ParaView data to numpy arrays.

sapphireppplot.numpyify.to_numpy_1d(solution, array_names, x_direction=0, x_min=None, x_max=None, time=None)

Convert 1D data, e.g. from PlotOverLine, to a numpy array.

Parameters:
  • solution (SourceProxy) – ParaView solution data.

  • array_names (Sequence[str]) – List of array names that should be extracted.

  • x_direction (int) – The of the x-axes to extract.

  • x_min (Optional[float]) – If set, only return the data x >= x_min.

  • x_max (Optional[float]) – If set, only return the data x <= x_max.

  • time (Optional[float]) – Time at which to extract the solution. This (should) default to the current animation time, but in non-interactive sessions this can break. Setting an explicit time avoids this issue.

Return type:

tuple[ndarray[tuple[int], dtype[float16] | dtype[float32] | dtype[float64]], ndarray[tuple[int, int], dtype[float16] | dtype[float32] | dtype[float64]]]

Returns:

  • x_values (np.ndarray) – The x vales as np.ndarray.

  • data (np.ndarray) – 2D array data[c][i] with the data from the solution. The first index c corresponds to array_names[c], the second index corresponds to the x_array[i].

Raises:

KeyError – If array_name is not available.

sapphireppplot.numpyify.to_numpy_point_list(solution, array_names)

Convert data to a numpy arrays with the data evaluated at the cell centers.

Parameters:
  • solution (SourceProxy) – ParaView solution data.

  • array_names (Sequence[str]) – List of array names that should be extracted.

Return type:

tuple[ndarray[tuple[int, int], dtype[float16] | dtype[float32] | dtype[float64]], ndarray[tuple[int, int], dtype[float16] | dtype[float32] | dtype[float64]]]

Returns:

  • points (np.ndarray) – The x/y/z-values of the points as a list: points[i] = [x, y, z].

  • data (np.ndarray) – 2D array data[c][i] with the data from the solution. The first index c corresponds to array_names[c], the second index to the point points[i].

Raises:

KeyError – If array_name is not available.

See also

paraview.simple.CellCenters

ParaView CellCenters filter.

paraview.simple.PointDatatoCellData

ParaView PointDatatoCellData filter.

sapphireppplot.numpyify.to_numpy_2d(solution, array_names)

Convert 2D data to a numpy array with the data evaluated at the cell centers.

Parameters:
  • solution (SourceProxy) – ParaView solution data.

  • array_names (Sequence[str]) – List of array names that should be extracted.

Return type:

tuple[ndarray[tuple[int, int, int], dtype[float16] | dtype[float32] | dtype[float64]], ndarray[tuple[int, int, int], dtype[float16] | dtype[float32] | dtype[float64]]]

Returns:

  • points (np.ndarray) – The x/y/z-values of the points organized in a 2D grid: points[i][j] = [x, y, z]. Sorted so that x corresponds to i and y to j.

  • data (np.ndarray) – 3D array data[c][i][j] with the data from the solution. The first index c corresponds to array_names[c], the second index and third corresponds to points[i][j].

See also

to_numpy_point_list

Get numpy arrays of data as point list.

sapphireppplot.numpyify.to_numpy_3d(solution, array_names)

Convert 3D data to a numpy array with the data evaluated at the cell centers.

Parameters:
  • solution (SourceProxy) – ParaView solution data.

  • array_names (Sequence[str]) – List of array names that should be extracted.

Return type:

tuple[ndarray[tuple[int, int, int, int], dtype[float16] | dtype[float32] | dtype[float64]], ndarray[tuple[int, int, int, int], dtype[float16] | dtype[float32] | dtype[float64]]]

Returns:

  • points (np.ndarray) – The x/y/z-values of the points organized in a 3D grid: points[i][j][k] = [x, y, z]. Sorted so that x corresponds to i, y to j and z to k.

  • data (np.ndarray) – 4D array data[c][i][j][k] with the data from the solution. The first index c corresponds to array_names[c], the second, third and forth index corresponds to points[i][j][k].

See also

to_numpy_point_list

Get numpy arrays of data as point list.

sapphireppplot.numpyify.to_numpy_time_steps(solution, animation_scene, array_names, time_steps=None)

Retrieve data at given time steps and converts them to cell-centred numpy arrays.

Makes no assumption on the grid. It can be irregular and change over time.

Parameters:
  • solution (SourceProxy) – ParaView solution data.

  • animation_scene (Proxy) – The ParaView AnimationScene.

  • array_names (Sequence[str]) – List of array names that should be extracted.

  • time_steps (Optional[Iterable[float]]) – List of time steps to extract the data. Defaults to using all time steps.

Return type:

tuple[list[float], list[ndarray[tuple[int, int], dtype[float16] | dtype[float32] | dtype[float64]]], list[ndarray[tuple[int, int], dtype[float16] | dtype[float32] | dtype[float64]]]]

Returns:

  • time_steps (list[float]) – The time steps: time_steps[t] = time where t is the index of the time step.

  • points (list[np.ndarray]) – The x/y/z-values of the points as a list at time t: points[t][i] = [x, y, z].

  • data (list[np.ndarray]) – List of 2D arrays data[t][c][i] with the data from the solution. The first index corresponds to time_steps[t], the second index c to array_names[c], the third index to the point points[t][i].

Raises:
  • KeyError – Throws an error if the array_name is not available.

  • AttributeError – If solution.TimestepValues is not a property of the solution object. This commonly occurs, if the solution is a derived object, e.g. a paraview.simple.Calculator. To fix parse the time_steps argument explicitly.

See also

paraview.simple.CellCenters :

ParaView CellCenters filter.

paraview.simple.PointDatatoCellData :

ParaView PointDatatoCellData filter.

paraview.simple.proxy.UpdatePipeline :

ParaView method to set the time.

sapphireppplot.numpyify.to_numpy_time_steps_2d(solution, animation_scene, array_names, time_steps=None)

Convert time dependent 2D data to a numpy array with the data evaluated at the cell centers.

Assumes that the grid is regular and is constant over time.

Parameters:
  • solution (SourceProxy) – ParaView solution data.

  • animation_scene (Proxy) – The ParaView AnimationScene.

  • array_names (Sequence[str]) – List of array names that should be extracted.

  • time_steps (Optional[Iterable[float]]) – List of time steps to extract the data. Defaults to using all time steps.

Return type:

tuple[ndarray[tuple[int], dtype[float16] | dtype[float32] | dtype[float64]], ndarray[tuple[int, int, int], dtype[float16] | dtype[float32] | dtype[float64]], ndarray[tuple[int, int, int, int], dtype[float16] | dtype[float32] | dtype[float64]]]

Returns:

  • time_steps (np.ndarray) – The time steps: time_steps[t] = time where t is the index of the time step.

  • points (np.ndarray) – The x/y/z-values of the points organized in a 2D grid: points[i][j] = [x, y, z]. Sorted so that x corresponds to i and y to j.

  • data (np.ndarray) – 4D array data[t][c][i][j] with the data from the solution. The first index t corresponds to time_steps[t], the second index c to array_names[c], the third and forth index corresponds to points[i][j].

See also

to_numpy_time_steps

Get numpy arrays of data as point list for multiple time steps.

sapphireppplot.numpyify.to_numpy_time_steps_3d(solution, animation_scene, array_names, time_steps=None)

Convert time dependent 3D data to a numpy array with the data evaluated at the cell centers.

Assumes that the grid is regular and is constant over time.

Parameters:
  • solution (SourceProxy) – ParaView solution data.

  • animation_scene (Proxy) – The ParaView AnimationScene.

  • array_names (Sequence[str]) – List of array names that should be extracted.

  • time_steps (Optional[Sequence[float]]) – List of time steps to extract the data. Defaults to using all time steps.

Return type:

tuple[ndarray[tuple[int], dtype[float16] | dtype[float32] | dtype[float64]], ndarray[tuple[int, int, int, int], dtype[float16] | dtype[float32] | dtype[float64]], ndarray[tuple[int, int, int, int, int], dtype[float16] | dtype[float32] | dtype[float64]]]

Returns:

  • time_steps (np.ndarray) – The time steps: time_steps[t] = time where t is the index of the time step.

  • points (np.ndarray) – The x/y/z-values of the points organized in a 3D grid: points[i][j][k] = [x, y, z]. Sorted so that x corresponds to i, y to j and z to k.

  • data (np.ndarray) – 5D array data[t][c][i][j][k] with the data from the solution. The first index t corresponds to time_steps[t], the second index c to array_names[c], the third, forth and fifth index corresponds to points[i][j][k].

See also

to_numpy_time_steps

Get numpy arrays of data as point list for multiple time steps.

sapphireppplot.numpyify.to_numpy_integrate_variables(solution, array_names, time_steps=None)

Integrate variables over the grid at given time steps and return as numpy arrays.

Parameters:
  • solution (SourceProxy) – ParaView solution data.

  • array_names (Sequence[str]) – List of array names that should be integrated and extracted.

  • time_steps (Optional[Iterable[float]]) – List of time steps to extract the data. Defaults to using all time steps.

Return type:

tuple[ndarray[tuple[int], dtype[float16] | dtype[float32] | dtype[float64]], ndarray[tuple[int], dtype[float16] | dtype[float32] | dtype[float64]], ndarray[tuple[int, int], dtype[float16] | dtype[float32] | dtype[float64]]]

Returns:

  • time_steps (np.ndarray) – The time steps: time_steps[t] = time where t is the index of the time step.

  • volume (np.ndarray) – The volume (length/area/volume in 1D/2D/3D) of the grid at time t.

  • integrated_variables (np.ndarray) – 2D array integrated_variables[t][c] with the integrated variables. The first index corresponds to time_steps[t], the second index c to array_names[c]. The integrated variables are not divided by the volume.

Raises:
  • KeyError – If array_name is not available.

  • AttributeError – If solution.TimestepValues is not a property of the solution object. This commonly occurs, if the solution is a derived object, e.g. a paraview.simple.Calculator. To fix parse the time_steps argument explicitly.

See also

paraview.simple.IntegrateVariables :

ParaView IntegrateVariables filter.

paraview.simple.proxy.UpdatePipeline :

ParaView method to set the time.

sapphireppplot.numpyify.to_numpy_over_time(solution, array_names, time_array_name='Time')

Convert PlotOverTime data to a numpy array.

Parameters:
  • solution (SourceProxy) – ParaView solution data.

  • array_names (Sequence[str]) – List of array names that should be extracted.

  • time_array_name (str) – Name of the time array.

Return type:

tuple[ndarray[tuple[int], dtype[float16] | dtype[float32] | dtype[float64]], ndarray[tuple[int, int], dtype[float16] | dtype[float32] | dtype[float64]]]

Returns:

  • time_steps (np.ndarray) – The time steps as np.ndarray.

  • data (np.ndarray) – 2D array data[c][i] with the data from the solution. The first index c corresponds to array_names[c], the second index corresponds to the time_steps[i].

Raises:

KeyError – If array_name is not available.

See also

sapphireppplot.transform.plot_over_time

Get temporal evolution of the solution.