pyastroweatherio 0.76.0.dev3__tar.gz → 0.76.0.dev5__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.dev3 → pyastroweatherio-0.76.0.dev5}/PKG-INFO +1 -1
- {pyastroweatherio-0.76.0.dev3 → pyastroweatherio-0.76.0.dev5}/pyastroweatherio/client.py +121 -127
- {pyastroweatherio-0.76.0.dev3 → pyastroweatherio-0.76.0.dev5}/pyastroweatherio/const.py +20 -12
- {pyastroweatherio-0.76.0.dev3 → pyastroweatherio-0.76.0.dev5}/pyastroweatherio/helper_functions.py +1 -269
- {pyastroweatherio-0.76.0.dev3 → pyastroweatherio-0.76.0.dev5}/pyastroweatherio.egg-info/PKG-INFO +1 -1
- {pyastroweatherio-0.76.0.dev3 → pyastroweatherio-0.76.0.dev5}/setup.py +1 -1
- {pyastroweatherio-0.76.0.dev3 → pyastroweatherio-0.76.0.dev5}/tests/test_calculations.py +14 -108
- {pyastroweatherio-0.76.0.dev3 → pyastroweatherio-0.76.0.dev5}/LICENSE +0 -0
- {pyastroweatherio-0.76.0.dev3 → pyastroweatherio-0.76.0.dev5}/README.md +0 -0
- {pyastroweatherio-0.76.0.dev3 → pyastroweatherio-0.76.0.dev5}/pyastroweatherio/__init__.py +0 -0
- {pyastroweatherio-0.76.0.dev3 → pyastroweatherio-0.76.0.dev5}/pyastroweatherio/dataclasses.py +0 -0
- {pyastroweatherio-0.76.0.dev3 → pyastroweatherio-0.76.0.dev5}/pyastroweatherio/errors.py +0 -0
- {pyastroweatherio-0.76.0.dev3 → pyastroweatherio-0.76.0.dev5}/pyastroweatherio.egg-info/SOURCES.txt +0 -0
- {pyastroweatherio-0.76.0.dev3 → pyastroweatherio-0.76.0.dev5}/pyastroweatherio.egg-info/dependency_links.txt +0 -0
- {pyastroweatherio-0.76.0.dev3 → pyastroweatherio-0.76.0.dev5}/pyastroweatherio.egg-info/requires.txt +0 -0
- {pyastroweatherio-0.76.0.dev3 → pyastroweatherio-0.76.0.dev5}/pyastroweatherio.egg-info/top_level.txt +0 -0
- {pyastroweatherio-0.76.0.dev3 → pyastroweatherio-0.76.0.dev5}/setup.cfg +0 -0
- {pyastroweatherio-0.76.0.dev3 → pyastroweatherio-0.76.0.dev5}/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
|
)
|
|
@@ -152,7 +155,7 @@ class AstroWeather:
|
|
|
152
155
|
|
|
153
156
|
if self._experimental_features:
|
|
154
157
|
_LOGGER.debug(
|
|
155
|
-
"
|
|
158
|
+
"experimental_features is set but no longer has any effect — improved calculations are now always active"
|
|
156
159
|
)
|
|
157
160
|
|
|
158
161
|
# Testing
|
|
@@ -198,76 +201,48 @@ class AstroWeather:
|
|
|
198
201
|
return [r if not isinstance(r, BaseException) else (_LOGGER.warning("Dew point calculation failed: %s", r) or float("nan")) for r in results]
|
|
199
202
|
|
|
200
203
|
async def _calculate_seeing(self, df):
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
]
|
|
216
|
-
else:
|
|
217
|
-
tasks = [
|
|
218
|
-
self._atmosphere.calculate_seeing(
|
|
219
|
-
temperature=row["air_temperature"],
|
|
220
|
-
humidity=row["relative_humidity"],
|
|
221
|
-
dew_point_temperature=row["dew_point_temperature"],
|
|
222
|
-
wind_speed=row["wind_speed"],
|
|
223
|
-
cloud_cover=row["cloud_area_fraction"],
|
|
224
|
-
altitude=self._location_data.elevation,
|
|
225
|
-
air_pressure_at_sea_level=row["air_pressure_at_sea_level"],
|
|
226
|
-
)
|
|
227
|
-
for _, row in df.iterrows()
|
|
228
|
-
]
|
|
204
|
+
has_pbl = "gfs_boundary_layer_height" in df.columns
|
|
205
|
+
tasks = [
|
|
206
|
+
self._atmosphere.calculate_seeing(
|
|
207
|
+
temperature=row["air_temperature"],
|
|
208
|
+
humidity=row["relative_humidity"],
|
|
209
|
+
dew_point_temperature=row["dew_point_temperature"],
|
|
210
|
+
wind_speed=row["wind_speed"],
|
|
211
|
+
cloud_cover=row["cloud_area_fraction"],
|
|
212
|
+
altitude=self._location_data.elevation,
|
|
213
|
+
air_pressure_at_sea_level=row["air_pressure_at_sea_level"],
|
|
214
|
+
boundary_layer_height=row["gfs_boundary_layer_height"] if has_pbl else None,
|
|
215
|
+
)
|
|
216
|
+
for _, row in df.iterrows()
|
|
217
|
+
]
|
|
229
218
|
results = await asyncio.gather(*tasks, return_exceptions=True)
|
|
230
219
|
return [r if not isinstance(r, BaseException) else (_LOGGER.warning("Seeing calculation failed: %s", r) or float("nan")) for r in results]
|
|
231
220
|
|
|
232
221
|
async def _calculate_transparency(self, df):
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
]
|
|
246
|
-
else:
|
|
247
|
-
tasks = [
|
|
248
|
-
self._atmosphere.magnitude_degradation(
|
|
249
|
-
temperature=row["air_temperature"],
|
|
250
|
-
humidity=row["relative_humidity"],
|
|
251
|
-
dew_point_temperature=row["dew_point_temperature"],
|
|
252
|
-
wind_speed=row["wind_speed"],
|
|
253
|
-
cloud_cover=row["cloud_area_fraction"],
|
|
254
|
-
altitude=self._location_data.elevation,
|
|
255
|
-
air_pressure_at_sea_level=row["air_pressure_at_sea_level"],
|
|
256
|
-
)
|
|
257
|
-
for _, row in df.iterrows()
|
|
258
|
-
]
|
|
222
|
+
tasks = [
|
|
223
|
+
self._atmosphere.magnitude_degradation(
|
|
224
|
+
temperature=row["air_temperature"],
|
|
225
|
+
humidity=row["relative_humidity"],
|
|
226
|
+
dew_point_temperature=row["dew_point_temperature"],
|
|
227
|
+
wind_speed=row["wind_speed"],
|
|
228
|
+
cloud_cover=row["cloud_area_fraction"],
|
|
229
|
+
altitude=self._location_data.elevation,
|
|
230
|
+
air_pressure_at_sea_level=row["air_pressure_at_sea_level"],
|
|
231
|
+
)
|
|
232
|
+
for _, row in df.iterrows()
|
|
233
|
+
]
|
|
259
234
|
results = await asyncio.gather(*tasks, return_exceptions=True)
|
|
260
235
|
return [r if not isinstance(r, BaseException) else (_LOGGER.warning("Transparency calculation failed: %s", r) or float("nan")) for r in results]
|
|
261
236
|
|
|
262
237
|
async def _calculate_lifted_index(self, df):
|
|
263
|
-
|
|
264
|
-
|
|
238
|
+
# Prefer GFS NWP output; Bolton _11 approximation fills any missing slots.
|
|
239
|
+
if "gfs_lifted_index" in df.columns:
|
|
265
240
|
results = []
|
|
266
241
|
fallback_idx = [i for i, (_, row) in enumerate(df.iterrows()) if pd.isna(row["gfs_lifted_index"])]
|
|
267
242
|
if fallback_idx:
|
|
268
243
|
fallback_rows = df.iloc[fallback_idx]
|
|
269
244
|
fallback_tasks = [
|
|
270
|
-
self._atmosphere.
|
|
245
|
+
self._atmosphere.calculate_lifted_index(
|
|
271
246
|
temperature=row["air_temperature"],
|
|
272
247
|
dew_point_temperature=row["dew_point_temperature"],
|
|
273
248
|
altitude=self._location_data.elevation,
|
|
@@ -286,26 +261,15 @@ class AstroWeather:
|
|
|
286
261
|
r = fallback_map.get(i)
|
|
287
262
|
results.append(r if not isinstance(r, BaseException) else float("nan"))
|
|
288
263
|
return results
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
]
|
|
299
|
-
else:
|
|
300
|
-
tasks = [
|
|
301
|
-
self._atmosphere.calculate_lifted_index(
|
|
302
|
-
temperature=row["air_temperature"],
|
|
303
|
-
dew_point_temperature=row["dew_point_temperature"],
|
|
304
|
-
altitude=self._location_data.elevation,
|
|
305
|
-
air_pressure_at_sea_level=row["air_pressure_at_sea_level"],
|
|
306
|
-
)
|
|
307
|
-
for _, row in df.iterrows()
|
|
308
|
-
]
|
|
264
|
+
tasks = [
|
|
265
|
+
self._atmosphere.calculate_lifted_index(
|
|
266
|
+
temperature=row["air_temperature"],
|
|
267
|
+
dew_point_temperature=row["dew_point_temperature"],
|
|
268
|
+
altitude=self._location_data.elevation,
|
|
269
|
+
air_pressure_at_sea_level=row["air_pressure_at_sea_level"],
|
|
270
|
+
)
|
|
271
|
+
for _, row in df.iterrows()
|
|
272
|
+
]
|
|
309
273
|
results = await asyncio.gather(*tasks, return_exceptions=True)
|
|
310
274
|
return [r if not isinstance(r, BaseException) else (_LOGGER.warning("Lifted index calculation failed: %s", r) or float("nan")) for r in results]
|
|
311
275
|
|
|
@@ -491,15 +455,12 @@ class AstroWeather:
|
|
|
491
455
|
transparency = max(transparency, aod_mag)
|
|
492
456
|
aerosol_optical_depth = aod if not math.isnan(aod) else 0.0
|
|
493
457
|
|
|
494
|
-
# Calculate Fog Density
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
fog2m = max(0.0, min(100.0, (1.0 - gfs_vis / 10000.0) * 100.0))
|
|
501
|
-
else:
|
|
502
|
-
fog2m = await self._atmosphere.calculate_fog_density_11(temp2m, rh2m, dewpoint2m, wind_speed) * 100
|
|
458
|
+
# Calculate Fog Density: GFS visibility takes priority when available.
|
|
459
|
+
gfs_vis = row.get("gfs_visibility", float("nan"))
|
|
460
|
+
gfs_vis = float(gfs_vis) if gfs_vis is not None else float("nan")
|
|
461
|
+
if not math.isnan(gfs_vis):
|
|
462
|
+
# Map GFS visibility (m) to fog density [0, 1]: 0 m = dense fog, ≥10 km = clear
|
|
463
|
+
fog2m = max(0.0, min(100.0, (1.0 - gfs_vis / 10000.0) * 100.0))
|
|
503
464
|
else:
|
|
504
465
|
fog2m = await self._atmosphere.calculate_fog_density(temp2m, rh2m, dewpoint2m, wind_speed) * 100
|
|
505
466
|
|
|
@@ -530,6 +491,9 @@ class AstroWeather:
|
|
|
530
491
|
transparency=transparency,
|
|
531
492
|
wind_speed=wind_speed,
|
|
532
493
|
precipitation_amount=precipitation_amount,
|
|
494
|
+
moon_illuminance=moon_illuminance,
|
|
495
|
+
temp2m=temp2m,
|
|
496
|
+
dewpoint2m=dewpoint2m,
|
|
533
497
|
),
|
|
534
498
|
"rh2m": rh2m,
|
|
535
499
|
"wind_speed": wind_speed,
|
|
@@ -565,56 +529,83 @@ class AstroWeather:
|
|
|
565
529
|
transparency,
|
|
566
530
|
wind_speed,
|
|
567
531
|
precipitation_amount,
|
|
532
|
+
moon_illuminance,
|
|
533
|
+
temp2m,
|
|
534
|
+
dewpoint2m,
|
|
568
535
|
) -> int:
|
|
569
|
-
"""Return condition based on cloud cover, fog, seeing, transparency,
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
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
|
|
542
|
+
|
|
543
|
+
# Guard against NaN from failed atmospheric calculations.
|
|
544
|
+
# Seeing and transparency use worst-case so a data gap never produces an
|
|
545
|
+
# optimistic score; fog defaults to 0 (unknown ≠ foggy).
|
|
546
|
+
if math.isnan(seeing):
|
|
547
|
+
seeing = SEEING_MAX
|
|
548
|
+
if math.isnan(transparency):
|
|
549
|
+
transparency = MAG_DEGRATION_MAX
|
|
550
|
+
if math.isnan(fog):
|
|
551
|
+
fog = 0.0
|
|
552
|
+
if math.isnan(fog2m):
|
|
553
|
+
fog2m = 0.0
|
|
554
|
+
|
|
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
|
|
579
560
|
|
|
580
561
|
# Combined opacity of independent cloud layers: 1 - product of transmittances.
|
|
581
|
-
# Weakening factors (0–1) reduce each layer's effective blocking fraction.
|
|
582
562
|
ch = cloudcover_high * self._cloudcover_high_weakening / 100
|
|
583
563
|
cm = cloudcover_medium * self._cloudcover_medium_weakening / 100
|
|
584
564
|
cl = cloudcover_low * self._cloudcover_low_weakening / 100
|
|
585
565
|
combined_cloudcover = (1 - (1 - ch) * (1 - cm) * (1 - cl)) * 100
|
|
586
566
|
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
- (
|
|
594
|
-
self._cloudcover_weight * combined_cloudcover
|
|
595
|
-
+ self._fog_weight * max(fog, fog2m) # Use whatever is higher
|
|
596
|
-
+ self._seeing_weight * seeing
|
|
597
|
-
+ self._transparency_weight * transparency
|
|
598
|
-
+ self._calm_weight * wind_speed_value
|
|
599
|
-
)
|
|
600
|
-
/ (
|
|
601
|
-
self._cloudcover_weight
|
|
602
|
-
+ self._fog_weight
|
|
603
|
-
+ self._seeing_weight
|
|
604
|
-
+ self._transparency_weight
|
|
605
|
-
+ self._calm_weight
|
|
606
|
-
)
|
|
607
|
-
- precip_penalty
|
|
567
|
+
total_weight = (
|
|
568
|
+
self._cloudcover_weight
|
|
569
|
+
+ self._fog_weight
|
|
570
|
+
+ self._seeing_weight
|
|
571
|
+
+ self._transparency_weight
|
|
572
|
+
+ self._calm_weight
|
|
608
573
|
)
|
|
574
|
+
if total_weight == 0:
|
|
575
|
+
_LOGGER.warning("All condition weights are zero; returning 0")
|
|
576
|
+
return 0
|
|
577
|
+
|
|
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
|
|
609
605
|
|
|
610
|
-
|
|
611
|
-
# f"Cloudcover: {max(cloudcover)}, Fog: {fog}, Seeing: {seeing}, Transparency: {transparency}, Wind speed: {wind_speed_value}"
|
|
612
|
-
# )
|
|
613
|
-
|
|
614
|
-
# Ensure condition is within the valid range [0, 1]
|
|
615
|
-
condition = max(0, min(100, condition))
|
|
606
|
+
condition = min(max_possible, 100.0 - weighted_bad) - moon_penalty - dew_penalty
|
|
616
607
|
|
|
617
|
-
return int(condition)
|
|
608
|
+
return max(0, min(100, int(condition)))
|
|
618
609
|
|
|
619
610
|
@typechecked
|
|
620
611
|
def _test_data(self, data, keys) -> bool:
|
|
@@ -868,6 +859,9 @@ class AstroWeather:
|
|
|
868
859
|
transparency=details_forecast.transparency,
|
|
869
860
|
wind_speed=details_forecast.wind10m_speed,
|
|
870
861
|
precipitation_amount=details_forecast.precipitation_amount,
|
|
862
|
+
moon_illuminance=details_forecast.moon_illuminance,
|
|
863
|
+
temp2m=details_forecast.temp2m,
|
|
864
|
+
dewpoint2m=details_forecast.dewpoint2m,
|
|
871
865
|
)
|
|
872
866
|
)
|
|
873
867
|
|
|
@@ -46,18 +46,18 @@ ASTRONOMICAL_DUSK_DAWN = -18
|
|
|
46
46
|
# #####################################################
|
|
47
47
|
# Seeing
|
|
48
48
|
# #####################################################
|
|
49
|
-
SEEING = [0.
|
|
49
|
+
SEEING = [0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0]
|
|
50
50
|
# SEEING_PLAIN = [
|
|
51
51
|
# 'Below 0.5"',
|
|
52
|
-
# '0.5 to 0
|
|
53
|
-
# '0
|
|
54
|
-
# '1 to
|
|
55
|
-
# '
|
|
56
|
-
# '
|
|
57
|
-
# '
|
|
58
|
-
# 'Over
|
|
52
|
+
# '0.5 to 1.0"',
|
|
53
|
+
# '1.0 to 1.5"',
|
|
54
|
+
# '1.5 to 2.0"',
|
|
55
|
+
# '2.0 to 2.5"',
|
|
56
|
+
# '2.5 to 3.0"',
|
|
57
|
+
# '3.0 to 3.5"',
|
|
58
|
+
# 'Over 3.5"',
|
|
59
59
|
# ]
|
|
60
|
-
SEEING_MAX =
|
|
60
|
+
SEEING_MAX = 4.0
|
|
61
61
|
|
|
62
62
|
# #####################################################
|
|
63
63
|
# Transparency
|
|
@@ -161,15 +161,23 @@ 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
|
# #####################################################
|
|
169
177
|
DEFAULT_CONDITION_CLOUDCOVER_WEIGHT = 3
|
|
170
|
-
DEFAULT_CONDITION_CLOUDCOVER_HIGH_WEAKENING =
|
|
171
|
-
DEFAULT_CONDITION_CLOUDCOVER_MEDIUM_WEAKENING =
|
|
172
|
-
DEFAULT_CONDITION_CLOUDCOVER_LOW_WEAKENING = 1
|
|
178
|
+
DEFAULT_CONDITION_CLOUDCOVER_HIGH_WEAKENING = 0.40 # cirrus is largely transparent
|
|
179
|
+
DEFAULT_CONDITION_CLOUDCOVER_MEDIUM_WEAKENING = 0.70 # altocumulus is semi-opaque
|
|
180
|
+
DEFAULT_CONDITION_CLOUDCOVER_LOW_WEAKENING = 1.00 # stratus/fog blocks fully
|
|
173
181
|
DEFAULT_CONDITION_FOG_WEIGHT = 3
|
|
174
182
|
DEFAULT_CONDITION_SEEING_WEIGHT = 2
|
|
175
183
|
DEFAULT_CONDITION_TRANSPARENCY_WEIGHT = 1
|
{pyastroweatherio-0.76.0.dev3 → pyastroweatherio-0.76.0.dev5}/pyastroweatherio/helper_functions.py
RENAMED
|
@@ -116,56 +116,6 @@ class AtmosphericRoutines:
|
|
|
116
116
|
@typechecked
|
|
117
117
|
async def calculate_lifted_index(
|
|
118
118
|
self, temperature, altitude, dew_point_temperature, air_pressure_at_sea_level
|
|
119
|
-
) -> None | float:
|
|
120
|
-
"""Calculate atmospheric lifted index."""
|
|
121
|
-
# https://en.wikipedia.org/wiki/Lifted_index
|
|
122
|
-
|
|
123
|
-
values = {
|
|
124
|
-
"temperature": temperature,
|
|
125
|
-
"altitude": altitude,
|
|
126
|
-
"dew_point_temperature": dew_point_temperature,
|
|
127
|
-
"air_pressure_at_sea_level": air_pressure_at_sea_level,
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
missing = [name for name, val in values.items() if val is None or (isinstance(val, float) and math.isnan(val))]
|
|
131
|
-
|
|
132
|
-
if missing:
|
|
133
|
-
_LOGGER.warning(f"calculate_lifted_index: The following variables are None or NaN: {', '.join(missing)}")
|
|
134
|
-
return None
|
|
135
|
-
|
|
136
|
-
env_temp_500mb = -20.0 # °C, approximate environmental temperature at 500 hPa
|
|
137
|
-
|
|
138
|
-
# Calculate saturation vapor pressure at surface temperature
|
|
139
|
-
# Checked with https://www.weather.gov/epz/wxcalc_vaporpressure
|
|
140
|
-
# es = self._calculate_vapor_pressure(temperature)
|
|
141
|
-
|
|
142
|
-
# Calculate actual Vapor Pressure at surface
|
|
143
|
-
# Checked with https://www.weather.gov/epz/wxcalc_vaporpressure
|
|
144
|
-
e = self._calculate_vapor_pressure(dew_point_temperature)
|
|
145
|
-
|
|
146
|
-
# Calculate Mixing Ratio at Surface in grams per kilogram
|
|
147
|
-
# Checked with https://www.weather.gov/epz/wxcalc_mixingratio
|
|
148
|
-
w = self._calculate_mixing_ratio(e, air_pressure_at_sea_level)
|
|
149
|
-
|
|
150
|
-
# Calculate Lifting Condensation Level
|
|
151
|
-
lcl = self._calculate_lifting_condensation_level(w, air_pressure_at_sea_level)
|
|
152
|
-
|
|
153
|
-
# Calculate temperature of lifted parcel at 500 mb level
|
|
154
|
-
lifted_temp_500mb = (
|
|
155
|
-
env_temp_500mb + (temperature - lcl) * 0.5
|
|
156
|
-
) # Assumption: 500 mb is halfway through the troposphere
|
|
157
|
-
|
|
158
|
-
# Calculate Lifted Index
|
|
159
|
-
lifted_index = (env_temp_500mb - lifted_temp_500mb) * 2 + 7
|
|
160
|
-
|
|
161
|
-
# Ensure lifted index is within the valid range [-7, 7]
|
|
162
|
-
lifted_index = max(-7, min(7, lifted_index))
|
|
163
|
-
|
|
164
|
-
return lifted_index
|
|
165
|
-
|
|
166
|
-
@typechecked
|
|
167
|
-
async def calculate_lifted_index_11(
|
|
168
|
-
self, temperature, altitude, dew_point_temperature, air_pressure_at_sea_level
|
|
169
119
|
) -> None | float:
|
|
170
120
|
"""
|
|
171
121
|
Returns a rough Lifted Index (LI) proxy in °C, clamped to [-7, +7].
|
|
@@ -250,92 +200,10 @@ class AtmosphericRoutines:
|
|
|
250
200
|
return LI
|
|
251
201
|
|
|
252
202
|
# #####################################################
|
|
253
|
-
# Calculate
|
|
254
|
-
#
|
|
255
|
-
# Version _11:
|
|
256
|
-
# Extinction coefficient k (mag/airmass)
|
|
257
|
-
# Use pressure-scaled Rayleigh and an aerosol term
|
|
203
|
+
# Calculate magnitude degradation based on transparency
|
|
258
204
|
# #####################################################
|
|
259
205
|
@typechecked
|
|
260
206
|
async def magnitude_degradation(
|
|
261
|
-
self,
|
|
262
|
-
temperature,
|
|
263
|
-
humidity,
|
|
264
|
-
cloud_cover,
|
|
265
|
-
wind_speed,
|
|
266
|
-
altitude,
|
|
267
|
-
dew_point_temperature,
|
|
268
|
-
air_pressure_at_sea_level,
|
|
269
|
-
) -> None | float:
|
|
270
|
-
"""
|
|
271
|
-
Calculates the magnitude_degradation of the atmosphere.
|
|
272
|
-
This algorithm first calculates the lifted index and the seeing and uses them to calculate
|
|
273
|
-
the transparency from which the magnitude degradation is derived from.
|
|
274
|
-
|
|
275
|
-
Args:
|
|
276
|
-
- temperature: Surface temperature in Celsius.
|
|
277
|
-
- humidity: Humidity in Percent.
|
|
278
|
-
- dew_point_temperature: Dew point temperature in Celsius.
|
|
279
|
-
- wind_speed: Wind speed in meters per second.
|
|
280
|
-
- altitude: Altitude in meters.
|
|
281
|
-
- air_pressure_at_sea_level: Air pressure at sea level.
|
|
282
|
-
- cloud_cover: Cloud cover in Percent.
|
|
283
|
-
- lifted_index:
|
|
284
|
-
- seeing:
|
|
285
|
-
|
|
286
|
-
Returns:
|
|
287
|
-
- magnitude_degradation: In magnitude
|
|
288
|
-
"""
|
|
289
|
-
|
|
290
|
-
values = {
|
|
291
|
-
"temperature": temperature,
|
|
292
|
-
"humidity": humidity,
|
|
293
|
-
"cloud_cover": cloud_cover,
|
|
294
|
-
"wind_speed": wind_speed,
|
|
295
|
-
"altitude": altitude,
|
|
296
|
-
"dew_point_temperature": dew_point_temperature,
|
|
297
|
-
"air_pressure_at_sea_level": air_pressure_at_sea_level,
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
missing = [name for name, val in values.items() if val is None or (isinstance(val, float) and math.isnan(val))]
|
|
301
|
-
|
|
302
|
-
if missing:
|
|
303
|
-
_LOGGER.warning(f"magnitude_degradation: The following variables are None or NaN: {', '.join(missing)}")
|
|
304
|
-
return None
|
|
305
|
-
|
|
306
|
-
lifted_index = await self.calculate_lifted_index(
|
|
307
|
-
temperature, altitude, dew_point_temperature, air_pressure_at_sea_level
|
|
308
|
-
)
|
|
309
|
-
seeing = await self.calculate_seeing(
|
|
310
|
-
temperature,
|
|
311
|
-
humidity,
|
|
312
|
-
dew_point_temperature,
|
|
313
|
-
wind_speed,
|
|
314
|
-
cloud_cover,
|
|
315
|
-
altitude,
|
|
316
|
-
air_pressure_at_sea_level,
|
|
317
|
-
)
|
|
318
|
-
|
|
319
|
-
# Calculate transparency
|
|
320
|
-
transparency = self._calculate_transparency(
|
|
321
|
-
humidity,
|
|
322
|
-
temperature,
|
|
323
|
-
cloud_cover,
|
|
324
|
-
wind_speed,
|
|
325
|
-
altitude,
|
|
326
|
-
dew_point_temperature,
|
|
327
|
-
air_pressure_at_sea_level,
|
|
328
|
-
lifted_index,
|
|
329
|
-
seeing,
|
|
330
|
-
)
|
|
331
|
-
|
|
332
|
-
# Convert transparency to magnitude degradation
|
|
333
|
-
magnitude_degradation = self._transparency_to_magnitude_degradation(transparency)
|
|
334
|
-
|
|
335
|
-
return magnitude_degradation
|
|
336
|
-
|
|
337
|
-
@typechecked
|
|
338
|
-
async def magnitude_degradation_11(
|
|
339
207
|
self, temperature, humidity, cloud_cover, wind_speed, altitude, dew_point_temperature, air_pressure_at_sea_level
|
|
340
208
|
) -> None | float:
|
|
341
209
|
"""
|
|
@@ -433,88 +301,9 @@ class AtmosphericRoutines:
|
|
|
433
301
|
|
|
434
302
|
# #####################################################
|
|
435
303
|
# Calculate atmospheric seeing
|
|
436
|
-
#
|
|
437
|
-
# Version _11:
|
|
438
|
-
# A more physical way is to estimate optical turbulence C2,n(z)
|
|
439
|
-
# with the Hufnagel–Valley 5/7 profile, integrate to get r0,
|
|
440
|
-
# then ϵ≈0.98λ/r.
|
|
441
304
|
# #####################################################
|
|
442
305
|
@typechecked
|
|
443
306
|
async def calculate_seeing(
|
|
444
|
-
self,
|
|
445
|
-
temperature,
|
|
446
|
-
humidity,
|
|
447
|
-
dew_point_temperature,
|
|
448
|
-
wind_speed,
|
|
449
|
-
cloud_cover,
|
|
450
|
-
altitude,
|
|
451
|
-
air_pressure_at_sea_level,
|
|
452
|
-
) -> None | float:
|
|
453
|
-
"""
|
|
454
|
-
Calculated seeing of the atmosphere. This algorithm first calculates the seeing factor based on temperature,
|
|
455
|
-
humidity, wind speed and altitude above sea level. The seeing factor is then used to calculate the astronomical
|
|
456
|
-
seeing in arcseconds. The empirical relationship used here states that the seeing in arcseconds is approximately
|
|
457
|
-
equal to the reciprocal of the seeing factor multiplied by a conversion factor of 0.98.
|
|
458
|
-
|
|
459
|
-
Used by: magnitude degradation
|
|
460
|
-
|
|
461
|
-
Args:
|
|
462
|
-
- temperature: Surface temperature in Celsius.
|
|
463
|
-
- humidity: Humidity in Percent.
|
|
464
|
-
- dew_point_temperature: Dew point temperature in Celsius.
|
|
465
|
-
- wind_speed: Wind speed in meters per second.
|
|
466
|
-
- cloud_cover: Cloud cover in Percent.
|
|
467
|
-
- altitude: Altitude in meters.
|
|
468
|
-
- air_pressure_at_sea_level: Air pressure at sea level.
|
|
469
|
-
|
|
470
|
-
Returns:
|
|
471
|
-
- seeing: In arcsecs
|
|
472
|
-
|
|
473
|
-
Flow:
|
|
474
|
-
- _calculate_water_vapor_pressure
|
|
475
|
-
- adjusted_pressure
|
|
476
|
-
- relative_pressure
|
|
477
|
-
- seeing_factor
|
|
478
|
-
- seeing
|
|
479
|
-
"""
|
|
480
|
-
|
|
481
|
-
values = {
|
|
482
|
-
"temperature": temperature,
|
|
483
|
-
"humidity": humidity,
|
|
484
|
-
"dew_point_temperature": dew_point_temperature,
|
|
485
|
-
"wind_speed": wind_speed,
|
|
486
|
-
"cloud_cover": cloud_cover,
|
|
487
|
-
"altitude": altitude,
|
|
488
|
-
"air_pressure_at_sea_level": air_pressure_at_sea_level,
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
missing = [name for name, val in values.items() if val is None or (isinstance(val, float) and math.isnan(val))]
|
|
492
|
-
|
|
493
|
-
if missing:
|
|
494
|
-
_LOGGER.warning(f"calculate_seeing: The following variables are None or NaN: {', '.join(missing)}")
|
|
495
|
-
return None
|
|
496
|
-
|
|
497
|
-
# Constants
|
|
498
|
-
C = 6.5 # 1.7
|
|
499
|
-
|
|
500
|
-
water_vapor_pressure = self._calculate_water_vapor_pressure(dew_point_temperature, humidity)
|
|
501
|
-
|
|
502
|
-
# adjusted_pressure = air_pressure_at_sea_level * math.exp(-0.00012 * altitude)
|
|
503
|
-
adjusted_pressure = self._calculate_adjusted_pressure(air_pressure_at_sea_level, altitude)
|
|
504
|
-
relative_pressure = adjusted_pressure / air_pressure_at_sea_level
|
|
505
|
-
|
|
506
|
-
if wind_speed == 0:
|
|
507
|
-
wind_speed = 0.01
|
|
508
|
-
seeing_factor = C * (water_vapor_pressure / 10) ** 0.25 * (wind_speed / 10) ** 0.75 * relative_pressure
|
|
509
|
-
seeing = 0.98 / seeing_factor
|
|
510
|
-
|
|
511
|
-
if seeing > SEEING_MAX:
|
|
512
|
-
seeing = SEEING_MAX # max out seeing
|
|
513
|
-
|
|
514
|
-
return seeing
|
|
515
|
-
|
|
516
|
-
@typechecked
|
|
517
|
-
async def calculate_seeing_11(
|
|
518
307
|
self, temperature, humidity, dew_point_temperature, wind_speed, cloud_cover, altitude, air_pressure_at_sea_level,
|
|
519
308
|
boundary_layer_height=None,
|
|
520
309
|
) -> None | float:
|
|
@@ -650,66 +439,9 @@ class AtmosphericRoutines:
|
|
|
650
439
|
|
|
651
440
|
# #####################################################
|
|
652
441
|
# Calculate fog density at 2m
|
|
653
|
-
#
|
|
654
|
-
# Version _11:
|
|
655
|
-
# Tie to physics and aviation practice, estimate meteorological visibility
|
|
656
|
-
# V and then map it to a “fog density” in [0,1].
|
|
657
|
-
# anchor the metric to visibility vs extinction, a standard framework (Koschmieder).
|
|
658
|
-
# It’s still simple but behaves correctly near saturation and with wind
|
|
659
|
-
# Uses Koschmieder law: V = 3.912/betaext where betaext is the extinction coefficient
|
|
660
442
|
# #####################################################
|
|
661
443
|
@typechecked
|
|
662
444
|
async def calculate_fog_density(self, temp2m, rh2m, dewpoint2m, wind_speed) -> float:
|
|
663
|
-
"""
|
|
664
|
-
To calculate fog density, one can use a method based on the Liquid Water Content (LWC)
|
|
665
|
-
in fog, which depends on the difference between air temperature and dew point, relative
|
|
666
|
-
humidity, and wind speed. While there is no universally agreed-upon formula for fog
|
|
667
|
-
density, the implemented approximate method can provide a rough measure.
|
|
668
|
-
Note that actual fog density can be influenced by more complex microclimatic factors,
|
|
669
|
-
so this approach serves as a simplified approximation.
|
|
670
|
-
|
|
671
|
-
Args:
|
|
672
|
-
- temp2m: Surface temperature in Celsius.
|
|
673
|
-
- rh2m: Humidity in Percent.
|
|
674
|
-
- dewpoint2m: Dew point temperature in Celsius.
|
|
675
|
-
- wind_speed: Wind speed in meters per second.
|
|
676
|
-
|
|
677
|
-
Returns:
|
|
678
|
-
- adjusted_fog_density
|
|
679
|
-
"""
|
|
680
|
-
|
|
681
|
-
# Constants
|
|
682
|
-
# A normalizing constant chosen empirically to scale the fog density to a reasonable
|
|
683
|
-
# range. Adjust this based on the desired scale of output (e.g., 0.1 for very light
|
|
684
|
-
# fog, 1 for dense fog).
|
|
685
|
-
k = 0.50
|
|
686
|
-
|
|
687
|
-
# Controls how sensitive the density calculation is to the temperature-dew point
|
|
688
|
-
# difference. Smaller values of a make fog density increase faster as the temperature
|
|
689
|
-
# approaches the dew point.
|
|
690
|
-
a = 1.5
|
|
691
|
-
|
|
692
|
-
# Dampening constant for wind speed. This value ensures a gradual decay in fog density
|
|
693
|
-
# as wind speed increases, which reflects that moderate wind disperses fog.
|
|
694
|
-
b = 10
|
|
695
|
-
|
|
696
|
-
# Calculate initial fog density based on temperature and humidity
|
|
697
|
-
humidity_factor = rh2m / 100 # Relative humidity as a fraction
|
|
698
|
-
temp_dew_diff = temp2m - dewpoint2m
|
|
699
|
-
|
|
700
|
-
# Calculate fog density
|
|
701
|
-
fog_density = k * humidity_factor * math.exp(-temp_dew_diff / a)
|
|
702
|
-
|
|
703
|
-
# Adjust for wind speed
|
|
704
|
-
adjusted_fog_density = fog_density * math.exp(-wind_speed / b)
|
|
705
|
-
|
|
706
|
-
# Ensure fog density is within the valid range [0, 1]
|
|
707
|
-
adjusted_fog_density = max(0, min(1, adjusted_fog_density))
|
|
708
|
-
|
|
709
|
-
return float(adjusted_fog_density)
|
|
710
|
-
|
|
711
|
-
@typechecked
|
|
712
|
-
async def calculate_fog_density_11(self, temp2m, rh2m, dewpoint2m, wind_speed) -> float:
|
|
713
445
|
"""
|
|
714
446
|
Estimate fog likelihood as a dimensionless density in [0, 1].
|
|
715
447
|
|
|
@@ -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.dev5",
|
|
15
15
|
license="MIT",
|
|
16
16
|
description="Python Wrapper for OpenMeteo and Met.no REST API",
|
|
17
17
|
long_description=" ".join(
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"""Unit tests for atmospheric calculations in AtmosphericRoutines."""
|
|
2
2
|
|
|
3
3
|
import asyncio
|
|
4
|
-
import math
|
|
5
4
|
import unittest
|
|
6
5
|
|
|
7
6
|
from pyastroweatherio.helper_functions import AtmosphericRoutines
|
|
@@ -97,27 +96,6 @@ class TestAtmosphericCalculations(unittest.TestCase):
|
|
|
97
96
|
))
|
|
98
97
|
self.assertIsNone(result)
|
|
99
98
|
|
|
100
|
-
# ---------------------------------------------------------------
|
|
101
|
-
# calculate_lifted_index_11
|
|
102
|
-
# ---------------------------------------------------------------
|
|
103
|
-
def test_lifted_index_11_in_range(self):
|
|
104
|
-
c = self.clear
|
|
105
|
-
result = asyncio.run(self.atm.calculate_lifted_index_11(
|
|
106
|
-
temperature=c["temperature"], altitude=c["altitude"],
|
|
107
|
-
dew_point_temperature=c["dew_point_temperature"],
|
|
108
|
-
air_pressure_at_sea_level=c["air_pressure_at_sea_level"],
|
|
109
|
-
))
|
|
110
|
-
self.assertIsNotNone(result)
|
|
111
|
-
self.assertGreaterEqual(result, -7.0)
|
|
112
|
-
self.assertLessEqual(result, 7.0)
|
|
113
|
-
|
|
114
|
-
def test_lifted_index_11_returns_none_on_missing(self):
|
|
115
|
-
result = asyncio.run(self.atm.calculate_lifted_index_11(
|
|
116
|
-
temperature=None, altitude=500.0,
|
|
117
|
-
dew_point_temperature=5.0, air_pressure_at_sea_level=1013.25,
|
|
118
|
-
))
|
|
119
|
-
self.assertIsNone(result)
|
|
120
|
-
|
|
121
99
|
# ---------------------------------------------------------------
|
|
122
100
|
# calculate_seeing
|
|
123
101
|
# ---------------------------------------------------------------
|
|
@@ -131,40 +109,17 @@ class TestAtmosphericCalculations(unittest.TestCase):
|
|
|
131
109
|
))
|
|
132
110
|
self.assertIsNotNone(result)
|
|
133
111
|
self.assertGreater(result, 0.0)
|
|
134
|
-
self.assertLessEqual(result,
|
|
112
|
+
self.assertLessEqual(result, 4.0)
|
|
135
113
|
|
|
136
|
-
def
|
|
137
|
-
result = asyncio.run(self.atm.calculate_seeing(
|
|
138
|
-
temperature=None, humidity=50.0, dew_point_temperature=5.0,
|
|
139
|
-
wind_speed=2.0, cloud_cover=0.0, altitude=500.0,
|
|
140
|
-
air_pressure_at_sea_level=1013.25,
|
|
141
|
-
))
|
|
142
|
-
self.assertIsNone(result)
|
|
143
|
-
|
|
144
|
-
# ---------------------------------------------------------------
|
|
145
|
-
# calculate_seeing_11
|
|
146
|
-
# ---------------------------------------------------------------
|
|
147
|
-
def test_seeing_11_clear_in_range(self):
|
|
148
|
-
c = self.clear
|
|
149
|
-
result = asyncio.run(self.atm.calculate_seeing_11(
|
|
150
|
-
temperature=c["temperature"], humidity=c["humidity"],
|
|
151
|
-
dew_point_temperature=c["dew_point_temperature"],
|
|
152
|
-
wind_speed=c["wind_speed"], cloud_cover=c["cloud_cover"],
|
|
153
|
-
altitude=c["altitude"], air_pressure_at_sea_level=c["air_pressure_at_sea_level"],
|
|
154
|
-
))
|
|
155
|
-
self.assertIsNotNone(result)
|
|
156
|
-
self.assertGreater(result, 0.0)
|
|
157
|
-
self.assertLessEqual(result, 2.5)
|
|
158
|
-
|
|
159
|
-
def test_seeing_11_worse_overcast(self):
|
|
114
|
+
def test_seeing_worse_overcast(self):
|
|
160
115
|
c, o = self.clear, self.overcast
|
|
161
|
-
r_clear = asyncio.run(self.atm.
|
|
116
|
+
r_clear = asyncio.run(self.atm.calculate_seeing(
|
|
162
117
|
temperature=c["temperature"], humidity=c["humidity"],
|
|
163
118
|
dew_point_temperature=c["dew_point_temperature"],
|
|
164
119
|
wind_speed=c["wind_speed"], cloud_cover=c["cloud_cover"],
|
|
165
120
|
altitude=c["altitude"], air_pressure_at_sea_level=c["air_pressure_at_sea_level"],
|
|
166
121
|
))
|
|
167
|
-
r_overcast = asyncio.run(self.atm.
|
|
122
|
+
r_overcast = asyncio.run(self.atm.calculate_seeing(
|
|
168
123
|
temperature=o["temperature"], humidity=o["humidity"],
|
|
169
124
|
dew_point_temperature=o["dew_point_temperature"],
|
|
170
125
|
wind_speed=o["wind_speed"], cloud_cover=o["cloud_cover"],
|
|
@@ -173,8 +128,8 @@ class TestAtmosphericCalculations(unittest.TestCase):
|
|
|
173
128
|
# Larger arcsec value = worse seeing
|
|
174
129
|
self.assertGreater(r_overcast, r_clear)
|
|
175
130
|
|
|
176
|
-
def
|
|
177
|
-
result = asyncio.run(self.atm.
|
|
131
|
+
def test_seeing_returns_none_on_missing(self):
|
|
132
|
+
result = asyncio.run(self.atm.calculate_seeing(
|
|
178
133
|
temperature=None, humidity=50.0, dew_point_temperature=5.0,
|
|
179
134
|
wind_speed=2.0, cloud_cover=0.0, altitude=500.0,
|
|
180
135
|
air_pressure_at_sea_level=1013.25,
|
|
@@ -194,22 +149,9 @@ class TestAtmosphericCalculations(unittest.TestCase):
|
|
|
194
149
|
result = asyncio.run(self.atm.calculate_fog_density(10.0, 99.0, 9.8, 0.5))
|
|
195
150
|
self.assertGreater(result, 0.3)
|
|
196
151
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
def test_fog_density_11_clear_is_low(self):
|
|
201
|
-
result = asyncio.run(self.atm.calculate_fog_density_11(15.0, 50.0, 4.6, 2.0))
|
|
202
|
-
self.assertGreaterEqual(result, 0.0)
|
|
203
|
-
self.assertLessEqual(result, 1.0)
|
|
204
|
-
self.assertLess(result, 0.3)
|
|
205
|
-
|
|
206
|
-
def test_fog_density_11_saturated_is_high(self):
|
|
207
|
-
result = asyncio.run(self.atm.calculate_fog_density_11(10.0, 99.0, 9.8, 0.5))
|
|
208
|
-
self.assertGreater(result, 0.3)
|
|
209
|
-
|
|
210
|
-
def test_fog_density_11_wind_disperses_fog(self):
|
|
211
|
-
result_calm = asyncio.run(self.atm.calculate_fog_density_11(10.0, 99.0, 9.8, 0.0))
|
|
212
|
-
result_windy = asyncio.run(self.atm.calculate_fog_density_11(10.0, 99.0, 9.8, 15.0))
|
|
152
|
+
def test_fog_density_wind_disperses_fog(self):
|
|
153
|
+
result_calm = asyncio.run(self.atm.calculate_fog_density(10.0, 99.0, 9.8, 0.0))
|
|
154
|
+
result_windy = asyncio.run(self.atm.calculate_fog_density(10.0, 99.0, 9.8, 15.0))
|
|
213
155
|
self.assertGreater(result_calm, result_windy)
|
|
214
156
|
|
|
215
157
|
# ---------------------------------------------------------------
|
|
@@ -227,51 +169,15 @@ class TestAtmosphericCalculations(unittest.TestCase):
|
|
|
227
169
|
self.assertGreaterEqual(result, 0.0)
|
|
228
170
|
self.assertLessEqual(result, 1.0)
|
|
229
171
|
|
|
230
|
-
def
|
|
231
|
-
o = self.overcast
|
|
232
|
-
result = asyncio.run(self.atm.magnitude_degradation(
|
|
233
|
-
temperature=o["temperature"], humidity=o["humidity"],
|
|
234
|
-
cloud_cover=o["cloud_cover"], wind_speed=o["wind_speed"],
|
|
235
|
-
altitude=o["altitude"], dew_point_temperature=o["dew_point_temperature"],
|
|
236
|
-
air_pressure_at_sea_level=o["air_pressure_at_sea_level"],
|
|
237
|
-
))
|
|
238
|
-
self.assertIsNotNone(result)
|
|
239
|
-
self.assertGreaterEqual(result, 0.5)
|
|
240
|
-
|
|
241
|
-
def test_magnitude_degradation_returns_none_on_missing(self):
|
|
242
|
-
c = self.clear
|
|
243
|
-
result = asyncio.run(self.atm.magnitude_degradation(
|
|
244
|
-
temperature=None, humidity=c["humidity"],
|
|
245
|
-
cloud_cover=c["cloud_cover"], wind_speed=c["wind_speed"],
|
|
246
|
-
altitude=c["altitude"], dew_point_temperature=c["dew_point_temperature"],
|
|
247
|
-
air_pressure_at_sea_level=c["air_pressure_at_sea_level"],
|
|
248
|
-
))
|
|
249
|
-
self.assertIsNone(result)
|
|
250
|
-
|
|
251
|
-
# ---------------------------------------------------------------
|
|
252
|
-
# magnitude_degradation_11
|
|
253
|
-
# ---------------------------------------------------------------
|
|
254
|
-
def test_magnitude_degradation_11_clear_in_range(self):
|
|
255
|
-
c = self.clear
|
|
256
|
-
result = asyncio.run(self.atm.magnitude_degradation_11(
|
|
257
|
-
temperature=c["temperature"], humidity=c["humidity"],
|
|
258
|
-
cloud_cover=c["cloud_cover"], wind_speed=c["wind_speed"],
|
|
259
|
-
altitude=c["altitude"], dew_point_temperature=c["dew_point_temperature"],
|
|
260
|
-
air_pressure_at_sea_level=c["air_pressure_at_sea_level"],
|
|
261
|
-
))
|
|
262
|
-
self.assertIsNotNone(result)
|
|
263
|
-
self.assertGreaterEqual(result, 0.0)
|
|
264
|
-
self.assertLessEqual(result, 1.0)
|
|
265
|
-
|
|
266
|
-
def test_magnitude_degradation_11_worse_overcast(self):
|
|
172
|
+
def test_magnitude_degradation_worse_overcast(self):
|
|
267
173
|
c, o = self.clear, self.overcast
|
|
268
|
-
r_clear = asyncio.run(self.atm.
|
|
174
|
+
r_clear = asyncio.run(self.atm.magnitude_degradation(
|
|
269
175
|
temperature=c["temperature"], humidity=c["humidity"],
|
|
270
176
|
cloud_cover=c["cloud_cover"], wind_speed=c["wind_speed"],
|
|
271
177
|
altitude=c["altitude"], dew_point_temperature=c["dew_point_temperature"],
|
|
272
178
|
air_pressure_at_sea_level=c["air_pressure_at_sea_level"],
|
|
273
179
|
))
|
|
274
|
-
r_overcast = asyncio.run(self.atm.
|
|
180
|
+
r_overcast = asyncio.run(self.atm.magnitude_degradation(
|
|
275
181
|
temperature=o["temperature"], humidity=o["humidity"],
|
|
276
182
|
cloud_cover=o["cloud_cover"], wind_speed=o["wind_speed"],
|
|
277
183
|
altitude=o["altitude"], dew_point_temperature=o["dew_point_temperature"],
|
|
@@ -279,9 +185,9 @@ class TestAtmosphericCalculations(unittest.TestCase):
|
|
|
279
185
|
))
|
|
280
186
|
self.assertGreater(r_overcast, r_clear)
|
|
281
187
|
|
|
282
|
-
def
|
|
188
|
+
def test_magnitude_degradation_returns_none_on_missing(self):
|
|
283
189
|
c = self.clear
|
|
284
|
-
result = asyncio.run(self.atm.
|
|
190
|
+
result = asyncio.run(self.atm.magnitude_degradation(
|
|
285
191
|
temperature=None, humidity=c["humidity"],
|
|
286
192
|
cloud_cover=c["cloud_cover"], wind_speed=c["wind_speed"],
|
|
287
193
|
altitude=c["altitude"], dew_point_temperature=c["dew_point_temperature"],
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pyastroweatherio-0.76.0.dev3 → pyastroweatherio-0.76.0.dev5}/pyastroweatherio/dataclasses.py
RENAMED
|
File without changes
|
|
File without changes
|
{pyastroweatherio-0.76.0.dev3 → pyastroweatherio-0.76.0.dev5}/pyastroweatherio.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{pyastroweatherio-0.76.0.dev3 → pyastroweatherio-0.76.0.dev5}/pyastroweatherio.egg-info/requires.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|