HW#2: Visualizing Historical Temperature Changes in Singapore#

Objectives

This homework will provide you a real-world example in terms of:

  • how to visualize the GEV distribution

  • how to visualize time series of temperature anomalies and the trend

  • how to make beautiful, accessible, and understandable data visualizations

Happy coding!

Submission Guide

Deadline: Sunday 11:59 pm, 19th November 2023 (Note: Late submissions will not be accepted).

Please upload your solutions to Canvas in a Jupyter Notebook format with the name “Homework2_StudentID.ipynb”. Make sure to write down your student ID and full name in the cell below.

For any questions, feel free to contact Prof. Xiaogang HE (hexg@nus.edu.sg), or Zhixiao NIU (niu.zhixiao@u.nus.edu).

## Fill your student ID and full name below.

# Student ID:
# Full name:

Data: You will need to use the historical (1982-2020) daily mean air temperature data measured at Singapore’s Changi station for this homework. You can create a DataFrame using Pandas by reading the file “../../assets/data/Changi_daily_temperature.csv”.

Task 1: Visualize the GEV distribution (30 marks)#

To visualize the GEV distribution, you can:

  1. Fit the Generalized Extreme Value (GEV) distribution to annual maximum daily temperature data and estimate the GEV parameters using the Maximum Likelihood method.

  2. Plot the probability density function (PDF) curve to to represent the distribution directly.

  3. Calculate the return level for a 20-year event and mark it on the plot.

  4. Fill the figure with different colors regarding the calculated return level as the dividing line.

  5. Ensure that the necessary non-data elements are included, such as title, x/y axis labels, legend, etc. (you can check the Matplotlib tutorial for details).

# Your solutions go here.
# Use the + icon in the toolbar to add a cell.

Task 2: Visualize the trend of temperature anomaly ( 70 marks )#

Q1: Visualize the time series and trend of historical temperature anomalies of Singapore (35 marks)#

  • Calculate the annual mean temperature from the daily data. This will result in a data set of 39 values — one per year. (5 marks)

  • Calculate the annual temperature anomalies using the first 15-year period as the baseline. (Hint: the anomalies is calculated by substracting the mean temperature over year 1982 to 1996 from the yearly mean temperature.) (5 marks)

  • Make a line graph of these annual temperature anomalies and make sure that the necessary non-data elements are included. (10 marks)

  • Based on the annual temperature anomalies above, visualize the trend using a 10-year moving window. (15 marks)

# Your solutions go here.
# Use the + icon in the toolbar to add a cell.

Q2: Add climate stripes for Singapore (35 marks)#

  • Reproduce the climate stripes for Singapore using Matplotlib. (20 marks)

  • Use your generated climate stripes as the background and then overlay the time series and the trend of annual anomalies (from Q1) on top of the climate stripes. (15 marks)

Tips:

  • You can refer to this GitHub repository to make the climate stripes.

  • To make a pretty and accessible (colorblind safe) chart, you might want to fine tune the aesthetics (e.g., color palette of the diverging colorbar) of your chart.

# Your solutions go here.
# Use the + icon in the toolbar to add a cell.