_3Lc@sEdZddlZddlZddlmZdddYZdS(s Epoch module.iN(tdate2numtEpochcBseZiid d6d6idd6d6ZdddddZdZdZdZdZd Z d Z d Z d Z d Z dZeeZRS(go P@tUTCtETgo PcCs"|dkr|dk s|dk r0|dks|dk rT|dk s|dk s|dkr|dkr|dks|dks|dk r|dk s|dk r|dk s|dk s|dk rt|tj rdt|t|t|t|f}t|n||jkrYd|t|jjf}t|n||_|dk r}t |}n|dk rt |d}t j ||_ ||j d|_n\t ||_t ||_ tt j |jd}|j |7_ |j|d8_dS(sCreate 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. sInvalid inputs. Must enter sec and jd together, daynum by itself, or dt (must be a python datetime). Sec = %s JD = %s dnum= %s dt = %ss9Input frame '%s' is not one of the supported frames of %sgQD:Ag@N(tNonet isinstancetDTtdatetimetstrt ValueErrortallowedtkeyst_frameRtfloattmathtfloort_jdt_secondstint(tselftframetsectjdtdaynumtdttmsgt deltaDays((sU/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/testing/jpl_units/Epoch.pyt__init__!s4$0$+   cCsA|j|kr|S|j|j|}t||j||jS(N(R R RRR(RRtoffset((sU/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/testing/jpl_units/Epoch.pytconvert^scCs|jS(N(R (R((sU/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/testing/jpl_units/Epoch.pyRgscCs9|}||jkr'|j|}n|j|jdS(Ng@(R RRR(RRtt((sU/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/testing/jpl_units/Epoch.pyt julianDatekscCsC|}||jkr'|j|}n|j|}|j|dS(NiQ(R RRR(RRRRtdelta((sU/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/testing/jpl_units/Epoch.pyt secondsPastss  cCse|}|j|jkr-|j|j}n|j|jkrRt|j|jSt|j|jS(sCompare two Epoch's. = INPUT VARIABLES - rhs The Epoch to compare against. = RETURN VALUE - Returns -1 if self < rhs, 0 if self == rhs, +1 if self > rhs. (R RRtcmpR(RtrhsR((sU/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/testing/jpl_units/Epoch.pyt__cmp__|s cCsY|}|j|jkr0|j|j}n|j|j}t|j||jS(sAdd a duration to an Epoch. = INPUT VARIABLES - rhs The Epoch to subtract. = RETURN VALUE - Returns the difference of ourselves and the input Epoch. (R RRRtsecondsRR(RR#RR((sU/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/testing/jpl_units/Epoch.pyt__add__s cCsddljj}t||jr-|| S|}|j|jkrZ|j|j}n|j|j}|j|j}|j|j|d|S(sgSubtract 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. iNiQ( tmatplotlib.testing.jpl_unitsttestingt jpl_unitsRtDurationR RRR(RR#tURtdaysR((sU/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/testing/jpl_units/Epoch.pyt__sub__s cCsd|j|j|jfS(sPrint the Epoch.s %22.15e %s(RR (R((sU/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/testing/jpl_units/Epoch.pyt__str__scCs t|S(sPrint the Epoch.(R(R((sU/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/testing/jpl_units/Epoch.pyt__repr__scCsRg}d}x?trM|||}||kr3Pn|j||d7}qW|S(sGenerate 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 contianing the requested Epoch values. ii(tTruetappend(tstarttstoptsteptelemstitd((sU/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/testing/jpl_units/Epoch.pytranges   N(t__name__t __module__R RRRRRR!R$R&R-R.R/R8t staticmethod(((sU/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/testing/jpl_units/Epoch.pyRs" =        ((t__doc__RRRtmatplotlib.datesRR(((sU/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/testing/jpl_units/Epoch.pyts