text_prompt
stringlengths
157
13.1k
code_prompt
stringlengths
7
19.8k
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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): if slist[i] == 60: slist[i] = 0 slist[i-1] += 1 return slist[:-1]
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def strSlist(string): """ Converts angle string to signed list. """
sign = '-' if string[0] == '-' else '+' values = [abs(int(x)) for x in string.split(':')] return _fixSlist(list(sign) + values)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def slistStr(slist): """ Converts signed list to angle string. """
slist = _fixSlist(slist) string = ':'.join(['%02d' % x for x in slist[1:]]) return slist[0] + string
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def slistFloat(slist): """ Converts signed list to float. """
values = [v / 60**(i) for (i,v) in enumerate(slist[1:])] value = sum(values) return -value if slist[0] == '-' else value
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def floatSlist(value): """ Converts float to signed list. """
slist = ['+', 0, 0, 0, 0] if value < 0: slist[0] = '-' value = abs(value) for i in range(1,5): slist[i] = math.floor(value) value = (value - slist[i]) * 60 return _roundSlist(slist)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def toFloat(value): """ Converts string or signed list to float. """
if isinstance(value, str): return strFloat(value) elif isinstance(value, list): return slistFloat(value) else: return value
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def inDignities(self, idA, idB): """ Returns the dignities of A which belong to B. """
objA = self.chart.get(idA) info = essential.getInfo(objA.sign, objA.signlon) # Should we ignore exile and fall? return [dign for (dign, ID) in info.items() if ID == idB]
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def mutualReceptions(self, idA, idB): """ Returns all pairs of dignities in mutual reception. """
AB = self.receives(idA, idB) BA = self.receives(idB, idA) # Returns a product of both lists return [(a,b) for a in AB for b in BA]
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def reMutualReceptions(self, idA, idB): """ Returns ruler and exaltation mutual receptions. """
mr = self.mutualReceptions(idA, idB) filter_ = ['ruler', 'exalt'] # Each pair of dignities must be 'ruler' or 'exalt' return [(a,b) for (a,b) in mr if (a in filter_ and b in filter_)]
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def validAspects(self, ID, aspList): """ Returns a list with the aspects an object makes with the other six planets, considering a list of possible aspects. """
obj = self.chart.getObject(ID) res = [] for otherID in const.LIST_SEVEN_PLANETS: if ID == otherID: continue otherObj = self.chart.getObject(otherID) aspType = aspects.aspectType(obj, otherObj, aspList) if aspT...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def immediateAspects(self, ID, aspList): """ Returns the last separation and next application considering a list of possible aspects. """
asps = self.aspectsByCat(ID, aspList) applications = asps[const.APPLICATIVE] separations = asps[const.SEPARATIVE] exact = asps[const.EXACT] # Get applications and separations sorted by orb applications = applications + [val for val in exact if val['orb'] >= 0] ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def singleFactor(factors, chart, factor, obj, aspect=None): """" Single factor for the table. """
objID = obj if type(obj) == str else obj.id res = { 'factor': factor, 'objID': objID, 'aspect': aspect } # For signs (obj as string) return sign element if type(obj) == str: res['element'] = props.sign.element[obj] # For Sun return sign and sun...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def modifierFactor(chart, factor, factorObj, otherObj, aspList): """ Computes a factor for a modifier. """
asp = aspects.aspectType(factorObj, otherObj, aspList) if asp != const.NO_ASPECT: return { 'factor': factor, 'aspect': asp, 'objID': otherObj.id, 'element': otherObj.element() } return None
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def getFactors(chart): """ Returns the factors for the temperament. """
factors = [] # Asc sign asc = chart.getAngle(const.ASC) singleFactor(factors, chart, ASC_SIGN, asc.sign) # Asc ruler ascRulerID = essential.ruler(asc.sign) ascRuler = chart.getObject(ascRulerID) singleFactor(factors, chart, ASC_RULER, ascRuler) singleFactor(factors, c...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def getModifiers(chart): """ Returns the factors of the temperament modifiers. """
modifiers = [] # Factors which can be affected asc = chart.getAngle(const.ASC) ascRulerID = essential.ruler(asc.sign) ascRuler = chart.getObject(ascRulerID) moon = chart.getObject(const.MOON) factors = [ [MOD_ASC, asc], [MOD_ASC_RULER, ascRuler], [MOD_MOON,...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def scores(factors): """ Computes the score of temperaments and elements. """
temperaments = { const.CHOLERIC: 0, const.MELANCHOLIC: 0, const.SANGUINE: 0, const.PHLEGMATIC: 0 } qualities = { const.HOT: 0, const.COLD: 0, const.DRY: 0, const.HUMID: 0 } for factor in factors: eleme...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def getObject(ID, date, pos): """ Returns an ephemeris object. """
obj = eph.getObject(ID, date.jd, pos.lat, pos.lon) return Object.fromDict(obj)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def getObjectList(IDs, date, pos): """ Returns a list of objects. """
objList = [getObject(ID, date, pos) for ID in IDs] return ObjectList(objList)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def getHouses(date, pos, hsys): """ Returns the lists of houses and angles. Since houses and angles are computed at the same time, this function should be fast. ...
houses, angles = eph.getHouses(date.jd, pos.lat, pos.lon, hsys) hList = [House.fromDict(house) for house in houses] aList = [GenericObject.fromDict(angle) for angle in angles] return (HouseList(hList), GenericList(aList))
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def getFixedStar(ID, date): """ Returns a fixed star from the ephemeris. """
star = eph.getFixedStar(ID, date.jd) return FixedStar.fromDict(star)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def getFixedStarList(IDs, date): """ Returns a list of fixed stars. """
starList = [getFixedStar(ID, date) for ID in IDs] return FixedStarList(starList)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def nextSolarReturn(date, lon): """ Returns the next date when sun is at longitude 'lon'. """
jd = eph.nextSolarReturn(date.jd, lon) return Datetime.fromJD(jd, date.utcoffset)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def prevSolarReturn(date, lon): """ Returns the previous date when sun is at longitude 'lon'. """
jd = eph.prevSolarReturn(date.jd, lon) return Datetime.fromJD(jd, date.utcoffset)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def nextSunrise(date, pos): """ Returns the date of the next sunrise. """
jd = eph.nextSunrise(date.jd, pos.lat, pos.lon) return Datetime.fromJD(jd, date.utcoffset)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def nextStation(ID, date): """ Returns the aproximate date of the next station. """
jd = eph.nextStation(ID, date.jd) return Datetime.fromJD(jd, date.utcoffset)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def plot(hdiff, title): """ Plots the tropical solar length by year. """
import matplotlib.pyplot as plt years = [elem[0] for elem in hdiff] diffs = [elem[1] for elem in hdiff] plt.plot(years, diffs) plt.ylabel('Distance in minutes') plt.xlabel('Year') plt.title(title) plt.axhline(y=0, c='red') plt.show()
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def ascdiff(decl, lat): """ Returns the Ascensional Difference of a point. """
delta = math.radians(decl) phi = math.radians(lat) ad = math.asin(math.tan(delta) * math.tan(phi)) return math.degrees(ad)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def dnarcs(decl, lat): """ Returns the diurnal and nocturnal arcs of a point. """
dArc = 180 + 2 * ascdiff(decl, lat) nArc = 360 - dArc return (dArc, nArc)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def isAboveHorizon(ra, decl, mcRA, lat): """ Returns if an object's 'ra' and 'decl' is above the horizon at a specific latitude, given the MC's right ascension. ...
# This function checks if the equatorial distance from # the object to the MC is within its diurnal semi-arc. dArc, _ = dnarcs(decl, lat) dist = abs(angle.closestdistance(mcRA, ra)) return dist <= dArc/2.0 + 0.0003
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def eqCoords(lon, lat): """ Converts from ecliptical to equatorial coordinates. This algorithm is described in book 'Primary Directions', pp. 147-150. """
# Convert to radians _lambda = math.radians(lon) _beta = math.radians(lat) _epson = math.radians(23.44) # The earth's inclination # Declination in radians decl = math.asin(math.sin(_epson) * math.sin(_lambda) * math.cos(_beta) + \ math.cos(_epson) * math.sin(_beta)) # ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def sunRelation(obj, sun): """ Returns an object's relation with the sun. """
if obj.id == const.SUN: return None dist = abs(angle.closestdistance(sun.lon, obj.lon)) if dist < 0.2833: return CAZIMI elif dist < 8.0: return COMBUST elif dist < 16.0: return UNDER_SUN else: return None
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def light(obj, sun): """ Returns if an object is augmenting or diminishing light. """
dist = angle.distance(sun.lon, obj.lon) faster = sun if sun.lonspeed > obj.lonspeed else obj if faster == sun: return LIGHT_DIMINISHING if dist < 180 else LIGHT_AUGMENTING else: return LIGHT_AUGMENTING if dist < 180 else LIGHT_DIMINISHING
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def orientality(obj, sun): """ Returns if an object is oriental or occidental to the sun. """
dist = angle.distance(sun.lon, obj.lon) return OCCIDENTAL if dist < 180 else ORIENTAL
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def haiz(obj, chart): """ Returns if an object is in Haiz. """
objGender = obj.gender() objFaction = obj.faction() if obj.id == const.MERCURY: # Gender and faction of mercury depends on orientality sun = chart.getObject(const.SUN) orientalityM = orientality(obj, sun) if orientalityM == ORIENTAL: objGender = const.MASCUL...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def house(self): """ Returns the object's house. """
house = self.chart.houses.getObjectHouse(self.obj) return house
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def sunRelation(self): """ Returns the relation of the object with the sun. """
sun = self.chart.getObject(const.SUN) return sunRelation(self.obj, sun)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def light(self): """ Returns if object is augmenting or diminishing its light. """
sun = self.chart.getObject(const.SUN) return light(self.obj, sun)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def orientality(self): """ Returns the orientality of the object. """
sun = self.chart.getObject(const.SUN) return orientality(self.obj, sun)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def inHouseJoy(self): """ Returns if the object is in its house of joy. """
house = self.house() return props.object.houseJoy[self.obj.id] == house.id
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def inSignJoy(self): """ Returns if the object is in its sign of joy. """
return props.object.signJoy[self.obj.id] == self.obj.sign
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def reMutualReceptions(self): """ Returns all mutual receptions with the object and other planets, indexed by planet ID. It only includes ruler and exaltation re...
planets = copy(const.LIST_SEVEN_PLANETS) planets.remove(self.obj.id) mrs = {} for ID in planets: mr = self.dyn.reMutualReceptions(self.obj.id, ID) if mr: mrs[ID] = mr return mrs
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def aspectBenefics(self): """ Returns a list with the good aspects the object makes to the benefics. """
benefics = [const.VENUS, const.JUPITER] return self.__aspectLists(benefics, aspList=[0, 60, 120])
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def aspectMalefics(self): """ Returns a list with the bad aspects the object makes to the malefics. """
malefics = [const.MARS, const.SATURN] return self.__aspectLists(malefics, aspList=[0, 90, 180])
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def __sepApp(self, IDs, aspList): """ Returns true if the object last and next movement are separations and applications to objects in list IDs. It only consider...
sep, app = self.dyn.immediateAspects(self.obj.id, aspList) if sep is None or app is None: return False else: sepCondition = sep['id'] in IDs appCondition = app['id'] in IDs return sepCondition == appCondition == True
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def isAuxilied(self): """ Returns if the object is separating and applying to a benefic considering good aspects. """
benefics = [const.VENUS, const.JUPITER] return self.__sepApp(benefics, aspList=[0, 60, 120])
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def isSurrounded(self): """ Returns if the object is separating and applying to a malefic considering bad aspects. """
malefics = [const.MARS, const.SATURN] return self.__sepApp(malefics, aspList=[0, 90, 180])
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def isConjNorthNode(self): """ Returns if object is conjunct north node. """
node = self.chart.getObject(const.NORTH_NODE) return aspects.hasAspect(self.obj, node, aspList=[0])
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def isConjSouthNode(self): """ Returns if object is conjunct south node. """
node = self.chart.getObject(const.SOUTH_NODE) return aspects.hasAspect(self.obj, node, aspList=[0])
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def isFeral(self): """ Returns true if the object does not have any aspects. """
planets = copy(const.LIST_SEVEN_PLANETS) planets.remove(self.obj.id) for otherID in planets: otherObj = self.chart.getObject(otherID) if aspects.hasAspect(self.obj, otherObj, const.MAJOR_ASPECTS): return False return True
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def getActiveProperties(self): """ Returns the non-zero accidental dignities. """
score = self.getScoreProperties() return {key: value for (key, value) in score.items() if value != 0}
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def score(self): """ Returns the sum of the accidental dignities score. """
if not self.scoreProperties: self.scoreProperties = self.getScoreProperties() return sum(self.scoreProperties.values())
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def fromDict(cls, _dict): """ Builds instance from dictionary of properties. """
obj = cls() obj.__dict__.update(_dict) return obj
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def eqCoords(self, zerolat=False): """ Returns the Equatorial Coordinates of this object. Receives a boolean parameter to consider a zero latitude. """
lat = 0.0 if zerolat else self.lat return utils.eqCoords(self.lon, lat)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def relocate(self, lon): """ Relocates this object to a new longitude. """
self.lon = angle.norm(lon) self.signlon = self.lon % 30 self.sign = const.LIST_SIGNS[int(self.lon / 30.0)]
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def antiscia(self): """ Returns antiscia object. """
obj = self.copy() obj.type = const.OBJ_GENERIC obj.relocate(360 - obj.lon + 180) return obj
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def movement(self): """ Returns if this object is direct, retrograde or stationary. """
if abs(self.lonspeed) < 0.0003: return const.STATIONARY elif self.lonspeed > 0: return const.DIRECT else: return const.RETROGRADE
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def inHouse(self, lon): """ Returns if a longitude belongs to this house. """
dist = angle.distance(self.lon + House._OFFSET, lon) return dist < self.size
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def orb(self): """ Returns the orb of this fixed star. """
for (mag, orb) in FixedStar._ORBS: if self.mag < mag: return orb return 0.5
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def aspects(self, obj): """ Returns true if this star aspects another object. Fixed stars only aspect by conjunctions. """
dist = angle.closestdistance(self.lon, obj.lon) return abs(dist) < self.orb()
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def getObjectsInHouse(self, house): """ Returns a list with all objects in a house. """
res = [obj for obj in self if house.hasObject(obj)] return ObjectList(res)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def getObjectsAspecting(self, point, aspList): """ Returns a list of objects aspecting a point considering a list of possible aspects. """
res = [] for obj in self: if obj.isPlanet() and aspects.isAspecting(obj, point, aspList): res.append(obj) return ObjectList(res)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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 meth...
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 ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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 ...
pRA, pDecl = prom.eqCoords(zerolat) sRa, sDecl = sig.eqCoords(zerolat) mcRa, mcDecl = mc.eqCoords() return arc(pRA, pDecl, sRa, sDecl, mcRa, pos.lat)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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], ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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, ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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])...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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._ele...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def getFixedStars(self): """ Returns a list with all fixed stars. """
IDs = const.LIST_FIXED_STARS return ephem.getFixedStarList(IDs, self.date)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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) ret...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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.MO...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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] }
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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]
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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] }
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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_l...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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], ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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]