plaid.storage.common.bridge¶
Common bridge utilities.
This module provides bridge functions for converting between PLAID samples and storage formats, including flattening/unflattening and sample reconstruction.
Functions¶
|
Unflattens a Zarr key by replacing underscores with slashes. |
|
Flattens a path key by replacing slashes with underscores. |
|
Convert variable sample dict to time-based sample dict. |
|
Convert a flattened sample dict into a time-indexed flat-tree mapping. |
|
Convert sample dict to PLAID Sample. |
|
Convert PLAID Sample to sample dict. |
Module Contents¶
- to_sample_dict(var_sample_dict: dict[str, Any], flat_cst: dict[str, Any], cgns_types: dict[str, str], features: list[str] | None = None) dict[float, dict[str, Any]][source]¶
Convert variable sample dict to time-based sample dict.
- Parameters:
var_sample_dict – Variable features dictionary.
flat_cst – Constant features dictionary.
cgns_types – CGNS types dictionary.
features – Optional list of features to include.
- Returns:
Time-based sample dictionary.
- Return type:
- flat_dict_to_sample_dict(flat_dict: dict[str, Any], cgns_types: dict[str, str], features: list[str] | None = None) dict[float, dict[str, Any]][source]¶
Convert a flattened sample dict into a time-indexed flat-tree mapping.
This function processes a single flattened sample dictionary where keys are feature paths or feature path suffixed with ‘_times’ (holding time interval specs). It splits values and their corresponding time specifications, slices feature arrays per interval and groups features by their sample time into CGNS-style flattened trees.
- Parameters:
flat_dict – Mapping of flattened feature paths to values or to time specifications (keys ending with ‘_times’). Time specifications must be sequences or arrays reshapeable to (-1, 3) rows of (time, start, end).
cgns_types – Mapping from feature path to CGNS node type; used to determine which None-valued features should be preserved.
features – Optional list of feature paths to include; if None all features are included.
- Returns:
A dict mapping time (float) to a flattened tree dict (path -> array or None).
- to_plaid_sample(sample_dict: dict[float, dict[str, Any]], cgns_types: dict[str, str]) plaid.containers.sample.Sample[source]¶
Convert sample dict to PLAID Sample.
- Parameters:
sample_dict – Time-based sample dictionary.
cgns_types – CGNS types dictionary.
- Returns:
The reconstructed PLAID Sample.
- Return type: