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 datax >= x_min.x_max (
Optional[float]) – If set, only return the datax <= 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 indexccorresponds toarray_names[c], the second index corresponds to thex_array[i].
- Raises:
KeyError – If
array_nameis 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 indexccorresponds toarray_names[c], the second index to the pointpoints[i].
- Raises:
KeyError – If
array_nameis 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 thatxcorresponds toiandytoj.data (np.ndarray) – 3D array
data[c][i][j]with the data from the solution. The first indexccorresponds toarray_names[c], the second index and third corresponds topoints[i][j].
See also
to_numpy_point_listGet 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 thatxcorresponds toi,ytojandztok.data (np.ndarray) – 4D array
data[c][i][j][k]with the data from the solution. The first indexccorresponds toarray_names[c], the second, third and forth index corresponds topoints[i][j][k].
See also
to_numpy_point_listGet 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] = timewheretis 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 totime_steps[t], the second indexctoarray_names[c], the third index to the pointpoints[t][i].
- Raises:
KeyError – Throws an error if the
array_nameis not available.AttributeError – If
solution.TimestepValuesis not a property of thesolutionobject. This commonly occurs, if thesolutionis a derived object, e.g. a paraview.simple.Calculator. To fix parse thetime_stepsargument 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] = timewheretis 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 thatxcorresponds toiandytoj.data (np.ndarray) – 4D array
data[t][c][i][j]with the data from the solution. The first indextcorresponds totime_steps[t], the second indexctoarray_names[c], the third and forth index corresponds topoints[i][j].
See also
to_numpy_time_stepsGet 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] = timewheretis 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 thatxcorresponds toi,ytojandztok.data (np.ndarray) – 5D array
data[t][c][i][j][k]with the data from the solution. The first indextcorresponds totime_steps[t], the second indexctoarray_names[c], the third, forth and fifth index corresponds topoints[i][j][k].
See also
to_numpy_time_stepsGet 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] = timewheretis 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 totime_steps[t], the second indexctoarray_names[c]. The integrated variables are not divided by the volume.
- Raises:
KeyError – If
array_nameis not available.AttributeError – If
solution.TimestepValuesis not a property of thesolutionobject. This commonly occurs, if thesolutionis a derived object, e.g. a paraview.simple.Calculator. To fix parse thetime_stepsargument 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 indexccorresponds toarray_names[c], the second index corresponds to thetime_steps[i].
- Raises:
KeyError – If
array_nameis not available.
See also
sapphireppplot.transform.plot_over_timeGet temporal evolution of the solution.