mabuseif commited on
Commit
39ce859
·
verified ·
1 Parent(s): 43390f9

Update data/drapery.py

Browse files
Files changed (1) hide show
  1. data/drapery.py +47 -0
data/drapery.py CHANGED
@@ -283,6 +283,53 @@ class Drapery:
283
  self.fullness = fullness
284
  self.enabled = enabled
285
  self.shading_device = shading_device
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
286
 
287
  def get_openness_category(self) -> str:
288
  """Get openness category as string."""
 
283
  self.fullness = fullness
284
  self.enabled = enabled
285
  self.shading_device = shading_device
286
+
287
+ def _validate_inputs(self, drapery_type: str, orientation: str, hour: int, latitude: Any, month: str) -> Tuple[bool, str, str]:
288
+ """Validate inputs for drapery shading coefficient calculations, following ASHRAE latitude handling."""
289
+ valid_drapery_types = list(self.shading_coefficients.keys())
290
+ valid_orientations = [e.value for e in Orientation]
291
+ valid_latitudes = ['24N', '32N', '40N', '48N', '56N']
292
+ valid_months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
293
+
294
+ if drapery_type not in valid_drapery_types:
295
+ return False, f"Invalid drapery type: {drapery_type}. Valid types: {valid_drapery_types}", ""
296
+ if orientation not in valid_orientations:
297
+ return False, f"Invalid orientation: {orientation}. Valid orientations: {valid_orientations}", ""
298
+ if hour not in range(24):
299
+ return False, "Hour must be between 0 and 23.", ""
300
+
301
+ # Handle latitude input, following ASHRAE
302
+ mapped_latitude = ""
303
+ if latitude not in valid_latitudes:
304
+ try:
305
+ if isinstance(latitude, str):
306
+ lat_str = latitude.upper().strip().replace('°', '').replace(' ', '')
307
+ num_part = ''.join(c for c in lat_str if c.isdigit() or c == '.')
308
+ lat_val = float(num_part)
309
+ if 'S' in lat_str:
310
+ lat_val = -lat_val
311
+ else:
312
+ lat_val = float(latitude)
313
+ abs_lat = abs(lat_val)
314
+ if abs_lat < 28:
315
+ mapped_latitude = '24N'
316
+ elif abs_lat < 36:
317
+ mapped_latitude = '32N'
318
+ elif abs_lat < 44:
319
+ mapped_latitude = '40N'
320
+ elif abs_lat < 52:
321
+ mapped_latitude = '48N'
322
+ else:
323
+ mapped_latitude = '56N'
324
+ except (ValueError, TypeError):
325
+ return False, f"Invalid latitude: {latitude}. Valid latitudes: {valid_latitudes}", ""
326
+ else:
327
+ mapped_latitude = latitude
328
+
329
+ if month not in valid_months:
330
+ return False, f"Invalid month: {month}. Valid months: {valid_months}", ""
331
+
332
+ return True, "Valid inputs.", mapped_latitude
333
 
334
  def get_openness_category(self) -> str:
335
  """Get openness category as string."""