Skip to content

Commit

Permalink
Upload final project
Browse files Browse the repository at this point in the history
  • Loading branch information
xyliu6666 authored Oct 27, 2023
1 parent 356b5c8 commit fdd34ef
Showing 1 changed file with 318 additions and 1 deletion.
319 changes: 318 additions & 1 deletion chapters/project/FinalProject-2023Fall.ipynb
Original file line number Diff line number Diff line change
@@ -1 +1,318 @@

{
"cells": [
{
"cell_type": "markdown",
"id": "ea863e05",
"metadata": {},
"source": [
"## Visualizing Emerging Risks of Heat Extremes and Premature Death Rate in Southeast Asia under Climate Change\n",
"\n",
"```{admonition} Project Overview\n",
":class: tip\n",
"\n",
"Design creative visualizations to unravel the risks of heat extremes and the associated premature mortality rate in Southeast Asia using the latest climate model simulations.\n",
"\n",
"```"
]
},
{
"cell_type": "markdown",
"id": "af48d568",
"metadata": {},
"source": [
"```{admonition} Submission Guide\n",
"\n",
"Deadline: **Tuesday 11:59 pm, 5th December 2023** \n",
"(Note: Late submissions will not be accepted). \n",
"\n",
"You must submit your project to [Canvas](https://canvas.nus.edu.sg/courses/47849/assignments). Please upload a Jupyter Notebook with the name “FinalProject_StudentID.ipynb”. You need to include your codes, figures, and the required write-ups in a single Jupyter Notebook file. Make sure to write down your student ID and full name in the cell below.\n",
"\n",
"For any questions, feel free to contact Prof. Xiaogang HE ([hexg@nus.edu.sg](mailto:hexg@nus.edu.sg)) and Zhixiao NIU ([niu.zhixiao@u.nus.edu](mailto:niu.zhixiao@u.nus.edu)).\n",
"\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "c8ae81f2",
"metadata": {},
"outputs": [],
"source": [
"### Fill your student ID and full name below.\n",
"\n",
"# Student ID:\n",
"# Full name:"
]
},
{
"cell_type": "markdown",
"id": "5abc96cb",
"metadata": {},
"source": [
"### Data Description\n",
"\n",
"Each of you has been randomly assigned a city in Southeast Asia (see Figure below) according to your student ID. For this project, you only need to work on the city that we assigned to you. Simulated near-surface air temperature (tas, unit: K) from the latest climate models have been provided (available [here](https://github.com/XiaogangHe/python-climate-visuals/tree/master/assets/data/finalproject), you can load the data directly without downloading using the example provided below). This data have been divided into two parts: historical (1850.01.01-2014.12.31) simulations (`CityName_hist.csv`) and future (2015.01.01-2099.12.31) projections (`CityName_future.csv`). Historical data contains 12 climate models and 60265 time steps. Future data contains 12 climate models and 31046 time steps in 2 climate scenarios (ssp245: sustainable development scenario; ssp585: fossil-fuel based development; check SSP details [here](https://www.carbonbrief.org/explainer-how-shared-socioeconomic-pathways-explore-future-climate-change)). "
]
},
{
"cell_type": "markdown",
"id": "d38d15ed",
"metadata": {},
"source": [
"<img src=\"../../assets/images/selected_city.png\" width=\"80%\" align=\"center\"/>"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "d09b7c22",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Singapore\n"
]
}
],
"source": [
"# Run the following script to obtain the city assigned to you. \n",
"# Note: You must use the assigned city for this project.\n",
"\n",
"def getCityName(studentID):\n",
" \n",
" import json\n",
" studentCity = json.load(open('../../assets/data/2023_FinalProject_Student_City.json'))\n",
" \n",
" if studentID not in studentCity.keys():\n",
" raise ValueError('%s is not a correct student ID!'%studentID)\n",
" else:\n",
" return studentCity[studentID]\n",
"\n",
"# Example: (please use your own ID)\n",
"studentID = 'A0000000B' \n",
"cityName = getCityName(studentID)\n",
"\n",
"print(cityName)"
]
},
{
"cell_type": "markdown",
"id": "0fea729c",
"metadata": {},
"source": [
"An example is provided on how to load the temperature data for historical (tas_hist) and future (tas_ssp245, tas_ssp585) simulations from the provided `.csv` files. For more details on data loading and preprocessing, please check the [Pandas tutorial](https://xiaoganghe.github.io/python-climate-visuals/chapters/data-analytics/pandas-basic.html#input-output-of-data)."
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "6274a575",
"metadata": {},
"outputs": [],
"source": [
"# Run the following script to obtain the data assigned to you. \n",
"cityName = \"Singapore\"\n",
"\n",
"def load_data(cityName):\n",
" \n",
" import pandas as pd\n",
" url = \"https://raw.githubusercontent.com/XiaogangHe/python-climate-visuals/master/assets/data/finalproject\"\n",
" hist_address = url + \"/\" + cityName + \"_hist.csv\"\n",
" future_address = url + \"/\" + cityName + \"_future.csv\"\n",
" \n",
" # Refer to https://pandas.pydata.org/pandas-docs/stable/user_guide/advanced.html\n",
" # for more details about MultiIndex of DataFrame \n",
" hist = pd.read_csv(hist_address, header=[0,1], \n",
" index_col=0, parse_dates=True)\n",
" idx = pd.IndexSlice\n",
" # huss_hist = hist.loc[:,idx[\"huss\",:]].droplevel(level=0,axis=1)\n",
" tas_hist = hist.loc[:,idx[\"tas\",:]].droplevel(level=0,axis=1)\n",
" \n",
" future = pd.read_csv(future_address, header=[0,1,2], index_col=0, parse_dates=True)\n",
"\n",
" # huss_ssp245 = future.loc[:,idx[\"huss\",\"ssp245\",:]].droplevel(level=[0,1],axis=1)\n",
" # huss_ssp585 = future.loc[:,idx[\"huss\",\"ssp585\",:]].droplevel(level=[0,1],axis=1)\n",
" tas_ssp245 = future.loc[:,idx[\"tas\",\"ssp245\",:]].droplevel(level=[0,1],axis=1)\n",
" tas_ssp585 = future.loc[:,idx[\"tas\",\"ssp585\",:]].droplevel(level=[0,1],axis=1)\n",
" \n",
" return tas_hist, tas_ssp245, tas_ssp585\n",
"\n",
"tas_hist, tas_ssp245, tas_ssp585 = load_data(cityName)"
]
},
{
"cell_type": "markdown",
"id": "89af3af8",
"metadata": {},
"source": [
"### Task 1 (20 marks)\n",
"\n",
"Create “warming” stripes to visualize historical (1950-2014) and future (2015-2099) warming trends. You can use the annual average temperature from 1850 to 1900 as the baseline to calculate annual temperature anomalies for the required periods (1950-2014 and 2015-2099). "
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "a6aa6f17",
"metadata": {},
"outputs": [],
"source": [
"# Your solutions go here.\n",
"# Use the + icon in the toolbar to add a cell."
]
},
{
"cell_type": "markdown",
"id": "c03f010a",
"metadata": {},
"source": [
"### Task 2 (40 marks)\n",
"\n",
"Visualize the changing risks of heat extremes from historical (1950-2014) to future (2015-2099) periods. To do this, you need to:\n",
"\n",
"- Fit Generalized Extreme Value (GEV) distributions to the annual maximum daily temperature over different periods (e.g., 1850-1900 for pre-industrial baseline, 1950-2014 for the historical period, and 2015-2099 for future scenarios) and across different emission scenarios (ssp245 and ssp585), respectively. How do the shapes of GEV distributions change? \n",
"- Visualize the shift in your fitted GEV distributions over different periods and across different emission scenarios. (Hint: You may use visualization tools such as [Ridgeline plot](https://www.data-to-viz.com/graph/ridgeline.html#:~:text=Definition,presented%20with%20a%20slight%20overlap.))\n",
"- Calculate the return period for heat extremes in historical and future scenarios based on the fitted GEV distribution using pre-industrial data. Compare with the return period obtained from fitted GEV distributions using historical and future simulations. What do you observe?"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "432ead68",
"metadata": {},
"outputs": [],
"source": [
"# Your solutions go here.\n",
"# Use the + icon in the toolbar to add a cell."
]
},
{
"cell_type": "markdown",
"id": "43a25e7c",
"metadata": {},
"source": [
"### Task 3 (20 marks)\n",
"Extreme heat increases the risk of a number of adverse health outcomes, worsening chronic health conditions such as heart and lung disease. Moreover, exposure to hot temperatures is associated with premature deaths. Based on the GEV distribution that you fit to the future temperature simulation, compare heat-induced excess mortality in different levels of heat extremes.\n",
"To do this, you need to:\n",
"\n",
"- Calculate the excess mortality rate for the 45- to 64-year-old population (see Eq (1) in the Appendix) for the 1-in-100-year heat extreme under the ssp245 scenario.\n",
"- Repeat the above calculation for the 1-in-1000-year and 1-in-10000-year event and visualize the difference against the 1-in-100-year event.\n",
"- Repeat the calculation for the ssp585 scenario for all three event (i.e., 1-in-100-year, 1-in-1000-year, 1-in-10000-year) and visualize the difference against the ssp245 scenario."
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "b9813f27",
"metadata": {},
"outputs": [],
"source": [
"# Your solutions go here.\n",
"# Use the + icon in the toolbar to add a cell."
]
},
{
"cell_type": "markdown",
"id": "200070e4",
"metadata": {},
"source": [
"### Short Write-ups (20 marks)\n",
"- What story are you trying to tell? (Hints: You could discuss major findings from your analysis, key takeaways, and possible implications.)\n",
"- Why did you choose such a design and how does it facilitate effective communication? (Hint: you could provide some rationale in terms of your choice of chart types, use of color, size, etc.)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "d53eb7d9",
"metadata": {},
"outputs": [],
"source": [
"# Your write-ups go here.\n",
"# Use the + icon in the toolbar to add a cell."
]
},
{
"cell_type": "markdown",
"id": "030b48e3",
"metadata": {},
"source": [
"### Tips\n",
"- For all three tasks, design your visualizations to **incorporate uncertainties** from (1) climate models (which exist over the entire period from 1950-2099) and (2) climate scenarios (which only exist during 2015-2099).\n",
"- While you can create 24 (12 climate models × 2 climate scenarios) similar warming stripes for Task 1, I hope you could come up with some creative design (e.g., layout, chart types) to visualize all information with a minimum number of graphs.\n",
"- You can recycle your codes from HW1 and HW2.\n",
"- Official IPCC visual style guide can be found [here](https://www.ipcc.ch/site/assets/uploads/2019/04/IPCC-visual-style-guide.pdf).\n",
"- Feel free to make your own design. You can also utilize [animation for storytelling](https://ipyvizzu.vizzuhq.com/)."
]
},
{
"cell_type": "markdown",
"id": "3fc14425",
"metadata": {},
"source": [
"### Appendix\n",
"Exposure to heat extremes is associated with premature death. Assume the empirical relationship between temperature and excess mortality rate for the 45- to 64-year-old population can be estimated by:\n",
"\n",
"$$ \\text{Mortality}= \\left\\{\n",
"\\begin{array}{ll}\n",
" -0.54 * T - 0.2, T \\le -10\\\\\n",
" -0.25 * T + 2.8, -10 < T \\le 15 \\\\\n",
" -0.1 * T + 0.55, 15 < T \\le 22 \\\\\n",
" 0.5 * T - 12.65, 22 < T \\le 25 \\\\\n",
" 0.75 * T - 18.9, T > 25 \\\\\n",
"\\end{array} \n",
"\\right. \\tag{1}$$ \n",
"\n",
"where $\\text{Mortality}$ is the excess mortality (per 100k) for the 45- to 64-year-old population and $T$ is the temperature (°C). \n"
]
},
{
"cell_type": "markdown",
"id": "925ba2f0",
"metadata": {},
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.13"
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": true,
"sideBar": true,
"skip_h1_title": false,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": false
},
"vscode": {
"interpreter": {
"hash": "916dbcbb3f70747c44a77c7bcd40155683ae19c65e1c03b4aa3499c5328201f1"
}
}
},
"nbformat": 4,
"nbformat_minor": 5
}

0 comments on commit fdd34ef

Please sign in to comment.