API Reference: Core Module
core
Core functions for astronomical calculations using Skyfield library.
RetrogradeFunction
A class to determine if a planet is in retrograde motion from a given location on Earth.
Attributes:
| Name | Type | Description |
|---|---|---|
planet_name |
str
|
The name of the planet to observe. |
latitude |
float
|
The latitude of the observer's location. |
longitude |
float
|
The longitude of the observer's location. |
step_days |
int
|
The number of days to step back for comparison (default is 7). |
Methods:
| Name | Description |
|---|---|
__call__ |
Time) -> bool:
Determines if the planet is in retrograde motion at the given time |
Source code in .venv/lib/python3.11/site-packages/ndastro_engine/core.py
__call__(t)
Determine if the planet is in retrograde motion at a given time.
This method calculates the ecliptic longitude of the planet at the given time t
and compares it with the ecliptic longitude of the planet at the previous time t-1.
If the longitude decreases, the planet is in retrograde motion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
Time
|
The time at which to check for retrograde motion. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the planet is in retrograde motion, False otherwise. |
Source code in .venv/lib/python3.11/site-packages/ndastro_engine/core.py
__init__(planet_name, latitude, longitude)
Initialize a new instance of the retrograde class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
planet_name
|
str
|
The name of the planet. |
required |
latitude
|
float
|
The latitude coordinate. |
required |
longitude
|
float
|
The longitude coordinate. |
required |
Source code in .venv/lib/python3.11/site-packages/ndastro_engine/core.py
__get_retrograde_function(planet_name, latitude, longitude)
Create a RetrogradeFunction instance for a given planet and location.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
planet_name
|
str
|
The name of the planet. |
required |
latitude
|
float
|
The latitude of the location. |
required |
longitude
|
float
|
The longitude of the location. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RetrogradeFunction |
RetrogradeFunction
|
An instance of RetrogradeFunction for the specified planet and location. |
Source code in .venv/lib/python3.11/site-packages/ndastro_engine/core.py
find_retrograde_periods(start_date, end_date, planet_name, latitude, longitude)
Calculate the retrograde periods for a given planet within a specified date range and location.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_date
|
datetime
|
The start date of the period to check for retrograde motion. |
required |
end_date
|
datetime
|
The end date of the period to check for retrograde motion. |
required |
planet_name
|
str
|
The name of the planet to check for retrograde motion. |
required |
latitude
|
float
|
The latitude of the observation location. |
required |
longitude
|
float
|
The longitude of the observation location. |
required |
Returns:
| Type | Description |
|---|---|
list[tuple[datetime, datetime]]
|
list[tuple[datetime, datetime]]: A list of tuples, each containing the start and end datetime of a retrograde period. |
Source code in .venv/lib/python3.11/site-packages/ndastro_engine/core.py
get_ascendent_position(lat, lon, given_time)
Calculate the tropical ascendant.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lat
|
float
|
The latitude of the observer in decimal degrees. |
required |
lon
|
float
|
The longitude of the observer in decimal degrees. |
required |
given_time
|
datetime
|
The datetime of the observation. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The longitude of the tropical/sidereal ascendant. |
Source code in .venv/lib/python3.11/site-packages/ndastro_engine/core.py
get_lunar_node_positions(given_time)
Calculate the positions of the lunar nodes (Rahu and Kethu) for a given datetime.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
given_time
|
datetime
|
The datetime in UTC for which to calculate the lunar node positions. |
required |
Returns:
| Type | Description |
|---|---|
tuple[float, float]
|
tuple[float, float]: A tuple containing the longitudes of Rahu and Kethu in decimal degrees. |
Source code in .venv/lib/python3.11/site-packages/ndastro_engine/core.py
get_planet_position(planet, lat, lon, given_time)
Return the tropical position of the planet for the given latitude, longitude, and datetime.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
planet
|
Planets
|
The planet to calculate the position for. |
required |
lat
|
float
|
The latitude of the observer in decimal degrees. |
required |
lon
|
float
|
The longitude of the observer in decimal degrees. |
required |
given_time
|
datetime
|
The datetime of the observation in UTC. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
PlanetPosition |
PlanetPosition
|
The tropical latitude, longitude, distance, and their rates of change of the planet. |
Source code in .venv/lib/python3.11/site-packages/ndastro_engine/core.py
get_planets_position(planets, lat, lon, given_time)
Return the tropical positions of all planets for the given latitude, longitude, and datetime.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
planets
|
list[Planets]
|
The list of planets to calculate the positions for. |
required |
lat
|
float
|
The latitude of the observer in decimal degrees. |
required |
lon
|
float
|
The longitude of the observer in decimal degrees. |
required |
given_time
|
datetime
|
The datetime of the observation in UTC. |
required |
Returns:
| Type | Description |
|---|---|
dict[Planets, PlanetPosition]
|
dict[Planets, PlanetPosition]: A dictionary mapping each planet to its tropical/sidereal latitude, longitude, and distance & their rates of change. |
Source code in .venv/lib/python3.11/site-packages/ndastro_engine/core.py
get_sunrise_sunset(lat, lon, given_time, elevation=914)
Calculate the sunrise and sunset times for a given location and date.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lat
|
float
|
The latitude of the location in decimal degrees. |
required |
lon
|
float
|
The longitude of the location in decimal degrees. |
required |
given_time
|
datetime
|
The date and time for which to calculate the sunrise and sunset times. |
required |
elevation
|
float
|
The elevation of the location in meters. Defaults to 914 meters (approximately 3000 feet). |
914
|
Returns:
| Type | Description |
|---|---|
tuple[datetime, datetime]
|
tuple[datetime, datetime]: A tuple containing the sunrise and sunset times as datetime objects. |
Source code in .venv/lib/python3.11/site-packages/ndastro_engine/core.py
is_planet_in_retrograde(check_date, planet_name, latitude, longitude)
Check if a planet is in retrograde motion on a specific date.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
check_date
|
datetime
|
The date to check for retrograde motion. |
required |
planet_name
|
str
|
The name of the planet to check. |
required |
latitude
|
float
|
The latitude in decimal degrees of the observation location. |
required |
longitude
|
float
|
The longitude in decimal degrees of the observation location. |
required |
Returns:
| Type | Description |
|---|---|
tuple[bool, datetime | None, datetime | None]
|
tuple[bool, datetime | None, datetime | None]: A tuple containing: - bool: True if the planet is in retrograde motion on the given date, otherwise False. - datetime | None: The start date of the retrograde period (None if not in retrograde). - datetime | None: The end date of the retrograde period (None if not in retrograde). |