Skip to content

Commit

Permalink
Release version 4.5.0
Browse files Browse the repository at this point in the history
- Chiron has been made deactivatable. Chiron calculation can create some
issues with the Swiss Ephemeris when the date is too far in the past.
By default is allways active.

- Created new enum module, to be expanded in the future.

- Reformatted utils module.
  • Loading branch information
g-battaglia committed May 13, 2024
1 parent 06559f1 commit 3953306
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 19 deletions.
1 change: 1 addition & 0 deletions kerykeion/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,4 @@
from .aspects import SynastryAspects, NatalAspects
from .report import Report
from .settings import KerykeionSettingsModel, get_settings
from .enums import Planets, Aspects, Signs
43 changes: 36 additions & 7 deletions kerykeion/astrological_subject.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ class AstrologicalSubject:
- utc_datetime (datetime, optional): An alternative way of constructing the object,
if you know the UTC datetime but do not have easy access to e.g. timezone identifier
_ Defaults to None.
- disable_chiron (bool, optional): Disables the calculation of Chiron. Defaults to False.
Chiron calculation can create some issues with the Swiss Ephemeris when the date is too far in the past.
"""

# Defined by the user
Expand Down Expand Up @@ -91,7 +93,7 @@ class AstrologicalSubject:
pluto: KerykeionPointModel
true_node: KerykeionPointModel
mean_node: KerykeionPointModel
chiron: KerykeionPointModel
chiron: KerykeionPointModel | None

# Houses
first_house: KerykeionPointModel
Expand Down Expand Up @@ -132,6 +134,7 @@ def __init__(
zodiac_type: ZodiacType = "Tropic",
online: bool = True,
utc_datetime: Union[datetime, None] = None,
disable_chiron: bool = False
) -> None:
logging.debug("Starting Kerykeion")

Expand All @@ -158,6 +161,7 @@ def __init__(
self.json_dir = Path.home()
self.geonames_username = geonames_username
self.utc_datetime = utc_datetime
self.disable_chiron = disable_chiron

# This message is set to encourage the user to set a custom geonames username
if geonames_username is None and online:
Expand Down Expand Up @@ -375,7 +379,11 @@ def _planets_degrees_lister(self):
pluto_deg = swe.calc(self.julian_day, 9, self._iflag)[0][0]
mean_node_deg = swe.calc(self.julian_day, 10, self._iflag)[0][0]
true_node_deg = swe.calc(self.julian_day, 11, self._iflag)[0][0]
chiron_deg = swe.calc(self.julian_day, 15, self._iflag)[0][0]

if not self.disable_chiron:
chiron_deg = swe.calc(self.julian_day, 15, self._iflag)[0][0]
else:
chiron_deg = 0

self.planets_degrees_ut = [
sun_deg,
Expand All @@ -390,8 +398,10 @@ def _planets_degrees_lister(self):
pluto_deg,
mean_node_deg,
true_node_deg,
chiron_deg,
]

if not self.disable_chiron:
self.planets_degrees_ut.append(chiron_deg)

def _planets(self) -> None:
"""Defines body positon in signs and information and
Expand All @@ -411,7 +421,11 @@ def _planets(self) -> None:
self.pluto = calculate_position(self.planets_degrees_ut[9], "Pluto", point_type=point_type)
self.mean_node = calculate_position(self.planets_degrees_ut[10], "Mean_Node", point_type=point_type)
self.true_node = calculate_position(self.planets_degrees_ut[11], "True_Node", point_type=point_type)
self.chiron = calculate_position(self.planets_degrees_ut[12], "Chiron", point_type=point_type)

if not self.disable_chiron:
self.chiron = calculate_position(self.planets_degrees_ut[12], "Chiron", point_type=point_type)
else:
self.chiron = None

def _planets_in_houses(self) -> None:
"""Calculates the house of the planet and updates
Expand Down Expand Up @@ -472,7 +486,11 @@ def point_between(p1, p2, p3):
self.pluto = for_every_planet(self.pluto, self.planets_degrees_ut[9])
self.mean_node = for_every_planet(self.mean_node, self.planets_degrees_ut[10])
self.true_node = for_every_planet(self.true_node, self.planets_degrees_ut[11])
self.chiron = for_every_planet(self.chiron, self.planets_degrees_ut[12])

if not self.disable_chiron:
self.chiron = for_every_planet(self.chiron, self.planets_degrees_ut[12])
else:
self.chiron = None

self.planets_list = [
self.sun,
Expand All @@ -487,8 +505,10 @@ def point_between(p1, p2, p3):
self.pluto,
self.mean_node,
self.true_node,
self.chiron
]

if not self.disable_chiron:
self.planets_list.append(self.chiron)

# Check in retrograde or not:
planets_ret = []
Expand Down Expand Up @@ -643,10 +663,19 @@ def model(self) -> AstrologicalSubjectModel:
if __name__ == "__main__":
import json
from kerykeion.utilities import setup_logging
setup_logging(level="debug")

setup_logging(level="debug")

# With Chiron enabled
johnny = AstrologicalSubject("Johnny Depp", 1963, 6, 9, 0, 0, "Owensboro", "US")
print(json.loads(johnny.json(dump=True)))

print('\n')
print(johnny.chiron)

# With Chiron disabled
johnny = AstrologicalSubject("Johnny Depp", 1963, 6, 9, 0, 0, "Owensboro", "US", disable_chiron=True)
print(json.loads(johnny.json(dump=True)))

print('\n')
print(johnny.chiron)
50 changes: 50 additions & 0 deletions kerykeion/enums.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
from enum import Enum


class Planets(Enum):
SUN = "Sun"
MOON = "Moon"
MERCURY = "Mercury"
VENUS = "Venus"
MARS = "Mars"
JUPITER = "Jupiter"
SATURN = "Saturn"
URANUS = "Uranus"
NEPTUNE = "Neptune"
PLUTO = "Pluto"
CHIRON = "Chiron"
TRUE_NODE = "True_Node"
MEAN_NODE = "Mean_Node"


class Aspects(Enum):
CONJUNCTION = "Conjunction"
SEXTILE = "Sextile"
SEMI_SEXTILE = "Semi-Sextile"
SQUARE = "Square"
TRINE = "Trine"
OPPOSITION = "Opposition"
QUINCUNX = "Quincunx"
NONE = None
QUINTILE = "Quintile"
BIQUINTILE = "Biquintile"
OCTILE = "Octile"
TRIOCTILE = "Trioctile"
DECILE = "Decile"
TRIDECILE = "Tridecile"
SESQUIQUADRATE = "Sesquiquadrate"


class Signs(Enum):
ARI = "Ari"
TAU = "Tau"
GEM = "Gem"
CAN = "Can"
LEO = "Leo"
VIR = "Vir"
LIB = "Lib"
SCO = "Sco"
SAG = "Sag"
CAP = "Cap"
AQU = "Aqu"
PIS = "Pis"
2 changes: 1 addition & 1 deletion kerykeion/kr_types/kr_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class AstrologicalSubjectModel(BaseModel):
uranus: KerykeionPointModel
neptune: KerykeionPointModel
pluto: KerykeionPointModel
chiron: KerykeionPointModel
chiron: KerykeionPointModel | None

# Houses
first_house: KerykeionPointModel
Expand Down
25 changes: 15 additions & 10 deletions kerykeion/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,15 +203,20 @@ def calculate_position(

return KerykeionPointModel(**dictionary)


def setup_logging(level: str) -> None:
"""Setup logging for testing.
"""
Setup logging for testing.
Args:
level: Log level as a string, options: debug, info, warning, error"""
logopt: dict[str, int] = {"debug": logging.DEBUG,
"info": logging.INFO,
"warning": logging.WARNING ,
"error": logging.ERROR}
format: str = "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
loglevel: int = logopt.get(level, logging.INFO)
logging.basicConfig(format=format, level=loglevel)
level: Log level as a string, options: debug, info, warning, error
"""
logopt: dict[str, int] = {
"debug": logging.DEBUG,
"info": logging.INFO,
"warning": logging.WARNING,
"error": logging.ERROR,
}
format: str = "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
loglevel: int = logopt.get(level, logging.INFO)
logging.basicConfig(format=format, level=loglevel)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "kerykeion"
version = "4.4.2"
version = "4.5.0"
authors = ["Giacomo Battaglia <battaglia.giacomo@yahoo.it>"]
description = "A python library for astrology."
license = "AGPL-3.0"
Expand Down

0 comments on commit 3953306

Please sign in to comment.