Commit 45ad43de authored by Gerrit Erichsen's avatar Gerrit Erichsen

BugFixes: The stations did not get cleared and removed correctly, so it was...

BugFixes: The stations did not get cleared and removed correctly, so it was reset to always start at empty each loop
parent fcb7c0ae
This diff is collapsed.
......@@ -95,10 +95,10 @@ class WeatherStation:
# starting to caluclate things
def getDifferences(self):
""""(void) -> ([float])
function calculates the differences between observed and model data.
afterwards returns the resulting array. this is needed for the statistical
analysis."""
"""(void) -> ([float])
function calculates the differences between observed and model data.
afterwards returns the resulting array. this is needed for the statistical
analysis."""
differences = []
totalLength = len(self.observationData)
if (len(self.modelData) < totalLength):
......@@ -137,9 +137,9 @@ class WeatherStation:
# translating heights, as it is necessary with the wind data
def getHeightIndices(height):
""""(float) -> (str, str)
function returns indices of COSMO-DE's main planes, that lie
around the specified height"""
"""(float) -> (str, str)
function returns indices of COSMO-DE's main planes, that lie
around the specified height"""
lower = ''
upper = ''
if height <= 10.:
......@@ -177,8 +177,8 @@ class WeatherStation:
return lower, upper
def getHeightFromIndex(index):
""""(str) -> (float)
function returns height of COSMO-DE's main plane with index index"""
"""(str) -> (float)
function returns height of COSMO-DE's main plane with index index"""
if index == '50':
return 10.
elif index == '49':
......@@ -248,14 +248,12 @@ class WeatherStation:
if (int(targetYear) % 4 == 0):
supposedLength = 8784
if len(self.observationData) < supposedLength:
print(self.m_name, 'only has', len(self.observationData))
print(self.name, 'only has', len(self.observationData))
self.observationData = []
def readInModelFile(self, h5FileName, dataType, h5FileName2 = '', \
height = 10.):
def readInModelFile(self, h5FileName, dataType, targetYear, \
h5FileName2 = '', height = 10.):
self.modelData = []
if self.name == 'Brocken':
print('Brocken, alter', h5FileName, h5FileName2, height)
if h5FileName2 == '':
with h5py.File(h5FileName, 'r') as h5File:
self.modelData =h5File[dataType][:,self.latitudeId,self.longitudeId]
......@@ -272,14 +270,20 @@ class WeatherStation:
for lower, upper in zip(data1, data2):
self.modelData.append(np.interp(height, [height1, height2], \
[lower, upper]))
supposedLength = 8760
if (int(targetYear) % 4 == 0):
supposedLength = 8784
if len(self.modelData) < supposedLength:
print(self.name, 'only has', len(self.modelData))
self.modelData = []
# calculating all the statistics needed ------------------------------------
def calculateStats(self):
""""(void) -> (void)
kicks of calculation process. call-stack is:
-getDifferences()
-calculateMAE() | calculateMBE() | calculateRMSE()
afterwards operations on solar data and some min/max analysis"""
"""(void) -> (void)
kicks of calculation process. call-stack is:
-getDifferences()
-calculateMAE() | calculateMBE() | calculateRMSE()
afterwards operations on solar data and some min/max analysis"""
differences = self.getDifferences();
self.mae = WeatherStation.calculateMAE(differences);
self.mbe = WeatherStation.calculateMBE(differences);
......@@ -299,28 +303,28 @@ class WeatherStation:
self.obsAvg = valueArray.mean()
def calculateMAE(differences):
""""([float]) -> (np.array)
function returns mean of absolutes of float array"""
"""([float]) -> (np.array)
function returns mean of absolutes of float array"""
return abs(np.array(differences)).mean()
def calculateMBE(differences):
""""([float]) -> (np.array)
function returns mean of float array"""
"""([float]) -> (np.array)
function returns mean of float array"""
return np.array(differences).mean()
def calculateRMSE(differences):
""""([float]) -> (np.array)
function returns mean of square-roots of squares of float array"""
"""([float]) -> (np.array)
function returns mean of square-roots of squares of float array"""
return math.sqrt(np.square(np.array(differences)).mean())
# making plots -------------------------------------------------------------
def createPlots(self, fig, printAxis = False):
""""(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"""
"""(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 = []
......
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