Spaces:
Sleeping
Sleeping
mattritchey
commited on
Commit
•
425b3a3
1
Parent(s):
26dc9d7
Update app.py
Browse files
app.py
CHANGED
@@ -174,21 +174,7 @@ def map_folium(lat, lon,files_dates_selected, within_days ):
|
|
174 |
|
175 |
|
176 |
|
177 |
-
files = [
|
178 |
-
"data/2023_hail.h5",
|
179 |
-
"data/2022_hail.h5",
|
180 |
-
"data/2021_hail.h5",
|
181 |
-
"data/2020_hail.h5"
|
182 |
-
]
|
183 |
-
|
184 |
-
all_dates = []
|
185 |
-
for f in files:
|
186 |
-
with h5py.File(f, 'r') as f:
|
187 |
-
|
188 |
-
dates = f['dates'][:]
|
189 |
-
print(dates)
|
190 |
|
191 |
-
all_dates.append(dates)
|
192 |
|
193 |
#Set up 2 Columns
|
194 |
st.set_page_config(layout="wide")
|
@@ -229,53 +215,54 @@ crop_coords = col-radius, row-radius, col+radius+1, row+radius+1
|
|
229 |
files = glob.glob(r'webp/**/*.webp', recursive=True)
|
230 |
files_dates_selected = [i for i in files if any(
|
231 |
i for j in date_range if str(j) in re.search(r'(\d{8})', i).group())]
|
232 |
-
print(files_dates_selected)
|
233 |
|
234 |
|
235 |
-
# # Get Data
|
236 |
-
# df_data, max_values = get_data(row, col, radius)
|
237 |
|
238 |
-
# df_data = df_data.query(f"'{start_date}'<=Date<='{end_date}'")
|
239 |
-
# df_data['Max'] = df_data['Max'].round(3)
|
240 |
-
# df_data['Actual'] = df_data['Actual'].round(3)
|
241 |
|
|
|
|
|
242 |
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
#
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
#
|
253 |
-
#
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
|
|
|
|
|
|
|
|
|
|
263 |
|
264 |
|
265 |
|
266 |
|
267 |
with col1:
|
268 |
st.title(f'Hail')
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
|
280 |
|
281 |
with col2:
|
|
|
174 |
|
175 |
|
176 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
177 |
|
|
|
178 |
|
179 |
#Set up 2 Columns
|
180 |
st.set_page_config(layout="wide")
|
|
|
215 |
files = glob.glob(r'webp/**/*.webp', recursive=True)
|
216 |
files_dates_selected = [i for i in files if any(
|
217 |
i for j in date_range if str(j) in re.search(r'(\d{8})', i).group())]
|
|
|
218 |
|
219 |
|
|
|
|
|
220 |
|
|
|
|
|
|
|
221 |
|
222 |
+
# Get Data
|
223 |
+
df_data, max_values = get_data(row, col, radius)
|
224 |
|
225 |
+
df_data = df_data.query(f"'{start_date}'<=Date<='{end_date}'")
|
226 |
+
df_data['Max'] = df_data['Max'].round(3)
|
227 |
+
df_data['Actual'] = df_data['Actual'].round(3)
|
228 |
+
|
229 |
+
|
230 |
+
# Create the bar chart
|
231 |
+
fig = alt.Chart(df_data).mark_bar(size=3, color='red').encode(
|
232 |
+
x='Date:T', # Temporal data type
|
233 |
+
y='Actual:Q', # Quantitative data type
|
234 |
+
color='Actual:Q', # Color based on Actual values
|
235 |
+
tooltip=[ # Adding tooltips
|
236 |
+
alt.Tooltip('Date:T', title='Date'),
|
237 |
+
alt.Tooltip('Actual:Q', title='Actual Value'),
|
238 |
+
alt.Tooltip('Max:Q', title=f'Max Value with {circle_radius} Miles')
|
239 |
+
]
|
240 |
+
).configure(
|
241 |
+
view=alt.ViewConfig(
|
242 |
+
strokeOpacity=0 # No border around the chart
|
243 |
+
)
|
244 |
+
).configure_axis(
|
245 |
+
grid=False # Disable grid lines
|
246 |
+
).configure_legend(
|
247 |
+
fillColor='transparent', # Ensure no legend is shown
|
248 |
+
strokeColor='transparent'
|
249 |
+
)
|
250 |
|
251 |
|
252 |
|
253 |
|
254 |
with col1:
|
255 |
st.title(f'Hail')
|
256 |
+
try:
|
257 |
+
st.altair_chart(fig, use_container_width=True)
|
258 |
+
csv = convert_df(df_data)
|
259 |
+
st.download_button(
|
260 |
+
label="Download data as CSV",
|
261 |
+
data=csv,
|
262 |
+
file_name='data.csv',
|
263 |
+
mime='text/csv')
|
264 |
+
except:
|
265 |
+
pass
|
266 |
|
267 |
|
268 |
with col2:
|