oasislmf.pytools.getmodel.structure =================================== .. py:module:: oasislmf.pytools.getmodel.structure .. autoapi-nested-parse:: 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 ---------- .. autoapisummary:: oasislmf.pytools.getmodel.structure.logger oasislmf.pytools.getmodel.structure.STRUCTURE_DIR oasislmf.pytools.getmodel.structure.ARRAY_FILES Functions --------- .. autoapisummary:: oasislmf.pytools.getmodel.structure.getmodel_structure_exists oasislmf.pytools.getmodel.structure.build_structures oasislmf.pytools.getmodel.structure.create_getmodel_structure oasislmf.pytools.getmodel.structure.load_getmodel_structure Module Contents --------------- .. py:data:: logger .. py:data:: STRUCTURE_DIR :value: 'getmodel_structure' .. py:data:: ARRAY_FILES :value: ['vuln_array', 'vulns_id', 'areaperil_id_ind', 'areaperil_to_vulns_idx_array',... .. py:function:: getmodel_structure_exists(run_dir) Check whether pre-computed getmodel structures exist. .. py:function:: build_structures(run_dir, ignore_file_type, peril_filter, model_df_engine='oasis_data_manager.df_reader.reader.OasisPandasReader') 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. .. py:function:: create_getmodel_structure(run_dir, ignore_file_type, peril_filter, model_df_engine='oasis_data_manager.df_reader.reader.OasisPandasReader') 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. .. py:function:: load_getmodel_structure(run_dir) 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.