Esempio n. 1
0
    def _calc_midpoints(self):
        """Calculate midpoints.

        :todo: fetch houses results?
        """
        res = MidPointDataList() # results
        filt = self._filter._midpoints._planets
        jd = self.julday
        flag = self._filter.get_calcflag()
        self._setup_swisseph()
        all_pl = all_planets()
        # get all concerned planets, if not already calculated
        plres = PlanetDataList()
        for pl in [x for x in filt if filt[x]]:
            try:
                plres.append(self._planets.get_data(pl))
            except KeyError:
                p = all_pl[pl]
                plres.feed(p, p.calc_ut(jd, flag, self))
        # get midpoints
        plres.sort_by_ranking()
        for i, pos1 in enumerate(plres[:-1]):
            for pos2 in plres[i+1:]:
                if pos1._planet == pos2._planet:
                    continue
                res.feed(pos1, pos2,
                    (swe.deg_midp(pos1._longitude, pos2._longitude), # midp long
                        (pos1._latitude + pos2._latitude) / 2, # midp lat
                        (pos1._distance + pos2._distance) / 2, # midp dist
                        (pos1._lonspeed + pos2._lonspeed) / 2, # midp long speed
                        (pos1._latspeed + pos2._latspeed) / 2, # midp lat speed
                        (pos1._distspeed + pos2._distspeed) / 2) # midp dist speed
                    )
        self._midpoints = res
Esempio n. 2
0
    def _calc_planets(self):
        """Calculate planets positions (but houses).

        Houses must be calculated first (for parts).

        """
        res = PlanetDataList() # results
        filt = self._filter._planets
        jd = self.julday
        flag = self._filter.get_calcflag()
        self._setup_swisseph()
        all_pl = all_planets()
        # get planets
        db.close() # fixstars_ut will overflow on sqlite buffers: close db.
        for k, v in filt.items():
            if v == False: # not this object
                continue
            p = all_pl[k]
            if p._family == 4: # houses, dont calc
                continue
            else:
                res.feed(p, p.calc_ut(jd, flag, self))
        db.connect() # fixstars_ut bug: reopen db
        # add cusps needed
        for h in self._houses:
            if filt[h._planet._name]:
                res.append(self._houses.get_data(h._planet._name))
        self._planets = res
Esempio n. 3
0
 def _calc_midp_aspects(self):
     """Calculate midpoints aspects."""
     res = MidPointAspectDataList() # results
     midpres = self._midpoints
     jd = self.julday
     flag = self._filter.get_calcflag()
     self._setup_swisseph()
     f = self._filter._midpoints
     all_pl = all_planets()
     all_asp = all_aspects()
     # get all concerned planets, if not already calculated
     plres = PlanetDataList()
     for pl in [x for x in f._planets if f._planets[x] and f._asprestr[x]]:
         try:
             plres.append(self._planets.get_data(pl))
         except KeyError:
             p = all_pl[pl]
             plres.feed(p, p.calc_ut(jd, flag, self))
     # get midp aspects
     plres.sort_by_ranking()
     for i, midp in enumerate(midpres):
         ##p1, p2 = midp._planet, midp._planet2
         lon1, lonsp1 = midp._longitude, midp._lonspeed
         for pos in plres:
             pl, lon2, lonsp2 = pos._planet, pos._longitude, pos._lonspeed
             for asp, doasp in f._aspects.items():
                 if not doasp: # dont use this aspect
                     continue
                 asp = all_asp[asp]
                 # modify orb
                 orb = f._orbs[asp._name]
                 #orbmod1 = plorbfilt[p1._name].get_absolute(orb)
                 orbmod1 = 0 # todo?: midp obrestr
                 orbmod2 = f._orbrestr[pl._name].get_absolute(orb)
                 orb += (orbmod1 + orbmod2) / Decimal('2')
                 if orb < 0: # we'll never get such a precision
                     continue
                 # check aspect match
                 diff, apply, factor = swe._match_aspect2(
                     lon1, lonsp1, lon2, lonsp2,
                     float(asp._angle), float(orb))
                 if diff != None:
                     res.feed(midp, pos, asp, diff, apply, factor)
     self._midp_aspects = res
Esempio n. 4
0
    def add_pos(self, value):
        """Add degrees to positions.

        Chart positions must be computed before.

        :see: calc()

        :type value: numeric
        """
        pl = PlanetDataList()
        value = float(value)
        for pos in self._planets:
            ##if pos._planet._family == 4: # houses
                ##continue
            pos._longitude = swe.degnorm(pos._longitude + value)
            pl.append(pos)
        self._planets = pl
        # recalc
        self._calc_aspects()
        if self._filter._calc_midp:
            self._calc_midpoints()
            self._calc_midp_aspects()