sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
def arc(pRA, pDecl, sRA, sDecl, mcRA, lat): """ Returns the arc of direction between a Promissor and Significator. It uses the generic proportional semi-arc method. """ pDArc, pNArc = utils.dnarcs(pDecl, lat) sDArc, sNArc = utils.dnarcs(sDecl, lat) # Select meridian and arcs to be used # Default is MC and Diurnal arcs mdRA = mcRA sArc = sDArc pArc = pDArc if not utils.isAboveHorizon(sRA, sDecl, mcRA, lat): # Use IC and Nocturnal arcs mdRA = angle.norm(mcRA + 180) sArc = sNArc pArc = pNArc # Promissor and Significator distance to meridian pDist = angle.closestdistance(mdRA, pRA) sDist = angle.closestdistance(mdRA, sRA) # Promissor should be after significator (in degrees) if pDist < sDist: pDist += 360 # Meridian distances proportional to respective semi-arcs sPropDist = sDist / (sArc / 2.0) pPropDist = pDist / (pArc / 2.0) # The arc is how much of the promissor's semi-arc is # needed to reach the significator return (pPropDist - sPropDist) * (pArc / 2.0)
Returns the arc of direction between a Promissor and Significator. It uses the generic proportional semi-arc method.
entailment
def getArc(prom, sig, mc, pos, zerolat): """ Returns the arc of direction between a promissor and a significator. Arguments are also the MC, the geoposition and zerolat to assume zero ecliptical latitudes. ZeroLat true => inZodiaco, false => inMundo """ pRA, pDecl = prom.eqCoords(zerolat) sRa, sDecl = sig.eqCoords(zerolat) mcRa, mcDecl = mc.eqCoords() return arc(pRA, pDecl, sRa, sDecl, mcRa, pos.lat)
Returns the arc of direction between a promissor and a significator. Arguments are also the MC, the geoposition and zerolat to assume zero ecliptical latitudes. ZeroLat true => inZodiaco, false => inMundo
entailment
def _buildTerms(self): """ Builds a data structure indexing the terms longitude by sign and object. """ termLons = tables.termLons(tables.EGYPTIAN_TERMS) res = {} for (ID, sign, lon) in termLons: try: res[sign][ID] = lon except KeyError: res[sign] = {} res[sign][ID] = lon return res
Builds a data structure indexing the terms longitude by sign and object.
entailment
def G(self, ID, lat, lon): """ Creates a generic entry for an object. """ # Equatorial coordinates eqM = utils.eqCoords(lon, lat) eqZ = eqM if lat != 0: eqZ = utils.eqCoords(lon, 0) return { 'id': ID, 'lat': lat, 'lon': lon, 'ra': eqM[0], 'decl': eqM[1], 'raZ': eqZ[0], 'declZ': eqZ[1], }
Creates a generic entry for an object.
entailment
def T(self, ID, sign): """ Returns the term of an object in a sign. """ lon = self.terms[sign][ID] ID = 'T_%s_%s' % (ID, sign) return self.G(ID, 0, lon)
Returns the term of an object in a sign.
entailment
def A(self, ID): """ Returns the Antiscia of an object. """ obj = self.chart.getObject(ID).antiscia() ID = 'A_%s' % (ID) return self.G(ID, obj.lat, obj.lon)
Returns the Antiscia of an object.
entailment
def C(self, ID): """ Returns the CAntiscia of an object. """ obj = self.chart.getObject(ID).cantiscia() ID = 'C_%s' % (ID) return self.G(ID, obj.lat, obj.lon)
Returns the CAntiscia of an object.
entailment
def D(self, ID, asp): """ Returns the dexter aspect of an object. """ obj = self.chart.getObject(ID).copy() obj.relocate(obj.lon - asp) ID = 'D_%s_%s' % (ID, asp) return self.G(ID, obj.lat, obj.lon)
Returns the dexter aspect of an object.
entailment
def N(self, ID, asp=0): """ Returns the conjunction or opposition aspect of an object. """ obj = self.chart.get(ID).copy() obj.relocate(obj.lon + asp) ID = 'N_%s_%s' % (ID, asp) return self.G(ID, obj.lat, obj.lon)
Returns the conjunction or opposition aspect of an object.
entailment
def _arc(self, prom, sig): """ Computes the in-zodiaco and in-mundo arcs between a promissor and a significator. """ arcm = arc(prom['ra'], prom['decl'], sig['ra'], sig['decl'], self.mcRA, self.lat) arcz = arc(prom['raZ'], prom['declZ'], sig['raZ'], sig['declZ'], self.mcRA, self.lat) return { 'arcm': arcm, 'arcz': arcz }
Computes the in-zodiaco and in-mundo arcs between a promissor and a significator.
entailment
def getArc(self, prom, sig): """ Returns the arcs between a promissor and a significator. Should uses the object creation functions to build the objects. """ res = self._arc(prom, sig) res.update({ 'prom': prom['id'], 'sig': sig['id'] }) return res
Returns the arcs between a promissor and a significator. Should uses the object creation functions to build the objects.
entailment
def _elements(self, IDs, func, aspList): """ Returns the IDs as objects considering the aspList and the function. """ res = [] for asp in aspList: if (asp in [0, 180]): # Generate func for conjunctions and oppositions if func == self.N: res.extend([func(ID, asp) for ID in IDs]) else: res.extend([func(ID) for ID in IDs]) else: # Generate Dexter and Sinister for others res.extend([self.D(ID, asp) for ID in IDs]) res.extend([self.S(ID, asp) for ID in IDs]) return res
Returns the IDs as objects considering the aspList and the function.
entailment
def _terms(self): """ Returns a list with the objects as terms. """ res = [] for sign, terms in self.terms.items(): for ID, lon in terms.items(): res.append(self.T(ID, sign)) return res
Returns a list with the objects as terms.
entailment
def getList(self, aspList): """ Returns a sorted list with all primary directions. """ # Significators objects = self._elements(self.SIG_OBJECTS, self.N, [0]) houses = self._elements(self.SIG_HOUSES, self.N, [0]) angles = self._elements(self.SIG_ANGLES, self.N, [0]) significators = objects + houses + angles # Promissors objects = self._elements(self.SIG_OBJECTS, self.N, aspList) terms = self._terms() antiscias = self._elements(self.SIG_OBJECTS, self.A, [0]) cantiscias = self._elements(self.SIG_OBJECTS, self.C, [0]) promissors = objects + terms + antiscias + cantiscias # Compute all res = [] for prom in promissors: for sig in significators: if (prom['id'] == sig['id']): continue arcs = self._arc(prom, sig) for (x,y) in [('arcm', 'M'), ('arcz', 'Z')]: arc = arcs[x] if 0 < arc < self.MAX_ARC: res.append([ arcs[x], prom['id'], sig['id'], y, ]) return sorted(res)
Returns a sorted list with all primary directions.
entailment
def view(self, arcmin, arcmax): """ Returns the directions within the min and max arcs. """ res = [] for direction in self.table: if arcmin < direction[0] < arcmax: res.append(direction) return res
Returns the directions within the min and max arcs.
entailment
def bySignificator(self, ID): """ Returns all directions to a significator. """ res = [] for direction in self.table: if ID in direction[2]: res.append(direction) return res
Returns all directions to a significator.
entailment
def byPromissor(self, ID): """ Returns all directions to a promissor. """ res = [] for direction in self.table: if ID in direction[1]: res.append(direction) return res
Returns all directions to a promissor.
entailment
def copy(self): """ Returns a deep copy of this chart. """ chart = Chart.__new__(Chart) chart.date = self.date chart.pos = self.pos chart.hsys = self.hsys chart.objects = self.objects.copy() chart.houses = self.houses.copy() chart.angles = self.angles.copy() return chart
Returns a deep copy of this chart.
entailment
def get(self, ID): """ Returns an object, house or angle from the chart. """ if ID.startswith('House'): return self.getHouse(ID) elif ID in const.LIST_ANGLES: return self.getAngle(ID) else: return self.getObject(ID)
Returns an object, house or angle from the chart.
entailment
def getFixedStars(self): """ Returns a list with all fixed stars. """ IDs = const.LIST_FIXED_STARS return ephem.getFixedStarList(IDs, self.date)
Returns a list with all fixed stars.
entailment
def isHouse1Asc(self): """ Returns true if House1 is the same as the Asc. """ house1 = self.getHouse(const.HOUSE1) asc = self.getAngle(const.ASC) dist = angle.closestdistance(house1.lon, asc.lon) return abs(dist) < 0.0003
Returns true if House1 is the same as the Asc.
entailment
def isHouse10MC(self): """ Returns true if House10 is the same as the MC. """ house10 = self.getHouse(const.HOUSE10) mc = self.getAngle(const.MC) dist = angle.closestdistance(house10.lon, mc.lon) return abs(dist) < 0.0003
Returns true if House10 is the same as the MC.
entailment
def isDiurnal(self): """ Returns true if this chart is diurnal. """ sun = self.getObject(const.SUN) mc = self.getAngle(const.MC) # Get ecliptical positions and check if the # sun is above the horizon. lat = self.pos.lat sunRA, sunDecl = utils.eqCoords(sun.lon, sun.lat) mcRA, mcDecl = utils.eqCoords(mc.lon, 0) return utils.isAboveHorizon(sunRA, sunDecl, mcRA, lat)
Returns true if this chart is diurnal.
entailment
def getMoonPhase(self): """ Returns the phase of the moon. """ sun = self.getObject(const.SUN) moon = self.getObject(const.MOON) dist = angle.distance(sun.lon, moon.lon) if dist < 90: return const.MOON_FIRST_QUARTER elif dist < 180: return const.MOON_SECOND_QUARTER elif dist < 270: return const.MOON_THIRD_QUARTER else: return const.MOON_LAST_QUARTER
Returns the phase of the moon.
entailment
def solarReturn(self, year): """ Returns this chart's solar return for a given year. """ sun = self.getObject(const.SUN) date = Datetime('{0}/01/01'.format(year), '00:00', self.date.utcoffset) srDate = ephem.nextSolarReturn(date, sun.lon) return Chart(srDate, self.pos, hsys=self.hsys)
Returns this chart's solar return for a given year.
entailment
def objLon(ID, chart): """ Returns the longitude of an object. """ if ID.startswith('$R'): # Return Ruler ID = ID[2:] obj = chart.get(ID) rulerID = essential.ruler(obj.sign) ruler = chart.getObject(rulerID) return ruler.lon elif ID.startswith('Pars'): # Return an arabic part return partLon(ID, chart) else: # Return an object obj = chart.get(ID) return obj.lon
Returns the longitude of an object.
entailment
def partLon(ID, chart): """ Returns the longitude of an arabic part. """ # Get diurnal or nocturnal formula abc = FORMULAS[ID][0] if chart.isDiurnal() else FORMULAS[ID][1] a = objLon(abc[0], chart) b = objLon(abc[1], chart) c = objLon(abc[2], chart) return c + b - a
Returns the longitude of an arabic part.
entailment
def getPart(ID, chart): """ Returns an Arabic Part. """ obj = GenericObject() obj.id = ID obj.type = const.OBJ_ARABIC_PART obj.relocate(partLon(ID, chart)) return obj
Returns an Arabic Part.
entailment
def sweObject(obj, jd): """ Returns an object from the Ephemeris. """ sweObj = SWE_OBJECTS[obj] sweList = swisseph.calc_ut(jd, sweObj) return { 'id': obj, 'lon': sweList[0], 'lat': sweList[1], 'lonspeed': sweList[3], 'latspeed': sweList[4] }
Returns an object from the Ephemeris.
entailment
def sweObjectLon(obj, jd): """ Returns the longitude of an object. """ sweObj = SWE_OBJECTS[obj] sweList = swisseph.calc_ut(jd, sweObj) return sweList[0]
Returns the longitude of an object.
entailment
def sweNextTransit(obj, jd, lat, lon, flag): """ Returns the julian date of the next transit of an object. The flag should be 'RISE' or 'SET'. """ sweObj = SWE_OBJECTS[obj] flag = swisseph.CALC_RISE if flag == 'RISE' else swisseph.CALC_SET trans = swisseph.rise_trans(jd, sweObj, lon, lat, 0, 0, 0, flag) return trans[1][0]
Returns the julian date of the next transit of an object. The flag should be 'RISE' or 'SET'.
entailment
def sweHouses(jd, lat, lon, hsys): """ Returns lists of houses and angles. """ hsys = SWE_HOUSESYS[hsys] hlist, ascmc = swisseph.houses(jd, lat, lon, hsys) # Add first house to the end of 'hlist' so that we # can compute house sizes with an iterator hlist += (hlist[0],) houses = [ { 'id': const.LIST_HOUSES[i], 'lon': hlist[i], 'size': angle.distance(hlist[i], hlist[i+1]) } for i in range(12) ] angles = [ {'id': const.ASC, 'lon': ascmc[0]}, {'id': const.MC, 'lon': ascmc[1]}, {'id': const.DESC, 'lon': angle.norm(ascmc[0] + 180)}, {'id': const.IC, 'lon': angle.norm(ascmc[1] + 180)} ] return (houses, angles)
Returns lists of houses and angles.
entailment
def sweHousesLon(jd, lat, lon, hsys): """ Returns lists with house and angle longitudes. """ hsys = SWE_HOUSESYS[hsys] hlist, ascmc = swisseph.houses(jd, lat, lon, hsys) angles = [ ascmc[0], ascmc[1], angle.norm(ascmc[0] + 180), angle.norm(ascmc[1] + 180) ] return (hlist, angles)
Returns lists with house and angle longitudes.
entailment
def sweFixedStar(star, jd): """ Returns a fixed star from the Ephemeris. """ sweList = swisseph.fixstar_ut(star, jd) mag = swisseph.fixstar_mag(star) return { 'id': star, 'mag': mag, 'lon': sweList[0], 'lat': sweList[1] }
Returns a fixed star from the Ephemeris.
entailment
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], }
Returns the jd details of previous or next global solar eclipse.
entailment
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], }
Returns the jd details of previous or next global lunar eclipse.
entailment
def dateJDN(year, month, day, calendar): """ Converts date to Julian Day Number. """ a = (14 - month) // 12 y = year + 4800 - a m = month + 12*a - 3 if calendar == GREGORIAN: return day + (153*m + 2)//5 + 365*y + y//4 - y//100 + y//400 - 32045 else: return day + (153*m + 2)//5 + 365*y + y//4 - 32083
Converts date to Julian Day Number.
entailment
def jdnDate(jdn): """ Converts Julian Day Number to Gregorian date. """ a = jdn + 32044 b = (4*a + 3) // 146097 c = a - (146097*b) // 4 d = (4*c + 3) // 1461 e = c - (1461*d) // 4 m = (5*e + 2) // 153 day = e + 1 - (153*m + 2) // 5 month = m + 3 - 12*(m//10) year = 100*b + d - 4800 + m//10 return [year, month, day]
Converts Julian Day Number to Gregorian date.
entailment
def toList(self): """ Returns date as signed list. """ date = self.date() sign = '+' if date[0] >= 0 else '-' date[0] = abs(date[0]) return list(sign) + date
Returns date as signed list.
entailment
def toString(self): """ Returns date as string. """ slist = self.toList() sign = '' if slist[0] == '+' else '-' string = '/'.join(['%02d' % v for v in slist[1:]]) return sign + string
Returns date as string.
entailment
def getUTC(self, utcoffset): """ Returns a new Time object set to UTC given an offset Time object. """ newTime = (self.value - utcoffset.value) % 24 return Time(newTime)
Returns a new Time object set to UTC given an offset Time object.
entailment
def time(self): """ Returns time as list [hh,mm,ss]. """ slist = self.toList() if slist[0] == '-': slist[1] *= -1 # We must do a trick if we want to # make negative zeros explicit if slist[1] == -0: slist[1] = -0.0 return slist[1:]
Returns time as list [hh,mm,ss].
entailment
def toList(self): """ Returns time as signed list. """ slist = angle.toList(self.value) # Keep hours in 0..23 slist[1] = slist[1] % 24 return slist
Returns time as signed list.
entailment
def toString(self): """ Returns time as string. """ slist = self.toList() string = angle.slistStr(slist) return string if slist[0] == '-' else string[1:]
Returns time as string.
entailment
def fromJD(jd, utcoffset): """ Builds a Datetime object given a jd and utc offset. """ if not isinstance(utcoffset, Time): utcoffset = Time(utcoffset) localJD = jd + utcoffset.value / 24.0 date = Date(round(localJD)) time = Time((localJD + 0.5 - date.jdn) * 24) return Datetime(date, time, utcoffset)
Builds a Datetime object given a jd and utc offset.
entailment
def getUTC(self): """ Returns this Datetime localized for UTC. """ timeUTC = self.time.getUTC(self.utcoffset) dateUTC = Date(round(self.jd)) return Datetime(dateUTC, timeUTC)
Returns this Datetime localized for UTC.
entailment
def getObject(ID, jd, lat, lon): """ Returns an object for a specific date and location. """ if ID == const.SOUTH_NODE: obj = swe.sweObject(const.NORTH_NODE, jd) obj.update({ 'id': const.SOUTH_NODE, 'lon': angle.norm(obj['lon'] + 180) }) elif ID == const.PARS_FORTUNA: pflon = tools.pfLon(jd, lat, lon) obj = { 'id': ID, 'lon': pflon, 'lat': 0, 'lonspeed': 0, 'latspeed': 0 } elif ID == const.SYZYGY: szjd = tools.syzygyJD(jd) obj = swe.sweObject(const.MOON, szjd) obj['id'] = const.SYZYGY else: obj = swe.sweObject(ID, jd) _signInfo(obj) return obj
Returns an object for a specific date and location.
entailment
def getHouses(jd, lat, lon, hsys): """ Returns lists of houses and angles. """ houses, angles = swe.sweHouses(jd, lat, lon, hsys) for house in houses: _signInfo(house) for angle in angles: _signInfo(angle) return (houses, angles)
Returns lists of houses and angles.
entailment
def getFixedStar(ID, jd): """ Returns a fixed star. """ star = swe.sweFixedStar(ID, jd) _signInfo(star) return star
Returns a fixed star.
entailment
def nextSunrise(jd, lat, lon): """ Returns the JD of the next sunrise. """ return swe.sweNextTransit(const.SUN, jd, lat, lon, 'RISE')
Returns the JD of the next sunrise.
entailment
def nextSunset(jd, lat, lon): """ Returns the JD of the next sunset. """ return swe.sweNextTransit(const.SUN, jd, lat, lon, 'SET')
Returns the JD of the next sunset.
entailment
def _signInfo(obj): """ Appends the sign id and longitude to an object. """ lon = obj['lon'] obj.update({ 'sign': const.LIST_SIGNS[int(lon / 30)], 'signlon': lon % 30 })
Appends the sign id and longitude to an object.
entailment
def pfLon(jd, lat, lon): """ Returns the ecliptic longitude of Pars Fortuna. It considers diurnal or nocturnal conditions. """ sun = swe.sweObjectLon(const.SUN, jd) moon = swe.sweObjectLon(const.MOON, jd) asc = swe.sweHousesLon(jd, lat, lon, const.HOUSES_DEFAULT)[1][0] if isDiurnal(jd, lat, lon): return angle.norm(asc + moon - sun) else: return angle.norm(asc + sun - moon)
Returns the ecliptic longitude of Pars Fortuna. It considers diurnal or nocturnal conditions.
entailment
def isDiurnal(jd, lat, lon): """ Returns true if the sun is above the horizon of a given date and location. """ sun = swe.sweObject(const.SUN, jd) mc = swe.sweHousesLon(jd, lat, lon, const.HOUSES_DEFAULT)[1][1] ra, decl = utils.eqCoords(sun['lon'], sun['lat']) mcRA, _ = utils.eqCoords(mc, 0.0) return utils.isAboveHorizon(ra, decl, mcRA, lat)
Returns true if the sun is above the horizon of a given date and location.
entailment
def syzygyJD(jd): """ Finds the latest new or full moon and returns the julian date of that event. """ sun = swe.sweObjectLon(const.SUN, jd) moon = swe.sweObjectLon(const.MOON, jd) dist = angle.distance(sun, moon) # Offset represents the Syzygy type. # Zero is conjunction and 180 is opposition. offset = 180 if (dist >= 180) else 0 while abs(dist) > MAX_ERROR: jd = jd - dist / 13.1833 # Moon mean daily motion sun = swe.sweObjectLon(const.SUN, jd) moon = swe.sweObjectLon(const.MOON, jd) dist = angle.closestdistance(sun - offset, moon) return jd
Finds the latest new or full moon and returns the julian date of that event.
entailment
def solarReturnJD(jd, lon, forward=True): """ Finds the julian date before or after 'jd' when the sun is at longitude 'lon'. It searches forward by default. """ sun = swe.sweObjectLon(const.SUN, jd) if forward: dist = angle.distance(sun, lon) else: 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
Finds the julian date before or after 'jd' when the sun is at longitude 'lon'. It searches forward by default.
entailment
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
Finds the aproximate julian date of the next station of a planet.
entailment
def clean_caches(path): """ Removes all python cache files recursively on a path. :param path: the path :return: None """ for dirname, subdirlist, filelist in os.walk(path): for f in filelist: if f.endswith('pyc'): try: os.remove(os.path.join(dirname, f)) except FileNotFoundError: pass if dirname.endswith('__pycache__'): shutil.rmtree(dirname)
Removes all python cache files recursively on a path. :param path: the path :return: None
entailment
def clean_py_files(path): """ Removes all .py files. :param path: the path :return: None """ for dirname, subdirlist, filelist in os.walk(path): for f in filelist: if f.endswith('py'): os.remove(os.path.join(dirname, f))
Removes all .py files. :param path: the path :return: None
entailment
def toFloat(value): """ Converts angle representation to float. Accepts angles and strings such as "12W30:00". """ if isinstance(value, str): # Find lat/lon char in string and insert angle sign value = value.upper() for char in ['N', 'S', 'E', 'W']: if char in value: value = SIGN[char] + value.replace(char, ':') break return angle.toFloat(value)
Converts angle representation to float. Accepts angles and strings such as "12W30:00".
entailment
def toString(value, mode): """ Converts angle float to string. Mode refers to LAT/LON. """ string = angle.toString(value) sign = string[0] separator = CHAR[mode][sign] string = string.replace(':', separator, 1) return string[1:]
Converts angle float to string. Mode refers to LAT/LON.
entailment
def strings(self): """ Return lat/lon as strings. """ return [ toString(self.lat, LAT), toString(self.lon, LON) ]
Return lat/lon as strings.
entailment
def _orbList(obj1, obj2, aspList): """ Returns a list with the orb and angular distances from obj1 to obj2, considering a list of possible aspects. """ sep = angle.closestdistance(obj1.lon, obj2.lon) absSep = abs(sep) return [ { 'type': asp, 'orb': abs(absSep - asp), 'separation': sep, } for asp in aspList ]
Returns a list with the orb and angular distances from obj1 to obj2, considering a list of possible aspects.
entailment
def _aspectDict(obj1, obj2, aspList): """ Returns the properties of the aspect of obj1 to obj2, considering a list of possible aspects. This function makes the following assumptions: - Syzygy does not start aspects but receives any aspect. - Pars Fortuna and Moon Nodes only starts conjunctions but receive any aspect. - All other objects can start and receive any aspect. Note: this function returns the aspect even if it is not within the orb of obj1 (but is within the orb of obj2). """ # Ignore aspects from same and Syzygy if obj1 == obj2 or obj1.id == const.SYZYGY: return None orbs = _orbList(obj1, obj2, aspList) for aspDict in orbs: asp = aspDict['type'] orb = aspDict['orb'] # Check if aspect is within orb if asp in const.MAJOR_ASPECTS: # Ignore major aspects out of orb if obj1.orb() < orb and obj2.orb() < orb: continue else: # Ignore minor aspects out of max orb if MAX_MINOR_ASP_ORB < orb: continue # Only conjunctions for Pars Fortuna and Nodes if obj1.id in [const.PARS_FORTUNA, const.NORTH_NODE, const.SOUTH_NODE] and \ asp != const.CONJUNCTION: continue # We have a valid aspect within orb return aspDict return None
Returns the properties of the aspect of obj1 to obj2, considering a list of possible aspects. This function makes the following assumptions: - Syzygy does not start aspects but receives any aspect. - Pars Fortuna and Moon Nodes only starts conjunctions but receive any aspect. - All other objects can start and receive any aspect. Note: this function returns the aspect even if it is not within the orb of obj1 (but is within the orb of obj2).
entailment
def _aspectProperties(obj1, obj2, aspDict): """ Returns the properties of an aspect between obj1 and obj2, given by 'aspDict'. This function assumes obj1 to be the active object, i.e., the one responsible for starting the aspect. """ orb = aspDict['orb'] asp = aspDict['type'] sep = aspDict['separation'] # Properties prop1 = { 'id': obj1.id, 'inOrb': False, 'movement': const.NO_MOVEMENT } prop2 = { 'id': obj2.id, 'inOrb': False, 'movement': const.NO_MOVEMENT } prop = { 'type': asp, 'orb': orb, 'direction': -1, 'condition': -1, 'active': prop1, 'passive': prop2 } if asp == const.NO_ASPECT: return prop # Aspect within orb prop1['inOrb'] = orb <= obj1.orb() prop2['inOrb'] = orb <= obj2.orb() # Direction prop['direction'] = const.DEXTER if sep <= 0 else const.SINISTER # Sign conditions # Note: if obj1 is before obj2, orbDir will be less than zero orbDir = sep-asp if sep >= 0 else sep+asp offset = obj1.signlon + orbDir if 0 <= offset < 30: prop['condition'] = const.ASSOCIATE else: prop['condition'] = const.DISSOCIATE # Movement of the individual objects if abs(orbDir) < MAX_EXACT_ORB: prop1['movement'] = prop2['movement'] = const.EXACT else: # Active object applies to Passive if it is before # and direct, or after the Passive and Rx.. prop1['movement'] = const.SEPARATIVE if (orbDir > 0 and obj1.isDirect()) or \ (orbDir < 0 and obj1.isRetrograde()): prop1['movement'] = const.APPLICATIVE elif obj1.isStationary(): prop1['movement'] = const.STATIONARY # The Passive applies or separates from the Active # if it has a different direction.. # Note: Non-planets have zero speed prop2['movement'] = const.NO_MOVEMENT obj2speed = obj2.lonspeed if obj2.isPlanet() else 0.0 sameDir = obj1.lonspeed * obj2speed >= 0 if not sameDir: prop2['movement'] = prop1['movement'] return prop
Returns the properties of an aspect between obj1 and obj2, given by 'aspDict'. This function assumes obj1 to be the active object, i.e., the one responsible for starting the aspect.
entailment
def _getActivePassive(obj1, obj2): """ Returns which is the active and the passive objects. """ speed1 = abs(obj1.lonspeed) if obj1.isPlanet() else -1.0 speed2 = abs(obj2.lonspeed) if obj2.isPlanet() else -1.0 if speed1 > speed2: return { 'active': obj1, 'passive': obj2 } else: return { 'active': obj2, 'passive': obj1 }
Returns which is the active and the passive objects.
entailment
def aspectType(obj1, obj2, aspList): """ Returns the aspect type between objects considering a list of possible aspect types. """ ap = _getActivePassive(obj1, obj2) aspDict = _aspectDict(ap['active'], ap['passive'], aspList) return aspDict['type'] if aspDict else const.NO_ASPECT
Returns the aspect type between objects considering a list of possible aspect types.
entailment
def hasAspect(obj1, obj2, aspList): """ Returns if there is an aspect between objects considering a list of possible aspect types. """ aspType = aspectType(obj1, obj2, aspList) return aspType != const.NO_ASPECT
Returns if there is an aspect between objects considering a list of possible aspect types.
entailment
def isAspecting(obj1, obj2, aspList): """ Returns if obj1 aspects obj2 within its orb, considering a list of possible aspect types. """ aspDict = _aspectDict(obj1, obj2, aspList) if aspDict: return aspDict['orb'] < obj1.orb() return False
Returns if obj1 aspects obj2 within its orb, considering a list of possible aspect types.
entailment
def getAspect(obj1, obj2, aspList): """ Returns an Aspect object for the aspect between two objects considering a list of possible aspect types. """ ap = _getActivePassive(obj1, obj2) aspDict = _aspectDict(ap['active'], ap['passive'], aspList) if not aspDict: aspDict = { 'type': const.NO_ASPECT, 'orb': 0, 'separation': 0, } aspProp = _aspectProperties(ap['active'], ap['passive'], aspDict) return Aspect(aspProp)
Returns an Aspect object for the aspect between two objects considering a list of possible aspect types.
entailment
def movement(self): """ Returns the movement of this aspect. The movement is the one of the active object, except if the active is separating but within less than 1 degree. """ mov = self.active.movement if self.orb < 1 and mov == const.SEPARATIVE: mov = const.EXACT return mov
Returns the movement of this aspect. The movement is the one of the active object, except if the active is separating but within less than 1 degree.
entailment
def getRole(self, ID): """ Returns the role (active or passive) of an object in this aspect. """ if self.active.id == ID: return { 'role': 'active', 'inOrb': self.active.inOrb, 'movement': self.active.movement } elif self.passive.id == ID: return { 'role': 'passive', 'inOrb': self.passive.inOrb, 'movement': self.passive.movement } return None
Returns the role (active or passive) of an object in this aspect.
entailment
def setFaces(variant): """ Sets the default faces variant """ global FACES if variant == CHALDEAN_FACES: FACES = tables.CHALDEAN_FACES else: FACES = tables.TRIPLICITY_FACES
Sets the default faces variant
entailment
def setTerms(variant): """ Sets the default terms of the Dignities table. """ global TERMS if variant == EGYPTIAN_TERMS: TERMS = tables.EGYPTIAN_TERMS elif variant == TETRABIBLOS_TERMS: TERMS = tables.TETRABIBLOS_TERMS elif variant == LILLY_TERMS: TERMS = tables.LILLY_TERMS
Sets the default terms of the Dignities table.
entailment
def term(sign, lon): """ Returns the term for a sign and longitude. """ terms = TERMS[sign] for (ID, a, b) in terms: if (a <= lon < b): return ID return None
Returns the term for a sign and longitude.
entailment
def face(sign, lon): """ Returns the face for a sign and longitude. """ faces = FACES[sign] if lon < 10: return faces[0] elif lon < 20: return faces[1] else: return faces[2]
Returns the face for a sign and longitude.
entailment
def getInfo(sign, lon): """ Returns the complete essential dignities for a sign and longitude. """ return { 'ruler': ruler(sign), 'exalt': exalt(sign), 'dayTrip': dayTrip(sign), 'nightTrip': nightTrip(sign), 'partTrip': partTrip(sign), 'term': term(sign, lon), 'face': face(sign, lon), 'exile': exile(sign), 'fall': fall(sign) }
Returns the complete essential dignities for a sign and longitude.
entailment
def isPeregrine(ID, sign, lon): """ Returns if an object is peregrine on a sign and longitude. """ info = getInfo(sign, lon) for dign, objID in info.items(): if dign not in ['exile', 'fall'] and ID == objID: return False return True
Returns if an object is peregrine on a sign and longitude.
entailment
def score(ID, sign, lon): """ Returns the score of an object on a sign and longitude. """ info = getInfo(sign, lon) dignities = [dign for (dign, objID) in info.items() if objID == ID] return sum([SCORES[dign] for dign in dignities])
Returns the score of an object on a sign and longitude.
entailment
def almutem(sign, lon): """ Returns the almutem for a given sign and longitude. """ planets = const.LIST_SEVEN_PLANETS res = [None, 0] for ID in planets: sc = score(ID, sign, lon) if sc > res[1]: res = [ID, sc] return res[0]
Returns the almutem for a given sign and longitude.
entailment
def getDignities(self): """ Returns the dignities belonging to this object. """ info = self.getInfo() dignities = [dign for (dign, objID) in info.items() if objID == self.obj.id] return dignities
Returns the dignities belonging to this object.
entailment
def isPeregrine(self): """ Returns if this object is peregrine. """ return isPeregrine(self.obj.id, self.obj.sign, self.obj.signlon)
Returns if this object is peregrine.
entailment
def _computeChart(chart, date): """ Internal function to return a new chart for a specific date using properties from old chart. """ pos = chart.pos hsys = chart.hsys IDs = [obj.id for obj in chart.objects] return Chart(date, pos, IDs=IDs, hsys=hsys)
Internal function to return a new chart for a specific date using properties from old chart.
entailment
def nextSolarReturn(chart, date): """ Returns the solar return of a Chart after a specific date. """ sun = chart.getObject(const.SUN) srDate = ephem.nextSolarReturn(date, sun.lon) return _computeChart(chart, srDate)
Returns the solar return of a Chart after a specific date.
entailment
def hourTable(date, pos): """ Creates the planetary hour table for a date and position. The table includes both diurnal and nocturnal hour sequences and each of the 24 entries (12 * 2) are like (startJD, endJD, ruler). """ lastSunrise = ephem.lastSunrise(date, pos) middleSunset = ephem.nextSunset(lastSunrise, pos) nextSunrise = ephem.nextSunrise(date, pos) table = [] # Create diurnal hour sequence length = (middleSunset.jd - lastSunrise.jd) / 12.0 for i in range(12): start = lastSunrise.jd + i * length end = start + length ruler = nthRuler(i, lastSunrise.date.dayofweek()) table.append([start, end, ruler]) # Create nocturnal hour sequence length = (nextSunrise.jd - middleSunset.jd) / 12.0 for i in range(12): start = middleSunset.jd + i * length end = start + length ruler = nthRuler(i + 12, lastSunrise.date.dayofweek()) table.append([start, end, ruler]) return table
Creates the planetary hour table for a date and position. The table includes both diurnal and nocturnal hour sequences and each of the 24 entries (12 * 2) are like (startJD, endJD, ruler).
entailment
def getHourTable(date, pos): """ Returns an HourTable object. """ table = hourTable(date, pos) return HourTable(table, date)
Returns an HourTable object.
entailment
def index(self, date): """ Returns the index of a date in the table. """ for (i, (start, end, ruler)) in enumerate(self.table): if start <= date.jd <= end: return i return None
Returns the index of a date in the table.
entailment
def indexInfo(self, index): """ Returns information about a specific planetary time. """ entry = self.table[index] info = { # Default is diurnal 'mode': 'Day', 'ruler': self.dayRuler(), 'dayRuler': self.dayRuler(), 'nightRuler': self.nightRuler(), 'hourRuler': entry[2], 'hourNumber': index + 1, 'tableIndex': index, 'start': Datetime.fromJD(entry[0], self.date.utcoffset), 'end': Datetime.fromJD(entry[1], self.date.utcoffset) } if index >= 12: # Set information as nocturnal info.update({ 'mode': 'Night', 'ruler': info['nightRuler'], 'hourNumber': index + 1 - 12 }) return info
Returns information about a specific planetary time.
entailment
def compute(chart, date, fixedObjects=False): """ Returns a profection chart for a given date. Receives argument 'fixedObjects' to fix chart objects in their natal locations. """ sun = chart.getObject(const.SUN) prevSr = ephem.prevSolarReturn(date, sun.lon) nextSr = ephem.nextSolarReturn(date, sun.lon) # In one year, rotate chart 30º rotation = 30 * (date.jd - prevSr.jd) / (nextSr.jd - prevSr.jd) # Include 30º for each previous year age = math.floor((date.jd - chart.date.jd) / 365.25) rotation = 30 * age + rotation # Create a copy of the chart and rotate content pChart = chart.copy() for obj in pChart.objects: if not fixedObjects: obj.relocate(obj.lon + rotation) for house in pChart.houses: house.relocate(house.lon + rotation) for angle in pChart.angles: angle.relocate(angle.lon + rotation) return pChart
Returns a profection chart for a given date. Receives argument 'fixedObjects' to fix chart objects in their natal locations.
entailment
def _merge(listA, listB): """ Merges two list of objects removing repetitions. """ listA = [x.id for x in listA] listB = [x.id for x in listB] listA.extend(listB) set_ = set(listA) return list(set_)
Merges two list of objects removing repetitions.
entailment
def compute(chart): """ Computes the behavior. """ factors = [] # Planets in House1 or Conjunct Asc house1 = chart.getHouse(const.HOUSE1) planetsHouse1 = chart.objects.getObjectsInHouse(house1) asc = chart.getAngle(const.ASC) planetsConjAsc = chart.objects.getObjectsAspecting(asc, [0]) _set = _merge(planetsHouse1, planetsConjAsc) factors.append(['Planets in House1 or Conj Asc', _set]) # Planets conjunct Moon or Mercury moon = chart.get(const.MOON) mercury = chart.get(const.MERCURY) planetsConjMoon = chart.objects.getObjectsAspecting(moon, [0]) planetsConjMercury = chart.objects.getObjectsAspecting(mercury, [0]) _set = _merge(planetsConjMoon, planetsConjMercury) factors.append(['Planets Conj Moon or Mercury', _set]) # Asc ruler if aspected by disposer ascRulerID = essential.ruler(asc.sign) ascRuler = chart.getObject(ascRulerID) disposerID = essential.ruler(ascRuler.sign) disposer = chart.getObject(disposerID) _set = [] if aspects.isAspecting(disposer, ascRuler, const.MAJOR_ASPECTS): _set = [ascRuler.id] factors.append(['Asc Ruler if aspected by its disposer', _set]); # Planets aspecting Moon or Mercury aspMoon = chart.objects.getObjectsAspecting(moon, [60,90,120,180]) aspMercury = chart.objects.getObjectsAspecting(mercury, [60,90,120,180]) _set = _merge(aspMoon, aspMercury) factors.append(['Planets Asp Moon or Mercury', _set]) return factors
Computes the behavior.
entailment
def termLons(TERMS): """ Returns a list with the absolute longitude of all terms. """ res = [] for i, sign in enumerate(SIGN_LIST): termList = TERMS[sign] res.extend([ ID, sign, start + 30 * i, ] for (ID, start, end) in termList) return res
Returns a list with the absolute longitude of all terms.
entailment
def compute(chart): """ Computes the Almutem table. """ almutems = {} # Hylegic points hylegic = [ chart.getObject(const.SUN), chart.getObject(const.MOON), chart.getAngle(const.ASC), chart.getObject(const.PARS_FORTUNA), chart.getObject(const.SYZYGY) ] for hyleg in hylegic: row = newRow() digInfo = essential.getInfo(hyleg.sign, hyleg.signlon) # Add the scores of each planet where hyleg has dignities for dignity in DIGNITY_LIST: objID = digInfo[dignity] if objID: score = essential.SCORES[dignity] row[objID]['string'] += '+%s' % score row[objID]['score'] += score almutems[hyleg.id] = row # House positions row = newRow() for objID in OBJECT_LIST: obj = chart.getObject(objID) house = chart.houses.getObjectHouse(obj) score = HOUSE_SCORES[house.id] row[objID]['string'] = '+%s' % score row[objID]['score'] = score almutems['Houses'] = row # Planetary time row = newRow() table = planetarytime.getHourTable(chart.date, chart.pos) ruler = table.currRuler() hourRuler = table.hourRuler() row[ruler] = { 'string': '+7', 'score': 7 } row[hourRuler] = { 'string': '+6', 'score': 6 } almutems['Rulers'] = row; # Compute scores scores = newRow() for _property, _list in almutems.items(): for objID, values in _list.items(): scores[objID]['string'] += values['string'] scores[objID]['score'] += values['score'] almutems['Score'] = scores return almutems
Computes the Almutem table.
entailment
def get(self, resource_id=None, resource_action=None, resource_cls=None, single_resource=False): """ Gets the details for one or more resources by ID Args: cls - gophish.models.Model - The resource class resource_id - str - The endpoint (URL path) for the resource resource_action - str - An action to perform on the resource resource_cls - cls - A class to use for parsing, if different than the base resource single_resource - bool - An override to tell Gophish that even though we aren't requesting a single resource, we expect a single response object Returns: One or more instances of cls parsed from the returned JSON """ endpoint = self.endpoint if not resource_cls: resource_cls = self._cls if resource_id: endpoint = self._build_url(endpoint, resource_id) if resource_action: endpoint = self._build_url(endpoint, resource_action) response = self.api.execute("GET", endpoint) if not response.ok: raise Error.parse(response.json()) if resource_id or single_resource: return resource_cls.parse(response.json()) return [resource_cls.parse(resource) for resource in response.json()]
Gets the details for one or more resources by ID Args: cls - gophish.models.Model - The resource class resource_id - str - The endpoint (URL path) for the resource resource_action - str - An action to perform on the resource resource_cls - cls - A class to use for parsing, if different than the base resource single_resource - bool - An override to tell Gophish that even though we aren't requesting a single resource, we expect a single response object Returns: One or more instances of cls parsed from the returned JSON
entailment
def post(self, resource): """ Creates a new instance of the resource. Args: resource - gophish.models.Model - The resource instance """ response = self.api.execute( "POST", self.endpoint, json=(resource.as_dict())) if not response.ok: raise Error.parse(response.json()) return self._cls.parse(response.json())
Creates a new instance of the resource. Args: resource - gophish.models.Model - The resource instance
entailment
def put(self, resource): """ Edits an existing resource Args: resource - gophish.models.Model - The resource instance """ endpoint = self.endpoint if resource.id: endpoint = self._build_url(endpoint, resource.id) response = self.api.execute("PUT", endpoint, json=resource.as_dict()) if not response.ok: raise Error.parse(response.json()) return self._cls.parse(response.json())
Edits an existing resource Args: resource - gophish.models.Model - The resource instance
entailment
def delete(self, resource_id): """ Deletes an existing resource Args: resource_id - int - The resource ID to be deleted """ endpoint = '{}/{}'.format(self.endpoint, resource_id) response = self.api.execute("DELETE", endpoint) if not response.ok: raise Error.parse(response.json()) return self._cls.parse(response.json())
Deletes an existing resource Args: resource_id - int - The resource ID to be deleted
entailment
def as_dict(self): """ Returns a dict representation of the resource """ result = {} for key in self._valid_properties: val = getattr(self, key) if isinstance(val, datetime): val = val.isoformat() # Parse custom classes elif val and not Model._is_builtin(val): val = val.as_dict() # Parse lists of objects elif isinstance(val, list): # We only want to call as_dict in the case where the item # isn't a builtin type. for i in range(len(val)): if Model._is_builtin(val[i]): continue val[i] = val[i].as_dict() # If it's a boolean, add it regardless of the value elif isinstance(val, bool): result[key] = val # Add it if it's not None if val: result[key] = val return result
Returns a dict representation of the resource
entailment
def execute(self, method, path, **kwargs): """ Executes a request to a given endpoint, returning the result """ url = "{}{}".format(self.host, path) kwargs.update(self._client_kwargs) response = requests.request( method, url, headers={"Authorization": "Bearer {}".format(self.api_key)}, **kwargs) return response
Executes a request to a given endpoint, returning the result
entailment
def complete(self, campaign_id): """ Complete an existing campaign (Stop processing events) """ return super(API, self).get( resource_id=campaign_id, resource_action='complete')
Complete an existing campaign (Stop processing events)
entailment