move load_data function
Browse files
app.py
CHANGED
@@ -352,17 +352,7 @@ def latlon_to_xy(lat, lon):
|
|
352 |
# %%
|
353 |
def show_forecast():
|
354 |
|
355 |
-
with st.spinner('Fetching data...'):
|
356 |
-
@st.cache_data
|
357 |
-
def load_data(filepath):
|
358 |
-
local=False
|
359 |
-
if local:
|
360 |
-
subset = xr.open_dataset("subset.nc")
|
361 |
-
else:
|
362 |
-
subset = load_meps_for_location(filepath)
|
363 |
-
subset.to_netcdf("subset.nc")
|
364 |
-
return subset
|
365 |
-
|
366 |
if "file_path" not in st.session_state:
|
367 |
st.session_state.file_path = find_latest_meps_file()
|
368 |
subset = load_data(st.session_state.file_path)
|
@@ -471,6 +461,15 @@ def show_forecast():
|
|
471 |
st.session_state.file_path = find_latest_meps_file()
|
472 |
subset = load_data(st.session_state.file_path)
|
473 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
474 |
|
475 |
if __name__ == "__main__":
|
476 |
run_streamlit = True
|
@@ -483,12 +482,7 @@ if __name__ == "__main__":
|
|
483 |
x_target, y_target = latlon_to_xy(lat, lon)
|
484 |
|
485 |
dataset_file_path = find_latest_meps_file()
|
486 |
-
|
487 |
-
if local:
|
488 |
-
subset = xr.open_dataset("subset.nc")
|
489 |
-
else:
|
490 |
-
subset = load_meps_for_location()
|
491 |
-
subset.to_netcdf("subset.nc")
|
492 |
|
493 |
build_map_overlays(subset, date="2024-05-14", hour="16")
|
494 |
|
|
|
352 |
# %%
|
353 |
def show_forecast():
|
354 |
|
355 |
+
with st.spinner('Fetching data...'):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
356 |
if "file_path" not in st.session_state:
|
357 |
st.session_state.file_path = find_latest_meps_file()
|
358 |
subset = load_data(st.session_state.file_path)
|
|
|
461 |
st.session_state.file_path = find_latest_meps_file()
|
462 |
subset = load_data(st.session_state.file_path)
|
463 |
|
464 |
+
@st.cache_data
|
465 |
+
def load_data(filepath):
|
466 |
+
local=False
|
467 |
+
if local:
|
468 |
+
subset = xr.open_dataset("subset.nc")
|
469 |
+
else:
|
470 |
+
subset = load_meps_for_location(filepath)
|
471 |
+
subset.to_netcdf("subset.nc")
|
472 |
+
return subset
|
473 |
|
474 |
if __name__ == "__main__":
|
475 |
run_streamlit = True
|
|
|
482 |
x_target, y_target = latlon_to_xy(lat, lon)
|
483 |
|
484 |
dataset_file_path = find_latest_meps_file()
|
485 |
+
subset = load_data(dataset_file_path)
|
|
|
|
|
|
|
|
|
|
|
486 |
|
487 |
build_map_overlays(subset, date="2024-05-14", hour="16")
|
488 |
|