summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2023-03-28 23:37:35 +0200
committerAki <please@ignore.pl>2023-03-28 23:37:35 +0200
commit806110131888b5c925178d963676249b6d286d8c (patch)
tree86049a4c6fd0b90e27a5fbbea2e428d1251b42e8
parentd06a132c5a7b5b7426f71b29da9d5518b98ed704 (diff)
downloadwindy-806110131888b5c925178d963676249b6d286d8c.zip
windy-806110131888b5c925178d963676249b6d286d8c.tar.gz
windy-806110131888b5c925178d963676249b6d286d8c.tar.bz2
Ensure that pressure is sorted along and apply same order to all profiles
-rw-r--r--windy/point_forecast.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/windy/point_forecast.py b/windy/point_forecast.py
index f840d97..844cef3 100644
--- a/windy/point_forecast.py
+++ b/windy/point_forecast.py
@@ -172,6 +172,7 @@ class Response:
for parameter in levels:
levels[parameter] = tuple(sorted(levels[parameter]))
units = {x: registry(_convert_notation(raw['units'][f'{x}-{levels[x][0]}'])) for x in parameters}
+ pressure_sort = []
if 'pressure' in parameters:
for level in all_levels:
if level is Level.SURFACE:
@@ -179,6 +180,13 @@ class Response:
pressure = (level.pressure() * registry.hPa).m_as(units['pressure'])
raw[f'pressure-{level}'] = [pressure for _ in range(len(self.timestamps))]
levels['pressure'] = all_levels
+ for index in range(len(self.timestamps)):
+ surface = raw[f'pressure-{Level.SURFACE}'][index]
+ new_index = 0
+ for new_index, level in enumerate(all_levels[1:], start=0):
+ if surface > raw[f'pressure-{level}'][index]:
+ break
+ pressure_sort.append(new_index)
self.raw_predictions = {}
for parameter in parameters:
profiles = []
@@ -189,6 +197,9 @@ class Response:
profile.append(raw[f'{parameter}-{level}'][index])
except KeyError:
pass
+ if pressure_sort:
+ new_index = pressure_sort[index]
+ profile[0], profile[new_index] = profile[new_index], profile[0]
profiles.append(np.array(profile) * units[parameter])
self.raw_predictions[parameter] = profiles