|
16 | 16 |
|
17 | 17 | import swisseph as swe |
18 | 18 |
|
19 | | -from immanuel.const import chart, names |
20 | 19 | from immanuel.classes.cache import cache |
| 20 | +from immanuel.classes.localize import localize as _ |
| 21 | +from immanuel.const import chart, names |
21 | 22 | from immanuel.tools import calculate, find |
22 | | -from immanuel.classes.localize import _ |
23 | 23 |
|
24 | 24 |
|
25 | 25 | ALL = -1 |
@@ -333,10 +333,12 @@ def _angle(index: int, jd: float, lat: float, lon: float, house_system: int, arm |
333 | 333 |
|
334 | 334 | def _house(index: int, jd: float, lat: float, lon: float, house_system: int, armc: float, armc_obliquity: float) -> dict: |
335 | 335 | """ 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 | + |
336 | 338 | 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'] |
338 | 340 | 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'] |
340 | 342 |
|
341 | 343 | if index == ALL: |
342 | 344 | return houses |
@@ -519,22 +521,24 @@ def _is_daytime(jd: float, lat: float, lon: float, armc: float, armc_obliquity: |
519 | 521 |
|
520 | 522 |
|
521 | 523 | @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) |
527 | 530 |
|
528 | 531 |
|
529 | 532 | @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) |
535 | 539 |
|
536 | 540 |
|
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: |
538 | 542 | """ Get houses, angles & vertex direct from pyswisseph. """ |
539 | 543 | angles = {} |
540 | 544 |
|
@@ -566,11 +570,19 @@ def _angles_houses_vertex_from_swe(obliquity: float, cusps: tuple, ascmc: tuple, |
566 | 570 |
|
567 | 571 | houses = {} |
568 | 572 |
|
569 | | - for i, lon in enumerate(cusps, start=1): |
| 573 | + for i in range(1, 13): |
570 | 574 | 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] |
574 | 586 |
|
575 | 587 | houses[index] = { |
576 | 588 | 'index': index, |
@@ -668,3 +680,8 @@ def _swisseph_point(index: int, jd: float) -> dict: |
668 | 680 | def _type(index: int) -> int: |
669 | 681 | """ Return the type index of a given object's index. """ |
670 | 682 | 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 |
0 commit comments