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_structure builds all read-only numpy arrays once and saves them as .npy files.

  • load_getmodel_structure memory-maps them via np.load(mmap_mode='r'), allowing multiple modelpy processes to share physical memory pages through the OS page cache.

Attributes

Functions

getmodel_structure_exists(run_dir)

Check whether pre-computed getmodel structures exist.

build_structures(run_dir, ignore_file_type, peril_filter)

Build all read-only getmodel data structures from input files.

create_getmodel_structure(run_dir, ignore_file_type, ...)

Build and save all read-only getmodel data structures as .npy files.

load_getmodel_structure(run_dir)

Load pre-computed getmodel structures via memory-mapped numpy files.

Module Contents

oasislmf.pytools.getmodel.structure.logger[source]
oasislmf.pytools.getmodel.structure.STRUCTURE_DIR = 'getmodel_structure'[source]
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 (by create_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 .npy files.

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.