def assign_amaavaasya_vyatiipaata(self): if 'vyatIpAta-yOgaH_(alabhyam)' not in self.rules_collection.name_to_rule: return for d in range( self.panchaanga.duration_prior_padding, self.panchaanga.duration + self.panchaanga.duration_prior_padding): day_panchaanga = self.daily_panchaangas[d] # AMA-VYATIPATA YOGAH # श्रवणाश्विधनिष्ठार्द्रानागदैवतमापतेत् । # रविवारयुतामायां व्यतीपातः स उच्यते ॥ # व्यतीपाताख्ययोगोऽयं शतार्कग्रहसन्निभः ॥ # “In Mahabharata, if on a Sunday, Amavasya and one of the stars – # Sravanam, Asvini, Avittam, Tiruvadirai or Ayilyam, occurs, then it is called ‘Vyatipatam’. # This Vyatipata yoga is equal to a hundred Surya grahanas in merit.” tithi_sunset = NakshatraDivision( day_panchaanga.jd_sunset, ayanaamsha_id=self.ayanaamsha_id).get_anga( zodiac.AngaType.TITHI).index if day_panchaanga.date.get_weekday() == 0 and ( day_panchaanga.sunrise_day_angas.tithi_at_sunrise.index == 30 or tithi_sunset == 30): # AMAVASYA on a Sunday if (day_panchaanga.sunrise_day_angas.nakshatra_at_sunrise.index in [1, 6, 9, 22, 23] and day_panchaanga.sunrise_day_angas.tithi_at_sunrise.index == 30) or \ (tithi_sunset == 30 and NakshatraDivision(day_panchaanga.jd_sunset, ayanaamsha_id=self.ayanaamsha_id).get_anga( zodiac.AngaType.NAKSHATRA).index in [ 1, 6, 9, 22, 23]): festival_name = 'vyatIpAta-yOgaH (alabhyam)' self.panchaanga.add_festival(fest_id=festival_name, date=day_panchaanga.date)
def assign_ayushman_bava_saumya_yoga(self): for d in range(self.panchaanga.duration_prior_padding, self.panchaanga.duration + 1): [y, m, dt, t] = time.jd_to_utc_gregorian(self.panchaanga.jd_start + d - 1).to_date_fractional_hour_tuple() # AYUSHMAN BHAVA SAUMYA if self.daily_panchaangas[d].date.get_weekday( ) == 3 and NakshatraDivision( self.daily_panchaangas[d].jd_sunrise, ayanaamsha_id=self.ayanaamsha_id).get_anga( zodiac.AngaType.NAKSHATRA).index == 3: if NakshatraDivision( self.daily_panchaangas[d].jd_sunrise, ayanaamsha_id=self.ayanaamsha_id).get_anga( zodiac.AngaType.KARANA).index in list( range(2, 52, 7)): self.festival_id_to_days[ 'AyuSmad-bava-saumya-saMyogaH'].add( self.daily_panchaangas[d].date) if self.daily_panchaangas[d].date.get_weekday( ) == 3 and NakshatraDivision( self.daily_panchaangas[d].jd_sunset, ayanaamsha_id=self.ayanaamsha_id).get_anga( zodiac.AngaType.NAKSHATRA).index == 3: if NakshatraDivision( self.daily_panchaangas[d].jd_sunset, ayanaamsha_id=self.ayanaamsha_id).get_anga( zodiac.AngaType.KARANA).index in list( range(2, 52, 7)): self.festival_id_to_days[ 'AyuSmad-bava-saumya-saMyogaH'].add( self.daily_panchaangas[d].date)
def get_month_sunrise(self, daily_panchaanga): """ Assigns Lunar months to days in the period Implementation note: Works by looking at solar months and new moons (which makes it easy to deduce adhika-mAsa-s.) :return: """ # tithi_at_sunrise gives a rough indication of the number of days since last new moon. We now find a more precise interval below. anga_finder = zodiac.AngaSpanFinder.get_cached( ayanaamsha_id=Ayanamsha.ASHVINI_STARTING_0, anga_type=zodiac.AngaType.TITHI) last_new_moon = anga_finder.find( jd1=daily_panchaanga.jd_sunrise - daily_panchaanga.sunrise_day_angas.tithi_at_sunrise.index - 3, jd2=daily_panchaanga.jd_sunrise - daily_panchaanga.sunrise_day_angas.tithi_at_sunrise.index + 3, target_anga_id=30) this_new_moon = anga_finder.find(jd1=last_new_moon.jd_start + 24, jd2=last_new_moon.jd_start + 32, target_anga_id=30) last_new_moon_solar_raashi = NakshatraDivision( last_new_moon.jd_end, ayanaamsha_id=self.ayanaamsha_id).get_solar_raashi() this_new_moon_solar_raashi = NakshatraDivision( this_new_moon.jd_end, ayanaamsha_id=self.ayanaamsha_id).get_solar_raashi() is_adhika = last_new_moon_solar_raashi == this_new_moon_solar_raashi if is_adhika: return this_new_moon_solar_raashi + .5 else: return this_new_moon_solar_raashi
def assign_ayushman_bava_saumya_yoga(self): for d in range(self.panchaanga.duration_prior_padding, self.panchaanga.duration + 1): # AYUSHMAN BHAVA SAUMYA if self.daily_panchaangas[d].date.get_weekday( ) == 3 and NakshatraDivision( self.daily_panchaangas[d].jd_sunrise, ayanaamsha_id=self.ayanaamsha_id).get_anga( zodiac.AngaType.YOGA).index == 3: if NakshatraDivision( self.daily_panchaangas[d].jd_sunrise, ayanaamsha_id=self.ayanaamsha_id).get_anga( zodiac.AngaType.KARANA).index in list( range(2, 52, 7)): self.panchaanga.add_festival( fest_id='AyuSmad-bava-saumya-saMyOgaH', date=self.daily_panchaangas[d].date) if self.daily_panchaangas[d].date.get_weekday( ) == 3 and NakshatraDivision( self.daily_panchaangas[d].jd_sunset, ayanaamsha_id=self.ayanaamsha_id).get_anga( zodiac.AngaType.YOGA).index == 3: if NakshatraDivision( self.daily_panchaangas[d].jd_sunset, ayanaamsha_id=self.ayanaamsha_id).get_anga( zodiac.AngaType.KARANA).index in list( range(2, 52, 7)): self.panchaanga.add_festival( fest_id='AyuSmad-bava-saumya-saMyOgaH', date=self.daily_panchaangas[d].date)
def get(self, body_name, anga_type_str, timezone, year, month, day, hour, minute, second): jd = Timezone(timezone).local_time_to_julian_day( Date(year, month, day, hour, minute, second)) nd = NakshatraDivision(jd=jd, ayanaamsha_id=Ayanamsha.CHITRA_AT_180) body = Graha(body_name=body_name) anga_type = AngaType.NAKSHATRA if anga_type_str == AngaType.RASHI.name: anga_type = AngaType.RASHI division = nd.get_fractional_division_for_body(body=body, anga_type=anga_type) logging.info(division) return str(division)
def assign_mahodaya_ardhodaya(self): for d, daily_panchaanga in enumerate(self.daily_panchaangas): # MAHODAYAM # Can also refer youtube video https://youtu.be/0DBIwb7iaLE?list=PL_H2LUtMCKPjh63PRk5FA3zdoEhtBjhzj&t=6747 # 4th pada of vyatipatam, 1st pada of Amavasya, 2nd pada of Shravana, Suryodaya, Bhanuvasara = Ardhodayam # 4th pada of vyatipatam, 1st pada of Amavasya, 2nd pada of Shravana, Suryodaya, Somavasara = Mahodayam sunrise_zodiac = NakshatraDivision( daily_panchaanga.jd_sunrise, ayanaamsha_id=self.computation_system.ayanaamsha_id) sunset_zodiac = NakshatraDivision( daily_panchaanga.jd_sunset, ayanaamsha_id=self.computation_system.ayanaamsha_id) if daily_panchaanga.lunar_month_sunrise.index in [ 10, 11 ] and daily_panchaanga.sunrise_day_angas.tithi_at_sunrise.index == 30 or tithi.get_tithi( daily_panchaanga.jd_sunrise).index == 30: if sunrise_zodiac.get_anga(zodiac.AngaType.NAKSHATRA).index == 17 or \ sunset_zodiac.get_anga(zodiac.AngaType.NAKSHATRA).index == 17 and \ sunrise_zodiac.get_anga(zodiac.AngaType.NAKSHATRA).index == 22 or \ sunset_zodiac.get_anga(zodiac.AngaType.NAKSHATRA).index == 22: if daily_panchaanga.date.get_weekday() == 1: festival_name = 'mahOdaya-puNyakAlaH' self.panchaanga.add_festival( fest_id=festival_name, date=self.daily_panchaangas[d].date) # logging.debug('* %d-%02d-%02d> %s!' % (y, m, dt, festival_name)) elif daily_panchaanga.date.get_weekday() == 0: festival_name = 'ardhOdaya-puNyakAlaH' self.panchaanga.add_festival( fest_id=festival_name, date=self.daily_panchaangas[d].date)
def assign_vishesha_saptami(self): for d in range(self.panchaanga.duration_prior_padding, self.panchaanga.duration + 1): [y, m, dt, t] = time.jd_to_utc_gregorian(self.panchaanga.jd_start + d - 1).to_date_fractional_hour_tuple() # SPECIAL SAPTAMIs if self.daily_panchaangas[d].date.get_weekday() == 0 and ( self.daily_panchaangas[d].sunrise_day_angas. tithi_at_sunrise.index % 15) == 7: festival_name = 'bhAnusaptamI' if self.daily_panchaangas[ d].sunrise_day_angas.tithi_at_sunrise.index == 7: festival_name = 'vijayA' + '~' + festival_name if self.daily_panchaangas[ d].sunrise_day_angas.nakshatra_at_sunrise.index == 27: # Even more auspicious! festival_name += '★' self.festival_id_to_days[festival_name].add( self.daily_panchaangas[d].date) if NakshatraDivision(self.daily_panchaangas[d].jd_sunrise, ayanaamsha_id=self.ayanaamsha_id).get_anga( zodiac.AngaType.NAKSHATRA_PADA).index == 49 and \ self.daily_panchaangas[d].sunrise_day_angas.tithi_at_sunrise.index == 7: self.festival_id_to_days['bhadrA~saptamI'].add( self.daily_panchaangas[d].date) if self.daily_panchaangas[ d].solar_sidereal_date_sunset.month_transition is not None: # we have a Sankranti! if self.daily_panchaangas[ d].sunrise_day_angas.tithi_at_sunrise.index == 7: self.festival_id_to_days['mahAjayA~saptamI'].add( self.daily_panchaangas[d].date)
def compute_solar_day_sunset(self, previous_day_panchaanga=None): """Compute the solar month and day for a given Julian day at sunset. """ # If solar transition happens before the current sunset but after the previous sunset, then that is taken to be solar day 1. self.compute_sun_moon_transitions( previous_day_panchaanga=previous_day_panchaanga) solar_month_sunset = NakshatraDivision( jd=self.jd_sunset, ayanaamsha_id=self.computation_system.ayanaamsha_id).get_anga( anga_type=AngaType.SIDEREAL_MONTH) solar_sidereal_month_end_jd = None if previous_day_panchaanga is None or previous_day_panchaanga.solar_sidereal_date_sunset.day > 28: anga_finder = zodiac.AngaSpanFinder.get_cached( ayanaamsha_id=self.computation_system.ayanaamsha_id, anga_type=AngaType.SIDEREAL_MONTH) solar_month_sunset_span = anga_finder.find( jd1=self.jd_sunset - 32, jd2=self.jd_sunset + 5, target_anga_id=solar_month_sunset) solar_sidereal_month_day_sunset = len( self.city.get_sunsets_in_period( jd_start=solar_month_sunset_span.jd_start, jd_end=self.jd_sunset + 1 / 48.0)) if solar_sidereal_month_day_sunset == 1 and solar_month_sunset_span.jd_start > self.jd_sunrise: solar_sidereal_month_end_jd = solar_month_sunset_span.jd_start elif solar_sidereal_month_day_sunset == 30 and solar_month_sunset_span.jd_end < self.jd_next_sunrise: solar_sidereal_month_end_jd = solar_month_sunset_span.jd_end else: solar_sidereal_month_day_sunset = previous_day_panchaanga.solar_sidereal_date_sunset.day + 1 from jyotisha.panchaanga.temporal import time self.solar_sidereal_date_sunset = time.BasicDateWithTransitions( month=solar_month_sunset.index, day=solar_sidereal_month_day_sunset, month_transition=solar_sidereal_month_end_jd)
def assign_month_day_festivals(self): for d, daily_panchaanga in enumerate(self.daily_panchaangas): y = daily_panchaanga.date.year #################### # Festival details # #################### # KARADAIYAN NOMBU if daily_panchaanga.solar_sidereal_date_sunset.month == 12 and daily_panchaanga.solar_sidereal_date_sunset.day == 1: festival_name = 'kAraDaiyAn2 nOn2bu' if NakshatraDivision(daily_panchaanga.jd_sunrise - (1 / 15.0) * (daily_panchaanga.jd_sunrise - self.daily_panchaangas[d - 1].jd_sunrise), ayanaamsha_id=self.ayanaamsha_id).get_solar_raashi().index == 12: # If kumbha prevails two ghatikAs before sunrise, nombu can be done in the early morning itself, else, previous night. self.panchaanga.festival_id_to_days[festival_name] = {self.daily_panchaangas[d - 1].date} else: self.panchaanga.festival_id_to_days[festival_name] = {daily_panchaanga.date} # KUCHELA DINAM if daily_panchaanga.solar_sidereal_date_sunset.month == 9 and daily_panchaanga.solar_sidereal_date_sunset.day <= 7 and daily_panchaanga.date.get_weekday() == 3: self.panchaanga.festival_id_to_days['kucEla-dinam'] = {daily_panchaanga.date} # MESHA SANKRANTI if daily_panchaanga.solar_sidereal_date_sunset.month == 1 and self.daily_panchaangas[d - 1].solar_sidereal_date_sunset.month == 12: # distance from prabhava samvatsara_id = (y - 1568) % 60 + 1 new_yr = 'mESa-saGkrAntiH' + '~(' + names.NAMES['SAMVATSARA_NAMES']['hk'][ (samvatsara_id % 60) + 1] + \ '-' + 'saMvatsaraH' + ')' # self.panchaanga.festival_id_to_days[new_yr] = [d] self.festival_id_to_days[new_yr].add(self.daily_panchaangas[d].date) self.festival_id_to_days['paJcAGga-paThanam'].add(self.daily_panchaangas[d].date)
def f(x): if x is None: return None else: return NakshatraDivision( x, ayanaamsha_id=ayanaamsha_id).get_anga(anga_type=anga_type)
def get(self, timezone, year, month, day, hour, minute, second): jd = Timezone(timezone).local_time_to_julian_day( Date(year, month, day, hour, minute, second)) from jyotisha.panchaanga import temporal raashi = NakshatraDivision( jd, ayanaamsha_id=Ayanamsha.CHITRA_AT_180).get_solar_raashi() logging.info(raashi) return str(raashi)
def assign_vaarunii_trayodashi(self): if 'vAruNI~trayOdazI' not in self.rules_collection.name_to_rule: return for d in range( self.panchaanga.duration_prior_padding, self.panchaanga.duration + self.panchaanga.duration_prior_padding): day_panchaanga = self.daily_panchaangas[d] # VARUNI TRAYODASHI if day_panchaanga.lunar_month_sunrise.index == 12 and day_panchaanga.sunrise_day_angas.tithi_at_sunrise.index == 28: if NakshatraDivision( day_panchaanga.jd_sunrise, ayanaamsha_id=self.ayanaamsha_id).get_anga( zodiac.AngaType.NAKSHATRA).index == 24: vtr_name = 'vAruNI~trayOdazI' if day_panchaanga.date.get_weekday() == 6: vtr_name = 'mahA' + vtr_name if NakshatraDivision( day_panchaanga.jd_sunrise, ayanaamsha_id=self.ayanaamsha_id).get_anga( zodiac.AngaType.NAKSHATRA).index == 23: vtr_name = 'mahA' + vtr_name self.panchaanga.add_festival(fest_id=vtr_name, date=day_panchaanga.date)
def assign_vishesha_trayodashi(self): for d in range(self.panchaanga.duration_prior_padding, self.panchaanga.duration + 1): [y, m, dt, t] = time.jd_to_utc_gregorian(self.panchaanga.jd_start + d - 1).to_date_fractional_hour_tuple() # VARUNI TRAYODASHI if self.daily_panchaangas[ d].lunar_month_sunrise.index == 12 and self.daily_panchaangas[ d].sunrise_day_angas.tithi_at_sunrise.index == 28: if NakshatraDivision( self.daily_panchaangas[d].jd_sunrise, ayanaamsha_id=self.ayanaamsha_id).get_anga( zodiac.AngaType.NAKSHATRA).index == 24: vtr_name = 'vAruNI~trayOdazI' if self.daily_panchaangas[d].date.get_weekday() == 6: vtr_name = 'mahA' + vtr_name if NakshatraDivision( self.daily_panchaangas[d].jd_sunrise, ayanaamsha_id=self.ayanaamsha_id).get_anga( zodiac.AngaType.NAKSHATRA).index == 23: vtr_name = 'mahA' + vtr_name self.festival_id_to_days[vtr_name].add( self.daily_panchaangas[d].date)
def get_tithi(jd): """Returns the tithi prevailing at a given moment Tithi is computed as the difference in the longitudes of the moon and sun at any given point of time. Therefore, even the ayanaamsha does not matter, as it gets cancelled out. Returns: int tithi, where 1 stands for ShuklapakshaPrathama, ..., 15 stands for Paurnamasi, ..., 23 stands for KrishnapakshaAshtami, 30 stands for Amavasya """ from jyotisha.panchaanga.temporal.zodiac import NakshatraDivision, Ayanamsha # VERNAL_EQUINOX_AT_0 does not involve lookups, hence sending it - though ayanAmsha does not matter. return NakshatraDivision(jd=jd, ayanaamsha_id=Ayanamsha.VERNAL_EQUINOX_AT_0).get_anga(AngaType.TITHI)
def assign_vishesha_saptami(self): if 'bhAnusaptamI' in self.rules_collection.name_to_rule: for d in range( self.panchaanga.duration_prior_padding, self.panchaanga.duration + self.panchaanga.duration_prior_padding): day_panchaanga = self.daily_panchaangas[d] # SPECIAL SAPTAMIs if day_panchaanga.date.get_weekday() == 0 and ( day_panchaanga.sunrise_day_angas.tithi_at_sunrise.index % 15) == 7: festival_name = 'bhAnusaptamI' if day_panchaanga.sunrise_day_angas.tithi_at_sunrise.index == 7: festival_name = 'vijayA' + '~' + festival_name if day_panchaanga.sunrise_day_angas.nakshatra_at_sunrise.index == 27: # Even more auspicious! festival_name += '★' self.panchaanga.add_festival(fest_id=festival_name, date=day_panchaanga.date) if 'bhadrA~saptamI' in self.rules_collection.name_to_rule: for d in range( self.panchaanga.duration_prior_padding, self.panchaanga.duration + self.panchaanga.duration_prior_padding): day_panchaanga = self.daily_panchaangas[d] if NakshatraDivision(day_panchaanga.jd_sunrise, ayanaamsha_id=self.ayanaamsha_id).get_anga( zodiac.AngaType.NAKSHATRA_PADA).index == 49 and \ day_panchaanga.sunrise_day_angas.tithi_at_sunrise.index == 7: self.panchaanga.add_festival(fest_id='bhadrA~saptamI', date=day_panchaanga.date) if 'mahAjayA~saptamI' in self.rules_collection.name_to_rule: for d in range( self.panchaanga.duration_prior_padding, self.panchaanga.duration + self.panchaanga.duration_prior_padding): day_panchaanga = self.daily_panchaangas[d] if day_panchaanga.solar_sidereal_date_sunset.month_transition is not None: # we have a Sankranti! if day_panchaanga.sunrise_day_angas.tithi_at_sunrise.index == 7: self.panchaanga.add_festival( fest_id='mahAjayA~saptamI', date=day_panchaanga.date)
def assign_month_day_kaaradaiyan(self): if 'kAraDaiyAn2_nOn2bu' not in self.rules_collection.name_to_rule: return for d, daily_panchaanga in enumerate(self.daily_panchaangas): #################### # Festival details # #################### # KARADAIYAN NOMBU if daily_panchaanga.solar_sidereal_date_sunset.month == 12 and daily_panchaanga.solar_sidereal_date_sunset.day == 1: festival_name = 'kAraDaiyAn2 nOn2bu' if NakshatraDivision( daily_panchaanga.jd_sunrise - (1 / 15.0) * (daily_panchaanga.jd_sunrise - self.daily_panchaangas[d - 1].jd_sunrise), ayanaamsha_id=self.ayanaamsha_id).get_solar_raashi( ).index == 12: # If kumbha prevails two ghatikAs before sunrise, nombu can be done in the early morning itself, else, previous night. self.panchaanga.add_festival( fest_id=festival_name, date=self.daily_panchaangas[d - 1].date) else: self.panchaanga.add_festival(fest_id=festival_name, date=daily_panchaanga.date)
def test_get_anga(): nd = NakshatraDivision(jd=time.ist_timezone.local_time_to_julian_day(Date(2018, 7, 14)), ayanaamsha_id=Ayanamsha.CHITRA_AT_180) assert nd.get_anga( anga_type=AngaType.TITHI).index == 1 nd = NakshatraDivision(jd=time.ist_timezone.local_time_to_julian_day(Date(2018, 7, 14, 6, 1)), ayanaamsha_id=Ayanamsha.CHITRA_AT_180) assert nd.get_anga( anga_type=AngaType.TITHI).index == 2 nd = NakshatraDivision(jd=time.ist_timezone.local_time_to_julian_day(Date(2018, 7, 13)), ayanaamsha_id=Ayanamsha.CHITRA_AT_180) assert nd.get_anga( anga_type=AngaType.TITHI).index == 30 assert nd.get_anga( anga_type=AngaType.SIDEREAL_MONTH).index == 3 # Just before meSha sankrAnti assert NakshatraDivision(jd=time.ist_timezone.local_time_to_julian_day(Date(2018, 4, 13)), ayanaamsha_id=Ayanamsha.CHITRA_AT_180).get_anga( anga_type=AngaType.SIDEREAL_MONTH).index == 12 # 5:6:0.00 UT on December 23, 1981 nd = NakshatraDivision(2444961.7125, ayanaamsha_id=Ayanamsha.CHITRA_AT_180) assert nd.get_anga(AngaType.NAKSHATRA).index == 16 assert nd.get_anga(AngaType.TITHI).index == 28 assert nd.get_anga(AngaType.YOGA).index == 8 assert nd.get_anga(AngaType.KARANA).index == 55 assert nd.get_solar_raashi().index == 9
def assign_mahaadvaadashii(self): if 'pakSavardhinI~mahAdvAdazI' not in self.rules_collection.name_to_rule: return for d in range( self.panchaanga.duration_prior_padding, self.panchaanga.duration + self.panchaanga.duration_prior_padding): day_panchaanga = self.daily_panchaangas[d] # 8 MAHA DWADASHIS if (day_panchaanga.sunrise_day_angas.tithi_at_sunrise.index % 15) == 11 and (self.daily_panchaangas[ d + 1].sunrise_day_angas.tithi_at_sunrise.index % 15) == 11: self.panchaanga.add_festival(fest_id='unmIlanI~mahAdvAdazI', date=day_panchaanga.date + 1) if (day_panchaanga.sunrise_day_angas.tithi_at_sunrise.index % 15) == 12 and (self.daily_panchaangas[ d + 1].sunrise_day_angas.tithi_at_sunrise.index % 15) == 12: self.panchaanga.add_festival(fest_id='vyaJjulI~mahAdvAdazI', date=day_panchaanga.date) if (day_panchaanga.sunrise_day_angas.tithi_at_sunrise.index % 15) == 11 and (self.daily_panchaangas[ d + 1].sunrise_day_angas.tithi_at_sunrise.index % 15) == 13: self.panchaanga.add_festival(fest_id='trisparzA~mahAdvAdazI', date=day_panchaanga.date) if (day_panchaanga.sunrise_day_angas.tithi_at_sunrise.index % 15) == 0 and (self.daily_panchaangas[ d + 1].sunrise_day_angas.tithi_at_sunrise.index % 15) == 0: # Might miss out on those parva days right after Dec 31! if (d - 3) > 0: self.panchaanga.add_festival( fest_id='pakSavardhinI~mahAdvAdazI', date=day_panchaanga.date - 3) if day_panchaanga.sunrise_day_angas.nakshatra_at_sunrise.index == 4 and ( day_panchaanga.sunrise_day_angas.tithi_at_sunrise.index % 15) == 12: self.panchaanga.add_festival(fest_id='pApanAzinI~mahAdvAdazI', date=day_panchaanga.date) if day_panchaanga.sunrise_day_angas.nakshatra_at_sunrise.index == 7 and ( day_panchaanga.sunrise_day_angas.tithi_at_sunrise.index % 15) == 12: self.panchaanga.add_festival(fest_id='jayantI~mahAdvAdazI', date=day_panchaanga.date) if day_panchaanga.sunrise_day_angas.nakshatra_at_sunrise.index == 8 and ( day_panchaanga.sunrise_day_angas.tithi_at_sunrise.index % 15) == 12: self.panchaanga.add_festival(fest_id='jayA~mahAdvAdazI', date=day_panchaanga.date) if day_panchaanga.sunrise_day_angas.nakshatra_at_sunrise.index == 8 and ( day_panchaanga.sunrise_day_angas.tithi_at_sunrise.index % 15 ) == 12 and day_panchaanga.lunar_month_sunrise.index == 12: # Better checking needed (for other than sunrise). # Last occurred on 27-02-1961 - pushya nakshatra and phalguna krishna dvadashi (or shukla!?) self.panchaanga.add_festival(fest_id='gOvinda~mahAdvAdazI', date=day_panchaanga.date) if (day_panchaanga.sunrise_day_angas.tithi_at_sunrise.index % 15) == 12: if day_panchaanga.sunrise_day_angas.nakshatra_at_sunrise.index in [ 21, 22, 23 ]: # We have a dvaadashii near shravana, check for Shravana sparsha for td in [ x.sunrise_day_angas.tithis_with_ends for x in self.daily_panchaangas[d:d + 2] ]: (t12, t12_end) = (td[0].anga, td[0].jd_end) if t12_end is None: continue if (t12 % 15) == 11: if NakshatraDivision( t12_end, ayanaamsha_id=self.ayanaamsha_id).get_anga( zodiac.AngaType.NAKSHATRA).index == 22: if (day_panchaanga.sunrise_day_angas. tithi_at_sunrise.index % 15) == 12 and (self.daily_panchaangas[ d + 1].sunrise_day_angas. tithi_at_sunrise.index % 15) == 12: self.panchaanga.add_festival( fest_id='vijayA/zravaNa-mahAdvAdazI', date=day_panchaanga.date) elif (day_panchaanga.sunrise_day_angas. tithi_at_sunrise.index % 15) == 12: self.panchaanga.add_festival( fest_id='vijayA/zravaNa-mahAdvAdazI', date=day_panchaanga.date) elif (self.daily_panchaangas[d + 1]. sunrise_day_angas.tithi_at_sunrise.index % 15) == 12: self.panchaanga.add_festival( fest_id='vijayA/zravaNa-mahAdvAdazI', date=day_panchaanga.date + 1) if (t12 % 15) == 12: if NakshatraDivision( t12_end, ayanaamsha_id=self.ayanaamsha_id).get_anga( zodiac.AngaType.NAKSHATRA).index == 22: if (day_panchaanga.sunrise_day_angas. tithi_at_sunrise.index % 15) == 12 and (self.daily_panchaangas[ d + 1].sunrise_day_angas. tithi_at_sunrise.index % 15) == 12: self.panchaanga.add_festival( fest_id='vijayA/zravaNa-mahAdvAdazI', date=day_panchaanga.date) elif (day_panchaanga.sunrise_day_angas. tithi_at_sunrise.index % 15) == 12: self.panchaanga.add_festival( fest_id='vijayA/zravaNa-mahAdvAdazI', date=day_panchaanga.date) elif (self.daily_panchaangas[d + 1]. sunrise_day_angas.tithi_at_sunrise.index % 15) == 12: self.panchaanga.add_festival( fest_id='vijayA/zravaNa-mahAdvAdazI', date=day_panchaanga.date + 1) if day_panchaanga.sunrise_day_angas.nakshatra_at_sunrise.index == 22 and ( day_panchaanga.sunrise_day_angas.tithi_at_sunrise.index % 15) == 12: self.panchaanga.add_festival( fest_id='vijayA/zravaNa-mahAdvAdazI', date=day_panchaanga.date)
def f(x): tp_float = NakshatraDivision( x, ayanaamsha_id=self.ayanaamsha_id ).get_anga_float(zodiac.AngaType.TITHI_PADA) return tp_float - 105
def assign_mahaadvaadashii(self): for d in range(self.panchaanga.duration_prior_padding, self.panchaanga.duration + 1): [y, m, dt, t] = time.jd_to_utc_gregorian(self.panchaanga.jd_start + d - 1).to_date_fractional_hour_tuple() # 8 MAHA DWADASHIS if (self.daily_panchaangas[d].sunrise_day_angas.tithi_at_sunrise. index % 15) == 11 and (self.daily_panchaangas[ d + 1].sunrise_day_angas.tithi_at_sunrise.index % 15) == 11: self.festival_id_to_days['unmIlanI~mahAdvAdazI'].add( self.daily_panchaangas[d].date + 1) if (self.daily_panchaangas[d].sunrise_day_angas.tithi_at_sunrise. index % 15) == 12 and (self.daily_panchaangas[ d + 1].sunrise_day_angas.tithi_at_sunrise.index % 15) == 12: self.festival_id_to_days['vyaJjulI~mahAdvAdazI'].add( self.daily_panchaangas[d].date) if (self.daily_panchaangas[d].sunrise_day_angas.tithi_at_sunrise. index % 15) == 11 and (self.daily_panchaangas[ d + 1].sunrise_day_angas.tithi_at_sunrise.index % 15) == 13: self.festival_id_to_days['trisparzA~mahAdvAdazI'].add( self.daily_panchaangas[d].date) if (self.daily_panchaangas[d].sunrise_day_angas.tithi_at_sunrise. index % 15) == 0 and (self.daily_panchaangas[ d + 1].sunrise_day_angas.tithi_at_sunrise.index % 15) == 0: # Might miss out on those parva days right after Dec 31! if (d - 3) > 0: self.festival_id_to_days['pakSavardhinI~mahAdvAdazI'].add( self.daily_panchaangas[d].date - 3) if self.daily_panchaangas[ d].sunrise_day_angas.nakshatra_at_sunrise.index == 4 and ( self.daily_panchaangas[d].sunrise_day_angas. tithi_at_sunrise.index % 15) == 12: self.festival_id_to_days['pApanAzinI~mahAdvAdazI'].add( self.daily_panchaangas[d].date) if self.daily_panchaangas[ d].sunrise_day_angas.nakshatra_at_sunrise.index == 7 and ( self.daily_panchaangas[d].sunrise_day_angas. tithi_at_sunrise.index % 15) == 12: self.festival_id_to_days['jayantI~mahAdvAdazI'].add( self.daily_panchaangas[d].date) if self.daily_panchaangas[ d].sunrise_day_angas.nakshatra_at_sunrise.index == 8 and ( self.daily_panchaangas[d].sunrise_day_angas. tithi_at_sunrise.index % 15) == 12: self.festival_id_to_days['jayA~mahAdvAdazI'].add( self.daily_panchaangas[d].date) if self.daily_panchaangas[ d].sunrise_day_angas.nakshatra_at_sunrise.index == 8 and ( self.daily_panchaangas[d].sunrise_day_angas. tithi_at_sunrise.index % 15) == 12 and self.daily_panchaangas[ d].lunar_month_sunrise.index == 12: # Better checking needed (for other than sunrise). # Last occurred on 27-02-1961 - pushya nakshatra and phalguna krishna dvadashi (or shukla!?) self.festival_id_to_days['gOvinda~mahAdvAdazI'].add( self.daily_panchaangas[d].date) if (self.daily_panchaangas[d].sunrise_day_angas.tithi_at_sunrise. index % 15) == 12: if self.daily_panchaangas[ d].sunrise_day_angas.nakshatra_at_sunrise.index in [ 21, 22, 23 ]: # We have a dvaadashii near shravana, check for Shravana sparsha for td in [ x.sunrise_day_angas.tithis_with_ends for x in self.daily_panchaangas[d:d + 2] ]: (t12, t12_end) = (td[0].anga, td[0].jd_end) if t12_end is None: continue if (t12 % 15) == 11: if NakshatraDivision( t12_end, ayanaamsha_id=self.ayanaamsha_id).get_anga( zodiac.AngaType.NAKSHATRA).index == 22: if (self.daily_panchaangas[d].sunrise_day_angas .tithi_at_sunrise.index % 15) == 12 and (self.daily_panchaangas[ d + 1].sunrise_day_angas. tithi_at_sunrise.index % 15) == 12: self.festival_id_to_days[ 'vijayA/zravaNa-mahAdvAdazI'].add( self.daily_panchaangas[d].date) elif (self.daily_panchaangas[d]. sunrise_day_angas.tithi_at_sunrise.index % 15) == 12: self.festival_id_to_days[ 'vijayA/zravaNa-mahAdvAdazI'].add( self.daily_panchaangas[d].date) elif (self.daily_panchaangas[d + 1]. sunrise_day_angas.tithi_at_sunrise.index % 15) == 12: self.festival_id_to_days[ 'vijayA/zravaNa-mahAdvAdazI'].add( self.daily_panchaangas[d].date + 1) if (t12 % 15) == 12: if NakshatraDivision( t12_end, ayanaamsha_id=self.ayanaamsha_id).get_anga( zodiac.AngaType.NAKSHATRA).index == 22: if (self.daily_panchaangas[d].sunrise_day_angas .tithi_at_sunrise.index % 15) == 12 and (self.daily_panchaangas[ d + 1].sunrise_day_angas. tithi_at_sunrise.index % 15) == 12: self.festival_id_to_days[ 'vijayA/zravaNa-mahAdvAdazI'].add( self.daily_panchaangas[d].date) elif (self.daily_panchaangas[d]. sunrise_day_angas.tithi_at_sunrise.index % 15) == 12: self.festival_id_to_days[ 'vijayA/zravaNa-mahAdvAdazI'].add( self.daily_panchaangas[d].date) elif (self.daily_panchaangas[d + 1]. sunrise_day_angas.tithi_at_sunrise.index % 15) == 12: self.festival_id_to_days[ 'vijayA/zravaNa-mahAdvAdazI'].add( self.daily_panchaangas[d].date + 1) if self.daily_panchaangas[ d].sunrise_day_angas.nakshatra_at_sunrise.index == 22 and ( self.daily_panchaangas[d].sunrise_day_angas. tithi_at_sunrise.index % 15) == 12: self.festival_id_to_days['vijayA/zravaNa-mahAdvAdazI'].add( self.daily_panchaangas[d].date)
def assign_nakshatra_vara_yoga_vratam(self): if 'Adityahasta-puNyakAlaH' not in self.rules_collection.name_to_rule: return for d in range( self.panchaanga.duration_prior_padding, self.panchaanga.duration + self.panchaanga.duration_prior_padding): # NAKSHATRA-WEEKDAY FESTIVALS for (nwd_fest_n, nwd_fest_wd, nwd_fest_name) in ( (13, 0, 'Adityahasta-puNyakAlaH'), (8, 0, 'ravipuSyayOga-puNyakAlaH'), (22, 1, 'sOmazrAvaNI-puNyakAlaH'), (5, 1, 'sOmamRgazIrSa-puNyakAlaH'), (1, 2, 'bhaumAzvinI-puNyakAlaH'), # (6, 2, 'bhaumArdrA-puNyakAlaH'), removed because no pramANam (17, 3, 'budhAnurAdhA-puNyakAlaH'), (8, 4, 'gurupuSya-puNyakAlaH'), (27, 5, 'bhRgurEvatI-puNyakAlaH'), (4, 6, 'zanirOhiNI-puNyakAlaH'), ): n_prev = ((nwd_fest_n - 2) % 27) + 1 if (self.daily_panchaangas[d].sunrise_day_angas. nakshatra_at_sunrise.index == nwd_fest_n or self.daily_panchaangas[d].sunrise_day_angas. nakshatra_at_sunrise.index == n_prev ) and self.daily_panchaangas[d].date.get_weekday( ) == nwd_fest_wd: # Is it necessarily only at sunrise? d0_angas = self.daily_panchaangas[ d].day_length_based_periods.dinamaana.get_boundary_angas( anga_type=AngaType.NAKSHATRA, ayanaamsha_id=self.ayanaamsha_id) # if any(x == nwd_fest_n for x in [self.daily_panchaangas[d].sunrise_day_angas.nakshatra_at_sunrise.index, d0_angas.start.index, d0_angas.end.index]): # self.panchaanga.add_festival(fest_id=nwd_fest_name, date=self.daily_panchaangas[d].date) nakshatram_praatah = self.daily_panchaangas[ d].sunrise_day_angas.nakshatra_at_sunrise.index nakshatram_saayam = NakshatraDivision( jd=self.daily_panchaangas[d].jd_sunset, ayanaamsha_id=self.panchaanga.computation_system. ayanaamsha_id).get_anga( anga_type=AngaType.NAKSHATRA).index if nakshatram_praatah == nakshatram_saayam == n_prev: continue if nwd_fest_n == nakshatram_praatah == nakshatram_saayam: self.panchaanga.add_festival_instance( festival_instance=FestivalInstance( name=nwd_fest_name), date=self.daily_panchaangas[d].date) else: (nakshatra_ID, nakshatra_end_jd) = ( self.daily_panchaangas[d].sunrise_day_angas. nakshatras_with_ends[0].anga.index, self.daily_panchaangas[d].sunrise_day_angas. nakshatras_with_ends[0].jd_end) if nwd_fest_n == nakshatram_praatah: # assert nwd_fest_n == nakshatra_ID self.panchaanga.add_festival_instance( festival_instance=FestivalInstance( name=nwd_fest_name, interval=Interval( jd_start=None, jd_end=nakshatra_end_jd)), date=self.daily_panchaangas[d].date) elif nwd_fest_n == nakshatram_saayam: # assert n_prev == nakshatra_ID self.panchaanga.add_festival_instance( festival_instance=FestivalInstance( name=nwd_fest_name, interval=Interval( jd_start=nakshatra_end_jd, jd_end=None)), date=self.daily_panchaangas[d].date) else: logging.error('Should never be here!')
def assign_amavasya_yoga(self): if 'amAvAsyA' not in self.panchaanga.festival_id_to_days: logging.error('Must compute amAvAsyA before coming here!') else: ama_days = self.panchaanga.festival_id_to_days['amAvAsyA'] for ama_day in ama_days: d = int(ama_day - self.daily_panchaangas[0].date) # Get Name if self.daily_panchaangas[d].lunar_month_sunrise.index == 6: pref = '(%s) mahAlaya ' % (names.get_chandra_masa( self.daily_panchaangas[d].lunar_month_sunrise.index, names.NAMES, 'hk', visarga=False)) elif self.daily_panchaangas[ d].solar_sidereal_date_sunset.month == 4: pref = '%s (kaTaka) ' % (names.get_chandra_masa( self.daily_panchaangas[d].lunar_month_sunrise.index, names.NAMES, 'hk', visarga=False)) elif self.daily_panchaangas[ d].solar_sidereal_date_sunset.month == 10: pref = 'mauni (%s/makara) ' % (names.get_chandra_masa( self.daily_panchaangas[d].lunar_month_sunrise.index, names.NAMES, 'hk', visarga=False)) else: pref = names.get_chandra_masa( self.daily_panchaangas[d].lunar_month_sunrise.index, names.NAMES, 'hk', visarga=False) + '-' apraahna_interval = self.daily_panchaangas[ d].day_length_based_periods.aparaahna_muhuurta ama_nakshatra_today = [ y for y in apraahna_interval.get_boundary_angas( anga_type=AngaType.NAKSHATRA, ayanaamsha_id=self.ayanaamsha_id).to_tuple() ] suff = '' # Assign if 23 in ama_nakshatra_today and self.daily_panchaangas[ d].lunar_month_sunrise.index == 10: suff = ' (alabhyam–zraviSThA)' elif 24 in ama_nakshatra_today and self.daily_panchaangas[ d].lunar_month_sunrise.index == 10: suff = ' (alabhyam–zatabhiSak)' elif ama_nakshatra_today[0] in [ 15, 16, 17, 6, 7, 8, 23, 24, 25 ]: suff = ' (alabhyam–%s)' % names.NAMES['NAKSHATRA_NAMES'][ 'hk'][ama_nakshatra_today[0]] elif ama_nakshatra_today[1] in [ 15, 16, 17, 6, 7, 8, 23, 24, 25 ]: suff = ' (alabhyam–%s)' % names.NAMES['NAKSHATRA_NAMES'][ 'hk'][ama_nakshatra_today[1]] if self.daily_panchaangas[d].date.get_weekday() in [1, 2, 4]: if suff == '': suff = ' (alabhyam–puSkalA)' else: suff = suff.replace(')', ', puSkalA)') self.festival_id_to_days[pref + 'amAvAsyA' + suff].add( self.daily_panchaangas[d].date) self.panchaanga.delete_festival(fest_id='amAvAsyA') for d in range(self.panchaanga.duration_prior_padding, self.panchaanga.duration + 1): [y, m, dt, t] = time.jd_to_utc_gregorian(self.panchaanga.jd_start + d - 1).to_date_fractional_hour_tuple() # SOMAMAVASYA if self.daily_panchaangas[ d].sunrise_day_angas.tithi_at_sunrise.index == 30 and self.daily_panchaangas[ d].date.get_weekday() == 1: self.festival_id_to_days['sOmavatI amAvAsyA'].add( self.daily_panchaangas[d].date) # AMA-VYATIPATA YOGAH # श्रवणाश्विधनिष्ठार्द्रानागदैवतमापतेत् । # रविवारयुतामायां व्यतीपातः स उच्यते ॥ # व्यतीपाताख्ययोगोऽयं शतार्कग्रहसन्निभः ॥ # “In Mahabharata, if on a Sunday, Amavasya and one of the stars – # Sravanam, Asvini, Avittam, Tiruvadirai or Ayilyam, occurs, then it is called ‘Vyatipatam’. # This Vyatipata yoga is equal to a hundred Surya grahanas in merit.” tithi_sunset = NakshatraDivision( self.daily_panchaangas[d].jd_sunset, ayanaamsha_id=self.ayanaamsha_id).get_anga( zodiac.AngaType.TITHI).index if self.daily_panchaangas[d].date.get_weekday() == 0 and ( self.daily_panchaangas[d].sunrise_day_angas. tithi_at_sunrise.index == 30 or tithi_sunset == 30): # AMAVASYA on a Sunday if (self.daily_panchaangas[d].sunrise_day_angas.nakshatra_at_sunrise.index in [1, 6, 9, 22, 23] and self.daily_panchaangas[d].sunrise_day_angas.tithi_at_sunrise.index == 30) or \ (tithi_sunset == 30 and NakshatraDivision(self.daily_panchaangas[d].jd_sunset, ayanaamsha_id=self.ayanaamsha_id).get_anga( zodiac.AngaType.NAKSHATRA).index in [ 1, 6, 9, 22, 23]): festival_name = 'vyatIpAta-yOgaH (alabhyam)' self.festival_id_to_days[festival_name].add( self.daily_panchaangas[d].date) logging.debug('* %d-%02d-%02d> %s!' % (y, m, dt, festival_name))