예제 #1
0
    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)
예제 #2
0
    def assign_ekaadashii_vratam(self):
        if "ajA-EkAdazI" 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]
            # EKADASHI Vratam
            # One of two consecutive tithis must appear @ sunrise!

            if (day_panchaanga.sunrise_day_angas.tithi_at_sunrise.index %
                    15) == 10 or (
                        day_panchaanga.sunrise_day_angas.tithi_at_sunrise.index
                        % 15) == 11:
                yati_ekaadashii_fday = smaarta_ekaadashii_fday = vaishnava_ekaadashii_fday = None
                ekaadashii_tithi_days = [
                    x.sunrise_day_angas.tithi_at_sunrise.index % 15
                    for x in self.daily_panchaangas[d:d + 3]
                ]
                if day_panchaanga.sunrise_day_angas.tithi_at_sunrise.index > 15:
                    ekaadashii_paksha = 'krishna'
                else:
                    ekaadashii_paksha = 'shukla'
                if ekaadashii_tithi_days in [[11, 11, 12], [10, 12, 12]]:
                    smaarta_ekaadashii_fday = d + 1
                    tithi_arunodayam = tithi.get_tithi(
                        self.daily_panchaangas[d + 1].jd_sunrise - (1 / 15.0) *
                        (self.daily_panchaangas[d + 1].jd_sunrise -
                         day_panchaanga.jd_sunrise)).index
                    if tithi_arunodayam % 15 == 10:
                        vaishnava_ekaadashii_fday = d + 2
                    else:
                        vaishnava_ekaadashii_fday = d + 1
                elif ekaadashii_tithi_days in [[10, 12, 13], [11, 12, 13],
                                               [11, 12, 12], [11, 12, 14]]:
                    smaarta_ekaadashii_fday = d
                    tithi_arunodayam = temporal.tithi.get_tithi(
                        day_panchaanga.jd_sunrise - (1 / 15.0) *
                        (day_panchaanga.jd_sunrise -
                         self.daily_panchaangas[d - 1].jd_sunrise)).index
                    if tithi_arunodayam % 15 == 11 and ekaadashii_tithi_days in [
                        [11, 12, 13], [11, 12, 14]
                    ]:
                        vaishnava_ekaadashii_fday = d
                    else:
                        vaishnava_ekaadashii_fday = d + 1
                elif ekaadashii_tithi_days in [[10, 11, 13], [11, 11, 13]]:
                    smaarta_ekaadashii_fday = d
                    vaishnava_ekaadashii_fday = d + 1
                    yati_ekaadashii_fday = d + 1
                else:
                    pass
                    # These combinations are taken care of, either in the past or future.
                    # if ekaadashii_tithi_days == [10, 11, 12]:
                    #     logging.debug('Not assigning. Maybe tomorrow?')
                    # else:
                    #     logging.debug(('!!', d, ekaadashii_tithi_days))

                if yati_ekaadashii_fday == smaarta_ekaadashii_fday == vaishnava_ekaadashii_fday is None:
                    # Must have already assigned
                    pass
                elif yati_ekaadashii_fday is None:
                    if smaarta_ekaadashii_fday == vaishnava_ekaadashii_fday:
                        # It's sarva ekaadashii
                        self.panchaanga.add_festival(
                            fest_id='sarva-' + names.get_ekaadashii_name(
                                ekaadashii_paksha,
                                day_panchaanga.lunar_month_sunrise.index),
                            date=self.
                            daily_panchaangas[smaarta_ekaadashii_fday].date)
                        if ekaadashii_paksha == 'shukla':
                            if day_panchaanga.solar_sidereal_date_sunset.month == 9:
                                self.panchaanga.add_festival(
                                    fest_id='sarva-vaikuNTha-EkAdazI',
                                    date=self.daily_panchaangas[
                                        smaarta_ekaadashii_fday].date)
                    else:
                        self.panchaanga.add_festival(
                            fest_id='smArta-' + names.get_ekaadashii_name(
                                ekaadashii_paksha,
                                day_panchaanga.lunar_month_sunrise.index),
                            date=self.
                            daily_panchaangas[smaarta_ekaadashii_fday].date)
                        self.panchaanga.add_festival(
                            fest_id='vaiSNava-' + names.get_ekaadashii_name(
                                ekaadashii_paksha,
                                day_panchaanga.lunar_month_sunrise.index),
                            date=self.
                            daily_panchaangas[vaishnava_ekaadashii_fday].date)
                        if ekaadashii_paksha == 'shukla':
                            if day_panchaanga.solar_sidereal_date_sunset.month == 9:
                                self.panchaanga.add_festival(
                                    fest_id='smArta-vaikuNTha-EkAdazI',
                                    date=self.daily_panchaangas[
                                        smaarta_ekaadashii_fday].date)
                                self.panchaanga.add_festival(
                                    fest_id='vaiSNava-vaikuNTha-EkAdazI',
                                    date=self.daily_panchaangas[
                                        vaishnava_ekaadashii_fday].date)
                else:
                    self.panchaanga.add_festival(
                        fest_id='smArta-' + names.get_ekaadashii_name(
                            ekaadashii_paksha,
                            day_panchaanga.lunar_month_sunrise.index) +
                        ' (gRhastha)',
                        date=self.daily_panchaangas[smaarta_ekaadashii_fday].
                        date)
                    self.panchaanga.add_festival(
                        fest_id='smArta-' + names.get_ekaadashii_name(
                            ekaadashii_paksha, self.daily_panchaangas[d].
                            lunar_month_sunrise.index) + ' (sannyastha)',
                        date=self.daily_panchaangas[yati_ekaadashii_fday].date)
                    self.panchaanga.add_festival(
                        fest_id='vaiSNava-' + names.get_ekaadashii_name(
                            ekaadashii_paksha,
                            day_panchaanga.lunar_month_sunrise.index),
                        date=self.daily_panchaangas[vaishnava_ekaadashii_fday].
                        date)
                    if day_panchaanga.solar_sidereal_date_sunset.month == 9:
                        if ekaadashii_paksha == 'shukla':
                            self.panchaanga.add_festival(
                                fest_id='smArta-vaikuNTha-EkAdazI (gRhastha)',
                                date=self.daily_panchaangas[
                                    smaarta_ekaadashii_fday].date)
                            self.panchaanga.add_festival(
                                fest_id='smArta-vaikuNTha-EkAdazI (sannyastha)',
                                date=self.
                                daily_panchaangas[yati_ekaadashii_fday].date)
                            self.panchaanga.add_festival(
                                fest_id='vaiSNava-vaikuNTha-EkAdazI',
                                date=self.daily_panchaangas[
                                    vaishnava_ekaadashii_fday].date)

                if yati_ekaadashii_fday == smaarta_ekaadashii_fday == vaishnava_ekaadashii_fday is None:
                    # Must have already assigned
                    pass
                else:
                    if day_panchaanga.solar_sidereal_date_sunset.month == 8 and ekaadashii_paksha == 'shukla':
                        # self.add_festival('guruvAyupura-EkAdazI', smaarta_ekaadashii_fday)
                        self.panchaanga.add_festival(
                            fest_id='guruvAyupura-EkAdazI',
                            date=self.
                            daily_panchaangas[vaishnava_ekaadashii_fday].date)
                        self.panchaanga.add_festival(
                            fest_id='kaizika-EkAdazI',
                            date=self.
                            daily_panchaangas[vaishnava_ekaadashii_fday].date)

                    # Harivasara Computation
                    if ekaadashii_paksha == 'shukla':

                        def f(x):
                            tp_float = NakshatraDivision(
                                x, ayanaamsha_id=self.ayanaamsha_id
                            ).get_anga_float(zodiac.AngaType.TITHI_PADA)
                            return tp_float - 45

                        harivasara_end = brentq(
                            f, self.daily_panchaangas[smaarta_ekaadashii_fday].
                            jd_sunrise - 2,
                            self.daily_panchaangas[smaarta_ekaadashii_fday].
                            jd_sunrise + 2)
                    else:

                        def f(x):
                            tp_float = NakshatraDivision(
                                x, ayanaamsha_id=self.ayanaamsha_id
                            ).get_anga_float(zodiac.AngaType.TITHI_PADA)
                            return tp_float - 105

                        harivasara_end = brentq(
                            f, self.daily_panchaangas[smaarta_ekaadashii_fday].
                            jd_sunrise - 2,
                            self.daily_panchaangas[smaarta_ekaadashii_fday].
                            jd_sunrise + 2)
                    _date = self.panchaanga.city.get_timezone_obj(
                    ).julian_day_to_local_time(julian_day=harivasara_end)
                    _date.set_time_to_day_start()
                    fday_hv = time.utc_gregorian_to_jd(
                        _date) - time.utc_gregorian_to_jd(
                            self.daily_panchaangas[0].date)
                    fest = FestivalInstance(name='harivAsaraH',
                                            interval=Interval(
                                                jd_start=None,
                                                jd_end=harivasara_end))
                    self.panchaanga.add_festival_instance(
                        festival_instance=fest,
                        date=self.daily_panchaangas[int(fday_hv)].date)
예제 #3
0
 def _is_tithi_post_dark10(cls, jd):
     if tithi.get_tithi(jd=jd).index > 15 + 9:
         return True
     else:
         return False
예제 #4
0
    def assign_ekaadashii_vratam(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()

            # checking @ 6am local - can we do any better?
            local_time = tz(self.panchaanga.city.timezone).localize(
                datetime(y, m, dt, 6, 0, 0))
            # compute offset from UTC in hours
            tz_off = (datetime.utcoffset(local_time).days * 86400 +
                      datetime.utcoffset(local_time).seconds) / 3600.0

            # EKADASHI Vratam
            # One of two consecutive tithis must appear @ sunrise!

            if (self.daily_panchaangas[d].sunrise_day_angas.tithi_at_sunrise.
                    index %
                    15) == 10 or (self.daily_panchaangas[d].sunrise_day_angas.
                                  tithi_at_sunrise.index % 15) == 11:
                yati_ekaadashii_fday = smaarta_ekaadashii_fday = vaishnava_ekaadashii_fday = None
                ekaadashii_tithi_days = [
                    x.sunrise_day_angas.tithi_at_sunrise.index % 15
                    for x in self.daily_panchaangas[d:d + 3]
                ]
                if self.daily_panchaangas[
                        d].sunrise_day_angas.tithi_at_sunrise.index > 15:
                    ekaadashii_paksha = 'krishna'
                else:
                    ekaadashii_paksha = 'shukla'
                if ekaadashii_tithi_days in [[11, 11, 12], [10, 12, 12]]:
                    smaarta_ekaadashii_fday = d + 1
                    tithi_arunodayam = tithi.get_tithi(
                        self.daily_panchaangas[d + 1].jd_sunrise - (1 / 15.0) *
                        (self.daily_panchaangas[d + 1].jd_sunrise -
                         self.daily_panchaangas[d].jd_sunrise)).index
                    if tithi_arunodayam % 15 == 10:
                        vaishnava_ekaadashii_fday = d + 2
                    else:
                        vaishnava_ekaadashii_fday = d + 1
                elif ekaadashii_tithi_days in [[10, 12, 13], [11, 12, 13],
                                               [11, 12, 12], [11, 12, 14]]:
                    smaarta_ekaadashii_fday = d
                    tithi_arunodayam = temporal.tithi.get_tithi(
                        self.daily_panchaangas[d].jd_sunrise - (1 / 15.0) *
                        (self.daily_panchaangas[d].jd_sunrise -
                         self.daily_panchaangas[d - 1].jd_sunrise)).index
                    if tithi_arunodayam % 15 == 11 and ekaadashii_tithi_days in [
                        [11, 12, 13], [11, 12, 14]
                    ]:
                        vaishnava_ekaadashii_fday = d
                    else:
                        vaishnava_ekaadashii_fday = d + 1
                elif ekaadashii_tithi_days in [[10, 11, 13], [11, 11, 13]]:
                    smaarta_ekaadashii_fday = d
                    vaishnava_ekaadashii_fday = d + 1
                    yati_ekaadashii_fday = d + 1
                else:
                    pass
                    # These combinations are taken care of, either in the past or future.
                    # if ekaadashii_tithi_days == [10, 11, 12]:
                    #     logging.debug('Not assigning. Maybe tomorrow?')
                    # else:
                    #     logging.debug(('!!', d, ekaadashii_tithi_days))

                if yati_ekaadashii_fday == smaarta_ekaadashii_fday == vaishnava_ekaadashii_fday is None:
                    # Must have already assigned
                    pass
                elif yati_ekaadashii_fday is None:
                    if smaarta_ekaadashii_fday == vaishnava_ekaadashii_fday:
                        # It's sarva ekaadashii
                        self.festival_id_to_days[
                            'sarva-' + names.get_ekaadashii_name(
                                ekaadashii_paksha, self.daily_panchaangas[d].
                                lunar_month_sunrise.index)].add(
                                    self.daily_panchaangas[
                                        smaarta_ekaadashii_fday].date)
                        if ekaadashii_paksha == 'shukla':
                            if self.daily_panchaangas[
                                    d].solar_sidereal_date_sunset.month == 9:
                                self.festival_id_to_days[
                                    'sarva-vaikuNTha-EkAdazI'].add(
                                        self.daily_panchaangas[
                                            smaarta_ekaadashii_fday].date)
                    else:
                        self.festival_id_to_days[
                            'smArta-' + names.get_ekaadashii_name(
                                ekaadashii_paksha, self.daily_panchaangas[d].
                                lunar_month_sunrise.index)].add(
                                    self.daily_panchaangas[
                                        smaarta_ekaadashii_fday].date)
                        self.festival_id_to_days[
                            'vaiSNava-' + names.get_ekaadashii_name(
                                ekaadashii_paksha, self.daily_panchaangas[d].
                                lunar_month_sunrise.index)].add(
                                    self.daily_panchaangas[
                                        vaishnava_ekaadashii_fday].date)
                        if ekaadashii_paksha == 'shukla':
                            if self.daily_panchaangas[
                                    d].solar_sidereal_date_sunset.month == 9:
                                self.festival_id_to_days[
                                    'smArta-vaikuNTha-EkAdazI'].add(
                                        self.daily_panchaangas[
                                            smaarta_ekaadashii_fday].date)
                                self.festival_id_to_days[
                                    'vaiSNava-vaikuNTha-EkAdazI'].add(
                                        self.daily_panchaangas[
                                            vaishnava_ekaadashii_fday].date)
                else:
                    self.festival_id_to_days[
                        'smArta-' + names.get_ekaadashii_name(
                            ekaadashii_paksha, self.daily_panchaangas[d].
                            lunar_month_sunrise.index) +
                        ' (gRhastha)'].add(
                            self.daily_panchaangas[smaarta_ekaadashii_fday].
                            date)
                    self.festival_id_to_days[
                        'smArta-' + names.get_ekaadashii_name(
                            ekaadashii_paksha, self.daily_panchaangas[d].
                            lunar_month_sunrise.index) +
                        ' (sannyastha)'].add(
                            self.daily_panchaangas[yati_ekaadashii_fday].date)
                    self.festival_id_to_days[
                        'vaiSNava-' + names.get_ekaadashii_name(
                            ekaadashii_paksha, self.daily_panchaangas[d].
                            lunar_month_sunrise.index)].add(
                                self.daily_panchaangas[
                                    vaishnava_ekaadashii_fday].date)
                    if self.daily_panchaangas[
                            d].solar_sidereal_date_sunset.month == 9:
                        if ekaadashii_paksha == 'shukla':
                            self.festival_id_to_days[
                                'smArta-vaikuNTha-EkAdazI (gRhastha)'].add(
                                    self.daily_panchaangas[
                                        smaarta_ekaadashii_fday].date)
                            self.festival_id_to_days[
                                'smArta-vaikuNTha-EkAdazI (sannyastha)'].add(
                                    self.daily_panchaangas[
                                        yati_ekaadashii_fday].date)
                            self.festival_id_to_days[
                                'vaiSNava-vaikuNTha-EkAdazI'].add(
                                    self.daily_panchaangas[
                                        vaishnava_ekaadashii_fday].date)

                if yati_ekaadashii_fday == smaarta_ekaadashii_fday == vaishnava_ekaadashii_fday is None:
                    # Must have already assigned
                    pass
                else:
                    if self.daily_panchaangas[
                            d].solar_sidereal_date_sunset.month == 8 and ekaadashii_paksha == 'shukla':
                        # self.add_festival('guruvAyupura-EkAdazI', smaarta_ekaadashii_fday)
                        self.festival_id_to_days['guruvAyupura-EkAdazI'].add(
                            self.daily_panchaangas[vaishnava_ekaadashii_fday].
                            date)
                        self.festival_id_to_days['kaizika-EkAdazI'].add(
                            self.daily_panchaangas[vaishnava_ekaadashii_fday].
                            date)

                    # Harivasara Computation
                    if ekaadashii_paksha == 'shukla':

                        def f(x):
                            tp_float = NakshatraDivision(
                                x, ayanaamsha_id=self.ayanaamsha_id
                            ).get_anga_float(zodiac.AngaType.TITHI_PADA)
                            return tp_float - 45

                        harivasara_end = brentq(
                            f, self.daily_panchaangas[smaarta_ekaadashii_fday].
                            jd_sunrise - 2,
                            self.daily_panchaangas[smaarta_ekaadashii_fday].
                            jd_sunrise + 2)
                    else:

                        def f(x):
                            tp_float = NakshatraDivision(
                                x, ayanaamsha_id=self.ayanaamsha_id
                            ).get_anga_float(zodiac.AngaType.TITHI_PADA)
                            return tp_float - 105

                        harivasara_end = brentq(
                            f, self.daily_panchaangas[smaarta_ekaadashii_fday].
                            jd_sunrise - 2,
                            self.daily_panchaangas[smaarta_ekaadashii_fday].
                            jd_sunrise + 2)
                    _date = time.jd_to_utc_gregorian(harivasara_end +
                                                     (tz_off / 24.0))
                    _date.set_time_to_day_start()
                    fday_hv = time.utc_gregorian_to_jd(
                        _date) - time.utc_gregorian_to_jd(
                            self.daily_panchaangas[0].date)
                    fest = FestivalInstance(name='harivAsaraH',
                                            interval=Interval(
                                                jd_start=None,
                                                jd_end=harivasara_end))
                    self.daily_panchaangas[int(
                        fday_hv)].festival_id_to_instance[fest.name] = fest