diff options
author | Aki <please@ignore.pl> | 2022-10-06 00:40:25 +0200 |
---|---|---|
committer | Aki <please@ignore.pl> | 2022-10-06 00:40:25 +0200 |
commit | 2ed3c80435aa738bbb44aa8def5add158fc12dfe (patch) | |
tree | 6729c7063b5dec6ebc379b29a33e741bda23c737 | |
parent | 7f769285e3e4f55706474fc4233bb13d1ac33af1 (diff) | |
download | windy-2ed3c80435aa738bbb44aa8def5add158fc12dfe.zip windy-2ed3c80435aa738bbb44aa8def5add158fc12dfe.tar.gz windy-2ed3c80435aa738bbb44aa8def5add158fc12dfe.tar.bz2 |
Fixed unit notation
-rw-r--r-- | windy/point_forecast.py | 8 |
1 files changed, 6 insertions, 2 deletions
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) |