oasislmf.pytools.gul.structure¶
Pre-compute and persist gulpy read-only data structures.
- Follows the same pattern as
oasislmf.pytools.gulmc.structure: create_gulpy_structurebuilds all read-only numpy arrays once and saves them as.npyfiles.load_gulpy_structurememory-maps them vianp.load(mmap_mode='r'), allowing multiple gulpy processes to share physical memory pages through the OS page cache.
Attributes¶
Functions¶
|
Check whether pre-computed gulpy structures exist. |
|
Build all read-only gulpy data structures from input files. |
|
Build and save all read-only gulpy data structures as |
|
Load pre-computed gulpy structures via memory-mapped numpy files. |
Module Contents¶
- oasislmf.pytools.gul.structure.ARRAY_FILES = ['damage_bins', 'coverages', 'items', 'item_map_hm', 'item_map_hm_keys', 'item_map_ja_offsets',...[source]¶
- oasislmf.pytools.gul.structure.gulpy_structure_exists(run_dir)[source]¶
Check whether pre-computed gulpy structures exist.
- oasislmf.pytools.gul.structure.build_structures(run_dir, ignore_file_type, peril_filter)[source]¶
Build all read-only gulpy data structures from input files.
This extracts the preparation logic from
manager.run()into a standalone callable so that it can be invoked once (bycreate_gulpy_structure) rather than repeated in every parallel gulpy process.- Args:
run_dir (str): path to the run directory. ignore_file_type (set[str]): file extensions to ignore when loading. peril_filter (list): list of perils to include (empty = all).
- Returns:
dict: mapping variable names to numpy arrays / scalars.
- oasislmf.pytools.gul.structure.create_gulpy_structure(run_dir, ignore_file_type, peril_filter)[source]¶
Build and save all read-only gulpy data structures as
.npyfiles.- Args:
run_dir (str): path to the run directory. ignore_file_type (set[str]): file extensions to ignore when loading. peril_filter (list): list of perils to include (empty = all).
- oasislmf.pytools.gul.structure.load_gulpy_structure(run_dir)[source]¶
Load pre-computed gulpy structures via memory-mapped numpy files.
Each array is loaded with
mmap_mode='r'so that multiple gulpy processes share physical memory pages through the OS page cache.- Args:
run_dir (str): path to the run directory.
- Returns:
dict: mapping variable names to numpy arrays / scalars.