
    P/Ph                     \    d Z ddlZddlZddlZddlZddlmZ ddlm	Z	  G d d          Z
dS )zEpoch module.    N)_api)date2numc                   |   e Zd ZddiddidZddZd Zd	 Zd
 Zd Zd Z	 e
j        e	ej                  Z e
j        e	ej                  Z e
j        e	ej                  Z e
j        e	ej                  Z e
j        e	ej                  Z e
j        e	ej                  Zd Zd Zd Zd Zed             ZdS )EpochUTCg oP@ETg oP)r   r   Nc           
      j   ||8||4||0|.|||(|&||"||||5t          |t          j                  st          d|d|d|d|          t	          j        | j        |           || _        |t          |          }|?t          |          dz   }t          j        |          | _        || j        z
  dz  | _        dS t          |          | _        t          |          | _        t          j        | j        d	z            }| xj        |z  c_        | xj        |dz  z  c_        dS )
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          b/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/matplotlib/testing/jpl_units/Epoch.py__init__zEpoch.__init__   s^   , [R^RZ#/R^BJ+#S_.*R*E*E.* "cc222vvvrr34 4 4 	4<u5555>b\\Fv*Bz"~~DH$(]g5DMMM "#JJDMRyyDH 
4=5#899IHH	!HHMMY00MMMM    c                     | j         |k    r| S | j        | j                  |         }t          || j        |z   | j                  S N)r   r   r   r   r   )r   r
   offsets      r   convertzEpoch.convertT   sB    ;%Kdk*51UDMF2DH===r!   c                     | j         S r#   )r   r   s    r   r
   zEpoch.frame\   s
    {r!   c                 j    | }|| j         k    r|                     |          }|j        |j        dz  z   S )Nr   r   r%   r   r   )r   r
   ts      r   
julianDatezEpoch.julianDate_   s9    DKU##AuqzG+++r!   c                 t    | }|| j         k    r|                     |          }|j        |z
  }|j        |dz  z   S )Nr   r)   )r   r
   r   r*   deltas        r   secondsPastzEpoch.secondsPastf   sA    DKU##A
zEEM))r!   c                     | }| j         |j         k    r|                     |j                   }|j        |j        k    r ||j        |j                  S  ||j        |j                  S )z4Compare Epochs *self* and *rhs* using operator *op*.r)   )r   oprhsr*   s       r   _cmpz
Epoch._cmpn   sd    ;#*$$SZ((A5CG2aeSW%%%r!*cl+++r!   c                     | }| j         |                                k    r|                     |j                   }|j        |                                z   }t          |j         ||j                  S )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   r1   r*   r   s       r   __add__zEpoch.__add__~   s[     ;#))++%%SZ((Aj3;;==(QXsAE***r!   c                     ddl mc m} t          ||j                  r| | z   S | }| j        |j        k    r|                     |j                  }|j        |j        z
  }|j        |j        z
  }|                    |j        |dz  |z             S )a  
        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   r1   Ur*   daysr   s         r   __sub__zEpoch.__sub__   s      	100000000 c1:&& 	3$;;#*$$SZ((Auswj3<'zz#*d5j3&6777r!   c                 L    |                      | j                  dd| j         S )Print the Epoch.z22.15e )r+   r   r'   s    r   __str__zEpoch.__str__   s)    //$+..EEEEEEr!   c                      t          |           S )r?   )strr'   s    r   __repr__zEpoch.__repr__   s    4yyr!   c                 d    g }d}	 | ||z  z   }||k    rn|                     |           |dz  }*|S )a  
        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   T   )append)startstopstepelemsids         r   rangezEpoch.range   sQ    " 	D ADyyLLOOOFA	 r!   )NNNN)__name__
__module____qualname__r   r    r%   r
   r+   r.   r2   	functoolspartialmethodoperatoreq__eq__ne__ne__lt__lt__le__le__gt__gt__ge__ge__r5   r=   rA   rD   staticmethodrN    r!   r   r   r      sx       
 8 (	
 
G:1 :1 :1 :1x> > >  , , ,* * *, , , %Y$T8;77F$Y$T8;77F$Y$T8;77F$Y$T8;77F$Y$T8;77F$Y$T8;77F+ + +$8 8 8>F F F     \  r!   r   )__doc__rR   rT   r   r   r   
matplotlibr   matplotlib.datesr   r   rb   r!   r   <module>rf      s                      % % % % % %G G G G G G G G G Gr!   