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. |
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 ( |
Methods:
Name | Description |
---|---|
find_quants |
Find matching files for quantities. |
_load_quant_files |
Load quantity files (calls |
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 |
---|---|---|---|
|
str
|
The base path to search for files. |
required |
|
dict[str, str]
|
A dictionary mapping run names to directory paths relative to Tip The
|
required |
|
str, or list[str]
|
A quantity name or list of quantity names to search for. The search term may contain the full filename ( |
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 |
---|---|---|---|
|
list[str]
|
File paths to read data from. |
required |
|
Positional arguments to be passed to the |
()
|
|
|
{}
|
Returns:
Type | Description |
---|---|
Dataset
|
Parsed data. Includes the following Dataset attributes: |
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'])