emout.core.data package

Submodules

emout.core.data.data module

Dimensioned ndarray subclasses for EMSES grid data.

Re-exports all Data classes from their respective submodules for backward compatibility. New code should import from the submodules directly (e.g. from emout.core.data._data3d import Data3d).

class emout.core.data.data.Data(input_array, filename=None, name=None, xslice=None, yslice=None, zslice=None, tslice=None, slice_axes=None, axisunits=None, valunit=None)[source]

Bases: ndarray

Dimensioned ndarray subclass for EMSES grid data.

datafile

Data file metadata.

Type:

DataFileInfo

name

Field name.

Type:

str

slices

Sub-range on each axis (t, z, y, x).

Type:

list of slice

slice_axes

Mapping from array dimensions to original axes (0: t, 1: z, 2: y, 3: x).

Type:

list of int

axisunits

Per-axis unit translators.

Type:

list of UnitTranslator or None

valunit

Value unit translator.

Type:

UnitTranslator or None

axis(ax)[source]

Return the coordinate array for the given array dimension.

Parameters:

ax (int) – Array dimension index

Returns:

1-D coordinate array for the requested axis.

Return type:

np.ndarray

build_frame_updater(axis=0, title=None, notitle=False, offsets=None, use_si=True, vmin=None, vmax=None, **kwargs)[source]

Build a frame updater for animation.

Parameters:
  • axis (int, optional) – Axis along which to animate, by default 0

  • title (str, optional) – Plot title (uses the field name when None), by default None

  • notitle (bool, optional) – If True, suppress the automatic title, by default False

  • offsets (tuple of (float or str), optional) – Axis offsets for x, y, z (‘left’: start at 0, ‘center’: centre at 0, ‘right’: end at 0, float: shift by value), by default None

  • use_si (bool) – If True, use SI units; otherwise use EMSES grid units, by default False

  • vmin (float, optional) – Colour-map minimum, by default None

  • vmax (float, optional) – Colour-map maximum, by default None

Return type:

FrameUpdater

property directory: Path

Return the parent directory of the source file.

Returns:

Parent directory path.

Return type:

Path

property filename: Path

Return the source file path.

Returns:

Path to the originating HDF5 file.

Return type:

Path

flip(axis=0)[source]

Reverse the data along the specified axis.

Coordinates are kept unchanged, so plot() shows the values in reversed order against the original grid.

Parameters:

axis (int or str) – Array dimension index, or axis name ('x', 'y', 'z', 't').

Returns:

Reversed copy (same subclass).

Return type:

Data

Examples

>>> data.phisp[-1, :, ny//2, :].flip('z').plot()
gifplot(fig=None, axis=0, mode=None, action='to_html', filename=None, show=False, savefilename=None, interval=200, repeat=True, title=None, notitle=False, offsets=None, use_si=True, vmin=None, vmax=None, to_html=False, return_updater=False, **kwargs)[source]

Create and run an animation over one axis.

Parameters:
  • fig (plt.Figure or None, optional) – Target figure

  • axis (int, optional) – Axis to animate along

  • mode (str, optional) – Plot mode forwarded to the frame updater

  • action (ANIMATER_PLOT_MODE, optional) – Output action type

  • filename (path-like, optional) – Destination file path for saving the animation

  • show (bool, optional) – If True, display the animation interactively

  • savefilename (path-like, optional) – Destination file name (deprecated alias for filename)

  • interval (int, optional) – Frame interval in milliseconds

  • repeat (bool, optional) – If True, loop the animation

  • title (str or None, optional) – Plot title

  • notitle (bool, optional) – If True, suppress the automatic frame-number title

  • offsets (tuple of (float or str) or None, optional) – Per-axis offsets for x, y, z

  • use_si (bool, optional) – If True, use SI units

  • vmin (float, optional) – Colour-map minimum

  • vmax (float, optional) – Colour-map maximum

  • to_html (bool, optional) – Deprecated. Equivalent to action='to_html'.

  • return_updater (bool, optional) – Deprecated. Equivalent to action='frames'.

  • **kwargs (dict) – Additional keyword arguments forwarded to the underlying function.

Returns:

Animation object, HTML string, or FrameUpdater depending on action.

Return type:

object

masked(mask)[source]

Return a copy with masked elements set to NaN.

Parameters:

mask (numpy.ndarray or callable) – Boolean mask array, or a callable that returns one

Returns:

Copy of the data with masked elements replaced by NaN.

Return type:

Data

mirror(axis=0)[source]

Append a reflected copy along the specified axis.

Simulates a reflection (Neumann / symmetry) boundary by concatenating the array with its reverse along axis. The boundary point is not duplicated, so the length changes from n to 2n - 1.

Parameters:

axis (int or str) – Array dimension index, or axis name ('x', 'y', 'z', 't').

Returns:

New Data object with reflected data appended.

Return type:

Data

Examples

>>> d = data.phisp[-1, :, ny//2, :]
>>> d.mirror('z').plot()  # 2x domain with reflection
negate()[source]

Return a copy with all values sign-flipped.

Equivalent to -self but chainable with mirror(), tile(), and plot().

Returns:

Negated copy (same subclass).

Return type:

Data

Examples

>>> data.ex[-1, :, ny//2, :].negate().mirror('z').plot()
plot(**kwargs)[source]

Plot the data (subclass-specific).

scale(factor)[source]

Return a copy with all values multiplied by factor.

Parameters:

factor (float) – Multiplicative factor.

Returns:

Scaled copy (same subclass).

Return type:

Data

Examples

>>> data.phisp[-1].scale(1e3).plot()
property t: ndarray

Time-axis coordinate array in grid units.

Returns:

Time-axis coordinates.

Return type:

np.ndarray

property t_si: ndarray

Time-axis coordinate array in SI units.

Returns:

Time-axis coordinates in SI units.

Return type:

np.ndarray

tile(n=1, axis=0, *, include_edge=False)[source]

Tile (repeat) the data along the specified axis.

Simulates a periodic boundary by concatenating n additional copies. By default the first element of each appended copy is dropped (include_edge=False), giving [d0, ..., dn, d1, ..., dn, d1, ..., dn].

Parameters:
  • n (int, default 1) – Number of additional copies to append.

  • axis (int or str) – Array dimension index, or axis name.

  • include_edge (bool, default False) – If True, keep the first element of each copy ([d0, ..., dn, d0, ..., dn]). If False (default), drop it to avoid duplicating the boundary point.

Returns:

New Data object with tiled data.

Return type:

Data

Examples

>>> d = data.phisp[-1, :, ny//2, :]
>>> d.tile(1, 'z').plot()   # 2x periodic domain
>>> d.mirror('z').tile(1, 'z').plot()  # 4x (reflect + periodic)
to_numpy()[source]

Convert to a plain NumPy ndarray.

Return type:

ndarray

property tslice: slice

Return the sub-range along the time axis.

Returns:

Sub-range along the time axis.

Return type:

slice

property use_axes: List[str]

Return axis labels corresponding to each array dimension.

Returns:

Axis labels such as ['x'], ['x', 'z'], etc.

Return type:

list of str

property val_si: Data

Field values converted to SI units.

Returns:

Field values in SI units.

Return type:

Data

property x: ndarray

X-axis coordinate array in grid units.

Returns:

X-axis coordinates.

Return type:

np.ndarray

property x_si: ndarray

X-axis coordinate array in SI units.

Returns:

X-axis coordinates in SI units.

Return type:

np.ndarray

property xslice: slice

Return the sub-range along the x axis.

Returns:

Sub-range along the x axis.

Return type:

slice

property y: ndarray

Y-axis coordinate array in grid units.

Returns:

Y-axis coordinates.

Return type:

np.ndarray

property y_si: ndarray

Y-axis coordinate array in SI units.

Returns:

Y-axis coordinates in SI units.

Return type:

np.ndarray

property yslice: slice

Return the sub-range along the y axis.

Returns:

Sub-range along the y axis.

Return type:

slice

property z: ndarray

Z-axis coordinate array in grid units.

Returns:

Z-axis coordinates.

Return type:

np.ndarray

property z_si: ndarray

Z-axis coordinate array in SI units.

Returns:

Z-axis coordinates in SI units.

Return type:

np.ndarray

property zslice: slice

Return the sub-range along the z axis.

Returns:

Sub-range along the z axis.

Return type:

slice

class emout.core.data.data.Data1d(input_array, **kwargs)[source]

Bases: Data

One-dimensional line data container.

plot(show=False, use_si=True, offsets=None, **kwargs)[source]

Plot one-dimensional data as a line.

Parameters:
  • show (bool) – If True, display the plot (suppresses return value), by default False

  • use_si (bool) – If True, use SI units; otherwise use EMSES grid units, by default True

  • offsets (tuple of (float or str), optional) – Offsets for the x and y axes (‘left’: start at 0, ‘center’: centre at 0, ‘right’: end at 0, float: shift by value), by default None

  • savefilename (str, optional) – Output file name, by default None

  • vmin (float, optional) – Minimum value, by default None

  • vmax (float, optional) – Maximum value, by default None

  • figsize (tuple of float, optional) – Figure size, by default None

  • xlabel (str, optional) – Horizontal axis label, by default None

  • ylabel (str, optional) – Vertical axis label, by default None

  • label (str, optional) – Series label, by default None

  • title (str, optional) – Title, by default None

Returns:

Line object (None when saved or shown)

Return type:

Line2D or None

Raises:

ValueError – If the data is not one-dimensional.

class emout.core.data.data.Data2d(input_array, **kwargs)[source]

Bases: Data

Two-dimensional grid data container.

cmap(**kwargs)[source]

Plot two-dimensional data as a colour map.

Shortcut equivalent to plot(mode='cm'). Accepts the same arguments as plot() except mode (raises TypeError if supplied).

Returns:

Same as plot().

Return type:

matplotlib.image.AxesImage or list or None

contour(**kwargs)[source]

Plot two-dimensional data as contour lines.

Shortcut equivalent to plot(mode='cont'). Accepts the same arguments as plot() except mode (raises TypeError if supplied).

Returns:

Same as plot().

Return type:

matplotlib.contour.QuadContourSet or list or None

plot(axes='auto', show=False, use_si=True, offsets=None, mode='cm', **kwargs)[source]

Plot two-dimensional data.

Parameters:
  • axes (str, optional) – Axis pair to plot (‘xy’, ‘zx’, etc.), by default ‘auto’

  • show (bool) – If True, display the plot (suppresses file output), by default False

  • use_si (bool) – If True, use SI units; otherwise use EMSES grid units, by default True

  • offsets (tuple of (float or str), optional) – Per-axis offsets for x, y, z (‘left’: start at 0, ‘center’: centre at 0, ‘right’: end at 0, float: shift by value), by default None

  • mode (str) – Plot type (‘cm’: colour map, ‘cont’: contour, ‘surf’: surface)

  • **kwargs (dict) – Additional arguments forwarded to the low-level plot function (plot_2dmap for ‘cm’/’cm+cont’, plot_2d_contour for ‘cont’, plot_surface for ‘surf’).

  • mesh (tuple of numpy.ndarray, optional) – Mesh grid, by default None

  • savefilename (str, optional) – Output file name (None to skip saving), by default None

  • cmap (matplotlib.Colormap or str or None, optional) – Colour map, by default cm.coolwarm

  • vmin (float, optional) – Minimum value, by default None

  • vmax (float, optional) – Maximum value, by default None

  • figsize (tuple of float, optional) – Figure size, by default None

  • xlabel (str, optional) – X-axis label, by default None

  • ylabel (str, optional) – Y-axis label, by default None

  • title (str, optional) – Title, by default None

  • interpolation (str, optional) – Interpolation method, by default ‘bilinear’

  • dpi (int, optional) – Resolution (ignored when figsize is set), by default 10

Returns:

Plot image data (None when saved or shown)

Return type:

AxesImage or None

Raises:
  • ValueError – If the axes parameter is invalid.

  • ValueError – If the requested axis does not exist in the data.

  • ValueError – If the data is not two-dimensional.

plot3d(*args, **kwargs)[source]

Alias for plot_pyvista().

plot_pyvista(use_si=True, offsets=None, show=False, plotter=None, cmap='viridis', clim=None, show_edges=False, add_scalar_bar=True, **kwargs)[source]

Render two-dimensional data as a plane in 3-D space with PyVista.

class emout.core.data.data.Data3d(input_array, **kwargs)[source]

Bases: Data

Three-dimensional (z, y, x) grid data container.

plot(mode='auto', use_si=True, offsets=None, *args, **kwargs)[source]

Plot three-dimensional data.

Currently only mode='cont' is implemented, which delegates to emout.plot.contour3d.contour3d().

Parameters:
  • mode ({'auto', 'cont'}, optional) – Plot mode. 'auto' selects 'cont'.

  • use_si (bool, optional) – If True, convert to SI units before plotting.

  • offsets (tuple of (float or str) or None, optional) – Origin offsets (x, y, z). Strings 'left', 'center', 'right' are also accepted.

  • *args (tuple) – Positional arguments forwarded to contour3d. Typically the first element is levels (a sequence of iso-surface values).

  • **kwargs (dict) – Keyword arguments forwarded to contour3d, including ax, bounds_xyz, roi_zyx, opacity, step, title, save, show, xlabel, ylabel, zlabel, clabel, etc.

Returns:

(fig, ax) for mode='cont'; None for unsupported modes.

Return type:

tuple of (Figure, Axes) or None

plot3d(*args, **kwargs)[source]

Alias for plot_pyvista().

plot_pyvista(mode='box', use_si=True, offsets=None, show=False, plotter=None, cmap='viridis', clim=None, opacity='sigmoid', contour_levels=8, add_outline=True, outline_color='white', add_scalar_bar=True, **kwargs)[source]

Render three-dimensional data with PyVista.

plot_surfaces(surfaces, *, ax=None, use_si=True, vmin=None, vmax=None, **kwargs)[source]

Overlay explicit mesh boundaries on a 3-D scalar field.

Wraps self as a Field3D and passes it to emout.plot.surface_cut.plot_surfaces(). Designed for one-line calls such as data.phisp[-1].plot_surfaces(data.boundaries.mesh().render(), vmin=0, vmax=10).

Parameters:
  • surfaces – A RenderItem, MeshSurface3D, Boundary, BoundaryCollection, or a sequence thereof. A bare MeshSurface3D is wrapped with default render style. A Boundary / BoundaryCollection is converted via mesh(use_si=use_si) then render(), so data.phisp[-1].plot_surfaces(data.boundaries) works directly.

  • ax (matplotlib.axes.Axes, optional) – Target 3-D axes. Created automatically if not supplied.

  • use_si (bool, optional) – If True (default), convert data and grid spacing to SI units before plotting. Also propagated to boundary mesh generation. Falls back to False when no unit conversion key is available.

  • vmin (float, optional) – Colour-map range.

  • vmax (float, optional) – Colour-map range.

  • **kwargs (dict) – Additional keyword arguments forwarded to plot_surfaces() (e.g. bounds, cmap_name, contour_levels).

Returns:

(cmap, norm) returned by plot_surfaces.

Return type:

tuple

to_vtk(filename, use_si=True, array_name=None)[source]

Export to VTK ImageData format (.vti).

Parameters:
  • filename (path-like) – Destination file path. The .vti extension is appended automatically when missing.

  • use_si (bool, default True) – Convert values and grid spacing to SI units.

  • array_name (str, optional) – Name of the scalar array in the VTK file. Defaults to name.

Returns:

Path to the written file.

Return type:

Path

class emout.core.data.data.Data4d(input_array, **kwargs)[source]

Bases: Data

Four-dimensional (t, z, y, x) grid data container.

plot(mode='auto', **kwargs)[source]

Plot four-dimensional data (not yet implemented).

Parameters:
  • mode ({'auto'}, optional) – Plot mode. Currently only 'auto' is accepted.

  • **kwargs (dict) – Reserved for future extensions; currently unused.

Returns:

Not implemented.

Return type:

None

emout.core.data.griddata_series module

Lazy time-series loader for EMSES grid HDF5 files.

GridDataSeries memory-maps a sequence of {name}00_0000.h5 files and produces Data slices on demand.

class emout.core.data.griddata_series.GridDataSelection(series, selectors=None)[source]

Bases: NDArrayOperatorsMixin

Lazy staged selector for a GridDataSeries.

Instances keep the selected (t, z, y, x) ranges as metadata and only materialise arrays once the result has at most three dimensions or the caller asks for functionality that requires a real Data4d.

axis(ax)[source]
Return type:

ndarray

build_frame_updater(axis=0, title=None, notitle=False, offsets=None, use_si=True, vmin=None, vmax=None, **kwargs)[source]

Build a frame updater for lazy 4-D selections.

Return type:

FrameUpdater

property directory: Path
property filename: Path
gifplot(fig=None, axis=0, mode=None, action='to_html', filename=None, show=False, savefilename=None, interval=200, repeat=True, title=None, notitle=False, offsets=None, use_si=True, vmin=None, vmax=None, to_html=False, return_updater=False, **kwargs)[source]

Create an animation without materialising the full 4-D array.

materialize()[source]

Materialise the current selection as a Data object or scalar.

max()[source]

Return the maximum value without materialising the full 4-D array.

min()[source]

Return the minimum value without materialising the full 4-D array.

property ndim: int
plot(**kwargs)[source]

Delegate to the materialised Data4d.

select_space(*item)[source]

Select only spatial axes while preserving the current time range.

Examples

data.phisp.lazy[:].select_space(1, 1, 1) is equivalent to data.phisp.lazy[:][:, 1, 1, 1].

property shape
property slice_axes
property slices
property t: ndarray
property t_si: ndarray
to_numpy()[source]

Materialise the current selection as a plain NumPy array.

Return type:

ndarray

property use_axes
property x: ndarray
property x_si: ndarray
property y: ndarray
property y_si: ndarray
property z: ndarray
property z_si: ndarray
class emout.core.data.griddata_series.GridDataSeries(filename, name, tunit=None, axisunit=None, valunit=None)[source]

Bases: object

Manage 3-D time-series grid data.

datafile

Data file metadata.

Type:

DataFileInfo

h5

HDF5 file handle.

Type:

h5py.File

group

HDF5 dataset group.

Type:

h5py.Datasets

name

Dataset name.

Type:

str

chain(other_series)[source]

Chain this series with another.

Parameters:

other_series (GridDataSeries) – Series to append.

Returns:

Concatenated series.

Return type:

MultiGridDataSeries

close()[source]

Close the HDF5 file.

Return type:

None

property directory: Path

Return the directory name.

Returns:

Directory path.

Return type:

Path

property filename: Path

Return the file name.

Returns:

File name.

Return type:

Path

property grid_shape: Tuple[int, int, int]

Return the spatial grid shape as (z, y, x).

property lazy: GridDataSelection

Return a lazy 4-D selector for staged indexing.

series[:] also returns this selector. Use series.lazy when you want to make the lazy intent explicit before additional spatial slicing, e.g. data.phisp.lazy[:][:, 1, 1, 1] or data.phisp.lazy[:].select_space(1, 1, 1).

time_series(x, y, z)[source]

Return the time series for the specified spatial range.

Parameters:
  • x (int or slice) – X coordinate or range.

  • y (int or slice) – Y coordinate or range.

  • z (int or slice) – Z coordinate or range.

Returns:

Time-series data for the specified range.

Return type:

numpy.ndarray

property trange: List[int]

Return the sorted list of available time-step indices.

Returns:

Available time-step indices in ascending order.

Return type:

list of int

class emout.core.data.griddata_series.MultiGridDataSeries(*series)[source]

Bases: GridDataSeries

Manage multiple concatenated 3-D time-series datasets.

datafile

Data file metadata.

Type:

DataFileInfo

name

Dataset name.

Type:

str

tunit

Time unit translator.

Type:

UnitTranslator

axisunit

Spatial axis unit translator.

Type:

UnitTranslator

valunit

Value unit translator.

Type:

UnitTranslator

close()[source]

Close the HDF5 file.

Return type:

None

property directories: List[Path]

Return the list of directories.

Returns:

Directory paths.

Return type:

list of Path

property directory: Path

Return the directory of the first series.

Returns:

Directory path.

Return type:

Path

property filename: Path

Return the file name of the first series.

Returns:

File name.

Return type:

Path

property filenames: List[Path]

Return the list of file names.

Returns:

File names.

Return type:

list of Path

property grid_shape: Tuple[int, int, int]

Return the spatial grid shape as (z, y, x).

time_series(x, y, z)[source]

Return the time series for the specified spatial range.

Parameters:
  • x (int or slice) – X coordinate or range.

  • y (int or slice) – Y coordinate or range.

  • z (int or slice) – Z coordinate or range.

Returns:

Time-series data for the specified range.

Return type:

numpy.ndarray

emout.core.data.vector_data module

Multi-component vector field wrappers.

VectorData bundles two or three Data components and provides unified plotting for 2-D quiver / streamline and 3-D PyVista visualisation.

class emout.core.data.vector_data.VectorData(objs, name=None, attrs=None)[source]

Bases: Group

Multi-component vector field container.

Wraps 2 or 3 Data arrays (x, y[, z]) and delegates axis metadata, slicing, and plotting to the underlying components.

Parameters:
  • objs (list of Data) – Vector components (length 2 or 3).

  • name (str, optional) – Display name for the vector field.

  • attrs (dict, optional) – Additional attributes inherited by the wrapper.

property axisunits: UnitTranslator

Return per-axis unit translators.

Returns:

Per-axis unit translators [-1]=x, [-2]=y, [-3]=z.

Return type:

list of UnitTranslator

build_frame_updater(axis=0, title=None, notitle=False, offsets=None, use_si=True, **kwargs)[source]

Build a frame updater for animation.

Parameters:
  • axis (int, optional) – Axis along which to animate, by default 0

  • title (str, optional) – Plot title (uses the field name when None), by default None

  • notitle (bool, optional) – If True, suppress the automatic title, by default False

  • offsets (tuple of (float or str), optional) – Axis offsets for x, y, z (‘left’: start at 0, ‘center’: centre at 0, ‘right’: end at 0, float: shift by value), by default None

  • use_si (bool) – If True, use SI units; otherwise use EMSES grid units, by default False

gifplot(fig=None, axis=0, action='to_html', filename=None, interval=200, repeat=True, title=None, notitle=False, offsets=None, use_si=True, show=False, savefilename=None, to_html=False, return_updater=False, **kwargs)[source]

Create and run an animation over one axis.

Parameters:
  • fig (plt.Figure or None, optional) – Target figure

  • axis (int, optional) – Axis to animate along

  • action (ANIMATER_PLOT_MODE, optional) – Output action type

  • filename (path-like, optional) – Destination file path for saving the animation

  • interval (int, optional) – Frame interval in milliseconds

  • repeat (bool, optional) – If True, loop the animation

  • title (str or None, optional) – Plot title

  • notitle (bool, optional) – If True, suppress the automatic frame-number title

  • offsets (tuple of (float or str) or None, optional) – Per-axis offsets for x, y, z

  • use_si (bool, optional) – If True, use SI units

  • show (bool, optional) – If True, display the animation interactively

  • savefilename (path-like, optional) – Destination file name (deprecated alias for filename)

  • to_html (bool, optional) – Deprecated. Equivalent to action='to_html'.

  • return_updater (bool, optional) – Deprecated. Equivalent to action='frames'.

  • **kwargs (dict) – Additional keyword arguments forwarded to the underlying function.

Returns:

Animation object, HTML string, or FrameUpdater depending on action.

Return type:

object

property name: str

Return the human-readable name of this vector field.

Returns:

Human-readable name of this vector field.

Return type:

str

property ndim: int

Return the number of spatial dimensions (excluding vector components).

negate()[source]

Return a new VectorData with all components sign-flipped.

Returns:

Negated copy.

Return type:

VectorData

Examples

>>> data.bxyz[-1].negate().plot()
plot(*args, **kwargs)[source]

Plot vector data.

Delegates to plot2d() for 2-D data and plot3d() for 3-D data.

Parameters:
  • *args (tuple) – Positional arguments forwarded to plot2d(). Common arguments: mode, axes, show, use_si, offsets.

  • **kwargs (dict) – Keyword arguments forwarded to plot2d(), which in turn delegates to plot_2d_vector or plot_2d_streamline. Accepts mesh, savefilename, scale, scaler, skip, easy_to_read, color, cmap, norm, vmin, vmax, density, figsize, xlabel, ylabel, title, dpi, etc.

Returns:

Return value of the delegated plotting method.

Return type:

object

plot2d(mode='stream', axes='auto', show=False, use_si=True, offsets=None, **kwargs)[source]

Plot two-dimensional vector data.

Parameters:
  • mode (str) – Plot type (‘vec’: quiver, ‘stream’: streamline), by default ‘stream’

  • axes (str, optional) – Axis pair to plot (‘xy’, ‘zx’, etc.), by default ‘auto’

  • show (bool) – If True, display the plot, by default False

  • use_si (bool) – If True, use SI units; otherwise use EMSES grid units, by default False

  • offsets (tuple of (float or str), optional) – Per-axis offsets (‘left’, ‘center’, ‘right’, or float), by default None

  • mesh (tuple of numpy.ndarray, optional) – Mesh grid, by default None

  • savefilename (str, optional) – Output file name (None to skip saving), by default None

  • cmap (matplotlib.Colormap or str or None, optional) – Colour map, by default cm.coolwarm

  • vmin (float, optional) – Minimum value, by default None

  • vmax (float, optional) – Maximum value, by default None

  • figsize (tuple of float, optional) – Figure size, by default None

  • xlabel (str, optional) – X-axis label, by default None

  • ylabel (str, optional) – Y-axis label, by default None

  • title (str, optional) – Title, by default None

  • interpolation (str, optional) – Interpolation method, by default ‘bilinear’

  • dpi (int, optional) – Resolution (ignored when figsize is set), by default 10

Returns:

Plot image data (None when saved or shown)

Return type:

AxesImage or None

Raises:
  • ValueError – If the axes parameter is invalid.

  • ValueError – If the requested axis does not exist in the data.

  • ValueError – If the data is not two-dimensional.

plot3d(mode='stream', backend='mpl', **kwargs)[source]

Plot a 3-D vector field.

Parameters:
  • mode ({'stream', 'streamline', 'vec', 'quiver'}) – Plot type.

  • backend ({'mpl', 'pyvista'}, default 'mpl') – 'mpl' uses matplotlib 3-D axes; 'pyvista' uses the PyVista renderer.

  • **kwargs – Forwarded to plot3d_mpl() or plot_pyvista().

Return type:

object

plot3d_mpl(mode='stream', use_si=True, offsets=None, ax=None, **kwargs)[source]

Plot a 3-D vector field with matplotlib.

For mode='stream' (default), field lines are traced using scipy.integrate.solve_ivp() and drawn on a mpl_toolkits.mplot3d.Axes3D.

Parameters:
  • mode ({'stream', 'streamline', 'vec', 'quiver'}) – Plot type.

  • use_si (bool, default True) – Convert to SI units when available.

  • offsets (tuple of (float or str), optional) – Per-axis offsets.

  • ax (Axes3D, optional) – Target axes.

  • **kwargs – Forwarded to the underlying plot function (e.g. n_seeds, seed_points, max_length, step_size, color, cmap, linewidth).

Return type:

Axes3D

plot_pyvista(mode='stream', show=False, use_si=True, offsets=None, plotter=None, **kwargs)[source]

Render three-dimensional vector field with PyVista.

scale(factor)[source]

Return a new VectorData with all components scaled.

Parameters:

factor (float) – Multiplicative factor.

Returns:

Scaled copy.

Return type:

VectorData

property shape: tuple

Return the shape of the underlying component arrays.

Returns:

Shape tuple of the underlying component arrays.

Return type:

tuple

property slice_axes: ndarray

Return the mapping from current array axes to original data axes.

Returns:

Integer array mapping current array axes to original data axes.

Return type:

np.ndarray

property slices: ndarray

Return the slice objects describing the current sub-range on each axis.

Returns:

Slice objects describing the current sub-range on each axis.

Return type:

np.ndarray

property valunit: UnitTranslator

Return the unit translator for the field values.

Returns:

Unit translator for the field values.

Return type:

UnitTranslator

emout.core.data.vector_data.VectorData2d

alias of VectorData

emout.core.data.vector_data.VectorData3d

alias of VectorData

Module contents

Data classes for EMSES grid and particle output.

Re-exports

Data, Data1d, Data2d, Data3d, Data4d

Dimensioned numpy-subclass wrappers for grid data.

VectorData, VectorData2d, VectorData3d

Multi-component vector field wrappers.

GridDataSeries, GridDataSelection

Lazy time-series loader for grid HDF5 files.

ParticleData, ParticleDataSeries, MultiParticleDataSeries

Particle output wrappers.