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 the relevant section of Data object 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 ('osiris', 'ozzy', 'lcode').

Methods:

Name Description
find_quants

Find matching files for quantities.

_load_quant_files

Load quantity files (calls find_quants()).

parse_data

Read data from files and attach metadata.

Examples:

Create a new Backend instance and read files
backend = Backend('osiris')
files = backend.find_quants(path='sim_dir', dirs_runs={'run1': 'run1_dir'}, quants=['e2', 'b3'])
data = backend.parse_data(files)

find_quants §

find_quants(path, dirs_runs, quants=None)

Searches path for files matching quants in the run directories specified by dirs_runs. All arguments may contain glob patterns.

Parameters:

Name Type Description Default
path §
str

The base path to search for files.

required
dirs_runs §
dict[str, str]

A dictionary mapping run names to directory paths relative to path.

Tip

The dirs_runs parameter can be obtained by running ozzy.find_runs(path, runs_pattern). For example:

import ozzy as oz
dirs_runs = oz.find_runs(path='sim_dir', runs_pattern='param_scan_*')
required
quants §
str, or list[str]

A quantity name or list of quantity names to search for. The search term may contain the full filename ('e1-000001.h5'), only the quantity name ('e1') or any combination with a glob pattern ('e1-*', 'e1-*.h5'). If not provided, any files with the file endings associated with this Backend are searched for.

None

Returns:

Type Description
dict[str, list[str]]

A dictionary mapping quantity names to lists of matching file names.

Examples:

Search for files with a specific quantity
import ozzy.backend_interface as obi
backend = obi.Backend('lcode')
dirs_runs = {'run1': 'path/to/run1', 'run2': 'path/to/run2'}
quants_dict = backend.find_quants('/base/path', dirs_runs, 'xi_Ez')
# quants_dict = {'xi_Ez': ['xi_Ez_0001.swp', 'xi_Ez_0002.swp', ...]}
Search for files with any quantity
import ozzy.backend_interface as obi
backend = obi.Backend('lcode')
dirs_runs = {'run1': 'path/to/run1', 'run2': 'path/to/run2'}
quants_dict = backend.find_quants('/base/path', dirs_runs)
# quants_dict = {'xi_Ez': [...], 'xi_Er': [...], ...}

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'])