pyastroweatherio 0.43.1.dev8__tar.gz → 0.43.1.dev9__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.43.1.dev8 → pyastroweatherio-0.43.1.dev9}/PKG-INFO +1 -1
- {pyastroweatherio-0.43.1.dev8 → pyastroweatherio-0.43.1.dev9}/pyastroweatherio/client.py +10 -7
- {pyastroweatherio-0.43.1.dev8 → pyastroweatherio-0.43.1.dev9}/pyastroweatherio/helper_functions.py +109 -0
- {pyastroweatherio-0.43.1.dev8 → pyastroweatherio-0.43.1.dev9}/pyastroweatherio.egg-info/PKG-INFO +1 -1
- {pyastroweatherio-0.43.1.dev8 → pyastroweatherio-0.43.1.dev9}/setup.py +1 -1
- {pyastroweatherio-0.43.1.dev8 → pyastroweatherio-0.43.1.dev9}/LICENSE +0 -0
- {pyastroweatherio-0.43.1.dev8 → pyastroweatherio-0.43.1.dev9}/README.md +0 -0
- {pyastroweatherio-0.43.1.dev8 → pyastroweatherio-0.43.1.dev9}/pyastroweatherio/__init__.py +0 -0
- {pyastroweatherio-0.43.1.dev8 → pyastroweatherio-0.43.1.dev9}/pyastroweatherio/const.py +0 -0
- {pyastroweatherio-0.43.1.dev8 → pyastroweatherio-0.43.1.dev9}/pyastroweatherio/dataclasses.py +0 -0
- {pyastroweatherio-0.43.1.dev8 → pyastroweatherio-0.43.1.dev9}/pyastroweatherio/errors.py +0 -0
- {pyastroweatherio-0.43.1.dev8 → pyastroweatherio-0.43.1.dev9}/pyastroweatherio.egg-info/SOURCES.txt +0 -0
- {pyastroweatherio-0.43.1.dev8 → pyastroweatherio-0.43.1.dev9}/pyastroweatherio.egg-info/dependency_links.txt +0 -0
- {pyastroweatherio-0.43.1.dev8 → pyastroweatherio-0.43.1.dev9}/pyastroweatherio.egg-info/requires.txt +0 -0
- {pyastroweatherio-0.43.1.dev8 → pyastroweatherio-0.43.1.dev9}/pyastroweatherio.egg-info/top_level.txt +0 -0
- {pyastroweatherio-0.43.1.dev8 → pyastroweatherio-0.43.1.dev9}/setup.cfg +0 -0
|
@@ -43,7 +43,7 @@ from pyastroweatherio.dataclasses import (
|
|
|
43
43
|
DSOUpTonight,
|
|
44
44
|
)
|
|
45
45
|
from pyastroweatherio.errors import RequestError
|
|
46
|
-
from pyastroweatherio.helper_functions import ConversionFunctions, AstronomicalRoutines
|
|
46
|
+
from pyastroweatherio.helper_functions import ConversionFunctions, AstronomicalRoutines, AstronomicalSeeing
|
|
47
47
|
|
|
48
48
|
_LOGGER = logging.getLogger(__name__)
|
|
49
49
|
|
|
@@ -98,6 +98,8 @@ class AstroWeather:
|
|
|
98
98
|
self._test_datetime,
|
|
99
99
|
)
|
|
100
100
|
|
|
101
|
+
self._astro_seeing = AstronomicalSeeing()
|
|
102
|
+
|
|
101
103
|
# Testing
|
|
102
104
|
self._test_mode = False
|
|
103
105
|
if self._test_datetime is not None:
|
|
@@ -197,7 +199,7 @@ class AstroWeather:
|
|
|
197
199
|
"longitude": self._longitude,
|
|
198
200
|
"elevation": self._elevation,
|
|
199
201
|
# 7timer
|
|
200
|
-
"seeing": row["seeing"],
|
|
202
|
+
"seeing": await self._astro_seeing.calculate_seeing_model4(details.get("air_temperature", -1), details.get("wind_speed", -1), details.get("relative_humidity", -1), self._elevation), #row["seeing"],
|
|
201
203
|
"transparency": row["transparency"],
|
|
202
204
|
"lifted_index": row["lifted_index"],
|
|
203
205
|
# Calculate
|
|
@@ -255,7 +257,7 @@ class AstroWeather:
|
|
|
255
257
|
# Condition
|
|
256
258
|
"condition_percentage": await self.calc_condition_percentage(
|
|
257
259
|
details.get("cloud_area_fraction", -1) / 12.5 + 1,
|
|
258
|
-
row["seeing"],
|
|
260
|
+
await self._astro_seeing.calculate_seeing_model4(details.get("air_temperature", -1), details.get("wind_speed", -1), details.get("relative_humidity", -1), self._elevation), #row["seeing"],
|
|
259
261
|
row["transparency"],
|
|
260
262
|
details.get("wind_speed", -1),
|
|
261
263
|
),
|
|
@@ -305,7 +307,7 @@ class AstroWeather:
|
|
|
305
307
|
break
|
|
306
308
|
_LOGGER.debug("Met.no start index: %s", str(metno_index))
|
|
307
309
|
|
|
308
|
-
seeing = row["seeing"]
|
|
310
|
+
seeing = 0 #row["seeing"]
|
|
309
311
|
transparency = row["transparency"]
|
|
310
312
|
item = {
|
|
311
313
|
"seventimer_init": init_ts,
|
|
@@ -344,10 +346,11 @@ class AstroWeather:
|
|
|
344
346
|
item["fog_area_fraction"] = details.get("fog_area_fraction", -1)
|
|
345
347
|
item["rh2m"] = details.get("relative_humidity", -1)
|
|
346
348
|
item["wind_speed"] = details.get("wind_speed", -1)
|
|
349
|
+
item["seeing"] = await self._astro_seeing.calculate_seeing_model4(details.get("air_temperature", -1), details.get("wind_speed", -1), details.get("relative_humidity", -1), self._elevation)
|
|
347
350
|
|
|
348
351
|
item["condition_percentage"] = await self.calc_condition_percentage(
|
|
349
352
|
item["cloud_area_fraction"] / 12.5 + 1,
|
|
350
|
-
row["seeing"],
|
|
353
|
+
await self._astro_seeing.calculate_seeing_model4(details.get("air_temperature", -1), details.get("wind_speed", -1), details.get("relative_humidity", -1), self._elevation), #row["seeing"],
|
|
351
354
|
row["transparency"],
|
|
352
355
|
item["wind_speed"],
|
|
353
356
|
)
|
|
@@ -625,8 +628,8 @@ class AstroWeather:
|
|
|
625
628
|
# TODO: Think about a complete redesign of the calculations and potentially
|
|
626
629
|
# make met.no the leading source instead of 7timer
|
|
627
630
|
# TODO: Find another source for seeing and transparency
|
|
628
|
-
self._seeing_weight = 0
|
|
629
|
-
self._transparency_weight = 0
|
|
631
|
+
# self._seeing_weight = 0
|
|
632
|
+
# self._transparency_weight = 0
|
|
630
633
|
self._weather_data_seventimer = []
|
|
631
634
|
for index in range(0, 20):
|
|
632
635
|
self._weather_data_seventimer.append({"timepoint": index * 3, "seeing": 0, "transparency": 0, "lifted_index": 0})
|
{pyastroweatherio-0.43.1.dev8 → pyastroweatherio-0.43.1.dev9}/pyastroweatherio/helper_functions.py
RENAMED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
from datetime import datetime, timedelta
|
|
3
3
|
import logging
|
|
4
4
|
import ephem
|
|
5
|
+
import math
|
|
5
6
|
from ephem import degree
|
|
6
7
|
from math import degrees as deg
|
|
7
8
|
import pytz
|
|
@@ -40,6 +41,114 @@ class ConversionFunctions:
|
|
|
40
41
|
return datetime.strptime(value, "%Y%m%d%H")
|
|
41
42
|
|
|
42
43
|
|
|
44
|
+
class AstronomicalSeeing:
|
|
45
|
+
"""Calculate different astronomical objects"""
|
|
46
|
+
|
|
47
|
+
def __init__(
|
|
48
|
+
self,
|
|
49
|
+
):
|
|
50
|
+
_LOGGER.debug("AstronomicalSeeing calculation mode active")
|
|
51
|
+
# temperature = 15 # in Celsius
|
|
52
|
+
# wind_speed = 5 # in m/s
|
|
53
|
+
# humidity = 50 # in Percent
|
|
54
|
+
# aerosol_density = 0.1 # in kg/m^3
|
|
55
|
+
# altitude = 1000 # in Meters
|
|
56
|
+
|
|
57
|
+
# Modell 0: Simple linear Model
|
|
58
|
+
async def calculate_seeing_model0(self, temperature, wind_speed, humidity, altitude):
|
|
59
|
+
constant_1 = 0.314 * temperature / 273
|
|
60
|
+
constant_2 = 20.8 * (1 - math.exp(-0.0695 * humidity))
|
|
61
|
+
constant_3 = 0.0017 * wind_speed ** 1.5
|
|
62
|
+
seeing = constant_1 + constant_2 + constant_3
|
|
63
|
+
_LOGGER.debug("AstronomicalSeeing calculation model1: T %s, W %s, H %s, E %s - S %s", str(temperature), str(wind_speed), str(humidity), str(altitude), str(seeing))
|
|
64
|
+
if seeing >= 2.5: return 7
|
|
65
|
+
if seeing >= 2.0: return 6
|
|
66
|
+
if seeing >= 1.5: return 5
|
|
67
|
+
if seeing >= 1.25: return 4
|
|
68
|
+
if seeing >= 1.0: return 3
|
|
69
|
+
if seeing >= 0.75: return 2
|
|
70
|
+
if seeing >= 0.5: return 1
|
|
71
|
+
return 0
|
|
72
|
+
# return 0.1 * temperature + 0.2 * wind_speed + 0.05 * humidity + 0.1 * aerosol_density - 0.05 * altitude
|
|
73
|
+
|
|
74
|
+
# Modell 1: Simple linear Model
|
|
75
|
+
async def calculate_seeing_model1(self, temperature, wind_speed, humidity, altitude):
|
|
76
|
+
seeing = 0.1 * temperature + 0.2 * wind_speed + 0.05 * humidity # - 0.05 * altitude
|
|
77
|
+
_LOGGER.debug("AstronomicalSeeing calculation model1: T %s, W %s, H %s, E %s - S %s", str(temperature), str(wind_speed), str(humidity), str(altitude), str(seeing))
|
|
78
|
+
if seeing >= 2.5: return 7
|
|
79
|
+
if seeing >= 2.0: return 6
|
|
80
|
+
if seeing >= 1.5: return 5
|
|
81
|
+
if seeing >= 1.25: return 4
|
|
82
|
+
if seeing >= 1.0: return 3
|
|
83
|
+
if seeing >= 0.75: return 2
|
|
84
|
+
if seeing >= 0.5: return 1
|
|
85
|
+
return 0
|
|
86
|
+
# return 0.1 * temperature + 0.2 * wind_speed + 0.05 * humidity + 0.1 * aerosol_density - 0.05 * altitude
|
|
87
|
+
|
|
88
|
+
# Modell 2: Modell with Exponential functions
|
|
89
|
+
async def calculate_seeing_model2(self, temperature, wind_speed, humidity, altitude):
|
|
90
|
+
seeing = 0.05 * temperature + 0.1 * wind_speed ** 1.5 + 0.02 * humidity ** 2 - 0.03 * altitude ** 1.5
|
|
91
|
+
_LOGGER.debug("AstronomicalSeeing calculation model2: T %s, W %s, H %s, E %s - S %s", str(temperature), str(wind_speed), str(humidity), str(altitude), str(seeing))
|
|
92
|
+
if seeing >= 2.5: return 7
|
|
93
|
+
if seeing >= 2.0: return 6
|
|
94
|
+
if seeing >= 1.5: return 5
|
|
95
|
+
if seeing >= 1.25: return 4
|
|
96
|
+
if seeing >= 1.0: return 3
|
|
97
|
+
if seeing >= 0.75: return 2
|
|
98
|
+
if seeing >= 0.5: return 1
|
|
99
|
+
return 0
|
|
100
|
+
# return 0.05 * temperature + 0.1 * wind_speed ** 1.5 + 0.02 * humidity ** 2 + 0.08 * aerosol_density - 0.03 * altitude ** 1.5
|
|
101
|
+
|
|
102
|
+
# Modell 3: Modell basierend auf empirischen Daten
|
|
103
|
+
async def calculate_seeing_model3(self, temperature, wind_speed, humidity, altitude):
|
|
104
|
+
seeing = 0.08 * temperature + 0.15 * math.log(wind_speed + 1) + 0.03 * humidity - 0.02 * altitude
|
|
105
|
+
_LOGGER.debug("AstronomicalSeeing calculation model3: T %s, W %s, H %s, E %s - S %s", str(temperature), str(wind_speed), str(humidity), str(altitude), str(seeing))
|
|
106
|
+
if seeing >= 2.5: return 7
|
|
107
|
+
if seeing >= 2.0: return 6
|
|
108
|
+
if seeing >= 1.5: return 5
|
|
109
|
+
if seeing >= 1.25: return 4
|
|
110
|
+
if seeing >= 1.0: return 3
|
|
111
|
+
if seeing >= 0.75: return 2
|
|
112
|
+
if seeing >= 0.5: return 1
|
|
113
|
+
return 0
|
|
114
|
+
# return 0.08 * temperature + 0.15 * math.log(wind_speed + 1) + 0.03 * humidity + 0.1 * aerosol_density - 0.02 * altitude
|
|
115
|
+
|
|
116
|
+
def calculate_dew_point(self, temperature, humidity):
|
|
117
|
+
a = 17.62
|
|
118
|
+
b = 243.12
|
|
119
|
+
gamma = math.log(humidity / 100) + (a * temperature) / (b + temperature)
|
|
120
|
+
dew_point = (b * gamma) / (a - gamma)
|
|
121
|
+
return dew_point
|
|
122
|
+
|
|
123
|
+
def calculate_saturation_vapor_pressure(self, dew_point):
|
|
124
|
+
es = 6.11 * (10 ** (7.5 * dew_point / (237.7 + dew_point)))
|
|
125
|
+
return es
|
|
126
|
+
|
|
127
|
+
def calculate_water_vapor_pressure(self, temperature, humidity):
|
|
128
|
+
dew_point = self.calculate_dew_point(temperature, humidity)
|
|
129
|
+
es = self.calculate_saturation_vapor_pressure(dew_point)
|
|
130
|
+
water_vapor_pressure = (humidity / 100) * es
|
|
131
|
+
return water_vapor_pressure
|
|
132
|
+
|
|
133
|
+
async def calculate_seeing_model4(self, temperature, humidity, wind_speed, altitude):
|
|
134
|
+
water_vapor_pressure = self.calculate_water_vapor_pressure(temperature, humidity)
|
|
135
|
+
adjusted_pressure = 1013.25 * math.exp(-0.00012 * altitude)
|
|
136
|
+
relative_pressure = adjusted_pressure / 1013.25
|
|
137
|
+
seeing_factor = 0.8 * (water_vapor_pressure / 10) ** 0.25 * (wind_speed / 10) ** 0.75 * relative_pressure
|
|
138
|
+
seeing = 0.98 / seeing_factor
|
|
139
|
+
_LOGGER.debug("AstronomicalSeeing calculation model3: T %s, W %s, H %s, E %s - S %s", str(temperature), str(wind_speed), str(humidity), str(altitude), str(seeing))
|
|
140
|
+
if seeing >= 2.5: return 7
|
|
141
|
+
if seeing >= 2.0: return 6
|
|
142
|
+
if seeing >= 1.5: return 5
|
|
143
|
+
if seeing >= 1.25: return 4
|
|
144
|
+
if seeing >= 1.0: return 3
|
|
145
|
+
if seeing >= 0.75: return 2
|
|
146
|
+
if seeing >= 0.5: return 1
|
|
147
|
+
return 0
|
|
148
|
+
# return seeing_factor
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
43
152
|
class AstronomicalRoutines:
|
|
44
153
|
"""Calculate different astronomical objects"""
|
|
45
154
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pyastroweatherio-0.43.1.dev8 → pyastroweatherio-0.43.1.dev9}/pyastroweatherio/dataclasses.py
RENAMED
|
File without changes
|
|
File without changes
|
{pyastroweatherio-0.43.1.dev8 → pyastroweatherio-0.43.1.dev9}/pyastroweatherio.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{pyastroweatherio-0.43.1.dev8 → pyastroweatherio-0.43.1.dev9}/pyastroweatherio.egg-info/requires.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|