summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--windy/point_forecast.py14
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.