oasislmf.pytools.gulmc.manager ============================== .. py:module:: oasislmf.pytools.gulmc.manager .. autoapi-nested-parse:: Ground-up loss Monte Carlo (gulmc) manager. Jagged Array Naming Convention ------------------------------ _ja_id_ind — optional sparse ID → dense index (id_index.py) _ja_offsets — row boundaries: row i spans [offsets[i], offsets[i+1]) _ja_ — one or more parallel flat arrays holding payload data Two-level (nested) jagged arrays repeat the pattern on the payload: _ja__ja_offsets — L2 row boundaries _ja__ja_ — L2 payload data Attributes ---------- .. autoapisummary:: oasislmf.pytools.gulmc.manager.logger oasislmf.pytools.gulmc.manager.CDF_CACHE_EMPTY oasislmf.pytools.gulmc.manager.NO_RNG_INDEX oasislmf.pytools.gulmc.manager.kwargs Functions --------- .. autoapisummary:: oasislmf.pytools.gulmc.manager.run oasislmf.pytools.gulmc.manager.get_last_non_empty oasislmf.pytools.gulmc.manager.pdf_to_cdf oasislmf.pytools.gulmc.manager.calc_eff_damage_cdf oasislmf.pytools.gulmc.manager.get_gul_from_vuln_cdf oasislmf.pytools.gulmc.manager.compute_damage_bin_scaling oasislmf.pytools.gulmc.manager.compute_haz_bin_id oasislmf.pytools.gulmc.manager.build_vuln_pdf oasislmf.pytools.gulmc.manager.resolve_item_cdfs oasislmf.pytools.gulmc.manager.draw_correlation_samples oasislmf.pytools.gulmc.manager.sample_item_losses oasislmf.pytools.gulmc.manager.compute_event_losses oasislmf.pytools.gulmc.manager.process_areaperils_in_footprint oasislmf.pytools.gulmc.manager.reconstruct_coverages Module Contents --------------- .. py:data:: logger .. py:data:: CDF_CACHE_EMPTY .. py:data:: NO_RNG_INDEX .. py:function:: run(run_dir, ignore_file_type, sample_size, loss_threshold, alloc_rule, debug, random_generator, peril_filter=[], file_in=None, file_out=None, data_server=None, ignore_correlation=False, ignore_haz_correlation=False, effective_damageability=False, max_cached_vuln_cdf_size_MB=200, model_df_engine='oasis_data_manager.df_reader.reader.OasisPandasReader', dynamic_footprint=False, **kwargs) Execute the main gulmc workflow. :param run_dir: the directory of where the process is running :type run_dir: str :param ignore_file_type: file extension to ignore when loading :type ignore_file_type: set(str) :param sample_size: number of random samples to draw. :type sample_size: int :param loss_threshold: threshold above which losses are printed to the output stream. :type loss_threshold: float :param alloc_rule: back-allocation rule. :type alloc_rule: int :param debug: for each random sample, print to the output stream the random loss (if 0), the random value used to draw the hazard intensity sample (if 1), the random value used to draw the damage sample (if 2). Defaults to 0. :type debug: int :param random_generator: random generator function id. :type random_generator: int :param peril_filter: list of perils to include in the computation (if None, all perils will be included). Defaults to []. :type peril_filter: list[int], optional :param file_in: filename of input stream. Defaults to None. :type file_in: str, optional :param file_out: filename of output stream. Defaults to None. :type file_out: str, optional :param data_server: if True, run the data server. Defaults to None. :type data_server: bool, optional :param ignore_correlation: if True, do not compute correlated random samples. Defaults to False. :type ignore_correlation: bool, optional :param ignore_haz_correlation: if True, do not compute correlated hazard intensity samples. Defaults to False. :type ignore_haz_correlation: bool, optional :param effective_damageability: if True, it uses effective damageability to draw damage samples instead of using the full monte carlo approach (i.e., to draw hazard intensity first, then damage). :type effective_damageability: bool, optional :param max_cached_vuln_cdf_size_MB: size in MB of the in-memory cache to store and reuse vulnerability cdf. Defaults to 200. :type max_cached_vuln_cdf_size_MB: int, optional :param model_df_engine: The engine to use when loading model dataframes. Defaults to OasisPandasReader. :type model_df_engine: str, optional :param dynamic_footprint: if True, load the dynamic footprint data and adjust hazard intensities at runtime. Defaults to False. :type dynamic_footprint: bool, optional :param \*\*kwargs: additional keyword arguments. socket_server (str) enables the progress ping and, when numeric, gives the port to override; analysis_pk is reported with each ping. :raises ValueError: if alloc_rule is not 0, 1, 2, or 3. :raises ValueError: if alloc_rule is 1, 2, or 3 when debug is 1 or 2. :returns: 0 if no errors occurred. :rtype: int .. py:function:: get_last_non_empty(cdf, bin_i) Remove empty bucket from the end :param cdf: cumulative distribution :param bin_i: last valid bin index :returns: last bin index with an increased in the cdf .. py:function:: pdf_to_cdf(pdf, empty_cdf) Return the cumulative distribution from the probality distribution :param pdf: probality distribution :type pdf: np.array[float] :param empty_cdf: cumulative distribution buffer for output :type empty_cdf: np.array[float] :returns: here we return only the valid part if needed :rtype: cdf (np.array[float]) .. py:function:: calc_eff_damage_cdf(vuln_pdf, haz_pdf, eff_damage_cdf_empty) Calculate the covoluted cumulative distribution between vulnerability damage and hazard probability distribution :param vuln_pdf: vulnerability damage probability distribution :type vuln_pdf: np.array[float] :param haz_pdf: hazard probability distribution :type haz_pdf: np.array[float] :param eff_damage_cdf_empty: output buffer :type eff_damage_cdf_empty: np.array[float] :returns: cdf is stored in eff_damage_cdf_empty, here we return only the valid part if needed :rtype: eff_damage_cdf (np.array[float]) .. py:function:: get_gul_from_vuln_cdf(vuln_rval, vuln_cdf, Ndamage_bins, damage_bins, bin_scaling) .. py:function:: compute_damage_bin_scaling(damage_bins, Neff_damage_bins, tiv) Determine the tiv scaling factor to apply to gul values for a coverage. The scaling depends on the damage type recorded in the last effective damage bin: relative functions scale by tiv, absolute by 1, duration converts annual tiv to daily, and the default path infers relative-vs-absolute from whether the last bin_to is <= 1. :param damage_bins: damage bin dictionary with bin_to and damage_type fields. :type damage_bins: np.array :param Neff_damage_bins: number of effective damage bins. :type Neff_damage_bins: int :param tiv: total insured value of the coverage. :type tiv: float :returns: the scaling factor applied to damage-bin values to produce gul. :rtype: float .. py:function:: compute_haz_bin_id(haz_pdf_record, item, intensity_adjustment, dynamic_footprint, intensity_bin_peril_ids, intensity_bins) Resolve the hazard intensity bin ids for an item's hazard pdf records. With no dynamic footprint the intensity bin ids are read directly from the hazard pdf. With a dynamic footprint the recorded intensities are shifted by ``intensity_adjustment``, clamped to the valid range, and re-mapped to bin ids via the per-peril ``intensity_bins`` lookup table. :param haz_pdf_record: hazard pdf records for this item's areaperil. :type haz_pdf_record: np.array[haz_arr_type] :param item: the item record (needs peril_id when dynamic footprint is active). :type item: np.void :param intensity_adjustment: intensity shift to apply under a dynamic footprint. :type intensity_adjustment: int :param dynamic_footprint: None if no dynamic footprint, otherwise truthy. :type dynamic_footprint: None or object :param intensity_bin_peril_ids: sorted unique encoded peril_ids. :type intensity_bin_peril_ids: np.array[int32] :param intensity_bins: [peril_idx, intensity_value] -> intensity_bin_id. :type intensity_bins: np.array[int32, 2d] :returns: intensity bin ids, one per hazard pdf record. :rtype: np.array .. py:function:: build_vuln_pdf(item, Nhaz_bins, haz_bin_id, vuln_array, Ndamage_bins_max, areaperil_agg_vuln_idx_ja_offsets, areaperil_agg_vuln_idx_ja_data, vuln_pdf_empty) Assemble the per-hazard-bin vulnerability pdf for an item. For a single (non-aggregate) vulnerability the pdf is read straight out of ``vuln_array``. For an aggregate vulnerability the weighted sum of the member vulnerabilities is built from the jagged arrays; bins with no probability collapse to 100% no-loss in the first damage bin, and the result is normalised by the total weight (or by the member count when all weights are zero). :param item: the item record (uses areaperil_agg_vuln_idx / vulnerability_idx). :type item: np.void :param Nhaz_bins: number of hazard bins for this item. :type Nhaz_bins: int :param haz_bin_id: intensity bin id per hazard record. :type haz_bin_id: np.array :param vuln_array: 3d vulnerability array (Nvulnerability, Ndamage_bins_max, Nintensity_bins). :type vuln_array: np.array[float] :param Ndamage_bins_max: maximum number of damage bins. :type Ndamage_bins_max: int :param areaperil_agg_vuln_idx_ja_offsets: jagged array offsets. :type areaperil_agg_vuln_idx_ja_offsets: np.array[oasis_int] :param areaperil_agg_vuln_idx_ja_data: merged structured array with 'vuln_idx' and 'weight'. :type areaperil_agg_vuln_idx_ja_data: np.array :param vuln_pdf_empty: reusable buffer sliced to (Nhaz_bins, Ndamage_bins_max). :type vuln_pdf_empty: np.array[float] :returns: the vulnerability pdf, shape (Nhaz_bins, Ndamage_bins_max). :rtype: np.array[float] .. py:function:: resolve_item_cdfs(compute_info, cdf_group, do_calc_vuln_ptf, Nhaz_bins, item, haz_bin_id, haz_pdf_prob, vuln_array, areaperil_agg_vuln_idx_ja_offsets, areaperil_agg_vuln_idx_ja_data, cdf_cache_tag, cdf_cache_nbins, cdf_cache_mask, cached_vuln_cdfs, vuln_pdf_empty, eff_damage_cdf_empty, haz_i_to_Ndamage_bins_empty, haz_i_to_vuln_cdf_empty) Return an item's effective-damage CDF (and per-hazard-bin vuln CDFs), computing or reading the cache. On a cache miss the vulnerability pdf is (re)built, the effective damage CDF is computed and written to cache slot 0, and — when not running effective_damageability — each per-hazard-bin vulnerability CDF is computed and written to the following contiguous slots. On a cache hit the same CDFs are read back from those slots. ``compute_info['cdf_cache_ctr']``, ``cdf_cache_tag``, ``cdf_cache_nbins`` and ``cached_vuln_cdfs`` are mutated in place. The ``haz_i_to_*`` outputs are always returned (sliced from their reusable buffers) so the return type is stable; they are only populated when ``effective_damageability`` is False, which is also the only case in which the caller reads them. :returns: (eff_damage_cdf, haz_i_to_Ndamage_bins, haz_i_to_vuln_cdf). :rtype: tuple .. py:function:: draw_correlation_samples(compute_info, item, hazard_rng_index, rng_index, sample_size, haz_rndms_base, vuln_rndms_base, haz_eps_ij, damage_eps_ij, norm_inv_parameters, norm_inv_cdf, norm_cdf, vuln_adj, haz_z_unif, vuln_z_unif) Draw the (optionally correlated) hazard and damage random values for one item. Writes ``sample_size`` values into ``haz_z_unif`` and ``vuln_z_unif`` in place. When correlation is enabled for the relevant dimension the values are drawn through the Gaussian copula (``get_corr_rval``); otherwise the item's base random values are copied straight across. Hazard values are only drawn when ``hazard_rng_index >= 0`` (non-deterministic hazard under full Monte Carlo). For a single (non-aggregate) vulnerability the damage values are scaled by the per-vulnerability adjustment. :param compute_info: computation state (do_haz_correlation, do_correlation). :type compute_info: gulmc_compute_info_type :param item: the item record (correlation values, peril_correlation_group, vuln idx). :type item: np.void :param hazard_rng_index: index into haz_rndms_base, or < 0 if hazard is deterministic. :type hazard_rng_index: int :param rng_index: index into vuln_rndms_base for damage sampling. :type rng_index: int :param sample_size: number of random samples to draw. :type sample_size: int :param haz_rndms_base: base random values for hazard sampling. :type haz_rndms_base: np.array[float64] :param vuln_rndms_base: base random values for damage sampling. :type vuln_rndms_base: np.array[float64] :param haz_eps_ij: correlated random values for hazard sampling. :type haz_eps_ij: np.array[float] :param damage_eps_ij: correlated random values for damage sampling. :type damage_eps_ij: np.array[float] :param norm_inv_parameters: parameters for Gaussian inversion. :type norm_inv_parameters: NormInversionParameters :param norm_inv_cdf: inverse Gaussian cdf lookup table. :type norm_inv_cdf: np.array[float] :param norm_cdf: Gaussian cdf lookup table. :type norm_cdf: np.array[float] :param vuln_adj: per-vulnerability adjustment factors. :type vuln_adj: np.array[float] :param haz_z_unif: output buffer for hazard random values. :type haz_z_unif: np.array[float] :param vuln_z_unif: output buffer for damage random values. :type vuln_z_unif: np.array[float] .. py:function:: sample_item_losses(compute_info, item_j, sample_size, hazard_rng_index, dynamic_footprint, item_event_data, haz_z_unif, vuln_z_unif, haz_cdf_prob, Nhaz_bins, eff_damage_cdf, Neff_damage_bins, haz_i_to_Ndamage_bins, haz_i_to_vuln_cdf, damage_bins, damage_bin_scaling, losses) Write the per-sample gul (or debug random values) for one item into ``losses``. In debug modes 1/2 the drawn hazard/damage random values are stored directly. Otherwise the gul is computed per sample: under effective_damageability from the single effective damage CDF; with a single hazard bin from that bin's vulnerability CDF; and in the general case by drawing the hazard bin per sample (with per-sample return-period protection under a dynamic footprint) and using that bin's vulnerability CDF. :param compute_info: computation state (debug, effective_damageability). :type compute_info: gulmc_compute_info_type :param item_j: column index of this item within the coverage's loss buffer. :type item_j: int :param sample_size: number of random samples. :type sample_size: int :param hazard_rng_index: index into hazard random values, or < 0 if hazard deterministic. :type hazard_rng_index: int :param dynamic_footprint: None if no dynamic footprint, otherwise truthy. :type dynamic_footprint: None or object :param item_event_data: per-item event data (return_period, event_rp). :type item_event_data: np.void :param haz_z_unif: hazard random values for this item. :type haz_z_unif: np.array[float] :param vuln_z_unif: damage random values for this item. :type vuln_z_unif: np.array[float] :param haz_cdf_prob: hazard intensity cdf. :type haz_cdf_prob: np.array[float] :param Nhaz_bins: number of hazard bins. :type Nhaz_bins: int :param eff_damage_cdf: effective damage cdf. :type eff_damage_cdf: np.array[oasis_float] :param Neff_damage_bins: number of effective damage bins. :type Neff_damage_bins: int :param haz_i_to_Ndamage_bins: per-hazard-bin vulnerability cdf lengths. :type haz_i_to_Ndamage_bins: np.array[oasis_int] :param haz_i_to_vuln_cdf: per-hazard-bin vulnerability cdfs. :type haz_i_to_vuln_cdf: np.array :param damage_bins: damage bin dictionary. :type damage_bins: np.array :param damage_bin_scaling: tiv scaling factor. :type damage_bin_scaling: float :param losses: loss buffer written in place at column item_j. :type losses: np.array[oasis_float] .. py:function:: compute_event_losses(compute_info, coverages, coverage_ids, items_event_data, items, sample_size, haz_pdf, haz_arr_ptr, vuln_array, damage_bins, cdf_cache_tag, cdf_cache_nbins, cdf_cache_mask, cached_vuln_cdfs, areaperil_agg_vuln_idx_ja_offsets, areaperil_agg_vuln_idx_ja_data, losses, haz_rndms_base, vuln_rndms_base, vuln_adj, haz_eps_ij, damage_eps_ij, norm_inv_parameters, norm_inv_cdf, norm_cdf, vuln_z_unif, haz_z_unif, byte_mv, dynamic_footprint, intensity_bin_peril_ids, intensity_bins) Compute ground-up losses for all coverages in a single event. Iterates over coverages and their items, looking up or computing the vulnerability cdf for each item, then sampling losses using the pre-generated random numbers. Results are written into a byte buffer for streaming output. CDF caching uses a monotonic write counter and array-based slot tracking. Each unique (areaperil, vuln_id[, intensity_adjustment]) CDF group has a pre-computed index stored in eff_cdf_id. cdf_cache_tag[triplet_idx] records the write counter value when the CDFs were cached. A slot is valid when cdf_cache_tag[triplet_idx] >= 0 and cdf_cache_ctr - cdf_cache_tag[triplet_idx] < cdf_cache_size. Physical slot indexing uses bitwise AND with cdf_cache_mask (power-of-two sized cache). For effective_damageability=False, CDFs are stored as contiguous blocks: slot 0 = effective damage CDF, slots 1..Nhaz_bins = per-intensity-bin vulnerability CDFs. :param compute_info: computation state (event_id, cursor position, coverage range, cdf_cache_ctr, thresholds, flags). :type compute_info: gulmc_compute_info_type :param coverages: coverage data indexed by coverage_id. :type coverages: numpy.array[coverage_type] :param coverage_ids: ordered list of coverage_ids to process in this event. :type coverage_ids: numpy.array[int] :param items_event_data: per-item event data populated by reconstruct_coverages, containing item_idx, haz_arr_i, rng_index, hazard_rng_index, and eff_cdf_id (CDF group index). :type items_event_data: numpy.array[items_MC_data_type] :param items: items table merged with correlation parameters. :type items: np.ndarray :param sample_size: number of random samples to draw. :type sample_size: int :param haz_pdf: hazard intensity pdf records for this event. :type haz_pdf: np.array[haz_arr_type] :param haz_arr_ptr: indices where each areaperil's hazard records start in haz_pdf. :type haz_arr_ptr: np.array[int64] :param vuln_array: 3d vulnerability array of shape (Nvulnerability, Ndamage_bins_max, Nintensity_bins). :type vuln_array: np.array[float] :param damage_bins: damage bin dictionary with bin_from, bin_to, interpolation, damage_type. :type damage_bins: np.array :param cdf_cache_tag: CDF group index → write counter when cached (CDF_CACHE_EMPTY = -1). :type cdf_cache_tag: np.array[int64] :param cdf_cache_nbins: physical slot → CDF length (Ndamage_bins). :type cdf_cache_nbins: np.array[int32] :param cdf_cache_mask: bitmask for physical slot indexing (cdf_cache_size - 1). :type cdf_cache_mask: int64 :param cached_vuln_cdfs: 2d cdf cache of shape (cdf_cache_size, Ndamage_bins_max). :type cached_vuln_cdfs: np.array[oasis_float] :param areaperil_agg_vuln_idx_ja_offsets: jagged array offsets. :type areaperil_agg_vuln_idx_ja_offsets: np.array[oasis_int] :param areaperil_agg_vuln_idx_ja_data: merged structured array with fields 'vuln_idx' (dense vulnerability index) and 'weight' (vulnerability weight). :type areaperil_agg_vuln_idx_ja_data: np.array[agg_vuln_idx_weight_dtype] :param losses: reusable 2d buffer for loss values. :type losses: numpy.array[oasis_float] :param haz_rndms_base: base random values for hazard intensity sampling. :type haz_rndms_base: numpy.array[float64] :param vuln_rndms_base: base random values for damage sampling. :type vuln_rndms_base: numpy.array[float64] :param vuln_adj: per-vulnerability adjustment factors. :type vuln_adj: np.array[float] :param haz_eps_ij: correlated random values for hazard sampling. :type haz_eps_ij: np.array[float] :param damage_eps_ij: correlated random values for damage sampling. :type damage_eps_ij: np.array[float] :param norm_inv_parameters: parameters for Gaussian inversion. :type norm_inv_parameters: NormInversionParameters :param norm_inv_cdf: inverse Gaussian cdf lookup table. :type norm_inv_cdf: np.array[float] :param norm_cdf: Gaussian cdf lookup table. :type norm_cdf: np.array[float] :param vuln_z_unif: reusable buffer for correlated vulnerability random values. :type vuln_z_unif: np.array[float] :param haz_z_unif: reusable buffer for correlated hazard random values. :type haz_z_unif: np.array[float] :param byte_mv: output byte buffer for the binary stream. :type byte_mv: numpy.array[byte] :param dynamic_footprint: None if no dynamic footprint, otherwise truthy. :type dynamic_footprint: None or object :param intensity_bin_peril_ids: sorted unique encoded peril_ids (length n_perils). :type intensity_bin_peril_ids: np.array[int32] :param intensity_bins: shape (n_perils, max_intensity + 1) mapping [peril_idx, intensity_value] -> intensity_bin_id. :type intensity_bins: np.array[int32, 2d] :returns: True if all coverages have been processed, False if the buffer is full and the caller should flush and call again. :rtype: bool .. py:function:: process_areaperils_in_footprint(event_footprint, areaperil_id_ind, dynamic_footprint, ap_inds, event_rps, haz_arr_ptr) Process areaperils in the footprint, filtering to those with vulnerability functions. Writes into pre-allocated arrays (ap_inds, event_rps, haz_arr_ptr) that are owned by the caller and reused across events. The buffer stores the dense areaperil index (from `areaperil_id_ind`) rather than the raw `areaperil_id`, so downstream consumers (reconstruct_coverages) can index `item_map_ja_offsets` directly and skip a second id_index lookup. :param event_footprint: footprint entries. :type event_footprint: np.array[Event or footprint_event_dtype] :param areaperil_id_ind: id_index structure for known areaperil_ids. :type areaperil_id_ind: np.array :param dynamic_footprint: true if there is dynamic_footprint. :type dynamic_footprint: bool :param ap_inds: pre-allocated output buffer for dense areaperil indices. :type ap_inds: np.array[uint32] :param event_rps: pre-allocated output buffer for return periods (dynamic only). :type event_rps: np.array[int32] :param haz_arr_ptr: pre-allocated output buffer for hazard pdf offsets. :type haz_arr_ptr: np.array[int64] :returns: number of areaperils stored. If zero, no items have losses. haz_pdf (np.array[haz_arr_type]): hazard intensity pdf (freshly sliced). :rtype: Nhaz_arr_this_event (int) .. py:function:: reconstruct_coverages(compute_info, ap_inds, Nhaz_arr_this_event, haz_arr_ptr, event_rps, item_map_ja_offsets, item_map_ja_vuln_ja_offsets, item_map_ja_vuln_ja_item_idxs, items, item_cdf_group_idx, coverages, compute, haz_seeds, haz_peril_correlation_groups, haz_corr_seeds, vuln_seeds, damage_peril_correlation_groups, damage_corr_seeds, dynamic_footprint, byte_mv, group_seq_rng_index, hazard_group_seq_rng_index) Register each item to its coverage and prepare per-item event data for loss computation. For each (areaperil_id, vulnerability_id) pair present in the event footprint, iterates over all mapped items and: 1. Computes deterministic hash-based random seeds for hazard and damage sampling, using group_id and hazard_group_id respectively. Seeds are deduplicated via pre-allocated arrays indexed by sequential group ids. 2. Maps each item to its coverage structure, tracking the start offset and count. 3. Stores per-item event data (haz_arr_i, rng_index, hazard_rng_index, eff_cdf_id) in the items_event_data array. The eff_cdf_id is the pre-computed CDF group index from item_cdf_group_idx. :param compute_info: computation state; coverage_i, coverage_n, and event_id fields are read/written. :type compute_info: gulmc_compute_info_type :param ap_inds: dense areaperil indices present in the event footprint (from process_areaperils_in_footprint), length >= Nhaz_arr_this_event. :type ap_inds: np.array[uint32] :param Nhaz_arr_this_event: number of valid entries in ap_inds. :type Nhaz_arr_this_event: int :param haz_arr_ptr: per-areaperil offsets into the event hazard pdf; the number of hazard intensity bins for areaperil ap_i is haz_arr_ptr[ap_i+1] - haz_arr_ptr[ap_i]. A count of 1 means the hazard is deterministic and no hazard rng row is needed. :type haz_arr_ptr: np.array[int64] :param event_rps: parallel array of return periods per areaperil (dynamic only). :type event_rps: np.array[int32] :param item_map_ja_offsets: L1 CSR offsets (N_areaperil + 1). :type item_map_ja_offsets: np.array[oasis_int] :param item_map_ja_vuln_ja_offsets: L2 CSR offsets (N_pairs + 1). :type item_map_ja_vuln_ja_offsets: np.array[oasis_int] :param item_map_ja_vuln_ja_item_idxs: flat item indices into items array. :type item_map_ja_vuln_ja_item_idxs: np.array[oasis_int] :param items: items table merged with correlation parameters, containing group_id, hazard_group_id, coverage_id, group_seq_id, hazard_group_seq_id, etc. :type items: np.ndarray :param item_cdf_group_idx: pre-computed mapping from item_idx to CDF group index. :type item_cdf_group_idx: np.array[int64] :param coverages: coverage data indexed by coverage_id. :type coverages: numpy.array[coverage_type] :param compute: output buffer for the list of coverage_ids to be computed. :type compute: numpy.array[int] :param haz_seeds: output buffer for hazard intensity random seeds. :type haz_seeds: numpy.array[int] :param haz_peril_correlation_groups: unique peril correlation groups for hazard. :type haz_peril_correlation_groups: numpy.array[int] :param haz_corr_seeds: output buffer for hazard correlation seeds. :type haz_corr_seeds: numpy.array[int] :param vuln_seeds: output buffer for damage random seeds. :type vuln_seeds: numpy.array[int] :param damage_peril_correlation_groups: unique peril correlation groups for damage. :type damage_peril_correlation_groups: numpy.array[int] :param damage_corr_seeds: output buffer for damage correlation seeds. :type damage_corr_seeds: numpy.array[int] :param dynamic_footprint: None if no dynamic footprint, otherwise truthy. :type dynamic_footprint: None or object :param byte_mv: output byte buffer, may be resized if needed. :type byte_mv: numpy.array[byte] :param group_seq_rng_index: pre-allocated array of size n_unique_groups, used for O(1) group_id to rng_index mapping (reset to NO_RNG_INDEX each event). :type group_seq_rng_index: numpy.array[int64] :param hazard_group_seq_rng_index: pre-allocated array of size n_unique_haz_groups, for hazard_group_id to rng_index mapping. :type hazard_group_seq_rng_index: numpy.array[int64] :returns: (items_event_data, rng_index, hazard_rng_index, byte_mv) - items_event_data (numpy.array[items_MC_data_type]): per-item data including item_idx, haz_arr_i, rng_index, hazard_rng_index, eff_cdf_id. - rng_index (int): number of unique damage random seeds generated. - hazard_rng_index (int): number of unique hazard random seeds generated. Only hazard groups touching a non-deterministic areaperil (and only under full Monte Carlo, not effective damageability) are counted, so this is 0 for events with no hazard uncertainty. Items not assigned a hazard rng row carry the NO_RNG_INDEX sentinel in items_event_data['hazard_rng_index']. - byte_mv (numpy.array[byte]): output buffer, possibly resized. :rtype: tuple .. py:data:: kwargs