oasislmf.computation.data.dummy_model.generate ============================================== .. py:module:: oasislmf.computation.data.dummy_model.generate Classes ------- .. autoapisummary:: oasislmf.computation.data.dummy_model.generate.VulnerabilityFile oasislmf.computation.data.dummy_model.generate.EventsFile oasislmf.computation.data.dummy_model.generate.LossFactorsFile oasislmf.computation.data.dummy_model.generate.FootprintIdxFile oasislmf.computation.data.dummy_model.generate.FootprintBinFile oasislmf.computation.data.dummy_model.generate.DamageBinDictFile oasislmf.computation.data.dummy_model.generate.OccurrenceFile oasislmf.computation.data.dummy_model.generate.RandomFile oasislmf.computation.data.dummy_model.generate.CoveragesFile oasislmf.computation.data.dummy_model.generate.ItemsFile oasislmf.computation.data.dummy_model.generate.AmplificationsFile oasislmf.computation.data.dummy_model.generate.FMProgrammeFile oasislmf.computation.data.dummy_model.generate.FMPolicyTCFile oasislmf.computation.data.dummy_model.generate.FMProfileFile oasislmf.computation.data.dummy_model.generate.FMXrefFile oasislmf.computation.data.dummy_model.generate.GULSummaryXrefFile oasislmf.computation.data.dummy_model.generate.FMSummaryXrefFile Module Contents --------------- .. py:class:: VulnerabilityFile(num_vulnerabilities, num_intensity_bins, num_damage_bins, vulnerability_sparseness, random_seed, directory) Bases: :py:obj:`ModelFile` Generate random data for Vulnerability dummy model file. This file shows the conditional distributions of damage for each intensity bin and for each vulnerability ID. Attributes: generate_data: Generate Vulnerability dummy model file data. .. py:attribute:: num_vulnerabilities .. py:attribute:: num_intensity_bins .. py:attribute:: num_damage_bins .. py:attribute:: vulnerability_sparseness .. py:attribute:: dtypes .. py:attribute:: start_stats .. py:attribute:: random_seed .. py:attribute:: data_length .. py:attribute:: file_name .. py:method:: generate_data() Generate Vulnerability dummy model file data. Yields: vulnerability (int): vulnerability ID. intensity_bin (int): intensity bin ID. damage_bin (int): damage bin ID. probability (float): impact probability. .. py:class:: EventsFile(num_events, directory) Bases: :py:obj:`ModelFile` Generate random data for Events dummy model file. This file lists event IDs to be run. Attributes: generate_data: Generate Events dummy model file data. .. py:attribute:: num_events .. py:attribute:: dtypes .. py:attribute:: start_stats :value: None .. py:attribute:: data_length .. py:attribute:: file_name .. py:method:: generate_data() Generate Events dummy model file data. Yields: event (int): event ID. .. py:class:: LossFactorsFile(num_events, num_amplifications, min_pla_factor, max_pla_factor, random_seed, directory) Bases: :py:obj:`ModelFile` Generate data for Loss Factors dummy model file. This file maps post loss amplification/reduction loss factors to event ID-amplification ID pairs. Attributes: generate_data: Geenrate Loss Factors dummy model file data. write_file: Write data to Loss Factors dummy model file in binary format. .. py:attribute:: num_events .. py:attribute:: num_amplifications .. py:attribute:: min_pla_factor .. py:attribute:: delta_pla_factor .. py:attribute:: random_seed .. py:attribute:: file_name .. py:attribute:: start_stats .. py:attribute:: dtypes .. py:method:: generate_data() Generate Loss Factors dummy model file data. Yields: event (int): event ID amplification (int): amplification ID factor (float): post loss amplification/reduction factor .. py:method:: write_file() Write data to output Loss Factors file in binary format. Checks number of amplifications are greater than 0 before calling base class method. .. py:class:: FootprintIdxFile(directory) Bases: :py:obj:`ModelFile` Generate data for Footprint index dummy model file. The binary footprint file footprint.bin requires the index file footprint.idx. Attributes: write_file: Write data to Footprint index file in binary format. .. py:attribute:: dtypes .. py:attribute:: dtypes_list .. py:attribute:: file_name .. py:method:: write_file(event_id, offset, event_size) Write data to output Footprint index file in binary format. Overrides method in base class. Converts data to arguments to binary and writes to file. Called by FootprintBinFile.generate_data(). Args: event_id (int): event ID. offset (long long): position of data for event ID in generated Footprint binary file relative to beginning of that file. size (long long): size of data corresponding to event ID in generated Footprint binary file, long long. .. py:class:: FootprintBinFile(num_events, num_areaperils, areaperils_per_event, num_intensity_bins, intensity_sparseness, no_intensity_uncertainty, random_seed, directory) Bases: :py:obj:`ModelFile` Generate data for Footprint binary dummy model file. This file shows the intensity of a given event-areaperil combination. The binary footprint file footprint.bin requires the index file footprint.idx. Attributes: generate_data: Generate Footprint binary dummy model file data. .. py:attribute:: num_events .. py:attribute:: num_areaperils .. py:attribute:: areaperils_per_event .. py:attribute:: num_intensity_bins .. py:attribute:: intensity_sparseness .. py:attribute:: no_intensity_uncertainty .. py:attribute:: random_seed .. py:attribute:: file_name .. py:attribute:: event_id :value: 0 .. py:attribute:: start_stats .. py:attribute:: dtypes .. py:attribute:: idx_file .. py:attribute:: size :value: 0 .. py:attribute:: offset :value: 0 .. py:method:: generate_data() Generate Footprint binary dummy model file data. Yields: areaperil (int): areaperil ID. intensity_bin (int): intensity bin ID. probability (float): impact probability. .. py:class:: DamageBinDictFile(num_damage_bins, directory) Bases: :py:obj:`ModelFile` Generate data for Damage Bin Dictionary dummy model file. This file shows the discretisation of the effective damageability cumulative distribution function. Attributes: generate_data: Generate Damage Bin Dictionary dummy model file data. .. py:attribute:: num_damage_bins .. py:attribute:: dtypes .. py:attribute:: start_stats :value: None .. py:attribute:: data_length .. py:attribute:: file_name .. py:method:: generate_data() Generate Damage Bin Dictionary dummy model file data. First bin always runs from 0 to 0, i.e. has a midpoint (interpolation) of 0. Last bin always runs from 0 to 0, i.e. has a midpoint (interpolation) of 1. Yields: bin_id (int): damage bin ID. bin_from (float): damage bin lower limit. bin_to (float): damage bin upper limit. interpolation (float): damage bin midpoint. interval_type (int): interval_type (deprecated). .. py:class:: OccurrenceFile(num_events, num_periods, random_seed, directory, mean, stddev) Bases: :py:obj:`ModelFile` Generate data for Occurrence dummy model file. This file maps events to periods, which can represent any length of time. Attributes: get_num_periods_from_truncated_normal_cdf: Get number of periods on event-by-event basis. get_num_periods_from_truncated_normal_cdf: Get number of periods from truncated normal cumulative distribution function. set_occ_date_id: Set date of occurrence in ktools format. generate_data: Generate Occurrence dummy model file data. .. py:attribute:: num_events .. py:attribute:: num_periods .. py:attribute:: dtypes .. py:attribute:: date_algorithm :value: 1 .. py:attribute:: start_stats .. py:attribute:: random_seed .. py:attribute:: data_length .. py:attribute:: mean .. py:attribute:: stddev .. py:attribute:: file_name .. py:method:: get_num_periods_from_truncated_normal_cdf() Get number of periods from truncated normal cumulative distribution function. Events can occur mupltiple times over multiple periods in the occurrence file. The number of periods per event is modelled by sampling from a truncated normal distribution with mean self.mean and standard deviation self.stddev. The lower tail of the distribution is truncated at 0.5 and the cumulative distribution function is given by: F(x) = [Phi(g(x)) - Phi(g(a))] / [Phi(g(b)) - Phi(g(a))] g(y) = (y - mean) / standard_deviation Phi(g(y)) = 1/2 * (1 + erf(g(y) / sqrt(2))) a = lower boundary = 0.5, b = upper boundary = infinity therefore g(b) -> infinity ===> Phi(g(b)) -> 1 Returns: bound_a (int): lower boundary, when converted to an integer gives number of periods for this event. .. py:method:: get_num_periods_per_event() Get number of periods on event-by-event basis. Determines whether sampling of truncated normal cumulative distribution function is required to obtain number of periods for this event. Returns: mean|bound_a (int): Number of periods for this event. .. py:method:: set_occ_date_id(year, month, day) Set date of occurrence in ktools format. Reduce year, month and day information to a single integer. Args: year (int): year. month (int): month. day (int): day. Returns: date (int): date in ktools format. .. py:method:: generate_data() Generate Occurrence dummy model file data. Yields: event (int): event ID. period_no (int): period number. date (int): date in ktools format. .. py:class:: RandomFile(num_randoms, random_seed, directory) Bases: :py:obj:`ModelFile` Generate data for Random Numbers dummy model file. This optional file contains random numbers for ground up loss sampling. Attributes: generate_data: Generate Random Numbers dummy model file data. .. py:attribute:: num_randoms .. py:attribute:: dtypes .. py:attribute:: start_stats :value: None .. py:attribute:: random_seed .. py:attribute:: data_length .. py:attribute:: file_name .. py:method:: generate_data() Generate Random Numbers dummy model file data. Yields: random number (float): random number. .. py:class:: CoveragesFile(num_locations, coverages_per_location, random_seed, directory) Bases: :py:obj:`ModelFile` Generate data for Coverages dummy model Oasis file. This file maps coverage IDs to Total Insured Values. Attributes: generate_data: Generate Coverages dummy model Oasis file data. .. py:attribute:: num_locations .. py:attribute:: coverages_per_location .. py:attribute:: dtypes .. py:attribute:: start_stats :value: None .. py:attribute:: random_seed .. py:attribute:: data_length .. py:attribute:: file_name .. py:method:: generate_data() Generate Coverages dummy model file data. Yields: total insured value (float): Total Insured Value (TIV). .. py:class:: ItemsFile(num_locations, coverages_per_location, num_areaperils, num_vulnerabilities, random_seed, directory) Bases: :py:obj:`ModelFile` Generate data for Items dummy model Oasis file. This file lists the exposure items for which ground up loss will be sampled. Attributes: generate_data: Generate Items dummy model Oasis file data. .. py:attribute:: num_locations .. py:attribute:: coverages_per_location .. py:attribute:: num_areaperils .. py:attribute:: num_vulnerabilities .. py:attribute:: dtypes .. py:attribute:: start_stats :value: None .. py:attribute:: random_seed .. py:attribute:: data_length .. py:attribute:: file_name .. py:method:: generate_data() Generate Items dummy model file data. Yields: item (int): item ID. item (int): coverage ID = item ID (1-1 mapping). areaperils[coverage] (int): areaperil ID corresponding to coverage ID. vulnerabilities[coverage] (int): vulnerability ID corresponding to coverage ID. location (int): group ID mapped to location ID. .. py:class:: AmplificationsFile(num_locations, coverages_per_location, num_amplifications, random_seed, directory) Bases: :py:obj:`ModelFile` Generate data for Amplifications dummy model Oasis file. This file maps exposure items to amplification IDs. Attributes: generate_data: Generate Amplifications dummy model Oasis file data. write_file: Write data to Amplifications dummy model Oasis file in binary format. .. py:attribute:: num_items .. py:attribute:: num_amplifications .. py:attribute:: random_seed .. py:attribute:: file_name .. py:attribute:: start_stats .. py:attribute:: dtypes .. py:method:: generate_data() Generate Amplifications dummy model Oasis file data. Yields: item (int): item ID amplification (int): amplification ID .. py:method:: write_file() Write data to output Amplifications file in binary format. Checks number of amplifications are greater than 0 before calling base class method. .. py:class:: FMProgrammeFile(num_locations, coverages_per_location, directory) Bases: :py:obj:`FMFile` Generate data for Financial Model Programme dummy model Oasis file. This file shows the level hierarchy. Attributes: generate_data: Generate Financial Model Programme dummy model Oasis file data. .. py:attribute:: dtypes .. py:attribute:: data_length .. py:attribute:: file_name .. py:method:: generate_data() Generate Financial Model Programme dummy model file data. Yields: agg_id (int): from aggregate ID. level (int): level ID. agg_id (int): to aggregate ID. .. py:class:: FMPolicyTCFile(num_locations, coverages_per_location, num_layers, directory) Bases: :py:obj:`FMFile` Generate data for Financial Model Policy dummy model Oasis file. This file shows the calculation rule (from the Financial Model Policy file) that should be applied to aggregations of loss at a particular level. Attributes: generate_data: Generate Financial Model Policy dummy model Oasis file data. .. py:attribute:: num_layers .. py:attribute:: dtypes .. py:attribute:: data_length .. py:attribute:: file_name .. py:method:: generate_data() Generate Financial Model Policy dummy model file data. Yields: level (int): level ID. agg_id (int): aggregate ID. layer (int): layer ID. profile_id (int): profile ID. .. py:class:: FMProfileFile(num_layers, directory) Bases: :py:obj:`ModelFile` Generate data for Financial Model Profile dummy model Oasis file. This file contains the list of calculation rules with profile values used to generate insurance losses. Attributes: generate_data: Generate Financial Model Profile dummy model Oasis file data. .. py:attribute:: num_layers .. py:attribute:: dtypes .. py:attribute:: start_stats :value: None .. py:attribute:: data_length .. py:attribute:: file_name .. py:method:: generate_data() Generate Financial Model Profile dummy model file data. Yields: profile_id (int): profile ID. calculation rule ID (int): calculation rule ID (2 or 100). first deductible (float): first deductible (fixed at 0.0). second deductible (float): second deductible (fixed at 0.0). third deductible (float): third deductible (fixed at 0.0). attachment1 (float): attachment point/excess. limit1 (float): limit. first proportional share (float): first proportional share (0.0 or 0.3). second proportional share (float): second proportional share (fixed at 0.0). third proportional share (float): third proportional share (fixed at 0.0). .. py:class:: FMXrefFile(num_locations, coverages_per_location, num_layers, directory) Bases: :py:obj:`FMFile` Generate data for Financial Model Cross Reference dummy model Oasis file. This file shows the mapping between the financial model output ID, and aggregate and layer IDs. Attributes: generate_data: Generate Financial Model Cross Reference dummy model Oasis file data. .. py:attribute:: num_layers .. py:attribute:: dtypes .. py:attribute:: data_length .. py:attribute:: file_name .. py:method:: generate_data() Generate Financial Model Cross Reference dummy model file data. Yields: output_count (int): output ID. agg_id (int): aggregate ID. layer (int): layer ID. .. py:class:: GULSummaryXrefFile(num_locations, coverages_per_location, directory) Bases: :py:obj:`FMFile` Generate data for Ground Up Losses Summary Cross Reference dummy model Oasis file. This file shows how item ground up losses are summed together at various summary levels in summarycalc. Attributes: generate_data: Generate Ground Up Losses Summary Cross Reference dummy model Oasis file data. .. py:attribute:: dtypes .. py:attribute:: data_length .. py:attribute:: file_name .. py:method:: generate_data() Generate Ground Up Losses Summary Cross Reference dummy model file data. Yields: item (int): item ID. summary_id (int): summary ID. summaryset_id (int): summary set ID. .. py:class:: FMSummaryXrefFile(num_locations, coverages_per_location, num_layers, directory) Bases: :py:obj:`FMFile` Generate data for Financial Model Summary Cross Reference dummy model Oasis file. This file shows how insurance losses are summed together at various levels by summarycalc. Attributes: generate_data: Generate Financial Model Summary Cross Reference dummy model Oasis file data. .. py:attribute:: num_layers .. py:attribute:: dtypes .. py:attribute:: data_length .. py:attribute:: file_name .. py:method:: generate_data() Generate Financial Model Summary Cross Reference dummy model file data. Yields: output_id (int): output ID. summary_id (int): summary ID. summaryset_id (int): summary set ID.