diff options
author | Aki <please@ignore.pl> | 2022-10-07 23:51:27 +0200 |
---|---|---|
committer | Aki <please@ignore.pl> | 2022-10-07 23:51:27 +0200 |
commit | 73b7fe1a0487b1791d8bccd9adcde0e05b49a560 (patch) | |
tree | 86adbc84f710c8aa2f97ecea7b65e3d59dad1429 | |
parent | b17a73f2cb8bb2dcdc4063305ac541441250cf87 (diff) | |
download | windy-73b7fe1a0487b1791d8bccd9adcde0e05b49a560.zip windy-73b7fe1a0487b1791d8bccd9adcde0e05b49a560.tar.gz windy-73b7fe1a0487b1791d8bccd9adcde0e05b49a560.tar.bz2 |
Initialize Response's levels and parameters directly in __init__
-rw-r--r-- | windy/point_forecast.py | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/windy/point_forecast.py b/windy/point_forecast.py index 54a10c1..938d30e 100644 --- a/windy/point_forecast.py +++ b/windy/point_forecast.py @@ -140,20 +140,16 @@ class Response: def __init__(self, registry, raw): self.timestamps = [datetime.fromtimestamp(x // 1000) for x in raw['ts']] + self.parameters = tuple(x for x in raw if x not in self._INTERNAL_FIELDS) + self.levels = tuple(sorted({Level(x.split("-")[1]) for x in self.parameters})) self.samples = {} - 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 * registry(_convert_notation(unit)) for x in raw[parameter]] + for parameter in self.parameters: + unit = registry(_convert_notation(raw['units'][parameter])) + self.samples[parameter] = [x * unit for x in raw[parameter]] def __len__(self): return len(self.timestamps) - def parameters(self) -> tuple: - """ - All of the available output parameters. - """ - return tuple(self.samples.keys()) - def predictions(self) -> Prediction: """ Yields Prediction for each time point available in this Response. |