full functional based in input . getting all house information. 14th oct 24 1929
after checking online portal get informatin.
give information as sample. in the code.
planet_data = [
("Lagna", "050 Dhan 49 54", "Mula", 2),
("Surya", "260 Simh 41 21", "Purvaphalguni", 4), # U Phalguni--> Uttaraphalguni
("Chandra", "Vibh Dhan 52 34", "Krittika", 4), # P Ashadha -->Uttarashadha
("Mangal", "270 Simha 01 02", "Purvaphalguni", 2),
("Budha", "220 Kanya 23 03", "Hasta", 2), #P Phalguni -->Purvaphalguni
("Guru", "260 Kany 58 08", "Ashwini", 2),
("Shukra", "070 Tula 58 34", "Uttaraphalguni", 2),
("Shani", "130 Kark 15 13", "Jyeshtha", 2),
("Spashth Rahu", "190 Meen 53 00", "Uttarabhadra", 2),
("Spashth Ketu", "190 Kany 53 00", "Uttaraphalguni", 4)
]
---- it will display output as follows.
H1=['Gur+']
H2=['Cha+']
H3=[]
H4=[]
H5=['Sur+', 'Kuj+']
H6=['Bhd-', 'Shu-', 'Mitra-', 'Ket+']
H7=[]
H8=['Sha-']
H9=['Lag']
H10=[]
H11=['Bho+']
H12=['Chitra-', 'Rah-']
with out duplicates of plants;
--------------------------------------
# Reference dictionary for Nakshatra to House mapping
nakshatra_to_house = {
# Mesh (H12)
'Purvabhadra 4': 'H12', 'Uttarabhadra 1': 'H12', 'Uttarabhadra 2': 'H12',
'Uttarabhadra 3': 'H12', 'Uttarabhadra 4': 'H12', 'Revati 1': 'H12',
'Revati 2': 'H12', 'Revati 3': 'H12', 'Revati 4': 'H12',
# Vibh (H1)
'Ashwini 1': 'H1', 'Ashwini 2': 'H1', 'Ashwini 3': 'H1', 'Ashwini 4': 'H1',
'Bharani 1': 'H1', 'Bharani 2': 'H1', 'Bharani 3': 'H1', 'Bharani 4': 'H1',
'Krittika 1': 'H1',
# Mitu (H2)
'Krittika 2': 'H2', 'Krittika 3': 'H2', 'Krittika 4': 'H2',
'Rohini 1': 'H2', 'Rohini 2': 'H2', 'Rohini 3': 'H2', 'Rohini 4': 'H2',
'Mrigashira 1': 'H2', 'Mrigashira 2': 'H2',
# Kark (H3)
'Mrigashira 3': 'H3', 'Mrigashira 4': 'H3', 'Ardra 1': 'H3', 'Ardra 2': 'H3',
'Ardra 3': 'H3', 'Ardra 4': 'H3', 'Punarvasu 1': 'H3', 'Punarvasu 2': 'H3',
'Punarvasu 3': 'H3',
# Simh (H4)
'Punarvasu 4': 'H4', 'Pushyami 1': 'H4', 'Pushyami 2': 'H4', 'Pushyami 3': 'H4',
'Pushyami 4': 'H4', 'Ashlesha 1': 'H4', 'Ashlesha 2': 'H4', 'Ashlesha 3': 'H4',
'Ashlesha 4': 'H4',
# Kany (H5)
'Magha 1': 'H5', 'Magha 2': 'H5', 'Magha 3': 'H5', 'Magha 4': 'H5',
'Purvaphalguni 1': 'H5', 'Purvaphalguni 2': 'H5', 'Purvaphalguni 3': 'H5',
'Purvaphalguni 4': 'H5', 'Uttaraphalguni 1': 'H5',
# Tula (H6)
'Uttaraphalguni 2': 'H6', 'Uttaraphalguni 3': 'H6', 'Uttaraphalguni 4': 'H6',
'Hasta 1': 'H6', 'Hasta 2': 'H6', 'Hasta 3': 'H6', 'Hasta 4': 'H6',
'Chitra 1': 'H6', 'Chitra 2': 'H6',
# Vish (H7)
'Chitra 3': 'H7', 'Chitra 4': 'H7', 'Swati 1': 'H7', 'Swati 2': 'H7',
'Swati 3': 'H7', 'Swati 4': 'H7', 'Vishaka 1': 'H7', 'Vishaka 2': 'H7',
'Vishaka 3': 'H7',
# Dhan (H8)
'Vishaka 4': 'H8', 'Anuradha 1': 'H8', 'Anuradha 2': 'H8', 'Anuradha 3': 'H8',
'Anuradha 4': 'H8', 'Jyeshtha 1': 'H8', 'Jyeshtha 2': 'H8', 'Jyeshtha 3': 'H8',
'Jyeshtha 4': 'H8',
# Maka (H9)
'Mula 1': 'H9', 'Mula 2': 'H9', 'Mula 3': 'H9', 'Mula 4': 'H9',
'Purvashadha 1': 'H9', 'Purvashadha 2': 'H9', 'Purvashadha 3': 'H9',
'Purvashadha 4': 'H9', 'Uttarashadha 1': 'H9',
# Kumb (H10)
'Uttarashadha 2': 'H10', 'Uttarashadha 3': 'H10', 'Uttarashadha 4': 'H10',
'Shravana 1': 'H10', 'Shravana 2': 'H10', 'Shravana 3': 'H10', 'Shravana 4': 'H10',
'Dhanishta 1': 'H10', 'Dhanishta 2': 'H10',
# Meen (H11)
'Dhanishta 3': 'H11', 'Dhanishta 4': 'H11', 'Shatabhisha 1': 'H11',
'Shatabhisha 2': 'H11', 'Shatabhisha 3': 'H11', 'Shatabhisha 4': 'H11',
'Purvabhadra 1': 'H11', 'Purvabhadra 2': 'H11', 'Purvabhadra 3': 'H11'
}
# Planets mapping to abbreviations
planet_abbr = {
'Lagna': 'Lag', 'Surya': 'Sur', 'Chandra': 'Cha', 'Mangal': 'Kuj', 'Budha': 'Bhd',
'Guru': 'Gur', 'Shukra': 'Shu', 'Shani': 'Sha', 'Spashth Rahu': 'Rah', 'Spashth Ketu': 'Ket'
}
# Input data
planet_data = [
("Lagna", "050 Dhan 49 54", "Mula", 2),
("Surya", "260 Simh 41 21", "Purvaphalguni", 4), # U Phalguni--> Uttaraphalguni
("Chandra", "Vibh Dhan 52 34", "Krittika", 4), # P Ashadha -->Uttarashadha
("Mangal", "270 Simha 01 02", "Purvaphalguni", 2),
("Budha", "220 Kanya 23 03", "Hasta", 2), #P Phalguni -->Purvaphalguni
("Guru", "260 Kany 58 08", "Ashwini", 2),
("Shukra", "070 Tula 58 34", "Uttaraphalguni", 2),
("Shani", "130 Kark 15 13", "Jyeshtha", 2),
("Spashth Rahu", "190 Meen 53 00", "Uttarabhadra", 2),
("Spashth Ketu", "190 Kany 53 00", "Uttaraphalguni", 4)
]
# Initialize houses dictionary
houses = {f"H{i}": [] for i in range(1, 13)}
# Process the planet data
for planet, _, nakshatra, padam in planet_data:
key = f"{nakshatra} {padam}"
house = nakshatra_to_house.get(key, "")
if house:
houses[house].append(planet_abbr[planet])
# determine which is good and bad planet as janma lagna
# Output the result for each house
for house, planets in houses.items():
print(f'{house}={planets}')
print("\n$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$")
# Find Lagna house position
lagna_house = None
for planet, _, nakshatra, padam in planet_data:
key = f"{nakshatra} {padam}"
house = nakshatra_to_house.get(key, "")
if house:
houses[house].append(planet_abbr[planet])
if planet == "Lagna":
lagna_house = house
# Output the result for each house before applying the + or - logic
print("Initial House Allocation:")
for house, planets in houses.items():
print(f'{house}={planets}')
# Define rules for appending + or - based on Lagna house
positive_houses = {'H12', 'H1', 'H4', 'H5', 'H8', 'H9'}
positive_planets = {'Sur', 'Cha', 'Kuj', 'Ket','Gur'}
negative_planets = {'Bud', 'Shu', 'Sha', 'Rah','Shu'}
# Apply sign logic based on Lagna house and eliminate duplicates
print("\nAdjusted Planet Signs:")
for house, planets in houses.items():
updated_planets = set() # Use a set to avoid duplicates
for planet in planets:
if planet == 'Lag': # Skip adding sign for Lagna
updated_planets.add(planet)
continue
if lagna_house in positive_houses: # Lagna in one of the positive houses
if planet in positive_planets:
updated_planets.add(f"{planet}+")
else:
updated_planets.add(f"{planet}-")
else: # Lagna in other houses
if planet in positive_planets:
updated_planets.add(f"{planet}-")
else:
updated_planets.add(f"{planet}+")
houses[house] = list(updated_planets) # Convert set back to list for display
# Display the updated house allocations
for house, planets in houses.items():
print(f'{house}={planets}')
# adding 17:23
# adding 17:23
print("\n$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$")
# Helper function to move circularly through houses
def circular_move(current_house, steps):
house_number = int(current_house[1:]) # Extract the house number (H1 to H12)
new_house_number = ((house_number - 1 + steps) % 12) + 1 # Circular move
return f"H{new_house_number}"
# Helper function to find the next Nakshatra-Padam in sequence
def find_next_nakshatra_padam(nakshatra, padam):
nakshatra_list = list(nakshatra_to_house.keys())
current_key = f"{nakshatra} {padam}"
if current_key in nakshatra_list:
current_index = nakshatra_list.index(current_key)
next_index = (current_index + 1) % len(nakshatra_list) # Circular move to next Nakshatra-Padam
return nakshatra_list[next_index]
return None
# Process to determine missing planets' positions based on the provided logic
for planet, _, nakshatra, padam in planet_data:
# Calculate Bhu's position based on Surya's position
#
if planet == "Surya":
surya_key = f"{nakshatra} {padam}"
surya_house = nakshatra_to_house.get(surya_key, "")
bhu_house = circular_move(surya_house, -6) # Move 61 steps circularly from Surya's house
if bhu_house:
houses[bhu_house].append('Bho')
print(f"Bho's adjusted position based on Surya and opp house: {surya_house,bhu_house}")
#calcuated house position based on house position.
#houses[chitra_house].append('Chitra')
# Calculate Mitra's position based on Ketu's position
if planet == "Spashth Ketu":
ketu_key = f"{nakshatra} {padam}"
next_nakshatra_padam = find_next_nakshatra_padam(nakshatra, padam)
print(f"\nKetu's adjusted position based on Ketu and next start house: {ketu_key,next_nakshatra_padam}")
if next_nakshatra_padam:
mitra_house = nakshatra_to_house.get(next_nakshatra_padam, "")
if mitra_house:
houses[mitra_house].append('Mitra')
print(f"\nmitra_house: {mitra_house}")
# Calculate Chitra's position based on Rahu's position
if planet == "Spashth Rahu":
rahu_key = f"{nakshatra} {padam}"
next_nakshatra_padam = find_next_nakshatra_padam(nakshatra, padam)
print(f"\nRahu's adjusted position based on Raghu and next start house: {rahu_key,next_nakshatra_padam}")
if next_nakshatra_padam:
chitra_house = nakshatra_to_house.get(next_nakshatra_padam, "")
if chitra_house:
houses[chitra_house].append('Chitra')
print(f"\nchitra_house: {chitra_house}")
# Display the final house allocations after calculating missing planets
print("\nFinal House Allocations (Including Bhu, Mitra, Chitra):")
for house, planets in houses.items():
print(f'{house}={planets}')
# Define the remaining logic for appending + or - for Lagna houses and avoiding duplicates
positive_houses = {'H12', 'H1', 'H4', 'H5', 'H8', 'H9'}
positive_planets = {'Sur', 'Cha', 'Kuj', 'Ket', 'Gur','Bho'}
negative_planets = {'Bud', 'Shu', 'Sha', 'Rah','Chitra','Mitra'}
print("\nAdjusted Planet Signs (Final):")
# Define the special planets where sign logic should apply
special_planets = {'Mitra', 'Chitra', 'Bho'}
for house, planets in houses.items():
updated_planets = set() # Use a set to avoid duplicates
for planet in planets:
if planet == 'Lag': # Skip adding sign for Lagna
updated_planets.add(planet)
continue
# Check if the planet is in the special_planets set
if planet in special_planets:
if lagna_house in positive_houses: # Lagna in one of the positive houses
if planet in positive_planets:
updated_planets.add(f"{planet}+") # Add '+' sign
else:
updated_planets.add(f"{planet}-") # Add '-' sign
else: # Lagna in other houses
if planet in positive_planets:
updated_planets.add(f"{planet}-") # Add '-' sign
else:
updated_planets.add(f"{planet}+") # Add '+' sign
else:
updated_planets.add(planet) # No sign added for other planets
houses[house] = list(updated_planets) # Convert set back to list for displayfor display
# Display the final house allocations with signs
for house, planets in houses.items():
print(f'{house}={planets}');
print("\n$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$")