Climatology

A climatology is an estimate of seasonal average values for a phenomenon averaged over a long period. Examples considered here are either monthly or daily (based on the day of the year). Note that the number of samples for the daily case is not very high unless some additional windowing is done around each day of the year, borrowing from neighboring days. That is what the argument nsmooth does. The following analysis uses 12 years of water temperature data and smooths over a window of 7 days.

The climatology object in this case will be a DataFrame with an integer 1-based index representing day of the year. To compare it to the original series, which has a DatetimeIndex, the function apply_climatology applies the integer climatology onto the indicated index – in this case it is that of the original time series.

[39]:
import pandas as pd
import matplotlib.pyplot as plt
from vtools import climatology, apply_climatology, climatology_quantiles

df = pd.read_csv("data/mup_temp_2006_2018.csv",index_col=0,parse_dates=[0])
clim = climatology(df,freq="day",nsmooth=7)
print(clim)
ts_clim = apply_climatology(clim,df.index)

ax=df.plot()
ts_clim.plot(ax=ax)

              value
dayofyear
1          8.343130
2          8.315923
3          8.342832
4          8.454129
5          8.439410
...             ...
361        8.786297
362        8.694978
363        8.665551
364        8.581858
365        8.449950

[365 rows x 1 columns]
[39]:
<AxesSubplot:xlabel='datetime'>
../_images/notebooks_climatology_1_2.png
[41]:

qlim = climatology_quantiles(df, min_day_year=31, max_day_year=325, window_width=21, quantiles=(0.25,0.5,0.75)) qlim.plot() plt.ylabel("Deg C")
[41]:
Text(0, 0.5, 'Deg C')
../_images/notebooks_climatology_3_1.png