oasislmf.pytools.getmodel.structure¶
Pre-compute and persist getmodel (modelpy) read-only data structures.
- Follows the same pattern as
oasislmf.pytools.gulmc.structure: create_getmodel_structurebuilds all read-only numpy arrays once and saves them as.npyfiles.load_getmodel_structurememory-maps them vianp.load(mmap_mode='r'), allowing multiple modelpy processes to share physical memory pages through the OS page cache.
Attributes¶
Functions¶
|
Check whether pre-computed getmodel structures exist. |
|
Build all read-only getmodel data structures from input files. |
|
Build and save all read-only getmodel data structures as |
|
Load pre-computed getmodel structures via memory-mapped numpy files. |
Module Contents¶
- oasislmf.pytools.getmodel.structure.ARRAY_FILES = ['vuln_array', 'vulns_id', 'areaperil_id_ind', 'areaperil_to_vulns_idx_array',...[source]¶
- oasislmf.pytools.getmodel.structure.getmodel_structure_exists(run_dir)[source]¶
Check whether pre-computed getmodel structures exist.
- oasislmf.pytools.getmodel.structure.build_structures(run_dir, ignore_file_type, peril_filter, model_df_engine='oasis_data_manager.df_reader.reader.OasisPandasReader')[source]¶
Build all read-only getmodel 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_getmodel_structure) rather than repeated in every parallel modelpy 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). model_df_engine (str): engine for loading model dataframes.
- Returns:
dict: mapping variable names to numpy arrays / scalars.
- oasislmf.pytools.getmodel.structure.create_getmodel_structure(run_dir, ignore_file_type, peril_filter, model_df_engine='oasis_data_manager.df_reader.reader.OasisPandasReader')[source]¶
Build and save all read-only getmodel 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). model_df_engine (str): engine for loading model dataframes.
- oasislmf.pytools.getmodel.structure.load_getmodel_structure(run_dir)[source]¶
Load pre-computed getmodel structures via memory-mapped numpy files.
Each array is loaded with
mmap_mode='r'so that multiple modelpy 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.