Skip to content

Commit

Permalink
Merge pull request #82 from MeilianLee/master
Browse files Browse the repository at this point in the history
Upload 2024Fall Project
  • Loading branch information
MeilianLee authored Oct 25, 2024
2 parents 790728e + db83b6c commit ba58708
Showing 1 changed file with 336 additions and 0 deletions.
336 changes: 336 additions & 0 deletions chapters/project/FinalProject-2024Fall.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,336 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "ea863e05",
"metadata": {},
"source": [
"## Visualizing Climate Change's Impact on Energy Demand for Cooling Buildings in Southeast Asia under Extreme Heat\n",
"\n",
"```{admonition} Project Overview\n",
":class: tip\n",
"\n",
"Design creative visualizations to unravel the impact of extreme heat and the associated energy demand 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, 3rd December 2024** \n",
"(Note: Late submissions will not be accepted). \n",
"\n",
"You must submit your project to [Canvas](https://canvas.nus.edu.sg/courses/61921/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 ([[email protected]](mailto:[email protected])), Haoling CHEN ([[email protected]](mailto:[email protected])), or Meilian LI ([[email protected]](mailto:[email protected])).\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 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": 3,
"id": "d09b7c22",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Ipoh\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/2024_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": 4,
"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": "markdown",
"id": "6e190257",
"metadata": {},
"source": [
"```{admonition} Bonus: 10 masks\n",
":class: tip\n",
"\n",
"While you can create 24 (12 climate models × 2 climate scenarios) similar warming stripes for Task 1, we 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",
"\n",
"```"
]
},
{
"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": "98d79fdb",
"metadata": {},
"source": [
"### Task 2 (40 marks)\n",
"\n",
"Visualize the changing risks of heat extremes based on the average simulations from multiple climate models. To do this, you need to:\n",
"\n",
"- Fit Generalized Extreme Value (GEV) distributions using 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. Demonstrate the performance of your fitness.\n",
"- Visualize the shift in your fitted GEV distributions over different periods and 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",
"- Estimate and compare the return levels for the 1-in-100-year and 1-in-1000-year heat extreme events over different periods and scenarios. Annotate the return levels in the fitted distributions."
]
},
{
"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": "8e75784c",
"metadata": {},
"source": [
"### Task 3 (20 marks)\n",
"Extreme heat events can increase air conditioning use and drive surges in electricity demand. Cooling Degree Days (CDD) provide a simple indicator of how temperature drives energy demand for building cooling. Using the daily air temperature time series for the city assigned to you, estimate the energy demand for building cooling. To do this, you need to:\n",
"\n",
"- Calculate the monthly CDD for future scenarios (see Appendix 1). Visualize and compare the distributions of CDD across different months and scenarios (SSP245 and SSP585). \n",
"- Estimate the annual energy consumption using the empirical equation provided (see Appendix 2). Visualize the time series of annual energy consumption from the historical period (1950-2014) to the future scenarios (2015-2099). \n",
"- Estimate the energy consumption of building cooling in the 1-in-100-year and 1-in-1000-year heat extreme events identified in Task 2. Compare it with the average of historical daily energy consumption. To what extent will extreme events increase energy consumption?"
]
},
{
"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 visual 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": "9c84cc49",
"metadata": {},
"source": [
"```{admonition} Bonus: 20 masks\n",
":class: tip\n",
"\n",
"- For both Task 1 and Task 3, 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",
"\n",
"- Feel free to make your own design. You can utilize [ChatGPT](https://nightingaledvs.com/data-visualization-using-chatgpt-to-code/) for better data storytelling, such as creating [dashboards](https://medium.com/mcd-unison/3-minute-data-science-dashboards-with-chatgpt-4-and-dash-8a54646510d8) or [animation](https://medium.com/@htobochnik/animated-data-visualization-in-python-how-to-leverage-chatgpt-56de5f196004).\n",
"\n",
"```"
]
},
{
"cell_type": "markdown",
"id": "030b48e3",
"metadata": {},
"source": [
"### Tips\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)."
]
},
{
"cell_type": "markdown",
"id": "d027f0ee",
"metadata": {},
"source": [
"### AI policies\n",
"You are encouraged to use ChatGPT (or other AI tools) for coding, visualization design, and related tasks. However, AI should not be used for your short write-ups. All written content must be your own. If you use AI for coding or visualizations, proper citations must be provided where applicable."
]
},
{
"cell_type": "markdown",
"id": "2fcb2115",
"metadata": {},
"source": [
"### Appendix\n",
"1. Cooling Degree Days (CDD) are a measure of how much (in degrees), and for how long (in days), outside air temperature was higher than a specific base. CDD can be calculated as:\n",
"\n",
"$$\\text{CDD} = \\sum_{i=1}^{n} \\max(T_i - T_b, 0)$$\n",
"\n",
"where $n$ is the number of days over a desired period, $T_i$ is the daily average temperature (°C), and $T_b$ is the base temperature (°C) (e.g., 18°C).\n",
"\n",
"2. The daily energy consumption (kWh) for building cooling (specifically for a building in a campus) can be estimated by the following empirical equation:\n",
"\n",
"$$ \\text{Energy Consumption} = 1677.5 \\times \\text{CDD} + 14605 $$"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.8.8"
},
"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
}
},
"nbformat": 4,
"nbformat_minor": 5
}

0 comments on commit ba58708

Please sign in to comment.