
[c           @` s<  d  d l  m Z m Z m Z m 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 Z d d l m Z d d l m Z d d l m Z d d l m Z d	 d
 l m Z m Z m Z m Z d d d d d d d d d d d d d d d d d d d d d d  d! d" d# d$ d% d& g Z d g Z e
   Z e
   Z i d' d( 6d' d) 6d* d+ 6d* d, 6d- d. 6Z d/   Z  d0 e! f d1     YZ" e j# e"  d2 e$ f d3     Y Z% d4 e% f d5     YZ& d6 e% f d7     YZ' d8 e% f d9     YZ( d: e% f d;     YZ) d< e) f d=     YZ* d> e) f d?     YZ+ d@ e) f dA     YZ, dB e) f dC     YZ- dD e% f dE     YZ. dF e. f dG     YZ/ dH e. f dI     YZ0 dJ e j1 f dK     YZ2 dL e. f dM     YZ3 dN e3 f dO     YZ4 dP e4 f dQ     YZ5 dR e4 f dS     YZ6 dT e3 f dU     YZ7 dV e% f dW     YZ8 dX e8 f dY     YZ9 dZ e8 f d[     YZ: d\ e3 f d]     YZ; d^ e; f d_     YZ< d` e; f da     YZ= db e" f dc     YZ> e j# e>  dd e% f de     Y Z? df e? f dg     YZ@ dh e? f di     YZA d	 dj lB mC ZC mD ZD mE ZE mF ZF d S(k   i    (   t   absolute_importt   divisiont   print_functiont   unicode_literalsN(   t   OrderedDicti   (   t   units(   t   _erfa(   t   six(   t   zipi   (   t   day_fract   quantity_day_fract   two_sumt   two_productu
   TimeFormatu   TimeJDu   TimeMJDu   TimeFromEpochu   TimeUnixu
   TimeCxcSecu   TimeGPSu   TimeDecimalYearu   TimePlotDateu
   TimeUniqueu   TimeDatetimeu
   TimeStringu   TimeISOu   TimeISOTu   TimeFITSu   TimeYearDayTimeu   TimeEpochDateu   TimeBesselianEpochu   TimeJulianEpochu   TimeDeltaFormatu   TimeDeltaSecu   TimeDeltaJDu   TimeEpochDateStringu   TimeBesselianEpochStringu   TimeJulianEpochStringu   TIME_FORMATSu   TIME_DELTA_FORMATSu   TimezoneInfou   ttu   TDTu   ETu   utcu   GMTu   UTu   taiu   IATc         C` s   g  } x |  D] } | d } x8 d d d d d d f D] \ } } | j  | |  } q6 Wd | k r | d t j | d  | d f } n  | j |  q Wt |  S(   u  
    Iterate through each of the sub-formats and try substituting simple
    regular expressions for the strptime codes for year, month, day-of-month,
    hour, minute, second.  If no % characters remain then turn the final string
    into a compiled regex.  This assumes time formats do not have a % in them.

    This is done both to speed up parsing of strings and to allow mixed formats
    where strptime does not quite work well enough.
    i   u   %Yu   (?P<year>\d\d\d\d)u   %mu   (?P<mon>\d{1,2})u   %du   (?P<mday>\d{1,2})u   %Hu   (?P<hour>\d{1,2})u   %Mu   (?P<min>\d{1,2})u   %Su   (?P<sec>\d{1,2})u   %i    u   $i   (   u   %Yu   (?P<year>\d\d\d\d)(   u   %mu   (?P<mon>\d{1,2})(   u   %du   (?P<mday>\d{1,2})(   u   %Hu   (?P<hour>\d{1,2})(   u   %Mu   (?P<min>\d{1,2})(   u   %Su   (?P<sec>\d{1,2})(   t   replacet   ret   compilet   appendt   tuple(   t   subfmtst   new_subfmtst   subfmt_tuplet	   subfmt_int   strptime_codet   regex(    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyt   _regexify_subfmts-   s     

t   TimeFormatMetac           B` s   e  Z d  Z e Z d   Z RS(   u   
    Metaclass that adds `TimeFormat` and `TimeDeltaFormat` to the
    `TIME_FORMATS` and `TIME_DELTA_FORMATS` registries, respectively.
    c         C` su   t  t |   j |  | | |  } d | k rO | j d k rO | |  j | j <n  d | k rq t | d  | _ n  | S(   Nu   nameu   astropy_timeu   subfmts(   t   superR   t   __new__t   namet	   _registryR   R   (   t   mclsR   t   basest   memberst   cls(    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR   S   s    !(   t   __name__t
   __module__t   __doc__t   TIME_FORMATSR   R   (    (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR   K   s   t
   TimeFormatc           B` sz   e  Z d  Z e d  Z d   Z e d    Z e j d    Z d   Z	 d   Z
 d   Z d
 d  Z e d	    Z RS(   uD  
    Base class for time representations.

    Parameters
    ----------
    val1 : numpy ndarray, list, str, or number
        Data to initialize table.
    val2 : numpy ndarray, list, str, or number; optional
        Data to initialize table.
    scale : str
        Time scale of input value(s)
    precision : int
        Precision for seconds as floating point
    in_subfmt : str
        Select subformat for inputting string times
    out_subfmt : str
        Select subformat for outputting string times
    from_jd : bool
        If true then val1, val2 are jd1, jd2
    c         C` sk   | |  _  | |  _ | |  _ | |  _ | r? | |  _ | |  _ n( |  j | |  \ } } |  j | |  d  S(   N(   t   scalet	   precisiont	   in_subfmtt
   out_subfmtt   jd1t   jd2t   _check_val_typet   set_jds(   t   selft   val1t   val2R'   R(   R)   R*   t   from_jd(    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyt   __init__y   s    					c         C` s   t  |  j  S(   N(   t   lenR+   (   R/   (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyt   __len__   s    c         C` s   |  j  |  j  |  _ |  j S(   u
   Time scale(   t   _check_scalet   _scale(   R/   (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR'      s    c         C` s   | |  _  d  S(   N(   R7   (   R/   t   val(    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR'      s    c         C` s  | j  t j k o] t j t j |   o] | d k p] | j  t j k o] t j t j |   s{ t d j |  j    n  t	 | d d  d k	 rkt
 j | d t } | d k	 r t
 j | d t } n  y t | |  \ } } Wn# t
 j k
 r
t
 j d   n Xd t	 |  d d  } | d k rt | |  \ } } | | | 7} t | |  \ } } qn' t	 | d d  d k	 rt d   n  | d k rt j |  } n  d   } | |  | |  f S(	   u?   Input value validation, typically overridden by derived classesu1   Input values for {0} class must be finite doublesu   unitt   copyuJ   only quantities with time units can be used to instantiate Time instances.g      ?u$   Cannot mix float and Quantity inputsc         S` s#   t  |  t j  r t j |   S|  S(   u   
            Remove ndarray subclasses since for jd1/jd2 we want a pure ndarray
            or a Python or numpy scalar.
            (   t
   isinstancet   npt   ndarrayt   asarray(   R8   (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyt   asarray_or_scalar   s    N(   t   dtypeR;   t   doublet   allt   isfinitet   Nonet	   TypeErrort   formatR   t   getattrt   ut   Quantityt   FalseR
   t
   UnitsErrort   UnitConversionErrorR   R   t
   zeros_like(   R/   R0   R1   t   factort   carryR>   (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR-      s2    **		c         C` sm   t  |  j d  r- | d k r- |  j j } n  | d k rB d } n  | t k ri t d j | t    n  | S(   u  
        Return a validated scale value.

        If there is a class attribute 'scale' then that defines the default /
        required time scale for this format.  In this case if a scale value was
        provided that needs to match the class default, otherwise return
        the class default.

        Otherwise just make sure that scale is in the allowed list of
        scales.  Provide a different error message if `None` (no value) was
        supplied.
        u   epoch_scaleu   utcu+   Scale value '{0}' not in allowed values {1}N(   t   hasattrt	   __class__RC   t   epoch_scalet   TIME_SCALESt   ScaleValueErrorRE   (   R/   R'   (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR6      s    		c         C` s
   t   d S(   ul   
        Set internal jd1 and jd2 from val1 and val2.  Must be provided
        by derived classes.
        N(   t   NotImplementedError(   R/   R0   R1   (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR.      s    c         C` s   |  j  S(   uV  
        Return time representation from internal jd1 and jd2.  This is
        the base method that ignores ``parent`` and requires that
        subclasses implement the ``value`` property.  Subclasses that
        require ``parent`` or have other optional args for ``to_value``
        should compute and return the value directly.
        (   t   value(   R/   t   parent(    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyt   to_value   s    c         C` s
   t   d  S(   N(   RT   (   R/   (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyRU      s    N(   R"   R#   R$   RI   R3   R5   t   propertyR'   t   setterR-   R6   R.   RC   RW   RU   (    (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR&   b   s   		1		
t   TimeJDc           B` s,   e  Z d  Z d Z d   Z e d    Z RS(   u   
    Julian Date time format.
    This represents the number of days since the beginning of
    the Julian Period.
    For example, 2451544.5 in JD is midnight on January 1, 2000.
    u   jdc         C` s/   |  j  |  j  t | |  \ |  _ |  _ d  S(   N(   R6   R7   R	   R+   R,   (   R/   R0   R1   (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR.      s    c         C` s   |  j  |  j S(   N(   R+   R,   (   R/   (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyRU     s    (   R"   R#   R$   R   R.   RX   RU   (    (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyRZ      s   	t   TimeMJDc           B` s,   e  Z d  Z d Z d   Z e d    Z RS(   u   
    Modified Julian Date time format.
    This represents the number of days since midnight on November 17, 1858.
    For example, 51544.0 in MJD is midnight on January 1, 2000.
    u   mjdc         C` sQ   |  j  |  j  t | |  \ } } | t j 7} t | |  \ |  _ |  _ d  S(   N(   R6   R7   R	   t   erfat   DJM0R+   R,   (   R/   R0   R1   R+   R,   (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR.     s    c         C` s   |  j  t j |  j S(   N(   R+   R\   R]   R,   (   R/   (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyRU     s    (   R"   R#   R$   R   R.   RX   RU   (    (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR[     s   	
t   TimeDecimalYearc           B` s,   e  Z d  Z d Z d   Z e d    Z RS(   u   
    Time as a decimal year, with integer values corresponding to midnight
    of the first day of each year.  For example 2000.5 corresponds to the
    ISO time '2000-07-02 00:00:00'.
    u   decimalyearc         C` s  |  j  |  j  t | |  \ } } t j |  j t j  } t | |  \ } } | | | 7} | | j t j  } t j |  j t j  } t j |  }	 t j |  }
 t j	 |  } t j	 |  } t j	 |  } |  j
 j   j d  } t j | | |	 |
 | | |  \ } } t j | | d |	 |
 | | |  \ } } t | | d |  j
 d d } t | | d |  j
 d d } | | | | } t | j | j  \ |  _ |  _ d  S(   Nu   asciii   R'   RE   u   jd(   R6   R7   R   R;   t   trunct   astypet   intR@   t	   ones_likeRL   R'   t   uppert   encodeR\   t   dtf2dt   TimeR	   R+   R,   (   R/   R0   R1   t   sum12t   err12t   iy_startt   extrat   y_fracR8   t   imont   idayt   ihrt   imint   isecR'   t	   jd1_startt	   jd2_startt   jd1_endt   jd2_endt   t_startt   t_endt   t_frac(    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR.   &  s*    c         C` s6  |  j  j   j d  } t j | d |  j |  j  \ } } } } t j |  } t j |  } t j	 |  } t j	 |  }	 t j	 |  j  }
 |  j  j   j d  } t j
 | | | | | |	 |
  \ } } t j
 | | d | | | |	 |
  \ } } |  j | |  j | } | | | | } | | | } | S(   Nu   asciii    i   (   R'   Rc   Rd   R\   t   d2dtfR+   R,   R;   Rb   RL   Re   (   R/   R'   Ri   t   imst   idst   ihmsfsRl   Rm   Rn   Ro   Rp   Rq   Rr   Rs   Rt   t   dtt   dt_endt   decimalyear(    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyRU   E  s"    (   R"   R#   R$   R   R.   RX   RU   (    (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR^     s   	t   TimeFromEpochc           B` s;   e  Z d  Z e d  Z d   Z d d  Z e e  Z	 RS(   u   
    Base class for times that represent the interval from a particular
    epoch as a floating point multiple of a unit time interval (e.g. seconds
    or days).
    c   	      C` se   | |  _  t |  j |  j d |  j d |  j } | |  _ t t |   j	 | | | | | | |  d  S(   NR'   RE   (
   R'   Rf   t	   epoch_valt
   epoch_val2RQ   t   epoch_formatt   epochR   R   R3   (	   R/   R0   R1   R'   R(   R)   R*   R2   R   (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR3   f  s    		c   	      C` s   t  | | d d |  j \ } } |  j j | } |  j j | } y. t t | | d |  j d d |  j  } Wn: t	 k
 r } t
 d j |  j |  j |  j |    n Xt  | j j | j j  \ |  _ |  _ d S(   u   
        Initialize the internal jd1 and jd2 attributes given val1 and val2.
        For an TimeFromEpoch subclass like TimeUnix these will be floats giving
        the effective seconds since an epoch time (e.g. 1970-01-01 00:00:00).
        t   divisorg      ?R'   RE   u   jduS   Cannot convert from '{0}' epoch scale '{1}'to specified scale '{2}', got error:
{3}N(   R	   t   unitR   R+   R,   RF   Rf   RQ   R'   t	   ExceptionRS   RE   R   t   _time(	   R/   R0   R1   t   dayt   fracR+   R,   t   tmt   err(    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR.   r  s    "	c         C` s   |  j  |  j k r[ | d  k r- t d   n  t | |  j  } | j j | j j } } n |  j |  j } } | |  j j | |  j j |  j	 } | S(   Nu/   cannot compute value without parent Time object(
   R'   RQ   RC   t
   ValueErrorRF   R   R+   R,   R   R   (   R/   RV   R   R+   R,   t   time_from_epoch(    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyRW     s    N(
   R"   R#   R$   RI   R3   R.   RC   RW   RX   RU   (    (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR   _  s
   	't   TimeUnixc           B` s9   e  Z d  Z d Z d e j Z d Z d Z	 d Z
 d Z RS(   u  
    Unix time: seconds from 1970-01-01 00:00:00 UTC.
    For example, 946684800.0 in Unix time is midnight on January 1, 2000.

    NOTE: this quantity is not exactly unix time and differs from the strict
    POSIX definition by up to 1 second on days with a leap second.  POSIX
    unix time actually jumps backward by 1 second at midnight on leap second
    days while this class value is monotonically increasing at 86400 seconds
    per UTC day.
    u   unixg      ?u   1970-01-01 00:00:00u   utcu   isoN(   R"   R#   R$   R   R\   t   DAYSECR   R   RC   R   RQ   R   (    (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR     s   
t
   TimeCxcSecc           B` s9   e  Z d  Z d Z d e j Z d Z d Z	 d Z
 d Z RS(   u   
    Chandra X-ray Center seconds from 1998-01-01 00:00:00 TT.
    For example, 63072064.184 is midnight on January 1, 2000.
    u   cxcsecg      ?u   1998-01-01 00:00:00u   ttu   isoN(   R"   R#   R$   R   R\   R   R   R   RC   R   RQ   R   (    (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR     s   t   TimeGPSc           B` s9   e  Z d  Z d Z d e j Z d Z d Z	 d Z
 d Z RS(   u  GPS time: seconds from 1980-01-06 00:00:00 UTC
    For example, 630720013.0 is midnight on January 1, 2000.

    Notes
    =====
    This implementation is strictly a representation of the number of seconds
    (including leap seconds) since midnight UTC on 1980-01-06.  GPS can also be
    considered as a time scale which is ahead of TAI by a fixed offset
    (to within about 100 nanoseconds).

    For details, see http://tycho.usno.navy.mil/gpstt.html
    u   gpsg      ?u   1980-01-06 00:00:19u   taiu   isoN(   R"   R#   R$   R   R\   R   R   R   RC   R   RQ   R   (    (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR     s   t   TimePlotDatec           B` s2   e  Z d  Z d Z d Z d Z d Z d Z d Z	 RS(   u'  
    Matplotlib `~matplotlib.pyplot.plot_date` input:
    1 + number of days from 0001-01-01 00:00:00 UTC

    This can be used directly in the matplotlib `~matplotlib.pyplot.plot_date`
    function::

      >>> import matplotlib.pyplot as plt
      >>> jyear = np.linspace(2000, 2001, 20)
      >>> t = Time(jyear, format='jyear', scale='utc')
      >>> plt.plot_date(t.plot_date, jyear)
      >>> plt.gcf().autofmt_xdate()  # orient date labels at a slant
      >>> plt.draw()

    For example, 730120.0003703703 is midnight on January 1, 2000.
    u	   plot_dateg      ?g   PD:Au   utcu   jdN(
   R"   R#   R$   R   R   R   RC   R   RQ   R   (    (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR     s   t
   TimeUniquec           B` s   e  Z d  Z RS(   u   
    Base class for time formats that can uniquely create a time object
    without requiring an explicit format specifier.  This class does
    nothing but provide inheritance to identify a class as unique.
    (   R"   R#   R$   (    (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR     s   t   TimeAstropyTimec           B` s    e  Z d  Z d Z e d  Z RS(   u   
    Instantiate date from an Astropy Time object (or list thereof).

    This is purely for instantiating from a Time object.  The output
    format is the same as the first time instance.
    u   astropy_timec      	   ` sQ  | j  d   t   t  o8 t   f d   | j  D  sV t d j |  j    n  | d k rn   j } n  | j	 r g  | D] } t
 | |  j ^ q~ }	 t j g  |	 D] } t j | j  ^ q  }
 t j g  |	 D] } t j | j  ^ q  } n% t
   |  j } | j | j }
 }   j j } | |
 | | | | | d t } | S(   u   
        Use __new__ instead of __init__ to output a class instance that
        is the same as the class of the first Time object in the list.
        i    c         3` s'   |  ] } t  |  t     k Vq d  S(   N(   t   type(   t   .0R8   (   t   val1_0(    s3   lib/python2.7/site-packages/astropy/time/formats.pys	   <genexpr>  s   u>   Input values for {0} class must all be same astropy Time type.R2   N(   t   flatR:   Rf   RA   RD   RE   R   RC   R'   t   shapeRF   R   R;   t   concatenatet
   atleast_1dR+   R,   RP   t   True(   R!   R0   R1   R'   R(   R)   R*   R2   R8   t   valsR+   R,   t   OutTimeFormatR/   (    (   R   s3   lib/python2.7/site-packages/astropy/time/formats.pyR     s"    		%.1	(   R"   R#   R$   R   RI   R   (    (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR     s   t   TimeDatetimec           B` sA   e  Z d  Z d Z d   Z d   Z d d d  Z e e  Z	 RS(   um  
    Represent date as Python standard library `~datetime.datetime` object

    Example::

      >>> from astropy.time import Time
      >>> from datetime import datetime
      >>> t = Time(datetime(2000, 1, 2, 12, 0, 0), scale='utc')
      >>> t.iso
      '2000-01-02 12:00:00.000'
      >>> t.tt.datetime
      datetime.datetime(2000, 1, 2, 12, 1, 4, 184000)
    u   datetimec         C` s>   t  d   | j D  s4 t d j |  j    n  | d  f S(   Nc         s` s!   |  ] } t  | t j  Vq d  S(   N(   R:   t   datetime(   R   R8   (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pys	   <genexpr><  s    u3   Input values for {0} class must be datetime objects(   RA   R   RD   RE   R   RC   (   R/   R0   R1   (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR-   :  s    	c         C` sZ  t  j | d
 d
 d
 d
 d
 d
 g d d g d t  j g d t  j g t  j g } x | D] \ } } } } } }	 }
 | j   } | j d
 k	 r | | j   j	 d d
  } n  | j
 | d <| j | d <| j | d <| j | d <| j |	 d <| j | j d |
 d <qX Wt j |  j j   j d  | j d	  \ } } t | |  \ |  _ |  _ d
 S(   u5   Convert datetime object contained in val1 to jd1, jd2t   flagsu   refs_okt	   op_dtypesi   t   tzinfo.g    .Au   asciii   N(   R;   t   nditerRC   t   objectt   intcR@   t   itemR   t	   utcoffsetR   t   yeart   monthR   t   hourt   minutet   secondt   microsecondR\   Re   R'   Rc   Rd   t   operandsR	   R+   R,   (   R/   R0   R1   t   iteratorR8   t   iyt   imt   idRn   Ro   t   dsecR|   R+   R,   (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR.   A  s     !	'"c         C` s  | d k	 r9 |  j d k r9 t d j |  j    q9 n  |  j j   j d  } t j | d |  j	 |  j
  \ } } } } | d } | d }	 | d }
 | d } t j | | | | |	 |
 | d g d
 d g d d | j g t j g } x | D] \ } } } } } } } } | d k rKt d j | | | | | | | f    n  | d k	 rt j | | | | | | | d t   j |  | d <q t j | | | | | | |  | d <q W| j d S(   u  
        Convert to (potentially timezone-aware) `~datetime.datetime` object.

        If ``timezone`` is not ``None``, return a timezone-aware datetime
        object.

        Parameters
        ----------
        timezone : {`~datetime.tzinfo`, None} (optional)
            If not `None`, return timezone-aware datetime.

        Returns
        -------
        `~datetime.datetime`
            If ``timezone`` is not ``None``, output will be timezone-aware.
        u   utcu5   scale is {}, must be 'utc' when timezone is supplied.u   asciii   .i    i   i   i   R   u   refs_okR   i   i<   uJ   Time {} is within a leap second but datetime does not support leap secondsR   iN(   .i    (   .i   (   .i   (   .i   (   RC   R7   RS   RE   R'   Rc   Rd   R\   Rx   R+   R,   R;   R   R?   R   R   R   t   TimezoneInfot
   astimezoneR   (   R/   t   timezoneRV   R'   t   iysRy   Rz   R{   t   ihrst   iminst   isecst   ifracsR   R   R   R   Rn   Ro   Rp   t   ifracsect   out(    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyRW   X  s.    	



$	%	$)N(
   R"   R#   R$   R   R-   R.   RC   RW   RX   RU   (    (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR   *  s   		/R   c           B` sg   e  Z d  Z e j d e j d e j  d e j d e j d d   Z d   Z d   Z	 d   Z
 RS(	   u)  
    Subclass of the `~datetime.tzinfo` object, used in the
    to_datetime method to specify timezones.

    It may be safer in most cases to use a timezone database package like
    pytz rather than defining your own timezones - this class is mainly
    a workaround for users without pytz.
    t
   utc_offsett   dsti    c         C` sv   | d k r- | d k r- | d k r- d } n  t j | j t j   |  _ | |  _ t j | j t j   |  _ d S(   u  
        Parameters
        ----------
        utc_offset : `~astropy.units.Quantity` (optional)
            Offset from UTC in days. Defaults to zero.
        dst : `~astropy.units.Quantity` (optional)
            Daylight Savings Time offset in days. Defaults to zero
            (no daylight savings).
        tzname : string, `None` (optional)
            Name of timezone

        Examples
        --------
        >>> from datetime import datetime
        >>> from astropy.time import TimezoneInfo  # Specifies a timezone
        >>> import astropy.units as u
        >>> utc = TimezoneInfo()    # Defaults to UTC
        >>> utc_plus_one_hour = TimezoneInfo(utc_offset=1*u.hour)  # UTC+1
        >>> dt_aware = datetime(2000, 1, 1, 0, 0, 0, tzinfo=utc_plus_one_hour)
        >>> print(dt_aware)
        2000-01-01 00:00:00+01:00
        >>> print(dt_aware.astimezone(utc))
        1999-12-31 23:00:00+00:00
        i    u   UTCN(	   RC   R   t	   timedeltaRW   RG   R   t
   _utcoffsett   _tznamet   _dst(   R/   R   R   t   tzname(    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR3     s
    $		c         C` s   |  j  S(   N(   R   (   R/   R|   (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR     s    c         C` s   t  |  j  S(   N(   t   strR   (   R/   R|   (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR     s    c         C` s   |  j  S(   N(   R   (   R/   R|   (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR     s    N(   R"   R#   R$   RG   t   quantity_inputR   RC   R3   R   R   R   (    (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR     s   #		t
   TimeStringc           B` sS   e  Z d  Z d   Z d   Z d   Z d   Z d   Z e d    Z	 d   Z
 RS(   u   
    Base class for string-like time representations.

    This class assumes that anything following the last decimal point to the
    right is a fraction of a second.

    This is a reference implementation can be made much faster with effort.
    c         C` s7   | j  j d k r- t d j |  j    n  | d  f S(   Nu   Su   Uu*   Input values for {0} class must be strings(   u   Su   U(   R?   t   kindRD   RE   R   RC   (   R/   R0   R1   (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR-     s    	c         C` sx  d } d } y | j d	  } Wn t k
 r8 d
 } n" X| |  | | } } t |  } x| D] \ } } } t | t j  r y t j | |  }	 Wn t	 k
 r qa qBXg  | D] }
 t
 |	 d |
  ^ q } nj t j | |  }	 |	 d k r qa n  |	 j   }	 g  t | |  D]$ \ }
 } t |	 j |
 |   ^ q} | d | | d <| SWt	 d j | |  j    d S(   u@   Read time from a single string, using a set of possible formats.u   yearu   monu   mdayu   houru   minu   seci   i    u   .g        u   tm_iu"   Time {0} does not match {1} formatN(   u   yearu   monu   mdayu   houru   minu   sec(   Ni   i   i    i    i    (   RC   t   rindexR   t   floatR:   R   t   string_typest   timet   strptimeR   RF   R   t   matcht	   groupdictR   Ra   t   getRE   R   (   R/   t   timestrR   t
   componentst   defaultst   idott   fracsect   _t   strptime_fmt_or_regexR   t	   componentR   t   default(    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyt   parse_string  s4    
&7	c      	   C` s  |  j  |  j  } t j | d d d d d d g d | j g d t j g t j g } xe | D]] \ } } } } }	 }
 } |  j | j	   |  \ | d <| d <| d <|	 d <|
 d <| d <qa Wt
 j |  j j   j d  | j d  \ } } t | |  \ |  _ |  _ d S(   u9   Parse the time strings contained in val1 and set jd1, jd2R   i   .u   asciii   N(   t   _select_subfmtsR)   R;   R   RC   R?   R   R@   R   R   R\   Re   R'   Rc   Rd   R   R	   R+   R,   (   R/   R0   R1   R   R   R8   R   R   R   Rn   Ro   R   R+   R,   (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR.     s    !'"Fc         c` s  |  j  j   j d  f } t j | |  j |  j |  j  \ } } } } |  j |  j	  d \ } } } d | k r| t
 } n t } d }	 | d }
 | d } | d } | d } x t j | | | |
 | | | g  D] \ } } } } } } } | rt j | | |  j   j }	 n  i t |  d 6t |  d	 6t |  d
 6t |  d 6t |  d 6t |  d 6t |  d 6|	 d 6Vq Wd S(   u   
        Generator that yields a dict of values corresponding to the
        calendar date and time for the internal JD values.
        u   asciii    u   {yday:.i   i   i   u   yearu   monu   dayu   houru   minu   secu   fracsecu   ydayN(   .i    (   .i   (   .i   (   .i   (   R'   Rc   Rd   R\   Rx   R(   R+   R,   R   R*   R   RI   RC   R;   R   R   t	   timetuplet   tm_ydayRa   (   R/   R'   R   Ry   Rz   R{   R   t   str_fmtt   has_ydayt   ydayR   R   R   R   R   R   R   Rn   Ro   Rp   R   (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyt
   str_kwargs  s&    	



	7!*'c         K` s   | j  |   S(   u   Write time to a string using a given format.

        By default, just interprets str_fmt as a format string,
        but subclasses can add to this.
        (   RE   (   R/   R   t   kwargs(    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyt   format_string&  s    c         C` s   |  j  |  j  } | d \ } } } |  j d k ra | j d  ra | d t |  j  d 7} n  g  } x3 |  j   D]% } | j t |  j | |    qt Wt j	 |  j
 |  j j  S(   Ni    u	   {sec:02d}u   .{fracsec:0u   d}(   R   R*   R(   t   endswithR   R   R   R   R;   t   arrayt   reshapeR+   R   (   R/   R   R   R   t   outsR   (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyRU   .  s    #c         C` sf   t  j } g  |  j D] } | | d |  r | ^ q } t |  d k rb t d j |    n  | S(   uc   
        Return a list of subformats where name matches ``pattern`` using
        fnmatch.
        i    u   No subformats match {0}(   t   fnmatcht   fnmatchcaseR   R4   R   RE   (   R/   t   patternR   t   xR   (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR   A  s
    	/(   R"   R#   R$   R-   R   R.   R   R   RX   RU   R   (    (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR     s   		)			t   TimeISOc           B` s,   e  Z d  Z d Z d d d f Z d   Z RS(   u7  
    ISO 8601 compliant date-time format "YYYY-MM-DD HH:MM:SS.sss...".
    For example, 2000-01-01 00:00:00.000 is midnight on January 1, 2000.

    The allowed subformats are:

    - 'date_hms': date + hours, mins, secs (and optional fractional secs)
    - 'date_hm': date + hours, mins
    - 'date': date
    u   isou   date_hmsu   %Y-%m-%d %H:%M:%Su;   {year:d}-{mon:02d}-{day:02d} {hour:02d}:{min:02d}:{sec:02d}u   date_hmu   %Y-%m-%d %H:%Mu1   {year:d}-{mon:02d}-{day:02d} {hour:02d}:{min:02d}u   dateu   %Y-%m-%du   {year:d}-{mon:02d}-{day:02d}c         C` sS   | j  d  r: |  j d k r- t d   n  | d  } n  t t |   j | |  S(   Nu   Zu   utcu3   Time input terminating in 'Z' must have scale='UTC'i(   R   R'   R   R   R   R   (   R/   R   R   (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR   f  s
    (   u   date_hmsu   %Y-%m-%d %H:%M:%Su;   {year:d}-{mon:02d}-{day:02d} {hour:02d}:{min:02d}:{sec:02d}(   u   date_hmu   %Y-%m-%d %H:%Mu1   {year:d}-{mon:02d}-{day:02d} {hour:02d}:{min:02d}(   u   dateu   %Y-%m-%du   {year:d}-{mon:02d}-{day:02d}(   R"   R#   R$   R   R   R   (    (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR   N  s   
      	t   TimeISOTc           B` s#   e  Z d  Z d Z d d d f Z RS(   u  
    ISO 8601 compliant date-time format "YYYY-MM-DDTHH:MM:SS.sss...".
    This is the same as TimeISO except for a "T" instead of space between
    the date and time.
    For example, 2000-01-01T00:00:00.000 is midnight on January 1, 2000.

    The allowed subformats are:

    - 'date_hms': date + hours, mins, secs (and optional fractional secs)
    - 'date_hm': date + hours, mins
    - 'date': date
    u   isotu   date_hmsu   %Y-%m-%dT%H:%M:%Su;   {year:d}-{mon:02d}-{day:02d}T{hour:02d}:{min:02d}:{sec:02d}u   date_hmu   %Y-%m-%dT%H:%Mu1   {year:d}-{mon:02d}-{day:02d}T{hour:02d}:{min:02d}u   dateu   %Y-%m-%du   {year:d}-{mon:02d}-{day:02d}(   u   date_hmsu   %Y-%m-%dT%H:%M:%Su;   {year:d}-{mon:02d}-{day:02d}T{hour:02d}:{min:02d}:{sec:02d}(   u   date_hmu   %Y-%m-%dT%H:%Mu1   {year:d}-{mon:02d}-{day:02d}T{hour:02d}:{min:02d}(   u   dateu   %Y-%m-%du   {year:d}-{mon:02d}-{day:02d}(   R"   R#   R$   R   R   (    (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR   p  s         t   TimeYearDayTimec           B` s#   e  Z d  Z d Z d d d f Z RS(   uq  
    Year, day-of-year and time as "YYYY:DOY:HH:MM:SS.sss...".
    The day-of-year (DOY) goes from 001 to 365 (366 in leap years).
    For example, 2000:001:00:00:00.000 is midnight on January 1, 2000.

    The allowed subformats are:

    - 'date_hms': date + hours, mins, secs (and optional fractional secs)
    - 'date_hm': date + hours, mins
    - 'date': date
    u   ydayu   date_hmsu   %Y:%j:%H:%M:%Su2   {year:d}:{yday:03d}:{hour:02d}:{min:02d}:{sec:02d}u   date_hmu   %Y:%j:%H:%Mu(   {year:d}:{yday:03d}:{hour:02d}:{min:02d}u   dateu   %Y:%ju   {year:d}:{yday:03d}(   u   date_hmsu   %Y:%j:%H:%M:%Su2   {year:d}:{yday:03d}:{hour:02d}:{min:02d}:{sec:02d}(   u   date_hmu   %Y:%j:%H:%Mu(   {year:d}:{yday:03d}:{hour:02d}:{min:02d}(   u   dateu   %Y:%ju   {year:d}:{yday:03d}(   R"   R#   R$   R   R   (    (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR     s         t   TimeFITSc           B` si   e  Z d  Z d Z d d d d f Z e d   e D  Z d Z d Z d   Z	 d   Z
 e d    Z RS(   u&  
    FITS format: "[±Y]YYYY-MM-DD[THH:MM:SS[.sss]][(SCALE[(REALIZATION)])]".

    ISOT with two extensions:
    - Can give signed five-digit year (mostly for negative years);
    - A possible time scale (and realization) appended in parentheses.

    Note: FITS supports some deprecated names for timescales; these are
    translated to the formal names upon initialization.  Furthermore, any
    specific realization information is stored only as long as the time scale
    is not changed.

    The allowed subformats are:

    - 'date_hms': date + hours, mins, secs (and optional fractional secs)
    - 'date': date
    - 'longdate_hms': as 'date_hms', but with signed 5-digit year
    - 'longdate': as 'date', but with signed 5-digit year

    See Rots et al., 2015, A&A 574:A36 (arXiv:1409.7583).
    u   fitsu   date_hmsu_   (?P<year>\d{4})-(?P<mon>\d\d)-(?P<mday>\d\d)T(?P<hour>\d\d):(?P<min>\d\d):(?P<sec>\d\d(\.\d*)?)u=   {year:04d}-{mon:02d}-{day:02d}T{hour:02d}:{min:02d}:{sec:02d}u   dateu,   (?P<year>\d{4})-(?P<mon>\d\d)-(?P<mday>\d\d)u   {year:04d}-{mon:02d}-{day:02d}u   longdate_hmsuc   (?P<year>[+-]\d{5})-(?P<mon>\d\d)-(?P<mday>\d\d)T(?P<hour>\d\d):(?P<min>\d\d):(?P<sec>\d\d(\.\d*)?)u>   {year:+06d}-{mon:02d}-{day:02d}T{hour:02d}:{min:02d}:{sec:02d}u   longdateu0   (?P<year>[+-]\d{5})-(?P<mon>\d\d)-(?P<mday>\d\d)u   {year:+06d}-{mon:02d}-{day:02d}c         c` s.   |  ]$ } | d  | d d | d f Vq d S(   i    i   u0   (\((?P<scale>\w+)(\((?P<realization>\w+)\))?\))?i   N(    (   R   t   subfmt(    (    s3   lib/python2.7/site-packages/astropy/time/formats.pys	   <genexpr>  s   c   	   	   C` s  xN | D]+ \ } } } t  j | |  } | r Pq q Wt d j | |  j    | j   } | d d k	 rl| d j   } t j	 | | j
    } | t k r t d j | t t     n  | d r | d j   n d } |  j d k r!| |  _ | |  _ |  j d k r!| |  _ q!n  | |  j k sN| |  j k sN| |  j k rlt d j |  j    qln  t | d  t | d  t | d  t | j	 d	 d
   t | j	 d d
   t | j	 d d   g S(   u:   Read time and set scale according to trailing scale codes.u"   Time {0} does not match {1} formatu   scaleu,   Scale {0!r} is not in the allowed scales {1}u   realizationuA   Input strings for {0} class must all have consistent time scales.u   yearu   monu   mdayu   houri    u   minu   secg        N(   R   R   R   RE   R   R   RC   Rc   t   FITS_DEPRECATED_SCALESR   t   lowerRR   t   sortedt   _fits_scalet   _fits_realizationR7   R'   Ra   R   (	   R/   R   R   R   R   R   t
   fits_scaleR'   t   fits_realization(    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR     s4    		 			'*c         K` sc   t  t |   j | |  } |  j rF |  j rF d j | |  j |  j  Sd j | |  j j    Sd S(   u?   Format time-string: append the scale to the normal ISOT format.u   {0}({1}({2}))u   {0}({1})N(   R   R   R   R   R   RE   R7   Rc   (   R/   R   R   t   time_str(    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR     s
    
c         C` si   d |  j  k rY |  j |  j } | j   d k  sC | j   d k rY d |  j  |  _  qY n  t t |   j S(   u<   Convert times to strings, using signed 5 digit if necessary.u   longg   QD:Ag    TA(   R*   R+   R,   t   mint   maxR   R   RU   (   R/   t   jd(    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyRU      s
    $(   u   date_hmsu_   (?P<year>\d{4})-(?P<mon>\d\d)-(?P<mday>\d\d)T(?P<hour>\d\d):(?P<min>\d\d):(?P<sec>\d\d(\.\d*)?)u=   {year:04d}-{mon:02d}-{day:02d}T{hour:02d}:{min:02d}:{sec:02d}(   u   dateu,   (?P<year>\d{4})-(?P<mon>\d\d)-(?P<mday>\d\d)u   {year:04d}-{mon:02d}-{day:02d}(   u   longdate_hmsuc   (?P<year>[+-]\d{5})-(?P<mon>\d\d)-(?P<mday>\d\d)T(?P<hour>\d\d):(?P<min>\d\d):(?P<sec>\d\d(\.\d*)?)u>   {year:+06d}-{mon:02d}-{day:02d}T{hour:02d}:{min:02d}:{sec:02d}(   u   longdateu0   (?P<year>[+-]\d{5})-(?P<mon>\d\d)-(?P<mday>\d\d)u   {year:+06d}-{mon:02d}-{day:02d}N(   R"   R#   R$   R   R   R   RC   R   R   R   R   RX   RU   (    (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR     s,           		&		t   TimeEpochDatec           B` s&   e  Z d  Z d   Z e d    Z RS(   uP   
    Base class for support floating point Besselian and Julian epoch dates
    c         C` sW   |  j  |  j  t t |  j  } | | |  \ } } t | |  \ |  _ |  _ d  S(   N(   R6   R7   RF   R\   t   epoch_to_jdR	   R+   R,   (   R/   R0   R1   R   R+   R,   (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR.     s    c         C` s%   t  t |  j  } | |  j |  j  S(   N(   RF   R\   t   jd_to_epochR+   R,   (   R/   R   (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyRU     s    (   R"   R#   R$   R.   RX   RU   (    (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR     s   	t   TimeBesselianEpochc           B` s)   e  Z d  Z d Z d Z d Z d   Z RS(   u;   Besselian Epoch year as floating point value(s) like 1950.0u   byearu   epb2jdu   epbc         C` sF   t  | d  r- t  | d  r- t d   n  t t |   j | |  S(   u?   Input value validation, typically overridden by derived classesu   tou   unitu{   Cannot use Quantities for 'byear' format, as the interpretation would be ambiguous. Use float with Besselian year instead. (   RO   R   R   R   R-   (   R/   R0   R1   (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR-   #  s    (   R"   R#   R$   R   R   R   R-   (    (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR     s
   t   TimeJulianEpochc           B` s)   e  Z d  Z d Z e j Z d Z d Z RS(   u8   Julian Epoch year as floating point value(s) like 2000.0u   jyearu   epj2jdu   epj(	   R"   R#   R$   R   R\   t   DJYR   R   R   (    (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR  -  s
   	t   TimeEpochDateStringc           B` s&   e  Z d  Z d   Z e d    Z RS(   ux   
    Base class to support string Besselian and Julian epoch dates
    such as 'B1950.0' or 'J2000.0' respectively.
    c         C` s,  |  j  } t j | d  g d | j t j g } x | D] \ } } | j   } y@ | d | d } }	 t |	  }
 | j   | k r t	  n  Wn2 t
 t	 f k
 r t	 d j | |  j    q7 X|
 | d <q7 W|  j |  j  t t |  j  } | | j d  \ } } t | |  \ |  _ |  _ d  S(   NR   i    i   u"   Time {0} does not match {1} format.i(   t   epoch_prefixR;   R   RC   R?   R@   R   R   Rc   R   t
   IndexErrorRE   R   R6   R7   RF   R\   R   R   R	   R+   R,   (   R/   R0   R1   R  R   R8   t   yearsR   t
   epoch_typet   year_strR   R   R+   R,   (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR.   ;  s"    	'	c         C` s   t  t |  j  } | |  j |  j  } |  j d t |  j  d } g  | j D] } | | ^ qO } t	 j
 |  j |  j j  S(   Nu   %.u   f(   RF   R\   R   R+   R,   R  R   R(   R   R;   R   R   R   (   R/   R   R  R   R   R   (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyRU   P  s
     (   R"   R#   R$   R.   RX   RU   (    (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR  5  s   	t   TimeBesselianEpochStringc           B` s&   e  Z d  Z d Z d Z d Z d Z RS(   u6   Besselian Epoch year as string value(s) like 'B1950.0'u	   byear_stru   epb2jdu   epbu   B(   R"   R#   R$   R   R   R   R  (    (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR	  Z  s
   t   TimeJulianEpochStringc           B` s&   e  Z d  Z d Z d Z d Z d Z RS(   u3   Julian Epoch year as string value(s) like 'J2000.0'u	   jyear_stru   epj2jdu   epju   J(   R"   R#   R$   R   R   R   R  (    (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR
  b  s
   t   TimeDeltaFormatMetac           B` s   e  Z e Z RS(    (   R"   R#   t   TIME_DELTA_FORMATSR   (    (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR  j  s   t   TimeDeltaFormatc           B` s/   e  Z d  Z d   Z d   Z e d    Z RS(   u)   Base class for time delta representationsc         C` s7   | d k	 r3 | t k r3 t d j | t    n  | S(   uU   
        Check that the scale is in the allowed list of scales, or is `None`
        u+   Scale value '{0}' not in allowed values {1}N(   RC   t   TIME_DELTA_SCALESRS   RE   (   R/   R'   (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR6   r  s    	c         C` s<   |  j  |  j  t | | d d |  j \ |  _ |  _ d  S(   NR   g      ?(   R6   R7   R	   R   R+   R,   (   R/   R0   R1   (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR.   }  s    c         C` s   |  j  |  j |  j S(   N(   R+   R,   R   (   R/   (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyRU     s    (   R"   R#   R$   R6   R.   RX   RU   (    (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR  n  s   		t   TimeDeltaSecc           B` s!   e  Z d  Z d Z d e j Z RS(   u   Time delta in SI secondsu   secg      ?(   R"   R#   R$   R   R\   R   R   (    (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR    s   t   TimeDeltaJDc           B` s   e  Z d  Z d Z d Z RS(   u,   Time delta in Julian days (86400 SI seconds)u   jdg      ?(   R"   R#   R$   R   R   (    (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyR    s   (   Rf   RR   R  RS   (G   t
   __future__R    R   R   R   R   R   R   R   t   collectionsR   t   numpyR;   t    R   RG   R   R\   t   externR   t   extern.six.movesR   t   utilsR	   R
   R   R   t   __all__t   __doctest_skip__R%   R  R   R   R   R   t   add_metaclassR   R&   RZ   R[   R^   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R  R  R	  R
  R  R  R  R  t   coreRf   RR   R  RS   (    (    (    s3   lib/python2.7/site-packages/astropy/time/formats.pyt   <module>   st   ""									AL&`3"i%