Note

This notebook can be downloaded here: 02_DATA_WeatherStation.ipynb

#Setup
%load_ext autoreload
%matplotlib nbagg
%autoreload 2
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib as mpl
from matplotlib import animation, rc, cm
rc('animation', html='html5')

Practical work: Analysis of data from a weather station

The purpose of this session is to highlight temperature data evolution using the panda module.

The data are measured at the station “Col du grand saint Bernad” in Switzerland. The data can be downloaded at the following address : https://www.noaa.gov/

Questions

Question 1: Load the data base and observe the different fields.

Question 2: What is the type of the DATE data ? Use the pandas function to_datetime() to convert it to date type data.

Question 3: Plot the temperature vs. time. Is thier missing data ?

Question 4: Compute the annual average of each temperature (TMIN, TAVG, TMAX)? And plot it.

The date object allows to acces date informations. If D is a DATE object : * D.dt.year gives the year of the date * D.dt.month gives the month of the date

Question 6: What is the average temperature profile of a year month by month? Do this average calculation on the data from 1860 to 1900. Make a plot of it.

Question 7: Calculates the gap between this base year and the following years (1960 to 2020).

Question 8: Make a plot looking like a known gif:

# an exemple to do an annimation
T = np.linspace(0,10,100)
mrad = np.linspace(0,6*np.pi,100)
def updatefig(i):
    line.set_data(mrad[:i], T[:i])
    #time_text.set_text('Year = {:}'.format(dfby.index.get_level_values(0)[i]))
    return line,time_text


fig, ax = plt.subplots()
ax.axis('off')
line, = plt.polar([], [],'-.', animated=True)
time_text = ax.text(0.02, 0.95, '', transform=ax.transAxes)
plt.ylim([-1, 10])


anim = animation.FuncAnimation(fig, updatefig, frames=100, interval=10, blit=True)
anim