Skip to content

Commit 479e2b7

Browse files
committed
Added planet on first house systems.
1 parent 655e168 commit 479e2b7

File tree

11 files changed

+83
-26
lines changed

11 files changed

+83
-26
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ Immanuel's output is currently available in the following locales / languages:
2222
* **es_ES:** Spanish
2323
* **de_DE:** German
2424

25-
See [here](https://github.com/theriftlab/immanuel-python/tree/v1.4.3/docs/5-settings.md#locale) for details on how to switch. The documentation itself is not currently available in other translations. To contribute in-software translations, see [here](https://github.com/theriftlab/immanuel-python/tree/v1.4.3/docs/7-contributions.md).
25+
See [here](https://github.com/theriftlab/immanuel-python/tree/v1.4.4/docs/5-settings.md#locale) for details on how to switch. The documentation itself is not currently available in other translations. To contribute in-software translations, see [here](https://github.com/theriftlab/immanuel-python/tree/v1.4.4/docs/7-contributions.md).
2626

2727
## Documentation
2828

29-
Full documentation is available [here](https://github.com/theriftlab/immanuel-python/tree/v1.4.3/docs/0-contents.md), or follow the Quick Start below to see how to quickly generate a natal chart.
29+
Full documentation is available [here](https://github.com/theriftlab/immanuel-python/tree/v1.4.4/docs/0-contents.md), or follow the Quick Start below to see how to quickly generate a natal chart.
3030

3131
## Quick Start
3232

docs/5-settings.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,16 @@ Which house system to use. Available options:
183183
* `chart.REGIOMONTANUS`
184184
* `chart.VEHLOW_EQUAL`
185185
* `chart.WHOLE_SIGN`
186+
* `chart.SUN_ON_FIRST`
187+
* `chart.MOON_ON_FIRST`
188+
* `chart.MERCURY_ON_FIRST`
189+
* `chart.VENUS_ON_FIRST`
190+
* `chart.MARS_ON_FIRST`
191+
* `chart.JUPITER_ON_FIRST`
192+
* `chart.SATURN_ON_FIRST`
193+
* `chart.URANUS_ON_FIRST`
194+
* `chart.NEPTUNE_ON_FIRST`
195+
* `chart.PLUTO_ON_FIRST`
186196

187197
Default: `chart.PLACIDUS`
188198

immanuel/charts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from zoneinfo import ZoneInfo
2323

2424
from immanuel.classes import wrap
25-
from immanuel.classes.localize import _
25+
from immanuel.classes.localize import localize as _
2626
from immanuel.const import calc, chart, names
2727
from immanuel.reports import aspect, dignity, pattern, weighting
2828
from immanuel.setup import settings

immanuel/classes/localize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def reset() -> None:
5151
MAPPINGS = {}
5252

5353

54-
def _(input: str, context: str = None) -> str:
54+
def localize(input: str, context: str = None) -> str:
5555
if Localize.translation is None:
5656
return input
5757

immanuel/classes/wrap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111

1212
from datetime import datetime
1313

14+
from immanuel.classes.localize import gender, localize as _
1415
from immanuel.const import calc, chart, dignities, names
1516
from immanuel.reports import dignity
1617
from immanuel.setup import settings
1718
from immanuel.tools import calculate, convert, date, ephemeris, position
18-
from immanuel.classes.localize import gender, _
1919

2020

2121
class Angle:

immanuel/const/chart.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,17 @@
6565
REGIOMONTANUS = 111
6666
VEHLOW_EQUAL = 112
6767
WHOLE_SIGN = 113
68+
PLANET_ON_FIRST = 1000
69+
SUN_ON_FIRST = 1001
70+
MOON_ON_FIRST = 1002
71+
MERCURY_ON_FIRST = 1003
72+
VENUS_ON_FIRST = 1004
73+
MARS_ON_FIRST = 1005
74+
JUPITER_ON_FIRST = 1006
75+
SATURN_ON_FIRST = 1007
76+
URANUS_ON_FIRST = 1008
77+
NEPTUNE_ON_FIRST = 1009
78+
PLUTO_ON_FIRST = 1010
6879

6980
""" Houses. """
7081
HOUSE = 2 * TYPE_MULTIPLIER

immanuel/const/names.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,16 @@
7676
chart.REGIOMONTANUS: 'Regiomontanus',
7777
chart.VEHLOW_EQUAL: 'Vehlow Equal House',
7878
chart.WHOLE_SIGN: 'Whole Sign',
79+
chart.SUN_ON_FIRST: 'Sun On First',
80+
chart.MOON_ON_FIRST: 'Moon On First',
81+
chart.MERCURY_ON_FIRST: 'Mercury On First',
82+
chart.VENUS_ON_FIRST: 'Venus On First',
83+
chart.MARS_ON_FIRST: 'Mars On First',
84+
chart.JUPITER_ON_FIRST: 'Jupiter On First',
85+
chart.SATURN_ON_FIRST: 'Saturn On First',
86+
chart.URANUS_ON_FIRST: 'Uranus On First',
87+
chart.NEPTUNE_ON_FIRST: 'Neptune On First',
88+
chart.PLUTO_ON_FIRST: 'Pluto On First',
7989
}
8090

8191
HOUSES = {

immanuel/tools/ephemeris.py

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616

1717
import swisseph as swe
1818

19-
from immanuel.const import chart, names
2019
from immanuel.classes.cache import cache
20+
from immanuel.classes.localize import localize as _
21+
from immanuel.const import chart, names
2122
from immanuel.tools import calculate, find
22-
from immanuel.classes.localize import _
2323

2424

2525
ALL = -1
@@ -333,10 +333,12 @@ def _angle(index: int, jd: float, lat: float, lon: float, house_system: int, arm
333333

334334
def _house(index: int, jd: float, lat: float, lon: float, house_system: int, armc: float, armc_obliquity: float) -> dict:
335335
""" Function for house() and armc_house(). """
336+
first_house_lon = get(_first_house_planet(house_system), jd)['lon'] if house_system > chart.PLANET_ON_FIRST else None
337+
336338
if armc is not None:
337-
houses = _angles_houses_vertex_armc(armc, lat, armc_obliquity, house_system)['houses']
339+
houses = _angles_houses_vertex_armc(armc, lat, armc_obliquity, house_system, first_house_lon)['houses']
338340
else:
339-
houses = _angles_houses_vertex(jd, lat, lon, house_system)['houses']
341+
houses = _angles_houses_vertex(jd, lat, lon, house_system, first_house_lon)['houses']
340342

341343
if index == ALL:
342344
return houses
@@ -519,22 +521,24 @@ def _is_daytime(jd: float, lat: float, lon: float, armc: float, armc_obliquity:
519521

520522

521523
@cache
522-
def _angles_houses_vertex(jd: float, lat: float, lon: float, house_system: int) -> dict:
523-
""" Returns ecliptic longitudes for the houses, main angles,
524-
and the vertex, along with their speeds. Based on Julian
525-
date and lat / lon coordinates. """
526-
return _angles_houses_vertex_from_swe(obliquity(jd), *swe.houses_ex2(jd, lat, lon, _SWE[house_system]))
524+
def _angles_houses_vertex(jd: float, lat: float, lon: float, house_system: int, first_house_lon: float = None) -> dict:
525+
""" Returns ecliptic longitudes for the houses, main angles, and the vertex,
526+
along with their speeds. Defaults to Placidus for main angles & vertex if
527+
an PLANET_ON_FIRST house system is chosen. Based on Julian date and
528+
lat / lon coordinates. """
529+
return _angles_houses_vertex_from_swe(obliquity(jd), *swe.houses_ex2(jd, lat, lon, _SWE[house_system if house_system < chart.PLANET_ON_FIRST else chart.PLACIDUS]), first_house_lon)
527530

528531

529532
@cache
530-
def _angles_houses_vertex_armc(armc: float, lat: float, obliquity: float, house_system: int) -> dict:
531-
""" Returns ecliptic longitudes for the houses, main angles,
532-
and the vertex, along with their speeds. Based on ARMC, latitude
533-
and ecliptic obliquity. """
534-
return _angles_houses_vertex_from_swe(obliquity, *swe.houses_armc_ex2(armc, lat, obliquity, _SWE[house_system]))
533+
def _angles_houses_vertex_armc(armc: float, lat: float, obliquity: float, house_system: int, first_house_lon: float = None) -> dict:
534+
""" Returns ecliptic longitudes for the houses, main angles, and the vertex,
535+
along with their speeds. Defaults to Placidus for main angles & vertex if
536+
an PLANET_ON_FIRST house system is chosen. Based on ARMC, latitude and
537+
ecliptic obliquity. """
538+
return _angles_houses_vertex_from_swe(obliquity, *swe.houses_armc_ex2(armc, lat, obliquity, _SWE[house_system if house_system < chart.PLANET_ON_FIRST else chart.PLACIDUS]), first_house_lon)
535539

536540

537-
def _angles_houses_vertex_from_swe(obliquity: float, cusps: tuple, ascmc: tuple, cuspsspeed: tuple, ascmcspeed: tuple) -> dict:
541+
def _angles_houses_vertex_from_swe(obliquity: float, cusps: tuple, ascmc: tuple, cuspsspeed: tuple, ascmcspeed: tuple, first_house_lon: float) -> dict:
538542
""" Get houses, angles & vertex direct from pyswisseph. """
539543
angles = {}
540544

@@ -566,11 +570,19 @@ def _angles_houses_vertex_from_swe(obliquity: float, cusps: tuple, ascmc: tuple,
566570

567571
houses = {}
568572

569-
for i, lon in enumerate(cusps, start=1):
573+
for i in range(1, 13):
570574
index = chart.HOUSE + i
571-
size = swe.difdeg2n(cusps[i if i < 12 else 0], lon)
572-
speed = cuspsspeed[i-1]
573-
dec = swe.cotrans((lon, 0, 0), -obliquity)[1]
575+
576+
if first_house_lon is not None:
577+
lon = swe.degnorm(first_house_lon + (30 * (i-1)))
578+
size = 30
579+
speed = 0
580+
dec = 0
581+
else:
582+
lon = cusps[i-1]
583+
size = swe.difdeg2n(cusps[i if i < 12 else 0], lon)
584+
speed = cuspsspeed[i-1]
585+
dec = swe.cotrans((lon, 0, 0), -obliquity)[1]
574586

575587
houses[index] = {
576588
'index': index,
@@ -668,3 +680,8 @@ def _swisseph_point(index: int, jd: float) -> dict:
668680
def _type(index: int) -> int:
669681
""" Return the type index of a given object's index. """
670682
return round(index, -2)
683+
684+
685+
def _first_house_planet(house_system: int) -> int:
686+
""" Return the index of the planet that marks the first house. """
687+
return (house_system - chart.PLANET_ON_FIRST) + chart.PLANET

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "immanuel"
7-
version = "1.4.3"
7+
version = "1.4.4"
88
description = "Quickly produce both human-readable and JSON-formatted astrology chart data based on the Swiss Ephemeris and astro.com."
99
authors = [
1010
{ name = "Robert Davies", email = "robert@theriftlab.com" },

tests/test_ephemeris.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,15 @@ def test_armc_house(jd, coords, armc, all_houses):
299299
assert ephemeris.armc_house(ephemeris.ALL, armc, coords[0], obliquity, chart.PLACIDUS) == ephemeris.armc_houses(armc, coords[0], obliquity, chart.PLACIDUS)
300300

301301

302+
def test_planet_on_first_house(jd, coords):
303+
sun = ephemeris.planet(chart.SUN, jd)
304+
first_house = ephemeris.house(chart.HOUSE1, jd, *coords, chart.SUN_ON_FIRST)
305+
second_house = ephemeris.house(chart.HOUSE2, jd, *coords, chart.SUN_ON_FIRST)
306+
307+
assert sun['lon'] == first_house['lon']
308+
assert sun['lon'] + 30 == second_house['lon']
309+
310+
302311
def test_point(jd, coords, all_points):
303312
for index in all_points:
304313
point = ephemeris.point(index, jd, *coords, chart.PLACIDUS, calc.DAY_NIGHT_FORMULA)

0 commit comments

Comments
 (0)