-í
2Fc       sú      d  k  Z   d  k Z  d  k Z  d Z  d e Z 	 e d Z 
 d d Z  d „  Z  d „  Z  d „  Z	  d „  Z
   d	 „  Z $ d
 „  Z . d „  Z u d „  Z  d „  Z © d „  Z ³ d „  Z ¹ d „  Z Ù e d „ Z d  S(   Nf3.1415926535897931f180.0f1.0f360.0c    sA      d |  d |  | d d d d | d | d Sd S(	   sn   A macro to compute the number of days elapsed since 2000 Jan 0.0
       (which is equal to 1999 Dec 31, 0h UT)io  i   i	   i   i   i  i¢% N(   s   ys   ms   d(   s   ys   ms   d(    (    s   SunRiseSet.pys   __daysSince2000Jan0 s   c    s      t  i |  t ƒ Sd S(   s   Returns the sin in degreesN(   s   maths   sins   xs   DEGRAD(   s   x(    (    s   SunRiseSet.pys   __sind s   c    s      t  i |  t ƒ Sd S(   s   Returns the cos in degreesN(   s   maths   coss   xs   DEGRAD(   s   x(    (    s   SunRiseSet.pys   __cosd s   c    s      t  i |  ƒ t Sd S(   s   Returns the arc cos in degreesN(   s   maths   acoss   xs   RADEG(   s   x(    (    s   SunRiseSet.pys   __acosd s   c    s!     ! " t  i |  | ƒ t Sd S(   s   Returns the atan2 in degreesN(   s   maths   atan2s   ys   xs   RADEG(   s   ys   x(    (    s   SunRiseSet.pys   __atan2d  s   c    s-   $ * + t  |  | | | | d d d ƒ Sd S(   sâ   
    This macro computes times for sunrise/sunset.
    Sunrise/set is considered to occur when the Sun's upper limb is
    35 arc minutes below the horizon (this accounts for the refraction
    of the Earth's atmosphere).
    f-35.0f60.0i   N(   s   __sunriset__s   years   months   days   lons   lat(   s   years   months   days   lons   lat(    (    s   SunRiseSet.pys   __sunRiseSet$ s   c    sl  . J L t  |  | | ƒ d | d } O t t | ƒ d | ƒ } R t	 | ƒ } S | d } T | d }	 U | d } X d t | | ƒ d } [ d	 | } ^ | o _ | | } n d t | ƒ t | ƒ t |	 ƒ t | ƒ t |	 ƒ }
 f |
 d
 j o g d } h d } n: j |
 d j o k d } l d } n o t |
 ƒ d } r | | | | f Sd S(   sC  
    Note: year,month,date = calendar date, 1801-2099 only.
          Eastern longitude positive, Western longitude negative
          Northern latitude positive, Southern latitude negative
          The longitude value IS critical in this function!
          altit = the altitude which the Sun should cross
                  Set to -35/60 degrees for rise/set, -6 degrees
                  for civil, -12 degrees for nautical and -18
                  degrees for astronomical twilight.
                  upper_limb: non-zero -> upper limb, zero -> center
                  Set to non-zero (e.g. 1) when computing rise/set
                  times, and to zero when computing start/end of
                  twilight.
          *rise = where to store the rise time 
          *set  = where to store the set  time 
                  Both times are relative to the specified altitude,
                  and thus this function can be used to compute
                  various twilight times, as well as rise/set times
    Return value:  0 = sun rises/sets this day, times stored at
                       *trise and *tset.
                  +1 = sun above the specified 'horizon' 24 hours.
                       *trise set to time when the sun is at south,
                       minus 12 hours while *tset is set to the south
                       time plus 12 hours. 'Day' length = 24 hours 
                  -1 = sun is below the specified 'horizon' 24 hours
                       'Day' length = 0 hours, *trise and *tset are
                       both set to the time when the sun is at south.
    f0.5f360.0f180.0i    i   i   f12.0f15.0f0.2666f1.0iÿÿÿÿf0.0f-1.0N(   s   __daysSince2000Jan0s   years   months   days   lons   ds   __revolutions   __GMST0s   sidtimes
   __sunRADecs   ress   sRAs   sdecs   srs   __rev180s   tsouths   sradiuss
   upper_limbs   altits   __sinds   lats   __cosds   costs   rcs   ts   __acosd(   s   years   months   days   lons   lats   altits
   upper_limbs   tsouths   rcs   sdecs   costs   sRAs   ds   ress   ts   srs   sidtimes   sradius(    (    s   SunRiseSet.pys   __sunriset__. s(   !
7		c 
   s  u { ~ t  d d |  ƒ }  d d |  } € d d |  } ƒ | | t t | ƒ d | t | ƒ }	 „ t |	 ƒ | } … t
 i d | | ƒ t |	 ƒ } † t
 i | | | | ƒ } ‡ t | | ƒ } ˆ | | } ‰ | d j o Š | d } n Œ | | f Sd	 S(
   så   
    Computes the Sun's ecliptic longitude and distance 
    at an instant given in d, number of days since     
    2000 Jan 0.0.  The Sun's ecliptic latitude is not  
    computed, since it's always very near 0.           
    f356.04700000000003f0.98560025849999999f282.94040000000001f4.7093499999999999e-05f0.016709000000000002f1.1510000000000001e-09f1.0f360.0N(   s   __revolutions   ds   Ms   ws   es   RADEGs   __sinds   __cosds   Es   xs   maths   sqrts   ys   rs   __atan2ds   vs   lon(
   s   ds   es   lons   Ms   rs   ws   vs   ys   xs   E(    (    s   SunRiseSet.pys   __sunposu s   -$c 
   sÙ     “ t  |  ƒ } ” | d } • | d } ˜ | t | ƒ } ™ | t | ƒ } œ d d |  } Ÿ | t | ƒ }   | t | ƒ } £ t | | ƒ } ¤ t | t i | | | | ƒ ƒ }	 ¦ | |	 | f Sd S(   s    i    i   f23.439299999999999f3.5629999999999998e-07N(   s   __sunposs   ds   ress   lons   rs   __cosds   xs   __sinds   ys   obl_ecls   zs   __atan2ds   RAs   maths   sqrts   dec(
   s   ds   ress   zs   lons   rs   RAs   ys   xs   obl_ecls   dec(    (    s   SunRiseSet.pys
   __sunRADec s   'c    s&   © ° ± |  d t i |  t ƒ Sd S(   sÝ   
    This function reduces any angle to within the first revolution 
    by subtracting or adding even multiples of 360.0 until the     
    result is >= 0.0 and < 360.0
    
    Reduce angle to within 0..360 degrees
    f360.0N(   s   xs   maths   floors   INV360(   s   x(    (    s   SunRiseSet.pys   __revolution© s   c    s*   ³ ¶ · |  d t i |  t d ƒ Sd S(   s3   
    Reduce angle to within +180..+180 degrees
    f360.0f0.5N(   s   xs   maths   floors   INV360(   s   x(    (    s   SunRiseSet.pys   __rev180³ s   c    s(   ¹ Ñ Õ t  d d |  ƒ } Ö | Sd S(   sË  
    This function computes GMST0, the Greenwich Mean Sidereal Time  
    at 0h UT (i.e. the sidereal time at the Greenwhich meridian at  
    0h UT).  GMST is then the sidereal time at Greenwich at any     
    time of the day.  I've generalized GMST0 as well, and define it 
    as:  GMST0 = GMST - UT  --  this allows GMST0 to be computed at 
    other times than 0h UT as well.  While this sounds somewhat     
    contradictory, it is very practical:  instead of computing      
    GMST like:                                                      
                                                                    
     GMST = (GMST0) + UT * (366.2422/365.2422)                      
                                                                    
    where (GMST0) is the GMST last time UT was 0 hours, one simply  
    computes:                                                       
                                                                    
     GMST = GMST0 + UT                                              
                                                                    
    where GMST0 is the GMST "at 0h UT" but at the current moment!   
    Defined in this way, GMST0 will increase with about 4 min a     
    day.  It also happens that GMST0 (in degrees, 1 hr = 15 degr)   
    is equal to the Sun's mean longitude plus/minus 180 degrees!    
    (if we neglect aberration, which amounts to 20 seconds of arc   
    or 1.33 seconds of time)
    f818.98753999999997f0.98564735199999998N(   s   __revolutions   ds   sidtim0(   s   ds   sidtim0(    (    s   SunRiseSet.pys   __GMST0¹ s   c 
   s  Ù Ú | t j o Û t i t i ƒ  ƒ } n Ü t | d | d | d |  | ƒ } ß | d d j o à t i d } n â t i
 d } ä g  } å xv | Då ]k } æ t | ƒ }	 ç t i | ƒ \ } } è t | | ƒ |	 d <é t | d ƒ |	 d <ê | i |	 ƒ q¡ Wë | Sd  S(	   Ni    i   i   i   i  i   i<   i   (   s   dates   Nones   times   gmtimes   __sunRiseSets   lons   lats   timess   altzones   timeDiffs   timezones   sunRSTs   ts   lists	   localTimes   maths   modfs   mins   hours   ints   append(
   s   lons   lats   dates   hours   mins   sunRSTs   timess   ts   timeDiffs	   localTime(    (    s   SunRiseSet.pys   calcSunRiseSetÙ s   '	
 	(   s   maths   times   strings   PIs   RADEGs   DEGRADs   INV360s   __daysSince2000Jan0s   __sinds   __cosds   __acosds   __atan2ds   __sunRiseSets   __sunriset__s   __sunposs
   __sunRADecs   __revolutions   __rev180s   __GMST0s   Nones   calcSunRiseSet(   s   __sunriset__s   __cosds   strings   __sinds   DEGRADs   __daysSince2000Jan0s   __revolutions
   __sunRADecs   __GMST0s   calcSunRiseSets   RADEGs   __atan2ds   __sunRiseSets   __sunposs   times   PIs   INV360s   __rev180s   maths   __acosd(    (    s   SunRiseSet.pys   ? s&   	
G
 