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

Update data/ashrae_tables.py

Browse files
Files changed (1) hide show
  1. data/ashrae_tables.py +20 -1
data/ashrae_tables.py CHANGED
@@ -581,6 +581,20 @@ class ASHRAETables:
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,8 +616,13 @@ class ASHRAETables:
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
 
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
  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