extend the weather model

This commit is contained in:
Sven Czarnian
2021-11-13 09:46:19 +01:00
parent e6fc82fd5a
commit 8c703c13a1

View File

@@ -100,17 +100,20 @@ class WeatherModel:
self.MaximumAltitude = -1 self.MaximumAltitude = -1
self.WindDirectionModel = None self.WindDirectionModel = None
self.WindSpeedModel = None self.WindSpeedModel = None
self.Altitudes = None
self.Directions = None
self.Windspeeds = None
if None != self.Weather.Provider.WindData and self.Gafor in self.Weather.Provider.WindData: if None != self.Weather.Provider.WindData and self.Gafor in self.Weather.Provider.WindData:
altitudes = [] self.Altitudes = []
directions = [] self.Directions = []
speeds = [] self.Windspeeds = []
# collect the data for the wind model # collect the data for the wind model
for level in self.Weather.Provider.WindData[self.Gafor]: for level in self.Weather.Provider.WindData[self.Gafor]:
altitudes.append(level[0]) self.Altitudes.append(level[0])
directions.append(level[1]) self.Directions.append(level[1])
speeds.append(level[2]) self.Windspeeds.append(level[2])
# define the thresholds for later boundary checks # define the thresholds for later boundary checks
if self.MinimumAltitude > level[0]: if self.MinimumAltitude > level[0]:
@@ -119,9 +122,9 @@ class WeatherModel:
self.MaximumAltitude = level[0] self.MaximumAltitude = level[0]
# calculate the models # calculate the models
if 1 < len(altitudes): if 1 < len(self.Altitudes):
self.WindDirectionModel = scipy.interpolate.interp1d(altitudes, directions) self.WindDirectionModel = scipy.interpolate.interp1d(self.Altitudes, self.Directions)
self.WindSpeedModel = scipy.interpolate.interp1d(altitudes, speeds) self.WindSpeedModel = scipy.interpolate.interp1d(self.Altitudes, self.Windspeeds)
self.LastWeatherUpdate = self.Weather.Provider.UpdateTime self.LastWeatherUpdate = self.Weather.Provider.UpdateTime
else: else:
self.LastWeatherUpdate = None self.LastWeatherUpdate = None