pyastroweatherio 0.24.0.dev20__tar.gz → 0.24.0.dev22__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.24.0.dev20 → pyastroweatherio-0.24.0.dev22}/PKG-INFO +1 -1
- {pyastroweatherio-0.24.0.dev20 → pyastroweatherio-0.24.0.dev22}/pyastroweatherio/client.py +43 -58
- {pyastroweatherio-0.24.0.dev20 → pyastroweatherio-0.24.0.dev22}/pyastroweatherio/const.py +57 -57
- {pyastroweatherio-0.24.0.dev20 → pyastroweatherio-0.24.0.dev22}/pyastroweatherio/dataclasses.py +53 -54
- {pyastroweatherio-0.24.0.dev20 → pyastroweatherio-0.24.0.dev22}/pyastroweatherio/helper_functions.py +62 -73
- {pyastroweatherio-0.24.0.dev20 → pyastroweatherio-0.24.0.dev22}/pyastroweatherio.egg-info/PKG-INFO +1 -1
- {pyastroweatherio-0.24.0.dev20 → pyastroweatherio-0.24.0.dev22}/setup.py +1 -1
- {pyastroweatherio-0.24.0.dev20 → pyastroweatherio-0.24.0.dev22}/LICENSE +0 -0
- {pyastroweatherio-0.24.0.dev20 → pyastroweatherio-0.24.0.dev22}/README.md +0 -0
- {pyastroweatherio-0.24.0.dev20 → pyastroweatherio-0.24.0.dev22}/pyastroweatherio/__init__.py +0 -0
- {pyastroweatherio-0.24.0.dev20 → pyastroweatherio-0.24.0.dev22}/pyastroweatherio/errors.py +0 -0
- {pyastroweatherio-0.24.0.dev20 → pyastroweatherio-0.24.0.dev22}/pyastroweatherio.egg-info/SOURCES.txt +0 -0
- {pyastroweatherio-0.24.0.dev20 → pyastroweatherio-0.24.0.dev22}/pyastroweatherio.egg-info/dependency_links.txt +0 -0
- {pyastroweatherio-0.24.0.dev20 → pyastroweatherio-0.24.0.dev22}/pyastroweatherio.egg-info/requires.txt +0 -0
- {pyastroweatherio-0.24.0.dev20 → pyastroweatherio-0.24.0.dev22}/pyastroweatherio.egg-info/top_level.txt +0 -0
- {pyastroweatherio-0.24.0.dev20 → pyastroweatherio-0.24.0.dev22}/setup.cfg +0 -0
|
@@ -71,18 +71,15 @@ class AstroWeather:
|
|
|
71
71
|
self._forecast_data = None
|
|
72
72
|
|
|
73
73
|
self.req = session
|
|
74
|
-
|
|
74
|
+
|
|
75
75
|
# Astro Routines
|
|
76
76
|
self._astro_routines = AstronomicalRoutines(
|
|
77
|
-
self._latitude,
|
|
78
|
-
self._longitude,
|
|
79
|
-
self._elevation,
|
|
80
|
-
self._timezone_info
|
|
77
|
+
self._latitude, self._longitude, self._elevation, self._timezone_info
|
|
81
78
|
)
|
|
82
|
-
|
|
79
|
+
|
|
83
80
|
# Testing
|
|
84
|
-
self.test_mode =
|
|
85
|
-
self.dump_json =
|
|
81
|
+
self.test_mode = True
|
|
82
|
+
self.dump_json = True
|
|
86
83
|
|
|
87
84
|
# Public functions
|
|
88
85
|
async def get_location_data(
|
|
@@ -123,18 +120,8 @@ class AstroWeather:
|
|
|
123
120
|
# Anchor timestamp
|
|
124
121
|
init_ts = await cnv.anchor_timestamp(self._weather_data_seventimer_init)
|
|
125
122
|
|
|
126
|
-
# # Astro Routines
|
|
127
|
-
# astro_routines = AstronomicalRoutines(
|
|
128
|
-
# self._latitude,
|
|
129
|
-
# self._longitude,
|
|
130
|
-
# self._elevation,
|
|
131
|
-
# self._timezone_info,
|
|
132
|
-
# now,
|
|
133
|
-
# )
|
|
134
|
-
|
|
135
123
|
await self._astro_routines.need_update()
|
|
136
124
|
|
|
137
|
-
|
|
138
125
|
# Met.no
|
|
139
126
|
metno_index = -1
|
|
140
127
|
forecast_skipped = 0
|
|
@@ -163,15 +150,15 @@ class AstroWeather:
|
|
|
163
150
|
"latitude": self._latitude,
|
|
164
151
|
"longitude": self._longitude,
|
|
165
152
|
"elevation": self._elevation,
|
|
166
|
-
"cloudcover": row["cloudcover"],
|
|
153
|
+
# "cloudcover": row["cloudcover"], # overwritten
|
|
167
154
|
"seeing": row["seeing"],
|
|
168
155
|
"transparency": row["transparency"],
|
|
169
156
|
"lifted_index": row["lifted_index"],
|
|
170
|
-
"rh2m": row["rh2m"],
|
|
171
|
-
"wind10m": row["wind10m"],
|
|
172
|
-
"temp2m": row["temp2m"],
|
|
173
|
-
"dewpoint2m": await self.calc_dewpoint2m(row["rh2m"], row["temp2m"]),
|
|
174
|
-
"prec_type": row["prec_type"],
|
|
157
|
+
# "rh2m": row["rh2m"], # overwritten
|
|
158
|
+
# "wind10m": row["wind10m"], # overwritten
|
|
159
|
+
# "temp2m": row["temp2m"], # overwritten
|
|
160
|
+
# "dewpoint2m": await self.calc_dewpoint2m(row["rh2m"], row["temp2m"]), # overwritten
|
|
161
|
+
# "prec_type": row["prec_type"],
|
|
175
162
|
"sun_next_rising": await self._astro_routines.sun_next_rising_civil(),
|
|
176
163
|
"sun_next_rising_nautical": await self._astro_routines.sun_next_rising_nautical(),
|
|
177
164
|
"sun_next_rising_astro": await self._astro_routines.sun_next_rising_astro(),
|
|
@@ -183,9 +170,10 @@ class AstroWeather:
|
|
|
183
170
|
"moon_next_rising": await self._astro_routines.moon_next_rising(),
|
|
184
171
|
"moon_next_setting": await self._astro_routines.moon_next_setting(),
|
|
185
172
|
"moon_phase": await self._astro_routines.moon_phase(),
|
|
173
|
+
"moon_next_new_moon": await self._astro_routines.moon_next_new_moon(),
|
|
186
174
|
"moon_altitude": await self._astro_routines.moon_altitude(),
|
|
187
175
|
"moon_azimuth": await self._astro_routines.moon_azimuth(),
|
|
188
|
-
"weather": row.get("weather", ""),
|
|
176
|
+
# "weather": row.get("weather", ""),
|
|
189
177
|
"deepsky_forecast": await self._get_deepsky_forecast(),
|
|
190
178
|
}
|
|
191
179
|
# Met.no
|
|
@@ -214,10 +202,12 @@ class AstroWeather:
|
|
|
214
202
|
row["transparency"],
|
|
215
203
|
)
|
|
216
204
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
205
|
+
item["rh2m"] = details.get("relative_humidity", -1)
|
|
206
|
+
item["wind_speed"] = details.get("wind_speed", -1)
|
|
207
|
+
item["wind_from_direction"] = details.get("wind_from_direction", -1)
|
|
208
|
+
item["temp2m"] = details.get("air_temperature", -1)
|
|
209
|
+
item["dewpoint2m"] = details.get("dew_point_temperature", -1)
|
|
210
|
+
item["weather"] = self._weather_data_metno[metno_index].get("data", {}).get("next_1_hours", {}).get("summary", {}).get("symbol_code", "")
|
|
221
211
|
|
|
222
212
|
else:
|
|
223
213
|
# _LOGGER.debug("Met.no no Cloud Area Fraction for: %s", str(forecast_time))
|
|
@@ -253,12 +243,6 @@ class AstroWeather:
|
|
|
253
243
|
# Anchor timestamp
|
|
254
244
|
init_ts = await cnv.anchor_timestamp(self._weather_data_seventimer_init)
|
|
255
245
|
|
|
256
|
-
# Astro Routines
|
|
257
|
-
# astro_routines = AstronomicalRoutines(
|
|
258
|
-
# self._latitude, self._longitude, self._elevation, self._timezone_info, now
|
|
259
|
-
# )
|
|
260
|
-
# await self._astro_routines.need_update()
|
|
261
|
-
|
|
262
246
|
utc_to_local_diff = self._astro_routines.utc_to_local_diff()
|
|
263
247
|
_LOGGER.debug("UTC to local diff: %s", str(utc_to_local_diff))
|
|
264
248
|
_LOGGER.debug("Forecast length: %s", str(len(self._weather_data_seventimer)))
|
|
@@ -293,16 +277,16 @@ class AstroWeather:
|
|
|
293
277
|
"timestamp": forecast_time,
|
|
294
278
|
# "timestamp": self._astro_routines.utc_to_local(forecast_time),
|
|
295
279
|
"hour": hour_of_day,
|
|
296
|
-
"cloudcover": cloudcover,
|
|
280
|
+
# "cloudcover": cloudcover,
|
|
297
281
|
"seeing": seeing,
|
|
298
282
|
"transparency": transparency,
|
|
299
283
|
"lifted_index": row["lifted_index"],
|
|
300
|
-
"rh2m": row["rh2m"],
|
|
301
|
-
"wind10m": row["wind10m"],
|
|
302
|
-
"temp2m": row["temp2m"],
|
|
303
|
-
"dewpoint2m": await self.calc_dewpoint2m(row["rh2m"], row["temp2m"]),
|
|
304
|
-
"prec_type": row["prec_type"],
|
|
305
|
-
"weather": row.get("weather", ""),
|
|
284
|
+
# "rh2m": row["rh2m"],
|
|
285
|
+
# "wind10m": row["wind10m"],
|
|
286
|
+
# "temp2m": row["temp2m"],
|
|
287
|
+
# "dewpoint2m": await self.calc_dewpoint2m(row["rh2m"], row["temp2m"]),
|
|
288
|
+
# "prec_type": row["prec_type"],
|
|
289
|
+
# "weather": row.get("weather", ""),
|
|
306
290
|
}
|
|
307
291
|
# Met.no
|
|
308
292
|
if (
|
|
@@ -336,6 +320,13 @@ class AstroWeather:
|
|
|
336
320
|
row["seeing"],
|
|
337
321
|
row["transparency"],
|
|
338
322
|
)
|
|
323
|
+
item["rh2m"] = details.get("relative_humidity", -1)
|
|
324
|
+
item["wind_speed"] = details.get("wind_speed", -1)
|
|
325
|
+
item["wind_from_direction"] = details.get("wind_from_direction", -1)
|
|
326
|
+
item["temp2m"] = details.get("air_temperature", -1)
|
|
327
|
+
item["dewpoint2m"] = details.get("dew_point_temperature", -1)
|
|
328
|
+
item["weather"] = self._weather_data_metno[metno_index + cnt + i].get("data", {}).get("next_1_hours", {}).get("summary", {}).get("symbol_code", "")
|
|
329
|
+
|
|
339
330
|
items.append(ForecastData(item))
|
|
340
331
|
|
|
341
332
|
item["timepoint"] = item["timepoint"] + 1
|
|
@@ -375,12 +366,6 @@ class AstroWeather:
|
|
|
375
366
|
# Anchor timestamp
|
|
376
367
|
init_ts = await cnv.anchor_timestamp(self._weather_data_seventimer_init)
|
|
377
368
|
|
|
378
|
-
# Astro Routines
|
|
379
|
-
# astro_routines = AstronomicalRoutines(
|
|
380
|
-
# self._latitude, self._longitude, self._elevation, self._timezone_info, now
|
|
381
|
-
# )
|
|
382
|
-
# await self._astro_routines.need_update()
|
|
383
|
-
|
|
384
369
|
utc_to_local_diff = self._astro_routines.utc_to_local_diff()
|
|
385
370
|
|
|
386
371
|
# Create forecast
|
|
@@ -511,27 +496,27 @@ class AstroWeather:
|
|
|
511
496
|
_LOGGER.debug("Updating data from 7Timer")
|
|
512
497
|
|
|
513
498
|
astro_dataseries = None
|
|
514
|
-
civil_dataseries = None
|
|
499
|
+
# civil_dataseries = None
|
|
515
500
|
|
|
516
501
|
# Testing
|
|
517
502
|
if self.test_mode:
|
|
518
503
|
with open("astro.json") as json_file:
|
|
519
504
|
astro_dataseries_json = json.load(json_file)
|
|
520
505
|
astro_dataseries = astro_dataseries_json.get("dataseries", {})
|
|
521
|
-
json_data_astro = {
|
|
522
|
-
with open("civil.json") as json_file:
|
|
523
|
-
|
|
506
|
+
json_data_astro = {"init": astro_dataseries_json.get("init")}
|
|
507
|
+
# with open("civil.json") as json_file:
|
|
508
|
+
# civil_dataseries = json.load(json_file).get("dataseries", {})
|
|
524
509
|
else:
|
|
525
510
|
json_data_astro = await self.async_request_seventimer("astro", "get")
|
|
526
|
-
json_data_civil = await self.async_request_seventimer("civil", "get")
|
|
511
|
+
# json_data_civil = await self.async_request_seventimer("civil", "get")
|
|
527
512
|
|
|
528
513
|
astro_dataseries = json_data_astro.get("dataseries", {})
|
|
529
|
-
civil_dataseries = json_data_civil.get("dataseries", {})
|
|
514
|
+
# civil_dataseries = json_data_civil.get("dataseries", {})
|
|
530
515
|
|
|
531
|
-
for astro, civil in zip(astro_dataseries, civil_dataseries):
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
516
|
+
# for astro, civil in zip(astro_dataseries, civil_dataseries):
|
|
517
|
+
# if astro["timepoint"] == civil["timepoint"]:
|
|
518
|
+
# # astro["weather"] = civil["weather"]
|
|
519
|
+
# astro["rh2m"] = int(civil["rh2m"].replace("%", ""))
|
|
535
520
|
|
|
536
521
|
self._weather_data_seventimer = astro_dataseries
|
|
537
522
|
self._weather_data_seventimer_init = json_data_astro.get("init")
|
|
@@ -71,36 +71,36 @@ LIFTED_INDEX_PLAIN = [
|
|
|
71
71
|
"Over 11, very stable",
|
|
72
72
|
]
|
|
73
73
|
|
|
74
|
-
WIND10M_SPEED_PLAIN = [
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
]
|
|
74
|
+
# WIND10M_SPEED_PLAIN = [
|
|
75
|
+
# "none",
|
|
76
|
+
# "calm",
|
|
77
|
+
# "light",
|
|
78
|
+
# "moderate",
|
|
79
|
+
# "fresh",
|
|
80
|
+
# "strong",
|
|
81
|
+
# "gale",
|
|
82
|
+
# "storm",
|
|
83
|
+
# "hurricane",
|
|
84
|
+
# ]
|
|
85
85
|
|
|
86
86
|
WIND10M_DIRECTON = ["N", "NE", "E", "SE", "S", "SW", "W", "NW"]
|
|
87
87
|
|
|
88
|
-
WIND10M_SPEED = [
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
]
|
|
88
|
+
# WIND10M_SPEED = [
|
|
89
|
+
# 0,
|
|
90
|
+
# 0.3,
|
|
91
|
+
# 3.4,
|
|
92
|
+
# 8.0,
|
|
93
|
+
# 10.8,
|
|
94
|
+
# 17.2,
|
|
95
|
+
# 24.5,
|
|
96
|
+
# 32.6,
|
|
97
|
+
# 36.7,
|
|
98
|
+
# 41.4,
|
|
99
|
+
# 46.2,
|
|
100
|
+
# 50.9,
|
|
101
|
+
# 55.9,
|
|
102
|
+
# 60.9,
|
|
103
|
+
# ]
|
|
104
104
|
# WIND10M_SPEED = [
|
|
105
105
|
# "0.3m/s (calm)",
|
|
106
106
|
# "0.3-3.4m/s (light)",
|
|
@@ -117,36 +117,36 @@ WIND10M_SPEED = [
|
|
|
117
117
|
# "Over 55.9m/s (hurricane+)",
|
|
118
118
|
# ]
|
|
119
119
|
|
|
120
|
-
MAP_WEATHER_TYPE = {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
120
|
+
# MAP_WEATHER_TYPE = {
|
|
121
|
+
# "clearday": "Total cloud cover less than 20%",
|
|
122
|
+
# "clearnight": "Total cloud cover less than 20%",
|
|
123
|
+
# "pcloudyday": "Total cloud cover between 20%-60%",
|
|
124
|
+
# "pcloudynight": "Total cloud cover between 20%-60%",
|
|
125
|
+
# "mcloudyday": "Total cloud cover between 60%-80%",
|
|
126
|
+
# "mcloudynight": "Total cloud cover between 60%-80%",
|
|
127
|
+
# "cloudyday": "Total cloud cover over 80%",
|
|
128
|
+
# "cloudynight": "Total cloud cover over 80%",
|
|
129
|
+
# "humidday": "Relative humidity over 90% with total cloud cover less than 60%",
|
|
130
|
+
# "humidnight": "Relative humidity over 90% with total cloud cover less than 60%",
|
|
131
|
+
# "lightrainday": "Precipitation rate less than 4mm/hr with total cloud cover more than 80%",
|
|
132
|
+
# "lightrainnight": "Precipitation rate less than 4mm/hr with total cloud cover more than 80%",
|
|
133
|
+
# "oshowerday": "Precipitation rate less than 4mm/hr with total cloud cover between 60%-80%",
|
|
134
|
+
# "oshowernight": "Precipitation rate less than 4mm/hr with total cloud cover between 60%-80%",
|
|
135
|
+
# "ishowerday": "Precipitation rate less than 4mm/hr with total cloud cover less than 60%",
|
|
136
|
+
# "ishowernight": "Precipitation rate less than 4mm/hr with total cloud cover less than 60%",
|
|
137
|
+
# "lightsnowday": "Precipitation rate less than 4mm/hr",
|
|
138
|
+
# "lightsnownight": "Precipitation rate less than 4mm/hr",
|
|
139
|
+
# "rainday": "Precipitation rate over 4mm/hr",
|
|
140
|
+
# "rainnight": "Precipitation rate over 4mm/hr",
|
|
141
|
+
# "snowday": "Precipitation rate over 4mm/hr",
|
|
142
|
+
# "snownight": "Precipitation rate over 4mm/hr",
|
|
143
|
+
# "rainsnowday": "Precipitation type to be ice pellets or freezing rain",
|
|
144
|
+
# "rainsnownight": "Precipitation type to be ice pellets or freezing rain",
|
|
145
|
+
# "tsday": "Lifted Index less than -5 with precipitation rate below 4mm/hr",
|
|
146
|
+
# "tsnight": "Lifted Index less than -5 with precipitation rate below 4mm/hr",
|
|
147
|
+
# "tsrainday": "Lifted Index less than -5 with precipitation rate over 4mm/hr",
|
|
148
|
+
# "tsrainnight": "Lifted Index less than -5 with precipitation rate over 4mm/hr",
|
|
149
|
+
# }
|
|
150
150
|
|
|
151
151
|
# CONDITION = ["excellent", "good", "fair", "poor", "bad"]
|
|
152
152
|
# CONDITION = ["↑", "↗", "→", "↘", "↓"]
|
{pyastroweatherio-0.24.0.dev20 → pyastroweatherio-0.24.0.dev22}/pyastroweatherio/dataclasses.py
RENAMED
|
@@ -9,10 +9,10 @@ from pyastroweatherio.const import (
|
|
|
9
9
|
LIFTED_INDEX_PLAIN,
|
|
10
10
|
SEEING_PLAIN,
|
|
11
11
|
TRANSPARENCY_PLAIN,
|
|
12
|
-
WIND10M_SPEED_PLAIN,
|
|
13
|
-
WIND10M_SPEED,
|
|
12
|
+
# WIND10M_SPEED_PLAIN,
|
|
13
|
+
# WIND10M_SPEED,
|
|
14
14
|
WIND10M_DIRECTON,
|
|
15
|
-
MAP_WEATHER_TYPE,
|
|
15
|
+
# MAP_WEATHER_TYPE,
|
|
16
16
|
)
|
|
17
17
|
|
|
18
18
|
|
|
@@ -34,10 +34,11 @@ class BaseData:
|
|
|
34
34
|
self._condition_percentage = data["condition_percentage"]
|
|
35
35
|
self._lifted_index = data["lifted_index"]
|
|
36
36
|
self._rh2m = data["rh2m"]
|
|
37
|
-
self.
|
|
37
|
+
self._wind_speed = data["wind_speed"]
|
|
38
|
+
self._wind_from_direction = data["wind_from_direction"]
|
|
38
39
|
self._temp2m = data["temp2m"]
|
|
39
40
|
self._dewpoint2m = data["dewpoint2m"]
|
|
40
|
-
self._prec_type = data["prec_type"]
|
|
41
|
+
# self._prec_type = data["prec_type"]
|
|
41
42
|
self._weather = data["weather"]
|
|
42
43
|
|
|
43
44
|
@property
|
|
@@ -133,12 +134,19 @@ class BaseData:
|
|
|
133
134
|
@property
|
|
134
135
|
def wind10m_speed(self) -> float:
|
|
135
136
|
"""Return 10m Wind Speed."""
|
|
136
|
-
|
|
137
|
-
if speed >= 1 and speed <= 8:
|
|
138
|
-
return float(WIND10M_SPEED[self._wind10m.get("speed", 0)])
|
|
139
|
-
# return float(0)
|
|
140
|
-
return None
|
|
137
|
+
return self._wind_speed
|
|
141
138
|
|
|
139
|
+
@property
|
|
140
|
+
def wind10m_direction(self) -> str:
|
|
141
|
+
"""Return 10m Wind Direction."""
|
|
142
|
+
direction = self._wind_from_direction
|
|
143
|
+
|
|
144
|
+
# points = ["n", "ne", "e", "se", "s", "sw", "w", "nw"]
|
|
145
|
+
direction += 22.5
|
|
146
|
+
direction = direction % 360
|
|
147
|
+
direction = int(direction / 45) # values 0 to 7
|
|
148
|
+
return WIND10M_DIRECTON[direction]
|
|
149
|
+
|
|
142
150
|
@property
|
|
143
151
|
def temp2m(self) -> int:
|
|
144
152
|
"""Return 2m Temperature."""
|
|
@@ -149,15 +157,15 @@ class BaseData:
|
|
|
149
157
|
"""Return 2m Dew Point."""
|
|
150
158
|
return round(self._dewpoint2m, 1)
|
|
151
159
|
|
|
152
|
-
@property
|
|
153
|
-
def prec_type(self) -> str:
|
|
154
|
-
|
|
155
|
-
|
|
160
|
+
# @property
|
|
161
|
+
# def prec_type(self) -> str:
|
|
162
|
+
# """Return Precipitation Type."""
|
|
163
|
+
# return self._prec_type.capitalize()
|
|
156
164
|
|
|
157
165
|
@property
|
|
158
166
|
def weather(self) -> str:
|
|
159
167
|
"""Return Current Weather."""
|
|
160
|
-
return self._weather
|
|
168
|
+
return self._weather.replace('_', ' ').capitalize()
|
|
161
169
|
|
|
162
170
|
|
|
163
171
|
class LocationData(BaseData):
|
|
@@ -180,6 +188,7 @@ class LocationData(BaseData):
|
|
|
180
188
|
self._moon_next_rising = data["moon_next_rising"]
|
|
181
189
|
self._moon_next_setting = data["moon_next_setting"]
|
|
182
190
|
self._moon_phase = data["moon_phase"]
|
|
191
|
+
self._moon_next_new_moon = data["moon_next_new_moon"]
|
|
183
192
|
self._moon_altitude = data["moon_altitude"]
|
|
184
193
|
self._moon_azimuth = data["moon_azimuth"]
|
|
185
194
|
self._deepsky_forecast = data["deepsky_forecast"]
|
|
@@ -247,22 +256,14 @@ class LocationData(BaseData):
|
|
|
247
256
|
return trans.get(self._lifted_index, "")
|
|
248
257
|
return None
|
|
249
258
|
|
|
250
|
-
@property
|
|
251
|
-
def
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
@property
|
|
259
|
-
def wind10m_speed_plain(self) -> str:
|
|
260
|
-
"""Return 10m Wind Speed."""
|
|
261
|
-
speed = self._wind10m.get("speed", 0)
|
|
262
|
-
if speed >= 1 and speed <= 8:
|
|
263
|
-
return WIND10M_SPEED_PLAIN[speed].capitalize()
|
|
264
|
-
# return WIND10M_SPEED_PLAIN[0].capitalize()
|
|
265
|
-
return None
|
|
259
|
+
# @property
|
|
260
|
+
# def wind10m_speed_plain(self) -> str:
|
|
261
|
+
# """Return 10m Wind Speed."""
|
|
262
|
+
# speed = self._wind10m.get("speed", 0)
|
|
263
|
+
# if speed >= 1 and speed <= 8:
|
|
264
|
+
# return WIND10M_SPEED_PLAIN[speed].capitalize()
|
|
265
|
+
# # return WIND10M_SPEED_PLAIN[0].capitalize()
|
|
266
|
+
# return None
|
|
266
267
|
|
|
267
268
|
@property
|
|
268
269
|
def deep_sky_view(self) -> bool:
|
|
@@ -355,6 +356,12 @@ class LocationData(BaseData):
|
|
|
355
356
|
"""Return Moon Phase."""
|
|
356
357
|
return round(self._moon_phase, 1)
|
|
357
358
|
|
|
359
|
+
@property
|
|
360
|
+
def moon_next_new_moon(self) -> datetime:
|
|
361
|
+
"""Return Moon Next New Moon."""
|
|
362
|
+
if isinstance(self._moon_next_new_moon, datetime):
|
|
363
|
+
return self._moon_next_new_moon
|
|
364
|
+
|
|
358
365
|
@property
|
|
359
366
|
def moon_altitude(self) -> float:
|
|
360
367
|
"""Return Moon Altitude."""
|
|
@@ -416,13 +423,13 @@ class LocationData(BaseData):
|
|
|
416
423
|
return out
|
|
417
424
|
# return None
|
|
418
425
|
|
|
419
|
-
@property
|
|
420
|
-
def deepsky_forecast_today_desc(self):
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
+
# @property
|
|
427
|
+
# def deepsky_forecast_today_desc(self):
|
|
428
|
+
# """Return Forecast Today Description."""
|
|
429
|
+
# if len(self._deepsky_forecast) > 0:
|
|
430
|
+
# nightly_conditions = self._deepsky_forecast[0]
|
|
431
|
+
# return MAP_WEATHER_TYPE[nightly_conditions.weather]
|
|
432
|
+
# return None
|
|
426
433
|
|
|
427
434
|
@property
|
|
428
435
|
def deepsky_forecast_tomorrow(self) -> int:
|
|
@@ -477,13 +484,13 @@ class LocationData(BaseData):
|
|
|
477
484
|
# + "-"
|
|
478
485
|
return out
|
|
479
486
|
|
|
480
|
-
@property
|
|
481
|
-
def deepsky_forecast_tomorrow_desc(self):
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
+
# @property
|
|
488
|
+
# def deepsky_forecast_tomorrow_desc(self):
|
|
489
|
+
# """Return Forecast Tomorrow Description."""
|
|
490
|
+
# if len(self._deepsky_forecast) > 1:
|
|
491
|
+
# nightly_conditions = self._deepsky_forecast[1]
|
|
492
|
+
# return MAP_WEATHER_TYPE[nightly_conditions.weather]
|
|
493
|
+
# return None
|
|
487
494
|
|
|
488
495
|
|
|
489
496
|
class ForecastData(BaseData):
|
|
@@ -498,14 +505,6 @@ class ForecastData(BaseData):
|
|
|
498
505
|
"""Return Forecast Hour of the day."""
|
|
499
506
|
return self._hour
|
|
500
507
|
|
|
501
|
-
@property
|
|
502
|
-
def wind10m_direction(self) -> str:
|
|
503
|
-
"""Return 10m Wind Direction."""
|
|
504
|
-
direction = self._wind10m.get("direction", "O")
|
|
505
|
-
if direction in WIND10M_DIRECTON:
|
|
506
|
-
return direction.upper()
|
|
507
|
-
return None
|
|
508
|
-
|
|
509
508
|
@property
|
|
510
509
|
def deep_sky_view(self) -> bool:
|
|
511
510
|
"""Return True if Deep Sky should be possible."""
|
|
@@ -552,4 +551,4 @@ class NightlyConditionsData:
|
|
|
552
551
|
@property
|
|
553
552
|
def weather(self) -> str:
|
|
554
553
|
"""Return Current Weather."""
|
|
555
|
-
return self._weather
|
|
554
|
+
return self._weather.replace('_', ' ').capitalize()
|
{pyastroweatherio-0.24.0.dev20 → pyastroweatherio-0.24.0.dev22}/pyastroweatherio/helper_functions.py
RENAMED
|
@@ -73,14 +73,12 @@ class AstronomicalRoutines:
|
|
|
73
73
|
self._sun_azimuth = None
|
|
74
74
|
self._moon_next_rising = None
|
|
75
75
|
self._moon_next_setting = None
|
|
76
|
+
self._moon_next_new_moon = None
|
|
76
77
|
self._moon_altitude = None
|
|
77
78
|
self._moon_azimuth = None
|
|
78
79
|
self._sun = None
|
|
79
80
|
self._moon = None
|
|
80
81
|
|
|
81
|
-
# self.calculate_sun()
|
|
82
|
-
# self.calculate_moon()
|
|
83
|
-
|
|
84
82
|
def utc_to_local(self, utc_dt):
|
|
85
83
|
"""Localizes the datetime"""
|
|
86
84
|
local_tz = pytz.timezone(self._timezone_info)
|
|
@@ -125,13 +123,6 @@ class AstronomicalRoutines:
|
|
|
125
123
|
if self._sun is None:
|
|
126
124
|
self._sun = ephem.Sun()
|
|
127
125
|
|
|
128
|
-
# # Alt / Az
|
|
129
|
-
# self._sun_observer.date = self.utc_to_local(self._forecast_time)
|
|
130
|
-
# self._sun.compute(self._sun_observer)
|
|
131
|
-
|
|
132
|
-
# self._sun_altitude = deg(float(self._sun.alt))
|
|
133
|
-
# self._sun_azimuth = deg(float(self._sun.az))
|
|
134
|
-
|
|
135
126
|
try:
|
|
136
127
|
self._sun_next_rising_civil = self.utc_to_local(
|
|
137
128
|
self._sun_observer.next_rising(ephem.Sun(), use_center=True).datetime()
|
|
@@ -273,7 +264,7 @@ class AstronomicalRoutines:
|
|
|
273
264
|
|
|
274
265
|
self._sun_altitude = deg(float(self._sun.alt))
|
|
275
266
|
self._sun_azimuth = deg(float(self._sun.az))
|
|
276
|
-
|
|
267
|
+
|
|
277
268
|
def calculate_moon(self):
|
|
278
269
|
"""Calculates moon rising and setting"""
|
|
279
270
|
if self._moon_observer is None:
|
|
@@ -281,13 +272,6 @@ class AstronomicalRoutines:
|
|
|
281
272
|
if self._moon is None:
|
|
282
273
|
self._moon = ephem.Moon()
|
|
283
274
|
|
|
284
|
-
# Alt / Az
|
|
285
|
-
# self._moon_observer.date = self.utc_to_local(self._forecast_time)
|
|
286
|
-
# self._moon.compute(self._moon_observer)
|
|
287
|
-
|
|
288
|
-
# self._moon_altitude = deg(float(self._moon.alt))
|
|
289
|
-
# self._moon_azimuth = deg(float(self._moon.az))
|
|
290
|
-
|
|
291
275
|
# Rise and Setting
|
|
292
276
|
self._moon_observer.date = self._forecast_time
|
|
293
277
|
self._moon.compute(self._moon_observer)
|
|
@@ -306,6 +290,9 @@ class AstronomicalRoutines:
|
|
|
306
290
|
except (ephem.AlwaysUpError, ephem.NeverUpError):
|
|
307
291
|
pass
|
|
308
292
|
|
|
293
|
+
# Next new Moon
|
|
294
|
+
self._moon_next_new_moon = self.utc_to_local(ephem.next_new_moon(self._forecast_time).datetime())
|
|
295
|
+
|
|
309
296
|
def calculate_moon_altaz(self):
|
|
310
297
|
"""Calculates moon altitude and azimuth"""
|
|
311
298
|
if self._moon_observer is None:
|
|
@@ -319,7 +306,7 @@ class AstronomicalRoutines:
|
|
|
319
306
|
|
|
320
307
|
self._moon_altitude = deg(float(self._moon.alt))
|
|
321
308
|
self._moon_azimuth = deg(float(self._moon.az))
|
|
322
|
-
|
|
309
|
+
|
|
323
310
|
async def need_update(self):
|
|
324
311
|
self._forecast_time = datetime.utcnow()
|
|
325
312
|
self.calculate_sun_altaz()
|
|
@@ -353,7 +340,7 @@ class AstronomicalRoutines:
|
|
|
353
340
|
# _LOGGER.debug("set %s, %s, %s", str(self._sun_next_setting_civil), str(self._sun_next_setting_nautical), str(self._sun_next_setting_astro))
|
|
354
341
|
# _LOGGER.debug("rise %s, %s, %s", str(self._sun_next_rising_astro), str(self._sun_next_rising_nautical), str(self._sun_next_rising_civil))
|
|
355
342
|
# _LOGGER.debug("moon %s, %s", str(self._moon_next_rising), str(self._moon_next_setting))
|
|
356
|
-
|
|
343
|
+
|
|
357
344
|
# Return Sun setting and rising
|
|
358
345
|
async def sun_next_rising(self) -> datetime:
|
|
359
346
|
"""Returns sun next rising"""
|
|
@@ -376,20 +363,19 @@ class AstronomicalRoutines:
|
|
|
376
363
|
return self._sun_next_rising_nautical
|
|
377
364
|
if self._sun_next_rising_civil is not None:
|
|
378
365
|
return self._sun_next_rising_civil
|
|
379
|
-
|
|
366
|
+
|
|
380
367
|
async def sun_next_rising_civil(self) -> datetime:
|
|
381
368
|
"""Returns sun next rising"""
|
|
382
369
|
localtime = self.utc_to_local(datetime.utcnow())
|
|
383
|
-
if
|
|
384
|
-
self._sun_next_setting_civil is None
|
|
385
|
-
or localtime > self._sun_next_setting_civil
|
|
386
|
-
):
|
|
370
|
+
if self._sun_next_setting_civil is None or localtime > self._sun_next_setting_civil:
|
|
387
371
|
_LOGGER.debug("Astronomical calculations updating sun_next_rising_civil")
|
|
388
372
|
self._forecast_time = datetime.utcnow()
|
|
389
373
|
self.calculate_sun()
|
|
390
374
|
else:
|
|
391
|
-
_LOGGER.debug(
|
|
392
|
-
|
|
375
|
+
_LOGGER.debug(
|
|
376
|
+
"Astronomical calculations sun_next_rising_civil in %s", str(self._sun_next_setting_civil - localtime)
|
|
377
|
+
)
|
|
378
|
+
|
|
393
379
|
self._forecast_time = datetime.utcnow()
|
|
394
380
|
if self._sun_next_rising_civil is not None:
|
|
395
381
|
return self._sun_next_rising_civil
|
|
@@ -397,32 +383,31 @@ class AstronomicalRoutines:
|
|
|
397
383
|
async def sun_next_rising_nautical(self) -> datetime:
|
|
398
384
|
"""Returns sun next nautical rising"""
|
|
399
385
|
localtime = self.utc_to_local(datetime.utcnow())
|
|
400
|
-
if
|
|
401
|
-
self._sun_next_rising_nautical is None
|
|
402
|
-
or localtime > self._sun_next_rising_nautical
|
|
403
|
-
):
|
|
386
|
+
if self._sun_next_rising_nautical is None or localtime > self._sun_next_rising_nautical:
|
|
404
387
|
_LOGGER.debug("Astronomical calculations updating sun_next_rising_nautical")
|
|
405
388
|
self._forecast_time = datetime.utcnow()
|
|
406
389
|
self.calculate_sun()
|
|
407
390
|
else:
|
|
408
|
-
_LOGGER.debug(
|
|
409
|
-
|
|
391
|
+
_LOGGER.debug(
|
|
392
|
+
"Astronomical calculations sun_next_rising_nautical in %s",
|
|
393
|
+
str(self._sun_next_rising_nautical - localtime),
|
|
394
|
+
)
|
|
395
|
+
|
|
410
396
|
if self._sun_next_rising_nautical is not None:
|
|
411
397
|
return self._sun_next_rising_nautical
|
|
412
398
|
|
|
413
399
|
async def sun_next_rising_astro(self) -> datetime:
|
|
414
400
|
"""Returns sun next astronomical rising"""
|
|
415
401
|
localtime = self.utc_to_local(datetime.utcnow())
|
|
416
|
-
if
|
|
417
|
-
self._sun_next_rising_astro is None
|
|
418
|
-
or localtime > self._sun_next_rising_astro
|
|
419
|
-
):
|
|
402
|
+
if self._sun_next_rising_astro is None or localtime > self._sun_next_rising_astro:
|
|
420
403
|
_LOGGER.debug("Astronomical calculations updating sun_next_rising_astro")
|
|
421
404
|
self._forecast_time = datetime.utcnow()
|
|
422
405
|
self.calculate_sun()
|
|
423
406
|
else:
|
|
424
|
-
_LOGGER.debug(
|
|
425
|
-
|
|
407
|
+
_LOGGER.debug(
|
|
408
|
+
"Astronomical calculations sun_next_rising_astro in %s", str(self._sun_next_rising_astro - localtime)
|
|
409
|
+
)
|
|
410
|
+
|
|
426
411
|
if self._sun_next_rising_astro is not None:
|
|
427
412
|
return self._sun_next_rising_astro
|
|
428
413
|
|
|
@@ -447,83 +432,74 @@ class AstronomicalRoutines:
|
|
|
447
432
|
return self._sun_next_setting_nautical
|
|
448
433
|
if self._sun_next_setting_civil is not None:
|
|
449
434
|
return self._sun_next_setting_civil
|
|
450
|
-
|
|
435
|
+
|
|
451
436
|
async def sun_next_setting_civil(self) -> datetime:
|
|
452
437
|
"""Returns sun next setting"""
|
|
453
438
|
localtime = self.utc_to_local(datetime.utcnow())
|
|
454
|
-
if
|
|
455
|
-
self._sun_next_setting_civil is None
|
|
456
|
-
or localtime > self._sun_next_setting_civil
|
|
457
|
-
):
|
|
439
|
+
if self._sun_next_setting_civil is None or localtime > self._sun_next_setting_civil:
|
|
458
440
|
_LOGGER.debug("Astronomical calculations updating sun_next_setting_civil")
|
|
459
441
|
self._forecast_time = datetime.utcnow()
|
|
460
442
|
self.calculate_sun()
|
|
461
443
|
else:
|
|
462
|
-
_LOGGER.debug(
|
|
463
|
-
|
|
444
|
+
_LOGGER.debug(
|
|
445
|
+
"Astronomical calculations sun_next_setting_civil in %s", str(self._sun_next_setting_civil - localtime)
|
|
446
|
+
)
|
|
447
|
+
|
|
464
448
|
if self._sun_next_setting_civil is not None:
|
|
465
449
|
return self._sun_next_setting_civil
|
|
466
450
|
|
|
467
451
|
async def sun_next_setting_nautical(self) -> datetime:
|
|
468
452
|
"""Returns sun next nautical setting"""
|
|
469
453
|
localtime = self.utc_to_local(datetime.utcnow())
|
|
470
|
-
if
|
|
471
|
-
self._sun_next_setting_nautical is None
|
|
472
|
-
or localtime > self._sun_next_setting_nautical
|
|
473
|
-
):
|
|
454
|
+
if self._sun_next_setting_nautical is None or localtime > self._sun_next_setting_nautical:
|
|
474
455
|
_LOGGER.debug("Astronomical calculations updating sun_next_setting_nautical")
|
|
475
456
|
self._forecast_time = datetime.utcnow()
|
|
476
457
|
self.calculate_sun()
|
|
477
458
|
else:
|
|
478
|
-
_LOGGER.debug(
|
|
479
|
-
|
|
459
|
+
_LOGGER.debug(
|
|
460
|
+
"Astronomical calculations sun_next_setting_nautical in %s",
|
|
461
|
+
str(self._sun_next_setting_nautical - localtime),
|
|
462
|
+
)
|
|
463
|
+
|
|
480
464
|
if self._sun_next_setting_nautical is not None:
|
|
481
465
|
return self._sun_next_setting_nautical
|
|
482
466
|
|
|
483
467
|
async def sun_next_setting_astro(self) -> datetime:
|
|
484
468
|
"""Returns sun next astronomical setting"""
|
|
485
469
|
localtime = self.utc_to_local(datetime.utcnow())
|
|
486
|
-
if
|
|
487
|
-
self._sun_next_setting_astro is None
|
|
488
|
-
or localtime > self._sun_next_setting_astro
|
|
489
|
-
):
|
|
470
|
+
if self._sun_next_setting_astro is None or localtime > self._sun_next_setting_astro:
|
|
490
471
|
_LOGGER.debug("Astronomical calculations updating sun_next_setting_astro")
|
|
491
472
|
self._forecast_time = datetime.utcnow()
|
|
492
473
|
self.calculate_sun()
|
|
493
474
|
else:
|
|
494
|
-
_LOGGER.debug(
|
|
495
|
-
|
|
475
|
+
_LOGGER.debug(
|
|
476
|
+
"Astronomical calculations sun_next_setting_astro in %s", str(self._sun_next_setting_astro - localtime)
|
|
477
|
+
)
|
|
478
|
+
|
|
496
479
|
if self._sun_next_setting_astro is not None:
|
|
497
480
|
return self._sun_next_setting_astro
|
|
498
481
|
|
|
499
|
-
|
|
500
482
|
# Return Moon setting and rising
|
|
501
483
|
async def moon_next_rising(self) -> datetime:
|
|
502
484
|
localtime = self.utc_to_local(datetime.utcnow())
|
|
503
|
-
if
|
|
504
|
-
self._moon_next_rising is None
|
|
505
|
-
or localtime > self._moon_next_rising
|
|
506
|
-
):
|
|
485
|
+
if self._moon_next_rising is None or localtime > self._moon_next_rising:
|
|
507
486
|
_LOGGER.debug("Astronomical calculations updating moon_next_rising")
|
|
508
|
-
self.
|
|
487
|
+
self.calculate_moon()
|
|
509
488
|
else:
|
|
510
489
|
_LOGGER.debug("Astronomical calculations moon_next_rising in %s", str(self._moon_next_rising - localtime))
|
|
511
|
-
|
|
490
|
+
|
|
512
491
|
"""Returns moon next rising"""
|
|
513
492
|
if self._moon_next_rising is not None:
|
|
514
493
|
return self._moon_next_rising
|
|
515
494
|
|
|
516
495
|
async def moon_next_setting(self) -> datetime:
|
|
517
496
|
localtime = self.utc_to_local(datetime.utcnow())
|
|
518
|
-
if
|
|
519
|
-
self._moon_next_setting is None
|
|
520
|
-
or localtime > self._moon_next_setting
|
|
521
|
-
):
|
|
497
|
+
if self._moon_next_setting is None or localtime > self._moon_next_setting:
|
|
522
498
|
_LOGGER.debug("Astronomical calculations updating moon_next_setting")
|
|
523
|
-
self.
|
|
499
|
+
self.calculate_moon()
|
|
524
500
|
else:
|
|
525
501
|
_LOGGER.debug("Astronomical calculations moon_next_setting in %s", str(self._moon_next_setting - localtime))
|
|
526
|
-
|
|
502
|
+
|
|
527
503
|
"""Returns moon next setting"""
|
|
528
504
|
if self._moon_next_setting is not None:
|
|
529
505
|
return self._moon_next_setting
|
|
@@ -533,9 +509,22 @@ class AstronomicalRoutines:
|
|
|
533
509
|
self._forecast_time = datetime.utcnow()
|
|
534
510
|
self.calculate_moon()
|
|
535
511
|
|
|
536
|
-
if self._moon
|
|
512
|
+
if self._moon is not None:
|
|
537
513
|
return self._moon.phase
|
|
538
514
|
|
|
515
|
+
async def moon_next_new_moon(self) -> float:
|
|
516
|
+
"""Returns the next new moon"""
|
|
517
|
+
localtime = self.utc_to_local(datetime.utcnow())
|
|
518
|
+
if self._moon_next_new_moon is None or localtime > self._moon_next_new_moon:
|
|
519
|
+
_LOGGER.debug("Astronomical calculations updating moon_next_new_moon")
|
|
520
|
+
self.calculate_moon()
|
|
521
|
+
else:
|
|
522
|
+
_LOGGER.debug(
|
|
523
|
+
"Astronomical calculations moon_next_new_moon in %s", str(self._moon_next_new_moon - localtime)
|
|
524
|
+
)
|
|
525
|
+
|
|
526
|
+
if self._moon_next_new_moon is not None:
|
|
527
|
+
return self._moon_next_new_moon
|
|
539
528
|
|
|
540
529
|
# Return Alt Azimuth of Sun and Moon
|
|
541
530
|
async def sun_altitude(self) -> float:
|
|
@@ -568,4 +557,4 @@ class AstronomicalRoutines:
|
|
|
568
557
|
self.calculate_moon_altaz()
|
|
569
558
|
|
|
570
559
|
if self._moon_azimuth is not None:
|
|
571
|
-
return self._moon_azimuth
|
|
560
|
+
return self._moon_azimuth
|
|
File without changes
|
|
File without changes
|
{pyastroweatherio-0.24.0.dev20 → pyastroweatherio-0.24.0.dev22}/pyastroweatherio/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|