Spaces:
Sleeping
Sleeping
Update app/climate_data.py
Browse files- app/climate_data.py +9 -4
app/climate_data.py
CHANGED
@@ -426,7 +426,7 @@ class ClimateDataManager:
|
|
426 |
|
427 |
def _process_hourly_data(self, df: pd.DataFrame) -> List[Dict[str, Any]]:
|
428 |
"""
|
429 |
-
Process hourly data from EPW DataFrame, including dew point
|
430 |
|
431 |
Args:
|
432 |
df: DataFrame containing EPW data
|
@@ -441,7 +441,7 @@ class ClimateDataManager:
|
|
441 |
numeric_columns = [
|
442 |
"dry_bulb_temp", "dew_point_temp", "relative_humidity", "atmospheric_pressure",
|
443 |
"global_horizontal_radiation", "direct_normal_radiation",
|
444 |
-
"diffuse_horizontal_radiation", "wind_speed", "wind_direction"
|
445 |
]
|
446 |
|
447 |
for col in numeric_columns:
|
@@ -470,6 +470,9 @@ class ClimateDataManager:
|
|
470 |
direct_normal = float(row["direct_normal_radiation"]) if not pd.isna(row["direct_normal_radiation"]) else 0.0
|
471 |
sky_clearness_index = self._calculate_sky_clearness_index(diffuse_horizontal, global_horizontal, direct_normal)
|
472 |
|
|
|
|
|
|
|
473 |
record = {
|
474 |
"month": int(row["month"]),
|
475 |
"day": int(row["day"]),
|
@@ -483,7 +486,8 @@ class ClimateDataManager:
|
|
483 |
"diffuse_horizontal_radiation": float(row["diffuse_horizontal_radiation"]) if not pd.isna(row["diffuse_horizontal_radiation"]) else 0.0,
|
484 |
"wind_speed": float(row["wind_speed"]) if not pd.isna(row["wind_speed"]) else 0.0,
|
485 |
"wind_direction": float(row["wind_direction"]) if not pd.isna(row["wind_direction"]) else 0.0,
|
486 |
-
"sky_clearness_index": sky_clearness_index if sky_clearness_index is not None else None
|
|
|
487 |
}
|
488 |
hourly_data.append(record)
|
489 |
|
@@ -858,7 +862,8 @@ def display_climate_summary(climate_data: Dict[str, Any]):
|
|
858 |
"Diffuse Horizontal Radiation (W/m²)": f"{record['diffuse_horizontal_radiation']:.1f}",
|
859 |
"Wind Speed (m/s)": f"{record['wind_speed']:.1f}",
|
860 |
"Wind Direction (°)": f"{record['wind_direction']:.1f}",
|
861 |
-
"Sky Clearness Index": f"{record['sky_clearness_index']:.3f}" if record['sky_clearness_index'] is not None else "N/A"
|
|
|
862 |
}
|
863 |
for record in climate_data["hourly_data"]
|
864 |
]
|
|
|
426 |
|
427 |
def _process_hourly_data(self, df: pd.DataFrame) -> List[Dict[str, Any]]:
|
428 |
"""
|
429 |
+
Process hourly data from EPW DataFrame, including dew point, Sky Clearness Index, and total sky cover.
|
430 |
|
431 |
Args:
|
432 |
df: DataFrame containing EPW data
|
|
|
441 |
numeric_columns = [
|
442 |
"dry_bulb_temp", "dew_point_temp", "relative_humidity", "atmospheric_pressure",
|
443 |
"global_horizontal_radiation", "direct_normal_radiation",
|
444 |
+
"diffuse_horizontal_radiation", "wind_speed", "wind_direction", "total_sky_cover"
|
445 |
]
|
446 |
|
447 |
for col in numeric_columns:
|
|
|
470 |
direct_normal = float(row["direct_normal_radiation"]) if not pd.isna(row["direct_normal_radiation"]) else 0.0
|
471 |
sky_clearness_index = self._calculate_sky_clearness_index(diffuse_horizontal, global_horizontal, direct_normal)
|
472 |
|
473 |
+
# Extract total sky cover
|
474 |
+
total_sky_cover = float(row["total_sky_cover"]) if not pd.isna(row["total_sky_cover"]) else None
|
475 |
+
|
476 |
record = {
|
477 |
"month": int(row["month"]),
|
478 |
"day": int(row["day"]),
|
|
|
486 |
"diffuse_horizontal_radiation": float(row["diffuse_horizontal_radiation"]) if not pd.isna(row["diffuse_horizontal_radiation"]) else 0.0,
|
487 |
"wind_speed": float(row["wind_speed"]) if not pd.isna(row["wind_speed"]) else 0.0,
|
488 |
"wind_direction": float(row["wind_direction"]) if not pd.isna(row["wind_direction"]) else 0.0,
|
489 |
+
"sky_clearness_index": sky_clearness_index if sky_clearness_index is not None else None,
|
490 |
+
"total_sky_cover": total_sky_cover
|
491 |
}
|
492 |
hourly_data.append(record)
|
493 |
|
|
|
862 |
"Diffuse Horizontal Radiation (W/m²)": f"{record['diffuse_horizontal_radiation']:.1f}",
|
863 |
"Wind Speed (m/s)": f"{record['wind_speed']:.1f}",
|
864 |
"Wind Direction (°)": f"{record['wind_direction']:.1f}",
|
865 |
+
"Sky Clearness Index": f"{record['sky_clearness_index']:.3f}" if record['sky_clearness_index'] is not None else "N/A",
|
866 |
+
"Total Sky Cover": f"{record['total_sky_cover']:.1f}" if record['total_sky_cover'] is not None else "N/A"
|
867 |
}
|
868 |
for record in climate_data["hourly_data"]
|
869 |
]
|