rL iTdZddlZddlZddlZddlZddlmZddlm Z GddZ y)z Epoch module.N)_api)date2numceZdZddiddidZddZdZd Zd Zd Zd Z e je e jZe je e jZe je e j"Ze je e j&Ze je e j*Ze je e j.Zd ZdZdZdZedZy)EpochUTCgo P@ETgo P)rrNc v||8||4||0|.|||(|&||"||||1t|tjstd|d|d|d|t j |j |||_| t|}|@t|dz}tj||_ ||jz dz|_ yt||_ t||_ tj|jd z }|xj|z c_ |xj|dzzc_ y) 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 = )framegQD:A@Q) isinstanceDTdatetime ValueErrorr check_in_listallowed_framerfloatmathfloor_jd_seconds)selfr secjddaynumdt deltaDayss h/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/matplotlib/testing/jpl_units/Epoch.py__init__zEpoch.__init__s1,[R^RZ#/R^BJ+#S_.*R*E "2vr 34 4 4<b\F  v*Bzz"~DH$((]g5DM"#JDMRyDH 4==5#89I HH !H MMY0 0Mc|j|k(r|S|j|j|}t||j|z|jSN)rrrrr)rr offsets rconvertz Epoch.convertTsF ;;% Kdkk*51UDMMF2DHH==r!c|jSr#)rrs rr z Epoch.frame\s {{r!c~|}||jk7r|j|}|j|jdz zS)Nr rr%rr)rr ts r julianDatezEpoch.julianDate_s9  DKK  U#AuuqzzG+++r!c|}||jk7r|j|}|j|z }|j|dzzS)Nr r))rr rr*deltas r secondsPastzEpoch.secondsPastfsA  DKK  U#A zzEEM))r!c|}|j|jk7r|j|j}|j|jk7r||j|jS||j|jS)z4Compare Epochs *self* and *rhs* using operator *op*.r))roprhsr*s r_cmpz Epoch._cmpnsc  ;;#** $ SZZ(A 55CGG aeeSWW% %!**cll++r!c|}|j|jk7r|j|j}|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. )rr r%rsecondsrr)rr1r*rs r__add__z Epoch.__add__~sX  ;;#))+ % SZZ(Ajj3;;=(QXXsAEE**r!c`ddlmcm}t||jr|| zS|}|j |j k7r|j |j }|j|jz }|j|jz }|j |j |dz|zS)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. rNr ) matplotlib.testing.jpl_unitstesting jpl_unitsr Durationrr%rr)rr1Ur*daysrs r__sub__z Epoch.__sub__s 10 c1:: &3$;   ;;#** $ SZZ(Auuswwjj3<<'zz#**d5j3&677r!cX|j|jdd|jS)Print the Epoch.z22.15e )r+rr's r__str__z Epoch.__str__s'//$++.v6a }EEr!ct|S)r?)strr's r__repr__zEpoch.__repr__s 4yr!cZg}d} |||zz}||k\r |S|j||dz }')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)append)startstopstepelemsids rrangez Epoch.rangesK" D ADy   LLO FA r!)NNNN)__name__ __module__ __qualname__rr r%r r+r.r2 functools partialmethodoperatoreq__eq__ne__ne__lt__lt__le__le__gt__gt__ge__ge__r5r=rArD staticmethodrNr!rrr s 8 (  G:1x>,*,%Y $ $T8;; 7F $Y $ $T8;; 7F $Y $ $T8;; 7F $Y $ $T8;; 7F $Y $ $T8;; 7F $Y $ $T8;; 7F+$8>Fr!r) __doc__rRrTrrr matplotlibrmatplotlib.datesrrrbr!rrfs& %GGr!