kerykeion 4.14.2__py3-none-any.whl → 4.18.0__py3-none-any.whl

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.

Potentially problematic release.


This version of kerykeion might be problematic. Click here for more details.

Files changed (34) hide show
  1. kerykeion/__init__.py +2 -1
  2. kerykeion/aspects/aspects_utils.py +33 -117
  3. kerykeion/aspects/natal_aspects.py +26 -25
  4. kerykeion/aspects/synastry_aspects.py +25 -27
  5. kerykeion/astrological_subject.py +145 -189
  6. kerykeion/charts/charts_utils.py +400 -126
  7. kerykeion/charts/draw_planets.py +407 -0
  8. kerykeion/charts/kerykeion_chart_svg.py +502 -770
  9. kerykeion/charts/templates/aspect_grid_only.xml +452 -0
  10. kerykeion/charts/templates/chart.xml +39 -39
  11. kerykeion/charts/templates/wheel_only.xml +499 -0
  12. kerykeion/charts/themes/classic.css +82 -0
  13. kerykeion/charts/themes/dark-high-contrast.css +121 -0
  14. kerykeion/charts/themes/dark.css +121 -0
  15. kerykeion/charts/themes/light.css +117 -0
  16. kerykeion/ephemeris_data.py +22 -18
  17. kerykeion/kr_types/chart_types.py +3 -7
  18. kerykeion/kr_types/kr_literals.py +10 -1
  19. kerykeion/kr_types/kr_models.py +33 -8
  20. kerykeion/kr_types/settings_models.py +1 -10
  21. kerykeion/relationship_score/__init__.py +2 -0
  22. kerykeion/relationship_score/relationship_score.py +175 -0
  23. kerykeion/relationship_score/relationship_score_factory.py +275 -0
  24. kerykeion/report.py +6 -3
  25. kerykeion/settings/kerykeion_settings.py +6 -1
  26. kerykeion/settings/kr.config.json +238 -98
  27. kerykeion/utilities.py +116 -215
  28. {kerykeion-4.14.2.dist-info → kerykeion-4.18.0.dist-info}/METADATA +40 -10
  29. kerykeion-4.18.0.dist-info/RECORD +42 -0
  30. kerykeion/relationship_score.py +0 -205
  31. kerykeion-4.14.2.dist-info/RECORD +0 -33
  32. {kerykeion-4.14.2.dist-info → kerykeion-4.18.0.dist-info}/LICENSE +0 -0
  33. {kerykeion-4.14.2.dist-info → kerykeion-4.18.0.dist-info}/WHEEL +0 -0
  34. {kerykeion-4.14.2.dist-info → kerykeion-4.18.0.dist-info}/entry_points.txt +0 -0
@@ -20,11 +20,13 @@ from kerykeion.kr_types import (
20
20
  PointType,
21
21
  SiderealMode,
22
22
  HousesSystemIdentifier,
23
- PerspectiveType
23
+ PerspectiveType,
24
+ Planet,
25
+ Houses
24
26
  )
25
27
  from kerykeion.utilities import (
26
28
  get_number_from_name,
27
- calculate_position,
29
+ get_kerykeion_point_from_degree,
28
30
  get_planet_house,
29
31
  get_moon_emoji_from_phase_int,
30
32
  get_moon_phase_name_from_phase_int,
@@ -34,10 +36,10 @@ from pathlib import Path
34
36
  from typing import Union, get_args
35
37
 
36
38
  DEFAULT_GEONAMES_USERNAME = "century.boy"
37
- DEFAULT_SIDEREAL_MODE = "FAGAN_BRADLEY"
38
- DEFAULT_HOUSES_SYSTEM_IDENTIFIER = "P"
39
- DEFAULT_ZODIAC_TYPE = "Tropic"
40
- DEFAULT_PERSPECTIVE_TYPE = "Apparent Geocentric"
39
+ DEFAULT_SIDEREAL_MODE: SiderealMode = "FAGAN_BRADLEY"
40
+ DEFAULT_HOUSES_SYSTEM_IDENTIFIER: HousesSystemIdentifier = "P"
41
+ DEFAULT_ZODIAC_TYPE: ZodiacType = "Tropic"
42
+ DEFAULT_PERSPECTIVE_TYPE: PerspectiveType = "Apparent Geocentric"
41
43
  GEONAMES_DEFAULT_USERNAME_WARNING = (
42
44
  "\n********\n"
43
45
  "NO GEONAMES USERNAME SET!\n"
@@ -101,12 +103,12 @@ class AstrologicalSubject:
101
103
  day: int
102
104
  hour: int
103
105
  minute: int
104
- city: Union[str, None]
105
- nation: Union[str, None]
106
- lng: Union[int, float, None]
107
- lat: Union[int, float, None]
108
- tz_str: Union[str, None]
109
- geonames_username: Union[str, None]
106
+ city: str
107
+ nation: str
108
+ lng: Union[int, float]
109
+ lat: Union[int, float]
110
+ tz_str: str
111
+ geonames_username: str
110
112
  online: bool
111
113
  zodiac_type: ZodiacType
112
114
  sidereal_mode: Union[SiderealMode, None]
@@ -136,7 +138,7 @@ class AstrologicalSubject:
136
138
  true_node: KerykeionPointModel
137
139
  mean_node: KerykeionPointModel
138
140
  chiron: Union[KerykeionPointModel, None]
139
- mean_lilit: Union[KerykeionPointModel, None]
141
+ mean_lilith: Union[KerykeionPointModel, None]
140
142
 
141
143
  # Houses
142
144
  first_house: KerykeionPointModel
@@ -153,15 +155,16 @@ class AstrologicalSubject:
153
155
  twelfth_house: KerykeionPointModel
154
156
 
155
157
  # Lists
156
- houses_list: list[KerykeionPointModel]
157
- planets_list: list[KerykeionPointModel]
158
- planets_degrees_ut: list[float]
159
- houses_degree_ut: list[float]
158
+ _houses_list: list[KerykeionPointModel]
159
+ _houses_degree_ut: list[float]
160
160
 
161
161
  # Enable or disable features
162
- disable_chiron: bool # Deprecated
162
+ disable_chiron: Union[None, bool]
163
163
  disable_chiron_and_lilith: bool
164
164
 
165
+ planets_names_list: list[Planet]
166
+ houses_names_list: list[Houses]
167
+
165
168
  def __init__(
166
169
  self,
167
170
  name="Now",
@@ -178,7 +181,7 @@ class AstrologicalSubject:
178
181
  geonames_username: Union[str, None] = None,
179
182
  zodiac_type: ZodiacType = DEFAULT_ZODIAC_TYPE,
180
183
  online: bool = True,
181
- disable_chiron: Union[None, bool] = None,
184
+ disable_chiron: Union[None, bool] = None, # Deprecated
182
185
  sidereal_mode: Union[SiderealMode, None] = None,
183
186
  houses_system_identifier: HousesSystemIdentifier = DEFAULT_HOUSES_SYSTEM_IDENTIFIER,
184
187
  perspective_type: PerspectiveType = DEFAULT_PERSPECTIVE_TYPE,
@@ -207,15 +210,9 @@ class AstrologicalSubject:
207
210
  self.day = day
208
211
  self.hour = hour
209
212
  self.minute = minute
210
- self.city = city
211
- self.nation = nation
212
- self.lng = lng
213
- self.lat = lat
214
- self.tz_str = tz_str
215
213
  self.zodiac_type = zodiac_type
216
214
  self.online = online
217
215
  self.json_dir = Path.home()
218
- self.geonames_username = geonames_username
219
216
  self.disable_chiron = disable_chiron
220
217
  self.sidereal_mode = sidereal_mode
221
218
  self.houses_system_identifier = houses_system_identifier
@@ -227,30 +224,46 @@ class AstrologicalSubject:
227
224
  # General setup #
228
225
  #---------------#
229
226
 
230
- # This message is set to encourage the user to set a custom geonames username
227
+ # Geonames username
231
228
  if geonames_username is None and online:
232
229
  logging.warning(GEONAMES_DEFAULT_USERNAME_WARNING)
233
-
234
230
  self.geonames_username = DEFAULT_GEONAMES_USERNAME
231
+ else:
232
+ self.geonames_username = geonames_username # type: ignore
235
233
 
236
- if not self.city:
234
+ # City
235
+ if not city:
237
236
  self.city = "London"
238
237
  logging.info("No city specified, using London as default")
238
+ else:
239
+ self.city = city
239
240
 
240
- if not self.nation:
241
+ # Nation
242
+ if not nation:
241
243
  self.nation = "GB"
242
244
  logging.info("No nation specified, using GB as default")
245
+ else:
246
+ self.nation = nation
243
247
 
244
- if not self.lat and not self.online:
248
+ # Latitude
249
+ if not lat and not self.online:
245
250
  self.lat = 51.5074
246
251
  logging.info("No latitude specified, using London as default")
247
-
248
- if not self.lng and not self.online:
252
+ else:
253
+ self.lat = lat # type: ignore
254
+
255
+ # Longitude
256
+ if not lng and not self.online:
249
257
  self.lng = 0
250
258
  logging.info("No longitude specified, using London as default")
259
+ else:
260
+ self.lng = lng # type: ignore
251
261
 
262
+ # Timezone
252
263
  if (not self.online) and (not tz_str):
253
264
  raise KerykeionException("You need to set the coordinates and timezone if you want to use the offline mode!")
265
+ else:
266
+ self.tz_str = tz_str # type: ignore
254
267
 
255
268
  #-----------------------#
256
269
  # Swiss Ephemeris setup #
@@ -298,7 +311,8 @@ class AstrologicalSubject:
298
311
 
299
312
  if self.zodiac_type == "Sidereal":
300
313
  # Check if the sidereal mode is valid
301
- if not self.sidereal_mode in get_args(SiderealMode):
314
+
315
+ if not self.sidereal_mode or not self.sidereal_mode in get_args(SiderealMode):
302
316
  raise KerykeionException(f"\n* ERROR: '{self.sidereal_mode}' is NOT a valid sidereal mode! Available modes are: *" + "\n" + str(get_args(SiderealMode)))
303
317
 
304
318
  self._iflag += swe.FLG_SIDEREAL
@@ -337,11 +351,9 @@ class AstrologicalSubject:
337
351
  self.julian_day = float(swe.julday(utc_object.year, utc_object.month, utc_object.day, utc_float_hour_with_minutes))
338
352
  # <--- UTC, julian day and local time setup
339
353
 
340
- self._planets_degrees_lister()
341
- self._planets()
342
- self._houses()
343
- self._planets_in_houses()
344
- self._lunar_phase_calc()
354
+ self._initialize_houses()
355
+ self._initialize_planets()
356
+ self._initialize_moon_phase()
345
357
 
346
358
  # Deprecated properties
347
359
  self.utc_time
@@ -383,7 +395,7 @@ class AstrologicalSubject:
383
395
  self.lat = float(self.city_data["lat"])
384
396
  self.tz_str = self.city_data["timezonestr"]
385
397
 
386
- def _houses(self) -> None:
398
+ def _initialize_houses(self) -> None:
387
399
  """
388
400
  Calculate positions and store them in dictionaries
389
401
 
@@ -418,7 +430,7 @@ class AstrologicalSubject:
418
430
  """
419
431
 
420
432
  if self.zodiac_type == "Sidereal":
421
- self.houses_degree_ut = swe.houses_ex(
433
+ self._houses_degree_ut = swe.houses_ex(
422
434
  tjdut=self.julian_day,
423
435
  lat=self.lat, lon=self.lng,
424
436
  hsys=str.encode(self.houses_system_identifier),
@@ -426,7 +438,7 @@ class AstrologicalSubject:
426
438
  )[0]
427
439
 
428
440
  elif self.zodiac_type == "Tropic":
429
- self.houses_degree_ut = swe.houses(
441
+ self._houses_degree_ut = swe.houses(
430
442
  tjdut=self.julian_day, lat=self.lat,
431
443
  lon=self.lng,
432
444
  hsys=str.encode(self.houses_system_identifier)
@@ -435,20 +447,23 @@ class AstrologicalSubject:
435
447
  point_type: PointType = "House"
436
448
 
437
449
  # stores the house in singular dictionaries.
438
- self.first_house = calculate_position(self.houses_degree_ut[0], "First_House", point_type=point_type)
439
- self.second_house = calculate_position(self.houses_degree_ut[1], "Second_House", point_type=point_type)
440
- self.third_house = calculate_position(self.houses_degree_ut[2], "Third_House", point_type=point_type)
441
- self.fourth_house = calculate_position(self.houses_degree_ut[3], "Fourth_House", point_type=point_type)
442
- self.fifth_house = calculate_position(self.houses_degree_ut[4], "Fifth_House", point_type=point_type)
443
- self.sixth_house = calculate_position(self.houses_degree_ut[5], "Sixth_House", point_type=point_type)
444
- self.seventh_house = calculate_position(self.houses_degree_ut[6], "Seventh_House", point_type=point_type)
445
- self.eighth_house = calculate_position(self.houses_degree_ut[7], "Eighth_House", point_type=point_type)
446
- self.ninth_house = calculate_position(self.houses_degree_ut[8], "Ninth_House", point_type=point_type)
447
- self.tenth_house = calculate_position(self.houses_degree_ut[9], "Tenth_House", point_type=point_type)
448
- self.eleventh_house = calculate_position(self.houses_degree_ut[10], "Eleventh_House", point_type=point_type)
449
- self.twelfth_house = calculate_position(self.houses_degree_ut[11], "Twelfth_House", point_type=point_type)
450
-
451
- self.houses_list = [
450
+ self.first_house = get_kerykeion_point_from_degree(self._houses_degree_ut[0], "First_House", point_type=point_type)
451
+ self.second_house = get_kerykeion_point_from_degree(self._houses_degree_ut[1], "Second_House", point_type=point_type)
452
+ self.third_house = get_kerykeion_point_from_degree(self._houses_degree_ut[2], "Third_House", point_type=point_type)
453
+ self.fourth_house = get_kerykeion_point_from_degree(self._houses_degree_ut[3], "Fourth_House", point_type=point_type)
454
+ self.fifth_house = get_kerykeion_point_from_degree(self._houses_degree_ut[4], "Fifth_House", point_type=point_type)
455
+ self.sixth_house = get_kerykeion_point_from_degree(self._houses_degree_ut[5], "Sixth_House", point_type=point_type)
456
+ self.seventh_house = get_kerykeion_point_from_degree(self._houses_degree_ut[6], "Seventh_House", point_type=point_type)
457
+ self.eighth_house = get_kerykeion_point_from_degree(self._houses_degree_ut[7], "Eighth_House", point_type=point_type)
458
+ self.ninth_house = get_kerykeion_point_from_degree(self._houses_degree_ut[8], "Ninth_House", point_type=point_type)
459
+ self.tenth_house = get_kerykeion_point_from_degree(self._houses_degree_ut[9], "Tenth_House", point_type=point_type)
460
+ self.eleventh_house = get_kerykeion_point_from_degree(self._houses_degree_ut[10], "Eleventh_House", point_type=point_type)
461
+ self.twelfth_house = get_kerykeion_point_from_degree(self._houses_degree_ut[11], "Twelfth_House", point_type=point_type)
462
+
463
+ self.houses_names_list = list(get_args(Houses))
464
+
465
+ # Deprecated
466
+ self._houses_list = [
452
467
  self.first_house,
453
468
  self.second_house,
454
469
  self.third_house,
@@ -463,10 +478,12 @@ class AstrologicalSubject:
463
478
  self.twelfth_house,
464
479
  ]
465
480
 
466
- def _planets_degrees_lister(self):
467
- """Sidereal or tropic mode."""
481
+ def _initialize_planets(self) -> None:
482
+ """Defines body positon in signs and information and
483
+ stores them in dictionaries"""
484
+
485
+ point_type: PointType = "Planet"
468
486
 
469
- # Calculates the position of the planets and stores it in a list.
470
487
  sun_deg = swe.calc(self.julian_day, 0, self._iflag)[0][0]
471
488
  moon_deg = swe.calc(self.julian_day, 1, self._iflag)[0][0]
472
489
  mercury_deg = swe.calc(self.julian_day, 2, self._iflag)[0][0]
@@ -480,79 +497,34 @@ class AstrologicalSubject:
480
497
  mean_node_deg = swe.calc(self.julian_day, 10, self._iflag)[0][0]
481
498
  true_node_deg = swe.calc(self.julian_day, 11, self._iflag)[0][0]
482
499
 
483
- self.planets_degrees_ut = [
484
- sun_deg,
485
- moon_deg,
486
- mercury_deg,
487
- venus_deg,
488
- mars_deg,
489
- jupiter_deg,
490
- saturn_deg,
491
- uranus_deg,
492
- neptune_deg,
493
- pluto_deg,
494
- mean_node_deg,
495
- true_node_deg,
496
- ]
497
-
498
- if not self.disable_chiron_and_lilith:
499
- chiron_deg = swe.calc(self.julian_day, 15, self._iflag)[0][0]
500
- self.planets_degrees_ut.append(chiron_deg)
501
-
502
- mean_lilith_deg = swe.calc(self.julian_day, 12, self._iflag)[0][0]
503
- self.planets_degrees_ut.append(mean_lilith_deg)
504
-
505
- else:
506
- self.chiron = None
507
- self.mean_lilith = None
508
-
509
-
510
- def _planets(self) -> None:
511
- """Defines body positon in signs and information and
512
- stores them in dictionaries"""
513
-
514
- point_type: PointType = "Planet"
515
- # stores the planets in singular dictionaries.
516
- self.sun = calculate_position(self.planets_degrees_ut[0], "Sun", point_type=point_type)
517
- self.moon = calculate_position(self.planets_degrees_ut[1], "Moon", point_type=point_type)
518
- self.mercury = calculate_position(self.planets_degrees_ut[2], "Mercury", point_type=point_type)
519
- self.venus = calculate_position(self.planets_degrees_ut[3], "Venus", point_type=point_type)
520
- self.mars = calculate_position(self.planets_degrees_ut[4], "Mars", point_type=point_type)
521
- self.jupiter = calculate_position(self.planets_degrees_ut[5], "Jupiter", point_type=point_type)
522
- self.saturn = calculate_position(self.planets_degrees_ut[6], "Saturn", point_type=point_type)
523
- self.uranus = calculate_position(self.planets_degrees_ut[7], "Uranus", point_type=point_type)
524
- self.neptune = calculate_position(self.planets_degrees_ut[8], "Neptune", point_type=point_type)
525
- self.pluto = calculate_position(self.planets_degrees_ut[9], "Pluto", point_type=point_type)
526
- self.mean_node = calculate_position(self.planets_degrees_ut[10], "Mean_Node", point_type=point_type)
527
- self.true_node = calculate_position(self.planets_degrees_ut[11], "True_Node", point_type=point_type)
528
-
529
- if not self.disable_chiron_and_lilith:
530
- self.chiron = calculate_position(self.planets_degrees_ut[12], "Chiron", point_type=point_type)
531
- self.mean_lilith = calculate_position(self.planets_degrees_ut[13], "Mean_Lilith", point_type=point_type)
532
-
533
- else:
534
- self.chiron = None
535
- self.mean_lilith = None
536
-
537
-
538
- def _planets_in_houses(self) -> None:
539
- """Calculates the house of the planet and updates
540
- the planets dictionary."""
541
-
542
- self.sun.house = get_planet_house(self.planets_degrees_ut[0], self.houses_degree_ut)
543
- self.moon.house = get_planet_house(self.planets_degrees_ut[1], self.houses_degree_ut)
544
- self.mercury.house = get_planet_house(self.planets_degrees_ut[2], self.houses_degree_ut)
545
- self.venus.house = get_planet_house(self.planets_degrees_ut[3], self.houses_degree_ut)
546
- self.mars.house = get_planet_house(self.planets_degrees_ut[4], self.houses_degree_ut)
547
- self.jupiter.house = get_planet_house(self.planets_degrees_ut[5], self.houses_degree_ut)
548
- self.saturn.house = get_planet_house(self.planets_degrees_ut[6], self.houses_degree_ut)
549
- self.uranus.house = get_planet_house(self.planets_degrees_ut[7], self.houses_degree_ut)
550
- self.neptune.house = get_planet_house(self.planets_degrees_ut[8], self.houses_degree_ut)
551
- self.pluto.house = get_planet_house(self.planets_degrees_ut[9], self.houses_degree_ut)
552
- self.mean_node.house = get_planet_house(self.planets_degrees_ut[10], self.houses_degree_ut)
553
- self.true_node.house = get_planet_house(self.planets_degrees_ut[11], self.houses_degree_ut)
554
-
555
- self.planets_list = [
500
+ self.sun = get_kerykeion_point_from_degree(sun_deg, "Sun", point_type=point_type)
501
+ self.moon = get_kerykeion_point_from_degree(moon_deg, "Moon", point_type=point_type)
502
+ self.mercury = get_kerykeion_point_from_degree(mercury_deg, "Mercury", point_type=point_type)
503
+ self.venus = get_kerykeion_point_from_degree(venus_deg, "Venus", point_type=point_type)
504
+ self.mars = get_kerykeion_point_from_degree(mars_deg, "Mars", point_type=point_type)
505
+ self.jupiter = get_kerykeion_point_from_degree(jupiter_deg, "Jupiter", point_type=point_type)
506
+ self.saturn = get_kerykeion_point_from_degree(saturn_deg, "Saturn", point_type=point_type)
507
+ self.uranus = get_kerykeion_point_from_degree(uranus_deg, "Uranus", point_type=point_type)
508
+ self.neptune = get_kerykeion_point_from_degree(neptune_deg, "Neptune", point_type=point_type)
509
+ self.pluto = get_kerykeion_point_from_degree(pluto_deg, "Pluto", point_type=point_type)
510
+ self.mean_node = get_kerykeion_point_from_degree(mean_node_deg, "Mean_Node", point_type=point_type)
511
+ self.true_node = get_kerykeion_point_from_degree(true_node_deg, "True_Node", point_type=point_type)
512
+
513
+ self.sun.house = get_planet_house(sun_deg, self._houses_degree_ut)
514
+ self.moon.house = get_planet_house(moon_deg, self._houses_degree_ut)
515
+ self.mercury.house = get_planet_house(mercury_deg, self._houses_degree_ut)
516
+ self.venus.house = get_planet_house(venus_deg, self._houses_degree_ut)
517
+ self.mars.house = get_planet_house(mars_deg, self._houses_degree_ut)
518
+ self.jupiter.house = get_planet_house(jupiter_deg, self._houses_degree_ut)
519
+ self.saturn.house = get_planet_house(saturn_deg, self._houses_degree_ut)
520
+ self.uranus.house = get_planet_house(uranus_deg, self._houses_degree_ut)
521
+ self.neptune.house = get_planet_house(neptune_deg, self._houses_degree_ut)
522
+ self.pluto.house = get_planet_house(pluto_deg, self._houses_degree_ut)
523
+ self.mean_node.house = get_planet_house(mean_node_deg, self._houses_degree_ut)
524
+ self.true_node.house = get_planet_house(true_node_deg, self._houses_degree_ut)
525
+
526
+ # Deprecated
527
+ planets_list = [
556
528
  self.sun,
557
529
  self.moon,
558
530
  self.mercury,
@@ -566,91 +538,70 @@ class AstrologicalSubject:
566
538
  self.mean_node,
567
539
  self.true_node,
568
540
  ]
569
-
541
+
570
542
  if not self.disable_chiron_and_lilith:
571
- self.chiron.house = get_planet_house(self.planets_degrees_ut[12], self.houses_degree_ut)
572
- self.planets_list.append(self.chiron)
543
+ chiron_deg = swe.calc(self.julian_day, 15, self._iflag)[0][0]
544
+ mean_lilith_deg = swe.calc(self.julian_day, 12, self._iflag)[0][0]
573
545
 
574
- self.mean_lilith.house = get_planet_house(self.planets_degrees_ut[13], self.houses_degree_ut)
575
- self.planets_list.append(self.mean_lilith)
546
+ self.chiron = get_kerykeion_point_from_degree(chiron_deg, "Chiron", point_type=point_type)
547
+ self.mean_lilith = get_kerykeion_point_from_degree(mean_lilith_deg, "Mean_Lilith", point_type=point_type)
548
+
549
+ self.chiron.house = get_planet_house(chiron_deg, self._houses_degree_ut)
550
+ self.mean_lilith.house = get_planet_house(mean_lilith_deg, self._houses_degree_ut)
551
+
552
+ # Deprecated
553
+ planets_list.append(self.chiron)
554
+ planets_list.append(self.mean_lilith)
576
555
 
577
556
  else:
578
557
  self.chiron = None
579
558
  self.mean_lilith = None
580
559
 
560
+ # FIXME: Update after removing planets_list
561
+ self.planets_names_list = [planet["name"] for planet in planets_list]
562
+
581
563
  # Check in retrograde or not:
582
- planets_ret = []
583
- for planet in self.planets_list:
564
+ for planet in planets_list:
584
565
  planet_number = get_number_from_name(planet["name"])
585
566
  if swe.calc(self.julian_day, planet_number, self._iflag)[0][3] < 0:
586
567
  planet["retrograde"] = True
587
568
  else:
588
569
  planet["retrograde"] = False
589
- planets_ret.append(planet)
590
570
 
591
- def _lunar_phase_calc(self) -> None:
592
- """Function to calculate the lunar phase"""
593
571
 
594
- # If ther's an error:
595
- moon_phase, sun_phase = None, None
572
+ def _initialize_moon_phase(self) -> None:
573
+ """
574
+ Calculate and initialize the lunar phase based on the positions of the moon and sun.
596
575
 
597
- # anti-clockwise degrees between sun and moon
598
- moon, sun = self.planets_degrees_ut[1], self.planets_degrees_ut[0]
599
- degrees_between = moon - sun
576
+ This function calculates the degrees between the moon and the sun, determines the moon phase
577
+ and sun phase, and initializes the lunar phase model with the calculated values.
578
+ """
579
+ # Initialize moon_phase and sun_phase to None in case of an error
580
+ moon_phase, sun_phase = None, None
600
581
 
601
- if degrees_between < 0:
602
- degrees_between += 360.0
582
+ # Calculate the anti-clockwise degrees between the sun and moon
583
+ moon, sun = self.moon.abs_pos, self.sun.abs_pos
584
+ degrees_between = (moon - sun) % 360
603
585
 
586
+ # Calculate the moon phase (1-28) based on the degrees between the sun and moon
604
587
  step = 360.0 / 28.0
588
+ moon_phase = int(degrees_between // step) + 1
605
589
 
606
- for x in range(28):
607
- low = x * step
608
- high = (x + 1) * step
609
-
610
- if degrees_between >= low and degrees_between < high:
611
- moon_phase = x + 1
612
-
590
+ # Define the sun phase steps
613
591
  sunstep = [
614
- 0,
615
- 30,
616
- 40,
617
- 50,
618
- 60,
619
- 70,
620
- 80,
621
- 90,
622
- 120,
623
- 130,
624
- 140,
625
- 150,
626
- 160,
627
- 170,
628
- 180,
629
- 210,
630
- 220,
631
- 230,
632
- 240,
633
- 250,
634
- 260,
635
- 270,
636
- 300,
637
- 310,
638
- 320,
639
- 330,
640
- 340,
641
- 350,
592
+ 0, 30, 40, 50, 60, 70, 80, 90, 120, 130, 140, 150, 160, 170, 180,
593
+ 210, 220, 230, 240, 250, 260, 270, 300, 310, 320, 330, 340, 350
642
594
  ]
643
595
 
596
+ # Calculate the sun phase (1-28) based on the degrees between the sun and moon
644
597
  for x in range(len(sunstep)):
645
598
  low = sunstep[x]
646
-
647
- if x == 27:
648
- high = 360
649
- else:
650
- high = sunstep[x + 1]
651
- if degrees_between >= low and degrees_between < high:
599
+ high = sunstep[x + 1] if x < len(sunstep) - 1 else 360
600
+ if low <= degrees_between < high:
652
601
  sun_phase = x + 1
602
+ break
653
603
 
604
+ # Create a dictionary with the lunar phase information
654
605
  lunar_phase_dictionary = {
655
606
  "degrees_between_s_m": degrees_between,
656
607
  "moon_phase": moon_phase,
@@ -659,6 +610,7 @@ class AstrologicalSubject:
659
610
  "moon_phase_name": get_moon_phase_name_from_phase_int(moon_phase)
660
611
  }
661
612
 
613
+ # Initialize the lunar phase model with the calculated values
662
614
  self.lunar_phase = LunarPhaseModel(**lunar_phase_dictionary)
663
615
 
664
616
  def json(self, dump=False, destination_folder: Union[str, None] = None, indent: Union[int, None] = None) -> str:
@@ -860,3 +812,7 @@ if __name__ == "__main__":
860
812
  # Test Mean Lilith
861
813
  johnny = AstrologicalSubject("Johnny Depp", 1963, 6, 9, 0, 0, "Owensboro", "US", disable_chiron_and_lilith=True)
862
814
  print(johnny.mean_lilith)
815
+
816
+ # Offline mode
817
+ johnny = AstrologicalSubject("Johnny Depp", 1963, 6, 9, 0, 0, "Owensboro", "US", online=False, tz_str="America/New_York", lng=-87.1111, lat=37.7711)
818
+ print(johnny.json(dump=True, indent=2))