Spaces:
Sleeping
Sleeping
Update data/drapery.py
Browse files- data/drapery.py +33 -8
data/drapery.py
CHANGED
@@ -395,7 +395,6 @@ class Drapery:
|
|
395 |
}
|
396 |
return reductions.get(self.openness, 0.10)
|
397 |
|
398 |
-
|
399 |
class CLTDCalculator:
|
400 |
"""Class for calculating Cooling Load Temperature Difference (CLTD) values."""
|
401 |
|
@@ -423,12 +422,18 @@ class CLTDCalculator:
|
|
423 |
try:
|
424 |
if isinstance(latitude, str):
|
425 |
lat_str = latitude.upper().strip().replace('°', '').replace(' ', '')
|
|
|
426 |
num_part = ''.join(c for c in lat_str if c.isdigit() or c == '.')
|
427 |
-
|
|
|
|
|
|
|
|
|
428 |
if 'S' in lat_str:
|
429 |
lat_val = -lat_val
|
430 |
else:
|
431 |
lat_val = float(latitude)
|
|
|
432 |
abs_lat = abs(lat_val)
|
433 |
if abs_lat < 28:
|
434 |
mapped_latitude = '24N'
|
@@ -440,9 +445,16 @@ class CLTDCalculator:
|
|
440 |
mapped_latitude = '48N'
|
441 |
else:
|
442 |
mapped_latitude = '56N'
|
443 |
-
|
444 |
-
|
445 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
446 |
|
447 |
# Initialize ASHRAE tables
|
448 |
self.ashrae_tables = ASHRAETables()
|
@@ -839,10 +851,22 @@ class CLTDCalculator:
|
|
839 |
Returns:
|
840 |
Corrected CLTD value (°C)
|
841 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
842 |
try:
|
843 |
-
base_cltd = self.cltd_window_tables[self.latitude.value][
|
844 |
-
|
845 |
-
|
|
|
|
|
|
|
846 |
|
847 |
# Apply corrections
|
848 |
latitude_factor = self.latitude_corrections.get(self.latitude.value, 1.0)
|
@@ -850,6 +874,7 @@ class CLTDCalculator:
|
|
850 |
temp_correction = (self.outdoor_avg_temp - 29.4) + (self.indoor_temp - 24.0)
|
851 |
|
852 |
corrected_cltd = base_cltd * latitude_factor * month_factor + temp_correction
|
|
|
853 |
return max(0.0, corrected_cltd)
|
854 |
|
855 |
def get_cltd_door(self, door_type: str, orientation: str, hour: int) -> float:
|
|
|
395 |
}
|
396 |
return reductions.get(self.openness, 0.10)
|
397 |
|
|
|
398 |
class CLTDCalculator:
|
399 |
"""Class for calculating Cooling Load Temperature Difference (CLTD) values."""
|
400 |
|
|
|
422 |
try:
|
423 |
if isinstance(latitude, str):
|
424 |
lat_str = latitude.upper().strip().replace('°', '').replace(' ', '')
|
425 |
+
logger.debug(f"Processing latitude string: {lat_str}")
|
426 |
num_part = ''.join(c for c in lat_str if c.isdigit() or c == '.')
|
427 |
+
try:
|
428 |
+
lat_val = float(num_part)
|
429 |
+
except ValueError:
|
430 |
+
logger.error(f"Failed to parse numerical part from latitude: {lat_str}")
|
431 |
+
raise ValueError(f"Invalid latitude format: {latitude}. Expected format like '32N'")
|
432 |
if 'S' in lat_str:
|
433 |
lat_val = -lat_val
|
434 |
else:
|
435 |
lat_val = float(latitude)
|
436 |
+
logger.debug(f"Processing numerical latitude: {lat_val}")
|
437 |
abs_lat = abs(lat_val)
|
438 |
if abs_lat < 28:
|
439 |
mapped_latitude = '24N'
|
|
|
445 |
mapped_latitude = '48N'
|
446 |
else:
|
447 |
mapped_latitude = '56N'
|
448 |
+
logger.debug(f"Mapped latitude: {lat_val} -> {mapped_latitude}")
|
449 |
+
except (ValueError, TypeError) as e:
|
450 |
+
logger.error(f"Invalid latitude: {latitude}. Defaulting to 40N. Error: {str(e)}")
|
451 |
+
mapped_latitude = '40N'
|
452 |
+
try:
|
453 |
+
self.latitude = Latitude[mapped_latitude]
|
454 |
+
logger.debug(f"Set latitude enum: {self.latitude}")
|
455 |
+
except KeyError:
|
456 |
+
logger.error(f"Latitude {mapped_latitude} not found in Latitude enum. Defaulting to LAT_40N")
|
457 |
+
self.latitude = Latitude.LAT_40N
|
458 |
|
459 |
# Initialize ASHRAE tables
|
460 |
self.ashrae_tables = ASHRAETables()
|
|
|
851 |
Returns:
|
852 |
Corrected CLTD value (°C)
|
853 |
"""
|
854 |
+
# Map glazing type to table keys
|
855 |
+
glazing_key_map = {
|
856 |
+
'Single Clear': 'SingleClear',
|
857 |
+
'Double Tinted': 'DoubleTinted',
|
858 |
+
'Low-E': 'LowE',
|
859 |
+
'Reflective': 'Reflective'
|
860 |
+
}
|
861 |
+
glazing_key = glazing_key_map.get(glazing_type, glazing_type)
|
862 |
+
logger.debug(f"get_cltd_window: glazing_type={glazing_type}, mapped_glazing_key={glazing_key}, orientation={orientation}, hour={hour}, latitude={self.latitude.value}")
|
863 |
try:
|
864 |
+
base_cltd = self.cltd_window_tables[self.latitude.value][glazing_key][orientation][hour]
|
865 |
+
logger.debug(f"Base CLTD: {base_cltd}")
|
866 |
+
except KeyError as e:
|
867 |
+
logger.error(f"KeyError in cltd_window_tables: latitude={self.latitude.value}, glazing_key={glazing_key}, orientation={orientation}, hour={hour}. Error: {str(e)}")
|
868 |
+
logger.warning("Using default CLTD=8.0°C")
|
869 |
+
base_cltd = 8.0
|
870 |
|
871 |
# Apply corrections
|
872 |
latitude_factor = self.latitude_corrections.get(self.latitude.value, 1.0)
|
|
|
874 |
temp_correction = (self.outdoor_avg_temp - 29.4) + (self.indoor_temp - 24.0)
|
875 |
|
876 |
corrected_cltd = base_cltd * latitude_factor * month_factor + temp_correction
|
877 |
+
logger.debug(f"Applied corrections: base_cltd={base_cltd}, latitude_factor={latitude_factor}, month_factor={month_factor}, temp_correction={temp_correction}, corrected_cltd={corrected_cltd}")
|
878 |
return max(0.0, corrected_cltd)
|
879 |
|
880 |
def get_cltd_door(self, door_type: str, orientation: str, hour: int) -> float:
|