-
Notifications
You must be signed in to change notification settings - Fork 1
/
plot_energy_meteograms.py
executable file
·47 lines (38 loc) · 1.58 KB
/
plot_energy_meteograms.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import xarray as xr
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
import datetime
from glob import glob
dset = xr.open_dataset('energy_sources_gfs.nc')
germany = dset.sel(lat=slice(54.8, 47.5), lon=slice(6.3, 15.)).mean(dim=('lat','lon'), skipna=True).interpolate_na(dim='time')
sns.set()
fig = plt.figure(1, figsize=(16,6))
boxplot = sns.boxplot(pd.to_datetime(germany.time.values), germany.wind_power.T, fliersize=2)
plt.gca().set_xticklabels([tm.strftime('%Y-%m-%d \n %H UTC') for tm in pd.to_datetime(germany.time.values)],
rotation=50)
plt.gca().set_ylabel("Wind Power [MW]",fontsize=14)
plt.gca().yaxis.grid(True)
plt.gca().xaxis.grid(True, color='gray', linewidth=0.2)
for ind, label in enumerate(boxplot.get_xticklabels()):
if ind % 3 == 0: # every 10th label is kept
label.set_visible(True)
else:
label.set_visible(False)
plt.savefig('boxplot_wind_power.pdf', bbox_inches='tight')
plt.clf()
sns.set()
fig = plt.figure(1, figsize=(16,6))
boxplot = sns.boxplot(pd.to_datetime(germany.time.values), germany['2m_temperature'].T, fliersize=2)
plt.gca().set_xticklabels([tm.strftime('%Y-%m-%d \n %H UTC') for tm in pd.to_datetime(germany.time.values)],
rotation=50)
plt.gca().set_ylabel("2m Temperature [C]",fontsize=14)
plt.gca().yaxis.grid(True)
plt.gca().xaxis.grid(True, color='gray', linewidth=0.2)
for ind, label in enumerate(boxplot.get_xticklabels()):
if ind % 3 == 0: # every 10th label is kept
label.set_visible(True)
else:
label.set_visible(False)
plt.savefig('2mt.pdf', bbox_inches='tight')