Commit 746ae958 authored by Gerrit Erichsen's avatar Gerrit Erichsen

BugFixes: Wrong deletion behaviour fixed, by centralizing it (also index comparison was wrong)

Features: Added histograms
Generates plots now, only for different RMSE/MAE/MBE, so number of subplots is reduced.
parent 45ad43de
This diff is collapsed.
......@@ -15,8 +15,8 @@ import cartopy.io.shapereader as shpreader
#from geopandas.tools import sjoin
dType = 'TMP' #data type
year = '2013'
dType = 'ASWDIR' #data type
year = '2015'
path = 'D:/WetterdatenPamore/' + year + '/' \
+ year + '_'+ dType + '.h5'
......@@ -54,4 +54,10 @@ with h5py.File(path, 'r') as f:
ax.scatter(refPos[1], refPos[0], transform=data_crs, c='black')
ax.scatter(posRight[1], posRight[0], transform=data_crs, c='red')
ax.scatter(posDown[1], posDown[0], transform=data_crs, c='blue')
print('Top left - Lat:', lat[0,0], " Lon:", lon[0,0])
print('Top Right - Lat:', lat[0,len(lat[0]) - 1], " Lon:", lon[0,len(lon[0]) - 1])
print('Bottom left - Lat:', lat[len(lat) - 1,0], " Lon:", lon[len(lon) - 1,0])
print('Bottom Right - Lat:', lat[len(lat) - 1,len(lat[0]) - 1], " Lon:", lon[len(lon) - 1,len(lon[0]) - 1])
plt.show()
\ No newline at end of file
......@@ -19,6 +19,7 @@ import h5py
import math
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
class WeatherStation:
# member variables ---------------------
......@@ -414,3 +415,102 @@ class WeatherStation:
fig.set_xlabel('m / s')
if printAxis:
fig.set_ylabel('m / s')
def createDistPlots(self, fig):
"""(matplotlib.axes, bool) -> (void)
creates a scatter plot of obersvation data and model data (x and y,
repsectively). the scatter plot is added to the matplotlib axes given
at function call.
@remark: this re-uses some code of the differences() function. may be
this can be done less verbose and more well structed"""
differences = self.getDifferences();
valuesObs = []
valuesObsBounds = []
valuesMod = []
xAxis = []
histBins = []
i = 0
total = len(self.observationData)
if (len(self.modelData) < total): total = len(self.modelData)
if self.type == 'solar' \
or self.type == 'diffuseIrridiation' \
or self.type == 'globalIrridiation':
histBins = [0, 25, 50, 75, 100, 125, 150, 175, 200, 225, 250, \
275, 300, 325, 350, 375, 400, 425, 450, 475, 500, 525,\
575, 600, 625, 650, 675, 700, 725, 750, 775, 800, 825,\
850, 875, 900, 925, 950, 975, 1000]
for i in range(0, total):
if (self.observationData[i] > -500. \
and self.observationData[i] < 2000.):
valuesObs.append(self.observationData[i])
valuesObsBounds.append(self.error)
valueMod = self.modelData[i]
if self.type == 'solar' \
or self.type == 'diffuseIrridiation' \
or self.type == 'globalIrridiation':
joulePerCm2ToWhPerM2 = 1. * 10000. / 3600.
valuesObs[-1] *= joulePerCm2ToWhPerM2
valueMod = 0.
if i > 0 :
valueMod= self.modelData[i] \
* self.minuteIndicator[i] / 60. \
+ self.modelData[i - 1] \
* (60 - self.minuteIndicator[i - 1]) / 60.
valuesMod.append(valueMod)
xAxis.append(i)
else:
if self.type == 'temperature':
histBins = [-15, -14, -13, -12, -11, -10, -9, -8, -7, -6, \
-5, -4, -3, -2, -1, 0, 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]
elif self.type == 'windDirection':
histBins = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, \
100, 110, 120, 130, 140, 150, 160, 170, 180, 190, \
200, 210, 220, 230, 240, 250, 260, 270, 280, 290, \
300, 310, 320, 330, 340, 350, 360]
else:
histBins = [0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5,\
6, 6.5, 7, 7.5, 8, 8.5, 9, 9.5, 10, 10.5, \
11, 11.5, 12, 12.5, 13, 13.5, 14, 14.5, 15, 15.5,\
16, 16.5, 17, 17.5, 18, 18.5, 19, 19.5, 20, 20.5,\
21, 21.5, 22, 22.5, 23, 23.5, 24, 24.5, 25, 25.5,\
26, 26.5, 27, 27.5, 28, 28.5, 29, 29.5, 30, 30.5,\
31, 31.5, 32, 32.5, 33, 33.5, 34, 34.5, 35]
for i in range(0, total):
if (self.observationData[i] > -500. \
and self.observationData[i] < 2000.):
valuesObs.append(self.observationData[i])
valuesMod.append(self.modelData[i])
# plt.plot(differences, label = "diff")
# plt.plot(valuesObs, label = "measure")
# plt.plot(valuesMod, label = "model")
# upper = np.array(valuesObs) + np.array(valuesObsBounds)
# lower = np.array(valuesObs) - np.array(valuesObsBounds)
# plt.fill_between(xAxis, lower, upper)
# plt.title(self.getName() + ' ' + self.type + ' Run')
# plt.legend()
# plt.show()
# plt.figure()
#ax = plt.subplots()
#ax1 = sns.distplot(valuesObs, color="tab:orange", label='Observation')
#ax2 = sns.distplot(valuesMod, color="tab:blue", label='Model')
fig.hist(valuesObs, bins=histBins, color="tab:orange",
histtype='step', density=True, label='Observation')
fig.hist(valuesMod, bins=histBins, color="tab:blue",
histtype='step', density=True, label='Model')
fig.set_title(self.getName())
if self.type == 'temperature':
fig.set_xlabel("Temperature in °C")
elif self.type == 'solar' \
or self.type == 'diffuseIrridiation':
fig.set_xlabel('DHI in W / m$^2$')
elif self.type == 'globalIrridiation':
fig.set_xlabel('GHI in W / m$^2$')
elif self.type == 'windDirection':
fig.set_xlabel('Wind Direction in Deg')
else:
fig.set_xlabel('Wind speed in m / s')
fig.set_ylabel('Relative Occurences in -')
fig.legend()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment