oasislmf.pytools.gulmc.structure

Pre-compute and persist gulmc read-only data structures.

Follows the same pattern as oasislmf.pytools.fm.financial_structure:
  • create_gulmc_structure builds all read-only numpy arrays once and saves them as .npy files.

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

Attributes

Functions

gulmc_structure_exists(run_dir)

Check whether pre-computed gulmc structures exist.

build_structures(run_dir, ignore_file_type, ...)

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

create_gulmc_structure(run_dir, ignore_file_type, ...)

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

load_gulmc_structure(run_dir)

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

Module Contents

oasislmf.pytools.gulmc.structure.logger[source]
oasislmf.pytools.gulmc.structure.STRUCTURE_DIR = 'gulmc_structure'[source]
oasislmf.pytools.gulmc.structure.ARRAY_FILES = ['items', 'coverages', 'item_map_ja_areaperil_ids', 'item_map_ja_offsets',...[source]
oasislmf.pytools.gulmc.structure.gulmc_structure_exists(run_dir)[source]

Check whether pre-computed gulmc structures exist.

oasislmf.pytools.gulmc.structure.build_structures(run_dir, ignore_file_type, peril_filter, dynamic_footprint, model_df_engine)[source]

Build all read-only gulmc 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_gulmc_structure) rather than repeated in every parallel gulmc 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). dynamic_footprint (bool): whether to apply dynamic footprint logic. model_df_engine (str): engine for loading model dataframes.

Returns:

dict: mapping variable names to numpy arrays / scalars.

oasislmf.pytools.gulmc.structure.create_gulmc_structure(run_dir, ignore_file_type, peril_filter, dynamic_footprint, model_df_engine)[source]

Build and save all read-only gulmc 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). dynamic_footprint (bool): whether to apply dynamic footprint logic. model_df_engine (str): engine for loading model dataframes.

oasislmf.pytools.gulmc.structure.load_gulmc_structure(run_dir)[source]

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

Each array is loaded with mmap_mode='r' so that multiple gulmc 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.