kerykeion 5.0.0a10__py3-none-any.whl → 5.0.0a11__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.
- kerykeion/__init__.py +2 -6
- kerykeion/aspects/natal_aspects_factory.py +3 -4
- kerykeion/aspects/synastry_aspects_factory.py +69 -28
- kerykeion/astrological_subject_factory.py +683 -77
- kerykeion/charts/draw_planets.py +584 -343
- kerykeion/charts/kerykeion_chart_svg.py +2 -7
- kerykeion/charts/templates/wheel_only.xml +1 -1
- kerykeion/composite_subject_factory.py +228 -9
- kerykeion/ephemeris_data_factory.py +431 -0
- kerykeion/fetch_geonames.py +27 -8
- kerykeion/kr_types/kerykeion_exception.py +6 -0
- kerykeion/kr_types/kr_models.py +55 -2
- kerykeion/planetary_return_factory.py +532 -32
- kerykeion/relationship_score_factory.py +96 -42
- kerykeion/report.py +7 -0
- kerykeion/transits_time_range_factory.py +293 -0
- kerykeion/utilities.py +129 -67
- {kerykeion-5.0.0a10.dist-info → kerykeion-5.0.0a11.dist-info}/METADATA +1 -1
- {kerykeion-5.0.0a10.dist-info → kerykeion-5.0.0a11.dist-info}/RECORD +21 -24
- kerykeion/charts/draw_planets_v2.py +0 -648
- kerykeion/charts/draw_planets_v3.py +0 -679
- kerykeion/enums.py +0 -57
- kerykeion/ephemeris_data.py +0 -238
- kerykeion/transits_time_range.py +0 -128
- {kerykeion-5.0.0a10.dist-info → kerykeion-5.0.0a11.dist-info}/WHEEL +0 -0
- {kerykeion-5.0.0a10.dist-info → kerykeion-5.0.0a11.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Ephemeris Data Factory Module
|
|
3
|
+
|
|
4
|
+
This module provides the EphemerisDataFactory class for generating time-series
|
|
5
|
+
astrological ephemeris data. It enables the creation of comprehensive astronomical
|
|
6
|
+
and astrological datasets across specified date ranges with flexible time intervals
|
|
7
|
+
and calculation parameters.
|
|
8
|
+
|
|
9
|
+
Key Features:
|
|
10
|
+
- Time-series ephemeris data generation
|
|
11
|
+
- Multiple time interval support (days, hours, minutes)
|
|
12
|
+
- Configurable astrological calculation systems
|
|
13
|
+
- Built-in performance safeguards and limits
|
|
14
|
+
- Multiple output formats (dictionaries or model instances)
|
|
15
|
+
- Complete AstrologicalSubject instance generation
|
|
16
|
+
|
|
17
|
+
The module supports both lightweight data extraction (via get_ephemeris_data)
|
|
18
|
+
and full-featured astrological analysis (via get_ephemeris_data_as_astrological_subjects),
|
|
19
|
+
making it suitable for various use cases from simple data collection to complex
|
|
20
|
+
astrological research and analysis applications.
|
|
21
|
+
|
|
22
|
+
Classes:
|
|
23
|
+
EphemerisDataFactory: Main factory class for generating ephemeris data
|
|
24
|
+
|
|
25
|
+
Dependencies:
|
|
26
|
+
- kerykeion.AstrologicalSubjectFactory: For creating astrological subjects
|
|
27
|
+
- kerykeion.utilities: For house and planetary data extraction
|
|
28
|
+
- kerykeion.kr_types: For type definitions and model structures
|
|
29
|
+
- datetime: For date/time handling
|
|
30
|
+
- logging: For performance warnings
|
|
31
|
+
|
|
32
|
+
Example:
|
|
33
|
+
Basic usage for daily ephemeris data:
|
|
34
|
+
|
|
35
|
+
>>> from datetime import datetime
|
|
36
|
+
>>> from kerykeion.ephemeris_data_factory import EphemerisDataFactory
|
|
37
|
+
>>>
|
|
38
|
+
>>> start = datetime(2024, 1, 1)
|
|
39
|
+
>>> end = datetime(2024, 1, 31)
|
|
40
|
+
>>> factory = EphemerisDataFactory(start, end)
|
|
41
|
+
>>> data = factory.get_ephemeris_data()
|
|
42
|
+
>>> print(f"Generated {len(data)} data points")
|
|
43
|
+
|
|
44
|
+
Author: Giacomo Battaglia
|
|
45
|
+
Copyright: (C) 2025 Kerykeion Project
|
|
46
|
+
License: AGPL-3.0
|
|
47
|
+
"""
|
|
48
|
+
|
|
49
|
+
from kerykeion import AstrologicalSubjectFactory
|
|
50
|
+
from kerykeion.kr_types.kr_models import AstrologicalSubjectModel
|
|
51
|
+
from kerykeion.utilities import get_houses_list, get_available_astrological_points_list
|
|
52
|
+
from kerykeion.astrological_subject_factory import DEFAULT_HOUSES_SYSTEM_IDENTIFIER, DEFAULT_PERSPECTIVE_TYPE, DEFAULT_ZODIAC_TYPE
|
|
53
|
+
from kerykeion.kr_types import EphemerisDictModel
|
|
54
|
+
from kerykeion.kr_types import SiderealMode, HousesSystemIdentifier, PerspectiveType, ZodiacType
|
|
55
|
+
from datetime import datetime, timedelta
|
|
56
|
+
from typing import Literal, Union, List
|
|
57
|
+
import logging
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
class EphemerisDataFactory:
|
|
61
|
+
"""
|
|
62
|
+
A factory class for generating ephemeris data over a specified date range.
|
|
63
|
+
|
|
64
|
+
This class calculates astrological ephemeris data (planetary positions and house cusps)
|
|
65
|
+
for a sequence of dates, allowing for detailed astronomical calculations across time periods.
|
|
66
|
+
It supports different time intervals (days, hours, or minutes) and various astrological
|
|
67
|
+
calculation systems.
|
|
68
|
+
|
|
69
|
+
The factory creates data points at regular intervals between start and end dates,
|
|
70
|
+
with built-in safeguards to prevent excessive computational loads through configurable
|
|
71
|
+
maximum limits.
|
|
72
|
+
|
|
73
|
+
Args:
|
|
74
|
+
start_datetime (datetime): The starting date and time for ephemeris calculations.
|
|
75
|
+
end_datetime (datetime): The ending date and time for ephemeris calculations.
|
|
76
|
+
step_type (Literal["days", "hours", "minutes"], optional): The time interval unit
|
|
77
|
+
for data points. Defaults to "days".
|
|
78
|
+
step (int, optional): The number of units to advance for each data point.
|
|
79
|
+
For example, step=2 with step_type="days" creates data points every 2 days.
|
|
80
|
+
Defaults to 1.
|
|
81
|
+
lat (float, optional): Geographic latitude in decimal degrees for calculations.
|
|
82
|
+
Positive values for North, negative for South. Defaults to 51.4769 (Greenwich).
|
|
83
|
+
lng (float, optional): Geographic longitude in decimal degrees for calculations.
|
|
84
|
+
Positive values for East, negative for West. Defaults to 0.0005 (Greenwich).
|
|
85
|
+
tz_str (str, optional): Timezone identifier (e.g., "Europe/London", "America/New_York").
|
|
86
|
+
Defaults to "Etc/UTC".
|
|
87
|
+
is_dst (bool, optional): Whether daylight saving time is active for the location.
|
|
88
|
+
Only relevant for certain timezone calculations. Defaults to False.
|
|
89
|
+
zodiac_type (ZodiacType, optional): The zodiac system to use (tropical or sidereal).
|
|
90
|
+
Defaults to DEFAULT_ZODIAC_TYPE.
|
|
91
|
+
sidereal_mode (Union[SiderealMode, None], optional): The sidereal calculation mode
|
|
92
|
+
if using sidereal zodiac. Only applies when zodiac_type is sidereal.
|
|
93
|
+
Defaults to None.
|
|
94
|
+
houses_system_identifier (HousesSystemIdentifier, optional): The house system
|
|
95
|
+
for astrological house calculations (e.g., Placidus, Koch, Equal).
|
|
96
|
+
Defaults to DEFAULT_HOUSES_SYSTEM_IDENTIFIER.
|
|
97
|
+
perspective_type (PerspectiveType, optional): The calculation perspective
|
|
98
|
+
(geocentric, heliocentric, etc.). Defaults to DEFAULT_PERSPECTIVE_TYPE.
|
|
99
|
+
max_days (Union[int, None], optional): Maximum number of daily data points allowed.
|
|
100
|
+
Set to None to disable this safety check. Defaults to 730 (2 years).
|
|
101
|
+
max_hours (Union[int, None], optional): Maximum number of hourly data points allowed.
|
|
102
|
+
Set to None to disable this safety check. Defaults to 8760 (1 year).
|
|
103
|
+
max_minutes (Union[int, None], optional): Maximum number of minute-interval data points.
|
|
104
|
+
Set to None to disable this safety check. Defaults to 525600 (1 year).
|
|
105
|
+
|
|
106
|
+
Raises:
|
|
107
|
+
ValueError: If step_type is not one of "days", "hours", or "minutes".
|
|
108
|
+
ValueError: If the calculated number of data points exceeds the respective maximum limit.
|
|
109
|
+
ValueError: If no valid dates are generated from the input parameters.
|
|
110
|
+
|
|
111
|
+
Examples:
|
|
112
|
+
Create daily ephemeris data for a month:
|
|
113
|
+
|
|
114
|
+
>>> from datetime import datetime
|
|
115
|
+
>>> start = datetime(2024, 1, 1)
|
|
116
|
+
>>> end = datetime(2024, 1, 31)
|
|
117
|
+
>>> factory = EphemerisDataFactory(start, end)
|
|
118
|
+
>>> data = factory.get_ephemeris_data()
|
|
119
|
+
|
|
120
|
+
Create hourly data for a specific location:
|
|
121
|
+
|
|
122
|
+
>>> factory = EphemerisDataFactory(
|
|
123
|
+
... start, end,
|
|
124
|
+
... step_type="hours",
|
|
125
|
+
... lat=40.7128, # New York
|
|
126
|
+
... lng=-74.0060,
|
|
127
|
+
... tz_str="America/New_York"
|
|
128
|
+
... )
|
|
129
|
+
>>> subjects = factory.get_ephemeris_data_as_astrological_subjects()
|
|
130
|
+
|
|
131
|
+
Note:
|
|
132
|
+
Large date ranges with small step intervals can generate thousands of data points,
|
|
133
|
+
which may require significant computation time and memory. The factory includes
|
|
134
|
+
warnings for calculations exceeding 1000 data points and enforces maximum limits
|
|
135
|
+
to prevent system overload.
|
|
136
|
+
"""
|
|
137
|
+
|
|
138
|
+
def __init__(
|
|
139
|
+
self,
|
|
140
|
+
start_datetime: datetime,
|
|
141
|
+
end_datetime: datetime,
|
|
142
|
+
step_type: Literal["days", "hours", "minutes"] = "days",
|
|
143
|
+
step: int = 1,
|
|
144
|
+
lat: float = 51.4769,
|
|
145
|
+
lng: float = 0.0005,
|
|
146
|
+
tz_str: str = "Etc/UTC",
|
|
147
|
+
is_dst: bool = False,
|
|
148
|
+
zodiac_type: ZodiacType = DEFAULT_ZODIAC_TYPE,
|
|
149
|
+
sidereal_mode: Union[SiderealMode, None] = None,
|
|
150
|
+
houses_system_identifier: HousesSystemIdentifier = DEFAULT_HOUSES_SYSTEM_IDENTIFIER,
|
|
151
|
+
perspective_type: PerspectiveType = DEFAULT_PERSPECTIVE_TYPE,
|
|
152
|
+
max_days: Union[int, None] = 730,
|
|
153
|
+
max_hours: Union[int, None] = 8760,
|
|
154
|
+
max_minutes: Union[int, None] = 525600,
|
|
155
|
+
):
|
|
156
|
+
self.start_datetime = start_datetime
|
|
157
|
+
self.end_datetime = end_datetime
|
|
158
|
+
self.step_type = step_type
|
|
159
|
+
self.step = step
|
|
160
|
+
self.lat = lat
|
|
161
|
+
self.lng = lng
|
|
162
|
+
self.tz_str = tz_str
|
|
163
|
+
self.is_dst = is_dst
|
|
164
|
+
self.zodiac_type = zodiac_type
|
|
165
|
+
self.sidereal_mode = sidereal_mode
|
|
166
|
+
self.houses_system_identifier = houses_system_identifier
|
|
167
|
+
self.perspective_type = perspective_type
|
|
168
|
+
self.max_days = max_days
|
|
169
|
+
self.max_hours = max_hours
|
|
170
|
+
self.max_minutes = max_minutes
|
|
171
|
+
|
|
172
|
+
self.dates_list = []
|
|
173
|
+
if self.step_type == "days":
|
|
174
|
+
self.dates_list = [self.start_datetime + timedelta(days=i * self.step) for i in range((self.end_datetime - self.start_datetime).days // self.step + 1)]
|
|
175
|
+
if max_days and (len(self.dates_list) > max_days):
|
|
176
|
+
raise ValueError(f"Too many days: {len(self.dates_list)} > {self.max_days}. To prevent this error, set max_days to a higher value or reduce the date range.")
|
|
177
|
+
|
|
178
|
+
elif self.step_type == "hours":
|
|
179
|
+
hours_diff = (self.end_datetime - self.start_datetime).total_seconds() / 3600
|
|
180
|
+
self.dates_list = [self.start_datetime + timedelta(hours=i * self.step) for i in range(int(hours_diff) // self.step + 1)]
|
|
181
|
+
if max_hours and (len(self.dates_list) > max_hours):
|
|
182
|
+
raise ValueError(f"Too many hours: {len(self.dates_list)} > {self.max_hours}. To prevent this error, set max_hours to a higher value or reduce the date range.")
|
|
183
|
+
|
|
184
|
+
elif self.step_type == "minutes":
|
|
185
|
+
minutes_diff = (self.end_datetime - self.start_datetime).total_seconds() / 60
|
|
186
|
+
self.dates_list = [self.start_datetime + timedelta(minutes=i * self.step) for i in range(int(minutes_diff) // self.step + 1)]
|
|
187
|
+
if max_minutes and (len(self.dates_list) > max_minutes):
|
|
188
|
+
raise ValueError(f"Too many minutes: {len(self.dates_list)} > {self.max_minutes}. To prevent this error, set max_minutes to a higher value or reduce the date range.")
|
|
189
|
+
|
|
190
|
+
else:
|
|
191
|
+
raise ValueError(f"Invalid step type: {self.step_type}")
|
|
192
|
+
|
|
193
|
+
if not self.dates_list:
|
|
194
|
+
raise ValueError("No dates found. Check the date range and step values.")
|
|
195
|
+
|
|
196
|
+
if len(self.dates_list) > 1000:
|
|
197
|
+
logging.warning(f"Large number of dates: {len(self.dates_list)}. The calculation may take a while.")
|
|
198
|
+
|
|
199
|
+
def get_ephemeris_data(self, as_model: bool = False) -> list:
|
|
200
|
+
"""
|
|
201
|
+
Generate ephemeris data for the specified date range.
|
|
202
|
+
|
|
203
|
+
This method creates a comprehensive dataset containing planetary positions and
|
|
204
|
+
astrological house cusps for each date in the configured time series. The data
|
|
205
|
+
is structured for easy consumption by astrological applications and analysis tools.
|
|
206
|
+
|
|
207
|
+
The returned data includes all available astrological points (planets, asteroids,
|
|
208
|
+
lunar nodes, etc.) as configured by the perspective type, along with complete
|
|
209
|
+
house cusp information for each calculated moment.
|
|
210
|
+
|
|
211
|
+
Args:
|
|
212
|
+
as_model (bool, optional): If True, returns data as validated model instances
|
|
213
|
+
(EphemerisDictModel objects) which provide type safety and validation.
|
|
214
|
+
If False, returns raw dictionary data for maximum flexibility.
|
|
215
|
+
Defaults to False.
|
|
216
|
+
|
|
217
|
+
Returns:
|
|
218
|
+
list: A list of ephemeris data points, where each element represents one
|
|
219
|
+
calculated moment in time. The structure depends on the as_model parameter:
|
|
220
|
+
|
|
221
|
+
If as_model=False (default):
|
|
222
|
+
List of dictionaries with keys:
|
|
223
|
+
- "date" (str): ISO format datetime string (e.g., "2020-01-01T00:00:00")
|
|
224
|
+
- "planets" (list): List of dictionaries, each containing planetary data
|
|
225
|
+
with keys like 'name', 'abs_pos', 'lon', 'lat', 'dist', 'speed', etc.
|
|
226
|
+
- "houses" (list): List of dictionaries containing house cusp data
|
|
227
|
+
with keys like 'name', 'abs_pos', 'lon', etc.
|
|
228
|
+
|
|
229
|
+
If as_model=True:
|
|
230
|
+
List of EphemerisDictModel instances providing the same data
|
|
231
|
+
with type validation and structured access.
|
|
232
|
+
|
|
233
|
+
Examples:
|
|
234
|
+
Basic usage with dictionary output:
|
|
235
|
+
|
|
236
|
+
>>> factory = EphemerisDataFactory(start_date, end_date)
|
|
237
|
+
>>> data = factory.get_ephemeris_data()
|
|
238
|
+
>>> print(f"Sun position: {data[0]['planets'][0]['abs_pos']}")
|
|
239
|
+
>>> print(f"First house cusp: {data[0]['houses'][0]['abs_pos']}")
|
|
240
|
+
|
|
241
|
+
Using model instances for type safety:
|
|
242
|
+
|
|
243
|
+
>>> data_models = factory.get_ephemeris_data(as_model=True)
|
|
244
|
+
>>> first_point = data_models[0]
|
|
245
|
+
>>> print(f"Date: {first_point.date}")
|
|
246
|
+
>>> print(f"Number of planets: {len(first_point.planets)}")
|
|
247
|
+
|
|
248
|
+
Note:
|
|
249
|
+
- The calculation time is proportional to the number of data points
|
|
250
|
+
- For large datasets (>1000 points), consider using the method in batches
|
|
251
|
+
- Planet order and availability depend on the configured perspective type
|
|
252
|
+
- House system affects the house cusp calculations
|
|
253
|
+
- All positions are in the configured zodiac system (tropical/sidereal)
|
|
254
|
+
"""
|
|
255
|
+
ephemeris_data_list = []
|
|
256
|
+
for date in self.dates_list:
|
|
257
|
+
subject = AstrologicalSubjectFactory.from_birth_data(
|
|
258
|
+
year=date.year,
|
|
259
|
+
month=date.month,
|
|
260
|
+
day=date.day,
|
|
261
|
+
hour=date.hour,
|
|
262
|
+
minute=date.minute,
|
|
263
|
+
lng=self.lng,
|
|
264
|
+
lat=self.lat,
|
|
265
|
+
tz_str=self.tz_str,
|
|
266
|
+
city="Placeholder",
|
|
267
|
+
nation="Placeholder",
|
|
268
|
+
online=False,
|
|
269
|
+
zodiac_type=self.zodiac_type,
|
|
270
|
+
sidereal_mode=self.sidereal_mode,
|
|
271
|
+
houses_system_identifier=self.houses_system_identifier,
|
|
272
|
+
perspective_type=self.perspective_type,
|
|
273
|
+
is_dst=self.is_dst,
|
|
274
|
+
)
|
|
275
|
+
|
|
276
|
+
houses_list = get_houses_list(subject)
|
|
277
|
+
available_planets = get_available_astrological_points_list(subject)
|
|
278
|
+
|
|
279
|
+
ephemeris_data_list.append({"date": date.isoformat(), "planets": available_planets, "houses": houses_list})
|
|
280
|
+
|
|
281
|
+
if as_model:
|
|
282
|
+
return [EphemerisDictModel(**data) for data in ephemeris_data_list]
|
|
283
|
+
|
|
284
|
+
return ephemeris_data_list
|
|
285
|
+
|
|
286
|
+
def get_ephemeris_data_as_astrological_subjects(self, as_model: bool = False) -> List[AstrologicalSubjectModel]:
|
|
287
|
+
"""
|
|
288
|
+
Generate ephemeris data as complete AstrologicalSubject instances.
|
|
289
|
+
|
|
290
|
+
This method creates fully-featured AstrologicalSubject objects for each date in the
|
|
291
|
+
configured time series, providing access to all astrological calculation methods
|
|
292
|
+
and properties. Unlike the dictionary-based approach of get_ephemeris_data(),
|
|
293
|
+
this method returns objects with the complete Kerykeion API available.
|
|
294
|
+
|
|
295
|
+
Each AstrologicalSubject instance represents a complete astrological chart for
|
|
296
|
+
the specified moment, location, and calculation settings. This allows direct
|
|
297
|
+
access to methods like get_sun(), get_all_points(), draw_chart(), calculate
|
|
298
|
+
aspects, and all other astrological analysis features.
|
|
299
|
+
|
|
300
|
+
Args:
|
|
301
|
+
as_model (bool, optional): If True, returns AstrologicalSubjectModel instances
|
|
302
|
+
(Pydantic model versions) which provide serialization and validation features.
|
|
303
|
+
If False, returns raw AstrologicalSubject instances with full method access.
|
|
304
|
+
Defaults to False.
|
|
305
|
+
|
|
306
|
+
Returns:
|
|
307
|
+
List[AstrologicalSubjectModel]: A list of AstrologicalSubject or
|
|
308
|
+
AstrologicalSubjectModel instances (depending on as_model parameter).
|
|
309
|
+
Each element represents one calculated moment in time with full
|
|
310
|
+
astrological chart data and methods available.
|
|
311
|
+
|
|
312
|
+
Each subject contains:
|
|
313
|
+
- All planetary and astrological point positions
|
|
314
|
+
- Complete house system calculations
|
|
315
|
+
- Chart drawing capabilities
|
|
316
|
+
- Aspect calculation methods
|
|
317
|
+
- Access to all Kerykeion astrological features
|
|
318
|
+
|
|
319
|
+
Examples:
|
|
320
|
+
Basic usage for accessing individual chart features:
|
|
321
|
+
|
|
322
|
+
>>> factory = EphemerisDataFactory(start_date, end_date)
|
|
323
|
+
>>> subjects = factory.get_ephemeris_data_as_astrological_subjects()
|
|
324
|
+
>>>
|
|
325
|
+
>>> # Access specific planetary data
|
|
326
|
+
>>> sun_data = subjects[0].get_sun()
|
|
327
|
+
>>> moon_data = subjects[0].get_moon()
|
|
328
|
+
>>>
|
|
329
|
+
>>> # Get all astrological points
|
|
330
|
+
>>> all_points = subjects[0].get_all_points()
|
|
331
|
+
>>>
|
|
332
|
+
>>> # Generate chart visualization
|
|
333
|
+
>>> chart_svg = subjects[0].draw_chart()
|
|
334
|
+
|
|
335
|
+
Using model instances for serialization:
|
|
336
|
+
|
|
337
|
+
>>> subjects_models = factory.get_ephemeris_data_as_astrological_subjects(as_model=True)
|
|
338
|
+
>>> # Model instances can be easily serialized to JSON
|
|
339
|
+
>>> json_data = subjects_models[0].model_dump_json()
|
|
340
|
+
|
|
341
|
+
Batch processing for analysis:
|
|
342
|
+
|
|
343
|
+
>>> subjects = factory.get_ephemeris_data_as_astrological_subjects()
|
|
344
|
+
>>> sun_positions = [subj.sun['abs_pos'] for subj in subjects if subj.sun]
|
|
345
|
+
>>> # Analyze sun position changes over time
|
|
346
|
+
|
|
347
|
+
Use Cases:
|
|
348
|
+
- Time-series astrological analysis
|
|
349
|
+
- Planetary motion tracking
|
|
350
|
+
- Aspect pattern analysis over time
|
|
351
|
+
- Chart animation data generation
|
|
352
|
+
- Astrological research and statistics
|
|
353
|
+
- Progressive chart calculations
|
|
354
|
+
|
|
355
|
+
Performance Notes:
|
|
356
|
+
- More computationally intensive than get_ephemeris_data()
|
|
357
|
+
- Each subject performs full astrological calculations
|
|
358
|
+
- Memory usage scales with the number of data points
|
|
359
|
+
- Consider processing in batches for very large date ranges
|
|
360
|
+
- Ideal for comprehensive analysis requiring full chart features
|
|
361
|
+
|
|
362
|
+
See Also:
|
|
363
|
+
get_ephemeris_data(): For lightweight dictionary-based ephemeris data
|
|
364
|
+
AstrologicalSubject: For details on available methods and properties
|
|
365
|
+
"""
|
|
366
|
+
subjects_list = []
|
|
367
|
+
for date in self.dates_list:
|
|
368
|
+
subject = AstrologicalSubjectFactory.from_birth_data(
|
|
369
|
+
year=date.year,
|
|
370
|
+
month=date.month,
|
|
371
|
+
day=date.day,
|
|
372
|
+
hour=date.hour,
|
|
373
|
+
minute=date.minute,
|
|
374
|
+
lng=self.lng,
|
|
375
|
+
lat=self.lat,
|
|
376
|
+
tz_str=self.tz_str,
|
|
377
|
+
city="Placeholder",
|
|
378
|
+
nation="Placeholder",
|
|
379
|
+
online=False,
|
|
380
|
+
zodiac_type=self.zodiac_type,
|
|
381
|
+
sidereal_mode=self.sidereal_mode,
|
|
382
|
+
houses_system_identifier=self.houses_system_identifier,
|
|
383
|
+
perspective_type=self.perspective_type,
|
|
384
|
+
is_dst=self.is_dst,
|
|
385
|
+
)
|
|
386
|
+
|
|
387
|
+
if as_model:
|
|
388
|
+
subjects_list.append(subject.model())
|
|
389
|
+
else:
|
|
390
|
+
subjects_list.append(subject)
|
|
391
|
+
|
|
392
|
+
return subjects_list
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
if "__main__" == __name__:
|
|
396
|
+
start_date = datetime.fromisoformat("2020-01-01")
|
|
397
|
+
end_date = datetime.fromisoformat("2020-01-03")
|
|
398
|
+
|
|
399
|
+
factory = EphemerisDataFactory(
|
|
400
|
+
start_datetime=start_date,
|
|
401
|
+
end_datetime=end_date,
|
|
402
|
+
step_type="minutes",
|
|
403
|
+
step=60, # One hour intervals to make the example more manageable
|
|
404
|
+
lat=37.9838,
|
|
405
|
+
lng=23.7275,
|
|
406
|
+
tz_str="Europe/Athens",
|
|
407
|
+
is_dst=False,
|
|
408
|
+
max_hours=None,
|
|
409
|
+
max_minutes=None,
|
|
410
|
+
max_days=None,
|
|
411
|
+
)
|
|
412
|
+
|
|
413
|
+
# Test original method
|
|
414
|
+
ephemeris_data = factory.get_ephemeris_data(as_model=True)
|
|
415
|
+
print(f"Number of ephemeris data points: {len(ephemeris_data)}")
|
|
416
|
+
print(f"First data point date: {ephemeris_data[0].date}")
|
|
417
|
+
|
|
418
|
+
# Test new method
|
|
419
|
+
subjects = factory.get_ephemeris_data_as_astrological_subjects()
|
|
420
|
+
print(f"Number of astrological subjects: {len(subjects)}")
|
|
421
|
+
print(f"First subject sun position: {subjects[0].sun}")
|
|
422
|
+
|
|
423
|
+
# Example of accessing more data from the first subject
|
|
424
|
+
first_subject = subjects[0]
|
|
425
|
+
print(f"Sun sign: {first_subject.sun['sign']}")
|
|
426
|
+
|
|
427
|
+
# Compare sun positions from both methods
|
|
428
|
+
for i in range(min(3, len(subjects))):
|
|
429
|
+
print(f"Date: {ephemeris_data[i].date}")
|
|
430
|
+
print(f"Sun position from dict: {ephemeris_data[i].planets[0]['abs_pos']}")
|
|
431
|
+
print("---")
|
kerykeion/fetch_geonames.py
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
"""
|
|
3
|
-
|
|
3
|
+
Author: Giacomo Battaglia
|
|
4
|
+
Copyright: (C) 2025 Kerykeion Project
|
|
5
|
+
License: AGPL-3.0
|
|
4
6
|
"""
|
|
5
7
|
|
|
6
8
|
|
|
@@ -13,13 +15,16 @@ from typing import Union
|
|
|
13
15
|
|
|
14
16
|
class FetchGeonames:
|
|
15
17
|
"""
|
|
16
|
-
Class to handle requests to the GeoNames API
|
|
18
|
+
Class to handle requests to the GeoNames API for location data and timezone information.
|
|
19
|
+
|
|
20
|
+
This class provides cached access to the GeoNames API to retrieve location coordinates,
|
|
21
|
+
timezone information, and other geographical data for astrological calculations.
|
|
17
22
|
|
|
18
23
|
Args:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
city_name: Name of the city to search for.
|
|
25
|
+
country_code: Two-letter country code (ISO 3166-1 alpha-2).
|
|
26
|
+
username: GeoNames username for API access, defaults to "century.boy".
|
|
27
|
+
cache_expire_after_days: Number of days to cache responses, defaults to 30.
|
|
23
28
|
"""
|
|
24
29
|
|
|
25
30
|
def __init__(
|
|
@@ -43,7 +48,14 @@ class FetchGeonames:
|
|
|
43
48
|
|
|
44
49
|
def __get_timezone(self, lat: Union[str, float, int], lon: Union[str, float, int]) -> dict[str, str]:
|
|
45
50
|
"""
|
|
46
|
-
Get
|
|
51
|
+
Get timezone information for a given latitude and longitude.
|
|
52
|
+
|
|
53
|
+
Args:
|
|
54
|
+
lat: Latitude coordinate.
|
|
55
|
+
lon: Longitude coordinate.
|
|
56
|
+
|
|
57
|
+
Returns:
|
|
58
|
+
dict: Timezone data including timezone string and cache status.
|
|
47
59
|
"""
|
|
48
60
|
# Dictionary that will be returned:
|
|
49
61
|
timezone_data = {}
|
|
@@ -75,7 +87,14 @@ class FetchGeonames:
|
|
|
75
87
|
|
|
76
88
|
def __get_contry_data(self, city_name: str, country_code: str) -> dict[str, str]:
|
|
77
89
|
"""
|
|
78
|
-
Get
|
|
90
|
+
Get city location data without timezone for a given city and country.
|
|
91
|
+
|
|
92
|
+
Args:
|
|
93
|
+
city_name: Name of the city to search for.
|
|
94
|
+
country_code: Two-letter country code.
|
|
95
|
+
|
|
96
|
+
Returns:
|
|
97
|
+
dict: City location data excluding timezone information.
|
|
79
98
|
"""
|
|
80
99
|
# Dictionary that will be returned:
|
|
81
100
|
city_data_whitout_tz = {}
|
|
@@ -10,5 +10,11 @@ class KerykeionException(Exception):
|
|
|
10
10
|
"""
|
|
11
11
|
|
|
12
12
|
def __init__(self, message):
|
|
13
|
+
"""
|
|
14
|
+
Initialize a new KerykeionException.
|
|
15
|
+
|
|
16
|
+
Args:
|
|
17
|
+
message: The error message to be displayed.
|
|
18
|
+
"""
|
|
13
19
|
# Call the base class constructor with the parameters it needs
|
|
14
20
|
super().__init__(message)
|
kerykeion/kr_types/kr_models.py
CHANGED
|
@@ -34,19 +34,33 @@ class SubscriptableBaseModel(BaseModel):
|
|
|
34
34
|
"""
|
|
35
35
|
|
|
36
36
|
def __getitem__(self, key):
|
|
37
|
+
"""Get an attribute using dictionary-style access."""
|
|
37
38
|
return getattr(self, key)
|
|
38
39
|
|
|
39
40
|
def __setitem__(self, key, value):
|
|
41
|
+
"""Set an attribute using dictionary-style access."""
|
|
40
42
|
setattr(self, key, value)
|
|
41
43
|
|
|
42
44
|
def __delitem__(self, key):
|
|
45
|
+
"""Delete an attribute using dictionary-style access."""
|
|
43
46
|
delattr(self, key)
|
|
44
47
|
|
|
45
48
|
def get(self, key, default = None):
|
|
49
|
+
"""Get an attribute with a default value if not found."""
|
|
46
50
|
return getattr(self, key, default)
|
|
47
51
|
|
|
48
52
|
|
|
49
53
|
class LunarPhaseModel(SubscriptableBaseModel):
|
|
54
|
+
"""
|
|
55
|
+
Model representing lunar phase information.
|
|
56
|
+
|
|
57
|
+
Attributes:
|
|
58
|
+
degrees_between_s_m: Angular separation between Sun and Moon in degrees.
|
|
59
|
+
moon_phase: Numerical phase identifier for the Moon.
|
|
60
|
+
sun_phase: Numerical phase identifier for the Sun.
|
|
61
|
+
moon_emoji: Emoji representation of the lunar phase.
|
|
62
|
+
moon_phase_name: Text name of the lunar phase.
|
|
63
|
+
"""
|
|
50
64
|
degrees_between_s_m: Union[float, int]
|
|
51
65
|
moon_phase: int
|
|
52
66
|
sun_phase: int
|
|
@@ -56,7 +70,24 @@ class LunarPhaseModel(SubscriptableBaseModel):
|
|
|
56
70
|
|
|
57
71
|
class KerykeionPointModel(SubscriptableBaseModel):
|
|
58
72
|
"""
|
|
59
|
-
|
|
73
|
+
Model representing an astrological celestial point or house cusp.
|
|
74
|
+
|
|
75
|
+
This model contains comprehensive information about celestial objects
|
|
76
|
+
(planets, points) or house cusps including their zodiacal position,
|
|
77
|
+
sign placement, and metadata.
|
|
78
|
+
|
|
79
|
+
Attributes:
|
|
80
|
+
name: The name of the celestial point or house.
|
|
81
|
+
quality: Astrological quality (Cardinal, Fixed, Mutable).
|
|
82
|
+
element: Astrological element (Fire, Earth, Air, Water).
|
|
83
|
+
sign: The zodiac sign the point is located in.
|
|
84
|
+
sign_num: Numerical identifier for the zodiac sign (0-11).
|
|
85
|
+
position: Position within the sign (0-30 degrees).
|
|
86
|
+
abs_pos: Absolute position in the zodiac (0-360 degrees).
|
|
87
|
+
emoji: Unicode emoji representing the point or sign.
|
|
88
|
+
point_type: Type of the celestial point (Planet, House, etc.).
|
|
89
|
+
house: House placement of the point (optional).
|
|
90
|
+
retrograde: Whether the point is in retrograde motion (optional).
|
|
60
91
|
"""
|
|
61
92
|
|
|
62
93
|
name: Union[AstrologicalPoint, Houses]
|
|
@@ -74,7 +105,29 @@ class KerykeionPointModel(SubscriptableBaseModel):
|
|
|
74
105
|
|
|
75
106
|
class AstrologicalBaseModel(SubscriptableBaseModel):
|
|
76
107
|
"""
|
|
77
|
-
Base
|
|
108
|
+
Base model containing common fields for all astrological subjects.
|
|
109
|
+
|
|
110
|
+
This model serves as the foundation for all astrological chart types,
|
|
111
|
+
providing standard location, time, and configuration data. It supports
|
|
112
|
+
both complete charts (with full location/time data) and composite charts
|
|
113
|
+
(where some fields may be optional).
|
|
114
|
+
|
|
115
|
+
Attributes:
|
|
116
|
+
name: Subject identifier or name.
|
|
117
|
+
city: Location city (optional for composite charts).
|
|
118
|
+
nation: Country code (optional for composite charts).
|
|
119
|
+
lng: Longitude coordinate (optional for composite charts).
|
|
120
|
+
lat: Latitude coordinate (optional for composite charts).
|
|
121
|
+
tz_str: Timezone string (optional for composite charts).
|
|
122
|
+
iso_formatted_local_datetime: Local datetime in ISO format (optional).
|
|
123
|
+
iso_formatted_utc_datetime: UTC datetime in ISO format (optional).
|
|
124
|
+
julian_day: Julian day number for astronomical calculations (optional).
|
|
125
|
+
day_of_week: Day of the week (optional).
|
|
126
|
+
zodiac_type: Type of zodiac system used (Tropical or Sidereal).
|
|
127
|
+
sidereal_mode: Sidereal calculation mode (if applicable).
|
|
128
|
+
houses_system_identifier: House system used for calculations.
|
|
129
|
+
perspective_type: Astrological perspective (geocentric, heliocentric, etc.).
|
|
130
|
+
active_points: List of celestial points included in calculations.
|
|
78
131
|
"""
|
|
79
132
|
# Common identification data
|
|
80
133
|
name: str
|