plaid.storage.common.bridge¶
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.
plaid.storage.common.bridge.unflatten_path
¶
Unflattens a Zarr key by replacing underscores with slashes.
Parameters:
-
key(str) –The flattened key with underscores.
Returns:
-
str(str) –The unflattened key with slashes.
Source code in plaid/storage/common/bridge.py
plaid.storage.common.bridge.flatten_path
¶
Flattens a path key by replacing slashes with underscores.
Parameters:
-
key(str) –The path key to flatten.
Returns:
-
str(str) –The flattened key with slashes replaced by underscores.
Source code in plaid/storage/common/bridge.py
plaid.storage.common.bridge.to_sample_dict
¶
Convert variable sample dict to time-based sample dict.
Parameters:
-
var_sample_dict(dict[str, Any]) –Variable features dictionary.
-
flat_cst(dict[str, Any]) –Constant features dictionary.
-
cgns_types(dict[str, str]) –CGNS types dictionary.
-
features(Optional[list[str]], default:None) –Optional list of features to include.
Returns:
-
dict(dict[float, dict[str, Any]]) –Time-based sample dictionary.
Source code in plaid/storage/common/bridge.py
plaid.storage.common.bridge.flat_dict_to_sample_dict
¶
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(dict[str, Any]) –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(dict[str, str]) –Mapping from feature path to CGNS node type; used to determine which None-valued features should be preserved.
-
features(Optional[list[str]], default:None) –Optional list of feature paths to include; if None all features are included.
Returns:
-
dict[float, dict[str, Any]]–A dict mapping time (float) to a flattened tree dict (path -> array or None).
Source code in plaid/storage/common/bridge.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | |
plaid.storage.common.bridge.to_plaid_sample
¶
Convert sample dict to PLAID Sample.
Parameters:
-
sample_dict(dict[float, dict[str, Any]]) –Time-based sample dictionary.
-
cgns_types(dict[str, str]) –CGNS types dictionary.
Returns:
-
Sample(Sample) –The reconstructed PLAID Sample.
Source code in plaid/storage/common/bridge.py
plaid.storage.common.bridge.plaid_to_sample_dict
¶
Convert PLAID Sample to sample dict.
Parameters:
-
sample(Sample) –The PLAID Sample.
-
variable_features(Iterable[str]) –List of variable feature names.
-
constant_features(Iterable[str]) –List of constant feature names.
Returns:
-
dict[str, Any]–dict[str, Any]: sample_dict