emout.core package

Subpackages

Submodules

emout.core.extraction module

Data extraction utilities for saving subsets of EMSES output.

Provides EmoutDataExtraction which wraps an Emout instance and automatically persists accessed grid data as HDF5 snapshots.

class emout.core.extraction.EmoutDataExtraction(root, data, nparent=1)[source]

Bases: object

Wrapper around Emout that persists accessed data to disk.

Every grid field accessed via attribute lookup is automatically saved as an HDF5 snapshot (last timestep only) into an extraction directory, enabling lightweight data subsets for post-processing or transfer.

property backtrace: BacktraceWrapper

Return the backtrace solver wrapper.

Returns:

Backtrace API bound to the underlying simulation data.

Return type:

BacktraceWrapper

property directory

Return the base simulation directory.

Returns:

Root output directory of the wrapped Emout instance.

Return type:

Path

property extract_dir

Compute the extraction output directory.

The path is derived from directory by taking the last nparent path components and appending them to root.

Returns:

Directory where extracted HDF5 snapshots are written.

Return type:

Path

property icur: DataFrame

Return the icur diagnostic file as a DataFrame.

Returns:

Table with step numbers and per-species / per-body current columns parsed from the icur text file.

Return type:

pd.DataFrame

property inp

Return the input parameter file.

Returns:

Parsed plasma.inp parameters, or None if unavailable.

Return type:

InpFile or None

is_valid()[source]

Check whether the underlying dataset is valid.

Returns:

Whether the simulation completed successfully.

Return type:

bool

property pbody: DataFrame

Return the pbody diagnostic file as a DataFrame.

Returns:

Table with a step column and per-body particle-count columns parsed from the pbody text file.

Return type:

pd.DataFrame

save_hdf5(name)[source]

Save the last timestep of the named field to an HDF5 file.

The file is written to extract_dir as {name}00_0000.h5. If the file already exists the write is skipped.

Parameters:

name (str) – Grid-data field name (e.g. "phisp", "ex").

property unit

Return the unit conversion object.

Returns:

Unit translators derived from the conversion key, or None.

Return type:

Units or None

emout.core.facade module

Facade class that provides unified access to EMSES simulation outputs.

The Emout class aggregates directory inspection, grid data loading, particle data, boundary modelling, and backtrace analysis into a single entry point.

class emout.core.facade.Emout(directory='./', append_directories=None, ad=None, inpfilename='plasma.inp', input_path=None, output_directory=None)[source]

Bases: object

Facade class for unified access to EMSES simulation outputs.

property append_directories: List[Path]

Return the list of chained append directories.

Returns:

Directories concatenated after the main directory during loading.

Return type:

List[Path]

available_fields()[source]

Return the names of available grid data fields.

Scans the output directory for *00_0000.h5 files and returns the field names (e.g. ['ex', 'ey', 'ez', 'phisp']).

Returns:

Sorted field names.

Return type:

list of str

property backtrace: BacktraceWrapper

Return the backtrace solver wrapper.

Returns:

Backtrace API bound to this simulation’s directory and input parameters.

Return type:

BacktraceWrapper

property boundaries

Return the MPIEMSES finbound boundary collection.

Builds Boundary instances from the boundary_types array in data.inp (when boundary_type = 'complex') and returns them as a BoundaryCollection.

Examples:

data = Emout("output_dir")

# Individual boundary mesh (grid units)
mesh = data.boundaries[0].mesh()

# SI units with resolution override
mesh = data.boundaries[0].mesh(use_si=True, ntheta=96)

# Composite mesh of all boundaries
composite = data.boundaries.mesh(use_si=True)

# Per-boundary keyword overrides
composite = data.boundaries.mesh(
    use_si=True,
    per={0: {"ntheta": 64}, 1: {"nradial": 12}},
)
Returns:

Supported finbound boundaries. Returns an empty collection if data.inp is not loaded or is not in complex mode.

Return type:

BoundaryCollection

property directory: Path

Return the main output directory.

Returns:

Base directory for EMSES output files.

Return type:

Path

property icur: DataFrame

Return the icur diagnostic file as a DataFrame.

Returns:

Table with step numbers and per-species / per-body current columns parsed from the icur text file.

Return type:

pd.DataFrame

property inp: InpFile | None

Return the parsed input parameter file.

Returns:

Parsed plasma.inp parameters, or None if not loaded.

Return type:

InpFile or None

is_valid()[source]

Check whether the simulation completed successfully.

Returns:

True if the last recorded step matches nstep in the input file.

Return type:

bool

name2unit = {'axis': <function build_name2unit_mapping.<locals>.<lambda>>, 'b[xyz]': <function build_name2unit_mapping.<locals>.<lambda>>, 'e[xyz]': <function build_name2unit_mapping.<locals>.<lambda>>, 'j.*': <function build_name2unit_mapping.<locals>.<lambda>>, 'nd[1-9]\\d*p': <function ndp_unit>, 'p[1-9][xyz]': <function build_name2unit_mapping.<locals>.<lambda>>, 'p[1-9]tid': <function build_name2unit_mapping.<locals>.<lambda>>, 'p[1-9]v[xyz]': <function build_name2unit_mapping.<locals>.<lambda>>, 'phisp': <function build_name2unit_mapping.<locals>.<lambda>>, 'rb[xyz]': <function build_name2unit_mapping.<locals>.<lambda>>, 're[xyz]': <function build_name2unit_mapping.<locals>.<lambda>>, 'rho': <function build_name2unit_mapping.<locals>.<lambda>>, 'rhobk': <function build_name2unit_mapping.<locals>.<lambda>>, 'rhobkac[1-9]': <function build_name2unit_mapping.<locals>.<lambda>>, 'rhobksp[1-9]': <function build_name2unit_mapping.<locals>.<lambda>>, 't': <function t_unit>}
particle(species)[source]

Return a ParticlesSeries for the given species.

Parameters:

species (int) – Particle species number (1-based)

Returns:

Particle data series for the specified species.

Return type:

ParticlesSeries

property pbody: DataFrame

Return the pbody diagnostic file as a DataFrame.

Returns:

Table with a step column and per-body particle-count columns parsed from the pbody text file.

Return type:

pd.DataFrame

remote()[source]

Return a remote proxy backed by the shared Dask session.

property toml

Return the parsed TOML configuration.

Only available when plasma.toml exists. Provides attribute access to the structured TOML data, e.g. data.toml.species[0].wp. Entries using group_id (*_groups) are expanded at load time and the group tables are removed from the returned object.

Returns:

Parsed TOML data, or None if unavailable.

Return type:

TomlData or None

property unit: Units | None

Return the unit conversion object.

Returns:

Unit translators derived from the conversion key, or None if no conversion key is available.

Return type:

Units or None

emout.core.units module

Unit mapping from EMSES field names to physical-unit translators.

Defines build_name2unit_mapping() which creates a regex-keyed dictionary that maps grid-data names (e.g. phisp, bx, nd1p) to factory functions producing UnitTranslator instances.

emout.core.units.build_name2unit_mapping(max_ndp=9)[source]

Build a regex dictionary mapping field-name patterns to unit-translator factories.

Parameters:

max_ndp (int, optional) – Maximum species number for density fields (nd{N}p).

Returns:

Regex dictionary mapping field-name patterns to unit-translator factory functions.

Return type:

RegexDict

emout.core.units.nd3p_unit(out)[source]

Return a unit translator for species-3 grid-density (nd3p).

Parameters:

out (Emout) – Source Emout instance providing plasma parameters.

Returns:

Translator converting grid-density to number density in /cc for species 3.

Return type:

UnitTranslator

emout.core.units.ndp_unit(out)[source]

Return a unit translator for grid-density fields (nd*p).

Parameters:

out (Emout) – Source Emout instance providing plasma parameters.

Returns:

Translator converting grid-density to number density in /cc.

Return type:

UnitTranslator

emout.core.units.none_unit(out)[source]

Return an identity (dimensionless) unit translator.

Parameters:

out (Emout) – Source Emout instance (unused, kept for API consistency).

Returns:

Identity translator (dimensionless).

Return type:

UnitTranslator

emout.core.units.t_unit(out)[source]

tの単位変換器を生成する.

Parameters:

out (Emout) – Emoutオブジェクト

Returns:

tの単位変換器

Return type:

UnitTranslator

emout.core.units.wpet_unit(out)[source]

wpe * tの単位変換器を生成する.

以下のコードを実行することで、データのt軸をwpe*tで規格化できる.

>>> Emout.name2unit['t'] = wpet_unit
Parameters:

out (Emout) – Emoutオブジェクト

Returns:

wpe * tの単位変換器

Return type:

UnitTranslator

emout.core.units.wpit_unit(out)[source]

wpi * tの単位変換器を生成する.

以下のコードを実行することで、データのt軸をwpe*tで規格化できる.

>>> Emout.name2unit['t'] = wpit_unit
Parameters:

out (Emout) – Emoutオブジェクト

Returns:

wpi * tの単位変換器

Return type:

UnitTranslator

Module contents

Core domain model for the emout package.

Provides the Emout facade and supporting modules for data access, I/O, boundary modelling, backtrace analysis, field relocation, and unit conversion.