Spaces:
Sleeping
Sleeping
Update data/ashrae_tables.py
Browse files- data/ashrae_tables.py +22 -36
data/ashrae_tables.py
CHANGED
|
@@ -15,7 +15,6 @@ ENHANCEMENTS:
|
|
| 15 |
"""
|
| 16 |
|
| 17 |
from typing import Dict, List, Any, Optional, Tuple
|
| 18 |
-
import logging
|
| 19 |
import pandas as pd
|
| 20 |
import numpy as np
|
| 21 |
import os
|
|
@@ -93,34 +92,25 @@ class EquipmentType(Enum):
|
|
| 93 |
class ASHRAETables:
|
| 94 |
"""Class for managing ASHRAE tables for load calculations, compliant with ASHRAE Handbook—Fundamentals (2017, Chapter 18)."""
|
| 95 |
|
| 96 |
-
|
| 97 |
-
"""
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
self.color_correction = self._load_color_correction()
|
| 116 |
-
self.month_correction = self._load_month_correction()
|
| 117 |
-
# Load thermal properties and roof classifications
|
| 118 |
-
self.thermal_properties = self._load_thermal_properties()
|
| 119 |
-
self.roof_classifications = self._load_roof_classifications()
|
| 120 |
-
logger.info("ASHRAETables initialized successfully")
|
| 121 |
-
except Exception as e:
|
| 122 |
-
logger.error(f"Error initializing ASHRAETables: {str(e)}")
|
| 123 |
-
raise
|
| 124 |
|
| 125 |
def _validate_cltd_inputs(self, group: str, orientation: str, hour: int, latitude: str, month: str, solar_absorptivity: float, is_wall: bool = True) -> Tuple[bool, str]:
|
| 126 |
"""Validate inputs for CLTD calculations."""
|
|
@@ -197,14 +187,13 @@ class ASHRAETables:
|
|
| 197 |
0.9: 1.15 # Dark surfaces
|
| 198 |
}
|
| 199 |
|
| 200 |
-
|
| 201 |
"""
|
| 202 |
Load latitude correction factors for CLTD based on ASHRAE Handbook—Fundamentals (2017, Chapter 18, Table 7).
|
| 203 |
|
| 204 |
Returns:
|
| 205 |
pd.DataFrame: DataFrame with columns 'latitude' (degrees N), 'correction_factor' (dimensionless).
|
| 206 |
"""
|
| 207 |
-
logger.info("Loading latitude correction table")
|
| 208 |
try:
|
| 209 |
# Simplified correction factors for CLTD (dimensionless, applied to wall/roof conduction)
|
| 210 |
# Values are approximate, based on ASHRAE Table 7 for typical wall/roof types
|
|
@@ -216,11 +205,9 @@ class ASHRAETables:
|
|
| 216 |
{'latitude': 56, 'correction_factor': 0.92}
|
| 217 |
]
|
| 218 |
df = pd.DataFrame(data)
|
| 219 |
-
logger.info(f"Latitude correction table loaded: {df.shape[0]} rows")
|
| 220 |
return df
|
| 221 |
except Exception as e:
|
| 222 |
-
|
| 223 |
-
raise
|
| 224 |
|
| 225 |
def _load_occupancy_heat_gain_table(self) -> pd.DataFrame:
|
| 226 |
"""
|
|
@@ -348,8 +335,7 @@ class ASHRAETables:
|
|
| 348 |
raise ValueError(f"No data found for source: {source}, subcategory: {subcategory}")
|
| 349 |
return float(row['sensible'].iloc[0]), float(row['latent'].iloc[0])
|
| 350 |
except Exception as e:
|
| 351 |
-
|
| 352 |
-
raise
|
| 353 |
|
| 354 |
def interpolate_cltd(self, latitude: float, cltd_table_low: pd.DataFrame, cltd_table_high: pd.DataFrame, lat_low: float, lat_high: float) -> pd.DataFrame:
|
| 355 |
"""
|
|
|
|
| 15 |
"""
|
| 16 |
|
| 17 |
from typing import Dict, List, Any, Optional, Tuple
|
|
|
|
| 18 |
import pandas as pd
|
| 19 |
import numpy as np
|
| 20 |
import os
|
|
|
|
| 92 |
class ASHRAETables:
|
| 93 |
"""Class for managing ASHRAE tables for load calculations, compliant with ASHRAE Handbook—Fundamentals (2017, Chapter 18)."""
|
| 94 |
|
| 95 |
+
def__init__(self):
|
| 96 |
+
"""Initialize ASHRAE tables with CLTD, SCL, CLF, heat gain, and correction factors."""
|
| 97 |
+
# Load tables
|
| 98 |
+
self.cltd_wall = self._load_cltd_wall_table()
|
| 99 |
+
self.cltd_roof = self._load_cltd_roof_table()
|
| 100 |
+
self.scl = self._load_scl_table()
|
| 101 |
+
self.clf_lights = self._load_clf_lights_table()
|
| 102 |
+
self.clf_people = self._load_clf_people_table()
|
| 103 |
+
self.clf_equipment = self._load_clf_equipment_table()
|
| 104 |
+
self.heat_gain = self._load_heat_gain_table()
|
| 105 |
+
self.occupancy_heat_gain = self._load_occupancy_heat_gain_table()
|
| 106 |
+
self.equipment_heat_gain = self._load_equipment_heat_gain_table()
|
| 107 |
+
# Load correction factors
|
| 108 |
+
self.latitude_correction = self._load_latitude_correction()
|
| 109 |
+
self.color_correction = self._load_color_correction()
|
| 110 |
+
self.month_correction = self._load_month_correction()
|
| 111 |
+
# Load thermal properties and roof classifications
|
| 112 |
+
self.thermal_properties = self._load_thermal_properties()
|
| 113 |
+
self.roof_classifications = self._load_roof_classifications()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
|
| 115 |
def _validate_cltd_inputs(self, group: str, orientation: str, hour: int, latitude: str, month: str, solar_absorptivity: float, is_wall: bool = True) -> Tuple[bool, str]:
|
| 116 |
"""Validate inputs for CLTD calculations."""
|
|
|
|
| 187 |
0.9: 1.15 # Dark surfaces
|
| 188 |
}
|
| 189 |
|
| 190 |
+
def_load_latitude_correction(self) -> pd.DataFrame:
|
| 191 |
"""
|
| 192 |
Load latitude correction factors for CLTD based on ASHRAE Handbook—Fundamentals (2017, Chapter 18, Table 7).
|
| 193 |
|
| 194 |
Returns:
|
| 195 |
pd.DataFrame: DataFrame with columns 'latitude' (degrees N), 'correction_factor' (dimensionless).
|
| 196 |
"""
|
|
|
|
| 197 |
try:
|
| 198 |
# Simplified correction factors for CLTD (dimensionless, applied to wall/roof conduction)
|
| 199 |
# Values are approximate, based on ASHRAE Table 7 for typical wall/roof types
|
|
|
|
| 205 |
{'latitude': 56, 'correction_factor': 0.92}
|
| 206 |
]
|
| 207 |
df = pd.DataFrame(data)
|
|
|
|
| 208 |
return df
|
| 209 |
except Exception as e:
|
| 210 |
+
raise Exception(f"Error loading latitude correction table: {str(e)}")
|
|
|
|
| 211 |
|
| 212 |
def _load_occupancy_heat_gain_table(self) -> pd.DataFrame:
|
| 213 |
"""
|
|
|
|
| 335 |
raise ValueError(f"No data found for source: {source}, subcategory: {subcategory}")
|
| 336 |
return float(row['sensible'].iloc[0]), float(row['latent'].iloc[0])
|
| 337 |
except Exception as e:
|
| 338 |
+
raise ValueError(f"Error in get_heat_gain: {str(e)}")
|
|
|
|
| 339 |
|
| 340 |
def interpolate_cltd(self, latitude: float, cltd_table_low: pd.DataFrame, cltd_table_high: pd.DataFrame, lat_low: float, lat_high: float) -> pd.DataFrame:
|
| 341 |
"""
|