pyastroweatherio 0.62.0.dev6__tar.gz → 0.62.0.dev8__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (17) hide show
  1. {pyastroweatherio-0.62.0.dev6 → pyastroweatherio-0.62.0.dev8}/PKG-INFO +1 -1
  2. {pyastroweatherio-0.62.0.dev6 → pyastroweatherio-0.62.0.dev8}/pyastroweatherio/client.py +62 -70
  3. {pyastroweatherio-0.62.0.dev6 → pyastroweatherio-0.62.0.dev8}/pyastroweatherio/dataclasses.py +215 -22
  4. {pyastroweatherio-0.62.0.dev6 → pyastroweatherio-0.62.0.dev8}/pyastroweatherio/helper_functions.py +34 -26
  5. {pyastroweatherio-0.62.0.dev6 → pyastroweatherio-0.62.0.dev8}/pyastroweatherio.egg-info/PKG-INFO +1 -1
  6. {pyastroweatherio-0.62.0.dev6 → pyastroweatherio-0.62.0.dev8}/pyastroweatherio.egg-info/SOURCES.txt +0 -1
  7. {pyastroweatherio-0.62.0.dev6 → pyastroweatherio-0.62.0.dev8}/setup.py +1 -1
  8. pyastroweatherio-0.62.0.dev6/pyastroweatherio/models.py +0 -209
  9. {pyastroweatherio-0.62.0.dev6 → pyastroweatherio-0.62.0.dev8}/LICENSE +0 -0
  10. {pyastroweatherio-0.62.0.dev6 → pyastroweatherio-0.62.0.dev8}/README.md +0 -0
  11. {pyastroweatherio-0.62.0.dev6 → pyastroweatherio-0.62.0.dev8}/pyastroweatherio/__init__.py +0 -0
  12. {pyastroweatherio-0.62.0.dev6 → pyastroweatherio-0.62.0.dev8}/pyastroweatherio/const.py +0 -0
  13. {pyastroweatherio-0.62.0.dev6 → pyastroweatherio-0.62.0.dev8}/pyastroweatherio/errors.py +0 -0
  14. {pyastroweatherio-0.62.0.dev6 → pyastroweatherio-0.62.0.dev8}/pyastroweatherio.egg-info/dependency_links.txt +0 -0
  15. {pyastroweatherio-0.62.0.dev6 → pyastroweatherio-0.62.0.dev8}/pyastroweatherio.egg-info/requires.txt +0 -0
  16. {pyastroweatherio-0.62.0.dev6 → pyastroweatherio-0.62.0.dev8}/pyastroweatherio.egg-info/top_level.txt +0 -0
  17. {pyastroweatherio-0.62.0.dev6 → pyastroweatherio-0.62.0.dev8}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyastroweatherio
3
- Version: 0.62.0.dev6
3
+ Version: 0.62.0.dev8
4
4
  Summary: Python Wrapper for 7Timer and Met.no REST API
5
5
  Home-page: https://github.com/mawinkler/pyastroweatherio
6
6
  Author: Markus Winkler
@@ -7,12 +7,12 @@ import math
7
7
  import os.path
8
8
  from datetime import UTC, datetime, timedelta
9
9
  from json.decoder import JSONDecodeError
10
+ from pprint import pprint as pp
10
11
  from typing import Optional
11
12
 
12
13
  import aiofiles
13
14
  from aiohttp import ClientSession, ClientTimeout
14
15
  from aiohttp.client_exceptions import ClientError
15
- from pydantic import ValidationError
16
16
 
17
17
  from pyastroweatherio.const import (
18
18
  BASE_URL_MET,
@@ -41,15 +41,25 @@ from pyastroweatherio.const import (
41
41
  )
42
42
  from pyastroweatherio.dataclasses import (
43
43
  AtmosphereData,
44
- TimeData,
45
- GeoLocationData,
44
+ AtmosphereDataModel,
46
45
  ConditionData,
46
+ ConditionDataModel,
47
47
  ForecastData,
48
+ ForecastDataModel,
49
+ GeoLocationData,
50
+ GeoLocationDataModel,
48
51
  LocationData,
52
+ LocationDataModel,
49
53
  NightlyConditionsData,
50
- UpTonightDSOData,
54
+ NightlyConditionsDataModel,
55
+ TimeData,
56
+ TimeDataModel,
51
57
  UpTonightBodiesData,
58
+ UpTonightBodiesDataModel,
52
59
  UpTonightCometsData,
60
+ UpTonightCometsDataModel,
61
+ UpTonightDSOData,
62
+ UpTonightDSODataModel,
53
63
  )
54
64
  from pyastroweatherio.errors import RequestError
55
65
  from pyastroweatherio.helper_functions import (
@@ -57,20 +67,6 @@ from pyastroweatherio.helper_functions import (
57
67
  AtmosphericRoutines,
58
68
  ConversionFunctions,
59
69
  )
60
- from pyastroweatherio.models import (
61
- AtmosphereDataModel,
62
- ConditionDataModel,
63
- ForecastDataModel,
64
- GeoLocationDataModel,
65
- LocationDataModel,
66
- TimeDataModel,
67
- NightlyConditionsDataModel,
68
- UpTonightDSODataModel,
69
- UpTonightBodiesDataModel,
70
- UpTonightCometsDataModel,
71
- )
72
-
73
- from pprint import pprint as pp
74
70
 
75
71
  _LOGGER = logging.getLogger(__name__)
76
72
  _NOT_AVAILABLE = -9999
@@ -174,8 +170,8 @@ class AstroWeather:
174
170
  timezone_info,
175
171
  ) -> GeoLocationData | None:
176
172
 
177
- geolocation = GeoLocationData(
178
- data={
173
+ geolocation = GeoLocationDataModel(
174
+ {
179
175
  "latitude": latitude,
180
176
  "longitude": longitude,
181
177
  "elevation": elevation,
@@ -184,9 +180,8 @@ class AstroWeather:
184
180
  )
185
181
 
186
182
  try:
187
- GeoLocationDataModel.validate(geolocation)
188
- return geolocation
189
- except ValidationError as ve:
183
+ return GeoLocationData(data=geolocation)
184
+ except TypeError as ve:
190
185
  _LOGGER.error(f"Failed to parse geo location data: {geolocation}")
191
186
  _LOGGER.error(ve)
192
187
  return None
@@ -233,8 +228,8 @@ class AstroWeather:
233
228
  else:
234
229
  lifted_index = LIFTED_INDEX_7TIMER_MAPPING[details_seventimer["lifted_index"]]
235
230
 
236
- atmosphere = AtmosphereData(
237
- data={
231
+ atmosphere = AtmosphereDataModel(
232
+ {
238
233
  "seeing": seeing,
239
234
  "transparency": transparency,
240
235
  "lifted_index": lifted_index,
@@ -242,9 +237,8 @@ class AstroWeather:
242
237
  )
243
238
 
244
239
  try:
245
- AtmosphereDataModel.validate(atmosphere)
246
- return atmosphere
247
- except ValidationError as ve:
240
+ return AtmosphereData(data=atmosphere)
241
+ except TypeError as ve:
248
242
  _LOGGER.error(f"Failed to parse atmosphere data: {atmosphere}")
249
243
  _LOGGER.error(ve)
250
244
  return None
@@ -259,8 +253,8 @@ class AstroWeather:
259
253
  lifted_index,
260
254
  ) -> ConditionData | None:
261
255
 
262
- condition = ConditionData(
263
- data={
256
+ condition = ConditionDataModel(
257
+ {
264
258
  "cloudcover": details_metno.get("cloud_area_fraction"),
265
259
  "cloud_area_fraction": details_metno.get("cloud_area_fraction"),
266
260
  "cloud_area_fraction_high": details_metno.get("cloud_area_fraction_high"),
@@ -292,9 +286,8 @@ class AstroWeather:
292
286
  )
293
287
 
294
288
  try:
295
- ConditionDataModel.validate(condition)
296
- return condition
297
- except ValidationError as ve:
289
+ return ConditionData(data=condition)
290
+ except TypeError as ve:
298
291
  _LOGGER.error(f"Failed to parse condition data: {condition}")
299
292
  _LOGGER.error(ve)
300
293
  return None
@@ -435,8 +428,8 @@ class AstroWeather:
435
428
 
436
429
  atmosphere_data = await self._get_atmosphere(details_seventimer, details_metno)
437
430
 
438
- time_data = TimeData(
439
- data={
431
+ time_data = TimeDataModel(
432
+ {
440
433
  # seventimer_init is "init" of 7timer astro data
441
434
  "seventimer_init": seventimer_init,
442
435
  # seventimer_timepoint is "timepoint" of 7timer astro data and defines the data for init + timepoint
@@ -448,13 +441,13 @@ class AstroWeather:
448
441
  )
449
442
 
450
443
  try:
451
- TimeDataModel.validate(time_data)
452
- except ValidationError as ve:
444
+ time_data = TimeData(data=time_data)
445
+ except TypeError as ve:
453
446
  _LOGGER.error(f"Failed to parse location data model data: {time_data}")
454
447
  _LOGGER.error(ve)
455
448
 
456
- item = LocationData(
457
- data={
449
+ item = LocationDataModel(
450
+ {
458
451
  # Time data
459
452
  "time_data": time_data,
460
453
  # Time shift to UTC
@@ -486,9 +479,8 @@ class AstroWeather:
486
479
  )
487
480
 
488
481
  try:
489
- LocationDataModel.validate(item)
490
- items.append(item)
491
- except ValidationError as ve:
482
+ items.append(LocationData(data=item))
483
+ except TypeError as ve:
492
484
  _LOGGER.error(f"Failed to parse location data model data: {item}")
493
485
  _LOGGER.error(ve)
494
486
 
@@ -566,8 +558,8 @@ class AstroWeather:
566
558
 
567
559
  atmosphere_data = await self._get_atmosphere(details_seventimer, details_metno)
568
560
 
569
- time_data = TimeData(
570
- data={
561
+ td = TimeDataModel(
562
+ {
571
563
  # seventimer_init is "init" of 7timer astro data
572
564
  "seventimer_init": init_ts,
573
565
  # seventimer_timepoint is "timepoint" of 7timer astro data and defines the data for init + timepoint
@@ -579,13 +571,13 @@ class AstroWeather:
579
571
  )
580
572
 
581
573
  try:
582
- TimeDataModel.validate(time_data)
583
- except ValidationError as ve:
574
+ time_data = TimeData(data=td)
575
+ except TypeError as ve:
584
576
  _LOGGER.error(f"Failed to parse location data model data: {time_data}")
585
577
  _LOGGER.error(ve)
586
578
 
587
- item = ForecastData(
588
- data={
579
+ item = ForecastDataModel(
580
+ {
589
581
  # Time data
590
582
  "time_data": time_data,
591
583
  "hour": datetime.strptime(
@@ -603,9 +595,9 @@ class AstroWeather:
603
595
  )
604
596
 
605
597
  try:
606
- ForecastDataModel.validate(item)
607
- items.append(item)
608
- except ValidationError as ve:
598
+
599
+ items.append(ForecastData(data=item))
600
+ except TypeError as ve:
609
601
  _LOGGER.error(f"Failed to parse forecast data: {item}")
610
602
  _LOGGER.error(ve)
611
603
 
@@ -704,8 +696,8 @@ class AstroWeather:
704
696
  )
705
697
 
706
698
  if details_forecast.forecast_time.hour == sun_next_rising.hour or index >= (forecast_data_len - 1):
707
- item = NightlyConditionsData(
708
- data={
699
+ item = NightlyConditionsDataModel(
700
+ {
709
701
  "seventimer_init": init_ts,
710
702
  "dayname": forecast_dayname,
711
703
  "hour": start_forecast_hour,
@@ -716,8 +708,8 @@ class AstroWeather:
716
708
  )
717
709
 
718
710
  try:
719
- NightlyConditionsDataModel.validate(item)
720
- except ValidationError as ve:
711
+ item = NightlyConditionsData(data=item)
712
+ except TypeError as ve:
721
713
  _LOGGER.error(f"Failed to parse nightly conditions model data: {item}")
722
714
  _LOGGER.error(ve)
723
715
 
@@ -783,8 +775,8 @@ class AstroWeather:
783
775
  else:
784
776
  dso_meridian_antitransit_utc = ""
785
777
 
786
- item = UpTonightDSOData(
787
- data={
778
+ item = UpTonightDSODataModel(
779
+ {
788
780
  "id": dso_id.get(str(row), ""),
789
781
  "target_name": dso_target_name.get(str(row), ""),
790
782
  "type": dso_type.get(str(row), ""),
@@ -797,9 +789,9 @@ class AstroWeather:
797
789
  }
798
790
  )
799
791
  try:
800
- UpTonightDSODataModel.validate(item)
801
- items.append(item)
802
- except ValidationError as ve:
792
+
793
+ items.append(UpTonightDSOData(data=item))
794
+ except TypeError as ve:
803
795
  _LOGGER.error(f"Failed to parse deep sky object data: {item}")
804
796
  _LOGGER.error(ve)
805
797
 
@@ -839,8 +831,8 @@ class AstroWeather:
839
831
  else:
840
832
  body_meridian_transit_utc = ""
841
833
 
842
- item = UpTonightBodiesData(
843
- data={
834
+ item = UpTonightBodiesDataModel(
835
+ {
844
836
  "target_name": body_target_name.get(str(row), ""),
845
837
  "max_altitude": body_max_altitude.get(str(row), ""),
846
838
  "azimuth": body_azimuth.get(str(row), ""),
@@ -851,9 +843,9 @@ class AstroWeather:
851
843
  }
852
844
  )
853
845
  try:
854
- UpTonightBodiesDataModel.validate(item)
855
- items.append(item)
856
- except ValidationError as ve:
846
+
847
+ items.append(UpTonightBodiesData(data=item))
848
+ except TypeError as ve:
857
849
  _LOGGER.error(f"Failed to parse bodies data: {item}")
858
850
  _LOGGER.error(ve)
859
851
 
@@ -891,8 +883,8 @@ class AstroWeather:
891
883
  - timedelta(seconds=await self._astro_routines.time_shift())
892
884
  ).replace(tzinfo=UTC)
893
885
 
894
- item = UpTonightCometsData(
895
- data={
886
+ item = UpTonightCometsDataModel(
887
+ {
896
888
  "designation": comet_target_name.get(str(row), ""),
897
889
  "distance_au_earth": distance_au_earth.get(str(row), ""),
898
890
  "distance_au_sun": distance_au_sun.get(str(row), ""),
@@ -905,9 +897,9 @@ class AstroWeather:
905
897
  }
906
898
  )
907
899
  try:
908
- UpTonightCometsDataModel.validate(item)
909
- items.append(item)
910
- except ValidationError as ve:
900
+
901
+ items.append(UpTonightCometsData(data=item))
902
+ except TypeError as ve:
911
903
  _LOGGER.error(f"Failed to parse comets data: {item}")
912
904
  _LOGGER.error(ve)
913
905
 
@@ -1,9 +1,12 @@
1
1
  """Defines the Data Classes used."""
2
2
 
3
3
  import math
4
+ from dataclasses import dataclass
4
5
  from datetime import datetime
5
-
6
6
  from pprint import pprint as pp
7
+ from typing import TypedDict
8
+
9
+ from typeguard import typechecked
7
10
 
8
11
  from pyastroweatherio.const import (
9
12
  CONDITION,
@@ -22,10 +25,20 @@ from pyastroweatherio.const import (
22
25
  )
23
26
 
24
27
 
28
+ @dataclass
29
+ class TimeDataModel(TypedDict):
30
+ """Model for time data"""
31
+
32
+ seventimer_init: datetime
33
+ seventimer_timepoint: int
34
+ forecast_time: datetime
35
+
36
+
37
+ @typechecked
25
38
  class TimeData:
26
39
  """A representation of the time data of forecasts."""
27
40
 
28
- def __init__(self, *, data: dict):
41
+ def __init__(self, *, data: TimeDataModel):
29
42
  self.seventimer_init = data["seventimer_init"]
30
43
  self.seventimer_timepoint = data["seventimer_timepoint"]
31
44
  self.forecast_time = data["forecast_time"]
@@ -41,29 +54,68 @@ class TimeData:
41
54
  # self.seventimer_timepoint = timepoint
42
55
 
43
56
 
57
+ class GeoLocationDataModel(TypedDict):
58
+ """Model for the location"""
59
+
60
+ latitude: float
61
+ longitude: float
62
+ elevation: float
63
+ timezone_info: str
64
+
65
+
66
+ @typechecked
44
67
  class GeoLocationData:
45
68
  """A representation of the geographic location."""
46
69
 
47
- def __init__(self, *, data: dict):
70
+ def __init__(self, *, data: GeoLocationDataModel):
48
71
  self.latitude = data["latitude"]
49
72
  self.longitude = data["longitude"]
50
73
  self.elevation = data["elevation"]
51
74
  self.timezone_info = data["timezone_info"]
52
75
 
76
+ # if not all(data[key] is not None for key in asdict(self)):
77
+ # print("NONE value")
78
+ # print("done")
79
+
80
+
81
+ class AtmosphereDataModel(TypedDict):
82
+ """Model for atmosperic conditions"""
83
+
84
+ seeing: float
85
+ transparency: float
86
+ lifted_index: float
53
87
 
88
+
89
+ @typechecked
54
90
  class AtmosphereData:
55
91
  """A representation of atmospheric condition base class."""
56
92
 
57
- def __init__(self, *, data: dict):
93
+ def __init__(self, *, data: AtmosphereDataModel):
58
94
  self.seeing = data["seeing"]
59
95
  self.transparency = data["transparency"]
60
96
  self.lifted_index = data["lifted_index"]
61
97
 
62
98
 
99
+ class SunDataModel(TypedDict):
100
+ """Model for Sun data"""
101
+
102
+ altitude: float
103
+ azimuth: float
104
+ next_rising_astro: datetime
105
+ next_rising_civil: datetime
106
+ next_rising_nautical: datetime
107
+ next_setting_astro: datetime
108
+ next_setting_civil: datetime
109
+ next_setting_nautical: datetime
110
+ previous_rising_astro: datetime
111
+ previous_setting_astro: datetime
112
+
113
+
114
+ @typechecked
63
115
  class SunData:
64
116
  """A representation of Sun data class."""
65
117
 
66
- def __init__(self, *, data: dict):
118
+ def __init__(self, *, data: SunDataModel):
67
119
  self.altitude = data["altitude"]
68
120
  self.azimuth = data["azimuth"]
69
121
  self.next_rising_astro = data["next_rising_astro"]
@@ -76,10 +128,32 @@ class SunData:
76
128
  self.previous_setting_astro = data["previous_setting_astro"]
77
129
 
78
130
 
131
+ class MoonDataModel(TypedDict):
132
+ """Model for Moon data"""
133
+
134
+ altitude: float
135
+ angular_size: float
136
+ avg_angular_size: float
137
+ avg_distance_km: float
138
+ azimuth: float
139
+ distance: float
140
+ distance_km: float
141
+ next_full_moon: datetime
142
+ next_new_moon: datetime
143
+ next_rising: datetime
144
+ next_setting: datetime
145
+ phase: float
146
+ previous_rising: datetime
147
+ previous_setting: datetime
148
+ relative_distance: float
149
+ relative_size: float
150
+
151
+
152
+ @typechecked
79
153
  class MoonData:
80
154
  """A representation of Moon data class."""
81
155
 
82
- def __init__(self, *, data: dict):
156
+ def __init__(self, *, data: MoonDataModel):
83
157
  self.altitude = data["altitude"]
84
158
  self.angular_size = data["angular_size"]
85
159
  self.avg_angular_size = data["avg_angular_size"]
@@ -98,10 +172,21 @@ class MoonData:
98
172
  self.relative_size = data["relative_size"]
99
173
 
100
174
 
175
+ class DarknessDataModel(TypedDict):
176
+ """Model for deep sky darkness"""
177
+
178
+ deep_sky_darkness_moon_rises: bool
179
+ deep_sky_darkness_moon_sets: bool
180
+ deep_sky_darkness_moon_always_up: bool
181
+ deep_sky_darkness_moon_always_down: bool
182
+ deep_sky_darkness: float
183
+
184
+
185
+ @typechecked
101
186
  class DarknessData:
102
187
  """A representation of darkness data class."""
103
188
 
104
- def __init__(self, *, data: dict):
189
+ def __init__(self, *, data: DarknessDataModel):
105
190
  self.deep_sky_darkness_moon_rises = data["deep_sky_darkness_moon_rises"]
106
191
  self.deep_sky_darkness_moon_sets = data["deep_sky_darkness_moon_sets"]
107
192
  self.deep_sky_darkness_moon_always_up = data["deep_sky_darkness_moon_always_up"]
@@ -109,10 +194,35 @@ class DarknessData:
109
194
  self.deep_sky_darkness = data["deep_sky_darkness"]
110
195
 
111
196
 
197
+ class ConditionDataModel(TypedDict):
198
+ """Model for weather conditions"""
199
+
200
+ cloudcover: float
201
+ cloud_area_fraction: float
202
+ cloud_area_fraction_high: float
203
+ cloud_area_fraction_low: float
204
+ cloud_area_fraction_medium: float
205
+ fog_area_fraction: float
206
+ seeing: float
207
+ transparency: float
208
+ lifted_index: float
209
+ condition_percentage: int
210
+ rh2m: float
211
+ wind_speed: float
212
+ wind_from_direction: float
213
+ temp2m: float
214
+ dewpoint2m: float
215
+ weather: str
216
+ weather6: str
217
+ precipitation_amount: float
218
+ precipitation_amount6: float
219
+
220
+
221
+ @typechecked
112
222
  class ConditionData:
113
223
  """A representation of the condition base class."""
114
224
 
115
- def __init__(self, *, data: dict):
225
+ def __init__(self, *, data: ConditionDataModel):
116
226
  self.cloudcover = data["cloudcover"]
117
227
  self.cloud_area_fraction = data["cloud_area_fraction"]
118
228
  self.cloud_area_fraction_high = data["cloud_area_fraction_high"]
@@ -140,7 +250,7 @@ class ConditionData:
140
250
  def cloudcover_percentage(self) -> int:
141
251
  """Return Cloud Cover Percentage."""
142
252
 
143
- return self.cloudcover
253
+ return int(self.cloudcover)
144
254
 
145
255
  @property
146
256
  def cloudless_percentage(self) -> int:
@@ -273,11 +383,26 @@ class ConditionData:
273
383
  self._weather6 = new_value
274
384
 
275
385
 
386
+ class UpTonightDSODataModel(TypedDict):
387
+ """Model for DSO objects"""
388
+
389
+ id: str
390
+ target_name: str
391
+ type: str
392
+ constellation: str
393
+ size: float
394
+ visual_magnitude: float
395
+ meridian_transit: datetime | str
396
+ meridian_antitransit: datetime | str
397
+ foto: float
398
+
399
+
400
+ @typechecked
276
401
  class UpTonightDSOData:
277
402
  """A representation of uptonight DSO."""
278
403
 
279
404
  # def __init__(self, data):
280
- def __init__(self, *, data: dict):
405
+ def __init__(self, *, data: UpTonightDSODataModel):
281
406
  self.id = data["id"]
282
407
  self.target_name = data["target_name"]
283
408
  self.type = data["type"]
@@ -289,11 +414,24 @@ class UpTonightDSOData:
289
414
  self.foto = data["foto"]
290
415
 
291
416
 
417
+ class UpTonightBodiesDataModel(TypedDict):
418
+ """Model for bodies"""
419
+
420
+ target_name: str
421
+ max_altitude: float
422
+ azimuth: float
423
+ max_altitude_time: datetime
424
+ visual_magnitude: float
425
+ meridian_transit: datetime | str
426
+ foto: float
427
+
428
+
429
+ @typechecked
292
430
  class UpTonightBodiesData:
293
431
  """A representation of uptonight bodies."""
294
432
 
295
433
  # def __init__(self, data):
296
- def __init__(self, *, data: dict):
434
+ def __init__(self, *, data: UpTonightBodiesDataModel):
297
435
  self.target_name = data["target_name"]
298
436
  self.max_altitude = data["max_altitude"]
299
437
  self.azimuth = data["azimuth"]
@@ -303,11 +441,26 @@ class UpTonightBodiesData:
303
441
  self.foto = data["foto"]
304
442
 
305
443
 
444
+ class UpTonightCometsDataModel(TypedDict):
445
+ """Model for comets"""
446
+
447
+ designation: str
448
+ distance_au_earth: float
449
+ distance_au_sun: float
450
+ absolute_magnitude: float
451
+ visual_magnitude: float
452
+ altitude: float
453
+ azimuth: float
454
+ rise_time: datetime
455
+ set_time: datetime
456
+
457
+
458
+ @typechecked
306
459
  class UpTonightCometsData:
307
460
  """A representation of uptonight comets."""
308
461
 
309
462
  # def __init__(self, data):
310
- def __init__(self, *, data: dict):
463
+ def __init__(self, *, data: UpTonightCometsDataModel):
311
464
  self.designation = data["designation"]
312
465
  self.distance_au_earth = data["distance_au_earth"]
313
466
  self.distance_au_sun = data["distance_au_sun"]
@@ -319,11 +472,30 @@ class UpTonightCometsData:
319
472
  self.set_time = data["set_time"]
320
473
 
321
474
 
475
+ class LocationDataModel(TypedDict):
476
+ """Model for location conditions data"""
477
+
478
+ time_data: TimeData
479
+ time_shift: int
480
+ forecast_length: int
481
+ location_data: GeoLocationData
482
+ sun_data: SunData
483
+ moon_data: MoonData
484
+ darkness_data: DarknessData
485
+ night_duration_astronomical: float
486
+ deepsky_forecast: list
487
+ condition_data: ConditionData
488
+ uptonight: list
489
+ uptonight_bodies: list
490
+ uptonight_comets: list
491
+
492
+
493
+ @typechecked
322
494
  class LocationData:
323
495
  """A representation of the Location AstroWeather Data."""
324
496
 
325
497
  # def __init__(self, data):
326
- def __init__(self, *, data: dict):
498
+ def __init__(self, *, data: LocationDataModel):
327
499
  self.time_data = data["time_data"]
328
500
  self.time_shift = data["time_shift"]
329
501
  self.forecast_length = data["forecast_length"]
@@ -474,7 +646,7 @@ class LocationData:
474
646
  return self.condition_data.calm_percentage
475
647
 
476
648
  @property
477
- def wind10m_direction(self) -> float:
649
+ def wind10m_direction(self) -> str:
478
650
  return self.condition_data.wind10m_direction
479
651
 
480
652
  @property
@@ -768,7 +940,7 @@ class LocationData:
768
940
  # return None
769
941
 
770
942
  @property
771
- def uptonight_bodies_list(self) -> list[dict]:
943
+ def uptonight_bodies_list(self) -> list[UpTonightBodiesData]:
772
944
  """Return the list of UpTonight bodies."""
773
945
 
774
946
  return self.uptonight_bodies
@@ -785,16 +957,25 @@ class LocationData:
785
957
  # return None
786
958
 
787
959
  @property
788
- def uptonight_comets_list(self) -> list[dict]:
960
+ def uptonight_comets_list(self) -> list[UpTonightCometsData]:
789
961
  """Return the list of UpTonight comets."""
790
962
 
791
963
  return self.uptonight_comets
792
964
 
793
965
 
966
+ class ForecastDataModel(TypedDict):
967
+ """Model for forecast data"""
968
+
969
+ time_data: TimeData
970
+ hour: int
971
+ condition_data: ConditionData
972
+
973
+
974
+ @typechecked
794
975
  class ForecastData:
795
976
  """A representation of 3-Hour Based Forecast AstroWeather Data."""
796
977
 
797
- def __init__(self, *, data: dict):
978
+ def __init__(self, *, data: ForecastDataModel):
798
979
  self.time_data = data["time_data"]
799
980
  self.hour = data["hour"]
800
981
  self.condition_data = data["condition_data"]
@@ -842,15 +1023,15 @@ class ForecastData:
842
1023
  return self.condition_data.cloud_area_fraction_percentage
843
1024
 
844
1025
  @property
845
- def cloud_area_fraction_high_percentage(self) -> str:
1026
+ def cloud_area_fraction_high_percentage(self) -> int:
846
1027
  return self.condition_data.cloud_area_fraction_high_percentage
847
1028
 
848
1029
  @property
849
- def cloud_area_fraction_medium_percentage(self) -> str:
1030
+ def cloud_area_fraction_medium_percentage(self) -> int:
850
1031
  return self.condition_data.cloud_area_fraction_medium_percentage
851
1032
 
852
1033
  @property
853
- def cloud_area_fraction_low_percentage(self) -> str:
1034
+ def cloud_area_fraction_low_percentage(self) -> int:
854
1035
  return self.condition_data.cloud_area_fraction_low_percentage
855
1036
 
856
1037
  @property
@@ -878,7 +1059,7 @@ class ForecastData:
878
1059
  return self.condition_data.calm_percentage
879
1060
 
880
1061
  @property
881
- def wind10m_direction(self) -> float:
1062
+ def wind10m_direction(self) -> str:
882
1063
  return self.condition_data.wind10m_direction
883
1064
 
884
1065
  @property
@@ -914,10 +1095,22 @@ class ForecastData:
914
1095
  return self.condition_data.precipitation_amount6
915
1096
 
916
1097
 
1098
+ class NightlyConditionsDataModel(TypedDict):
1099
+ """Model for nightly conditions data"""
1100
+
1101
+ seventimer_init: datetime
1102
+ dayname: str
1103
+ hour: int
1104
+ nightly_conditions: list
1105
+ weather: str
1106
+ precipitation_amount6: float
1107
+
1108
+
1109
+ @typechecked
917
1110
  class NightlyConditionsData:
918
1111
  """A representation of nights Sky Quality Data."""
919
1112
 
920
- def __init__(self, *, data: dict):
1113
+ def __init__(self, *, data: NightlyConditionsDataModel):
921
1114
  self.seventimer_init = data["seventimer_init"]
922
1115
  self.dayname = data["dayname"]
923
1116
  self.hour = data["hour"]
@@ -7,7 +7,6 @@ from math import degrees as deg
7
7
 
8
8
  import ephem
9
9
  from ephem import degree
10
- from pydantic import ValidationError
11
10
  from zoneinfo import ZoneInfo
12
11
 
13
12
  # import metpy.calc as mpcalc
@@ -20,9 +19,16 @@ from pyastroweatherio.const import (
20
19
  NAUTICAL_DUSK_DAWN,
21
20
  SEEING_MAX,
22
21
  )
23
- from pyastroweatherio.models import DarknessDataModel, MoonDataModel, SunDataModel
24
22
 
25
- from pyastroweatherio.dataclasses import SunData, MoonData, DarknessData
23
+ # from pyastroweatherio.models import DarknessDataModel, MoonDataModel, SunDataModel
24
+ from pyastroweatherio.dataclasses import (
25
+ DarknessData,
26
+ DarknessDataModel,
27
+ MoonData,
28
+ MoonDataModel,
29
+ SunData,
30
+ SunDataModel,
31
+ )
26
32
 
27
33
  _LOGGER = logging.getLogger(__name__)
28
34
 
@@ -616,11 +622,11 @@ class AstronomicalRoutines:
616
622
  async def sun_data(self) -> dict:
617
623
  """Returns sun data."""
618
624
 
619
- sd = SunData(data=self._sun_data)
625
+ sd = SunDataModel(self._sun_data)
620
626
  try:
621
- SunDataModel.validate(sd)
622
- return sd
623
- except ValidationError as ve:
627
+
628
+ return SunData(data=sd)
629
+ except TypeError as ve:
624
630
  _LOGGER.error(f"Failed to parse Sun data: {self._sun_data}")
625
631
  _LOGGER.error(ve)
626
632
  return None
@@ -893,11 +899,11 @@ class AstronomicalRoutines:
893
899
  async def moon_data(self) -> dict:
894
900
  """Returns moon data."""
895
901
 
896
- md = MoonData(data=self._moon_data)
902
+ md = MoonDataModel(self._moon_data)
897
903
  try:
898
- MoonDataModel.validate(md)
899
- return md
900
- except ValidationError as ve:
904
+
905
+ return MoonData(data=md)
906
+ except TypeError as ve:
901
907
  _LOGGER.error(f"Failed to parse Sun data: {self._moon_data}")
902
908
  _LOGGER.error(ve)
903
909
  return None
@@ -1011,19 +1017,21 @@ class AstronomicalRoutines:
1011
1017
  # #########################################################################
1012
1018
  # Darkness
1013
1019
  # #########################################################################
1014
- async def darkness_data(self) -> dict:
1020
+ async def darkness_data(self) -> DarknessData:
1015
1021
  """Returns darkness data."""
1016
1022
 
1017
- if not self._test_data(self._moon_data, ["next_setting", "next_rising", "previous_setting"]):
1018
- _LOGGER.debug("DSD: moon data missing")
1019
- return False
1023
+ # if not self._test_data(
1024
+ # self._moon_data, ["next_setting", "next_rising", "previous_setting"]
1025
+ # ):
1026
+ # _LOGGER.debug("DSD: moon data missing")
1027
+ # return False
1020
1028
 
1021
- if not self._test_data(
1022
- self._sun_data,
1023
- ["previous_setting_astro", "next_setting_astro", "next_rising_astro"],
1024
- ):
1025
- _LOGGER.debug("DSD: sun data missing")
1026
- return False
1029
+ # if not self._test_data(
1030
+ # self._sun_data,
1031
+ # ["previous_setting_astro", "next_setting_astro", "next_rising_astro"],
1032
+ # ):
1033
+ # _LOGGER.debug("DSD: sun data missing")
1034
+ # return False
1027
1035
 
1028
1036
  self._darkness_data["deep_sky_darkness_moon_rises"] = self._deep_sky_darkness_moon_rises()
1029
1037
  self._darkness_data["deep_sky_darkness_moon_sets"] = self._deep_sky_darkness_moon_sets()
@@ -1031,11 +1039,11 @@ class AstronomicalRoutines:
1031
1039
  self._darkness_data["deep_sky_darkness_moon_always_down"] = self._deep_sky_darkness_moon_always_down()
1032
1040
  self._darkness_data["deep_sky_darkness"] = self._deep_sky_darkness()
1033
1041
 
1034
- dd = DarknessData(data=self._darkness_data)
1042
+ dd = DarknessDataModel(self._darkness_data)
1035
1043
  try:
1036
- DarknessDataModel.validate(dd)
1037
- return dd
1038
- except ValidationError as ve:
1044
+
1045
+ return DarknessData(data=dd)
1046
+ except TypeError as ve:
1039
1047
  _LOGGER.error(f"Failed to parse darkness data: {self._darkness_data}")
1040
1048
  _LOGGER.error(ve)
1041
1049
  return None
@@ -1061,7 +1069,7 @@ class AstronomicalRoutines:
1061
1069
  if self._astronomical_darkness():
1062
1070
  _LOGGER.debug("DSD: In astronomical darkness")
1063
1071
  if self._deep_sky_darkness_moon_rises():
1064
- dsd = self._moon_data("next_rising") - self._forecast_time
1072
+ dsd = self._moon_data["next_rising"] - self._forecast_time
1065
1073
  _LOGGER.debug(f"DSD: Sun down, Moon rises {dsd}")
1066
1074
 
1067
1075
  if self._deep_sky_darkness_moon_sets():
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyastroweatherio
3
- Version: 0.62.0.dev6
3
+ Version: 0.62.0.dev8
4
4
  Summary: Python Wrapper for 7Timer and Met.no REST API
5
5
  Home-page: https://github.com/mawinkler/pyastroweatherio
6
6
  Author: Markus Winkler
@@ -8,7 +8,6 @@ pyastroweatherio/const.py
8
8
  pyastroweatherio/dataclasses.py
9
9
  pyastroweatherio/errors.py
10
10
  pyastroweatherio/helper_functions.py
11
- pyastroweatherio/models.py
12
11
  pyastroweatherio.egg-info/PKG-INFO
13
12
  pyastroweatherio.egg-info/SOURCES.txt
14
13
  pyastroweatherio.egg-info/dependency_links.txt
@@ -3,7 +3,7 @@ from setuptools import setup
3
3
  setup(
4
4
  name="pyastroweatherio",
5
5
  packages=["pyastroweatherio"],
6
- version="0.62.0.dev6",
6
+ version="0.62.0.dev8",
7
7
  license="MIT",
8
8
  description="Python Wrapper for 7Timer and Met.no REST API",
9
9
  long_description=" ".join(
@@ -1,209 +0,0 @@
1
- from datetime import datetime
2
- from typing import List, Optional
3
-
4
- from pydantic import BaseModel, ConfigDict, Field
5
-
6
- from pyastroweatherio.const import (
7
- DEFAULT_ELEVATION,
8
- DEFAULT_LATITUDE,
9
- DEFAULT_LONGITUDE,
10
- DEFAULT_TIMEZONE,
11
- )
12
-
13
-
14
- class GeoLocationDataModel(BaseModel):
15
- """Model for the location"""
16
-
17
- model_config = ConfigDict(from_attributes=True)
18
-
19
- latitude: float = Field(default=DEFAULT_LATITUDE)
20
- longitude: float = Field(default=DEFAULT_LONGITUDE)
21
- elevation: float = Field(default=DEFAULT_ELEVATION)
22
- timezone_info: str = Field(default=DEFAULT_TIMEZONE)
23
-
24
-
25
- class ConditionDataModel(BaseModel):
26
- """Model for weather conditions"""
27
-
28
- model_config = ConfigDict(from_attributes=True)
29
-
30
- cloudcover: float
31
- cloud_area_fraction: float
32
- cloud_area_fraction_high: float
33
- cloud_area_fraction_low: float
34
- cloud_area_fraction_medium: float
35
- fog_area_fraction: float
36
- seeing: float
37
- transparency: float
38
- lifted_index: float
39
- condition_percentage: int
40
- rh2m: float
41
- wind_speed: float
42
- wind_from_direction: float
43
- temp2m: float
44
- dewpoint2m: float
45
- weather: str
46
- weather6: str
47
- precipitation_amount: float
48
- precipitation_amount6: float
49
-
50
-
51
- class AtmosphereDataModel(BaseModel):
52
- """Model for atmosperic conditions"""
53
-
54
- model_config = ConfigDict(from_attributes=True)
55
-
56
- seeing: float
57
- transparency: float
58
- lifted_index: float
59
-
60
-
61
- class SunDataModel(BaseModel):
62
- """Model for Sun data"""
63
-
64
- model_config = ConfigDict(from_attributes=True)
65
-
66
- altitude: float
67
- azimuth: float
68
- next_rising_astro: datetime
69
- next_rising_civil: datetime
70
- next_rising_nautical: datetime
71
- next_setting_astro: datetime
72
- next_setting_civil: datetime
73
- next_setting_nautical: datetime
74
- previous_rising_astro: datetime
75
- previous_setting_astro: datetime
76
-
77
-
78
- class MoonDataModel(BaseModel):
79
- """Model for Moon data"""
80
-
81
- model_config = ConfigDict(from_attributes=True)
82
-
83
- altitude: float
84
- angular_size: float
85
- avg_angular_size: float
86
- avg_distance_km: float
87
- azimuth: float
88
- distance: float
89
- distance_km: float
90
- next_full_moon: datetime
91
- next_new_moon: datetime
92
- next_rising: datetime
93
- next_setting: datetime
94
- phase: float
95
- previous_rising: datetime
96
- previous_setting: datetime
97
- relative_distance: float
98
- relative_size: float
99
-
100
-
101
- class DarknessDataModel(BaseModel):
102
- """Model for deep sky darkness"""
103
-
104
- model_config = ConfigDict(from_attributes=True)
105
-
106
- deep_sky_darkness_moon_rises: bool
107
- deep_sky_darkness_moon_sets: bool
108
- deep_sky_darkness_moon_always_up: bool
109
- deep_sky_darkness_moon_always_down: bool
110
- deep_sky_darkness: float
111
-
112
-
113
- class TimeDataModel(BaseModel):
114
- """Model for time data"""
115
-
116
- model_config = ConfigDict(from_attributes=True)
117
-
118
- seventimer_init: datetime
119
- seventimer_timepoint: int
120
- forecast_time: datetime
121
-
122
-
123
- class LocationDataModel(BaseModel):
124
- """Model for location conditions data"""
125
-
126
- model_config = ConfigDict(from_attributes=True)
127
-
128
- time_data: TimeDataModel
129
- time_shift: int
130
- forecast_length: int
131
- location_data: GeoLocationDataModel
132
- sun_data: SunDataModel
133
- moon_data: MoonDataModel
134
- darkness_data: DarknessDataModel
135
- night_duration_astronomical: float
136
- deepsky_forecast: list
137
- condition_data: ConditionDataModel
138
- uptonight: list
139
- uptonight_bodies: list
140
- uptonight_comets: list
141
-
142
-
143
- class ForecastDataModel(BaseModel):
144
- """Model for forecast data"""
145
-
146
- model_config = ConfigDict(from_attributes=True)
147
-
148
- time_data: TimeDataModel
149
- hour: int
150
- condition_data: ConditionDataModel
151
-
152
-
153
- class NightlyConditionsDataModel(BaseModel):
154
- """Model for nightly conditions data"""
155
-
156
- model_config = ConfigDict(from_attributes=True)
157
-
158
- seventimer_init: datetime
159
- dayname: str
160
- hour: int
161
- nightly_conditions: list
162
- weather: str
163
- precipitation_amount6: float
164
-
165
-
166
- class UpTonightDSODataModel(BaseModel):
167
- """Model for DSO objects"""
168
-
169
- model_config = ConfigDict(from_attributes=True)
170
-
171
- id: str
172
- target_name: str
173
- type: str
174
- constellation: str
175
- size: float
176
- visual_magnitude: float
177
- meridian_transit: datetime | str
178
- meridian_antitransit: datetime | str
179
- foto: float
180
-
181
-
182
- class UpTonightBodiesDataModel(BaseModel):
183
- """Model for bodies"""
184
-
185
- model_config = ConfigDict(from_attributes=True)
186
-
187
- target_name: str
188
- max_altitude: float
189
- azimuth: float
190
- max_altitude_time: datetime
191
- visual_magnitude: float
192
- meridian_transit: datetime | str
193
- foto: float
194
-
195
-
196
- class UpTonightCometsDataModel(BaseModel):
197
- """Model for comets"""
198
-
199
- model_config = ConfigDict(from_attributes=True)
200
-
201
- designation: str
202
- distance_au_earth: float
203
- distance_au_sun: float
204
- absolute_magnitude: float
205
- visual_magnitude: float
206
- altitude: float
207
- azimuth: float
208
- rise_time: datetime
209
- set_time: datetime