{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Hazard indicators\n", "Physrisk is primarily designed to run 'bottom-up' calculations that model the impact of climate hazards on large numbers of individual assets (including natural) and operations. These calculations can be used to assess financial risks or socio-economic impacts. To do this physrisk collects:\n", "\n", "- hazard indicators and\n", "- models of vulnerability of assets/operations to hazards.\n", "\n", "Hazard indicators – that is, quantities that provide the information about hazards needed by the vulnerability models – are collected from a variety of sources. OS-Climate consolidates public domain hazard indicators and also provides the means to combine these with commercial data.\n", "\n", "We start with public domain indicators: which ones are available and how can these be obtained?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Requesting hazard indicators via the physrisk API\n", "\n", "Using physrisk, hazard indicators can be obtained directly from source, as long as the user has the necessary API keys. Alternatively, the API – which is simply a hosted instance of physrisk – can be used, albeit the number of requests will be restricted to 30,000 latitudes and longitudes.\n", "\n", "We give a walk-through of the hazard indicator API below, as well as examples of how to obtain the inventory of available hazard indicators." ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "vscode": { "languageId": "shellscript" } }, "outputs": [], "source": [ "# pip install nbformat pandas plotly requests" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "vscode": { "languageId": "shellscript" } }, "outputs": [], "source": [ "import pprint as pp\n", "from IPython.display import Markdown, display\n", "import pandas as pd\n", "import plotly.graph_objs as go\n", "from plotly.subplots import make_subplots\n", "import plotly.io\n", "import requests\n", "plotly.io.renderers.default = \"notebook\"" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "base_url = \"https://physrisk-api-sandbox.apps.odh-cl1.apps.os-climate.org/api/\"\n", "\n", "request = {\n", " \"items\": [\n", " {\n", " \"longitudes\": [69.4787, 68.71, 20.1047, 19.8936, 19.6359, 0.5407, 6.9366, 6.935, 13.7319, 13.7319],\n", " \"latitudes\": [34.556, 35.9416, 39.9116, 41.6796, 42.0137, 35.7835, 36.8789, 36.88, -12.4706, -12.4706],\n", " \"request_item_id\": \"my_flood_request\",\n", " \"hazard_type\": \"RiverineInundation\",\n", " \"indicator_id\": \"flood_depth\",\n", " \"scenario\": \"historical\",\n", " \"year\": 1980,\n", " },\n", " {\n", " \"longitudes\": [69.4787, 68.71, 20.1047, 19.8936, 19.6359, 0.5407, 6.9366, 6.935, 13.7319, 13.7319],\n", " \"latitudes\": [34.556, 35.9416, 39.9116, 41.6796, 42.0137, 35.7835, 36.8789, 36.88, -12.4706, -12.4706],\n", " \"request_item_id\": \"my_flood_request\",\n", " \"hazard_type\": \"RiverineInundation\",\n", " \"indicator_id\": \"flood_depth\",\n", " \"scenario\": \"rcp8p5\",\n", " \"indicator_model_gcm\": \"NorESM1-M\", # optional: can specify\n", " \"year\": 2050,\n", " },\n", " {\n", " \"longitudes\": [114.089],\n", " \"latitudes\": [22.4781],\n", " \"request_item_id\": \"my_wind_request_ssp585\",\n", " \"hazard_type\": \"Wind\",\n", " \"indicator_id\": \"max_speed\",\n", " \"scenario\": \"historical\",\n", " \"path\": \"wind/iris/v1/max_speed_{scenario}_{year}\",\n", " # if path is specified then that particular data array is used\n", " \"year\": 2010,\n", " },\n", " {\n", " \"longitudes\": [114.089],\n", " \"latitudes\": [22.4781],\n", " \"request_item_id\": \"my_wind_request_histo\",\n", " \"hazard_type\": \"Wind\",\n", " \"indicator_id\": \"max_speed\",\n", " \"scenario\": \"ssp585\",\n", " \"path\": \"wind/iris/v1/max_speed_{scenario}_{year}\",\n", " \"year\": 2050,\n", " },\n", " {\n", " \"longitudes\": [114.089],\n", " \"latitudes\": [22.4781],\n", " \"request_item_id\": \"my_fire_request\",\n", " \"hazard_type\": \"Fire\",\n", " \"indicator_id\": \"fire_probability\",\n", " \"scenario\": \"ssp585\",\n", " \"path\": \"fire/jupiter/v1/fire_probability_{scenario}_{year}\",\n", " \"year\": 2040,\n", " },\n", " ]\n", "}\n", "url = base_url + \"get_hazard_data\"\n", "response = requests.post(url, json=request).json()\n", "flood_results_baseline, flood_results_rcp585 = (\n", " response[\"items\"][0][\"intensity_curve_set\"],\n", " response[\"items\"][1][\"intensity_curve_set\"],\n", ")\n", "wind_results_baseline, wind_results_ssp585 = (\n", " response[\"items\"][2][\"intensity_curve_set\"],\n", " response[\"items\"][3][\"intensity_curve_set\"],\n", ")\n", "fire_results = response[\"items\"][4][\"intensity_curve_set\"]" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ " \n", " " ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "