JAMESPARK3 commited on
Commit
b39ed9c
Β·
verified Β·
1 Parent(s): 82fabd5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -7
app.py CHANGED
@@ -331,14 +331,47 @@ def show_weather_info(data):
331
 
332
  # 화면에 ν‘œμ‹œ
333
  weather_icon = ""
334
- if data['PRECPT_TYPE'] == "λΉ„":
335
- weather_icon = "β˜”"
336
- elif data['PRECPT_TYPE'] == "눈":
337
- weather_icon = "❄"
338
- elif data['PRECPT_TYPE'] == "λΉ„/눈":
339
- weather_icon = "β˜”β„"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
340
  precip_mark = weather_icon
341
-
342
  st.markdown(f'''
343
  <div class="time-container">
344
  <div style="text-align: center; margin-bottom: 0.5rem; font-size: 6em; font-weight: bold; color: black;">
 
331
 
332
  # 화면에 ν‘œμ‹œ
333
  weather_icon = ""
334
+ current_time_str = current_time.strftime('%Y%m%d%H')
335
+
336
+ # Check current precipitation type first
337
+ if data['PRECPT_TYPE'] in ["λΉ„", "눈", "λΉ„/눈", "λΉ—λ°©μšΈ"]:
338
+ if data['PRECPT_TYPE'] in ["λΉ„", "λΉ—λ°©μšΈ"]:
339
+ weather_icon = "β˜”"
340
+ elif data['PRECPT_TYPE'] == "눈":
341
+ weather_icon = "❄"
342
+ elif data['PRECPT_TYPE'] == "λΉ„/눈":
343
+ weather_icon = "β˜”β„"
344
+ else:
345
+ # Find nearest forecast time when no current precipitation
346
+ nearest_forecast = None
347
+ min_time_diff = float('inf')
348
+
349
+ for forecast in forecast_data:
350
+ forecast_time = datetime.strptime(forecast['FCST_DT'], '%Y%m%d%H%M')
351
+ time_diff = abs((forecast_time - current_time).total_seconds())
352
+ if time_diff < min_time_diff:
353
+ min_time_diff = time_diff
354
+ nearest_forecast = forecast
355
+
356
+ if nearest_forecast:
357
+ if nearest_forecast['PRECPT_TYPE'] in ["λΉ„", "눈", "λΉ„/눈", "λΉ—λ°©μšΈ"]:
358
+ if nearest_forecast['PRECPT_TYPE'] in ["λΉ„", "λΉ—λ°©μšΈ"]:
359
+ weather_icon = "β˜”"
360
+ elif nearest_forecast['PRECPT_TYPE'] == "눈":
361
+ weather_icon = "❄"
362
+ elif nearest_forecast['PRECPT_TYPE'] == "λΉ„/눈":
363
+ weather_icon = "β˜”β„"
364
+ else:
365
+ # Use SKY_STTS when no precipitation
366
+ sky_status = nearest_forecast['SKY_STTS']
367
+ if sky_status == "λ§‘μŒ":
368
+ weather_icon = "β˜€"
369
+ elif sky_status == "ꡬ름":
370
+ weather_icon = "β›…"
371
+ elif sky_status == "흐림":
372
+ weather_icon = "☁"
373
+
374
  precip_mark = weather_icon
 
375
  st.markdown(f'''
376
  <div class="time-container">
377
  <div style="text-align: center; margin-bottom: 0.5rem; font-size: 6em; font-weight: bold; color: black;">