# kerykeion.transits_time_range

View Source

      1from typing import Optional, Union, List
      2from datetime import datetime, timedelta
      3from kerykeion import AstrologicalSubject, SynastryAspects
      4from kerykeion.ephemeris_data import EphemerisDataFactory
      5from kerykeion.kr_types.kr_literals import AxialCusps, Planet
      6from kerykeion.kr_types.kr_models import ActiveAspect, TransitMomentModel, TransitsTimeRangeModel
      7from kerykeion.settings.config_constants import DEFAULT_ACTIVE_POINTS, DEFAULT_ACTIVE_ASPECTS
      8
      9
     10class TransitsTimeRangeFactory:
     11    """
     12    Factory class for generating astrological transit data over a period of time.
     13
     14    This class compares the positions of celestial bodies at different points in time
     15    with the natal chart of an astrological subject to identify significant aspects
     16    and produces structured models containing the transit data.
     17
     18    Attributes:
     19        natal_chart: The natal chart of the subject for whom transits are calculated.
     20        ephemeris_data_points: List of ephemeris data points representing planetary positions at different times.
     21        active_points: List of celestial points to consider when calculating aspects.
     22        active_aspects: List of aspect types to consider when analyzing planetary relationships.
     23        settings_file: Path to custom settings file for aspect calculations (optional).
     24    """
     25
     26    def __init__(
     27        self,
     28        natal_chart: AstrologicalSubject,
     29        ephemeris_data_points: List[AstrologicalSubject],
     30        active_points: List[Union[AxialCusps, Planet]] = DEFAULT_ACTIVE_POINTS,
     31        active_aspects: List[ActiveAspect] = DEFAULT_ACTIVE_ASPECTS,
     32        settings_file: Optional[str] = None
     33    ):
     34        """
     35        Initialize the TransitMomentsFactory with the necessary data.
     36
     37        Args:
     38            natal_chart: The natal chart of the subject for whom transits are calculated.
     39            ephemeris_data_points: List of ephemeris data points representing planetary positions at different times.
     40            active_points: List of celestial points to consider when calculating aspects.
     41            active_aspects: List of aspect types to consider when analyzing planetary relationships.
     42            settings_file: Path to custom settings file for aspect calculations (optional).
     43        """
     44        self.natal_chart = natal_chart
     45        self.ephemeris_data_points = ephemeris_data_points
     46        self.active_points = active_points
     47        self.active_aspects = active_aspects
     48        self.settings_file = settings_file
     49
     50    def get_transit_moments(self) -> TransitsTimeRangeModel:
     51        """
     52        Generate a model of transit moments for the given subject across all ephemeris data points.
     53
     54        This method compares the positions of celestial bodies at different points in time
     55        with the natal chart of the subject to identify significant aspects and
     56        compiles them into a structured model for analysis.
     57
     58        Returns:
     59            TransitMomentsListModel: A model containing all transit data, including aspects,
     60                                    dates, and subject information.
     61        """
     62        transit_moments = []
     63
     64        for ephemeris_point in self.ephemeris_data_points:
     65            # Calculate aspects between transit positions and natal chart
     66            aspects = SynastryAspects(
     67                ephemeris_point,
     68                self.natal_chart,
     69                active_points=self.active_points,
     70                active_aspects=self.active_aspects,
     71                new_settings_file=self.settings_file,
     72            ).relevant_aspects
     73
     74            # Create a transit moment for this point in time
     75            transit_moments.append(
     76                TransitMomentModel(
     77                    date=ephemeris_point.iso_formatted_utc_datetime,
     78                    aspects=aspects,
     79                )
     80            )
     81
     82        # Create and return the complete transits model
     83        return TransitsTimeRangeModel(
     84            dates=[point.iso_formatted_utc_datetime for point in self.ephemeris_data_points],
     85            subject=self.natal_chart.model(),
     86            transits=transit_moments
     87        )
     88
     89
     90if __name__ == "__main__":
     91    # Create a natal chart for the subject
     92    person = AstrologicalSubject(
     93        "Johnny Depp", 1963, 6, 9, 20, 15, "Owensboro", "US"
     94    )
     95
     96    # Define the time period for transit calculation
     97    start_date = datetime.now()
     98    end_date = datetime.now() + timedelta(days=30)
     99
    100    # Create ephemeris data for the specified time period
    101    ephemeris_factory = EphemerisDataFactory(
    102        start_datetime=start_date,
    103        end_datetime=end_date,
    104        step_type="days",
    105        step=1,
    106        lat=person.lat,
    107        lng=person.lng,
    108        tz_str=person.tz_str,
    109    )
    110
    111    ephemeris_data_points = ephemeris_factory.get_ephemeris_data_as_astrological_subjects()
    112
    113    # Calculate transits for the subject
    114    transit_factory = TransitsTimeRangeFactory(
    115        natal_chart=person,
    116        ephemeris_data_points=ephemeris_data_points,
    117    )
    118
    119    transit_results = transit_factory.get_transit_moments()
    120
    121    # Print example data
    122    print(transit_results.model_dump()["dates"][2])
    123    print(transit_results.model_dump()["transits"][2]['date'])
    124    print(transit_results.model_dump()["transits"][2]['aspects'][0])

class TransitsTimeRangeFactory: View Source

    11class TransitsTimeRangeFactory:
    12    """
    13    Factory class for generating astrological transit data over a period of time.
    14
    15    This class compares the positions of celestial bodies at different points in time
    16    with the natal chart of an astrological subject to identify significant aspects
    17    and produces structured models containing the transit data.
    18
    19    Attributes:
    20        natal_chart: The natal chart of the subject for whom transits are calculated.
    21        ephemeris_data_points: List of ephemeris data points representing planetary positions at different times.
    22        active_points: List of celestial points to consider when calculating aspects.
    23        active_aspects: List of aspect types to consider when analyzing planetary relationships.
    24        settings_file: Path to custom settings file for aspect calculations (optional).
    25    """
    26
    27    def __init__(
    28        self,
    29        natal_chart: AstrologicalSubject,
    30        ephemeris_data_points: List[AstrologicalSubject],
    31        active_points: List[Union[AxialCusps, Planet]] = DEFAULT_ACTIVE_POINTS,
    32        active_aspects: List[ActiveAspect] = DEFAULT_ACTIVE_ASPECTS,
    33        settings_file: Optional[str] = None
    34    ):
    35        """
    36        Initialize the TransitMomentsFactory with the necessary data.
    37
    38        Args:
    39            natal_chart: The natal chart of the subject for whom transits are calculated.
    40            ephemeris_data_points: List of ephemeris data points representing planetary positions at different times.
    41            active_points: List of celestial points to consider when calculating aspects.
    42            active_aspects: List of aspect types to consider when analyzing planetary relationships.
    43            settings_file: Path to custom settings file for aspect calculations (optional).
    44        """
    45        self.natal_chart = natal_chart
    46        self.ephemeris_data_points = ephemeris_data_points
    47        self.active_points = active_points
    48        self.active_aspects = active_aspects
    49        self.settings_file = settings_file
    50
    51    def get_transit_moments(self) -> TransitsTimeRangeModel:
    52        """
    53        Generate a model of transit moments for the given subject across all ephemeris data points.
    54
    55        This method compares the positions of celestial bodies at different points in time
    56        with the natal chart of the subject to identify significant aspects and
    57        compiles them into a structured model for analysis.
    58
    59        Returns:
    60            TransitMomentsListModel: A model containing all transit data, including aspects,
    61                                    dates, and subject information.
    62        """
    63        transit_moments = []
    64
    65        for ephemeris_point in self.ephemeris_data_points:
    66            # Calculate aspects between transit positions and natal chart
    67            aspects = SynastryAspects(
    68                ephemeris_point,
    69                self.natal_chart,
    70                active_points=self.active_points,
    71                active_aspects=self.active_aspects,
    72                new_settings_file=self.settings_file,
    73            ).relevant_aspects
    74
    75            # Create a transit moment for this point in time
    76            transit_moments.append(
    77                TransitMomentModel(
    78                    date=ephemeris_point.iso_formatted_utc_datetime,
    79                    aspects=aspects,
    80                )
    81            )
    82
    83        # Create and return the complete transits model
    84        return TransitsTimeRangeModel(
    85            dates=[point.iso_formatted_utc_datetime for point in self.ephemeris_data_points],
    86            subject=self.natal_chart.model(),
    87            transits=transit_moments
    88        )

Factory class for generating astrological transit data over a period of time.

This class compares the positions of celestial bodies at different points in time with the natal chart of an astrological subject to identify significant aspects and produces structured models containing the transit data.

Attributes: natal_chart: The natal chart of the subject for whom transits are calculated. ephemeris_data_points: List of ephemeris data points representing planetary positions at different times. active_points: List of celestial points to consider when calculating aspects. active_aspects: List of aspect types to consider when analyzing planetary relationships. settings_file: Path to custom settings file for aspect calculations (optional).

TransitsTimeRangeFactory( natal_chart: kerykeion.astrological_subject.AstrologicalSubject, ephemeris_data_points: List[kerykeion.astrological_subject.AstrologicalSubject], active_points: List[Union[Literal['Sun', 'Moon', 'Mercury', 'Venus', 'Mars', 'Jupiter', 'Saturn', 'Uranus', 'Neptune', 'Pluto', 'Mean_Node', 'True_Node', 'Mean_South_Node', 'True_South_Node', 'Chiron', 'Mean_Lilith'], Literal['Ascendant', 'Medium_Coeli', 'Descendant', 'Imum_Coeli']]] = ['Sun', 'Moon', 'Mercury', 'Venus', 'Mars', 'Jupiter', 'Saturn', 'Uranus', 'Neptune', 'Pluto', 'Mean_Node', 'Chiron', 'Ascendant', 'Medium_Coeli', 'Mean_Lilith', 'Mean_South_Node'], active_aspects: List[kerykeion.kr_types.kr_models.ActiveAspect] = [{'name': 'conjunction', 'orb': 10}, {'name': 'opposition', 'orb': 10}, {'name': 'trine', 'orb': 8}, {'name': 'sextile', 'orb': 6}, {'name': 'square', 'orb': 5}, {'name': 'quintile', 'orb': 1}], settings_file: Optional[str] = None) View Source

    27    def __init__(
    28        self,
    29        natal_chart: AstrologicalSubject,
    30        ephemeris_data_points: List[AstrologicalSubject],
    31        active_points: List[Union[AxialCusps, Planet]] = DEFAULT_ACTIVE_POINTS,
    32        active_aspects: List[ActiveAspect] = DEFAULT_ACTIVE_ASPECTS,
    33        settings_file: Optional[str] = None
    34    ):
    35        """
    36        Initialize the TransitMomentsFactory with the necessary data.
    37
    38        Args:
    39            natal_chart: The natal chart of the subject for whom transits are calculated.
    40            ephemeris_data_points: List of ephemeris data points representing planetary positions at different times.
    41            active_points: List of celestial points to consider when calculating aspects.
    42            active_aspects: List of aspect types to consider when analyzing planetary relationships.
    43            settings_file: Path to custom settings file for aspect calculations (optional).
    44        """
    45        self.natal_chart = natal_chart
    46        self.ephemeris_data_points = ephemeris_data_points
    47        self.active_points = active_points
    48        self.active_aspects = active_aspects
    49        self.settings_file = settings_file

Initialize the TransitMomentsFactory with the necessary data.

Args: natal_chart: The natal chart of the subject for whom transits are calculated. ephemeris_data_points: List of ephemeris data points representing planetary positions at different times. active_points: List of celestial points to consider when calculating aspects. active_aspects: List of aspect types to consider when analyzing planetary relationships. settings_file: Path to custom settings file for aspect calculations (optional).

natal_chart
ephemeris_data_points
active_points
active_aspects
settings_file
def get_transit_moments(self) -> kerykeion.kr_types.kr_models.TransitsTimeRangeModel: View Source

    51    def get_transit_moments(self) -> TransitsTimeRangeModel:
    52        """
    53        Generate a model of transit moments for the given subject across all ephemeris data points.
    54
    55        This method compares the positions of celestial bodies at different points in time
    56        with the natal chart of the subject to identify significant aspects and
    57        compiles them into a structured model for analysis.
    58
    59        Returns:
    60            TransitMomentsListModel: A model containing all transit data, including aspects,
    61                                    dates, and subject information.
    62        """
    63        transit_moments = []
    64
    65        for ephemeris_point in self.ephemeris_data_points:
    66            # Calculate aspects between transit positions and natal chart
    67            aspects = SynastryAspects(
    68                ephemeris_point,
    69                self.natal_chart,
    70                active_points=self.active_points,
    71                active_aspects=self.active_aspects,
    72                new_settings_file=self.settings_file,
    73            ).relevant_aspects
    74
    75            # Create a transit moment for this point in time
    76            transit_moments.append(
    77                TransitMomentModel(
    78                    date=ephemeris_point.iso_formatted_utc_datetime,
    79                    aspects=aspects,
    80                )
    81            )
    82
    83        # Create and return the complete transits model
    84        return TransitsTimeRangeModel(
    85            dates=[point.iso_formatted_utc_datetime for point in self.ephemeris_data_points],
    86            subject=self.natal_chart.model(),
    87            transits=transit_moments
    88        )

Generate a model of transit moments for the given subject across all ephemeris data points.

This method compares the positions of celestial bodies at different points in time with the natal chart of the subject to identify significant aspects and compiles them into a structured model for analysis.

Returns: TransitMomentsListModel: A model containing all transit data, including aspects, dates, and subject information.