Пример #1
0
 def approx_moment_of_depression(self, tee, alpha, early):
     """Return the moment in local time near tee when depression angle
     of sun is alpha (negative if above horizon) at location;
     early is true when MORNING event is sought and false for EVENING.
     Raise VlueError if depression angle is not reached."""
     ttry  = self.sine_offset(tee, alpha)
     date = Clock.fixed_from_moment(tee)
 
     if alpha >= 0:
         if early:
             alt = date
         else:
             alt = date + 1
     else:
         alt = date + Clock.days_from_hours(12)
 
     if abs(ttry) > 1:
         value = self.sine_offset(alt, alpha)
     else:
         value = ttry
 
     if abs(value) <= 1:
         temp = -1 if early else 1
         temp *= mod(Clock.days_from_hours(12) + arcsin_degrees(value) / 360, 1) - Clock.days_from_hours(6)
         temp += date + Clock.days_from_hours(12)
         return self.local_from_apparent(temp)
     else:
         raise ValueError("Depression angle not reached")
Пример #2
0
def hindu_tithi_occur(l_month, tithi, tee, l_year):
    """Return the fixed date of occurrence of Hindu lunar tithi prior
    to sundial time, tee, in Hindu lunar month, l_month, and
    year, l_year."""
    approx = hindu_date_occur(l_month, ifloor(tithi), l_year)
    lunar  = HinduLunarDate.day_at_or_after(tithi, approx - 2)
    ttry    = Clock.fixed_from_moment(lunar)
    tee_h  = HinduLunarDate.UJJAIN.standard_from_sundial(ttry + tee)
    if lunar <= tee_h or HinduLunarDate.lunar_phase(HinduLunarDate.UJJAIN.standard_from_sundial(ttry + 1 + tee)) > 12 * tithi:
        return ttry
    else:
        return ttry + 1
Пример #3
0
 def standard_from_sundial(self, tee):
     """Return standard time of temporal moment, tee, at location, location."""
     date = Clock.fixed_from_moment(tee)
     hour = 24 * mod(tee, 1)
     if 6 <= hour <= 18:
         h = self.daytime_temporal_hour(date)
     elif (hour < 6):
         h = self.nighttime_temporal_hour(date - 1)
     else:
         h = self.nighttime_temporal_hour(date)
 
     # return
     if 6 <= hour <= 18:
         return self.sunrise(date) + ((hour - 6) * h)
     elif hour < 6:
         return self.sunset(date - 1) + ((hour + 6) * h)
     else:
         return self.sunset(date) + ((hour - 18) * h)
Пример #4
0
 def sundial_time(cls, tee):
     """Return Hindu local time of temporal moment, tee."""
     date = Clock.fixed_from_moment(tee)
     time = mod(tee, 1)
     q    = ifloor(4 * time)
     if q == 0:
         a = cls.sunset(date - 1)
         b = cls.sunrise(date)
         t = Clock.days_from_hours(-6)
     elif q == 3:
         a = cls.sunset(date)
         b = cls.sunrise(date + 1)
         t = Clock.days_from_hours(18)
     else:
         a = cls.sunrise(date)
         b = cls.sunset(date)
         t = Clock.days_from_hours(6)
     return a + (2 * (b - a) * (time - t))