oasislmf.pytools.gul.structure

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

Follows the same pattern as oasislmf.pytools.gulmc.structure:
  • create_gulpy_structure builds all read-only numpy arrays once and saves them as .npy files.

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

Attributes

Functions

gulpy_structure_exists(run_dir)

Check whether pre-computed gulpy structures exist.

build_structures(run_dir, ignore_file_type, peril_filter)

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

create_gulpy_structure(run_dir, ignore_file_type, ...)

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

load_gulpy_structure(run_dir)

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

Module Contents

oasislmf.pytools.gul.structure.logger[source]
oasislmf.pytools.gul.structure.STRUCTURE_DIR = 'gulpy_structure'[source]
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 (by create_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 .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).

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.