Skip to content

Backends§

Please navigate to a specific section for more information about the implementation of each simulation file type.

If you're looking for the backend-specific methods that you can call on a data object, see Data object methods → Backend-specific methods.

Interface class§

Info

This section should only be relevant if you're planning to add support for a new backend or for debugging purposes.

The Backend class serves as an interface between ozzy's main file-reading functions and the modules for each implemented backend.

Backend §

Interface class for reading simulation data. Upon initialization, the Backend instance imports a specific submodule for a given data format and defines its data-parsing methods accordingly.

Attributes:

Name Type Description
name str

Name of the backend (e.g. 'osiris').

parse function

Function for parsing data from files.

mixin class

Mixin class that makes methods available to the data object depending on the file backend/data origin ('openpmd', 'osiris', 'ozzy', 'lcode').

parse_data §

parse_data(files, *args, **kwargs)

Read data from files and attach metadata according to the selected Backend.

Parameters:

Name Type Description Default
files §
list[str]

File paths to read data from.

required
*args §

Positional arguments to be passed to the read function of the backend specification.

()
**kwargs §

Keyword arguments to be passed to the read function of the backend specification.

See available keyword arguments for each backend:

{}

Returns:

Type Description
Dataset

Parsed data. Includes the following Dataset attributes: 'file_backend', 'source', 'file_prefix', 'pic_data_type' and 'data_origin'.

Examples:

Parse a single file
from ozzy.backend_interface import Backend

backend = Backend('lcode')
ds = backend.parse_data(['path/to/file.swp'])
Parse multiple files
from ozzy.backend_interface import Backend

backend = Backend('osiris')
ds = backend.parse_data(['path/to/file1.h5', 'path/to/file2.h5'])

plan_reads §

plan_reads(
    path,
    dirs_runs,
    quants=None,
    records=None,
    mode=ReadMode.SERIES,
    **kwargs
)

Plan backend reads for the supplied run directories.

For openPMD data, jobs are grouped by diagnostic and, in "compare" mode, by record. For the other backends, one job is produced for every discovered run-quantity combination.

Parameters:

Name Type Description Default
path §
str

Base path associated with the run directories. The directories in dirs_runs have already been resolved by the caller.

required
dirs_runs §
dict[str, str]

Mapping from run names to resolved run-directory paths.

required
quants §
str, list[str], or None

Quantity or diagnostic search pattern, or a list of patterns. None searches for all endings supported by the selected backend.

None
records §
str, list[str], or None

openPMD records to associate with each diagnostic. This parameter is used only by the "openpmd" backend.

None
mode §
ReadMode

Read-grouping mode. Available values are ReadMode.SERIES and ReadMode.COMPARE. The default is ReadMode.SERIES.

SERIES
**kwargs §

Additional keyword arguments accepted by the planning interface.

{}

Returns:

Type Description
list[ReadJob]

Planned read jobs.

ReadJob dataclass §

Describe a group of files to be passed to a backend reader.

Parameters:

Name Type Description Default

run §

str

Name of the run containing the files.

required

label §

str

Label assigned to the discovered quantity, diagnostic, or diagnostic-record pair.

required

files §

tuple[str, ...]

File paths belonging to the job.

required

reader_kwargs §

Mapping[str, Any]

Additional keyword arguments for the backend reader. The default is an empty mapping.

dict()

Attributes:

Name Type Description
run str

Name of the run containing the files.

label str

Label assigned to the job.

files tuple[str, ...]

File paths belonging to the job.

reader_kwargs Mapping[str, Any]

Additional keyword arguments for the backend reader.

ReadMode §

Bases: str, Enum


              flowchart TD
              ozzy.backend_interface.ReadMode[ReadMode]

              

              click ozzy.backend_interface.ReadMode href "" "ozzy.backend_interface.ReadMode"
            

Specify how discovered files are grouped into read jobs.

Attributes:

Name Type Description
SERIES str

Group an openPMD diagnostic and all requested records into one job. Its value is "series".

COMPARE str

Create a separate openPMD job for every diagnostic-record pair. Its value is "compare".