
    R1i                        d dl Zd dlZd dlZd dlmZ d dl mZm Z mZ d dlm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZ d dlmZmZ ddlmZ ddlm Z m!Z!m"Z"m#Z#m$Z$ dd	l%m&Z&m'Z' dd
l(m)Z) ddl*m+Z+m,Z, ddl-m.Z/ ddl0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9 ddl:m;Z;m<Z<m=Z=m>Z> ddl?m@Z@ dZAdZBdZCdZDej                  dk  ZFd ZG edd      ZH G d de      ZI eJed      rej                  j                  ZLn G d dej                        ZN eN       ZL ej4                  eL      ZOe1d   ZP e	de"z        ZQ G d  d!eR      ZS G d" d#eR      ZTd9d$ZUd:d%ZVd& ZWd;d'ZXeXZYd<d(ZZd=d)Z[ G d* d+eR      Z\ e&g d,      Z] e&g d-      Z^d. Z_d/ Z` ej                  d0      j                  Zc ej                  d1      j                  Zd ej                  d2      j                  Ze ej                  d3      j                  Zfd4 Zgd5 Zhd6 Zid7 Zjd8Zky)>    N)
namedtuple)datedatetime	timedelta)arrayconcatenatecosfloat_int64isnanisinflinspacenanndarraynonzeropirollaxissearchsortedsinwhere
zeros_like)strftimestruct_time   )interp)ASEC2RADB1950DAY_ST0tau)Splinesbuild_spline_given_ends)reify)sidereal_timeearth_rotation_angle)ICRS_to_J2000)	Amxmmxmxmload_bundled_npyrot_xrot_yrot_z	_to_array
_reconcile)build_nutation_matrix-equation_of_the_equinoxes_complimentary_termsiau2000a_radiansmean_obliquity)compute_precession g   `4Bi# i$ )      c                      t        | d      S )Nr   )axis)r   )argss    T/home/cursorai/projects/iching/venv/lib/python3.12/site-packages/skyfield/timelib.py_catr<       s    Dq11    CalendarTuplez!year month day hour minute secondc                   l    e Zd Zed        Zed        Zed        Zed        Zed        Zed        Z	y)CalendarArrayc                     | d   S )Nr   r5   selfs    r;   yearzCalendarArray.year%       7Nr=   c                     | d   S Nr   r5   rB   s    r;   monthzCalendarArray.month'   s     G^r=   c                     | d   S )Nr6   r5   rB   s    r;   dayzCalendarArray.day)   s    q'>r=   c                     | d   S )N   r5   rB   s    r;   hourzCalendarArray.hour+   rE   r=   c                     | d   S )N   r5   rB   s    r;   minutezCalendarArray.minute-       !!Wnr=   c                     | d   S )N   r5   rB   s    r;   secondzCalendarArray.second/   rQ   r=   N)
__name__
__module____qualname__propertyrD   rH   rJ   rM   rP   rT   r5   r=   r;   r@   r@   $   sV    " "# #! !" "$ $$ $r=   r@   timezonec                   2    e Zd Zd Z ed      Zd Zd Zd Zy)UTCr   c                     | j                   S NzerorC   dts     r;   	utcoffsetzUTC.utcoffset8       99r=   c                      y)Nr[   r5   r`   s     r;   tznamez
UTC.tzname:   s    r=   c                     | j                   S r]   r^   r`   s     r;   dstzUTC.dst<   rc   r=   N)	rU   rV   rW   __doc__r   r_   rb   re   rg   r5   r=   r;   r[   r[   5   s    |			r=   r[   tzinfo)0JanFebMarAprMayJunJulAugSepOctNovDecd;O@@c                       e Zd ZdZej
                  ZdZd Zd Z	d Z
d ZddZd Zd	 Zd
 ZddZ	 	 ddZddZ	 	 ddZddZd Z	 	 ddZddZ	 	 ddZd Zd ZddZy)	Timescaleu  The data necessary to express dates in different timescales.

    A `Timescale` provides time objects with the data tables they need
    to translate between different time scales: the schedule of UTC leap
    seconds, and the value of ∆T over time.  Most programs create a
    single `Timescale` which they use to build their `Time` objects:

    >>> from skyfield.api import load
    >>> ts = load.timescale()
    >>> t = ts.utc(1980, 3, 1, 9, 30)
    >>> t
    <Time tt=2444299.896425741>

    See :ref:`downloading-timescale-files` if you are interested in
    checking how recent the data is in the files loaded by the
    timescale.

    Nc                     t        |      r|| _        n|| _        t        |      | _        ||c| _        | _        t        | t        t                    | _	        t        | t        t                    | _
        d | _        t        |d         }|r
|dd }|dd  }ddgg}|d d d f   t        z  |z   j                         | _        |d d d f   |z   j                         | _        | j                  | j                   z   | _        y )Nr6   rL   r   )callabledelta_t_functiondelta_t_tablebuild_delta_t
leap_datesleap_offsetsTimer
   r   J2000r   julian_calendar_cutoffr   r   flatten	_leap_utc_leap_offsets	_leap_tai)rC   delta_t_recentr   r   is_legacy_tableone_zeros         r;   __init__zTimescale.__init___   s    N# %3D!!/D$1.$AD!-7**$r
+
$u.
&*#  
2/#Ab)J'+LF8$QtV,u4x?HHJ*1T62X=FFH$*<*<<r=   c                 h    | j                  | j                         j                  t                    S )a4  Return the current date and time as a `Time` object.

        For the return value to be correct, your operating system time
        and timezone settings must be set so that the Python Standard
        Library constructor ``datetime.datetime.utcnow()`` returns a
        correct UTC date and time.

        ri   )from_datetime_utcnowreplaceutcrB   s    r;   nowzTimescale.now}   s)     !!$,,."8"8"8"DEEr=   c                 6    | j                  t        |            S )u   Return a `Time` for a Python ``datetime``.

        The ``datetime`` must be “timezone-aware”: it must have a time
        zone object as its ``tzinfo`` attribute instead of ``None``.

        .. versionadded:: 1.24

        )_utc_datetime_to_utc_tuple)rC   r   s     r;   r   zTimescale.from_datetime   s     yy/9::r=   c                 P    d |D        }| j                  d t        | D              S )u  Return a `Time` for a list of Python ``datetime`` objects.

        The ``datetime`` objects must each be “timezone-aware”: they
        must each have a time zone object as their ``tzinfo`` attribute
        instead of ``None``.

        .. versionadded:: 1.24

        c              3   2   K   | ]  }t        |        y wr]   )r   ).0ds     r;   	<genexpr>z+Timescale.from_datetimes.<locals>.<genexpr>   s     C](+]   c              3   2   K   | ]  }t        |        y wr]   )r   )r   values     r;   r   z+Timescale.from_datetimes.<locals>.<genexpr>   s     @<%u<r   )r   zip)rC   datetime_listtupless      r;   from_datetimeszTimescale.from_datetimes   s(     D]Cyy@3<@@@r=   c                 H   t        |t              r| j                  |      S t        |t              r)| j                  t        j                  |t
                    S t        |d      r$t        |d   t              r| j                  |      S ||||||f}| j                  |      S )a  Build a `Time` from a UTC `calendar date`.

        .. versionadded:: 1.24
           Passing a Python ``datetime`` or a list of datetimes as the
           first argument has been deprecated (and was never supported
           for the other time scale methods).  Instead, use the methods
           :meth:`~skyfield.timelib.Timescale.from_datetime()` and
           :meth:`~skyfield.timelib.Timescale.from_datetimes()`.

        __len__r   )	
isinstancer   r   r   combine
_time_zerohasattrr   r   )rC   rD   rH   rJ   rM   rP   rT   tups           r;   r   zTimescale.utc   s     dH%%%d++dD!%%h&6&6tZ&HII4#
47H(E&&t,,E3ff4yy~r=   c                    |\  }}}}}}t         }| j                  }	t         ||       ||       ||      |	      dz
  t        z  }
t	        |
d      \  }
}|
t        |
| j                  | j                        z  }
 ||      dz   ||      dz  z    ||      z   }t	        ||z   d      \  }}|
|z  }
t	        |
t              \  }}||z  }|t        z  }t        | ||t        z         }||_
        |
|f|_        |S )N      ?      ?      @      N@)r.   r   
julian_dayr   divmodr   r   r   r   tt_minus_taitai_fraction_tai_seconds)rC   r   rD   rH   rJ   rM   rP   rT   acutoffsecondssfrmoreseconds2wholefractionts                    r;   r   zTimescale._utc   s    25.eS$,, agqx3@3F%Ogs+6'4>>43E3EFFw!F)d"22QvY>sTz3/#8 !%0xCEuh56! #r=   c                     t         }| j                  }t         ||       ||       ||      |      dz
  }	 ||       ||      dz  z    ||      dz  z   t        z  }
t	        |	|
      S )Nr   r   r   )r.   r   r   r   r/   )rC   rD   rH   rJ   rM   rP   rT   r   r   r   r   s              r;   _jdzTimescale._jd   sj    ,,1T7AeHaff=CfI&	D 001T7V3CCuL%**r=   c                 0    t        ||| j                        S r]   )calendar_tupler   )rC   r   r   s      r;   _calzTimescale._cal   s    eXt/J/JKKr=   c           
         t        |      \  }}||t        z  z   }| j                  ||      \  }}}	}
}}|dz  }|dz   t        |      z   j	                  t
              dz  }t        |      r7t        |dd| j                        }||z   dz   |z
  j	                  t
              }n|}|r|d |j                          dz   ||j                         d  z   }|dz  j	                  t
              }t        |d      \  }}|||z  }t        |d	d      rH|D cg c]  }d
|z  	 c}}|||	|
||||||f
}t        | D cg c]  }t        |t        |             c}S d
|z  }|||	|
||||||f
}t        |t        |            S |j	                  t
              }|||z  }|||	|
|||||f	}t        |d	d      r t        | D cg c]  }t        ||       c}S t        ||      S c c}w c c}w c c}w )Nr   r   r7   r   g      ?%Z    .A@B ndim%06d)_strftime_offset_secondsr   r   r.   astypeint_format_uses_day_of_yearr   r   startendr   getattrr   r   r   )rC   formatjdr   seconds_bumpoffsetmsrD   rH   rJ   rM   rP   rT   zweekdaystart_of_yearydayusecur   r   items                         r;   	_strftimezTimescale._strftime   s%    .f5
fun,152x1H.eS$1H
 c>IbM199#>B#F+&tQ43N3NOMMC'-7??DDDKRXXZ(4/&2CCFsl**3/F!&'2LFD',&r61%)-.AVaZ.UCvva,BEs)L)QQ8)LLAsD&&'4AMCFK$455]]3'F',&sD&&'4JCr61%;>9E94.9EEFC(( / M Fs   G4G7G#c                     || j                  |      S | j                  ||||||      \  }}	t        | ||	t        z         }
|	|
_        |
S )zBuild a `Time` from an International Atomic Time `calendar date`.

        .. versionadded:: 1.6
           Passing a Julian date with ``jd=`` has been deprecated;
           instead, use :meth:`~skyfield.timelib.Timescale.tai_jd()`.

        )tai_jdr   r   r   r   )rC   rD   rH   rJ   rM   rP   rT   r   r   r   r   s              r;   taizTimescale.tai
  sR     >;;r?"((4T66Jxuh56!r=   c                 Z    t        ||      \  }}t        | ||t        z         }||_        |S )z=Build a `Time` from an International Atomic Time Julian date.)_normalize_jd_and_fractionr   r   r   rC   r   r   r   s       r;   r   zTimescale.tai_jd  s1    1"h?Hr8l23!r=   c                 t    || j                  |      S | j                  ||||||      \  }}	t        | ||	      S )zBuild a `Time` from a Terrestrial Time `calendar date`.

        .. versionadded:: 1.6
           Passing a Julian date with ``jd=`` has been deprecated;
           instead, use :meth:`~skyfield.timelib.Timescale.tt_jd()`.

        )tt_jdr   r   
rC   rD   rH   rJ   rM   rP   rT   r   r   r   s
             r;   ttzTimescale.tt!  sB     >::b>!((4T66JxD%**r=   c                 :    t        ||      \  }}t        | ||      S )z3Build a `Time` from a Terrestrial Time Julian date.)r   r   )rC   r   r   s      r;   r   zTimescale.tt_jd/  s!    1"h?HD"h''r=   c                 >    t        |      dz  dz   }t        | |d      S )zBuild a `Time` from a Terrestrial Time Julian year or array.

        Julian years are convenient uniform periods of exactly 365.25
        days of Terrestrial Time, centered on 2000 January 1 12h TT =
        Julian year 2000.0.

             v@    B:A        )r.   r   )rC   rD   r   s      r;   JzTimescale.J4  s&     t_v%	1D"c""r=   c                     || j                  |      S | j                  ||||||      \  }}	||	z   }t        | |t        |       t        z        S )zBuild a `Time` from a Barycentric Dynamical Time `calendar date`.

        .. versionadded:: 1.6
           Passing a Julian date with ``jd=`` has been deprecated;
           instead, use :meth:`~skyfield.timelib.Timescale.tdb_jd()`.

        )tdb_jdr   r   tdb_minus_ttr   r   s
             r;   tdbzTimescale.tdb?  sY     >;;r?"((4T66JxXD"R 005899r=   c           	      t    t        ||      \  }}t        | ||t        ||      t        z  z
        }||_        |S )z=Build a `Time` from a Barycentric Dynamical Time Julian date.)r   r   r   r   tdb_fractionr   s       r;   r   zTimescale.tdb_jdN  s=    1"h?Hr8l2x&@5&HHI!r=   c                 d    || j                  ||||||      \  }}	||	z   }| j                  |      S )zBuild a `Time` from a UT1 Universal Time `calendar date`.

        .. versionadded:: 1.6
           Passing a Julian date with ``jd=`` has been deprecated;
           instead, use :meth:`~skyfield.timelib.Timescale.ut1_jd()`.

        )r   ut1_jdr   s
             r;   ut1zTimescale.ut1U  s=     :"hhtUCvvNOE8!B{{2r=   c                     t        |      }|}| j                  |      }||t        z  z   }| j                  |      }|t        z  }t        | ||      }d|z  |_        |S )z5Build a `Time` from a UT1 Universal Time Julian date.r   )r.   r~   r   r   ut1_fraction)rC   r   r   	tt_approxdelta_t_approxr   s         r;   r   zTimescale.ut1_jdc  sm    m 	..y9 .500	..y9 	%sN+sr=   c                 N    | j                  |j                   j                        S )z4Build a Skyfield `Time` from an AstroPy time object.)r   )r   r   )rC   r   s     r;   from_astropyzTimescale.from_astropyy  s    ww!$$''w""r=   c           	          |j                   }|j                  }|j                   }|j                  }t        | t        |||      t        |||            S )a  Return ``num`` times spaced uniformly between ``t0`` to ``t1``.

        This routine is named after, and powered by, the NumPy routine
        `linspace()`_.

        .. _linspace(): https://numpy.org/doc/stable/reference/generated/numpy.linspace.html

        )r   tt_fractionr   r   )rC   t0t1numwhole0frac0whole1frac1s           r;   r   zTimescale.linspace}  sP     VVS)UE3'
 	
r=   r   r   r   r   r   r]   )Nr   r   r   r   r   N)2   )rU   rV   rW   rh   r   utcnowr   polar_motion_tabler   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r5   r=   r;   rz   rz   I   s    $ ooG=<	F	;A.2+L.)` GJ  FI+(
	# GJ: GJ,#
r=   rz   c                      e Zd ZdZd:dZd Zd Zd Zd Zd Z	d	 Z
d
 Zd Zd;dZd Zd<dZd=dZd Zed        Zd Zd Zd Zd Zd Zd>dZd?dZd@dZdAdZed        Zed        Zed        Zed        Z ed        Z!d  Z" e#de"      Z"ed!        Z$ed"        Z%ed#        Z&ed$        Z'ed%        Z(ed&        Z)ed'        Z*ed(        Z+ed)        Z,ed*        Z-e#d+        Z.e#d,        Z/e#d-        Z0e#d.        Z1d/ Z2d0 Z3d1 Z4d2 Z5d3 Z6d4 Z7d5 Z8d6 Z9d7 Z: ee5      Z; ee4      Z<dxe;_        e<_        ed8        Z=ed9        Z>y)Br   u-  A single moment in history, or an array of several moments.

    Skyfield programs don’t usually instantiate this class directly, but
    instead build time objects using one of the timescale methods listed
    at `timescale-summary`.  If you do attempt the low-level operation
    of building a time object yourself, either leave ``tt_fraction`` at
    its default value of ``None`` — in which case Skyfield will assume
    the fraction is zero — or provide a ``tt_fraction`` array that has
    exactly the same dimensions as your ``tt`` array.

    Nc                 t    |t        |      }|| _        || _        || _        t	        |dt
              | _        y )Nshape)r   tsr   r   r   _EMPTY_TUPLEr
  )rC   r  r   r   s       r;   r   zTime.__init__  s7    $R.K
&R,7
r=   c                 J    | j                   }|t        u rt        d      |d   S )N#this is a single Time, not an arrayr   )r
  r  	TypeError)rC   r
  s     r;   r   zTime.__len__  s(    

L ABBQxr=   c                    t        | j                  dd      }|dkD  r/d}|j                  | j                  d   | j                  d   |      S dj                  | j                        j                  dd      j                  d	d
      S )Nsizer|   rL   z<Time tt=[{0} ... {1}] len={2}>r   z<Time tt={0}>z[ [z   )r   r   r   r   )rC   r  rstrs      r;   __repr__zTime.__repr__  sq    tww+!84D;;twwqz4772;==#**4773WT3'c(:<r=   c                    | j                   t        u rt        d      t        | j                  | j
                  |   | j                  |         }| j                  }dD ]&  }|j                  |      }|t        ||||          ( |S )Nr  )r   r   r   )
r
  r  r  r   r  r   r   __dict__getsetattr)rC   indexr   r   namer   s         r;   __getitem__zTime.__getitem__  s~    ::%ABB$**U+T-=-=e-DEMMBDEE$KE 4u. C r=   c                 .    | j                  |      \  }}|S )zConvert to a Python ``datetime`` in a particular timezone ``tz``.

        If this time is an array, then an array of datetimes is returned
        instead of a single value.

        )astimezone_and_leap_second)rC   tzra   leap_seconds       r;   
astimezonezTime.astimezone  s     99"=K	r=   c           
         | j                         \  }}t        |dd      }| j                  r4|2t        |D cg c]  } ||j	                  |             c}      }||fS | j                  r,t        |D cg c]  }|j	                  |       c}      }||fS | ||j	                  |            }||fS |j	                  |      }||fS c c}w c c}w )a  Convert to a Python ``datetime`` and leap second in a timezone.

        Convert this time to a Python ``datetime`` and a leap second::

            dt, leap_second = t.astimezone_and_leap_second(tz)

        The argument ``tz`` should be a ``datetime`` compatible
        timezone.

        The leap second value is provided because a Python ``datetime``
        can only number seconds ``0`` through ``59``, but leap seconds
        have a designation of at least ``60``.  The leap second return
        value will normally be ``0``, but will instead be ``1`` if the
        date and time are a UTC leap second.  Add the leap second value
        to the ``second`` field of the ``datetime`` to learn the real
        name of the second.

        If this time is an array, then an array of ``datetime`` objects
        and an array of leap second integers is returned, instead of a
        single value each.

        	normalizeN)utc_datetime_and_leap_secondr   r
  r   r!  )rC   r  ra   r   r#  r   s         r;   r  zTime.astimezone_and_leap_second  s    . ;;=KBT2	::)/R@R	!,,r"23R@AB ; ZZ"5"QR("56B
 ;	 "2==,-B ; r"B; A5s   C6Cc                 J    | j                  d      \  }}}|dz
  |z   t        z  S )a=  Return the proleptic Gregorian ordinal of the UTC date.

        This method makes Skyfield `Time` objects compatible with Python
        `datetime`_ objects, which also provide a ``toordinal()``
        method.  Thanks to this method, a `Time` can often be used
        directly as a coordinate for a plot.

        r   g  `PAB)_utc_secondsr   )rC   r   r   is_leap_seconds       r;   	toordinalzTime.toordinal  s0     +/*;*;C*@'x&1U::r=   c                 ,    | j                         \  }}|S )zConvert to a Python ``datetime`` in UTC.

        If this time is an array, then a list of datetimes is returned
        instead of a single value.

        )r$  )rC   ra   r   s      r;   utc_datetimezTime.utc_datetime  s     ;;=K	r=   c           
         | j                  d      \  }}}}}}|dz  j                  t              }t        |d      \  }}|dz  }||z  }| j                  rLt
        g| j                  d   z  }	t        ||||||||	      }
t        |
D cg c]
  }t        |  c}      }||fS t        |||||||t
              }||fS c c}w )aF  Convert to a Python ``datetime`` in UTC, plus a leap second value.

        Convert this time to a `datetime`_ object and a leap second::

            dt, leap_second = t.utc_datetime_and_leap_second()

        The leap second value is provided because a Python ``datetime``
        can only number seconds ``0`` through ``59``, but leap seconds
        have a designation of at least ``60``.  The leap second return
        value will normally be ``0``, but will instead be ``1`` if the
        date and time are a UTC leap second.  Add the leap second value
        to the ``second`` field of the ``datetime`` to learn the real
        name of the second.

        If this time is an array, then an array of ``datetime`` objects
        and an array of leap second integers is returned, instead of a
        single value each.

        gƠ>r   r   <   r   )	
_utc_tupler   r   r   r
  r   r   r   r   )rC   rD   rH   rJ   rM   rP   rT   micror   zoneargsetsr:   ra   s                r;   r$  z!Time.utc_datetime_and_leap_second  s    ( 261H.eS$#%%c*ug.l+::54::a=(D$sD&&%NGG<GD$G<=B ; $sD&&%MB; =s   B<c                 t   t        |t              r|}d}|rRd|z  }d|z  }| j                  |      \  }}}}}	}
t        |
d      \  }
}||z  }dj	                  ||      }|||||	|
|f}n"dj	                  |      }| j                  d      }| j
                  rt        | D cg c]  }||z  	 c}S ||z  S c c}w )zConvert to an ISO 8601 string like ``2014-01-18T01:35:38Z`` in UTC.

        If this time is an array of dates, then a sequence of strings is
        returned instead of a single string.

        T
   r   r   z'%04d-%02d-%02d{0}%02d:%02d:%02d.%0{1}dZz %04d-%02d-%02d{0}%02d:%02d:%02dZ)r   r   r-  r   r   r
  r   )rC   	delimiterplacespower_of_tenr   rD   rH   rJ   rM   rP   rT   r   r   r:   r   s                  r;   utc_isozTime.utc_iso#  s     i%FI<L<'F59__V5L2D%dFF%fc2FH$H>EE6#F%dFFHED7>>yIF??3'D::,/J7JSFSLJ77D=  8s   !B5c                    | j                  d      \  }}}}}}t        |d      \  }}|dz  }|dk  }t        ||z
        }t        |dd      }	d}
|	|t        |   |||||f}| j
                  rt        | D cg c]  }|
|z  	 c}S |
|z  S c c}w )a1  Convert to a string like ``A.D. 2014-Jan-18 01:35:37.5000 UTC``.

        Returns a string for this date and time in UTC, in the format
        used by the JPL HORIZONS system.  If this time is an array of
        dates, then a sequence of strings is returned instead of a
        single string.

        g-C6
?r   g     @r   zB.C.zA.D.z'%s %04d-%s-%02d %02d:%02d:%02d.%04d UTC)r-  r   absr   MONTH_NAMESr
  r   )rC   rD   rH   rJ   rM   rP   rT   r   bcerar   r:   r   s                r;   utc_jplzTime.utc_jplC  s     261I.eS$!&#.CAX4"9~B':T;u-sffh0 ::,/J7JSFSLJ77D=  8s   6B
c                     t        |      \  }}| j                  |d      \  }}}}}}	}
t        |dd| j                  j                        }|
dz  }|
dz   |z
  }t        |||||||	|||
      S )u  Format the UTC time using a Python datetime formatting string.

        This calls Python’s ``time.strftime()`` to format the date and
        time.  A single string is returned or else a whole array of
        strings, depending on whether this time object is an array.
        The most commonly used formats are:

        * ``%Y`` four-digit year, ``%y`` two-digit year
        * ``%m`` month number, ``%B`` name, ``%b`` abbreviation
        * ``%d`` day of month
        * ``%H`` hour
        * ``%M`` minute
        * ``%S`` second
        * ``%A`` day of week, ``%a`` its abbreviation

        You can find the full list, along with options that control
        field widths and leading zeros, at:

        https://docs.python.org/3/library/time.html#time.strftime

        If the smallest time unit in your format is minutes or seconds,
        then the time is rounded to the nearest minute or second.
        Otherwise the value is truncated rather than rounded.

        r   r7   )r   r-  r   r  r   r   )rC   r   r   uses_msrD   rH   rJ   rM   rP   rT   r   r   r   r   s                 r;   utc_strftimezTime.utc_strftime[  s    4 36:59__VQ5O2eS$"4Atww/M/MNq&Av%uc4 $1 	1r=   c                 H   | j                  |      \  }}}|j                  t              }||z  }t        |dz   d      \  }}| j                  j
                  }t        ||      \  }}	}
t        |d      \  }}t        |d      \  }}||z  }|s||	|
||||z   fS ||	|
||||z   |fS )a  Return UTC as (year, month, day, hour, minute, second.fraction).

        The `offset` in seconds is added to the UTC time before it is
        split into its components.  This is useful if the user is going
        to round the result before displaying it.  If the result is
        going to be displayed as seconds, for example, set `offset` to
        0.5 and then throw away the fraction; if the result is going to
        be displayed as minutes, set `offset` to 30.0 and then throw
        away the seconds; and so forth.

        i  iQ r,  )r&  r   r   r   r  r   compute_calendar_date)rC   r   	return_jdrT   r   r'  r   r   rD   rH   rJ   rP   rM   s                r;   r-  zTime._utc_tuple}  s     '+&7&7&?#^u%. FUNE2
F//0V<eS+fb)f. T66C<??UCvv|R??r=   c                     | j                   \  }}t        ||z   d      \  }}||z   }| j                  }t        ||j                  |j
                        }t        |d      \  }}|dkD  }||z
  ||fS )u?   Return integer seconds since JD 0.0, plus a 0 ≤ fraction < 1.r   r   )r   r   r  r   r   r   )rC   r   r   frr   r  tai_minus_utcr'  s           r;   r&  zTime._utc_seconds  s}    ''b6k3/"H$WWwb6F6FG(.}c(B%~'#-&N::r=   c                     t        | j                  t        z  d      \  }}t        || j                  t        z  z   d      \  }}||z  }||fS Nr   )r   r   r   r   )rC   r   rE  r   s       r;   r   zTime._tai_seconds  sQ     TZZ%/5b4#4#4u#<<cB"8{r=   c                 z    | j                   }| j                  \  }}t        ||j                  |j                        S r]   )r  r   r   r   r   )rC   r  r   rE  s       r;   _leap_secondszTime._leap_seconds  s3    WW''gr||R-=-=>>r=   c                 b    | j                   j                  | j                  | j                        S )zBTAI as a (year, month, day, hour, minute, second) `calendar date`.)r  r   r   r   rB   s    r;   tai_calendarzTime.tai_calendar  !    ww||DJJ(9(9::r=   c                 b    | j                   j                  | j                  | j                        S )zATT as a (year, month, day, hour, minute, second) `calendar date`.)r  r   r   r   rB   s    r;   tt_calendarzTime.tt_calendar  s!    ww||DJJ(8(899r=   c                 b    | j                   j                  | j                  | j                        S )zBTDB as a (year, month, day, hour, minute, second) `calendar date`.)r  r   r   r   rB   s    r;   tdb_calendarzTime.tdb_calendar  rM  r=   c                 b    | j                   j                  | j                  | j                        S )zBUT1 as a (year, month, day, hour, minute, second) `calendar date`.)r  r   r   r   rB   s    r;   ut1_calendarzTime.ut1_calendar  rM  r=   c                 d    | j                   j                  || j                  | j                        S )z4Format TAI with a datetime strftime() format string.)r  r   r   r   rC   r   s     r;   tai_strftimezTime.tai_strftime  %    ww  T5F5FGGr=   c                 d    | j                   j                  || j                  | j                        S )z3Format TT with a datetime strftime() format string.)r  r   r   r   rU  s     r;   tt_strftimezTime.tt_strftime  s%    ww  T5E5EFFr=   c                 d    | j                   j                  || j                  | j                        S )z4Format TDB with a datetime strftime() format string.)r  r   r   r   rU  s     r;   tdb_strftimezTime.tdb_strftime  rW  r=   c                 d    | j                   j                  || j                  | j                        S )z4Format UT1 with a datetime strftime() format string.)r  r   r   r   rU  s     r;   ut1_strftimezTime.ut1_strftime  rW  r=   c                     | j                   }|j                  d      }|| j                         }|j                  d      }|| j                         }t	        ||t
              S )u4   3×3 rotation matrix: ICRS → equinox of this date.PN)r  r  precession_matrixnutation_matrixr)   B)rC   r   r_  r`  s       r;   MzTime.M  s[     MMEE#J9&&(AEE#J9$$&AQ1~r=   c                 .    t        | j                  d      S )u4   3×3 rotation matrix: equinox of this date → ICRS.r   )r   rd  rB   s    r;   MTzTime.MT  s     ""r=   c                     t        | j                        | j                  dz  z
  }t        dt        z  |z        }t        || j                        S )N      8@r6   )r%   r   gastr-   r   r(   rd  )rC   
eq_originsRs      r;   CzTime.C  sC     +4884tyy47GG
!b&:%&1dff~r=   c                 .    t        | j                  d      S rG   )r   rl  rB   s    r;   CTzTime.CT  s    ""r=   c                     t        |       S r]   )r2   rB   s    r;   _nutation_angles_radianszTime._nutation_angles_radians  s      %%r=   c                 H    |\  }}|dz  t         z  |dz  t         z  f| _        y )Ng    cA)r   rp  )rC   anglesd_psid_epss       r;   _nutation_angleszTime._nutation_angles   s/    
 uCK("CK(")
%r=   c                 :    t        | j                        t        z  S r]   )r3   r   r   rB   s    r;   _mean_obliquity_radianszTime._mean_obliquity_radians  s     dhh'(22r=   c                 @    | j                   dz
  | j                  z   dz  S )zReturn a floating point Julian year or array of years for this date.

        Julian years are convenient uniform periods of exactly 365.25
        days of Terrestrial Time, centered on 2000 January 1 12h TT =
        Julian year 2000.0.

        r   r   r   r   rB   s    r;   r   zTime.J  s#     

Y&)9)99VCCr=   c                     | j                  d      }| j                  rt        |      j                  t              S t        | S )z=A tuple ``(year, month, day, hour, minute, seconds)`` in UTC.r   )r-  r
  r   viewr@   r>   )rC   r   s     r;   r   zTime.utc  s:     ooc"26**c
. 	*"C(	*r=   c                 (    | j                   t        z
  S r]   )r   r   rB   s    r;   r   zTime.tai_fraction&  s    ,..r=   c                 Z    | j                   }|t        | j                  |      t        z  z   S r]   )r   r   r   r   )rC   rE  s     r;   r   zTime.tdb_fraction*  s(    LR05888r=   c                 B    | j                   | j                  t        z  z
  S r]   )r   delta_tr   rB   s    r;   r   zTime.ut1_fraction/  s    $,,"666r=   c                 L    | j                   j                  | j                        S r]   )r  r~   r   rB   s    r;   r  zTime.delta_t3  s    ww''00r=   c                 B    d| j                         z   | j                  z
  S )Nrx   )rJ  r  rB   s    r;   dut1z	Time.dut17  s    **,,t||;;r=   c                     t        |       S )z-Greenwich Mean Sidereal Time (GMST) in hours.)r$   rB   s    r;   gmstz	Time.gmst;  s     T""r=   c                     | j                   \  }}| j                  }t        |      }|t        | j                        z  |z   }| j
                  |t        z  dz  z   dz  S )z1Greenwich Apparent Sidereal Time (GAST) in hours.rh  )rp  r   r1   r	   rw  r  r    )rC   rs  _r   c_termseq_eqs         r;   ri  z	Time.gast@  s]     00qWW?CD8899GC		ECK$..$66r=   c                 4    | j                   | j                  z   S r]   )r   r   rB   s    r;   r   zTime.taiL      zzD----r=   c                 4    | j                   | j                  z   S r]   ry  rB   s    r;   r   zTime.ttP  s    zzD,,,,r=   c                 4    | j                   | j                  z   S r]   )r   r   rB   s    r;   r   zTime.tdbT  r  r=   c                 4    | j                   | j                  z   S r]   )r   r   rB   s    r;   r   zTime.ut1X  r  r=   c                     | j                   j                  }|yd| j                  t        z
  z  dz  }|\  }}}|t	        | j
                  ||      t	        | j
                  ||      fS )N)r   r   r   g4;    @)r  r  r   r   r   r   )rC   tablesprimer   xys         r;   polar_motion_angleszTime.polar_motion_angles^  sb    **= TXX]+g5Aqvdggr1-vdggr1/EEEr=   c                     | j                         \  }}}t        t        |t        z        t	        |t        z        t        | t        z              S r]   )r  r)   r+   r   r,   r-   )rC   r  r  r  s       r;   polar_motion_matrixzTime.polar_motion_matrixf  sJ    //11!h,!h,6'H$%
 	
r=   c                 \    | j                   \  }}| j                  }||z   }t        |||      S )u1   Compute the 3×3 nutation matrix N for this date.)rp  rw  r0   )rC   rs  rt  r3   true_obliquitys        r;   rb  zTime.nutation_matrixn  s5    44u55'%/$^^UKKr=   c                 ,    t        | j                        S )u3   Compute the 3×3 precession matrix P for this date.)r4   r   rB   s    r;   ra  zTime.precession_matrixu  s    !$((++r=   c                 L    t        |t              r| j                  |      dk(  S y)Nr   F)r   r   __sub__)rC   
other_times     r;   __eq__zTime.__eq__{  s#    j$'<<
+s22r=   c                 N   t        |t              r4|j                  }|j                  t        z  |j
                  t        z  z   }n,t        |t        t        f      rt        |d      \  }}nt        S | j                  j                  | j                  |z   | j                  |z         S rH  )r   r   daysr   r   microsecondsDAY_USr   floatr   NotImplementedr  r   r   r   rC   r  wfs       r;   __add__zTime.__add__  s    j),A""U*Z-D-Dv-MMA
S%L1*c*DAq!!ww}}TZZ!^T-=-=-ABBr=   c                    t        |t              r3| j                  |j                  z
  | j                  |j                  z
  z   S t        |t              r4|j
                  }|j                  t        z  |j                  t        z  z   }n,t        |t        t        f      rt        |d      \  }}nt        S | j                  j                  | j                  |z
  | j                  |z
        S rH  )r   r   r   r   r   r  r   r   r  r  r   r  r   r  r  r   r  s       r;   r  zTime.__sub__  s    j$'::
 0 00  :#9#99  
I.A""U*Z-D-Dv-MMA
S%L1*c*DAq!!ww}}TZZ!^T-=-=-ABBr=   c                 ,    t        | j                        S r]   )hashr   rB   s    r;   __hash__zTime.__hash__  s    
 DGG}r=   c                 N    ddl m}  || j                  | j                  dd      S )z0Return an AstroPy object representing this time.r   )r   r   r   )r   scale)astropy.timer   r   r   )rC   r   s     r;   
to_astropyzTime.to_astropy  s     %DJJ 0 0TJJr=   c                 .    t        | j                  d      S rG   )r   r_  rB   s    r;   PTzTime.PT      !$&&!,,r=   c                 .    t        | j                  d      S rG   )r   r`  rB   s    r;   NTzTime.NT  r  r=   r]   )r2  r   )z%Y-%m-%d %H:%M:%S UTC)F)z%Y-%m-%d %H:%M:%S TAI)z%Y-%m-%d %H:%M:%S TT)z%Y-%m-%d %H:%M:%S TDB)z%Y-%m-%d %H:%M:%S UT1)?rU   rV   rW   rh   r   r   r  r  r!  r  r(  r*  r$  r7  r=  r@  r-  r&  r#   r   rJ  rL  rO  rQ  rS  rV  rY  r[  r]  rd  rf  rl  rn  rp  ru  rX   rw  r   r   r   r   r   r  r  r  ri  r   r   r   r   r  r  rb  ra  r  r  r  r  r  r_  r`  r  r  r5   r=   r;   r   r     s   
8<
!F
;B!@!0 1D@2	;  ?;:;;HGHH  ( # #   # # & &
	
  &67
3 3 D D * * / / 9 9 7 7 1 1 < < # # 7 7 . . - - . . . .
F
L,
	CCK 	 AoA  AI	
, ,
, ,r=   r   c                     t        |dz
  d      \  }}| |z   } |dz  }|dk  }| dz   |z
  }|dz   dz  }d|z  dz  |z   dz
  }|d	|z  dz   d
z  z   }	|dn|	|k\  }
|	d|dz   dz  dz  dz  z
  |
z  z  }	|	S )zGiven a calendar date, return a Julian day integer.

    Uses the proleptic Gregorian calendar unless ``julian_before`` is
    set to a specific Julian day, in which case the Julian calendar is
    used for dates older than that.

    r      r6   l  	     rO   iz     rS   &      d   rL   )r   )rD   rH   rJ   julian_beforer  janfebgr  er   masks              r;   r   r     s     eai$HAu!8D	QJE aZFtfA	bAqAd"A	S1Wq[QA&1a=.@D"CC!#q(
(D	00AHr=   c                 N    t        | ||      dz
  ||dz  z   |dz  z   t        z  z   S )u  Given a proleptic Gregorian calendar date and time, build a Julian date.

    The difference between a “Julian day” and a “Julian date” is that
    the “day” is the integer part, while the “date” includes a fraction
    indicating the time.

    r   r   r   )r   r   )rD   rH   rJ   rM   rP   rT   s         r;   julian_dater    s;     dE3'#-$.%18 8 8r=   c                     d| dz
  dz  z   S )Ngal!(lBAg     @gk8v@r5   )bs    r;   julian_date_of_besselian_epochr    s    AJ-777r=   c                     |du xs | |k\  }| dz   }||d| z  dz   dz  dz  dz  dz
  z  z  }d|z  dz   }|dz  dz  }d	|z  d
z   }|dz  d	z  dz   }|dz  d
z   dz  dz   }|dz  dz
  d|z
  dz  z   }	|	||fS )zConvert Julian day ``jd_integer`` into a calendar (year, month, day).

    Uses the proleptic Gregorian calendar unless ``julian_before`` is
    set to a specific Julian day, in which case the Julian calendar is
    used for dates older than that.

    Niy  rO   ie/ i: rL   r  r  rS   r6   r  r   r  r     r5   )

jd_integerr  use_gregorianr  r  r  hrJ   rH   rD   s
             r;   rB  rB    s     #d*L
m0KM 	TA1z>F2v=AQFK	LLA	A	A	DAA	A	A
c'Q,
C#X\R!#E9tv~"44Dr=   c                 0   t        |       } t        | d      \  }}t        ||z   dz   d      \  }}||z   j                  t              }t	        ||      \  }}}	|dz  }
t        |
d      \  }}
|j                  t              }t        |d      \  }}|||	|||
fS )zAReturn a (year, month, day, hour, minute, second.fraction) tuple.r   r   g     @r   r,  )r.   r   r   r   rB  )jd_floatr   r  r  	fraction1whole2r   rD   rH   rJ   rT   rP   rM   s                r;   r   r     s    "Hx-FIi(2S8#>FHf_$$S)E,UMBD%FFD)NFF]]3F&"%LD&T6611r=   c                 J   | t         z
  |z   dz  }dt        d|z  dz         z  dt        d|z  dz         z  z   dt        d	|z  d
z         z  z   dt        d|z  dz         z  z   dt        d|z  dz         z  z   dt        d|z  dz         z  z   d|z  t        d|z  dz         z  z   S )zComputes how far TDB is in advance of TT, given TDB.

    Given that the two time scales never diverge by more than 2ms, TT
    can also be given as the argument to perform the conversion in the
    other direction.

    r  gc3%[?g!u@g?@g&|>g|?@g㥛 0@g_>Y1\>g!u@gaTR'@gh㈵>ge`T@ghs@gFx|J@g镲q?g>gMStT5@g	h",@gh㈵>g"@)r   r   )jd_tdbfraction_tdbr   s      r;   r   r     s     
"|	#w.A sX\F233sX\F2334sIMF2334 sX\F2334 sgkF233	4
 sgkF2334 qL3A!6778 9r=   c                       e Zd Zd Zd Zy)DeltaTc                 .    || _         || _        || _        y r]   )table_tttable_delta_tlong_term_function)rC   r  r  r  s       r;   r   zDeltaT.__init__  s     *"4r=   c                 ,   t        || j                  | j                  t        t              }t	        |dd       r7t        t        |            }|r||   dz
  dz  }| j                  |      ||<   |S t        |      r|dz
  dz  }| j                  |      }|S )Nr
  r   r   )r   r  r  r   r   r   r   r  )rC   r   r  nan_indexesr   s        r;   __call__zDeltaT.__call__  s    T]]D,>,>SI7GT*!%.1K_y0F:'+'>'>q'A$
  W~)^v-11!4r=   N)rU   rV   rW   r   r  r5   r=   r;   r  r    s    5
r=   r  )g     @g     @r   g     @@@r   g      t)g     p@g      @r   g      @@r   g      4c                 h   t         }t        d      d   }| \  }}|}|j                  }t        |      }|j                  }|j                  d   |j
                  d   z
  }	d}
|j
                  d   }||
z
  }t        | ||       ||      | ||       ||            }|}||	z
  }t        | ||       ||      | ||       ||            }|d   dz
  dz  }t        |d   |      }|ddd|f   }|d   } ||      }|dddf   \  }}}}}}||z
  ||z
  z  }|||z
  |z  z   }||||||f|dddf<   |d   dz
  dz  }||
z   d	z  d	z  }|d   }t        d
t        |            }|d   ||    z
  |z  dz  }t        |||| ||       ||            }|}||	z   }t        | ||       ||      | ||       ||            }t        t        t        |g      j                  t        |g      j                  |t        |g      j                  t        |g      j                              }t        |||      S )u  Return a function t→∆T, given recent real-world observations of ∆T.

    When asked for ∆T outside the range of the `delta_t_recent` table,
    Skyfield uses the splines for 720 BC – AD 2015 computed by Morrison,
    Stephenson, Hohenkerk, and Zawilski.  For dates that fall outside of
    the spines, we use the long-term parabola of Stephenson, Morrison,
    and Hohenkerk.

    zdelta_t.npzzTable-S15.2020.txtr   g      @r   r   Nr|   g      Y@in  g     v@)3delta_t_parabola_stephenson_morrison_hohenkerk_2016r*   
derivativer!   upperlowerr"   r   minlenr<   r   r2  r  )r   parabola	s15_tabler  r  ppdssdlong_term_parabola_widthpatch_widthx1x0leftfar_leftr  i	desired_y	current_ya3a2a1a0r   y0lookbacksloperight	far_rightcurves                                 r;   r   r   +  s    CH /0DEI,HmA			B	A	
B wwqzAGGAJ6 K
 
B	k	B"2qubfb!B%BHD 
B	&	&B&r1R5"R&"aeRVLH
 
!y	 F*AYq\1%A!BQB$Ia I!I&qt_BBB	
RBGA	y9$)	)B"b"b",IadO
 2,
"f	,B
{
u	$u	,B	r	B3M*+H2y!99XEME#BE2qubfEE 
B	&	&B'AbE2b62qubfMIDxjtfugyk E (M511r=   c           	      V   t        t        d      ddddf   t        d            }| d   }t        |d   |      }d}|d   |z
  }t        d|      j                  }| d   |z   }t        d|      j                  }t        |gt        |      gg|ddd|f   | |gt        |      gg      S )	zEDeprecated: the Delta T interpolation table used in Skyfield <= 1.37.zmorrison_stephenson_deltat.npyN   zhistoric_deltat.npy)r   r   r   g    @)r   r|   )r<   r*   r   r   r   )delta_t_parabola_morrison_stephenson_2004)	r   bundledrecent_start_timer  centurystart_ttstart_Jend_ttend_Js	            r;   build_delta_t_tabler  }  s    9:1SbS5A./G 's+WQZ!23AGs|g%H4"$$GD!G+Fv  E
?HIJ"1"
=eDEF	 r=   z%[-_0^#EO]*fz%[-_0^#EO]*[STXc]z%[-_0^#EO]*[MR]z%[-_0^#EO]*jc                    | j                   }|t        t              |t        ur| j	                  t              } | j
                  | j                  | j                  | j                  | j                  | j                  | j                  dz  z   fS )Nr   )rj   
ValueError_naive_complaintr   r!  rD   rH   rJ   rM   rP   rT   microsecond)ra   r   s     r;   r   r     sq    
		Ay)**|]]3GGRXXrvvGGRYY		BNNS,@ @B Br=   c                 z    t        |       } |t        | d      \  } }| |fS t        | t        |            \  } }| |fS rH  )r.   r   r/   )r   r   s     r;   r   r     sM    	2Bb#H x< ""i&9:Hx<r=   c                     t        |       }|rt        rt        d      d}||fS t        |       rd}||fS t	        |       rd}||fS d}||fS )Nz,strftime() "%f" not supported under Python 2gؗҜ<r   g      >@r   )_format_uses_milliseconds_OLD_PYTHONr	  _format_uses_seconds_format_uses_minutes)r   r?  r   s      r;   r   r     sv    '/GKLL 7? 
f	%
 7?	 
f	% 7? 7?r=   c
           
      x   |dz  }
|	r| d |	j                          dz   | |	j                         d  z   } |dz  j                  t              }t	        |d      \  }}t        |dd      rH|D cg c]  }d|z  	 c}}|||||||||
|f
}t        | D cg c]  }t        | t        |             c}S d|z  }|||||||||
|f
}t        | t        |            S |j                  t              }|||||||||
f	}t        |dd      r t        | D cg c]  }t        | |       c}S t        | |      S c c}w c c}w c c}w )Nr   r   r   r   r   r   )	r   r   r   r   r   r   r   r   r   )r   rD   rH   rJ   rM   rP   rT   r   r   r?  r_   r   r   r   r   r   s                   r;   r   r     sh   !8D
 ()D06'++-.3II3,&&s+fg.4#%)*T!T*AT66D$+C>A3iHiHV[^4iHHTME3ffgtT1LC 011s#E3ffgtTI4#7:CyAytHVT*yAA$$ + I Bs   *D-D2D7a  cannot interpret a datetime that lacks a timezone

You must either specify that your datetime is in UTC:

    from skyfield.api import utc
    d = datetime(..., tzinfo=utc)  # to build a new datetime
    d = d.replace(tzinfo=utc)      # to fix an existing datetime

Or use a timezone object like those provided by the third-party `pytz` library:

    from pytz import timezone
    eastern = timezone('US/Eastern')
    d = eastern.localize(datetime(2014, 1, 16, 1, 32, 9)))r   r   Nr  r]   )r   N)r   )lr   	dt_moduleresyscollectionsr   r   r   numpyr   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   timer   r   _compatibilityr   	constantsr   r   r   r   r    curvelibr!   r"   descriptorlibr#   earthlibr$   r%   framelibr&   rc  	functionsr'   r(   r)   r*   r+   r,   r-   r.   r/   nutationlibr0   r1   r2   r3   precessionlibr4   r  r  GREGORIAN_STARTGREGORIAN_START_ENGLANDversion_infor  r<   r>   r@   r   rY   r   rj   r[   r   r:  r   objectrz   r   r   r  r  rB  calendar_dater   r   r  r  r  r   r  compilesearchr  r  r  r   r   r   r   r   r
  r5   r=   r;   <module>r)     s
    	 
 " . .    
 ' " 6 6 6   9 (/ / /  .	! ' 1?,OP%G % 9j!



 
 Ci  %C Y^^3'
 9 : Ve^$E
 E
N
c-6 c-J0	88* &29&V & 7>,7. 3 -4+-- )P2d( 'BJJ7>> !rzz"67>> !rzz"45<< %2::o6== B%4= r=   