pyastroweatherio 0.75.0.dev2__tar.gz → 0.75.0.dev3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (16) hide show
  1. {pyastroweatherio-0.75.0.dev2 → pyastroweatherio-0.75.0.dev3}/PKG-INFO +1 -1
  2. {pyastroweatherio-0.75.0.dev2 → pyastroweatherio-0.75.0.dev3}/pyastroweatherio/helper_functions.py +194 -126
  3. {pyastroweatherio-0.75.0.dev2 → pyastroweatherio-0.75.0.dev3}/pyastroweatherio.egg-info/PKG-INFO +1 -1
  4. {pyastroweatherio-0.75.0.dev2 → pyastroweatherio-0.75.0.dev3}/setup.py +1 -1
  5. {pyastroweatherio-0.75.0.dev2 → pyastroweatherio-0.75.0.dev3}/LICENSE +0 -0
  6. {pyastroweatherio-0.75.0.dev2 → pyastroweatherio-0.75.0.dev3}/README.md +0 -0
  7. {pyastroweatherio-0.75.0.dev2 → pyastroweatherio-0.75.0.dev3}/pyastroweatherio/__init__.py +0 -0
  8. {pyastroweatherio-0.75.0.dev2 → pyastroweatherio-0.75.0.dev3}/pyastroweatherio/client.py +0 -0
  9. {pyastroweatherio-0.75.0.dev2 → pyastroweatherio-0.75.0.dev3}/pyastroweatherio/const.py +0 -0
  10. {pyastroweatherio-0.75.0.dev2 → pyastroweatherio-0.75.0.dev3}/pyastroweatherio/dataclasses.py +0 -0
  11. {pyastroweatherio-0.75.0.dev2 → pyastroweatherio-0.75.0.dev3}/pyastroweatherio/errors.py +0 -0
  12. {pyastroweatherio-0.75.0.dev2 → pyastroweatherio-0.75.0.dev3}/pyastroweatherio.egg-info/SOURCES.txt +0 -0
  13. {pyastroweatherio-0.75.0.dev2 → pyastroweatherio-0.75.0.dev3}/pyastroweatherio.egg-info/dependency_links.txt +0 -0
  14. {pyastroweatherio-0.75.0.dev2 → pyastroweatherio-0.75.0.dev3}/pyastroweatherio.egg-info/requires.txt +0 -0
  15. {pyastroweatherio-0.75.0.dev2 → pyastroweatherio-0.75.0.dev3}/pyastroweatherio.egg-info/top_level.txt +0 -0
  16. {pyastroweatherio-0.75.0.dev2 → pyastroweatherio-0.75.0.dev3}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyastroweatherio
3
- Version: 0.75.0.dev2
3
+ Version: 0.75.0.dev3
4
4
  Summary: Python Wrapper for OpenMeteo and Met.no REST API
5
5
  Home-page: https://github.com/mawinkler/pyastroweatherio
6
6
  Author: Markus Winkler
@@ -62,11 +62,7 @@ class AtmosphericRoutines:
62
62
  # ---------- small internal helpers ----------
63
63
  @staticmethod
64
64
  def _is_missing(values: dict) -> list[str]:
65
- return [
66
- name
67
- for name, val in values.items()
68
- if val is None or (isinstance(val, float) and math.isnan(val))
69
- ]
65
+ return [name for name, val in values.items() if val is None or (isinstance(val, float) and math.isnan(val))]
70
66
 
71
67
  @staticmethod
72
68
  def _svp_hpa_magnus(Tc: float) -> float:
@@ -86,7 +82,7 @@ class AtmosphericRoutines:
86
82
  @staticmethod
87
83
  def _sigmoid(x: float) -> float:
88
84
  return 1.0 / (1.0 + math.exp(-x))
89
-
85
+
90
86
  # #####################################################
91
87
  # Calculate lifted index
92
88
  # #####################################################
@@ -148,24 +144,24 @@ class AtmosphericRoutines:
148
144
  return lifted_index
149
145
 
150
146
  # _11
151
- def _tlcl_bolton(self, T, Td):
152
- # T, Td in Kelvin. Bolton (1980) eqn 15 surrogate:
153
- return 1.0 / (1.0 / (Td - 56.0) + math.log(T / Td) / 800.0) + 56.0 # K
154
-
155
- def _moist_adiabat_to(self, T_lcl, p_lcl, p_target):
156
- # Bolton moist-adiabatic approximation via equivalent potential temp (θe)
157
- # For brevity, use a simple iterative moist lapse (Γ_m) integrator; step dp.
158
- T = T_lcl
159
- p = p_lcl
160
- dp = -5.0 # hPa step upward
161
- while p + dp >= p_target:
162
- # Γ_m ~ g*(1 + Lq/(Rd T)) / (cp + (L^2 q ε)/(R_d T^2)) [approx]
163
- # keep it simple or use Bolton’s formulas if you prefer
164
- gamma_m = 4.5 # K/km crude; replace with proper Γ_m(T,p)
165
- dz = 8.0 * abs(dp) # ~8 m/hPa
166
- T -= gamma_m * (dz / 1000.0)
167
- p += dp
168
- return T
147
+ # def _tlcl_bolton(self, T, Td):
148
+ # # T, Td in Kelvin. Bolton (1980) eqn 15 surrogate:
149
+ # return 1.0 / (1.0 / (Td - 56.0) + math.log(T / Td) / 800.0) + 56.0 # K
150
+
151
+ # def _moist_adiabat_to(self, T_lcl, p_lcl, p_target):
152
+ # # Bolton moist-adiabatic approximation via equivalent potential temp (θe)
153
+ # # For brevity, use a simple iterative moist lapse (Γ_m) integrator; step dp.
154
+ # T = T_lcl
155
+ # p = p_lcl
156
+ # dp = -5.0 # hPa step upward
157
+ # while p + dp >= p_target:
158
+ # # Γ_m ~ g*(1 + Lq/(Rd T)) / (cp + (L^2 q ε)/(R_d T^2)) [approx]
159
+ # # keep it simple or use Bolton’s formulas if you prefer
160
+ # gamma_m = 4.5 # K/km crude; replace with proper Γ_m(T,p)
161
+ # dz = 8.0 * abs(dp) # ~8 m/hPa
162
+ # T -= gamma_m * (dz / 1000.0)
163
+ # p += dp
164
+ # return T
169
165
 
170
166
  @typechecked
171
167
  async def calculate_lifted_index_11(
@@ -182,7 +178,7 @@ class AtmosphericRoutines:
182
178
  dry-adiabatic to LCL, then a simplified moist-adiabatic adjustment.
183
179
  - Estimate environmental temperature at 500 hPa using a standard lapse proxy.
184
180
 
185
- Output is clamped to [-7, +7] like your original.
181
+ Output is clamped to [-7, +7].
186
182
  """
187
183
  values = {
188
184
  "temperature": temperature,
@@ -195,7 +191,7 @@ class AtmosphericRoutines:
195
191
  _LOGGER.warning(f"calculate_lifted_index: None/NaN inputs: {', '.join(missing)}")
196
192
  return None
197
193
 
198
- T = float(temperature) # °C
194
+ T = float(temperature) # °C
199
195
  Td = float(dew_point_temperature)
200
196
  alt = float(altitude)
201
197
  p0 = float(air_pressure_at_sea_level) # hPa
@@ -237,14 +233,15 @@ class AtmosphericRoutines:
237
233
  # 500 hPa height is typically ~5.5 km; use (5.5km - altitude) thickness.
238
234
  z500 = 5500.0
239
235
  dz = max(0.0, z500 - alt) # meters
240
- env_lapse = 6.5 / 1000.0 # K/m (standard-ish)
236
+ env_lapse = 6.5 / 1000.0 # K/m (standard-ish)
241
237
  T_env_500 = (T + 273.15) - env_lapse * dz
242
238
 
243
239
  # LI = T_env(500) - T_parcel(500), in °C
244
- LI = (T_env_500 - T_parcel_500)
240
+ LI = T_env_500 - T_parcel_500
245
241
 
246
242
  # Clamp like your current implementation
247
243
  LI = max(-7.0, min(7.0, float(LI)))
244
+
248
245
  return LI
249
246
 
250
247
  # #####################################################
@@ -330,33 +327,26 @@ class AtmosphericRoutines:
330
327
  # Convert transparency to magnitude degradation
331
328
  magnitude_degradation = self._transparency_to_magnitude_degradation(transparency)
332
329
 
333
- # _LOGGER.debug(
334
- # "Magnitude Degradation: {:.2f} mag (".format(magnitude_degradation)
335
- # + "Lifted Index (LI): {:.2f} °C, ".format(lifted_index)
336
- # + "Seeing: {:.2f} arcsec, ".format(seeing)
337
- # + "Estimated Atmospheric Transparency: {:.2f})".format(transparency)
338
- # )
339
-
340
330
  return magnitude_degradation
341
331
 
342
332
  # _11
343
- def _airmass_kasten_young(self, zenith_deg):
344
- z = math.radians(zenith_deg)
345
- return 1.0 / (math.cos(z) + 0.50572 * (96.07995 - zenith_deg) ** (-1.6364))
333
+ # def _airmass_kasten_young(self, zenith_deg):
334
+ # z = math.radians(zenith_deg)
335
+ # return 1.0 / (math.cos(z) + 0.50572 * (96.07995 - zenith_deg) ** (-1.6364))
346
336
 
347
- def _extinction_components(self, pressure_hpa, rh, vis_km):
348
- # Rayleigh ~0.106 mag/airmass at sea level (V band), scale with pressure
349
- k_R = 0.106 * (pressure_hpa / 1013.25)
337
+ # def _extinction_components(self, pressure_hpa, rh, vis_km):
338
+ # # Rayleigh ~0.106 mag/airmass at sea level (V band), scale with pressure
339
+ # k_R = 0.106 * (pressure_hpa / 1013.25)
350
340
 
351
- # Aerosol from visibility: tau ≈ 3.912/Vis; convert to mag/airmass: k = 1.086*tau
352
- tau_a = 3.912 / max(1.0, vis_km)
353
- k_a = 1.086 * tau_a * 0.6 # 0.6 factor so "haze" vis isn’t overly punitive; tune
341
+ # # Aerosol from visibility: tau ≈ 3.912/Vis; convert to mag/airmass: k = 1.086*tau
342
+ # tau_a = 3.912 / max(1.0, vis_km)
343
+ # k_a = 1.086 * tau_a * 0.6 # 0.6 factor so "haze" vis isn’t overly punitive; tune
354
344
 
355
- # Ozone & water vapor: small constants unless you have columns
356
- k_O3 = 0.03
357
- k_H2O = 0.00 # set >0 in NIR or humid site with strong bands
345
+ # # Ozone & water vapor: small constants unless you have columns
346
+ # k_O3 = 0.03
347
+ # k_H2O = 0.00 # set >0 in NIR or humid site with strong bands
358
348
 
359
- return k_R, k_a, k_O3, k_H2O
349
+ # return k_R, k_a, k_O3, k_H2O
360
350
 
361
351
  @typechecked
362
352
  async def magnitude_degradation_11(
@@ -408,29 +398,30 @@ class AtmosphericRoutines:
408
398
  alt = max(0.0, float(altitude))
409
399
 
410
400
  # Base transparency from simple, bounded components
411
- # (weights are chosen for stable behavior; tune freely)
412
- hum_pen = self._sigmoid((rh - 75.0) / 10.0) # humidity haze risk
413
- cloud_pen = (cc / 100.0) ** 1.2 # clouds dominate quickly
414
- wind_pen = self._sigmoid((ws - 6.0) / 2.5) * 0.4 # blowing aerosols
401
+ # (weights are chosen for stable behavior)
402
+ hum_pen = self._sigmoid((rh - 75.0) / 10.0) # humidity haze risk
403
+ cloud_pen = (cc / 100.0) ** 1.2 # clouds dominate quickly
404
+ wind_pen = self._sigmoid((ws - 6.0) / 2.5) * 0.4 # blowing aerosols
415
405
  li_pen = self._sigmoid((-lifted_index - 1.0) / 2.0) * 0.35 # unstable air -> more haze/cloud risk
416
- seeing_pen = self._sigmoid((seeing - 2.0) / 0.8) * 0.25 # poor seeing correlates w/ bad transparency sometimes
406
+ seeing_pen = self._sigmoid((seeing - 2.0) / 0.8) * 0.25 # poor seeing correlates w/ bad transparency sometimes
417
407
 
418
408
  # altitude improves transparency a bit (less column)
419
409
  alt_gain = 1.0 - 0.12 * (1.0 - math.exp(-alt / 1800.0))
420
410
 
421
411
  # Combine into transparency 0..1
422
- penalty = 0.18*hum_pen + 0.50*cloud_pen + 0.12*wind_pen + 0.10*li_pen + 0.10*seeing_pen
412
+ penalty = 0.18 * hum_pen + 0.50 * cloud_pen + 0.12 * wind_pen + 0.10 * li_pen + 0.10 * seeing_pen
423
413
  transparency = max(0.02, min(1.0, (1.0 - penalty) * alt_gain))
424
414
 
425
415
  # Convert transparency to mag loss (extinction-like)
426
416
  mag_loss = -2.5 * math.log10(transparency)
427
417
 
428
- # Clamp to your global max
418
+ # Clamp to global max
429
419
  mag_loss = min(float(MAG_DEGRATION_MAX), float(mag_loss))
430
420
  if mag_loss < 0.0:
431
421
  mag_loss = 0.0
422
+
432
423
  return float(mag_loss)
433
-
424
+
434
425
  # #####################################################
435
426
  # Calculate atmospheric seeing
436
427
  #
@@ -508,56 +499,43 @@ class AtmosphericRoutines:
508
499
  seeing_factor = C * (water_vapor_pressure / 10) ** 0.25 * (wind_speed / 10) ** 0.75 * relative_pressure
509
500
  seeing = 0.98 / seeing_factor
510
501
 
511
- # _LOGGER.debug(
512
- # "Seeing: {:.2f} arcsec (".format(seeing)
513
- # + "Water Vapor Pressure: {:.2f} mbar, ".format(water_vapor_pressure)
514
- # + "Wind Speed: {:.2f} m/s, ".format(wind_speed)
515
- # + "Relative Pressure: {:.2f} mbar, ".format(relative_pressure)
516
- # + "Seeing Factor: {:.2f})".format(seeing_factor)
517
- # )
518
-
519
502
  if seeing > SEEING_MAX:
520
503
  seeing = SEEING_MAX # max out seeing
521
504
 
522
505
  return seeing
523
506
 
524
507
  # Seeing with Hufnagel–Valley 5/7 profile
525
- def _hv57_cn2(self, z, A=1.7e-14, v=20.0):
526
- term1 = 0.00594 * (v / 27.0) ** 2 * (1e-5 * z) ** 10 * math.exp(-z / 1000.0)
527
- term2 = 2.7e-16 * math.exp(-z / 1500.0)
528
- term3 = A * math.exp(-z / 100.0)
508
+ # def _hv57_cn2(self, z, A=1.7e-14, v=20.0):
509
+ # term1 = 0.00594 * (v / 27.0) ** 2 * (1e-5 * z) ** 10 * math.exp(-z / 1000.0)
510
+ # term2 = 2.7e-16 * math.exp(-z / 1500.0)
511
+ # term3 = A * math.exp(-z / 100.0)
529
512
 
530
- return term1 + term2 + term3
513
+ # return term1 + term2 + term3
531
514
 
532
- def _seeing_from_hv57(self, wavelength_m=5.5e-7, v=20.0, A=1.7e-14, zmax=20000.0):
533
- # integrate Cn^2 dz (simple Riemann sum)
534
- dz = 25.0
535
- z = 0.0
536
- integral = 0.0
515
+ # def _seeing_from_hv57(self, wavelength_m=5.5e-7, v=20.0, A=1.7e-14, zmax=20000.0):
516
+ # # integrate Cn^2 dz (simple Riemann sum)
517
+ # dz = 25.0
518
+ # z = 0.0
519
+ # integral = 0.0
537
520
 
538
- while z <= zmax:
539
- integral += self._hv57_cn2(z, A=A, v=v) * dz
540
- z += dz
541
- k = 2.0 * math.pi / wavelength_m
542
- r0 = (0.423 * k * k * integral) ** (-3.0 / 5.0)
543
- beta_rad = 0.98 * wavelength_m / r0
521
+ # while z <= zmax:
522
+ # integral += self._hv57_cn2(z, A=A, v=v) * dz
523
+ # z += dz
524
+ # k = 2.0 * math.pi / wavelength_m
525
+ # r0 = (0.423 * k * k * integral) ** (-3.0 / 5.0)
526
+ # beta_rad = 0.98 * wavelength_m / r0
544
527
 
545
- return beta_rad * (180.0 / math.pi) * 3600.0 # arcsec
528
+ # return beta_rad * (180.0 / math.pi) * 3600.0 # arcsec
546
529
 
547
530
  @typechecked
548
531
  async def calculate_seeing_11(
549
532
  self, temperature, humidity, dew_point_temperature, wind_speed, cloud_cover, altitude, air_pressure_at_sea_level
550
533
  ) -> None | float:
551
534
  """
552
- Returns a rough seeing estimate in arcseconds.
535
+ Seeing estimate in arcseconds (lower = better), tuned to behave more like
536
+ common forecast products (e.g., meteoblue) in terms of directionality.
553
537
 
554
- Improvements vs old version:
555
- - Avoids unit-mismatch water-vapor-pressure math.
556
- - Uses stable, bounded mapping driven by:
557
- * wind (mechanical turbulence),
558
- * dewpoint depression & RH (near-surface stability / saturation),
559
- * cloud cover (proxy for active layers),
560
- * altitude (usually helps boundary-layer seeing).
538
+ Still a heuristic: with only surface inputs you cannot model free-atmosphere seeing.
561
539
  """
562
540
  values = {
563
541
  "temperature": temperature,
@@ -580,32 +558,121 @@ class AtmosphericRoutines:
580
558
  cc = max(0.0, min(100.0, float(cloud_cover)))
581
559
  alt = max(0.0, float(altitude))
582
560
 
583
- # Boundary-layer proxies
584
- dT = max(-5.0, min(25.0, T - Td)) # dewpoint depression
585
- wind_term = math.log1p(ws) # grows slowly, stable
586
- cloud_term = (cc / 100.0) ** 0.7 # more sensitive at low-mid cloud
587
- humid_term = self._sigmoid((rh - 80.0) / 8.0) # ramps up beyond ~80%
588
-
589
- # Altitude often helps (thinner BL, less heat shimmer).
590
- # Don’t overdo it; this is a mild improvement curve.
591
- altitude_gain = 0.85 + 0.15 * math.exp(-alt / 1800.0) # ~1.0 at sea lvl -> ~0.85 at high alt
592
-
593
- # Base seeing floor and contributions (tunable constants)
594
- seeing = (
595
- 0.75
596
- + 0.55 * wind_term
597
- + 0.65 * cloud_term
598
- + 0.45 * humid_term
599
- + 0.35 * self._sigmoid((dT - 4.0) / 1.8) # very dry air often correlates with better seeing aloft, but BL can still shimmer; this keeps it moderate
600
- ) * altitude_gain
601
-
602
- # Clamp
603
- if seeing > SEEING_MAX:
604
- seeing = SEEING_MAX
605
- if seeing < 0.4:
606
- seeing = 0.4
561
+ # --- proxies ---
562
+ # Dewpoint depression: very small dT => near-saturation / stable layer; can be good or bad.
563
+ # We use it gently: extremes (very large dT) can correlate with strong radiative cooling + BL turbulence.
564
+ dT = max(0.0, min(25.0, T - Td))
565
+
566
+ # Wind: best seeing often with light breeze (mixes BL), worse with dead calm or strong wind
567
+ # U-shaped penalty centered near ~3 m/s.
568
+ wind_opt = 3.0
569
+ wind_sigma = 2.5
570
+ wind_pen = 1.0 - math.exp(-((ws - wind_opt) ** 2) / (2.0 * wind_sigma ** 2)) # 0 near optimum, ->1 away
571
+
572
+ # Humidity: very high RH often accompanies haze/fog layers and BL issues; moderate is fine.
573
+ humid_pen = self._sigmoid((rh - 85.0) / 7.0) # ramps above ~85%
574
+
575
+ # Clouds: weak proxy for turbulence aloft. Keep influence small.
576
+ cloud_pen = (cc / 100.0) ** 1.5
607
577
 
578
+ # Altitude: generally helps a bit.
579
+ alt_gain = 1.0 - 0.12 * (1.0 - math.exp(-alt / 1800.0)) # ~1.0 sea level -> ~0.88 high alt
580
+
581
+ # Very large dT (very dry) can mean strong surface cooling at night => local turbulence.
582
+ # Mild penalty that only kicks in past ~8°C depression.
583
+ dry_pen = self._sigmoid((dT - 8.0) / 2.5)
584
+
585
+ # --- combine into a "quality" score (higher = better) ---
586
+ # Start near 1.0, subtract penalties.
587
+ quality = 1.0
588
+ quality -= 0.35 * wind_pen
589
+ quality -= 0.25 * humid_pen
590
+ quality -= 0.10 * cloud_pen
591
+ quality -= 0.20 * dry_pen
592
+
593
+ # Apply altitude improvement
594
+ quality *= alt_gain
595
+
596
+ # Clamp quality to sane range
597
+ quality = max(0.05, min(0.98, quality))
598
+
599
+ # Map to seeing arcsec: better quality => smaller FWHM
600
+ # Choose a realistic range for forecasts (tunable):
601
+ best = 0.7 # arcsec
602
+ worst = 4.0 # arcsec
603
+ seeing = worst - (worst - best) * quality
604
+
605
+ # Clamp to your global max (if you have one)
606
+ seeing = max(0.4, min(float(SEEING_MAX), seeing))
607
+
608
+ # _LOGGER.debug(float(seeing))
608
609
  return float(seeing)
610
+
611
+ # """
612
+ # Returns a rough seeing estimate in arcseconds.
613
+
614
+ # Improvements vs old version:
615
+ # - Avoids unit-mismatch water-vapor-pressure math.
616
+ # - Uses stable, bounded mapping driven by:
617
+ # * wind (mechanical turbulence),
618
+ # * dewpoint depression & RH (near-surface stability / saturation),
619
+ # * cloud cover (proxy for active layers),
620
+ # * altitude (usually helps boundary-layer seeing).
621
+ # """
622
+ # values = {
623
+ # "temperature": temperature,
624
+ # "humidity": humidity,
625
+ # "dew_point_temperature": dew_point_temperature,
626
+ # "wind_speed": wind_speed,
627
+ # "cloud_cover": cloud_cover,
628
+ # "altitude": altitude,
629
+ # "air_pressure_at_sea_level": air_pressure_at_sea_level,
630
+ # }
631
+ # missing = self._is_missing(values)
632
+ # if missing:
633
+ # _LOGGER.warning(f"calculate_seeing: None/NaN inputs: {', '.join(missing)}")
634
+ # return None
635
+
636
+ # T = float(temperature)
637
+ # Td = float(dew_point_temperature)
638
+ # rh = max(0.0, min(100.0, float(humidity)))
639
+ # ws = max(0.0, float(wind_speed))
640
+ # cc = max(0.0, min(100.0, float(cloud_cover)))
641
+ # alt = max(0.0, float(altitude))
642
+
643
+ # # Boundary-layer proxies
644
+ # dT = max(-5.0, min(25.0, T - Td)) # dewpoint depression
645
+ # wind_term = math.log1p(ws) # grows slowly, stable
646
+ # cloud_term = (cc / 100.0) ** 0.7 # more sensitive at low-mid cloud
647
+ # humid_term = self._sigmoid((rh - 80.0) / 8.0) # ramps up beyond ~80%
648
+
649
+ # # Altitude often helps (thinner BL, less heat shimmer).
650
+ # # Don’t overdo it; this is a mild improvement curve.
651
+ # altitude_gain = 0.85 + 0.15 * math.exp(-alt / 1800.0) # ~1.0 at sea lvl -> ~0.85 at high alt
652
+
653
+ # # Base seeing floor and contributions (tunable constants)
654
+ # seeing = (
655
+ # (
656
+ # 0.75
657
+ # + 0.55 * wind_term
658
+ # + 0.65 * cloud_term
659
+ # + 0.45 * humid_term
660
+ # + 0.35
661
+ # * self._sigmoid(
662
+ # (dT - 4.0) / 1.8
663
+ # ) # very dry air often correlates with better seeing aloft, but BL can still shimmer; this keeps it moderate
664
+ # )
665
+ # * altitude_gain
666
+ # )
667
+
668
+ # # Clamp
669
+ # if seeing > SEEING_MAX:
670
+ # seeing = SEEING_MAX
671
+ # if seeing < 0.4:
672
+ # seeing = 0.4
673
+
674
+ # _LOGGER.debug(float(seeing))
675
+ # return float(seeing)
609
676
 
610
677
  # #####################################################
611
678
  # Calculate fog density at 2m
@@ -668,17 +735,17 @@ class AtmosphericRoutines:
668
735
  return float(adjusted_fog_density)
669
736
 
670
737
  # Visibility via Koschmieder
671
- def _visibility_koschmieder(self, rh, base_beta=0.02):
672
- """
673
- Crude RH→extinction: beta_ext = base_beta * f(RH).
674
- base_beta ~0.02 1/km is a hazy baseline; ramp up sharply near saturation.
675
- Returns visibility (km).
676
- """
677
- # Sigmoid that explodes as RH→100%
678
- f = 1.0 + 20.0 / (1.0 + math.exp(-(rh - 95.0) / 1.5)) # ~1 below 90–92%, jumps past 95%
679
- beta = base_beta * f # 1/km
680
-
681
- return 3.912 / beta # km
738
+ # def _visibility_koschmieder(self, rh, base_beta=0.02):
739
+ # """
740
+ # Crude RH→extinction: beta_ext = base_beta * f(RH).
741
+ # base_beta ~0.02 1/km is a hazy baseline; ramp up sharply near saturation.
742
+ # Returns visibility (km).
743
+ # """
744
+ # # Sigmoid that explodes as RH→100%
745
+ # f = 1.0 + 20.0 / (1.0 + math.exp(-(rh - 95.0) / 1.5)) # ~1 below 90–92%, jumps past 95%
746
+ # beta = base_beta * f # 1/km
747
+
748
+ # return 3.912 / beta # km
682
749
 
683
750
  @typechecked
684
751
  async def calculate_fog_density_11(self, temp2m, rh2m, dewpoint2m, wind_speed) -> float:
@@ -709,8 +776,8 @@ class AtmosphericRoutines:
709
776
  # - Fog becomes likely when RH is high AND dewpoint depression is small.
710
777
  # - Map into 0..1 smoothly.
711
778
  sat_score = (
712
- 2.2 * (rh - 92.0) / 8.0 # RH ~92% begins to matter strongly
713
- - 2.6 * (dT - 1.2) / 1.8 # dT <~ 1–2°C drives fog likelihood
779
+ 2.2 * (rh - 92.0) / 8.0 # RH ~92% begins to matter strongly
780
+ - 2.6 * (dT - 1.2) / 1.8 # dT <~ 1–2°C drives fog likelihood
714
781
  )
715
782
  sat = self._sigmoid(sat_score)
716
783
 
@@ -720,6 +787,7 @@ class AtmosphericRoutines:
720
787
 
721
788
  # Final, clipped
722
789
  fog = sat * wind_decay
790
+
723
791
  return float(max(0.0, min(1.0, fog)))
724
792
 
725
793
  # #####################################################
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyastroweatherio
3
- Version: 0.75.0.dev2
3
+ Version: 0.75.0.dev3
4
4
  Summary: Python Wrapper for OpenMeteo and Met.no REST API
5
5
  Home-page: https://github.com/mawinkler/pyastroweatherio
6
6
  Author: Markus Winkler
@@ -11,7 +11,7 @@ if os.path.isfile(requirement_path):
11
11
  setup(
12
12
  name="pyastroweatherio",
13
13
  packages=["pyastroweatherio"],
14
- version="0.75.0.dev2",
14
+ version="0.75.0.dev3",
15
15
  license="MIT",
16
16
  description="Python Wrapper for OpenMeteo and Met.no REST API",
17
17
  long_description=" ".join(