mabuseif commited on
Commit
e6865be
·
verified ·
1 Parent(s): 707d51f

Update data/ashrae_tables.py

Browse files
Files changed (1) hide show
  1. data/ashrae_tables.py +30 -21
data/ashrae_tables.py CHANGED
@@ -581,20 +581,6 @@ class ASHRAETables:
581
  except Exception as e:
582
  raise ValueError(f"Error applying climatic corrections: {str(e)}")
583
 
584
- def get_cltd_wall(self, wall_group: str, orientation: str, hour: int) -> float:
585
- """Get CLTD value for a wall."""
586
- if wall_group not in self.cltd_wall:
587
- raise ValueError(f"Invalid wall group: {wall_group}")
588
- orientation_map = {e.value: e.name for e in Orientation}
589
- orientation_abbr = orientation_map.get(orientation, orientation)
590
- if orientation_abbr not in self.cltd_wall[wall_group].columns:
591
- raise ValueError(f"Invalid orientation: {orientation}")
592
- # Normalize hour to 0-23 range for cyclic data
593
- normalized_hour = hour % 24
594
- if normalized_hour not in self.cltd_wall[wall_group].index:
595
- raise ValueError(f"Invalid hour: {hour} (normalized to {normalized_hour})")
596
- return float(self.cltd_wall[wall_group].loc[normalized_hour, orientation_abbr])
597
-
598
  def calculate_corrected_cltd_wall(self, wall_group: str, orientation: str, hour: int, latitude: str, month: str, color: str, outdoor_temp: float, indoor_temp: float) -> float:
599
  """
600
  Calculate corrected CLTD for a wall with climatic corrections.
@@ -616,15 +602,38 @@ class ASHRAETables:
616
  ValueError: If inputs are invalid or correction fails.
617
  """
618
  try:
619
- # Validate hour
620
- if not isinstance(hour, int):
621
- raise ValueError(f"Hour must be an integer, got: {hour}")
622
- # Normalize hour to 0-23 range
623
- normalized_hour = hour % 24
624
  # Get base CLTD
625
- base_cltd = self.get_cltd_wall(wall_group, orientation, normalized_hour)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
626
  # Apply climatic corrections
627
  corrected_cltd = self._apply_climatic_corrections(base_cltd, latitude, month, color, outdoor_temp, indoor_temp)
628
  return corrected_cltd
629
  except Exception as e:
630
- raise ValueError(f"Error calculating corrected CLTD for wall: {str(e)}")
 
581
  except Exception as e:
582
  raise ValueError(f"Error applying climatic corrections: {str(e)}")
583
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
584
  def calculate_corrected_cltd_wall(self, wall_group: str, orientation: str, hour: int, latitude: str, month: str, color: str, outdoor_temp: float, indoor_temp: float) -> float:
585
  """
586
  Calculate corrected CLTD for a wall with climatic corrections.
 
602
  ValueError: If inputs are invalid or correction fails.
603
  """
604
  try:
 
 
 
 
 
605
  # Get base CLTD
606
+ base_cltd = self.get_cltd_wall(wall_group, orientation, hour)
607
+ # Apply climatic corrections
608
+ corrected_cltd = self._apply_climatic_corrections(base_cltd, latitude, month, color, outdoor_temp, indoor_temp)
609
+ return corrected_cltd
610
+ except Exception as e:
611
+ raise ValueError(f"Error calculating corrected CLTD for wall: {str(e)}")
612
+
613
+ def calculate_corrected_cltd_roof(self, roof_group: str, latitude: str, hour: int, month: str, color: str, outdoor_temp: float, indoor_temp: float) -> float:
614
+ """
615
+ Calculate corrected CLTD for a roof with climatic corrections.
616
+
617
+ Args:
618
+ roof_group (str): Roof group (e.g., 'A', 'B', ..., 'G').
619
+ latitude (str): Latitude (e.g., '24N', '36N', '48N').
620
+ hour (int): Hour of the day (0-23).
621
+ month (str): Month (e.g., 'Jul').
622
+ color (str): Surface color ('Dark', 'Medium', 'Light').
623
+ outdoor_temp (float): Outdoor design temperature (°C).
624
+ indoor_temp (float): Indoor design temperature (°C).
625
+
626
+ Returns:
627
+ float: Corrected CLTD value (°C).
628
+
629
+ Raises:
630
+ ValueError: If inputs are invalid or correction fails.
631
+ """
632
+ try:
633
+ # Get base CLTD
634
+ base_cltd = self.get_cltd_roof(roof_group, latitude, hour)
635
  # Apply climatic corrections
636
  corrected_cltd = self._apply_climatic_corrections(base_cltd, latitude, month, color, outdoor_temp, indoor_temp)
637
  return corrected_cltd
638
  except Exception as e:
639
+ raise ValueError(f"Error calculating corrected CLTD for roof: {str(e)}")