pelicun.file_io module

This module has classes and methods that handle file input and output.

Contents

read_SimCenter_DL_input(input_path[, …])

Read the damage and loss input information from a json file.

read_SimCenter_EDP_input(input_path[, …])

Read the EDP input information from a text file with a tabular structure.

read_population_distribution(path_POP, occupancy)

Read the population distribution from an external json file.

read_component_DL_data(path_CMP, comp_info)

Read the damage and loss data for the components of the asset.

convert_P58_data_to_json(data_dir, target_dir)

Create JSON data files from publicly available P58 data.

create_HAZUS_EQ_json_files(data_dir, target_dir)

Create JSON data files from publicly available HAZUS data.

create_HAZUS_HU_json_files(data_dir, target_dir)

Create JSON data files from publicly available HAZUS data.

write_SimCenter_DL_output(output_path, output_df)

write_SimCenter_DM_output(DM_file_path, DMG_df)

write_SimCenter_DV_output(DV_file_path, …)

pelicun.file_io.read_SimCenter_DL_input(input_path, assessment_type='P58', verbose=False)[source]

Read the damage and loss input information from a json file.

The SimCenter in the function name refers to having specific fields available in the file. Such a file is automatically prepared by the SimCenter PBE Application, but it can also be easily manipulated or created manually. The accepted input fields are explained in detail in the Input section of the documentation.

Parameters
input_path: string

Location of the DL input json file.

assessment_type: {‘P58’, ‘HAZUS_EQ’, ‘HAZUS_HU’}

Tailors the warnings and verifications towards the type of assessment. default: ‘P58’.

verbose: boolean

If True, the function echoes the information read from the file. This can be useful to ensure that the information in the file is properly read by the method.

Returns
data: dict

A dictionary with all the damage and loss data.

pelicun.file_io.read_SimCenter_EDP_input(input_path, EDP_kinds=('PID', 'PFA'), units={'PFA': 1.0, 'PID': 1.0}, verbose=False)[source]

Read the EDP input information from a text file with a tabular structure.

The SimCenter in the function name refers to having specific columns available in the file. Currently, the expected formatting follows the output formatting of Dakota that is applied for the dakotaTab.out. When using pelicun with the PBE Application, such a dakotaTab.out is automatically generated. The Input section of the documentation provides more information about the expected formatting of the EDP input file.

Parameters
input_path: string

Location of the EDP input file.

EDP_kinds: tuple of strings, default: (‘PID’, ‘PFA’)

Collection of the kinds of EDPs in the input file. The default pair of ‘PID’ and ‘PFA’ can be replaced or extended by any other EDPs.

units: dict, default: {‘PID’:1., ‘PFA’:1}

Defines the unit conversion that shall be applied to the EDP values.

verbose: boolean

If True, the function echoes the information read from the file. This can be useful to ensure that the information in the file is properly read by the method.

Returns
data: dict

A dictionary with all the EDP data.

pelicun.file_io.read_population_distribution(path_POP, occupancy, assessment_type='P58', verbose=False)[source]

Read the population distribution from an external json file.

The population distribution is expected in a format used in FEMA P58, but the list of occupancy categories can be modified and/or extended beyond those available in that document. The population distributions for the occupancy categories from FEMA P58 and HAZUS MH are provided with pelicun in the population.json files in the corresponding folder under resources.

Note: Population distributions in HAZUS do not have a 1:1 mapping to the occupancy types provided in the Technical Manual. We expect inputs to follow the naming convention in the HAZUS Technical Manual and convert those to the broader categories here automatically. During conversion, the following assumptions are made about the occupancy classes: i) RES classes are best described as Residential; ii) COM and REL as Commercial; iii) EDU as Educational; iv) IND and AGR as Industrial; v) Hotels do not have a matching occupancy class.

Parameters
path_POP: string

Location of the population distribution json file.

occupancy: string

Identifies the occupancy category.

assessment_type: {‘P58’, ‘HAZUS_EQ’}

Tailors the warnings and verifications towards the type of assessment. default: ‘P58’.

verbose: boolean

If True, the function echoes the information read from the file. This can be useful to ensure that the information in the file is properly read by the method.

Returns
data: dict

A dictionary with the population distribution data.

pelicun.file_io.read_component_DL_data(path_CMP, comp_info, assessment_type='P58', verbose=False)[source]

Read the damage and loss data for the components of the asset.

DL data for each component is assumed to be stored in a JSON file following the DL file format specified by SimCenter. The name of the file is the ID (key) of the component in the comp_info dictionary. Besides the filename, the comp_info dictionary is also used to get other pieces of data about the component that is not available in the JSON files. Therefore, the following attributes need to be provided in the comp_info: [‘quantities’, ‘csg_weights’, ‘dirs’, ‘kind’, ‘distribution’, ‘cov’, ‘unit’, ‘locations’] Further information about these attributes is available in the Input section of the documentation.

Parameters
path_CMP: string

Location of the folder that contains the component data in JSON files.

comp_info: dict

Dictionary with additional information about the components.

assessment_type: {‘P58’, ‘HAZUS_EQ’, ‘HAZUS_HU’}

Tailors the warnings and verifications towards the type of assessment. default: ‘P58’.

verbose: boolean

If True, the function echoes the information read from the files. This can be useful to ensure that the information in the files is properly read by the method.

Returns
data: dict

A dictionary with damage and loss data for each component.

pelicun.file_io.convert_P58_data_to_json(data_dir, target_dir)[source]

Create JSON data files from publicly available P58 data.

FEMA P58 damage and loss information is publicly available in an Excel spreadsheet and also in a series of XML files as part of the PACT tool. Those files are copied to the resources folder in the pelicun repo. Here we collect the available information on Fragility Groups from those files and save the damage and loss data in the common SimCenter JSON format.

A large part of the Fragility Groups in FEMA P58 do not have complete damage and loss information available. These FGs are clearly marked with an incomplete flag in the JSON file and the ‘Undefined’ value highlights the missing pieces of information.

Parameters
data_dir: string

Path to the folder with the FEMA P58 Excel file and a ‘DL xml’ subfolder in it that contains the XML files.

target_dir: string

Path to the folder where the JSON files shall be saved.

pelicun.file_io.create_HAZUS_EQ_json_files(data_dir, target_dir)[source]

Create JSON data files from publicly available HAZUS data.

HAZUS damage and loss information is publicly available in the technical manuals. The relevant tables have been converted into a JSON input file (hazus_data_eq.json) that is stored in the ‘resources/HAZUS MH 2.1’ folder in the pelicun repo. Here we read that file (or a file of similar format) and produce damage and loss data for Fragility Groups in the common SimCenter JSON format.

HAZUS handles damage and losses at the assembly level differentiating only structural and two types of non-structural component assemblies. In this implementation we consider each of those assemblies a Fragility Group and describe their damage and its consequences in a FEMA P58-like framework but using the data from the HAZUS Technical Manual.

Parameters
data_dir: string

Path to the folder with the hazus_data_eq JSON file.

target_dir: string

Path to the folder where the results shall be saved. The population distribution file will be saved here, the DL JSON files will be saved to a ‘DL json’ subfolder.

pelicun.file_io.create_HAZUS_HU_json_files(data_dir, target_dir)[source]

Create JSON data files from publicly available HAZUS data.

HAZUS damage and loss information is publicly available in the technical manuals and the HAZUS software tool. The relevant data have been collected in a series of Excel files (e.g., hu_Wood.xlsx) that are stored in the ‘resources/HAZUS MH 2.1 hurricane’ folder in the pelicun repo. Here we read that file (or a file of similar format) and produce damage and loss data for Fragility Groups in the common SimCenter JSON format.

The HAZUS hurricane methodology handles damage and losses at the assembly level. In this implementation each building is represented by one Fragility Group that describes the damage states and their consequences in a FEMA P58-like framework but using the data from the HAZUS Technical Manual.

Note: HAZUS calculates lossess independently of damage using peak wind gust speed as a controlling variable. We fitted a model to the curves in HAZUS that assigns losses to each damage state and determines losses as a function of building damage. Results shall be in good agreement with those of HAZUS for the majority of building configurations. Exceptions and more details are provided in the … section of the documentation.

Parameters
data_dir: string

Path to the folder with the hazus_data_eq JSON file.

target_dir: string

Path to the folder where the results shall be saved. The population distribution file will be saved here, the DL JSON files will be saved to a ‘DL json’ subfolder.