Skip to content

p21utils.py

Prithwis Mukerjee edited this page Sep 26, 2022 · 6 revisions



This file holds most of the major functions required to convert the basic horoscope into a rich JSON object. Some of the key functions are listed here. The rest can be deduced by looking at the code.

These functions implement, or rather calculate the PAC or Position-Aspect-Conjunct data that is recommended by KNRao in his book, Learn Hindu Astrology Easily.

Long2Rashi(x)

The longitude of a Graha is converted into the Rashi of the chart where it resides. The logic changes depending on whether we are working with p21.ChartType = 'Rashi' or 'Navamsa'. Parameter x is a tuple consisting of Graha Name and Longitude from list derived from the dictionary p21.GLon.

R11_LocateGrahaInRashi()

Creates a dictionary p21.GRashiN that stores the Rashi number for each Graha as determined by the Long2Rashi() function.

C10_DetermineBhavs()

Determines and stores the Bhava in list BhavN. For example, BhavN[1] has Rashi Number corresponding to First Bhav and BhavA[2] has the Rashi name corresponding to Second Bhava

C11_DetermineLord()

Determines the Lord of each Bhava. Determines the Rashi number where each Lord resides. Determines the Rashi name where each Lord resides.

C12_BhavOfGraha_Lord()

First Determines the Bhava where Each planet resides. Lagna always resides in First Bhava. Then Determines the Bhav where each Lord resides.

C21_DeterminePositions()

Calls a number of other functions to determine whether
C21A_checkGexa(x,level = 'low') : Graha is exalted. There is a low precision determination and high precision determination. Default is Low
C21B_checkLexa(x) : Lord is exalted
C21C_checkGdeb(x, level = 'low') : Graha is debilitated
C21D_checkLdeb(x): Lord is debilitated
C21E_checkm3G(x) : Present in MoonTrikon position
C21F_checkOwnHG(x) : Present in Own House or Not
C21G_checkfen(x,Z) : Present in Friend, Enemy, Neutral house
Creates a dictionary p21.Positions that is appended to the p21.chart dictionary

C31_DetermineAspects()

Determines which Graha and Lord aspects other Grahas and Lords and creates a dictionary p21.Aspects, that is appended to the p21.chart main dictionary

C41_DetermineConjuncts()

Determines which Grahas and Lords are conjunct with each other and creates a dictionary p21.Conjuncts, that is appended to the p21.chart main dictionary

Utility Functions

Here is list of functions that are used in other functions to carry out housekeeping work
appendDict(d1,d2) : Append one dictionary to another
d2l : Convert a dictionary to a list
l2d: Convert a list to a dictionary
RashiGapA(R2,R1) : Gap between two Rashis
addToD(x,D,y) : Add an element as a member of a set that is defined as the value of dictionary
csidtil(D) : This is a weird one. Convert a dictionary keys into strings without which it cannot be stored in MongoDB