mabuseif commited on
Commit
19da9de
·
verified ·
1 Parent(s): f87c4c2

Update data/drapery.py

Browse files
Files changed (1) hide show
  1. data/drapery.py +32 -7
data/drapery.py CHANGED
@@ -400,7 +400,7 @@ class CLTDCalculator:
400
  """Class for calculating Cooling Load Temperature Difference (CLTD) values."""
401
 
402
  def __init__(self, indoor_temp: float = 25.6, outdoor_max_temp: float = 35.0,
403
- outdoor_daily_range: float = 11.7, latitude: Latitude = Latitude.LAT_40N,
404
  month: int = 7):
405
  """
406
  Initialize CLTD calculator.
@@ -409,17 +409,42 @@ class CLTDCalculator:
409
  indoor_temp: Indoor design temperature (°C)
410
  outdoor_max_temp: Outdoor maximum temperature (°C)
411
  outdoor_daily_range: Daily temperature range (°C)
412
- latitude: Latitude category (24°N, 40°N, 48°N)
413
  month: Month (1-12)
414
  """
415
- self.indoor_temp = indoor_temp # °C
416
- self.outdoor_max_temp = outdoor_max_temp # °C
417
- self.outdoor_daily_range = outdoor_daily_range # °C
418
- self.latitude = latitude
419
  self.month = month
420
  self.outdoor_avg_temp = outdoor_max_temp - outdoor_daily_range / 2
421
 
422
- # Initialize ASHRAE tables for SCL data
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
423
  self.ashrae_tables = ASHRAETables()
424
 
425
  # Load CLTD tables
 
400
  """Class for calculating Cooling Load Temperature Difference (CLTD) values."""
401
 
402
  def __init__(self, indoor_temp: float = 25.6, outdoor_max_temp: float = 35.0,
403
+ outdoor_daily_range: float = 11.7, latitude: Any = '40N',
404
  month: int = 7):
405
  """
406
  Initialize CLTD calculator.
 
409
  indoor_temp: Indoor design temperature (°C)
410
  outdoor_max_temp: Outdoor maximum temperature (°C)
411
  outdoor_daily_range: Daily temperature range (°C)
412
+ latitude: Latitude (number, e.g., 40, or string, e.g., '40N')
413
  month: Month (1-12)
414
  """
415
+ self.indoor_temp = indoor_temp
416
+ self.outdoor_max_temp = outdoor_max_temp
417
+ self.outdoor_daily_range = outdoor_daily_range
 
418
  self.month = month
419
  self.outdoor_avg_temp = outdoor_max_temp - outdoor_daily_range / 2
420
 
421
+ # Validate and map latitude
422
+ valid_latitudes = ['24N', '32N', '40N', '48N', '56N']
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
+ lat_val = float(num_part)
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'
435
+ elif abs_lat < 36:
436
+ mapped_latitude = '32N'
437
+ elif abs_lat < 44:
438
+ mapped_latitude = '40N'
439
+ elif abs_lat < 52:
440
+ mapped_latitude = '48N'
441
+ else:
442
+ mapped_latitude = '56N'
443
+ except (ValueError, TypeError):
444
+ raise ValueError(f"Invalid latitude: {latitude}. Use number (e.g., 40) or string (e.g., '40N')")
445
+ self.latitude = Latitude[mapped_latitude]
446
+
447
+ # Initialize ASHRAE tables
448
  self.ashrae_tables = ASHRAETables()
449
 
450
  # Load CLTD tables