flekspy.yt#

Submodules#

Classes#

YtFLEKSData

Read and plot the AMReX format output from FLEKS.

Functions#

extract_phase(pp)

Extract phase space distribution from PhasePlot object.

Package Contents#

class flekspy.yt.YtFLEKSData(output_dir, read_field_data=False, cparam_filename=None, fparam_filename=None, dataset_type='boxlib_native', storage_filename=None, units_override=None, unit_system='mks')[source]#

Bases: yt.frontends.boxlib.api.BoxlibDataset

Read and plot the AMReX format output from FLEKS.

Parameters:

output_dir (str) – the path to the data.

Examples

>>> import flekspy
>>> ds = flekspy.YtFLEKSData("3d_particle*n00004750_amrex")
_index_class#
_field_info_class#
default_fluid_type = 'mesh'#
default_field = ('mesh', 'density')#
fluid_types = ('mesh', 'index', 'raw')#
read_field_data = False#
_parse_parameter_file()[source]#

Parses the parameter file and establishes the various dictionaries.

_set_code_unit_attributes()[source]#
pvar(var)[source]#
get_slice(norm: str, cut_loc: float) xarray.Dataset[source]#

Returns a xarray.Dataset object that contains a slice along the normal direction.

Parameters:
  • norm (str) – slice normal direction in “x”, “y” or “z”

  • cut_loc (float) – cut location along the normal direction

get_domain() xarray.Dataset[source]#

Read all the simulation data into a 3D box. This method only reads grid data, not particle data.

_get_profile(x_field, y_field, z_field, region: yt.data_objects.selection_objects.data_selection_objects.YTSelectionContainer | None = None, x_bins: int = 128, y_bins: int = 128, domain_size: tuple | None = None)[source]#
get_phase(x_field, y_field, z_field, region: yt.data_objects.selection_objects.data_selection_objects.YTSelectionContainer | None = None, x_bins: int = 128, y_bins: int = 128, domain_size: tuple | None = None)[source]#

Get particle phase space distribution.

Parameters:
  • region – YTSelectionContainer Spatial region to be selected, such as all_data, box, region, or sphere.

  • y_field (x_field &) – string The x-/y- axes, from “p_ux”, “p_uy”, “p_uz”, “p_x”, “p_y” or “p_z”.

  • z_field – string It is usually the particle weight: “p_w”.

  • domain_size – tuple Axis range of 4 elements: x_min, x_max, y_min, y_max

Examples

>>> x, y, w = ds.get_phase("p_ux", "p_uy", "p_w", domain_size=(-1, 1, -1, 1))
plot_phase(x_field, y_field, z_field, region: yt.data_objects.selection_objects.data_selection_objects.YTSelectionContainer | None = None, unit_type: str = 'planet', x_bins: int = 128, y_bins: int = 128, domain_size: tuple | None = None, font_size: float = 18, figure_size: float = 8, customized: bool = False) yt.visualization.profile_plotter.PhasePlot[source]#

Plot particle phase space distribution.

Parameters:
  • region – YTSelectionContainer Spatial region to be selected, such as all_data, box, region, or sphere.

  • y_field (x_field &) – string The x-/y- axes, from “p_ux”, “p_uy”, “p_uz”, “p_x”, “p_y” or “p_z”.

  • z_field – string It is usually the particle weight: “p_w”.

  • unit_type – string The unit system of the plots. “planet” or “si”.

  • domain_size – tuple Axis range of 4 elements: x_min, x_max, y_min, y_max

Examples

>>> pp = ds.plot_phase("p_ux", "p_uy", "p_w", domain_size=(-1, 1, -1, 1))
>>> pp.show()
plot_particles(x_field, y_field, z_field, region: yt.data_objects.selection_objects.data_selection_objects.YTSelectionContainer | None = None, unit_type: str = 'planet', x_bins: int = 128, y_bins: int = 128, **kwargs)[source]#

Plot the particle position of particles inside a box.

Parameters:
  • y_field (x_field &) – str The x- y- axes, from “p_x”, “p_y”, “p_z”.

  • z_field – str color variable, usually the particle weight “p_w”.

  • region – YTSelectionContainer Spatial region to be selected, such as all_data, box, region, or sphere.

  • unit_type – str The unit system of the plots. “planet” or “si”.

See more at https://yt-project.org/doc/reference/api/yt.visualization.particle_plots.html#yt.visualization.particle_plots.ParticlePlot

Examples

>>> pp = ds.plot_particles([8, -1, -1], [10, 0, 0], "p_x", "p_y", "p_w", unit_type="planet")
>>> pp.show()
flekspy.yt.extract_phase(pp: yt.visualization.profile_plotter.PhasePlot)[source]#

Extract phase space distribution from PhasePlot object.

Parameters:

pp (PhasePlot) – YT PhasePlot object.

Returns:

Horizontal, vertical coordinates of the plot, and phase space density.

Return type:

x, y, f