
    h                     T    S r SSKrSSKrSSKrSSKrSSKJr  SSKJ	r	   " S S5      r
g)zEpoch module.    N)_api)date2numc                      \ rS rSrSS0SS0S.rSS jrS	 rS
 rS rS r	S r
\R                  " \
\R                  5      r\R                  " \
\R                   5      r\R                  " \
\R$                  5      r\R                  " \
\R(                  5      r\R                  " \
\R,                  5      r\R                  " \
\R0                  5      rS rS rS rS r\S 5       rSr g)Epoch   UTCg oP@ETg oP)r	   r   Nc           
         Uc  UcL  Ub  UbF  Ub  Uc@  Uc=  Uc	  Uc  Ub4  Ub1  Ub  Uc+  Ub  Uc%  Uc"  Ub:  [        U[        R                  5      (       d  [        SU< SU< SU< SU< 35      e[        R
                  " U R                  US9  Xl        Ub  [        U5      nUb@  [        U5      S-   n[        R                  " U5      U l        X0R                  -
  S-  U l        g[        U5      U l        [        U5      U l        [        R                  " U R                  S	-  5      nU =R                  U-  sl        U =R                  US-  -  sl        g)
a*  
Create a new Epoch object.

Build an epoch 1 of 2 ways:

Using seconds past a Julian date:
#   Epoch('ET', sec=1e8, jd=2451545)

or using a matplotlib day number
#   Epoch('ET', daynum=730119.5)

= ERROR CONDITIONS
- If the input units are not in the allowed list, an error is thrown.

= INPUT VARIABLES
- frame     The frame of the epoch.  Must be 'ET' or 'UTC'
- sec        The number of seconds past the input JD.
- jd         The Julian date of the epoch.
- daynum    The matplotlib day number of the epoch.
- dt         A python datetime instance.
NzlInvalid inputs.  Must enter sec and jd together, daynum by itself, or dt (must be a python datetime).
Sec = z
JD  = z
dnum= z
dt  = )frameg   QD:A     @Q )
isinstanceDTdatetime
ValueErrorr   check_in_listallowed_framer   floatmathfloor_jd_seconds)selfr   secjddaynumdt	deltaDayss          T/var/www/html/env/lib/python3.13/site-packages/matplotlib/testing/jpl_units/Epoch.py__init__Epoch.__init__   s0   , [R^RZ#/R^BJ+#S_.*R*E*E "2vr34 4 	4<<u5>b\Fv*Bzz"~DH((]g5DM "#JDMRyDH 

4==5#89IHH	!HMMY00M    c                     U R                   U:X  a  U $ U R                  U R                      U   n[        XR                  U-   U R                  5      $ N)r   r   r   r   r   )r   r   offsets      r    convertEpoch.convertT   sD    ;;%Kdkk*51UMMF2DHH==r#   c                     U R                   $ r%   )r   r   s    r    r   Epoch.frame\   s    {{r#   c                 ~    U nXR                   :w  a  U R                  U5      nUR                  UR                  S-  -   $ )Nr   r   r'   r   r   )r   r   ts      r    
julianDateEpoch.julianDate_   s7    KKU#AuuqzzG+++r#   c                     U nXR                   :w  a  U R                  U5      nUR                  U-
  nUR                  US-  -   $ )Nr   r-   )r   r   r   r.   deltas        r    secondsPastEpoch.secondsPastf   s?    KKU#A
zzEEM))r#   c                    U nU R                   UR                   :w  a  U R                  UR                   5      nUR                  UR                  :w  a  U" UR                  UR                  5      $ U" UR                  UR                  5      $ )z4Compare Epochs *self* and *rhs* using operator *op*.r-   )r   oprhsr.   s       r    _cmp
Epoch._cmpn   sc    ;;#**$SZZ(A55CGGaeeSWW%%!**cll++r#   c                     U nU R                   UR                  5       :w  a  U R                  UR                   5      nUR                  UR	                  5       -   n[        UR                   X2R                  5      $ )z
Add a duration to an Epoch.

= INPUT VARIABLES
- rhs     The Epoch to subtract.

= RETURN VALUE
- Returns the difference of ourselves and the input Epoch.
)r   r   r'   r   secondsr   r   )r   r7   r.   r   s       r    __add__Epoch.__add__~   sV     ;;#))+%SZZ(Ajj3;;=(QXXsEE**r#   c                 h   SSK Js  Jn  [        XR                  5      (       a  X* -   $ U nU R
                  UR
                  :w  a  U R                  UR
                  5      nUR                  UR                  -
  nUR                  UR                  -
  nUR	                  UR
                  US-  U-   5      $ )a3  
Subtract two Epoch's or a Duration from an Epoch.

Valid:
Duration = Epoch - Epoch
Epoch = Epoch - Duration

= INPUT VARIABLES
- rhs     The Epoch to subtract.

= RETURN VALUE
- Returns either the duration between to Epoch's or the a new
  Epoch that is the result of subtracting a duration from an epoch.
r   Nr   )	matplotlib.testing.jpl_unitstesting	jpl_unitsr   Durationr   r'   r   r   )r   r7   Ur.   daysr   s         r    __sub__Epoch.__sub__   s      	10 c::&&$;;;#**$SZZ(Auuswwjj3<<'zz#**d5j3&677r#   c                 X    U R                  U R                  5      S SU R                   3$ )Print the Epoch.z22.15e )r/   r   r*   s    r    __str__Epoch.__str__   s'    //$++.v6a}EEr#   c                     [        U 5      $ )rH   )strr*   s    r    __repr__Epoch.__repr__   s    4yr#   c                 Z    / nSn XU-  -   nXQ:  a   U$ UR                  U5        US-  nM'  )at  
Generate a range of Epoch objects.

Similar to the Python range() method.  Returns the range [
start, stop) at the requested step.  Each element will be a
Epoch object.

= INPUT VARIABLES
- start     The starting value of the range.
- stop      The stop value of the range.
- step      Step to use.

= RETURN VALUE
- Returns a list containing the requested Epoch values.
r      )append)startstopstepelemsids         r    rangeEpoch.range   sG    " D Ay
  LLOFA r#   )r   r   r   )NNNN)!__name__
__module____qualname____firstlineno__r   r!   r'   r   r/   r3   r8   	functoolspartialmethodoperatoreq__eq__ne__ne__lt__lt__le__le__gt__gt__ge__ge__r<   rE   rJ   rN   staticmethodrY   __static_attributes__ r#   r    r   r      s    
 8 (	
G:1x>,*, $$T8;;7F$$T8;;7F$$T8;;7F$$T8;;7F$$T8;;7F$$T8;;7F+$8>F  r#   r   )__doc__r_   ra   r   r   r   
matplotlibr   matplotlib.datesr   r   rp   r#   r    <module>rt      s&          %G Gr#   