Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ venv/

# Build
build/

# Ignore vim swp files
*.swp
Binary file added .main.py.swp
Binary file not shown.
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Changelog
---
## const.py
* Added LIST_OBJECTS as a common source for assignement of the
default Object list
* Added list with ten planest for modern astrology - LIST_TEN_PLANETS
* Added list of aspecing planets - LIST_ASP_PLANTES
* Added list with harmonious aspects - LIST_ASPECTS_POS
* Added list with hard aspects - LIST_ASPECTS_NEG
* Added list with tight orbs - LIST_ORBS_TIGHT
* Added list with wide orbs - LIST_WIDE_ORBS
* Defined a common orbs list LIST_IRBS for asignement
* Added constant MINUTE for Julian calendar claculations
* Added constant HOUR for Julian calendar calculations

---
## chart.py
* Changed Traditional list of objects with the general list LIST_OBJECTS
so the asignement can happen in the *const.py*
* Removed assignement of a default house system @ 166
* Changed default house system to Placidus

---
## object.py
* Changed the traditional house offset from -5deg to 0deg

---
## props.py
* Feeds orbs from the const.py rather than being hardcoded
2 changes: 1 addition & 1 deletion flatlib/angle.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def _fixSlist(slist):
def _roundSlist(slist):
""" Rounds a signed list over the last element and removes it. """
slist[-1] = 60 if slist[-1] >= 30 else 0
for i in range(len(slist) - 1, 1, -1):
for i in range(len(slist)-1, 0, -1):
if slist[i] == 60:
slist[i] = 0
slist[i - 1] += 1
Expand Down
6 changes: 3 additions & 3 deletions flatlib/chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ def __init__(self, date, pos, **kwargs):
"""
# Handle optional arguments
hsys = kwargs.get('hsys', const.HOUSES_DEFAULT)
IDs = kwargs.get('IDs', const.LIST_OBJECTS_TRADITIONAL)

IDs = kwargs.get('IDs', const.LIST_OBJECTS)
self.date = date
self.pos = pos
self.hsys = hsys
Expand Down Expand Up @@ -161,4 +161,4 @@ def solarReturn(self, year):
'00:00',
self.date.utcoffset)
srDate = ephem.nextSolarReturn(date, sun.lon)
return Chart(srDate, self.pos, hsys=self.hsys)
return Chart(srDate, self.pos)
86 changes: 85 additions & 1 deletion flatlib/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
HOUSES_POLICH_PAGE = 'Polich Page'
HOUSES_ALCABITUS = 'Alcabitus'
HOUSES_MORINUS = 'Morinus'
HOUSES_DEFAULT = HOUSES_ALCABITUS
HOUSES_DEFAULT = HOUSES_PLACIDUS

# === Angles === */

Expand Down Expand Up @@ -267,6 +267,19 @@
LIST_SEVEN_PLANETS = [
SUN, MOON, MERCURY, VENUS, MARS, JUPITER, SATURN
]
"""MH on 2018/3/3 - List of 10 plantes for modern astrology"""
LIST_TEN_PLANETS = [
SUN, MOON, MERCURY, VENUS, MARS, JUPITER, SATURN, NEPTUNE, URANUS, PLUTO
]

"""MH on 2018/3/4 - List of aspecting planets"""

#LIST_OBJECTS = LIST_TEN_PLANETS

LIST_ASP_PLANETS = [
SUN, MERCURY, VENUS, MARS, JUPITER, SATURN, NEPTUNE, URANUS, PLUTO, NORTH_NODE, SOUTH_NODE
]


LIST_HOUSES = [
HOUSE1, HOUSE2, HOUSE3, HOUSE4, HOUSE5, HOUSE6,
Expand All @@ -289,3 +302,74 @@
STAR_LESATH, STAR_VEGA, STAR_ALTAIR, STAR_DENEB_ALGEDI,
STAR_FOMALHAUT, STAR_DENEB_ADIGE, STAR_ACHERNAR,
]

"""MH on 2018/3/6 - List of Positive Aspects"""
LIST_ASPECTS_POS = [
SEXTILE, TRINE
]

"""MH on 2018/3/6 - List of Negative Aspects"""
LIST_ASPECTS_NEG = [
SQUARE, OPPOSITION
]

"""MH on 2018/3/6 - List of tight orbs"""

LIST_ORBS_TIGHT = {
NO_PLANET: 0,
SUN: 15,
MOON: 12,
MERCURY: 7,
VENUS: 7,
MARS: 8,
JUPITER: 9,
SATURN: 9,
URANUS: 5,
NEPTUNE: 5,
PLUTO: 5,
CHIRON: 5,
NORTH_NODE: 12,
SOUTH_NODE: 12,
SYZYGY: 0,
PARS_FORTUNA: 0
}

"""MH on 2018/3/6 - List of wide orbs"""
LIST_ORBS_WIDE = {
NO_PLANET: 0,
SUN: 5,
MOON: 4,
MERCURY: 2,
VENUS: 2,
MARS: 3,
JUPITER: 3,
SATURN: 3,
URANUS: 2,
NEPTUNE: 1,
PLUTO: 3,
CHIRON: 1,
NORTH_NODE: 2,
SOUTH_NODE: 2,
SYZYGY: 0,
PARS_FORTUNA: 0
}

LIST_ORBS = LIST_ORBS_TIGHT

"""MH on 2018/3/18"""
LIST_RULERS = {ARIES:MARS,
TAURUS:VENUS,
GEMINI:MERCURY,
CANCER:MOON,
LEO:SUN,
VIRGO:MERCURY,
LIBRA:VENUS,
SCORPIO:PLUTO,
SAGITTARIUS:JUPITER,
CAPRICORN:SATURN,
AQUARIUS:URANUS,
PISCES:NEPTUNE}

"""MH on 2018/3/9 - Time constants"""
MINUTE = 0.00069444440305233
HOUR = 0.04166666651144624
9 changes: 1 addition & 8 deletions flatlib/ephem/eph.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,6 @@ def lastSunset(jd, lat, lon):
return nextSunset(jd - 1.0, lat, lon)


# === Stations === #

def nextStation(ID, jd):
""" Returns the aproximate jd of the next station. """
return tools.nextStationJD(ID, jd)


# === Other functions === #

def _signInfo(obj):
Expand All @@ -121,4 +114,4 @@ def _signInfo(obj):
obj.update({
'sign': const.LIST_SIGNS[int(lon / 30)],
'signlon': lon % 30
})
})
51 changes: 0 additions & 51 deletions flatlib/ephem/ephem.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"""

from . import eph
from . import swe

from flatlib.datetime import Datetime
from flatlib.object import (GenericObject, Object,
Expand Down Expand Up @@ -114,53 +113,3 @@ def lastSunset(date, pos):
""" Returns the date of the last sunset. """
jd = eph.lastSunset(date.jd, pos.lat, pos.lon)
return Datetime.fromJD(jd, date.utcoffset)


# === Station === #

def nextStation(ID, date):
""" Returns the aproximate date of the next station. """
jd = eph.nextStation(ID, date.jd)
return Datetime.fromJD(jd, date.utcoffset)


# === Eclipses === #

def prevSolarEclipse(date):
""" Returns the Datetime of the maximum phase of the
previous global solar eclipse.

"""

eclipse = swe.solarEclipseGlobal(date.jd, backward=True)
return Datetime.fromJD(eclipse['maximum'], date.utcoffset)


def nextSolarEclipse(date):
""" Returns the Datetime of the maximum phase of the
next global solar eclipse.

"""

eclipse = swe.solarEclipseGlobal(date.jd, backward=False)
return Datetime.fromJD(eclipse['maximum'], date.utcoffset)


def prevLunarEclipse(date):
""" Returns the Datetime of the maximum phase of the
previous global lunar eclipse.

"""

eclipse = swe.lunarEclipseGlobal(date.jd, backward=True)
return Datetime.fromJD(eclipse['maximum'], date.utcoffset)


def nextLunarEclipse(date):
""" Returns the Datetime of the maximum phase of the
next global lunar eclipse.

"""

eclipse = swe.lunarEclipseGlobal(date.jd, backward=False)
return Datetime.fromJD(eclipse['maximum'], date.utcoffset)
32 changes: 0 additions & 32 deletions flatlib/ephem/swe.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,35 +144,3 @@ def sweFixedStar(star, jd):
'lon': sweList[0],
'lat': sweList[1]
}


# === Eclipses === #

def solarEclipseGlobal(jd, backward):
""" Returns the jd details of previous or next global solar eclipse. """

sweList = swisseph.sol_eclipse_when_glob(jd, backward=backward)
return {
'maximum': sweList[1][0],
'begin': sweList[1][2],
'end': sweList[1][3],
'totality_begin': sweList[1][4],
'totality_end': sweList[1][5],
'center_line_begin': sweList[1][6],
'center_line_end': sweList[1][7],
}


def lunarEclipseGlobal(jd, backward):
""" Returns the jd details of previous or next global lunar eclipse. """

sweList = swisseph.lun_eclipse_when(jd, backward=backward)
return {
'maximum': sweList[1][0],
'partial_begin': sweList[1][2],
'partial_end': sweList[1][3],
'totality_begin': sweList[1][4],
'totality_end': sweList[1][5],
'penumbral_begin': sweList[1][6],
'penumbral_end': sweList[1][7],
}
22 changes: 3 additions & 19 deletions flatlib/ephem/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,26 +82,10 @@ def solarReturnJD(jd, lon, forward=True):
if forward:
dist = angle.distance(sun, lon)
else:
dist = -angle.distance(lon, sun)

dist = angle.distance(lon, sun)
while abs(dist) > MAX_ERROR:
jd = jd + dist / 0.9833 # Sun mean motion
sun = swe.sweObjectLon(const.SUN, jd)
dist = angle.closestdistance(sun, lon)
return jd


# === Other algorithms === #

def nextStationJD(ID, jd):
""" Finds the aproximate julian date of the
next station of a planet.

"""
speed = swe.sweObject(ID, jd)['lonspeed']
for i in range(2000):
nextjd = jd + i / 2
nextspeed = swe.sweObject(ID, nextjd)['lonspeed']
if speed * nextspeed <= 0:
return nextjd
return None
return jd
69 changes: 69 additions & 0 deletions flatlib/moonca.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
from flatlib import const
from flatlib.chart import Chart
from flatlib.datetime import Datetime
from flatlib.ephem import swe

"""
Module to calcualate the moon next ingress and
voc
"""

# Assign a minute in Julian Calendar
MINUTE = const.MINUTE
# List of house distances
DIST = [0, 2, 3, 4, 6, 8, 9, 10]

# Mean Moon motion in deg/s
MEAN_MOTION_MOON_S = const.MEAN_MOTION_MOON / 86400

MAX_ERROR = 0.0003

def next_moon_ingress(chart):
"""
Calculates datetime of the next Moon ingress
"""

# Define the sign angles
angles = [30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330, 360]

# Initate local variables
# The next sign angle from the current moon position
angle = 0.0
# Distance between the current Moon position and the next sign
dist = 0.0
# Intiate iteration counter for statistical purposes
i = 0

# Load the current Moon position
moon_lon = swe.sweObjectLon(const.MOON, chart.date.jd)

# Find the next sign angle
for ang in angles:
if moon_lon < ang:
angle = ang
dist = ang - moon_lon
break

# Evalute a mean time in days before the next Moon ingress
jd = dist / const.MEAN_MOTION_MOON

# Add the 'jd' into the the current Moon position
jd = jd + chart.date.jd

# Run the loop for calculating the ingress time
while abs(dist) > MAX_ERROR:
# Get Moon longtitude
moon_lon = swe.sweObjectLon(const.MOON, jd)
# Correct value of the moon's longtitude if ingress
# to Aries
if angle == 360 and moon_lon >= 0.0 and moon_lon < 30.0:
moon_lon = moon_lon + 360.0

# Calcualte distance
dist = angle - moon_lon
# Calculate position differential
jd = jd + dist / const.MEAN_MOTION_MOON

i += 1
return {'Date':Datetime.fromJD(jd, '+00:00'), 'Iter':i}

Loading