Spaces:
Runtime error
Runtime error
Commit
·
7944a5b
1
Parent(s):
cac104d
Update app.py
Browse files
app.py
CHANGED
@@ -27,7 +27,7 @@ import rioxarray
|
|
27 |
import numpy as np
|
28 |
|
29 |
|
30 |
-
@st.
|
31 |
def geocode(address, buffer_size):
|
32 |
try:
|
33 |
address2 = address.replace(' ', '+').replace(',', '%2C')
|
@@ -49,7 +49,7 @@ def geocode(address, buffer_size):
|
|
49 |
return gdf
|
50 |
|
51 |
|
52 |
-
@st.
|
53 |
def get_pngs(date):
|
54 |
year, month, day = date[:4], date[4:6], date[6:]
|
55 |
url = f'https://mrms.nssl.noaa.gov/qvs/product_viewer/local/render_multi_domain_product_layer.php?mode=run&cpp_exec_dir=/home/metop/web/specific/opv/&web_resources_dir=/var/www/html/qvs/product_viewer/resources/&prod_root={prod_root}&qperate_pal_option=0&qpe_pal_option=0&year={year}&month={month}&day={day}&hour={hour}&minute={minute}&clon={lon}&clat={lat}&zoom={zoom}&width=920&height=630'
|
@@ -62,14 +62,14 @@ def get_pngs(date):
|
|
62 |
return data2_df2.reset_index()
|
63 |
|
64 |
|
65 |
-
@st.
|
66 |
def get_pngs_parallel(dates):
|
67 |
results1 = Parallel(n_jobs=32, prefer="threads")(
|
68 |
delayed(get_pngs)(i) for i in dates)
|
69 |
return results1
|
70 |
|
71 |
|
72 |
-
@st.
|
73 |
def png_data(date):
|
74 |
year, month, day = date[:4], date[4:6], date[6:]
|
75 |
url = f'https://mrms.nssl.noaa.gov/qvs/product_viewer/local/render_multi_domain_product_layer.php?mode=run&cpp_exec_dir=/home/metop/web/specific/opv/&web_resources_dir=/var/www/html/qvs/product_viewer/resources/&prod_root={prod_root}&qperate_pal_option=0&qpe_pal_option=0&year={year}&month={month}&day={day}&hour={hour}&minute={minute}&clon={lon}&clat={lat}&zoom={zoom}&width=920&height=630'
|
@@ -77,7 +77,7 @@ def png_data(date):
|
|
77 |
return data
|
78 |
|
79 |
|
80 |
-
@st.
|
81 |
def map_folium(data, gdf):
|
82 |
m = folium.Map(location=[lat, lon], zoom_start=zoom, height=300)
|
83 |
folium.Marker(
|
@@ -89,11 +89,9 @@ def map_folium(data, gdf):
|
|
89 |
data, opacity=0.8, bounds=bounds).add_to(m)
|
90 |
return m
|
91 |
|
92 |
-
|
93 |
def to_radians(degrees):
|
94 |
return degrees * math.pi / 180
|
95 |
|
96 |
-
|
97 |
def lat_lon_to_bounds(lat, lng, zoom, width, height):
|
98 |
earth_cir_m = 40075016.686
|
99 |
degreesPerMeter = 360 / earth_cir_m
|
@@ -109,7 +107,6 @@ def lat_lon_to_bounds(lat, lng, zoom, width, height):
|
|
109 |
|
110 |
return [[lat-shift_deg_ns, lng-shift_deg_ew], [lat+shift_deg_ns, lng+shift_deg_ew]]
|
111 |
|
112 |
-
|
113 |
def image_to_geotiff(bounds, input_file_path, output_file_path='template.tiff'):
|
114 |
south, west, north, east = tuple(
|
115 |
[item for sublist in bounds for item in sublist])
|
|
|
27 |
import numpy as np
|
28 |
|
29 |
|
30 |
+
@st.cache_resource
|
31 |
def geocode(address, buffer_size):
|
32 |
try:
|
33 |
address2 = address.replace(' ', '+').replace(',', '%2C')
|
|
|
49 |
return gdf
|
50 |
|
51 |
|
52 |
+
@st.cache_resource
|
53 |
def get_pngs(date):
|
54 |
year, month, day = date[:4], date[4:6], date[6:]
|
55 |
url = f'https://mrms.nssl.noaa.gov/qvs/product_viewer/local/render_multi_domain_product_layer.php?mode=run&cpp_exec_dir=/home/metop/web/specific/opv/&web_resources_dir=/var/www/html/qvs/product_viewer/resources/&prod_root={prod_root}&qperate_pal_option=0&qpe_pal_option=0&year={year}&month={month}&day={day}&hour={hour}&minute={minute}&clon={lon}&clat={lat}&zoom={zoom}&width=920&height=630'
|
|
|
62 |
return data2_df2.reset_index()
|
63 |
|
64 |
|
65 |
+
@st.cache_resource
|
66 |
def get_pngs_parallel(dates):
|
67 |
results1 = Parallel(n_jobs=32, prefer="threads")(
|
68 |
delayed(get_pngs)(i) for i in dates)
|
69 |
return results1
|
70 |
|
71 |
|
72 |
+
@st.cache_resource
|
73 |
def png_data(date):
|
74 |
year, month, day = date[:4], date[4:6], date[6:]
|
75 |
url = f'https://mrms.nssl.noaa.gov/qvs/product_viewer/local/render_multi_domain_product_layer.php?mode=run&cpp_exec_dir=/home/metop/web/specific/opv/&web_resources_dir=/var/www/html/qvs/product_viewer/resources/&prod_root={prod_root}&qperate_pal_option=0&qpe_pal_option=0&year={year}&month={month}&day={day}&hour={hour}&minute={minute}&clon={lon}&clat={lat}&zoom={zoom}&width=920&height=630'
|
|
|
77 |
return data
|
78 |
|
79 |
|
80 |
+
@st.cache_resource
|
81 |
def map_folium(data, gdf):
|
82 |
m = folium.Map(location=[lat, lon], zoom_start=zoom, height=300)
|
83 |
folium.Marker(
|
|
|
89 |
data, opacity=0.8, bounds=bounds).add_to(m)
|
90 |
return m
|
91 |
|
|
|
92 |
def to_radians(degrees):
|
93 |
return degrees * math.pi / 180
|
94 |
|
|
|
95 |
def lat_lon_to_bounds(lat, lng, zoom, width, height):
|
96 |
earth_cir_m = 40075016.686
|
97 |
degreesPerMeter = 360 / earth_cir_m
|
|
|
107 |
|
108 |
return [[lat-shift_deg_ns, lng-shift_deg_ew], [lat+shift_deg_ns, lng+shift_deg_ew]]
|
109 |
|
|
|
110 |
def image_to_geotiff(bounds, input_file_path, output_file_path='template.tiff'):
|
111 |
south, west, north, east = tuple(
|
112 |
[item for sublist in bounds for item in sublist])
|