Commit 78536135 authored by Marco Kulüke's avatar Marco Kulüke
Browse files

add further comments and emission pathways

parent b185e911
......@@ -63,7 +63,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Which data set do we need? -> Choose Place and Year\n",
"## Which data set do we need? -> Choose Scenario, Place, and Year\n",
"\n",
"<a id='selection'></a>"
]
......@@ -76,10 +76,21 @@
"source": [
"# Produce Widgets\n",
"\n",
"scenarios = {'historical':range(1850, 2015), 'ssp585':range(2015, 2101), 'ssp126':range(2015, 2101), 'ssp245':range(2015, 2101), 'ssp119':range(2015, 2101), 'ssp434':range(2015, 2101), 'ssp460':range(2015, 2101)}\n",
"scenario_box = widgets.Dropdown(options=scenarios, description=\"Select scenario: \", disabled=False,)\n",
"display(scenario_box)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"place_box = widgets.Text(description=\"Enter place:\")\n",
"display(place_box)\n",
"\n",
"x = range(1850, 2014)\n",
"x = scenario_box.value\n",
"year_box = widgets.Dropdown(options=x, description=\"Select year: \", disabled=False,)\n",
"display(year_box)"
]
......@@ -153,7 +164,7 @@
"col_url = \"/work/ik1017/Catalogs/mistral-cmip6.json\"\n",
"\n",
"# Open the catalog with the intake package and name it \"col\" as short for collection\n",
"col = intake.open_esm_datastore(collection_url)"
"col = intake.open_esm_datastore(col_url)"
]
},
{
......@@ -165,15 +176,6 @@
"\"col.df.head()\" shows us the first rows of the table of the catalog."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"col.df.head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
......@@ -197,11 +199,13 @@
"metadata": {},
"outputs": [],
"source": [
"climate_model = \"MPI-ESM1-2-LR\"\n",
"\n",
"query = dict(\n",
" source_id=\"MPI-ESM1-2-HR\", # here we choose Max-Plack Institute's Earth Sytem Model in high resolution\n",
" source_id=climate_model, # here we choose Max-Plack Institute's Earth Sytem Model in high resolution\n",
" variable_id=\"tasmax\", # temperature at surface, maximum\n",
" table_id=\"day\", # daily maximum\n",
" experiment_id=\"historical\", # historical Simulation, 1850-2014\n",
" experiment_id=scenario_box.label, # historical Simulation, 1850-2014\n",
" member_id=\"r10i1p1f1\", # \"r\" realization, \"i\" initialization, \"p\" physics, \"f\" forcing\n",
")\n",
"cat = col.search(**query)\n",
......@@ -306,13 +310,13 @@
"metadata": {},
"outputs": [],
"source": [
"# Find nearest model coordinate by finding thhe index of the nearest grid point\n",
"# Find nearest model coordinate by finding the index of the nearest grid point\n",
"\n",
"abslat = np.abs(tasmax_year_xr[\"lat\"] - location.latitude)\n",
"abslon = np.abs(tasmax_year_xr[\"lon\"] - location.longitude)\n",
"c = np.maximum(abslon, abslat)\n",
"\n",
"([xloc], [yloc]) = np.where(c == np.min(c))"
"([xloc], [yloc]) = np.where(c == np.min(c)) # xloc and yloc are the indices of the neares model grid point"
]
},
{
......@@ -325,12 +329,6 @@
"\n",
"m = folium.Map(location=[location.latitude, location.longitude], zoom_start=8)\n",
"\n",
"tooltip = float(tasmax_year_xr[\"lat\"][yloc].values), float(tasmax_year_xr[\"lon\"][xloc].values)\n",
"folium.Marker(\n",
" [tasmax_year_xr[\"lat\"][yloc], tasmax_year_xr[\"lon\"][xloc]],\n",
" tooltip=tooltip,\n",
" popup=\"Model Grid Cell Center\",\n",
").add_to(m)\n",
"\n",
"tooltip = location.latitude, location.longitude\n",
"folium.Marker(\n",
......@@ -339,14 +337,21 @@
" popup=\"Location selected by You\",\n",
").add_to(m)\n",
"\n",
"#\n",
"tooltip = float(tasmax_year_xr[\"lat\"][yloc].values), float(tasmax_year_xr[\"lon\"][xloc].values)\n",
"folium.Marker(\n",
" [tasmax_year_xr[\"lat\"][yloc], tasmax_year_xr[\"lon\"][xloc]],\n",
" tooltip=tooltip,\n",
" popup=\"Model Grid Cell Center\",\n",
").add_to(m)\n",
"\n",
"# Define model rectangle\n",
"# Define coordinates of model grid cell (just for visualization)\n",
"rect_lat1_model = (tasmax_year_xr[\"lat\"][yloc - 1] + tasmax_year_xr[\"lat\"][yloc]) / 2\n",
"rect_lon1_model = (tasmax_year_xr[\"lon\"][xloc - 1] + tasmax_year_xr[\"lon\"][xloc]) / 2\n",
"rect_lat2_model = (tasmax_year_xr[\"lat\"][yloc + 1] + tasmax_year_xr[\"lat\"][yloc]) / 2\n",
"rect_lon2_model = (tasmax_year_xr[\"lon\"][xloc + 1] + tasmax_year_xr[\"lon\"][xloc]) / 2\n",
"\n",
"# Draw model rectangle\n",
"# Draw model grid cell\n",
"folium.Rectangle(\n",
" bounds=[[rect_lat1_model, rect_lon1_model], [rect_lat2_model, rect_lon2_model]],\n",
" color=\"#ff7800\",\n",
......@@ -358,6 +363,16 @@
"m"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Climate models have a finite resolution. Hence, models do not provide the data of a particular point, but the mean over a model grid cell. Take this in mind when comparing model data with observed data (e.g. weather stations).\n",
"\\\n",
"\\\n",
"Now, we will visualize the daily maximum temperature time series of the model grid cell."
]
},
{
"cell_type": "markdown",
"metadata": {},
......@@ -365,20 +380,35 @@
"## Draw Temperature Time Series and Count Summer days"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The definition of a summer day varies from region to region. According to the [German Weather Service](https://www.dwd.de/EN/ourservices/germanclimateatlas/explanations/elements/_functions/faqkarussel/sommertage.html), \"a summer day is a day on which the maximum air temperature is at least 25.0°C.\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"tasmax_year_place_xr = tasmax_year_xr[:, yloc, xloc] - 273.15\n",
"tasmax_year_place_df = pd.DataFrame(index = tasmax_year_place_xr['time'].values, columns = ['Temperature', 'Summer Day Threshold'])\n",
"tasmax_year_place_xr = tasmax_year_xr[:, yloc, xloc] - 273.15 # Convert Kelvin to °C\n",
"tasmax_year_place_df = pd.DataFrame(index = tasmax_year_place_xr['time'].values, columns = ['Temperature', 'Summer Day Threshold']) # Create Pandas Series\n",
"\n",
"tasmax_year_place_df.loc[:, 'Model Temperature'] = tasmax_year_place_xr.values\n",
"tasmax_year_place_df.loc[:, 'Summer Day Threshold'] = 25\n",
"tasmax_year_place_df.loc[:, 'Model Temperature'] = tasmax_year_place_xr.values # Insert model data into Pandas Series\n",
"tasmax_year_place_df.loc[:, 'Summer Day Threshold'] = 25 # Insert threshold into Pandas series\n",
"\n",
"# Plot data and define title and legend\n",
"tasmax_year_place_df.hvplot.line(y=['Model Temperature', 'Summer Day Threshold'], \n",
" value_label='Temperature in °C', legend='bottom', title='Daily maximum Temperature near Surface for ' +place.value, height=500, width=620)"
" value_label='Temperature in °C', legend='bottom', title='Daily maximum Temperature near Surface for ' +place_box.value, height=500, width=620)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"As we can see, the maximum daily temperature is highly variable over the year. You might wonder, why there is a different amount of summer days than you would expect. The reason is, because we are looking at a model grid cell mean. (E.g. if the model grid cell area includes a substantial part of the ocean, the mean temperature in this grid cell will be less.)"
]
},
{
......@@ -387,8 +417,10 @@
"metadata": {},
"outputs": [],
"source": [
"no_summer_days_model = tasmax_year_place_xr[tasmax_year_place_xr > 25].size\n",
"print(\"Model: In \" +str(year.value) +\" \" +place.value +\" had \" + str(no_summer_days_model)+\" summer days.\")"
"no_summer_days_model = tasmax_year_place_xr[tasmax_year_place_xr > 25].size # count the number of summer days\n",
"\n",
"# Print results in a sentence\n",
"print(\"According to the German Weather Service definition, in the scenario \" +scenario_box.label +\" the \" +climate_model +\" model shows \" +str(no_summer_days_model) +\" summer days for \" +str(place_box.value) + \" in \" + str(year_box.value) +\".\")"
]
},
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment