satanic module

Module for SATANIC (Solving Acceleration, Transport And Non-thermal Interactions in star Clusters) specific plotting.

sapphireppplot.satanic.load_solution(path_prefix='', results_folder='', base_file_name='solution', animation_time=None, plot_properties_in=None)

Load solution for SATANIC.

This function performs the following steps:

  1. Retrieves the folder containing simulation results.

  2. Loads the parameter file.

  3. Loads the solution data from the files in the results folder.

  4. Adds time step information if necessary.

  5. Updates the animation scene to the specified animation time.

Parameters:
  • path_prefix (str) – Prefix for relative path.

  • results_folder (str) – The path to the results folder.

  • base_file_name (str) – 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.

  • plot_properties_in (Optional[PlotPropertiesSatanic]) – Properties of the solution.

Return type:

tuple[str, Dict[str, Any], SourceProxy, Proxy, PlotPropertiesSatanic]

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.

  • plot_properties (PlotPropertiesSatanic) – Properties of the solution as deduced from the parameters.

Raises:

ValueError – If no matching files are found.

See also

sapphireppplot.pvload

Module to load ParaView files.

sapphireppplot.utils.get_results_folder

Prompt for results folder.

sapphireppplot.plot_properties.PlotProperties.series_names

Series names list to load.

sapphireppplot.satanic.to_numpy(solution, animation_scene, plot_properties, time_steps=None)

Convert time dependent ParaView solution to a numpy array with the data evaluated at the cell centers.

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

  • animation_scene (Proxy) – The ParaView AnimationScene.

  • plot_properties (PlotPropertiesSatanic) – Properties of the solution.

  • 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], dtype[float16] | dtype[float32] | dtype[float64]], ndarray[tuple[int], dtype[float16] | dtype[float32] | dtype[float64]], ndarray[tuple[int], dtype[float16] | dtype[float32] | dtype[float64]], ndarray[tuple[int, int, int, int], dtype[float16] | dtype[float32] | dtype[float64]]]

Returns:

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

  • r (np.ndarray) – The radius \(r\): r[i] = r_i where i is the index of the radius.

  • ln_p (np.ndarray) – The logarithmic momentum \(\ln(p)\): ln_p[j] = ln_p_j where j is the index of the momentum.

  • mu (np.ndarray) – The azimuth angle \(\mu = \cos(\theta)\): mu[k] = mu_k where k is the index of the azimuth angle.

  • f (np.ndarray) – The distribution function \(F = p^s f\) as a 4D numpy array: f[n][i][j][k]. The first index n corresponds to t[n], the second index i to r[i], the third index j to ln_p[j] and the fourth index k to mu[k].

See also

sapphireppplot.numpify.to_numpy_time_steps_3d

Get numpy arrays.

sapphireppplot.satanic.convert_mu_to_theta(mu, f_mu)

Convert azimuthal angle from \(\mu\) to \(\theta = \arccos(\mu)\).

Extends \(f\) to span the full range from \(\theta=0^{\circ}\) to \(\theta=360^{\circ}\).

Parameters:
  • mu (ndarray[tuple[int], dtype[float16] | dtype[float32] | dtype[float64]]) – The azimuth angle \(\mu = \cos(\theta)\): mu[k] = mu_k where k is the index of the azimuth angle.

  • f_mu (ndarray[tuple[int, int], dtype[float16] | dtype[float32] | dtype[float64]]) – The distribution function \(F = p^s f\) as a function of \(\mu = \cos(\theta)\): f[i][k]. The first index i corresponds to r[i], and the last index k to mu[k].

Return type:

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

Returns:

  • theta (np.ndarray) – The azimuth angle \(\theta\) in radiants, running from \(\theta = \pi = 180^{\circ}\) to \(\theta = -\pi = -180^{\circ}\) theta[k] = theta_k where k is the index of the azimuth angle.

  • f (np.ndarray) – The distribution function \(F = p^s f\) as a 4D numpy array: f[n][i][j][k]. The first index n corresponds to t[n], the second index i to r[i], the third index j to ln_p[j] and the fourth index k to mu[k].

sapphireppplot.satanic.plot_f_2d(solution, results_folder, name, plot_properties, value_range=None, log_scale=True, show_time=False, save_animation=False, layout=None)

Plot and save visualization of F 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 (PlotPropertiesSatanic) – Properties for plotting.

  • 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?

  • 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.

sapphireppplot.satanic.plot_f_3d(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 visualization of F 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 (PlotPropertiesSatanic) – Properties for plotting.

  • 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.

sapphireppplot.satanic.plot_f_over_r(solution, animation_scene, plot_properties, ln_p=1.0, mu=0.0, time=None, results_folder='', filename=None)

Take line-out along \(r\) of the solution and convert it to numpy.

Parameters:
  • solution (SourceProxy) – The simulation or computation result containing the data to plot.

  • animation_scene (Proxy) – The ParaView AnimationScene.

  • plot_properties (PlotPropertiesSatanic) – Properties for plotting.

  • ln_p (float) – The logarithmic momentum \(\ln(p)\) where to plot the solution.

  • mu (float) – The azimuth angle \(\mu = \cos(\theta)\) where to plot the solution.

  • time (Optional[float]) – Time at which to extract the solution. Defaults to the last time step.

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

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

Return type:

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

Returns:

  • r (np.ndarray) – The radius \(r\).

  • f (np.ndarray) – The distribution function \(F = p^s f\).

sapphireppplot.satanic.plot_f_over_p(solution, animation_scene, plot_properties, r=1.0, mu=0.0, time=None, results_folder='', filename=None)

Take line-out along \(\ln(p)\) of the solution and convert it to numpy.

Parameters:
  • solution (SourceProxy) – The simulation or computation result containing the data to plot.

  • animation_scene (Proxy) – The ParaView AnimationScene.

  • plot_properties (PlotPropertiesSatanic) – Properties for plotting.

  • r (float) – The radius \(r\) where to plot the solution.

  • mu (float) – The azimuth angle \(\mu = \cos(\theta)\) where to plot the solution.

  • time (Optional[float]) – Time at which to extract the solution. Defaults to the last time step.

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

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

Return type:

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

Returns:

  • ln_p (np.ndarray) – The logarithmic momentum \(ln_p\).

  • f (np.ndarray) – The distribution function \(F = p^s f\).

sapphireppplot.satanic.plot_f_over_mu(solution, animation_scene, plot_properties, r=1.0, ln_p=1.0, time=None, results_folder='', filename=None)

Take line-out along \(\mu = \cos(\theta)\) of the solution and convert it to numpy.

Parameters:
  • solution (SourceProxy) – The simulation or computation result containing the data to plot.

  • animation_scene (Proxy) – The ParaView AnimationScene.

  • plot_properties (PlotPropertiesSatanic) – Properties for plotting.

  • r (float) – The radius \(r\) where to plot the solution.

  • ln_p (float) – The logarithmic momentum \(\ln(p)\) where to plot the solution.

  • time (Optional[float]) – Time at which to extract the solution. Defaults to the last time step.

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

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

Return type:

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

Returns:

  • mu (np.ndarray) – The azimuth angle \(\mu = \cos(\theta)\).

  • f (np.ndarray) – The distribution function \(F = p^s f\).

sapphireppplot.satanic.slice_plane_r_p(solution, animation_scene, plot_properties, mu=0.0, time=None, results_folder='', filename=None)

Slice 2D plane in \(r -\ln(p)\) of the solution and convert it to numpy.

Parameters:
  • solution (SourceProxy) – The simulation or computation result containing the data to plot.

  • animation_scene (Proxy) – The ParaView AnimationScene.

  • plot_properties (PlotPropertiesSatanic) – Properties for plotting.

  • mu (float) – The azimuth angle \(\mu = \cos(\theta)\) where to plot the solution.

  • time (Optional[float]) – Time at which to extract the solution. Defaults to the last time step.

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

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

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:

  • r (np.ndarray) – The radius \(r\): r[i] = r_i where i is the index of the radius.

  • ln_p (np.ndarray) – The logarithmic momentum \(\ln(p)\): ln_p[j] = ln_p_j where j is the index of the momentum.

  • f (np.ndarray) – The distribution function \(F = p^s f\) as a 2D numpy array: f[i][j]. The first index i corresponds to r[i] and the second index j to ln_p[j].

sapphireppplot.satanic.slice_plane_r_mu(solution, animation_scene, plot_properties, ln_p=1.0, time=None, results_folder='', filename=None)

Slice 2D plane in \(r -\mu\) of the solution and convert it to numpy.

Parameters:
  • solution (SourceProxy) – The simulation or computation result containing the data to plot.

  • animation_scene (Proxy) – The ParaView AnimationScene.

  • plot_properties (PlotPropertiesSatanic) – Properties for plotting.

  • ln_p (float) – The logarithmic momentum \(\ln(p)\) where to plot the solution.

  • time (Optional[float]) – Time at which to extract the solution. Defaults to the last time step.

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

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

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:

  • r (np.ndarray) – The radius \(r\): r[i] = r_i where i is the index of the radius.

  • mu (np.ndarray) – The azimuth angle \(\mu = \cos(\theta)\): mu[k] = mu_k where k is the index of the azimuth angle.

  • f (np.ndarray) – The distribution function \(F = p^s f\) as a 2D numpy array: f[i][k]. The first index i corresponds to r[i] and the second index k to mu[k].

sapphireppplot.satanic.matplot_f_over_r(ax, solution, animation_scene, plot_properties, p_values, mu=0.0, time=None, r_normalization=None)

Take line-out along \(r\) for multiple momenta and plot on the axes.

Parameters:
  • ax (Axes) – Matplotlib axes to add the plots.

  • solution (SourceProxy) – The simulation or computation result containing the data to plot.

  • animation_scene (Proxy) – The ParaView AnimationScene.

  • plot_properties (PlotPropertiesSatanic) – Properties for plotting.

  • p_values (Iterable[float]) – The linear momentum values \(p\) where to plot the solution.

  • mu (float) – The azimuth angle \(\mu = \cos(\theta)\) where to plot the solution.

  • time (Optional[float]) – Time at which to extract the solution. Defaults to the last time step.

  • r_normalization (Optional[float]) – Radius \(r\) to normalize the distribution function.

Return type:

Axes

Returns:

ax (Axes) – Matplotlib axes to with the plots.

See also

plot_f_over_r

Create line out using ParaView.

sapphireppplot.satanic.matplot_f_over_p(ax, solution, animation_scene, plot_properties, r_values, mu=0.0, time=None, p_normalization=None)

Take line-out along \(p\) for multiple radia and plot on the axes.

Parameters:
  • ax (Axes) – Matplotlib axes to add the plots.

  • solution (SourceProxy) – The simulation or computation result containing the data to plot.

  • animation_scene (Proxy) – The ParaView AnimationScene.

  • plot_properties (PlotPropertiesSatanic) – Properties for plotting.

  • r_values (Iterable[float]) – The radia \(r\) where to plot the solution.

  • mu (float) – The azimuth angle \(\mu = \cos(\theta)\) where to plot the solution.

  • time (Optional[float]) – Time at which to extract the solution. Defaults to the last time step.

  • p_normalization (Optional[float]) – Momentum \(p\) to normalize the distribution function.

Return type:

Axes

Returns:

ax (Axes) – Matplotlib axes to with the plots.

See also

plot_f_over_p

Create line out using ParaView.

sapphireppplot.satanic.matplot_f_over_mu(ax, solution, animation_scene, plot_properties, r_values, p_values, time=None, mu_normalization=None)

Take line-out along \(\mu = \cos(\theta)\) for multiple momenta and plot on the axes.

Parameters:
  • ax (Axes) – Matplotlib axes to add the plots.

  • solution (SourceProxy) – The simulation or computation result containing the data to plot.

  • animation_scene (Proxy) – The ParaView AnimationScene.

  • plot_properties (PlotPropertiesSatanic) – Properties for plotting.

  • r_values (Iterable[float]) – The radia \(r\) where to plot the solution.

  • p_values (Iterable[float]) – The linear momentum values \(p\) where to plot the solution.

  • time (Optional[float]) – Time at which to extract the solution. Defaults to the last time step.

  • mu_normalization (Optional[float]) – Azimuth angle \(\mu = \cos(\theta)\) to normalize the distribution function.

Return type:

Axes

Returns:

ax (Axes) – Matplotlib axes to with the plots.

See also

plot_f_over_mu

Create line out using ParaView.

sapphireppplot.satanic.matplot_f_r_p(fig, ax, solution, animation_scene, plot_properties, mu=0.0, time=None, value_range=(1e-10, None))

Slice 2D plane in \(r -\ln(p)\) of the solution and plot on the axes.

Parameters:
  • fig (Figure) – Matplotlib figure to add the plot.

  • ax (Axes) – Matplotlib axes to add the plot.

  • solution (SourceProxy) – The simulation or computation result containing the data to plot.

  • animation_scene (Proxy) – The ParaView AnimationScene.

  • plot_properties (PlotPropertiesSatanic) – Properties for plotting.

  • mu (float) – The azimuth angle \(\mu = \cos(\theta)\) where to plot the solution.

  • time (Optional[float]) – Time at which to extract the solution. Defaults to the last time step.

  • value_range (tuple[float, Optional[float]]) – Minimal (value_range[0]) and maximal (value_range[1]) value for the color bar.

Return type:

tuple[Figure, Axes, QuadMesh]

Returns:

  • fig (Figure) – Matplotlib figure with the plot.

  • ax (Axes) – Matplotlib axes with the plot.

  • cmesh (QuadMesh) – Matplotlib color mesh.

See also

slice_plane_r_p

Slice plane using ParaView.

sapphireppplot.satanic.matplot_f_r_mu(fig, ax, solution, animation_scene, plot_properties, p=1.0, time=None, value_range=(1e-10, None))

Slice solution and create polar plot \(f(\theta, r)\).

The axes must be use polar projection: fig, ax = plt.subplots(subplot_kw={"projection": "polar"})

Parameters:
  • fig (Figure) – Matplotlib figure to add the plot.

  • ax (Axes) – Matplotlib axes to add the plot. Must use polar projection: ax = fig.add_subplot(111, projection="polar")

  • solution (SourceProxy) – The simulation or computation result containing the data to plot.

  • animation_scene (Proxy) – The ParaView AnimationScene.

  • plot_properties (PlotPropertiesSatanic) – Properties for plotting.

  • p (float) – The linear momentum \(p\) where to plot the solution.

  • time (Optional[float]) – Time at which to extract the solution. Defaults to the last time step.

  • value_range (tuple[float, Optional[float]]) – Minimal (value_range[0]) and maximal (value_range[1]) value for the color bar.

Return type:

tuple[Figure, Axes, QuadMesh]

Returns:

  • fig (Figure) – Matplotlib figure with the plot.

  • ax (Axes) – Matplotlib axes with the plot.

  • cmesh (QuadMesh) – Matplotlib color mesh.

See also

slice_plane_r_mu

Slice plane using ParaView.

convert_mu_to_theta

Convert \(\mu\) to \(\theta\).