+ UV index label

* AQ fixes
+ Sun/moon distance
+ moon position
* moon illumination
This commit is contained in:
2026-06-24 10:12:58 -04:00
parent 67c46a935e
commit 97cf840847
3 changed files with 81 additions and 12 deletions

View File

@@ -132,13 +132,17 @@ def vpd(tc, rh):
def gas_to_aqi(gas_ohms, humidity, gas_reference):
if gas_ohms is None: return None, None
score = min(max(round(min(gas_ohms/gas_reference,1.0)*75 + (25 - abs(humidity-40)*0.5)), 0), 100)
label = 'Very Poor'
if score >= 80: label = 'Excellent'
elif score >= 60: label = 'Good'
elif score >= 40: label = 'Fair'
elif score >= 20: label = 'Poor'
return score, label
gas_score = min(gas_ohms / gas_reference, 1.0) * 75
hum_score = 25 - abs(humidity - 40) * 0.5
quality = min(max(gas_score + hum_score, 0), 100)
aqi = round((1 - quality / 100) * 500)
if aqi <= 50: label = 'Good'
elif aqi <= 100: label = 'Standard'
elif aqi <= 150: label = 'Warning'
elif aqi <= 200: label = 'Unhealthy'
elif aqi <= 300: label = 'Very Unhealthy'
else: label = 'Hazardous'
return aqi, label
def sea_level_pressure(pressure_hpa, alt_m):
if alt_m is None: return None
@@ -362,6 +366,13 @@ def visibility_estimate(lux, humidity, solar_el=None):
lux_factor = 1.0
return round(base_km * hum_factor * lux_factor, 1)
def uv_index_label(uvi):
if uvi < 3: return 'Low'
elif uvi < 6: return 'Moderate'
elif uvi < 8: return 'High'
elif uvi < 11: return 'Very High'
else: return 'Extreme'
def read_ltr(c, sensor, solar_el, humidity=None):
global uv_dose_mj, uv_dose_date, last_uv_time
global dli_lux_acc, dli_date, last_lux_time, daylight_start
@@ -414,7 +425,10 @@ def read_ltr(c, sensor, solar_el, humidity=None):
'daily_light_integral': dli,
'daylight': daylight_hours,
'visibility': visibility_estimate(lux, humidity, solar_el) if humidity else None,
}, tags={'clouds_label': cloud_label or ''})
}, tags={
'clouds_label': cloud_label or ''
'uv_index_label': uv_index_label(uvi),
})
# ── TF-Luna ───────────────────────────────────────────────────────────────────