Spaces:
Sleeping
Sleeping
Update data/ashrae_tables.py
Browse files- data/ashrae_tables.py +11 -11
data/ashrae_tables.py
CHANGED
@@ -1333,18 +1333,18 @@ class ASHRAETables:
|
|
1333 |
ValueError: If inputs are invalid or out of range.
|
1334 |
"""
|
1335 |
import streamlit as st # For debug logging
|
1336 |
-
|
1337 |
# Log inputs for debugging
|
1338 |
if st.session_state.get('debug_mode', False):
|
1339 |
st.write(f"Debug: get_cltd inputs: element_type={element_type}, group={group}, orientation={orientation}, hour={hour}, latitude={latitude}, solar_absorptivity={solar_absorptivity}")
|
1340 |
-
|
1341 |
if element_type not in ['wall', 'roof']:
|
1342 |
raise ValueError("element_type must be 'wall' or 'roof'")
|
1343 |
if hour not in range(24):
|
1344 |
raise ValueError("Hour must be between 0 and 23")
|
1345 |
if not 24 <= latitude <= 56:
|
1346 |
raise ValueError("Latitude must be between 24 and 56 degrees")
|
1347 |
-
|
1348 |
# Validate inputs
|
1349 |
is_wall = element_type == 'wall'
|
1350 |
latitude_str = f"{int(latitude)}N"
|
@@ -1352,25 +1352,25 @@ class ASHRAETables:
|
|
1352 |
is_valid, error_msg = self._validate_cltd_inputs(group, orientation, hour, latitude_str, month, solar_absorptivity, is_wall)
|
1353 |
if not is_valid:
|
1354 |
raise ValueError(error_msg)
|
1355 |
-
|
1356 |
# Available latitudes
|
1357 |
-
latitudes = [24, 32,
|
1358 |
lat1, lat2 = max([lat for lat in latitudes if lat <= latitude], default=24), min([lat for lat in latitudes if lat >= latitude], default=56)
|
1359 |
|
1360 |
# Log selected latitudes
|
1361 |
if st.session_state.get('debug_mode', False):
|
1362 |
st.write(f"Debug: Selected latitudes for interpolation: lat1={lat1}, lat2={lat2}")
|
1363 |
-
|
1364 |
# Load the appropriate table
|
1365 |
table = self.cltd_wall if element_type == 'wall' else self.cltd_roof
|
1366 |
-
key1 = f"{group}_{int(lat1)}"
|
1367 |
-
key2 = f"{group}_{int(lat2)}"
|
1368 |
|
1369 |
# Check if keys exist; use fallback if not
|
1370 |
if key1 not in table or key2 not in table:
|
1371 |
if st.session_state.get('debug_mode', False):
|
1372 |
st.write(f"Debug: Available table keys: {list(table.keys())}")
|
1373 |
-
st.error(f"Warning: Group {group} not found for latitude {lat1} or {lat2}. Using fallback CLTD value.")
|
1374 |
# Fallback CLTD value (average for medium construction, per ASHRAE)
|
1375 |
cltd = 8.0
|
1376 |
else:
|
@@ -1393,14 +1393,14 @@ class ASHRAETables:
|
|
1393 |
cltd = cltd1 + weight * (cltd2 - cltd1)
|
1394 |
if st.session_state.get('debug_mode', False):
|
1395 |
st.write(f"Debug: Interpolated CLTD: weight={weight}, cltd={cltd}")
|
1396 |
-
|
1397 |
# Apply corrections
|
1398 |
lm = self.month_correction.get(month, 0.0) # Simplified access for July
|
1399 |
f = self._load_fenestration_correction().get('Standard', 1.0)
|
1400 |
corrected_cltd = self.apply_cltd_corrections(cltd, lm, solar_absorptivity, f)
|
1401 |
if st.session_state.get('debug_mode', False):
|
1402 |
st.write(f"Debug: Applied corrections: lm={lm}, f={f}, corrected_cltd={corrected_cltd}")
|
1403 |
-
|
1404 |
return corrected_cltd
|
1405 |
|
1406 |
@lru_cache(maxsize=1000)
|
|
|
1333 |
ValueError: If inputs are invalid or out of range.
|
1334 |
"""
|
1335 |
import streamlit as st # For debug logging
|
1336 |
+
|
1337 |
# Log inputs for debugging
|
1338 |
if st.session_state.get('debug_mode', False):
|
1339 |
st.write(f"Debug: get_cltd inputs: element_type={element_type}, group={group}, orientation={orientation}, hour={hour}, latitude={latitude}, solar_absorptivity={solar_absorptivity}")
|
1340 |
+
|
1341 |
if element_type not in ['wall', 'roof']:
|
1342 |
raise ValueError("element_type must be 'wall' or 'roof'")
|
1343 |
if hour not in range(24):
|
1344 |
raise ValueError("Hour must be between 0 and 23")
|
1345 |
if not 24 <= latitude <= 56:
|
1346 |
raise ValueError("Latitude must be between 24 and 56 degrees")
|
1347 |
+
|
1348 |
# Validate inputs
|
1349 |
is_wall = element_type == 'wall'
|
1350 |
latitude_str = f"{int(latitude)}N"
|
|
|
1352 |
is_valid, error_msg = self._validate_cltd_inputs(group, orientation, hour, latitude_str, month, solar_absorptivity, is_wall)
|
1353 |
if not is_valid:
|
1354 |
raise ValueError(error_msg)
|
1355 |
+
|
1356 |
# Available latitudes
|
1357 |
+
latitudes = [24, 32, 36, 44, 56] # Updated to match table keys
|
1358 |
lat1, lat2 = max([lat for lat in latitudes if lat <= latitude], default=24), min([lat for lat in latitudes if lat >= latitude], default=56)
|
1359 |
|
1360 |
# Log selected latitudes
|
1361 |
if st.session_state.get('debug_mode', False):
|
1362 |
st.write(f"Debug: Selected latitudes for interpolation: lat1={lat1}, lat2={lat2}")
|
1363 |
+
|
1364 |
# Load the appropriate table
|
1365 |
table = self.cltd_wall if element_type == 'wall' else self.cltd_roof
|
1366 |
+
key1 = f"{group}_{int(lat1)}N" # e.g., A_32N
|
1367 |
+
key2 = f"{group}_{int(lat2)}N" # e.g., A_32N
|
1368 |
|
1369 |
# Check if keys exist; use fallback if not
|
1370 |
if key1 not in table or key2 not in table:
|
1371 |
if st.session_state.get('debug_mode', False):
|
1372 |
st.write(f"Debug: Available table keys: {list(table.keys())}")
|
1373 |
+
st.error(f"Warning: Group {group} not found for latitude {lat1}N or {lat2}N. Using fallback CLTD value.")
|
1374 |
# Fallback CLTD value (average for medium construction, per ASHRAE)
|
1375 |
cltd = 8.0
|
1376 |
else:
|
|
|
1393 |
cltd = cltd1 + weight * (cltd2 - cltd1)
|
1394 |
if st.session_state.get('debug_mode', False):
|
1395 |
st.write(f"Debug: Interpolated CLTD: weight={weight}, cltd={cltd}")
|
1396 |
+
|
1397 |
# Apply corrections
|
1398 |
lm = self.month_correction.get(month, 0.0) # Simplified access for July
|
1399 |
f = self._load_fenestration_correction().get('Standard', 1.0)
|
1400 |
corrected_cltd = self.apply_cltd_corrections(cltd, lm, solar_absorptivity, f)
|
1401 |
if st.session_state.get('debug_mode', False):
|
1402 |
st.write(f"Debug: Applied corrections: lm={lm}, f={f}, corrected_cltd={corrected_cltd}")
|
1403 |
+
|
1404 |
return corrected_cltd
|
1405 |
|
1406 |
@lru_cache(maxsize=1000)
|