summaryrefslogtreecommitdiff
path: root/waterspout_radar/_radar.py
diff options
context:
space:
mode:
Diffstat (limited to 'waterspout_radar/_radar.py')
-rw-r--r--waterspout_radar/_radar.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/waterspout_radar/_radar.py b/waterspout_radar/_radar.py
index 380c70b..336edd5 100644
--- a/waterspout_radar/_radar.py
+++ b/waterspout_radar/_radar.py
@@ -16,6 +16,7 @@ _L = point_forecast.Level
@dataclasses.dataclass
class Prediction:
time: datetime.datetime
+ made: datetime.datetime
latitude: float
longitude: float
temperature_difference: pint.Quantity
@@ -27,6 +28,7 @@ class Prediction:
def json(self):
return {
"time": self.time.isoformat(),
+ "made": self.made.isoformat(),
"latitude": self.latitude,
"longitude": self.longitude,
"dt": self.temperature_difference.m_as("kelvin"),
@@ -40,6 +42,7 @@ class Prediction:
def from_json(cls, json):
return cls(
datetime.datetime.fromisoformat(json["time"]),
+ datetime.datetime.fromisoformat(json["made"]),
json["latitude"],
json["longitude"],
json["dt"] * metunits.units.kelvin,
@@ -53,6 +56,7 @@ class Prediction:
def calculate(config) -> typing.List[Prediction]:
units = metunits.units
windy = Windy(units)
+ now = datetime.datetime.now()
def _calculate(latitude, longitude):
forecasts = windy.point_forecast(
@@ -79,7 +83,7 @@ def calculate(config) -> typing.List[Prediction]:
wind = [cast.at("wind_u", _L.H850), cast.at("wind_v", _L.H850)]
wind = np.array([x.m_as("kts") for x in wind])
wind = np.linalg.norm(wind) * units.kts
- yield Prediction(cast.timestamp, latitude, longitude, dt, ccd, wind, clouds, swi)
+ yield Prediction(cast.timestamp, now, latitude, longitude, dt, ccd, wind, clouds, swi)
predictions = []
locator = geocoders.Nominatim(user_agent="waterspout-radar")