pyastroweatherio 0.76.0.dev4__tar.gz → 0.76.0.dev6__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.
- {pyastroweatherio-0.76.0.dev4 → pyastroweatherio-0.76.0.dev6}/PKG-INFO +1 -1
- {pyastroweatherio-0.76.0.dev4 → pyastroweatherio-0.76.0.dev6}/pyastroweatherio/client.py +53 -34
- {pyastroweatherio-0.76.0.dev4 → pyastroweatherio-0.76.0.dev6}/pyastroweatherio/const.py +8 -0
- {pyastroweatherio-0.76.0.dev4 → pyastroweatherio-0.76.0.dev6}/pyastroweatherio/dataclasses.py +4 -0
- {pyastroweatherio-0.76.0.dev4 → pyastroweatherio-0.76.0.dev6}/pyastroweatherio.egg-info/PKG-INFO +1 -1
- {pyastroweatherio-0.76.0.dev4 → pyastroweatherio-0.76.0.dev6}/setup.py +1 -1
- {pyastroweatherio-0.76.0.dev4 → pyastroweatherio-0.76.0.dev6}/LICENSE +0 -0
- {pyastroweatherio-0.76.0.dev4 → pyastroweatherio-0.76.0.dev6}/README.md +0 -0
- {pyastroweatherio-0.76.0.dev4 → pyastroweatherio-0.76.0.dev6}/pyastroweatherio/__init__.py +0 -0
- {pyastroweatherio-0.76.0.dev4 → pyastroweatherio-0.76.0.dev6}/pyastroweatherio/errors.py +0 -0
- {pyastroweatherio-0.76.0.dev4 → pyastroweatherio-0.76.0.dev6}/pyastroweatherio/helper_functions.py +0 -0
- {pyastroweatherio-0.76.0.dev4 → pyastroweatherio-0.76.0.dev6}/pyastroweatherio.egg-info/SOURCES.txt +0 -0
- {pyastroweatherio-0.76.0.dev4 → pyastroweatherio-0.76.0.dev6}/pyastroweatherio.egg-info/dependency_links.txt +0 -0
- {pyastroweatherio-0.76.0.dev4 → pyastroweatherio-0.76.0.dev6}/pyastroweatherio.egg-info/requires.txt +0 -0
- {pyastroweatherio-0.76.0.dev4 → pyastroweatherio-0.76.0.dev6}/pyastroweatherio.egg-info/top_level.txt +0 -0
- {pyastroweatherio-0.76.0.dev4 → pyastroweatherio-0.76.0.dev6}/setup.cfg +0 -0
- {pyastroweatherio-0.76.0.dev4 → pyastroweatherio-0.76.0.dev6}/tests/test_calculations.py +0 -0
- {pyastroweatherio-0.76.0.dev4 → pyastroweatherio-0.76.0.dev6}/tests/test_client.py +0 -0
|
@@ -40,8 +40,11 @@ from pyastroweatherio.const import (
|
|
|
40
40
|
DEFAULT_TIMEZONE,
|
|
41
41
|
FORECAST_TYPE_HOURLY,
|
|
42
42
|
HEADERS,
|
|
43
|
+
DEW_PENALTY_MAX,
|
|
44
|
+
DEW_SPREAD_THRESHOLD,
|
|
43
45
|
MAG_DEGRATION_MAX,
|
|
44
|
-
|
|
46
|
+
MOON_PENALTY_WEIGHT,
|
|
47
|
+
PRECIP_VETO_THRESHOLD,
|
|
45
48
|
SEEING_MAX,
|
|
46
49
|
WIND10M_MAX,
|
|
47
50
|
)
|
|
@@ -488,6 +491,9 @@ class AstroWeather:
|
|
|
488
491
|
transparency=transparency,
|
|
489
492
|
wind_speed=wind_speed,
|
|
490
493
|
precipitation_amount=precipitation_amount,
|
|
494
|
+
moon_illuminance=moon_illuminance,
|
|
495
|
+
temp2m=temp2m,
|
|
496
|
+
dewpoint2m=dewpoint2m,
|
|
491
497
|
),
|
|
492
498
|
"rh2m": rh2m,
|
|
493
499
|
"wind_speed": wind_speed,
|
|
@@ -523,8 +529,16 @@ class AstroWeather:
|
|
|
523
529
|
transparency,
|
|
524
530
|
wind_speed,
|
|
525
531
|
precipitation_amount,
|
|
532
|
+
moon_illuminance,
|
|
533
|
+
temp2m,
|
|
534
|
+
dewpoint2m,
|
|
526
535
|
) -> int:
|
|
527
|
-
"""Return condition based on cloud cover, fog, seeing, transparency,
|
|
536
|
+
"""Return condition [0..100] based on cloud cover, fog, seeing, transparency,
|
|
537
|
+
wind, precipitation, moon illuminance, and dew risk."""
|
|
538
|
+
|
|
539
|
+
# Hard veto: any measurable precipitation makes observing impossible.
|
|
540
|
+
if precipitation_amount >= PRECIP_VETO_THRESHOLD:
|
|
541
|
+
return 0
|
|
528
542
|
|
|
529
543
|
# Guard against NaN from failed atmospheric calculations.
|
|
530
544
|
# Seeing and transparency use worst-case so a data gap never produces an
|
|
@@ -538,26 +552,18 @@ class AstroWeather:
|
|
|
538
552
|
if math.isnan(fog2m):
|
|
539
553
|
fog2m = 0.0
|
|
540
554
|
|
|
541
|
-
#
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
if wind_speed > WIND10M_MAX:
|
|
547
|
-
wind_speed = WIND10M_MAX
|
|
548
|
-
wind_speed_value = int(wind_speed * (100 / WIND10M_MAX)) # m/s up to 16.5
|
|
555
|
+
# Non-linear normalisation to [0..100], higher = worse.
|
|
556
|
+
# Power > 1 means excellent values barely penalise; poor values dominate.
|
|
557
|
+
seeing_norm = (seeing / SEEING_MAX) ** 2 * 100
|
|
558
|
+
transparency_norm = (transparency / MAG_DEGRATION_MAX) ** 1.5 * 100
|
|
559
|
+
wind_score = min(wind_speed / WIND10M_MAX, 1.0) * 100
|
|
549
560
|
|
|
550
561
|
# Combined opacity of independent cloud layers: 1 - product of transmittances.
|
|
551
|
-
# Weakening factors (0–1) reduce each layer's effective blocking fraction.
|
|
552
562
|
ch = cloudcover_high * self._cloudcover_high_weakening / 100
|
|
553
563
|
cm = cloudcover_medium * self._cloudcover_medium_weakening / 100
|
|
554
564
|
cl = cloudcover_low * self._cloudcover_low_weakening / 100
|
|
555
565
|
combined_cloudcover = (1 - (1 - ch) * (1 - cm) * (1 - cl)) * 100
|
|
556
566
|
|
|
557
|
-
# Precipitation penalty: capped at PRECIP_MAX (1 mm/h = fully bad) so
|
|
558
|
-
# heavy rain cannot push the score below 0 before the final clamp.
|
|
559
|
-
precip_penalty = min(precipitation_amount / PRECIP_MAX, 1.0) * 100
|
|
560
|
-
|
|
561
567
|
total_weight = (
|
|
562
568
|
self._cloudcover_weight
|
|
563
569
|
+ self._fog_weight
|
|
@@ -569,27 +575,37 @@ class AstroWeather:
|
|
|
569
575
|
_LOGGER.warning("All condition weights are zero; returning 0")
|
|
570
576
|
return 0
|
|
571
577
|
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
578
|
+
fog_eff = max(fog, fog2m)
|
|
579
|
+
|
|
580
|
+
# Weighted sum of bad factors.
|
|
581
|
+
weighted_bad = (
|
|
582
|
+
self._cloudcover_weight * combined_cloudcover
|
|
583
|
+
+ self._fog_weight * fog_eff
|
|
584
|
+
+ self._seeing_weight * seeing_norm
|
|
585
|
+
+ self._transparency_weight * transparency_norm
|
|
586
|
+
+ self._calm_weight * wind_score
|
|
587
|
+
) / total_weight
|
|
588
|
+
|
|
589
|
+
# Multiplicative cloud/fog ceiling: even a perfect weighted score cannot
|
|
590
|
+
# exceed what the sky clearness physically allows.
|
|
591
|
+
cloud_clearness = 1.0 - combined_cloudcover / 100
|
|
592
|
+
fog_clearness = 1.0 - fog_eff / 100
|
|
593
|
+
max_possible = cloud_clearness * fog_clearness * 100
|
|
594
|
+
|
|
595
|
+
# Moon penalty: illuminance proxy (phase_fraction × sin(altitude)) scaled
|
|
596
|
+
# to MOON_PENALTY_WEIGHT at full moon directly overhead.
|
|
597
|
+
moon_penalty = moon_illuminance * MOON_PENALTY_WEIGHT
|
|
598
|
+
|
|
599
|
+
# Dew risk penalty: spread below DEW_SPREAD_THRESHOLD signals condensation risk.
|
|
600
|
+
dew_spread = temp2m - dewpoint2m
|
|
601
|
+
if dew_spread < DEW_SPREAD_THRESHOLD:
|
|
602
|
+
dew_penalty = (1.0 - max(dew_spread, 0.0) / DEW_SPREAD_THRESHOLD) * DEW_PENALTY_MAX
|
|
603
|
+
else:
|
|
604
|
+
dew_penalty = 0.0
|
|
588
605
|
|
|
589
|
-
|
|
590
|
-
condition = max(0, min(100, condition))
|
|
606
|
+
condition = min(max_possible, 100.0 - weighted_bad) - moon_penalty - dew_penalty
|
|
591
607
|
|
|
592
|
-
return int(condition)
|
|
608
|
+
return max(0, min(100, int(condition)))
|
|
593
609
|
|
|
594
610
|
@typechecked
|
|
595
611
|
def _test_data(self, data, keys) -> bool:
|
|
@@ -843,6 +859,9 @@ class AstroWeather:
|
|
|
843
859
|
transparency=details_forecast.transparency,
|
|
844
860
|
wind_speed=details_forecast.wind10m_speed,
|
|
845
861
|
precipitation_amount=details_forecast.precipitation_amount,
|
|
862
|
+
moon_illuminance=details_forecast.moon_illuminance,
|
|
863
|
+
temp2m=details_forecast.temp2m,
|
|
864
|
+
dewpoint2m=details_forecast.dewpoint2m,
|
|
846
865
|
)
|
|
847
866
|
)
|
|
848
867
|
|
|
@@ -161,8 +161,16 @@ WIND10M_PLAIN = [
|
|
|
161
161
|
]
|
|
162
162
|
WIND10M_MAX = 16.5
|
|
163
163
|
PRECIP_MAX = 1.0 # mm/h at which precipitation fully degrades condition
|
|
164
|
+
PRECIP_VETO_THRESHOLD = 0.1 # mm/h: any measurable precipitation immediately vetoes observing
|
|
164
165
|
AOD_TO_MAG_FACTOR = 1.086 # Bouguer-Lambert: mag extinction ≈ AOD × 1.086 at zenith
|
|
165
166
|
|
|
167
|
+
# #####################################################
|
|
168
|
+
# Condition scoring penalties
|
|
169
|
+
# #####################################################
|
|
170
|
+
MOON_PENALTY_WEIGHT = 40 # max % points deducted for full moon at zenith (illuminance=1.0)
|
|
171
|
+
DEW_SPREAD_THRESHOLD = 3.0 # °C: dew/condensation risk begins below this temp–dewpoint spread
|
|
172
|
+
DEW_PENALTY_MAX = 15 # max % points deducted at zero spread (dew point = air temperature)
|
|
173
|
+
|
|
166
174
|
# #####################################################
|
|
167
175
|
# Condition
|
|
168
176
|
# #####################################################
|
{pyastroweatherio-0.76.0.dev4 → pyastroweatherio-0.76.0.dev6}/pyastroweatherio/dataclasses.py
RENAMED
|
@@ -1115,6 +1115,10 @@ class ForecastData:
|
|
|
1115
1115
|
def precipitation_amount6(self) -> float:
|
|
1116
1116
|
return self.condition_data.precipitation_amount6
|
|
1117
1117
|
|
|
1118
|
+
@property
|
|
1119
|
+
def moon_illuminance(self) -> float:
|
|
1120
|
+
return self.condition_data.moon_illuminance
|
|
1121
|
+
|
|
1118
1122
|
|
|
1119
1123
|
class NightlyConditionsDataModel(TypedDict):
|
|
1120
1124
|
"""Model for nightly conditions data"""
|
|
@@ -11,7 +11,7 @@ if os.path.isfile(requirement_path):
|
|
|
11
11
|
setup(
|
|
12
12
|
name="pyastroweatherio",
|
|
13
13
|
packages=["pyastroweatherio"],
|
|
14
|
-
version="0.76.0.
|
|
14
|
+
version="0.76.0.dev6",
|
|
15
15
|
license="MIT",
|
|
16
16
|
description="Python Wrapper for OpenMeteo and Met.no REST API",
|
|
17
17
|
long_description=" ".join(
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pyastroweatherio-0.76.0.dev4 → pyastroweatherio-0.76.0.dev6}/pyastroweatherio/helper_functions.py
RENAMED
|
File without changes
|
{pyastroweatherio-0.76.0.dev4 → pyastroweatherio-0.76.0.dev6}/pyastroweatherio.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{pyastroweatherio-0.76.0.dev4 → pyastroweatherio-0.76.0.dev6}/pyastroweatherio.egg-info/requires.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|