Spaces:
Sleeping
Sleeping
Jompatron
commited on
Commit
·
d7e18fc
1
Parent(s):
fbf6b81
move app.py
Browse files- app.py +2 -2
- helper.ipynb +63 -0
app.py
CHANGED
|
@@ -151,7 +151,7 @@ def generate_forecast(sensor_internal: str, days: int) -> str | None:
|
|
| 151 |
|
| 152 |
# Future weather (city-level, same for all sensors)
|
| 153 |
df_future = weather_fg.read().sort_values("date")
|
| 154 |
-
df_future["date"] = pd.to_datetime(df_future["date"]).dt.date
|
| 155 |
print("DEBUG: WEATHER FUTURE DATES:", df_future["date"].tail(15).tolist())
|
| 156 |
print("DEBUG: Today:", today)
|
| 157 |
|
|
@@ -244,7 +244,7 @@ def generate_hindcast(sensor_internal: str, days: int) -> str | None:
|
|
| 244 |
|
| 245 |
# Weather history
|
| 246 |
weather_df = weather_fg.read()
|
| 247 |
-
weather_df["date"] = pd.to_datetime(weather_df["date"]).dt.date
|
| 248 |
weather_df = weather_df[
|
| 249 |
(weather_df["date"] >= start_date) & (weather_df["date"] <= end_date)
|
| 250 |
].sort_values("date")
|
|
|
|
| 151 |
|
| 152 |
# Future weather (city-level, same for all sensors)
|
| 153 |
df_future = weather_fg.read().sort_values("date")
|
| 154 |
+
df_future["date"] = pd.to_datetime(df_future["date"], unit="ms").dt.date
|
| 155 |
print("DEBUG: WEATHER FUTURE DATES:", df_future["date"].tail(15).tolist())
|
| 156 |
print("DEBUG: Today:", today)
|
| 157 |
|
|
|
|
| 244 |
|
| 245 |
# Weather history
|
| 246 |
weather_df = weather_fg.read()
|
| 247 |
+
weather_df["date"] = pd.to_datetime(weather_df["date"], unit="ms").dt.date
|
| 248 |
weather_df = weather_df[
|
| 249 |
(weather_df["date"] >= start_date) & (weather_df["date"] <= end_date)
|
| 250 |
].sort_values("date")
|
helper.ipynb
CHANGED
|
@@ -135,6 +135,69 @@
|
|
| 135 |
"print(aq_df[\"sensor\"].unique())\n",
|
| 136 |
"aq_df.head()\n"
|
| 137 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
}
|
| 139 |
],
|
| 140 |
"metadata": {
|
|
|
|
| 135 |
"print(aq_df[\"sensor\"].unique())\n",
|
| 136 |
"aq_df.head()\n"
|
| 137 |
]
|
| 138 |
+
},
|
| 139 |
+
{
|
| 140 |
+
"cell_type": "code",
|
| 141 |
+
"execution_count": 7,
|
| 142 |
+
"id": "6f3ad3c6",
|
| 143 |
+
"metadata": {},
|
| 144 |
+
"outputs": [
|
| 145 |
+
{
|
| 146 |
+
"name": "stdout",
|
| 147 |
+
"output_type": "stream",
|
| 148 |
+
"text": [
|
| 149 |
+
"Finished: Reading data from Hopsworks, using Hopsworks Feature Query Service (1.29s) \n",
|
| 150 |
+
" date temperature_2m_mean precipitation_sum wind_speed_10m_max \\\n",
|
| 151 |
+
"0 1562284800000 15.346916 1.7 26.208395 \n",
|
| 152 |
+
"1 1567641600000 11.859416 0.0 25.099514 \n",
|
| 153 |
+
"2 1761523200000 6.684416 2.5 22.288042 \n",
|
| 154 |
+
"3 1728259200000 12.380249 0.5 14.800554 \n",
|
| 155 |
+
"4 1717545600000 9.526083 0.5 27.698952 \n",
|
| 156 |
+
"5 1671753600000 4.740667 12.1 25.501621 \n",
|
| 157 |
+
"6 1603929600000 8.753166 7.2 21.437386 \n",
|
| 158 |
+
"7 1706400000000 9.173999 1.9 29.284180 \n",
|
| 159 |
+
"8 1636588800000 8.882333 6.6 20.393293 \n",
|
| 160 |
+
"9 1577577600000 9.859415 0.5 26.280001 \n",
|
| 161 |
+
"10 1647388800000 6.380251 3.7 15.941944 \n",
|
| 162 |
+
"11 1695772800000 11.976083 9.8 32.449959 \n",
|
| 163 |
+
"12 1650672000000 9.903166 0.0 26.004860 \n",
|
| 164 |
+
"13 1550448000000 6.992749 0.6 33.355900 \n",
|
| 165 |
+
"14 1692748800000 14.184417 0.0 13.397612 \n",
|
| 166 |
+
"15 1732752000000 -0.515583 0.0 10.285232 \n",
|
| 167 |
+
"16 1592870400000 16.355253 1.2 22.077717 \n",
|
| 168 |
+
"17 1566432000000 15.001082 1.1 30.055149 \n",
|
| 169 |
+
"18 1759795200000 12.784416 0.6 27.887802 \n",
|
| 170 |
+
"19 1610323200000 6.136499 4.6 27.534704 \n",
|
| 171 |
+
"\n",
|
| 172 |
+
" wind_direction_10m_dominant city \n",
|
| 173 |
+
"0 256.384277 dundee \n",
|
| 174 |
+
"1 262.086700 dundee \n",
|
| 175 |
+
"2 290.110565 dundee \n",
|
| 176 |
+
"3 324.196442 dundee \n",
|
| 177 |
+
"4 260.956909 dundee \n",
|
| 178 |
+
"5 80.994522 dundee \n",
|
| 179 |
+
"6 208.235748 dundee \n",
|
| 180 |
+
"7 213.732895 dundee \n",
|
| 181 |
+
"8 209.134171 dundee \n",
|
| 182 |
+
"9 226.341934 dundee \n",
|
| 183 |
+
"10 229.775711 dundee \n",
|
| 184 |
+
"11 130.971649 dundee \n",
|
| 185 |
+
"12 51.709808 dundee \n",
|
| 186 |
+
"13 227.227173 dundee \n",
|
| 187 |
+
"14 239.813522 dundee \n",
|
| 188 |
+
"15 223.551529 dundee \n",
|
| 189 |
+
"16 203.593597 dundee \n",
|
| 190 |
+
"17 226.308945 dundee \n",
|
| 191 |
+
"18 237.837631 dundee \n",
|
| 192 |
+
"19 260.020325 dundee \n"
|
| 193 |
+
]
|
| 194 |
+
}
|
| 195 |
+
],
|
| 196 |
+
"source": [
|
| 197 |
+
"weather_fg = fs.get_feature_group(\"dundee_weather_fg\", version=1)\n",
|
| 198 |
+
"df = weather_fg.read()\n",
|
| 199 |
+
"print(df.head(20))"
|
| 200 |
+
]
|
| 201 |
}
|
| 202 |
],
|
| 203 |
"metadata": {
|