ra2ce.analysis.damages.damage_functions package#

Submodules#

ra2ce.analysis.damages.damage_functions.damage_fraction_uniform module#

GNU GENERAL PUBLIC LICENSE

Version 3, 29 June 2007

Risk Assessment and Adaptation for Critical Infrastructure (RA2CE). Copyright (C) 2023 Stichting Deltares

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

class DamageFractionUniform(*, name, hazard_unit, data, origin_path, interpolator=None)[source]#

Bases: object

Uniform: assuming the same curve for each road type and lane numbers and any other metadata

self.raw_data (pd.DataFrame) : Raw data from the csv file self.data (pd.DataFrame) : index = hazard severity (e.g. flood depth); column 0 = damage fraction

Parameters:
  • name (str)

  • hazard_unit (str)

  • data (DataFrame)

  • origin_path (Path)

  • interpolator (interp1d)

create_interpolator()[source]#

Create interpolator object from loaded data sets result to self.interpolator (Scipy interp1d)

data: DataFrame#
classmethod from_csv(csv_path, sep)[source]#

Construct object from csv file. Damage curve name is inferred from filename

Return type:

DamageFractionUniform

Parameters:
  • csv_path (Path)

  • sep (str)

Arguments:

csv_path (Path) : Path to the csv file sep (str) : csv seperator output_unit (str) : desired output unit

The CSV file should have the following structure:
  • column 1: hazard severity

  • column 2: damage fraction

  • row 1: column names

  • row 2: unit of column:

Example:

+- ——+——————————-+ | depth | damage | +——-+——————————-+ | cm | % of total construction costs | +——-+——————————-+ | 0 | 0 | +——-+——————————-+ | 50 | 0.25 | +——-+——————————-+ | 100 | 0.42 | +——-+——————————-+

hazard_unit: str#
interpolator: interp1d = None#
name: str#
origin_path: Path#

ra2ce.analysis.damages.damage_functions.damage_function_road_type_lane module#

GNU GENERAL PUBLIC LICENSE

Version 3, 29 June 2007

Risk Assessment and Adaptation for Critical Infrastructure (RA2CE). Copyright (C) 2023 Stichting Deltares

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

class DamageFunctionByRoadTypeByLane(*, max_damage, damage_fraction, name)[source]#

Bases: object

A damage function that has different max damages per road type, but a uniform damage_fraction curve

The attributes need to be of the type: self.max_damage (MaxDamage) self.damage_fraction (DamageFractionUniform) name (str)

Parameters:
add_max_damage(df, prefix)[source]#

“Ads the max damage value to the dataframe

Return type:

DataFrame

Parameters:
  • df (DataFrame)

  • prefix (str)

calculate_damage(df, damage_function_prefix, hazard_prefix, event_prefix)[source]#

Calculates the damage for one event. The prefixes are used to find/set the right df columns.

Return type:

DataFrame

Parameters:
  • df (DataFrame)

  • damage_function_prefix (str)

  • hazard_prefix (str)

  • event_prefix (str)

Args:

df (pd.DataFrame): dataframe with road network data. damage_function_prefix (str): prefix to identify the right damage function e.g. ‘A’. hazard_prefix (str): prefix to identify the right hazard e.g. ‘F’. event_prefix (str): prefix to identify the right event, e.g. ‘EV1’

Returns:

pd.DataFrame: dataframe data with the damage calculation added as new column

damage_fraction: DamageFractionUniform#
classmethod from_input_folder(name, folder_path)[source]#

Construct a set of damage functions from csv files located in the folder_path

Return type:

DamageFunctionByRoadTypeByLane

Parameters:
  • name (str)

  • folder_path (Path)

Arguments:

name (str) : name of the damage function folder_path (Pathlib Path) : path to folder where csv files can be found

max_damage: MaxDamage#
name: str#
property prefix: str#

ra2ce.analysis.damages.damage_functions.manual_damage_functions module#

GNU GENERAL PUBLIC LICENSE

Version 3, 29 June 2007

Risk Assessment and Adaptation for Critical Infrastructure (RA2CE). Copyright (C) 2023 Stichting Deltares

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

class ManualDamageFunctions(*, damage_functions=<factory>)[source]#

Bases: object

” This class keeps an overview of the manual damage functions

Default behaviour is to find, load and apply all available functions At 22 sept 2022: only implemented workflow for DamageFunction_by_RoadType_by_Lane

Parameters:

damage_functions (dict[str, DamageFunctionByRoadTypeByLane])

damage_functions: dict[str, DamageFunctionByRoadTypeByLane]#

ra2ce.analysis.damages.damage_functions.manual_damage_functions_reader module#

GNU GENERAL PUBLIC LICENSE

Version 3, 29 June 2007

Risk Assessment and Adaptation for Critical Infrastructure (RA2CE). Copyright (C) 2023 Stichting Deltares

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

class ManualDamageFunctionsReader(*args, **kwargs)[source]#

Bases: FileReaderProtocol

Reader class for the manual damage functions.

read(file_path)[source]#

Read the manual damage functions from the given folder. The folder should contain subfolders with the damage functions. Each damage functions is constructed by reading the csv files for the max damage and damage fraction.

Return type:

ManualDamageFunctions

Parameters:

file_path (Path)

Args:

file_path (Path): Pathm to the folder containing the manual damage functions folders

Returns:

ManualDamageFunctions: The manual damage functions

ra2ce.analysis.damages.damage_functions.max_damage module#

GNU GENERAL PUBLIC LICENSE

Version 3, 29 June 2007

Risk Assessment and Adaptation for Critical Infrastructure (RA2CE). Copyright (C) 2023 Stichting Deltares

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

class MaxDamage(*, name, damage_unit, data, origin_path=None)[source]#

Bases: object

Max damage per RoadType and per Lane

Parameters:
  • name (str)

  • damage_unit (str)

  • data (DataFrame)

  • origin_path (Path)

damage_unit: str#
data: DataFrame#
classmethod from_csv(csv_path, sep)[source]#

Construct object from csv file. Damage curve name is inferred from filename

The first row describes the lane numbers per column and should have ‘Road_type lanes’ as index/first value. Assume road types are in the rows; lane numbers in the columns. The second row has the units per column, and should have ‘unit’ as index/first value the rest of the rows contains the different road types as index/first value; and the costs as values

Return type:

MaxDamage

Parameters:
  • csv_path (Path)

  • sep (str)

Arguments:

csv_ (Path) : Path to the csv file sep (str) : csv seperator

name: str#
origin_path: Path = None#

Module contents#