{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Walk-through: modelling impact of climate hazards on cement plants\n", "\n", "This is a worked example of how to specify the vulnerability of an arbitrary asset to different climate hazards via configuration. In this walk-through, assets of type 'CementPlant' which belong to the 'ManufacturingAsset' class are modelled. A custom vulnerability configuration is defined in csv format, both for acute and chronic hazards." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from IPython.display import display\n", "import json\n", "from typing import NamedTuple\n", "from dependency_injector import providers\n", "from physrisk.container import Container\n", "from physrisk.vulnerability_models.vulnerability import VulnerabilityModelsFactory\n", "from physrisk.vulnerability_models.config_based_impact_curves import (\n", " config_items_from_csv,\n", " config_items_to_df,\n", ")\n", "import plotly.io\n", "\n", "plotly.io.renderers.default = \"notebook\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Define a portfolio. The ```asset_class``` must match one of the pre-defined ```physrisk``` classes, but ```type``` is free text that links to the vulnerability functions. In this example we use 'CementPlant' for the ```type```. The field can be hierarchical using a '\\\\' separator, but here for simplicity there is just a single level." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "portfolio = {\n", " \"items\": [\n", " {\n", " \"asset_class\": \"ManufacturingAsset\",\n", " \"type\": \"CementPlant\",\n", " \"latitude\": 46.73753446,\n", " \"longitude\": 15.57335874,\n", " },\n", " {\n", " \"asset_class\": \"ManufacturingAsset\",\n", " \"type\": \"CementPlant\",\n", " \"latitude\": 251.06066169,\n", " \"longitude\": -115.1701174,\n", " },\n", " {\n", " \"asset_class\": \"ManufacturingAsset\",\n", " \"type\": \"CementPlant\",\n", " \"latitude\": 49.1581039901669,\n", " \"longitude\": -123.00551933666,\n", " },\n", " ]\n", "}\n", "request = {\n", " \"assets\": portfolio,\n", " \"include_asset_level\": True,\n", " \"include_calc_details\": True,\n", " \"include_measures\": False,\n", " \"years\": [2050],\n", " \"scenarios\": [\"historical\", \"ssp585\"],\n", " \"calc_settings\": {\n", " \"hazard_interp\": \"linear\",\n", " # \"hazard_scope\": \"RiverineInundation\" # a useful way to select a subset of hazards\n", " },\n", "}" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The configuration for the CementPlants is contained in the file ```cement_plants_example_config.csv```. We will load into a Pandas DataFrame for ease of viewing." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
| \n", " | hazard_class | \n", "asset_class | \n", "asset_identifier | \n", "indicator_id | \n", "indicator_units | \n", "impact_id | \n", "impact_units | \n", "curve_type | \n", "points_x | \n", "points_y | \n", "points_z | \n", "points_kind | \n", "cap_of_points_x | \n", "cap_of_points_y | \n", "activation_of_points_x | \n", "
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | \n", "Wind | \n", "Asset | \n", "type=Generic,location=Asia | \n", "max_speed | \n", "m/s | \n", "damage | \n", "None | \n", "indicator/piecewise_linear | \n", "[20.0, 25.0, 30.0, 35.0, 40.0, 45.0, 50.0, 60.... | \n", "[0.0, 0.0, 0.001, 0.007, 0.024, 0.058, 0.109, ... | \n", "None | \n", "None | \n", "None | \n", "None | \n", "None | \n", "
| 1 | \n", "Wind | \n", "Asset | \n", "type=Generic,location=China Mainland | \n", "max_speed | \n", "m/s | \n", "damage | \n", "None | \n", "indicator/piecewise_linear | \n", "[20.0, 25.0, 30.0, 35.0, 40.0, 45.0, 50.0, 60.... | \n", "[0.0, 0.0, 0.0, 0.002, 0.008, 0.02, 0.039, 0.1... | \n", "None | \n", "None | \n", "None | \n", "None | \n", "None | \n", "
| 2 | \n", "Wind | \n", "Asset | \n", "type=Generic,location=Europe | \n", "max_speed | \n", "m/s | \n", "damage | \n", "None | \n", "indicator/piecewise_linear | \n", "[20.0, 25.0, 30.0, 35.0, 40.0, 45.0, 50.0, 60.... | \n", "[0.0, 0.0, 0.0, 0.003, 0.012, 0.029, 0.057, 0.... | \n", "None | \n", "None | \n", "None | \n", "None | \n", "None | \n", "
| 3 | \n", "Wind | \n", "Asset | \n", "type=Generic,location=Generic | \n", "max_speed | \n", "m/s | \n", "damage | \n", "None | \n", "indicator/piecewise_linear | \n", "[20.0, 25.0, 30.0, 35.0, 40.0, 45.0, 50.0, 60.... | \n", "[0.0, 0.0, 0.0, 0.003, 0.012, 0.029, 0.057, 0.... | \n", "None | \n", "None | \n", "None | \n", "None | \n", "None | \n", "
| 4 | \n", "Wind | \n", "Asset | \n", "type=Generic,location=North America | \n", "max_speed | \n", "m/s | \n", "damage | \n", "None | \n", "indicator/piecewise_linear | \n", "[20.0, 25.0, 30.0, 35.0, 40.0, 45.0, 50.0, 60.... | \n", "[0.0, 0.0, 0.0, 0.003, 0.012, 0.029, 0.057, 0.... | \n", "None | \n", "None | \n", "None | \n", "None | \n", "None | \n", "