2.1.5. 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.

write_SimCenter_DL_output(output_dir, …[, …])

write_SimCenter_EDP_output(output_dir, …)

write_SimCenter_DM_output(output_dir, …)

write_SimCenter_DV_output(output_dir, …)

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.