Resampling xarray datasets
The Howard Spring dataset has a 30 min resolution, recording atmospheric variables over a period of 17 years. It is interesting to reconstruct a typical day for each month. Data are aggregated using the groupby
method as follows :
Month = [1,2,3,4,5,6,7,8,9,10,11,12]
Title = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]
fig,axes = plt.subplots(4,3,figsize=(20,15),sharey="all")
for i in range(4):
for j in range(3):
mon = Month[2*i+j+i]
# do the ensemble mean for one month :
ds_window = ds.sel(time=ds['time.month']==mon) # select only one month
ds_window = ds_window.groupby("time.hour").mean() # ensemble mean : average hour per hour -> would like to do it for 30T not H ...
# do the plotting part :
ds_window.Ea_scen1.plot(ax=axes[i,j],label="Ea_scen1")
ds_window.E_meas.plot(ax=axes[i,j],label="E_meas")
axes[i,j].set_ylabel("Evaporation")
axes[i,j].set_xlabel("")
axes[i,j].legend()
axes[i,j].set_title(Title[2*i+j+i])
As indicated in comment, it is too bad to lose the 30 min time resolution for the hourly resolution. Is there a way to keep this 30min resolution but still grouping by month ?