Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -140,7 +140,7 @@ def parse_weather_data(data):
|
|
| 140 |
def calculate_total_new_snow(df):
|
| 141 |
"""
|
| 142 |
Calculate total new snow by:
|
| 143 |
-
1.
|
| 144 |
2. Using 9 AM as the daily reset point
|
| 145 |
3. Filtering out obvious anomalies (>9 inches in 3 hours)
|
| 146 |
|
|
@@ -153,7 +153,7 @@ def calculate_total_new_snow(df):
|
|
| 153 |
# Sort by datetime to ensure correct calculation
|
| 154 |
df = df.sort_values('datetime')
|
| 155 |
|
| 156 |
-
# Create a copy of the dataframe with
|
| 157 |
snow_df = df[['datetime', 'snowfall_3hr']].copy()
|
| 158 |
|
| 159 |
# Create a day group that starts at 9 AM instead of midnight
|
|
@@ -162,17 +162,21 @@ def calculate_total_new_snow(df):
|
|
| 162 |
)
|
| 163 |
|
| 164 |
def process_daily_snow(group):
|
| 165 |
-
"""Sum up the 3-hour snowfall amounts for each day period"""
|
| 166 |
# Sort by time to ensure proper sequence
|
| 167 |
group = group.sort_values('datetime')
|
| 168 |
|
| 169 |
-
#
|
| 170 |
-
|
| 171 |
-
|
|
|
|
|
|
|
| 172 |
|
| 173 |
-
# Sum
|
| 174 |
-
|
|
|
|
| 175 |
|
|
|
|
| 176 |
return daily_total
|
| 177 |
|
| 178 |
# Calculate daily snow totals
|
|
@@ -211,6 +215,8 @@ def create_daily_snow_plot(df, ax):
|
|
| 211 |
ha='center', va='bottom')
|
| 212 |
|
| 213 |
|
|
|
|
|
|
|
| 214 |
|
| 215 |
def create_wind_rose(df, ax):
|
| 216 |
"""Create a wind rose plot"""
|
|
|
|
| 140 |
def calculate_total_new_snow(df):
|
| 141 |
"""
|
| 142 |
Calculate total new snow by:
|
| 143 |
+
1. Using ONLY the 3-hour snowfall amounts
|
| 144 |
2. Using 9 AM as the daily reset point
|
| 145 |
3. Filtering out obvious anomalies (>9 inches in 3 hours)
|
| 146 |
|
|
|
|
| 153 |
# Sort by datetime to ensure correct calculation
|
| 154 |
df = df.sort_values('datetime')
|
| 155 |
|
| 156 |
+
# Create a copy of the dataframe with ONLY datetime and 3-hour snowfall
|
| 157 |
snow_df = df[['datetime', 'snowfall_3hr']].copy()
|
| 158 |
|
| 159 |
# Create a day group that starts at 9 AM instead of midnight
|
|
|
|
| 162 |
)
|
| 163 |
|
| 164 |
def process_daily_snow(group):
|
| 165 |
+
"""Sum up ONLY the 3-hour snowfall amounts for each day period"""
|
| 166 |
# Sort by time to ensure proper sequence
|
| 167 |
group = group.sort_values('datetime')
|
| 168 |
|
| 169 |
+
# Print debugging information
|
| 170 |
+
print(f"\nSnowfall amounts for {group['day_group'].iloc[0]}:")
|
| 171 |
+
for _, row in group.iterrows():
|
| 172 |
+
if pd.notna(row['snowfall_3hr']):
|
| 173 |
+
print(f"{row['datetime'].strftime('%Y-%m-%d %H:%M')}: {row['snowfall_3hr']} inches")
|
| 174 |
|
| 175 |
+
# Sum only the valid 3-hour amounts, treating NaN as 0
|
| 176 |
+
valid_amounts = group['snowfall_3hr'].fillna(0)
|
| 177 |
+
daily_total = valid_amounts.sum()
|
| 178 |
|
| 179 |
+
print(f"Daily total: {daily_total} inches")
|
| 180 |
return daily_total
|
| 181 |
|
| 182 |
# Calculate daily snow totals
|
|
|
|
| 215 |
ha='center', va='bottom')
|
| 216 |
|
| 217 |
|
| 218 |
+
|
| 219 |
+
|
| 220 |
|
| 221 |
def create_wind_rose(df, ax):
|
| 222 |
"""Create a wind rose plot"""
|