From 2ed3c80435aa738bbb44aa8def5add158fc12dfe Mon Sep 17 00:00:00 2001 From: Aki Date: Thu, 6 Oct 2022 00:40:25 +0200 Subject: Fixed unit notation --- windy/point_forecast.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'windy') diff --git a/windy/point_forecast.py b/windy/point_forecast.py index 8d55c5f..c15f3b2 100644 --- a/windy/point_forecast.py +++ b/windy/point_forecast.py @@ -10,6 +10,10 @@ def _json(value): return value +def _convert_notation(unit): + return unit.replace("-1", "^-1") + + class _StrEnum(Enum): def __str__(self): return self.value @@ -102,9 +106,9 @@ class Response: def __init__(self, registry, raw): self.timestamps = [datetime.fromtimestamp(x // 1000) for x in raw['ts']] self.samples = {} - parameters = ((x, registry(raw['units'][x])) for x in raw if x not in self._INTERNAL_FIELDS) + parameters = ((x, raw['units'][x]) for x in raw if x not in self._INTERNAL_FIELDS) for parameter, unit in parameters: - self.samples[parameter] = [x * unit for x in raw[parameter]] + self.samples[parameter] = [x * registry(_convert_notation(unit)) for x in raw[parameter]] def __len__(self): return len(self._timestamps) -- cgit v1.1