Spaces:
Sleeping
Sleeping
Update data/ashrae_tables.py
Browse files- data/ashrae_tables.py +46 -20
data/ashrae_tables.py
CHANGED
@@ -114,27 +114,12 @@ class ASHRAETables:
|
|
114 |
self.thermal_properties = self._load_thermal_properties()
|
115 |
self.roof_classifications = self._load_roof_classifications()
|
116 |
|
117 |
-
def _validate_cltd_inputs(self, group: str, orientation: str, hour: int, latitude: str, month: str,
|
118 |
-
"""
|
119 |
-
Validate inputs for CLTD calculations.
|
120 |
-
|
121 |
-
Args:
|
122 |
-
group (str): Wall or roof group (e.g., 'A', 'B').
|
123 |
-
orientation (str): Orientation (e.g., 'North', 'Horizontal').
|
124 |
-
hour (int): Hour of the day (0-23).
|
125 |
-
latitude (str): Latitude (e.g., '24N').
|
126 |
-
month (str): Month (e.g., 'Jul').
|
127 |
-
color (str): Surface color ('Dark', 'Medium', 'Light').
|
128 |
-
is_wall (bool): True if validating for walls, False for roofs.
|
129 |
-
|
130 |
-
Returns:
|
131 |
-
Tuple[bool, str]: (is_valid, error_message).
|
132 |
-
"""
|
133 |
valid_groups = [e.value for e in WallGroup] if is_wall else [e.value for e in RoofGroup]
|
134 |
valid_orientations = [e.value for e in Orientation]
|
135 |
-
valid_latitudes = ['24N', '32N', '
|
136 |
valid_months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
|
137 |
-
valid_colors = ['Dark', 'Medium', 'Light']
|
138 |
|
139 |
if group not in valid_groups:
|
140 |
return False, f"Invalid {'wall' if is_wall else 'roof'} group: {group}. Valid groups: {valid_groups}"
|
@@ -142,12 +127,53 @@ class ASHRAETables:
|
|
142 |
return False, f"Invalid orientation: {orientation}. Valid orientations: {valid_orientations}"
|
143 |
if hour not in range(24):
|
144 |
return False, "Hour must be between 0 and 23."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
if latitude not in valid_latitudes:
|
146 |
return False, f"Invalid latitude: {latitude}. Valid latitudes: {valid_latitudes}"
|
|
|
147 |
if month not in valid_months:
|
148 |
return False, f"Invalid month: {month}. Valid months: {valid_months}"
|
149 |
-
if
|
150 |
-
return False, f"Invalid
|
151 |
return True, "Valid inputs."
|
152 |
|
153 |
def interpolate_cltd(self, latitude: float, cltd_table_low: pd.DataFrame, cltd_table_high: pd.DataFrame, lat_low: float, lat_high: float) -> pd.DataFrame:
|
|
|
114 |
self.thermal_properties = self._load_thermal_properties()
|
115 |
self.roof_classifications = self._load_roof_classifications()
|
116 |
|
117 |
+
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]:
|
118 |
+
"""Validate inputs for CLTD calculations."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
valid_groups = [e.value for e in WallGroup] if is_wall else [e.value for e in RoofGroup]
|
120 |
valid_orientations = [e.value for e in Orientation]
|
121 |
+
valid_latitudes = ['24N', '32N', '40N', '48N', '56N']
|
122 |
valid_months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
|
|
|
123 |
|
124 |
if group not in valid_groups:
|
125 |
return False, f"Invalid {'wall' if is_wall else 'roof'} group: {group}. Valid groups: {valid_groups}"
|
|
|
127 |
return False, f"Invalid orientation: {orientation}. Valid orientations: {valid_orientations}"
|
128 |
if hour not in range(24):
|
129 |
return False, "Hour must be between 0 and 23."
|
130 |
+
|
131 |
+
# Handle numeric latitude values and ensure comprehensive mapping
|
132 |
+
if latitude not in valid_latitudes:
|
133 |
+
# Try to convert numeric latitude to standard format
|
134 |
+
try:
|
135 |
+
# First, handle string representations that might contain direction indicators
|
136 |
+
if isinstance(latitude, str):
|
137 |
+
# Extract numeric part, removing 'N' or 'S'
|
138 |
+
lat_str = latitude.upper().strip()
|
139 |
+
num_part = ''.join(c for c in lat_str if c.isdigit() or c == '.')
|
140 |
+
lat_val = float(num_part)
|
141 |
+
|
142 |
+
# Adjust for southern hemisphere if needed
|
143 |
+
if 'S' in lat_str:
|
144 |
+
lat_val = -lat_val
|
145 |
+
else:
|
146 |
+
# Handle direct numeric input
|
147 |
+
lat_val = float(latitude)
|
148 |
+
|
149 |
+
# Take absolute value for mapping purposes
|
150 |
+
abs_lat = abs(lat_val)
|
151 |
+
|
152 |
+
# Map to the closest standard latitude
|
153 |
+
if abs_lat < 28:
|
154 |
+
mapped_latitude = '24N'
|
155 |
+
elif abs_lat < 36:
|
156 |
+
mapped_latitude = '32N'
|
157 |
+
elif abs_lat < 44:
|
158 |
+
mapped_latitude = '40N'
|
159 |
+
elif abs_lat < 52:
|
160 |
+
mapped_latitude = '48N'
|
161 |
+
else:
|
162 |
+
mapped_latitude = '56N'
|
163 |
+
|
164 |
+
# Use the mapped latitude for validation
|
165 |
+
latitude = mapped_latitude
|
166 |
+
|
167 |
+
except (ValueError, TypeError):
|
168 |
+
return False, f"Invalid latitude: {latitude}. Valid latitudes: {valid_latitudes}"
|
169 |
+
|
170 |
if latitude not in valid_latitudes:
|
171 |
return False, f"Invalid latitude: {latitude}. Valid latitudes: {valid_latitudes}"
|
172 |
+
|
173 |
if month not in valid_months:
|
174 |
return False, f"Invalid month: {month}. Valid months: {valid_months}"
|
175 |
+
if not 0.0 <= solar_absorptivity <= 1.0:
|
176 |
+
return False, f"Invalid solar absorptivity: {solar_absorptivity}. Must be between 0.0 and 1.0."
|
177 |
return True, "Valid inputs."
|
178 |
|
179 |
def interpolate_cltd(self, latitude: float, cltd_table_low: pd.DataFrame, cltd_table_high: pd.DataFrame, lat_low: float, lat_high: float) -> pd.DataFrame:
|