Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- data/ashrae_tables.py +41 -0
data/ashrae_tables.py
CHANGED
|
@@ -84,8 +84,49 @@ class ASHRAETables:
|
|
| 84 |
return False, f"Invalid orientation: {orientation}. Valid orientations: {valid_orientations}"
|
| 85 |
if hour not in range(24):
|
| 86 |
return False, "Hour must be between 0 and 23."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
if latitude not in valid_latitudes:
|
| 88 |
return False, f"Invalid latitude: {latitude}. Valid latitudes: {valid_latitudes}"
|
|
|
|
| 89 |
if month not in valid_months:
|
| 90 |
return False, f"Invalid month: {month}. Valid months: {valid_months}"
|
| 91 |
if color not in valid_colors:
|
|
|
|
| 84 |
return False, f"Invalid orientation: {orientation}. Valid orientations: {valid_orientations}"
|
| 85 |
if hour not in range(24):
|
| 86 |
return False, "Hour must be between 0 and 23."
|
| 87 |
+
|
| 88 |
+
# Handle numeric latitude values and ensure comprehensive mapping
|
| 89 |
+
if latitude not in valid_latitudes:
|
| 90 |
+
# Try to convert numeric latitude to standard format
|
| 91 |
+
try:
|
| 92 |
+
# First, handle string representations that might contain direction indicators
|
| 93 |
+
if isinstance(latitude, str):
|
| 94 |
+
# Extract numeric part, removing 'N' or 'S'
|
| 95 |
+
lat_str = latitude.upper().strip()
|
| 96 |
+
num_part = ''.join(c for c in lat_str if c.isdigit() or c == '.')
|
| 97 |
+
lat_val = float(num_part)
|
| 98 |
+
|
| 99 |
+
# Adjust for southern hemisphere if needed
|
| 100 |
+
if 'S' in lat_str:
|
| 101 |
+
lat_val = -lat_val
|
| 102 |
+
else:
|
| 103 |
+
# Handle direct numeric input
|
| 104 |
+
lat_val = float(latitude)
|
| 105 |
+
|
| 106 |
+
# Take absolute value for mapping purposes
|
| 107 |
+
abs_lat = abs(lat_val)
|
| 108 |
+
|
| 109 |
+
# Map to the closest standard latitude
|
| 110 |
+
if abs_lat < 28:
|
| 111 |
+
mapped_latitude = '24N'
|
| 112 |
+
elif abs_lat < 36:
|
| 113 |
+
mapped_latitude = '32N'
|
| 114 |
+
elif abs_lat < 44:
|
| 115 |
+
mapped_latitude = '40N'
|
| 116 |
+
elif abs_lat < 52:
|
| 117 |
+
mapped_latitude = '48N'
|
| 118 |
+
else:
|
| 119 |
+
mapped_latitude = '56N'
|
| 120 |
+
|
| 121 |
+
# Use the mapped latitude for validation
|
| 122 |
+
latitude = mapped_latitude
|
| 123 |
+
|
| 124 |
+
except (ValueError, TypeError):
|
| 125 |
+
return False, f"Invalid latitude: {latitude}. Valid latitudes: {valid_latitudes}"
|
| 126 |
+
|
| 127 |
if latitude not in valid_latitudes:
|
| 128 |
return False, f"Invalid latitude: {latitude}. Valid latitudes: {valid_latitudes}"
|
| 129 |
+
|
| 130 |
if month not in valid_months:
|
| 131 |
return False, f"Invalid month: {month}. Valid months: {valid_months}"
|
| 132 |
if color not in valid_colors:
|