|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "metadata": {}, |
| 6 | + "source": [ |
| 7 | + "# Hazard: Hail in Europe\n", |
| 8 | + "\n", |
| 9 | + "\n", |
| 10 | + "Auth: Timo Schmid \n", |
| 11 | + "Date: March 2026\n", |
| 12 | + "\n", |
| 13 | + "This notebook will give a quick tour of the hail hazard data on the climada data API and its usage for impact modelling" |
| 14 | + ] |
| 15 | + }, |
| 16 | + { |
| 17 | + "cell_type": "markdown", |
| 18 | + "metadata": {}, |
| 19 | + "source": [ |
| 20 | + "## Data overview and usage\n", |
| 21 | + "\n", |
| 22 | + "The climada data API contains hail hazard data, based high-resolution climate simulations with the COSMO model and the HAILCAST hail diagnostic, conducted within the [scClim](https://scclim.ethz.ch) research project. \n", |
| 23 | + "The data has been spatially perturbed to create a small probabilistic event set of 330-year duration, as described in detail in [Schmid et al. (2026)](https://doi.org/10.1016/j.cliser.2025.100630)\n", |
| 24 | + "\n", |
| 25 | + "\n", |
| 26 | + "\n" |
| 27 | + ] |
| 28 | + }, |
| 29 | + { |
| 30 | + "cell_type": "code", |
| 31 | + "execution_count": null, |
| 32 | + "metadata": {}, |
| 33 | + "outputs": [], |
| 34 | + "source": [ |
| 35 | + "#Import packages\n", |
| 36 | + "import pandas as pd\n", |
| 37 | + "import numpy as np\n", |
| 38 | + "\n", |
| 39 | + "from climada.util.api_client import Client\n", |
| 40 | + "from climada.entity import ImpactFuncSet, ImpactFunc\n", |
| 41 | + "\n" |
| 42 | + ] |
| 43 | + }, |
| 44 | + { |
| 45 | + "cell_type": "code", |
| 46 | + "execution_count": null, |
| 47 | + "metadata": {}, |
| 48 | + "outputs": [], |
| 49 | + "source": [ |
| 50 | + "#helper functions\n", |
| 51 | + "def get_emanuel_impf(v_thresh=20, v_half=60, scale=1e-3,power=3,\n", |
| 52 | + " impf_id=1, intensity=np.arange(0, 70, 1),\n", |
| 53 | + " intensity_unit='mm',haz_type='HL'):\n", |
| 54 | + " \"\"\"\n", |
| 55 | + " Init TC impact function using the formula of Kerry Emanuel, 2011:\n", |
| 56 | + " https://doi.org/10.1175/WCAS-D-11-00007.1\n", |
| 57 | + "\n", |
| 58 | + " Parameters\n", |
| 59 | + " ----------\n", |
| 60 | + " impf_id : int, optional\n", |
| 61 | + " impact function id. Default: 1\n", |
| 62 | + " intensity : np.array, optional\n", |
| 63 | + " intensity array in intensity_unit.\n", |
| 64 | + " v_thresh : float, optional\n", |
| 65 | + " first shape parameter\n", |
| 66 | + " v_half : float, optional\n", |
| 67 | + " second shape parameter\n", |
| 68 | + " scale : float, optional\n", |
| 69 | + " scale parameter, linear scaling of MDD.\n", |
| 70 | + " 0<=scale<=1. Default: 1.0\n", |
| 71 | + " power : int, optional\n", |
| 72 | + " Exponential dependence. Default to 3 (as in Emanuel (2011))\n", |
| 73 | + "\n", |
| 74 | + " Raises\n", |
| 75 | + " ------\n", |
| 76 | + " ValueError\n", |
| 77 | + "\n", |
| 78 | + " Returns\n", |
| 79 | + " -------\n", |
| 80 | + " impf : ImpactFunc\n", |
| 81 | + " Impact function object\n", |
| 82 | + " \"\"\"\n", |
| 83 | + "\n", |
| 84 | + " #Get the function values. Note that invalid input parameters are checked\n", |
| 85 | + " # within get_emanuel_vals(). (e.g. V_half <= V_thresh)\n", |
| 86 | + " v_temp = get_emanuel_vals(intensity,v_thresh,v_half,scale,power)\n", |
| 87 | + "\n", |
| 88 | + " impf = ImpactFunc(haz_type=haz_type, id=impf_id,intensity=intensity,\n", |
| 89 | + " intensity_unit=intensity_unit,name='Emanuel-type')\n", |
| 90 | + " impf.paa = np.ones(intensity.shape)\n", |
| 91 | + " impf.mdd = v_temp\n", |
| 92 | + " return impf\n", |
| 93 | + "def get_emanuel_vals(intensity,v_thresh=20, v_half=60, scale=1e-3,power=3):\n", |
| 94 | + " \"\"\"Get the Emanuel-type impact function values for a given intensity array\"\"\"\n", |
| 95 | + "\n", |
| 96 | + " #Check whether the input parameters are valid\n", |
| 97 | + " if v_half <= v_thresh:\n", |
| 98 | + " raise ValueError('Shape parameters out of range: v_half <= v_thresh.')\n", |
| 99 | + " if v_thresh < 0 or v_half < 0:\n", |
| 100 | + " raise ValueError('Negative shape parameter.')\n", |
| 101 | + " if scale > 1 or scale <= 0:\n", |
| 102 | + " raise ValueError('Scale parameter out of range.')\n", |
| 103 | + "\n", |
| 104 | + " #Calculate the impact function values\n", |
| 105 | + " v_temp = (intensity - v_thresh) / (v_half - v_thresh)\n", |
| 106 | + " v_temp[v_temp < 0] = 0\n", |
| 107 | + " v_temp = v_temp**power / (1 + v_temp**power)\n", |
| 108 | + " v_temp *= scale\n", |
| 109 | + " return v_temp\n" |
| 110 | + ] |
| 111 | + }, |
| 112 | + { |
| 113 | + "cell_type": "code", |
| 114 | + "execution_count": null, |
| 115 | + "metadata": {}, |
| 116 | + "outputs": [ |
| 117 | + { |
| 118 | + "name": "stdout", |
| 119 | + "output_type": "stream", |
| 120 | + "text": [ |
| 121 | + "{'property': 'data_source', 'mandatory': True, 'description': 'radar (Radar-based daily hail hazard data), model (330-year probabilistice event set)'}\n", |
| 122 | + "{'property': 'radar_variable', 'mandatory': False, 'description': 'MESHS (Maximum Expected Severe Hail Size), POH (Probability Of Hail)'}\n", |
| 123 | + "{'property': 'climate_scenario', 'mandatory': False, 'description': 'REF (Reference period (2011-2021)), PGW (degree PGW scenario)'}\n", |
| 124 | + "{'property': 'country_iso3alpha', 'mandatory': False, 'description': 'ISO3 alpha code for country'}\n", |
| 125 | + "{'property': 'res_km', 'mandatory': False, 'description': 'spatial resolution in kilometers'}\n" |
| 126 | + ] |
| 127 | + } |
| 128 | + ], |
| 129 | + "source": [ |
| 130 | + "#Get an overview of the properties of the 'hail' data type on the climada API\n", |
| 131 | + "\n", |
| 132 | + "client = Client()\n", |
| 133 | + "data_types = client.list_data_type_infos()\n", |
| 134 | + "dtf = pd.DataFrame(data_types)\n", |
| 135 | + "\n", |
| 136 | + "\n", |
| 137 | + "#Select the row with data_type 'hail' and print the 'properties' column\n", |
| 138 | + "hail_properties = dtf[dtf['data_type'] == 'hail'].iloc[0]['properties']\n", |
| 139 | + "for row in hail_properties:\n", |
| 140 | + " print(row)\n" |
| 141 | + ] |
| 142 | + }, |
| 143 | + { |
| 144 | + "cell_type": "code", |
| 145 | + "execution_count": null, |
| 146 | + "metadata": {}, |
| 147 | + "outputs": [ |
| 148 | + { |
| 149 | + "name": "stdout", |
| 150 | + "output_type": "stream", |
| 151 | + "text": [ |
| 152 | + "2026-03-07 11:54:21,146 - climada.hazard.io - INFO - Reading C:\\Users\\timschmi\\climada\\data\\hazard\\hail\\hail_FRA_REF\\v2\\hail_FRA_ref.h5\n" |
| 153 | + ] |
| 154 | + } |
| 155 | + ], |
| 156 | + "source": [ |
| 157 | + "#Load the hazard\n", |
| 158 | + "\n", |
| 159 | + "haz_ref = client.get_hazard(\n", |
| 160 | + " \"hail\",\n", |
| 161 | + " properties={\n", |
| 162 | + " \"data_source\": \"model\",\n", |
| 163 | + " \"climate_scenario\": \"REF\",\n", |
| 164 | + " \"country_iso3alpha\": \"FRA\",\n", |
| 165 | + " },\n", |
| 166 | + ")\n", |
| 167 | + "\n", |
| 168 | + "haz_fut = client.get_hazard(\n", |
| 169 | + " \"hail\",\n", |
| 170 | + " properties={\n", |
| 171 | + " \"data_source\": \"model\",\n", |
| 172 | + " \"climate_scenario\": \"PGW\",\n", |
| 173 | + " \"country_iso3alpha\": \"FRA\",\n", |
| 174 | + " },\n", |
| 175 | + ")\n" |
| 176 | + ] |
| 177 | + }, |
| 178 | + { |
| 179 | + "cell_type": "code", |
| 180 | + "execution_count": null, |
| 181 | + "metadata": {}, |
| 182 | + "outputs": [], |
| 183 | + "source": [ |
| 184 | + "#Plot overview of both present and future hazard\n", |
| 185 | + "\n", |
| 186 | + "haz_ref" |
| 187 | + ] |
| 188 | + }, |
| 189 | + { |
| 190 | + "cell_type": "code", |
| 191 | + "execution_count": null, |
| 192 | + "metadata": {}, |
| 193 | + "outputs": [], |
| 194 | + "source": [ |
| 195 | + "#Set vulnerability functions as described in Schmid et al (2026); Table B.1\n", |
| 196 | + "\n", |
| 197 | + "params_PAA = {'v_thresh': 17.8,'v_half': 39.9,'scale': 1,'power': 4.95}\n", |
| 198 | + "params_MDD = {'a':0.064,'b':3.33e-3}\n", |
| 199 | + "\n", |
| 200 | + "impf_setPAA = ImpactFuncSet([get_emanuel_impf(**params_PAA)])\n", |
| 201 | + "\n", |
| 202 | + "\n", |
| 203 | + "\n" |
| 204 | + ] |
| 205 | + } |
| 206 | + ], |
| 207 | + "metadata": { |
| 208 | + "kernelspec": { |
| 209 | + "display_name": "climada_6", |
| 210 | + "language": "python", |
| 211 | + "name": "python3" |
| 212 | + }, |
| 213 | + "language_info": { |
| 214 | + "codemirror_mode": { |
| 215 | + "name": "ipython", |
| 216 | + "version": 3 |
| 217 | + }, |
| 218 | + "file_extension": ".py", |
| 219 | + "mimetype": "text/x-python", |
| 220 | + "name": "python", |
| 221 | + "nbconvert_exporter": "python", |
| 222 | + "pygments_lexer": "ipython3", |
| 223 | + "version": "3.11.12" |
| 224 | + } |
| 225 | + }, |
| 226 | + "nbformat": 4, |
| 227 | + "nbformat_minor": 4 |
| 228 | +} |
0 commit comments