Ejemplo n.º 1
0
 def from_fixed(cls, fixed_date):
     """Return Old Hindu lunar date equivalent to fixed date 'fixed_date'."""
     sun = cls.hindu_day_count(fixed_date) + Clock.days_from_hours(6)
     new_moon = sun - mod(sun, cls.ARYA_LUNAR_MONTH)
     leap = cls.ARYA_SOLAR_MONTH - cls.ARYA_LUNAR_MONTH >= mod(new_moon, cls.ARYA_SOLAR_MONTH) and mod(new_moon, cls.ARYA_SOLAR_MONTH) > 0
     month = mod(iceiling(new_moon / cls.ARYA_SOLAR_MONTH), 12) + 1
     day = mod(quotient(sun, cls.ARYA_LUNAR_DAY), 30) + 1
     year = iceiling((new_moon + cls.ARYA_SOLAR_MONTH) / cls.ARYA_SOLAR_YEAR) - 1
     return OldHinduLunarDate(year, month, leap, day)
Ejemplo n.º 2
0
 def from_arithmetic_fixed(cls, date):
     """Return the Persian date corresponding to fixed date, date."""
     year        = cls.to_arithmetic_year(date)
     day_of_year = 1 + date - PersianDate(year, 1, 1).to_fixed_arithmetic()
     month       = (iceiling(day_of_year / 31)
                    if (day_of_year <= 186)
                    else iceiling((day_of_year - 6) / 30))
     day = date - PersianDate(year, month, 1).to_fixed_arithmetic() +1
     return PersianDate(year, month, day)
Ejemplo n.º 3
0
 def from_fixed(cls, date):
     """Return Astronomical Persian date (year month day)
     corresponding to fixed date, date."""
     new_year = cls.new_year_on_or_before(date)
     y = iround((new_year - cls.EPOCH) / Solar.MEAN_TROPICAL_YEAR) + 1
     year = y if (0 < y) else (y - 1)
     day_of_year = date - PersianDate(year, 1, 1).to_fixed() + 1
     month = (iceiling(day_of_year / 31)
              if (day_of_year <= 186)
              else iceiling((day_of_year - 6) / 30))
     day = date - (PersianDate(year, month, 1).to_fixed() - 1)
     return PersianDate(year, month, day)
Ejemplo n.º 4
0
 def to_fixed(self):
     """Return fixed date corresponding to Old Hindu lunar date l_date."""
     mina  = ((12 * self.year) - 1) * self.ARYA_SOLAR_MONTH
     lunar_new_year = self.ARYA_LUNAR_MONTH * (quotient(mina, self.ARYA_LUNAR_MONTH) + 1)
 
     if not self.leap and iceiling((lunar_new_year - mina) / (self.ARYA_SOLAR_MONTH - self.ARYA_LUNAR_MONTH)) <= self.month:
         temp = self.month
     else:
         temp = self.month - 1
         
     temp = self.EPOCH + lunar_new_year + (self.ARYA_LUNAR_MONTH * temp) + ((self.day - 1) * self.ARYA_LUNAR_DAY) + Clock.days_from_hours(-6)
     
     return iceiling(temp)
Ejemplo n.º 5
0
 def minor_solar_term_on_or_after(cls, fixed_date):
     """Return moment (in Beijing) of the first Chinese minor solar
     term (jieqi) on or after fixed date, 'fixed_date'.  The minor terms
     begin when the sun's longitude is an odd multiple of 15 degrees."""
     s = Solar.solar_longitude(cls.midnight(fixed_date))
     l = mod(30 * iceiling((s - 15) / 30) + 15, 360)
     return cls.solar_longitude_on_or_after(l, fixed_date)
Ejemplo n.º 6
0
 def major_solar_term_on_or_after(cls, fixed_date):
     """Return moment (in Beijing) of the first Chinese major
     solar term (zhongqi) on or after fixed date, 'fixed_date'.  The
     major terms begin when the sun's longitude is a
     multiple of 30 degrees."""
     s = Solar.solar_longitude(cls.midnight(fixed_date))
     l = mod(30 * iceiling(s / 30), 360)
     return cls.solar_longitude_on_or_after(l, fixed_date)
Ejemplo n.º 7
0
 def sine(cls, theta):
     """Return the linear interpolation for angle, theta, in Hindu table."""
     entry    = theta / angle(0, 225, 0)
     fraction = mod(entry, 1)
     return ((fraction * cls.sine_table(iceiling(entry))) + ((1 - fraction) * cls.sine_table(ifloor(entry))))
Ejemplo n.º 8
0
 def to_fixed(self):
     """Return fixed date corresponding to Old Hindu solar date s_date."""
     return iceiling(self.EPOCH + self.year * self.ARYA_SOLAR_YEAR + (self.month - 1) * self.ARYA_SOLAR_MONTH + self.day + Clock.days_from_hours(-30))