|
1 | 1 | { |
2 | 2 | "cells": [ |
3 | | - { |
4 | | - "cell_type": "code", |
5 | | - "execution_count": 1, |
6 | | - "id": "96920214-a14b-4094-9949-36a1175b1df8", |
7 | | - "metadata": {}, |
8 | | - "outputs": [], |
9 | | - "source": [ |
10 | | - "%load_ext autoreload\n", |
11 | | - "%autoreload 2" |
12 | | - ] |
13 | | - }, |
14 | | - { |
15 | | - "cell_type": "markdown", |
16 | | - "id": "56a07dee-25a8-4bb5-a01c-933ee955f067", |
17 | | - "metadata": {}, |
18 | | - "source": [ |
19 | | - "Currently, to run this tutorial, from within a climada_python git repo please run:\n", |
20 | | - "\n", |
21 | | - "```\n", |
22 | | - "mamba create -n climada_trajectory \"python==3.11.*\"\n", |
23 | | - "git fetch\n", |
24 | | - "git checkout feature/risk_trajectory\n", |
25 | | - "mamba env update -n climada_trajectory -f requirements/env_climada.yml\n", |
26 | | - "mamba activate climada_trajectory\n", |
27 | | - "python -m pip install -e ./\n", |
28 | | - "\n", |
29 | | - "```\n", |
30 | | - "\n", |
31 | | - "To be able to select that environment in jupyter you possibly might also need:\n", |
32 | | - "\n", |
33 | | - "```\n", |
34 | | - "mamba install ipykernel\n", |
35 | | - "python -m ipykernel install --user --name climada_trajectory\n", |
36 | | - "```" |
37 | | - ] |
38 | | - }, |
39 | 3 | { |
40 | 4 | "cell_type": "markdown", |
41 | 5 | "id": "856ac388-9edb-497e-a2ff-a325f2a22562", |
|
94 | 58 | "id": "4e0f3261-f443-4cc6-b85b-c6a3d90b73e3", |
95 | 59 | "metadata": {}, |
96 | 60 | "source": [ |
97 | | - "The fundamental idea behing the `trajectories` module is to enable a better assessment of the evolution of risk over time, both by facilitating point by point comparison, and risk \"evolutions\".\n", |
| 61 | + "The fundamental idea behing the `trajectories` module is to enable a better assessment of the evolution of risk over time, both by facilitating point by point comparison, and the \"evolution\" or risk.\n", |
98 | 62 | "\n", |
99 | | - "It aims at facilitating answering questions such as:\n", |
| 63 | + "This module aims at facilitating answering questions such as:\n", |
100 | 64 | "\n", |
101 | 65 | "- How does future hazards (probabilistic event set), exposure and vulnerability change impacts with respect to present?\n", |
102 | 66 | "- How would the impacts compare if a past event were to happen again with present / future exposure?\n", |
103 | | - "- etc." |
| 67 | + "- How will risk evolve in the future under different assumptions on the evolution of hazard, exposure, vulnerability and discount rate?\n", |
| 68 | + "- *etc*.\n", |
| 69 | + "\n", |
| 70 | + "To achieve this, this module introduces two concepts:\n", |
| 71 | + "\n", |
| 72 | + "- Snapshots of risk, a fixed representation of risk (via its three components Exposure, Hazard and Vulnerability) for a given date. This concept is intended to be generic, as such the given date can be something else than a year, a month or a day for instance, but keep in mind that we will not check that the data you provide makes sense for it!\n", |
| 73 | + "- Trajectories of risk, a collection of snapshots,for which risk metrics can be computed and regrouped to ease their evaluation." |
104 | 74 | ] |
105 | 75 | }, |
106 | 76 | { |
|
116 | 86 | "id": "274a342f-54c0-4590-9110-5e297010955e", |
117 | 87 | "metadata": {}, |
118 | 88 | "source": [ |
119 | | - "We use `Snapshot` objects to define a point in time for risk. This object acts as a wrapper of the classic risk framework composed of Exposure, Hazard and Vulnerability. As such it is defined for a specific date (usually a year), and contains references to an `Exposures`, a `Hazard`, and an `ImpactFuncSet` object.\n", |
| 89 | + "We use `Snapshot` objects to define a point in time for risk. This object acts as a wrapper of the classic risk framework composed of Exposure, Hazard and Vulnerability. As such it is defined for a specific date (usually a year), and contains an `Exposures`, a `Hazard`, and an `ImpactFuncSet` object.\n", |
120 | 90 | "\n", |
121 | 91 | "Instantiating such a `Snapshot` is done simply with:\n", |
122 | 92 | "\n", |
|
131 | 101 | "\n", |
132 | 102 | "Note that to avoid any ambiguity, you need to write explicitly `exposure=your_exposure`.\n", |
133 | 103 | "\n", |
134 | | - "Think of `Snapshot` as a representation of risk at, or around, a specific date. Your hazard should thus be a probabilistic set of events representative for the specified date.\n", |
135 | | - "Note that the date does not need to be a year and can be a datetime if you want to make comparisons on a sub-yearly level.\n", |
| 104 | + "Think of `Snapshot` as a representation of risk at, or around, a specific date. Your hazard should be a probabilistic set of events that are representative for the designated date.\n", |
| 105 | + "\n", |
| 106 | + "To be consistent with the intuitive idea of a snapshot, `Snapshot` objects are make a \"deep copy\" of the risk triplet and are immutable. \n", |
| 107 | + "This means that they do not change once created (notably even if you change one of the component, e.g. the Hazard object, outside of the `Snapshot`).\n", |
| 108 | + "If you want a `Snapshot` with a different `Hazard`, you need to create a new one.\n", |
136 | 109 | "\n", |
137 | | - "Below is an example of how to setup a such Snapshot using data from the data API for tropical cyclones in Haiti:" |
| 110 | + "In that spirit, you cannot directly instantiate a Snapshot with an adaptation measure. To include adaptation, you need to first create the snapshot without adaptation, and then use `apply_measure()`, which\n", |
| 111 | + "will return a new `Snapshot`, with the changed (Exposure, Hazard, ImpactFuncSet) according to the given measure.\n", |
| 112 | + "\n", |
| 113 | + "Below is an concrete example of how to create a Snapshot using data from the data API for tropical cyclones in Haiti:" |
138 | 114 | ] |
139 | 115 | }, |
140 | 116 | { |
|
184 | 160 | "exp_present.gdf.rename(columns={\"impf_\": \"impf_TC\"}, inplace=True)\n", |
185 | 161 | "exp_present.gdf[\"impf_TC\"] = 1\n", |
186 | 162 | "\n", |
187 | | - "# Trajectories allow to look at the risk faced by specifics groups of coordinates based on the \"group_id\" column of the exposure\n", |
188 | | - "exp_present.gdf[\"group_id\"] = (exp_present.gdf[\"value\"] > 500000) * 1\n", |
189 | | - "\n", |
190 | 163 | "snap = Snapshot(exposure=exp_present, hazard=haz_present, impfset=impf_set, date=2018)" |
191 | 164 | ] |
192 | 165 | }, |
|
0 commit comments