
    IR-ez1                       d dl Z d dlZd dlZd dlZd dlZd dlmZmZ d dlm	Z	 d dl
Z
d dlZd dlmZ d dlmZmZ d dlmZmZ ddlmZmZmZ ddlmZmZmZmZ g d	Zd
gZ e            Z  e            Z!ddddddZ" G d de          Z#d Z$ G d d          Z% G d de%          Z& G d de&          Z' G d de&          Z(d Z) G d de&          Z* G d de&          Z+ G d d e+          Z, G d! d"e,          Z- G d# d$e+          Z. G d% d&e+          Z/ G d' d
e+          Z0 G d( d)e+          Z1 G d* d+e%          Z2 G d, d-e2          Z3 G d. d/e2          Z4 G d0 d1e2          Z5 G d2 d3e j6                  Z7 G d4 d5e2          Z8 G d6 d7e8          Z9 G d8 d9e9          Z: G d: d;e9          Z; G d< d=e:          Z< G d> d?e8          Z= G d@ dAe&          Z> G dB dCe>          Z? G dD dEe>          Z@ G dF dGe8          ZA G dH dIeA          ZB G dJ dKeA          ZC G dL dMe%          ZD G dN dOeDe&          ZE G dP dQeE          ZF G dR dSeE          ZG G dT dUeDe2          ZHdV ZIdW ZJddXlKmLZLmMZMmNZNmOZO dS )Y    N)OrderedDictdefaultdict)Decimal)classpropertylazyproperty)AstropyDeprecationWarningAstropyUserWarning   )_parse_timesconfutils)day_fracquantity_day_fractwo_producttwo_sum)# AstropyDatetimeLeapSecondWarning
TimeFormatTimeJDTimeMJDTimeFromEpochTimeUnixTimeUnixTai
TimeCxcSecTimeGPSTimeDecimalYearTimePlotDate
TimeUniqueTimeDatetime
TimeStringTimeISOTimeISOTTimeFITSTimeYearDayTimeTimeEpochDateTimeBesselianEpochTimeJulianEpochTimeDeltaFormatTimeDeltaSecTimeDeltaJDTimeEpochDateStringTimeBesselianEpochStringTimeJulianEpochStringTIME_FORMATSTIME_DELTA_FORMATSTimezoneInfoTimeDeltaDatetimeTimeDatetime64
TimeYMDHMSTimeNumericTimeDeltaNumericr   ttutctai)TDTETGMTUTIATc                       e Zd ZdZdS )r   zDWarning for leap second when converting to datetime.datetime object.N__name__
__module____qualname____doc__     4lib/python3.11/site-packages/astropy/time/formats.pyr   r   M   s        NNNNrD   r   c                 "   g }| D ]|}|d         }t          |t                    rHdD ]\  }}|                    ||          }d|vr&|d         t          j        |dz             |d         f}|                    |           }t          |          S )a  
    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.
    r
   ))z%Yz(?P<year>\d\d\d\d))z%mz(?P<mon>\d{1,2}))z%dz(?P<mday>\d{1,2}))z%Hz(?P<hour>\d{1,2}))z%Mz(?P<min>\d{1,2}))%Sz(?P<sec>\d{1,2})%r   $   )
isinstancestrreplacerecompileappendtuple)subfmtsnew_subfmtssubfmt_tuple	subfmt_instrptime_coderegexs         rE   _regexify_subfmtsrX   Q   s     K ) ) O	i%% 	) D D$u &--mUCC		)## OJy3// O 
 	<((((rD   c                   <    e Zd ZdZdZdZeZ	 d!dZ fdZ	e
d             Zed             Zej        d	             Zed
             Zej        d             Zed             Zej        d             Zed             Zej        d             Zd Zed             Zej        d             Zd Zed             Zed             Zed             Zed             Zej        d             Zed             Zd Zd Zd Zd"dZed             Ze
d              Z  xZ!S )#r   a1  
    Base class for time representations.

    Parameters
    ----------
    val1 : numpy ndarray, list, number, str, or bytes
        Values to initialize the time or times.  Bytes are decoded as ascii.
        Quantities with time units are allowed for formats where the
        interpretation is unambiguous.
    val2 : numpy ndarray, list, or number; optional
        Value(s) to initialize the time or times.  Only used for numerical
        input, to help preserve precision.
    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
    r6   rC   Fc                     || _         || _        || _        || _        d\  | _        | _        |r|| _        || _        d S |                     ||          \  }}| 	                    ||           d S )NNN)
scale	precision	in_subfmt
out_subfmt_jd1_jd2jd1jd2_check_val_typeset_jds)selfval1val2r\   r]   r^   r_   from_jds           rE   __init__zTimeFormat.__init__   s{     
""$)	49 	%DHDHHH--dD99JD$LLt$$$$$rD   c                    d| j         v rG| j        dk    r<d| j         v r$t          | j        d          st	          d          | | j        | j        <   d| j         v rt          | j                  | _         t                      j	        di |S )Nnameastropy_timevaluefgetz&If defined, 'value' must be a propertyrR   rC   )
__dict__rl   hasattrrn   
ValueError	_registryrX   rR   super__init_subclass__)clskwargs	__class__s     rE   ru   zTimeFormat.__init_subclass__   s     S\!!ch.&@&@ #,&&wsy&/I/I& !IJJJ&)CM#(# $$+CK88CK(uww(226222rD   c                 X    	 |                      |           n# t          $ r d}Y nw xY w|S )a[  Get an allowed subfmt for this class, either the input ``subfmt``
        if this is valid or '*' as a default.  This method gets used in situations
        where the format of an existing Time object is changing and so the
        out_ or in_subfmt may need to be coerced to the default '*' if that
        ``subfmt`` is no longer valid.
        *)_select_subfmtsrr   )rv   subfmts     rE   _get_allowed_subfmtzTimeFormat._get_allowed_subfmt   sG    	'''' 	 	 	FFF	s    ''c                     | j         S N)
_in_subfmtrf   s    rE   r^   zTimeFormat.in_subfmt   
    rD   c                 >    |                      |           || _        d S r   )r{   r   rf   r|   s     rE   r^   zTimeFormat.in_subfmt   s#     	V$$$ rD   c                     | j         S r   )_out_subfmtr   s    rE   r_   zTimeFormat.out_subfmt       rD   c                 >    |                      |           || _        d S r   )r{   r   r   s     rE   r_   zTimeFormat.out_subfmt   s&     	V$$$!rD   c                     | j         S r   )r`   r   s    rE   rb   zTimeFormat.jd1   
    yrD   c                     t          |          | _        | j        )t          | j        | j                  \  | _        | _        d S d S r   )_validate_jd_for_storager`   ra   _broadcast_writeable)rf   rb   s     rE   rb   zTimeFormat.jd1   A    ,S11	9 #7	49#M#M DItyyy ! rD   c                     | j         S r   )ra   r   s    rE   rc   zTimeFormat.jd2   r   rD   c                     t          |          | _        | j        )t          | j        | j                  \  | _        | _        d S d S r   )r   ra   r`   r   )rf   rc   s     rE   rc   zTimeFormat.jd2   r   rD   c                 *    t          | j                  S r   )lenrb   r   s    rE   __len__zTimeFormat.__len__   s    48}}rD   c                 N    |                      | j                  | _        | j        S )zTime scale.)_check_scale_scaler   s    rE   r\   zTimeFormat.scale   s#     ''44{rD   c                     || _         d S r   )r   rf   vals     rE   r\   zTimeFormat.scale   s    rD   c                 b    | j         r't          j                            || j        d          }|S )NF)maskcopy)maskednpmaarrayr   )rf   rn   s     rE   mask_if_neededzTimeFormat.mask_if_needed   s-    ; 	CEKKDIEKBBErD   c                     d| j         vrJt          j        | j                  | j         d<   | j         d         j        rd| j         d         j        _        | j         d         S )Nr   F)cacher   isnanrc   shapeflags	writeabler   s    rE   r   zTimeFormat.mask   sX    ##!#$(!3!3DJvz&!' ;5:
6"(2z&!!rD   c                     d| j         vr.t          t          j        | j                            | j         d<   | j         d         S )Nr   )r   boolr   anyr   r   s    rE   r   zTimeFormat.masked  s<    4:%%#'ty(9(9#:#:DJx z(##rD   c                 P    | j         rt          j        | j                  n| j        S r   )r   r   
nan_to_numrc   r   s    rE   
jd2_filledzTimeFormat.jd2_filled  s"    *.+Cr}TX&&&48CrD   c                     | j         S r   )
_precisionr   s    rE   r]   zTimeFormat.precision  r   rD   c                 t    t          |t                    r|dk     s|dk    rt          d          || _        d S )Nr   	   z2precision attribute must be an int between 0 and 9)rK   intrr   r   r   s     rE   r]   zTimeFormat.precision  sA     #s## 	SsQww#''QRRRrD   c                 *    t          t                    S )zA
        Return the cache associated with this instance.
        )r   dictr   s    rE   r   zTimeFormat.cache  s    
 4   rD   c                    t          j        |          }|j        dk    r|                                }n|j        dk    rd}|j        j        dk    r|j        j        dk    r|p
|j        dk    }|du pQ|j        j        dk    o6|j        j        dk    o&t          j        t          j        |                     p
|j        dk    }|r|st          d| j
         d          t          |d	d          t          j        |d
          }|t          j        |d
          }	 t          ||          \  }}n'# t          j        $ r t          j        d          w xY wdt          | d	d          z  }|dk    r.t#          ||          \  }}|||z  z  }t%          ||          \  }}n t          |d	d          t          d          |t          j        d|j                  }d } ||           ||          fS )@Input value validation, typically overridden by derived classes.r
   r   Ff   NInput values for z class must be finite doublesunit)r   zJonly quantities with time units can be used to instantiate Time instances.      ?z$Cannot mix float and Quantity inputsdtypec                 b    t          | t          j                  rt          j        |           n| S )z
            Remove ndarray subclasses since for jd1/jd2 we want a pure ndarray
            or a Python or numpy scalar.
            )rK   r   ndarrayasarray)r   s    rE   asarray_or_scalarz5TimeFormat._check_val_type.<locals>.asarray_or_scalarb  s'    
 '1bj&A&AJ2:c???sJrD   )r   isfinitesizeallr   kinditemsizer   isinf	TypeErrorrl   getattruQuantityr   
UnitsErrorUnitConversionErrorr   r   r   )	rf   rg   rh   	isfinite1ok1ok2factorcarryr   s	            rE   rd   zTimeFormat._check_val_type#  sk    K%%	9q== I Y!^^IJOs" 
#q( yA~	 	 DL 
3& /J'1,/rx~~...	 yA~ 	  	 	LDILLL   4&&2
 :d///Dz$U333.tT::
dd<   +:   74555F}})$77e&$T511
dT64((4BCCC<8ATZ000D	K 	K 	K ! &&(9(9$(?(???s   !D5 5$Ec                 ^    || j         }|t          vrt          d| dt                     |S )a  
        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.
        NScale value '' not in allowed values )_default_scaleTIME_SCALESScaleValueErrorrf   r\   s     rE   r   zTimeFormat._check_scalek  sH     ='E##!LLL{LL   rD   c                     t           )zl
        Set internal jd1 and jd2 from val1 and val2.  Must be provided
        by derived classes.
        NotImplementedErrorrf   rg   rh   s      rE   re   zTimeFormat.set_jds  s
    
 "!rD   Nc                     |*| j         }	 || _         | j        }|| _         n# || _         w xY w| j        }|                     |          S )a  
        Return time representation from internal jd1 and jd2 in specified
        ``out_subfmt``.

        This is the base method that ignores ``parent`` and uses the ``value``
        property to compute the output. This is done by temporarily setting
        ``self.out_subfmt`` and calling ``self.value``. This is required for
        legacy Format subclasses prior to astropy 4.0  New code should instead
        implement the value functionality in ``to_value()`` and then make the
        ``value`` property be a simple call to ``self.to_value()``.

        Parameters
        ----------
        parent : object
            Parent `~astropy.time.Time` object associated with this
            `~astropy.time.TimeFormat` object
        out_subfmt : str or None
            Output subformt (use existing self.out_subfmt if `None`)

        Returns
        -------
        value : numpy.array, numpy.ma.array
            Array or masked array of formatted time representation values
        )r_   rn   r   )rf   parentr_   out_subfmt_origrn   s        rE   to_valuezTimeFormat.to_value  s[    4 !"oO2",
"1/1111JE""5)))s   ! 	*c                     t           r   r   r   s    rE   rn   zTimeFormat.value  s    !!rD   c                 p   t          t                    st          d          dk    r| j        S fd| j        D             }t	          |          dk    r]t	          | j                  dk    rt          d| j                   d | j        D             }t          dd| d	| j                   |S )
am  
        Return a list of subformats where name matches ``pattern`` using
        fnmatch.

        If no subformat matches pattern then a ValueError is raised.  A special
        case is a format with no allowed subformats, i.e. subfmts=(), and
        pattern='*'.  This is OK and happens when this method is used for
        validation of an out_subfmt.
        z!subfmt attribute must be a stringrz   c                 J    g | ]}t          j        |d                    | S r   )fnmatchfnmatchcase).0xpatterns     rE   
<listcomp>z.TimeFormat._select_subfmts.<locals>.<listcomp>  s/    PPPW-@1w-O-OP1PPPrD   r   z!subformat not allowed for format c                     g | ]
}|d          S r   rC   )r   r   s     rE   r   z.TimeFormat._select_subfmts.<locals>.<listcomp>  s    :::!:::rD   z
subformat z must match one of z for format )rK   rL   rr   rR   r   rl   )rv   r   rR   subfmt_namess    `  rE   r{   zTimeFormat._select_subfmts  s     '3'' 	@AAA^^;PPPPckPPPw<<13;1$$ !OSX!O!OPPP::ck::: < < <#< <14< <  
 rD   Fr[   )"r?   r@   rA   rB   r   rR   r-   rs   rj   ru   classmethodr}   propertyr^   setterr_   rb   rc   r   r\   r   r   r   r   r]   r   r   rd   r   re   r   rn   r{   __classcell__rx   s   @rE   r   r   t   s        0 NGI LQ% % % %"3 3 3 3 3*   [   X ! ! !
     X  " " "
   X 	ZN N ZN
   X 	ZN N ZN
     X
 \  \  
 " " X" $ $ X$
 D D XD   X    ! ! \!F@ F@ F@P  ." " "$* $* $* $*L " " X"   [    rD   r   c                        e Zd Zdej        dej        fdej        ej        ej	        fdej
        ej        ej        fdej        ej        ej        fdej        ej        ej        ffZ fdZd	dZ ee          Z xZS )
r3   floatNlongdecimalrL   bytesc                    |du }|j         j        dk    r&t                                          ||          \  }}nV|r<|j         j        dv sF|j         j        dk    rt	          d |j        D                       st          d| j         d          |r|j         nt          j	        |j         |j                   }| 
                    | j                  }|D ]\  }}}}	t          j        ||          r nt          d          |7	  |||          \  }}n&# t          $ r t          d| j         d	          w xY w||fS )
r   Nr   USOc              3   @   K   | ]}t          |t                    V  d S r   )rK   r   )r   vs     rE   	<genexpr>z.TimeNumeric._check_val_type.<locals>.<genexpr>  s,      BB1
1g..BBBBBBrD   for zd class, input should be doubles, string, or Decimal, and second values are only allowed for doubles.z*input type not among selected sub-formats.zr class, input should be (long) doubles, string, or Decimal, and second values are only allowed for (long) doubles.)r   r   rt   rd   r   flatr   rl   r   result_typer{   r^   
issubdtyperr   	Exception)rf   rg   rh   orig_val2_is_none	val_dtyperR   r|   r   convert_rx   s             rE   rd   zTimeNumeric._check_val_type  s    !DL:?c!!00t<<JD$$" 
	JOt##
3&&BB	BBBBB ' Bty B B B   ,WDJJ
DJ1W1W 	 &&t~66)0 	K 	K%FE7A}Y..  IJJJ$WT400
dd   &49 & & &   Tzs   D #D:c           
         | j         j        j        | j         j        ur| j        S || j        }|| j        }|| j        }|                     |          d         }i }|d         dv rlt          | dd          }t          t          j        t          j        |t          j        t                    j        z                                }d| d|d<    |d	         ||fi |}	|                     |	          S )
z
        Return time representation from internal jd1 and jd2.
        Subclasses that require ``parent`` or to adjust the jds should
        override this method.
        Nr   )rL   r   r   r
   .r   fmt   )rx   rn   ro   r   rb   rc   r_   r{   r   r   r   ceillog10finfor   epsr   )
rf   rb   rc   r   r_   r|   rw   r   digitsrn   s
             rE   r   zTimeNumeric.to_value  s     >$DN,CCC:;(C;(CJ%%j11!4!9(((4++D$%1D*D!E!EFFGGF)MMMF5Mq	#s--f--""5)))rD   )NNNN)r?   r@   rA   r   float64add
longdoubler   longdouble_to_twovaltwoval_to_longdoubleobject_decimal_to_twovaltwoval_to_decimalstr_twoval_to_stringbytes_bytes_to_twovaltwoval_to_bytesrR   rd   r   r   rn   r   r   s   @rE   r3   r3     s        	"*dBF+	 :E<VW	BJ 79PQ	0%2HI	")U2E4IJG* * * * *X* * * *4 HXEEEEErD   r3   c                       e Zd ZdZdZd ZdS )r   z
    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.
    jdc                 t    |                      | j                   t          ||          \  | _        | _        d S r   )r   r   r   rb   rc   r   s      rE   re   zTimeJD.set_jds.  s4    $+&&&%dD11$(((rD   N)r?   r@   rA   rB   rl   re   rC   rD   rE   r   r   #  s4          D2 2 2 2 2rD   r   c                   B     e Zd ZdZdZd Z fdZ ee          Z xZ	S )r   z
    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.
    mjdc                     |                      | j                   t          ||          \  }}|t          j        z  }t          ||          \  | _        | _        d S r   )r   r   r   erfaDJM0rb   rc   rf   rg   rh   rb   rc   s        rE   re   zTimeMJD.set_jds=  sS    $+&&&D$''Sty%c3//$(((rD   c                 r    | j         t          j        z
  }| j        } t	                      j        d||d|S )Nrb   rc   rC   )rb   r$  r%  rc   rt   r   )rf   rw   rb   rc   rx   s       rE   r   zTimeMJD.to_valueC  s<    h"huww;CS;;F;;;rD   )
r?   r@   rA   rB   rl   re   r   r   rn   r   r   s   @rE   r   r   3  s]          D0 0 0< < < < <
 HXEEEEErD   r   c                 r    t          |d          r$t          |dd           t          d| d          d S d S )Ntor   zcannot use Quantities for z format, as the unit of year is defined as 365.25 days, while the length of year is variable in this format. Use float instead.)rq   r   rr   )format_namerg   rh   s      rE   _check_val_type_not_quantityr,  K  s_     tT 
wtVT::F1 1 1 1
 
 	

 
FFrD   c                   L     e Zd ZdZdZ fdZd Z fdZ ee          Z	 xZ
S )r   ai  
    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'.

    Since for this format the length of the year varies between 365 and
    366 days, it is not possible to use Quantity input, in which a year
    is always 365.25 days.
    decimalyearc                 t    t          | j        ||           t                                          ||          S r   r,  rl   rt   rd   rf   rg   rh   rx   s      rE   rd   zTimeDecimalYear._check_val_typed  1    $TYd;;;ww&&tT222rD   c           	         |                      | j                   t          ||          \  }}t          j        |                              t                    }t          ||           \  }}|||z   z  }||z                       t          j                  }t          j        |                              t                    }t          j        |          }	t          j        |          }
t          j	        |          }t          j	        |          }t          j	        |          }| j
                                                            d          }t          j        |||	|
|||          \  }}t          j        ||dz   |	|
|||          \  }}t          ||| j
        d          }t          ||| j
        d          }|||z
  |z  z   }t!          |j        |j                  \  | _        | _        d S )Nasciir
   r  r\   format)r   r   r   r   truncastyper   double	ones_like
zeros_liker\   upperencoder$  dtf2dTimer   rb   rc   )rf   rg   rh   sum12err12iy_startextray_fracr   imonidayihriminisecr\   	jd1_start	jd2_startjd1_endjd2_endt_startt_endt_fracs                         rE   re   zTimeDecimalYear.set_jdsi  s   $+&&&tT**u8E??))#..y11v%%-d{""29--8C=='',,|H%%|H%%mH%%}X&&}V$$ 
  ""))'22#z%4sDRVWW	9:eX\4sDRVWWy)4:dKKKWgTZEEEEGOv55%fj&*==$(((rD   c           	         | j                                                             d          }t          j        |d| j        | j                  \  }}}}t          j        |          }t          j        |          }t          j	        |          }	t          j	        |          }
t          j	        | j                  }| j                                                             d          }t          j
        |||||	|
|          \  }}t          j
        ||dz   |||	|
|          \  }}| j        |z
  | j        |z
  z   }||z
  ||z
  z   }|||z  z   } t                      j        d|t          j        d          d|S )Nr4  r   r
           r(  rC   )r\   r<  r=  r$  d2dtfrb   r   r   r:  r;  r>  rc   rt   r   r  )rf   rw   r\   rB  imsidsihmsfsrE  rF  rG  rH  rI  rJ  rK  rL  rM  dtdt_endr.  rx   s                      rE   r   zTimeDecimalYear.to_value  si   
  ""))'22%)Z1dh&
 &
"#sF |H%%|H%%mH%%}X&&}TX&& 
  ""))'22#z%4sDRVWW	9:eX\4sDRVWWh"tx)';<I%'I*=>f,uwwOKRZ__OOOOOrD   )r?   r@   rA   rB   rl   rd   re   r   r   rn   r   r   s   @rE   r   r   V  s{        	 	 D3 3 3 3 3
> > >:P P P P P. HXEEEEErD   r   c                        e Zd ZdZ ed          d             Zed             Zd Zd
 fd	Z	 ee	          Z
ed	             Z xZS )r   z
    Base class for times that represent the interval from a particular
    epoch as a numerical multiple of a unit time interval (e.g. seconds
    or days).
    T)lazyc                 P    t          | j        | j        | j        | j                  S )Nr5  )r?  	epoch_val
epoch_val2epoch_scaleepoch_format)rv   s    rE   _epochzTimeFromEpoch._epoch  s0    
 MN/#	
 
 
 	
rD   c                     | j         S )>Reference epoch time from which the time interval is measured.)r`  r   s    rE   epochzTimeFromEpoch.epoch  s     {rD   c                    t          ||d| j        z            \  }}| j        j        |z   }| j        j        |z   }| j        j        | j        k    rW|j        rt          j        |          n t          |	                                          }||z  }||z  }||c| _        | _        dS 	 t          t          ||| j        d          | j                  }n=# t          $ r0}	t          d| j         d| j         d| j         d	|	           |	d}	~	ww xY wt          |j        j        |j        j                  \  | _        | _        dS )
z
        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).
        r   divisorNr  r5  Cannot convert from '' epoch scale '' to specified scale '', got error:
)r   r   rc  rb   rc   r\   r   r   rounditemr   r?  r^  r  r   rl   _time)
rf   rg   rh   dayfracrb   rc   	jd1_extratmerrs
             rE   re   zTimeFromEpoch.set_jds  sy   " T4tyAAA	Tjns"jnt# :tz))),Ichhjj8I8II9C9C!$cDHdhF	S#T%5dCCCTZ BB  	 	 	!H	 H H$BR H H'+zH HBEH H  	 &bhlBHLAA$(((s   )+C 
D+D

DNc                    | j         | j        k    r~|t          d          	 t          || j                  }n=# t          $ r0}t          d| j         d| j         d| j          d|           |d }~ww xY w|j        j        |j        j	        }}n| j        | j	        }}d| j
        z  }|| j        j        z
  |z  }|| j        j	        z
  |z  }	 t                      j        d||	d|S )	Nz/cannot compute value without parent Time objectrg  rh  ri  rj  r   r(  rC   )r\   r^  rr   r   r  r   rl   rm  rb   rc   r   rc  rt   r   )rf   r   rw   rq  rr  rb   rc   r   time_from_epoch1time_from_epoch2rx   s             rE   r   zTimeFromEpoch.to_value  s4    :)))~ !RSSSVT%566   %)DI ) )() )@D
) )#&) )  	 x|RX\CCxC ty$*.0F:$*.0F:uwwU$4:JUUfUUUs   : 
A4+A//A4c                     | j         S r   )r^  r   s    rE   r   zTimeFromEpoch._default_scale
  r   rD   r   )r?   r@   rA   rB   r   r`  r   rc  re   r   rn   r   r   r   s   @rE   r   r     s          ]	
 	
 	
   X3B 3B 3BjV V V V V V6 HXE    X         rD   r   c                   :    e Zd ZdZdZdej        z  ZdZdZ	dZ
dZdS )r   a  
    Unix time (UTC): seconds from 1970-01-01 00:00:00 UTC, ignoring leap seconds.

    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.
    unixr   1970-01-01 00:00:00Nr6   isor?   r@   rA   rB   rl   r$  DAYSECr   r\  r]  r^  r_  rC   rD   rE   r   r     s?        
 
 DD%IJKLLLrD   r   c                       e Zd ZdZdZdZdZdS )r   aq  
    Unix time (TAI): SI seconds elapsed since 1970-01-01 00:00:00 TAI (see caveats).

    This will generally differ from standard (UTC) Unix time by the cumulative
    integral number of leap seconds introduced into UTC since 1972-01-01 UTC
    plus the initial offset of 10 seconds at that date.

    This convention matches the definition of linux CLOCK_TAI
    (https://www.cl.cam.ac.uk/~mgk25/posix-clocks.html),
    and the Precision Time Protocol
    (https://en.wikipedia.org/wiki/Precision_Time_Protocol), which
    is also used by the White Rabbit protocol in High Energy Physics:
    https://white-rabbit.web.cern.ch.

    Caveats:

    - Before 1972, fractional adjustments to UTC were made, so the difference
      between ``unix`` and ``unix_tai`` time is no longer an integer.
    - Because of the fractional adjustments, to be very precise, ``unix_tai``
      is the number of seconds since ``1970-01-01 00:00:00 TAI`` or equivalently
      ``1969-12-31 23:59:51.999918 UTC``.  The difference between TAI and UTC
      at that epoch was 8.000082 sec.
    - On the day of a positive leap second the difference between ``unix`` and
      ``unix_tai`` times increases linearly through the day by 1.0. See also the
      documentation for the `~astropy.time.TimeUnix` class.
    - Negative leap seconds are possible, though none have been needed to date.

    Examples
    --------
      >>> # get the current offset between TAI and UTC
      >>> from astropy.time import Time
      >>> t = Time('2020-01-01', scale='utc')
      >>> t.unix_tai - t.unix
      37.0

      >>> # Before 1972, the offset between TAI and UTC was not integer
      >>> t = Time('1970-01-01', scale='utc')
      >>> t.unix_tai - t.unix  # doctest: +FLOAT_CMP
      8.000082

      >>> # Initial offset of 10 seconds in 1972
      >>> t = Time('1972-01-01', scale='utc')
      >>> t.unix_tai - t.unix
      10.0
    unix_tairy  r7   N)r?   r@   rA   rB   rl   r\  r^  rC   rD   rE   r   r   $  s*        , ,\ D%IKKKrD   r   c                   :    e Zd ZdZdZdej        z  ZdZdZ	dZ
dZdS )r   z
    Chandra X-ray Center seconds from 1998-01-01 00:00:00 TT.
    For example, 63072064.184 is midnight on January 1, 2000.
    cxcsecr   z1998-01-01 00:00:00Nr5   rz  r{  rC   rD   rE   r   r   X  s?         
 DD%IJKLLLrD   r   c                   :    e Zd ZdZdZdej        z  ZdZdZ	dZ
dZdS )r   a  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 https://www.usno.navy.mil/USNO/time/gps/usno-gps-time-transfer
    gpsr   z1980-01-06 00:00:19Nr7   rz  r{  rC   rD   rE   r   r   f  s?          DD%IJKLLLrD   r   c                   @    e Zd ZdZdZdZdZdZdZdZ	e
d             ZdS )	r   a(  
    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.
    	plot_dater   g   PD:ANr6   r  c                    	 ddl m}  |            }ddlm} t	          j                    5  t	          j        d|           t          |dd          }d	d	d	           n# 1 swxY w Y   d
|_        n# t          $ r
 | j
        }Y nw xY w|S )rb  r   )	get_epoch)ErfaWarningignore)categoryr6   isotr5  Nr  )matplotlib.datesr  r$  r  warningscatch_warningsfilterwarningsr?  r6  ImportErrorr`  )rf   r  	epoch_utcr  r`  s        rE   rc  zTimePlotDate.epoch  s   	!222222 "	I(((((((** E E';GGGGiuVDDDE E E E E E E E E E E E E E E !FMM  	! 	! 	![FFF	! s"   A3 )A  A$'A$3BB)r?   r@   rA   rB   rl   r   r\  r]  r^  r_  r   rc  rC   rD   rE   r   r   }  sW         & DDIJKL  \  rD   c                   *    e Zd ZdZdZdZdZdZdZdZ	dS )TimeStardatez
    Stardate: date units from 2318-07-05 12:00:00 UTC.
    For example, stardate 41153.7 is 00:52 on April 30, 2363.
    See http://trekguide.com/Stardates.htm#TNG for calculations and reference points.
    stardateg|u?z2318-07-05 11:00:00Nr7   rz  )
r?   r@   rA   rB   rl   r   r\  r]  r^  r_  rC   rD   rE   r  r    s8          DD%IJKLLLrD   r  c                       e Zd ZdZdS )r   z
    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.
    Nr>   rC   rD   rE   r   r     s           rD   r   c                        e Zd ZdZdZ	 ddZdS )TimeAstropyTimez
    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.
    rm   Fc           	      t   |j         d         t          t                    r t          fd|j         D                       st	          d| j         d          j        |j        rfd|D             }t          j	        d |D                       }	t          j	        d |D                       }
t          d	 |D                       rt          d
 |D                       rt          d          g }|D ]T}t          j        |j        |j        j        j        d          }|                    t          j        |                     Ut          j	        |          }n-d}n*t%                    j        }|j        |j        }
}	j        }j        j        } ||	|
|||d          }||_        |S )z
        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.
        r   c              3   T   K   | ]"}t          |          t                    u V  #d S r   )type)r   r   val1_0s     rE   r   z*TimeAstropyTime.__new__.<locals>.<genexpr>  s4      CC#DIIf-CCCCCCrD   r   z. class must all be the same astropy Time type.Nc                 :    g | ]}t          |          j        S rC   )r   rm  )r   r   r\   s     rE   r   z+TimeAstropyTime.__new__.<locals>.<listcomp>  s&    >>>#GC''->>>rD   c                 @    g | ]}t          j        |j                  S rC   )r   
atleast_1drb   r   r   s     rE   r   z+TimeAstropyTime.__new__.<locals>.<listcomp>  $    !I!I!IS"-"8"8!I!I!IrD   c                 @    g | ]}t          j        |j                  S rC   )r   r  rc   r  s     rE   r   z+TimeAstropyTime.__new__.<locals>.<listcomp>  r  rD   c              3   (   K   | ]}|j         d uV  d S r   locationr   rq  s     rE   r   z*TimeAstropyTime.__new__.<locals>.<genexpr>  s)      ::r2;d*::::::rD   c              3   (   K   | ]}|j         d u V  d S r   r  r  s     rE   r   z*TimeAstropyTime.__new__.<locals>.<genexpr>  s)      ::rr{d*::::::rD   zMcannot concatenate times unless all locations are set or no locations are setT)subok)ri   )r   rK   r?  r   r   rl   r\   r   r   concatenater   rr   broadcast_tor  rm  rb   rP   r  r   rc   rx   	_location)rv   rg   rh   r\   r]   r^   r_   ri   valsrb   rc   	locationsrq  r  r   OutTimeFormatrf   r  s      `             @rE   __new__zTimeAstropyTime.__new__  s    1vt$$	CCCCCCCCC	 %CH % % %  
 =LE: 	'>>>>>>>D.!I!ID!I!I!IJJC.!I!ID!I!I!IJJC ::T:::::  ::T::::: $:   	 > >B!RX\%7t     H $$R]8%<%<====>)44  &%((.CwCH.}eY	:t
 
 
 "rD   Nr   )r?   r@   rA   rB   rl   r  rC   rD   rE   r  r    s@          D KP9 9 9 9 9 9rD   r  c                   B    e Zd ZdZdZd Zd Z	 ddZ ee          Z	dS )	r   an  
    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)
    datetimec                     t          d |j        D                       st          d| j         d          |t	          | j         d|           |d fS )Nc              3   J   K   | ]}t          |t          j                  V  d S r   )rK   r  r  s     rE   r   z/TimeDatetime._check_val_type.<locals>.<genexpr>  s/      KK#:c8#455KKKKKKrD   r   z class must be datetime objects/ objects do not accept a val2 but you provided r   r   r   rl   rr   r   s      rE   rd   zTimeDatetime._check_val_type  s~    KKKKKKK 	NDINNN   9SSTSS   TzrD   c           	         t          j        |ddddddgddgdgdt           j        gz  z   t           j        gz             }|D ]\  }}}}}}	}
|                                }|j        +||                                z
                      d          }|j        |d<   |j	        |d<   |j
        |d<   |j        |d<   |j        |	d<   |j        |j        dz  z   |
d<   t          j        | j                                                            d	          g|j        d
d         R  \  }}t+          ||          \  | _        | _        dS )z6Convert datetime object contained in val1 to jd1, jd2.Nrefs_okzerosize_ok   r   	op_dtypestzinfo.    .Ar4  r
   )r   nditerintcr9  rl  r  	utcoffsetrM   yearmonthrn  hourminutesecondmicrosecondr$  r>  r\   r<  r=  operandsr   rb   rc   )rf   rg   rh   iteratorr   iyimidrG  rH  dsecrW  rb   rc   s                 rE   re   zTimeDatetime.set_jds(  sb    94tT46m,fqBG9},	{:
 
 

 19 	9 	9,CRS$By$2<<>>)22$2??gBsGhBsGfBsGwCH	DI	BNS$88DII:J%%g..
191B1221F
 
 
S &c3//$(((rD   Nraisec                    ||                      |           |#| j        dk    rt          d| j         d          | j                                                            d          }t          j        |d| j        | j	                  \  }}}}	|	d         }
|	d         }|	d	         }|	d
         }t          j        ||||
|||dgddgddgz  t          gz             }|D ]\  }}}}}}}}|dk    r|dz
  }d}nd}|<t          j        |||||||t                                                    |          }nt          j        |||||||          }|rm|t          j        d          z  }d| d}|dk    rt#          |          |dk    rt%          j        |t(                     n|dk    rt#          d| d          ||d<   |                     |j        d                   S )ah  
        Convert to (potentially timezone-aware) `~datetime.datetime` object.

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

        Since the `~datetime.datetime` class does not natively handle leap seconds, the
        behavior when converting a time within a leap second is controlled by the
        ``leap_second_strict`` argument. For example::

          >>> from astropy.time import Time
          >>> t = Time("2015-06-30 23:59:60.500")
          >>> print(t.to_datetime(leap_second_strict='silent'))
          2015-07-01 00:00:00.500000

        Parameters
        ----------
        timezone : {`~datetime.tzinfo`, None}, optional
            If not `None`, return timezone-aware datetime.
        leap_second_strict : str, optional
            If ``raise`` (default), raise an exception if the time is within a leap
            second. If ``warn`` then issue a warning. If ``silent`` then silently
            handle the leap second.

        Returns
        -------
        `~datetime.datetime`
            If ``timezone`` is not ``None``, output will be timezone-aware.
        Nr6   z	scale is z*, must be 'utc' when timezone is supplied.r4     hmsr   r  r     r  <   r
   TFr  )secondsTime z is within a leap second but `datetime` does not support leap seconds. Use the `leap_second_strict` argument of the `Time.to_datetime()` method with value of 'raise', 'warn', or 'silent' to control how leap seconds are handled.r  warnsilentz>leap_second_strict must be 'raise', 'warn', or 'silent', not ''.)r{   r   r   r\   r<  r=  r$  rS  rb   r   r   r  objectr  r/   
astimezone	timedeltarr   r  r  r   r   r  )rf   timezoneleap_second_strictr   r_   r\   iysrT  rU  rV  ihrsiminsisecsifracsr  r  r  r  rG  rH  rI  ifracsecoutin_leap_secondrW  msgs                             rE   r   zTimeDatetime.to_valueB  s   > !   ,,,{e##%WWWW   
  ""))'22 $
1dh!
 !
S#v c{ss9#sD%=m,4&jF8+
 
 
 ;C  	  	6BBT43rzzax!%!&#&BT4,..  *X&&  &r2r3dHMM h(3333KB K K K  &00$S//)'611M#'GHHHH'833$6 26 6 6  
 CHH""8#4R#8999rD   )Nr  NN)
r?   r@   rA   rB   rl   rd   re   r   r   rn   rC   rD   rE   r   r     sn          D	 	 	0 0 06 RV\: \: \: \:| HXEEErD   r   c                   8    e Zd ZdZdZd Zd Zed             ZdS )r2   aB  
    ymdhms: A Time format to represent Time as year, month, day, hour,
    minute, second (thus the name ymdhms).

    Acceptable inputs must have keys or column names in the "YMDHMS" set of
    ``year``, ``month``, ``day`` ``hour``, ``minute``, ``second``:

    - Dict with keys in the YMDHMS set
    - NumPy structured array, record array or astropy Table, or single row
      of those types, with column names in the YMDHMS set

    One can supply a subset of the YMDHMS values, for instance only 'year',
    'month', and 'day'.  Inputs have the following defaults::

      'month': 1, 'day': 1, 'hour': 0, 'minute': 0, 'second': 0

    When the input is supplied as a ``dict`` then each value can be either a
    scalar value or an array.  The values will be broadcast to a common shape.

    Example::

      >>> from astropy.time import Time
      >>> t = Time({'year': 2015, 'month': 2, 'day': 3,
      ...           'hour': 12, 'minute': 13, 'second': 14.567},
      ...           scale='utc')
      >>> t.iso
      '2015-02-03 12:13:14.567'
      >>> t.ymdhms.year
      2015
    ymdhmsc                    |t          d          g d}j        j        rfdj        j        D             }nщj        dk    rdS j        j        dk    rj        dk    rt                                          t                    rs                                                                }                                	                                }d	 t          |t          j        |           D             }nt          d
          |                                }|dt          |                   }d }t          |          t          |          z
  }	|	rt           ||	           d          t          |          t          |          k    r+t          dt          |           d ||                     ||fS )aM  
        This checks inputs for the YMDHMS format.

        It is bit more complex than most format checkers because of the flexible
        input that is allowed.  Also, it actually coerces ``val1`` into an appropriate
        dict of ndarrays that can be used easily by ``set_jds()``.  This is useful
        because it makes it easy to get default values in that routine.

        Parameters
        ----------
        val1 : ndarray or None
        val2 : ndarray or None

        Returns
        -------
        val1_as_dict, val2 : val1 as dict or None, val2 is always None

        Nz#val2 must be None for ymdhms format)r  r  rn  r  r  r  c                 "    i | ]}||         S rC   rC   )r   rl   rg   s     rE   
<dictcomp>z.TimeYMDHMS._check_val_type.<locals>.<dictcomp>  s    JJJD$t*JJJrD   r   r[   r   rC   c                     i | ]\  }}||	S rC   rC   )r   rl   rn   s      rE   r  z.TimeYMDHMS._check_val_type.<locals>.<dictcomp>  s+        +ee  rD   z input must be dict or table-likec                 @    d                     d | D                       S )Nz, c              3   4   K   | ]}t          |          V  d S r   )reprr  s     rE   r   zATimeYMDHMS._check_val_type.<locals>.comma_repr.<locals>.<genexpr>  s(      773T#YY777777rD   )join)r  s    rE   
comma_reprz.TimeYMDHMS._check_val_type.<locals>.comma_repr  s#    9977$777777rD   z" not allowed as YMDHMS key name(s)r   z! input key names you must supply )rr   r   namesr   r   rK   rl  r   keysvalueszipr   broadcast_arraysr   set)
rf   rg   rh   r  val1_as_dictr  r  required_namesr  	bad_namess
    `        rE   rd   zTimeYMDHMS._check_val_type  s   & BCCCEEE: 	AJJJJ9IJJJLLZ4: JOs""
b  499;;-- ! IIKK$$&&EYY[[''))F /25":Mv:V/W/W  LL
 ?@@@ !!###e**-	8 	8 	8 JJV,	 	:i((LLL   u::^,,,,@s5zz @ @#-:n#=#=@ @  
 T!!rD   c                 (   |At          j        g t           j                  }t          j        g t           j                  }nt          j        | j                                                            d          |d         |                    dd          |                    dd          |                    dd          |                    d	d          |                    d
d                    \  }}t          ||          \  | _
        | _        d S )Nr   r4  r  r  r
   rn  r  r   r  r  )r   r   r  r$  r>  r\   r<  r=  getr   rb   rc   r&  s        rE   re   zTimeYMDHMS.set_jds  s    <(2RZ000C(2RZ000CC z
  ""))'22V!$$""##1%%1%% HC &c3//$(((rD   c                    | j                                                             d          }t          j        |d| j        | j                  \  }}}}t          j        | j        j	        g d          }||d<   ||d<   ||d<   |d         |d	<   |d
         |d<   |d         |d         dz  z   |d<   |
                    t          j                  }|                     |          S )Nr4  r   ))r  i4)r  r  )rn  r  )r  r  )r  r  )r  f8r   r  r  rn  r  r  r  r  r  r   g&.>r  )r\   r<  r=  r$  rS  rb   r   r   emptyr   viewrecarrayr   )rf   r\   r  rT  rU  rV  r  s          rE   rn   zTimeYMDHMS.value   s    
  ""))'22 $
5!TXt O OS#vhHN  

 

 

 FGE
SkFsHsfSkJ&>>Hhhr{##""3'''rD   N	r?   r@   rA   rB   rl   rd   re   r   rn   rC   rD   rE   r2   r2     sb         > DF" F" F"P0 0 0& ( ( X( ( (rD   r2   c                       e Zd ZdZ ej        ej        ej                  dej        z  dej        z  dfd            Zd Zd Z	d Z
dS )	r/   a)  
    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.
    )
utc_offsetdstr   Nc                    |dk    r
|dk    r|d}t          j        |                    t          j                            | _        || _        t          j        |                    t          j                            | _        dS )a  
        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 : str or 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
        r   NUTC)r  r  r   r   rn  
_utcoffset_tzname_dst)rf   r  r  tznames       rE   rj   zTimezoneInfo.__init__E  sk    4 ??saxxFNF",Z-@-@-G-GHH&s||AE':':;;			rD   c                     | j         S r   )r
  rf   rW  s     rE   r  zTimezoneInfo.utcoffsete  s
    rD   c                 *    t          | j                  S r   )rL   r  r  s     rE   r  zTimezoneInfo.tznameh  s    4<   rD   c                     | j         S r   )r  r  s     rE   r  zTimezoneInfo.dstk  s
    yrD   )r?   r@   rA   rB   r   quantity_inputrn  rj   r  r  r  rC   rD   rE   r/   r/   ;  s          QAE222"#ae)QU4 < < < 32<>  ! ! !    rD   r/   c                   b     e Zd ZdZ fdZd Zd Zd Zd Zd Z	d Z
d	 Zed
             Z xZS )r   a  
    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.

    **Fast C-based parser**

    Time format classes can take advantage of a fast C-based parser if the times
    are represented as fixed-format strings with year, month, day-of-month,
    hour, minute, second, OR year, day-of-year, hour, minute, second. This can
    be a factor of 20 or more faster than the pure Python parser.

    Fixed format means that the components always have the same number of
    characters. The Python parser will accept ``2001-9-2`` as a date, but the C
    parser would require ``2001-09-02``.

    A subclass in this case must define a class attribute ``fast_parser_pars``
    which is a `dict` with all of the keys below. An inherited attribute is not
    checked, only an attribute in the class ``__dict__``.

    - ``delims`` (tuple of int): ASCII code for character at corresponding
      ``starts`` position (0 => no character)

    - ``starts`` (tuple of int): position where component starts (including
      delimiter if present). Use -1 for the month component for format that use
      day of year.

    - ``stops`` (tuple of int): position where component ends. Use -1 to
      continue to end of string, or for the month component for formats that use
      day of year.

    - ``break_allowed`` (tuple of int): if true (1) then the time string can
          legally end just before the corresponding component (e.g. "2000-01-01"
          is a valid time but "2000-01-01 12" is not).

    - ``has_day_of_year`` (int): 0 if dates have year, month, day; 1 if year,
      day-of-year
    c                    d| j         v r| j        }t          j        t	          t          t          t          |d                   |d         |d         |d                             t          j	                  }| j        d         rdx|d         d	<   |d
         d	<   t          j
        |          | _         t                      j        di | d S )Nfast_parser_parsdelimsstartsstopsbreak_allowedhas_day_of_yearr  startr
   stoprC   )rp   r  r   r   listr  mapchrr   dt_parscreate_parser_fast_parserrt   ru   )rv   rw   fpprx   s      rE   ru   zTimeString.__init_subclass__  s    --&C(CX//HGO,	   $
 
C #$56 6355GQ#f+a.+9#>>C!!++F+++++rD   c                     |j         j        dvr|j        rt          d| j         d          |t          | j         d|           |d fS )N)SUr   z class must be stringsr  )r   r   r   r   rl   rr   r   s      rE   rd   zTimeString._check_val_type  sk    :?*,,,Q	QQQRRR9SSTSS   TzrD   c                 R   d}d}	 |                     d          }|d|         ||d         }}t          |          }d}n# t          $ r d}Y nw xY w|D ]\  }}	}t          |	t                    r9d|	v }
	 t          j        ||	          fd|D             }n\# t          $ r Y Pw xY wt          j	        |	|          l
                                fd	t          ||          D             }d
v }
|r|
r|d         |z   |d<   n|c S t          d| d| j         d          )z@Read time from a single string, using a set of possible formats.)r  monmdayr  minsec)Nr
   r
   r   r   r   r	  NTFrG   c                 6    g | ]}t          d |z             S )tm_)r   )r   	componentrq  s     rE   r   z+TimeString.parse_string.<locals>.<listcomp>  s(    WWWyGB	(9::WWWrD   c                 \    g | ](\  }}t                              ||                    )S rC   )r   r  )r   r.  defaultrq  s      rE   r   z+TimeString.parse_string.<locals>.<listcomp>  sC       *	7 y'2233  rD   r+  r  r   does not match  format)rindexr   r  rK   rL   timestrptimerr   rN   match	groupdictr  rl   )rf   timestrrR   
componentsdefaultsidotfracsectimestr_has_fractional_digitsr  strptime_fmt_or_regexsubfmt_has_secr  rq  s               @rE   parse_stringzTimeString.parse_string  s    C
(	1>>#&&D  'uu~wtuu~WGGnnG,0))  	2 	2 	2,1)))	2 ,3 !	R !	R'A$a/55 -!%)>!>Xw0EFFB XWWWJWWWDD "   H X3W==:\\^^   .1*h.G.G   "'" - ! #Bx'1DHHKKKPWPPdiPPPQQQs#   A AA6B
B'&B'c                 R   | j         dk    sd| j        j        vst          j        dk    r|                     ||          \  }}nU	 |                     ||          \  }}n:# t          $ r- t          j        dk    r |                     ||          \  }}Y nw xY w|| _        || _	        dS )z:Parse the time strings contained in val1 and set jd1, jd2.rz   r"  FalseforceN)
r^   rx   rp   r   use_fast_parserget_jds_pythonget_jds_fastr  rb   rc   r&  s        rE   re   zTimeString.set_jds  s     Nc!!T^%<<<#w..**466HC?,,T488SS ? ? ?'722#224>>HC? s   A 4BBc           	      <   |                      | j                  }|j        j        dk    rt          nd }t          j        |ddddddgdgdgdt
          j        gz  z   t
          j        gz             }|D ]D\  }}}}	}
}} ||          }| 	                    ||          \  |d<   |d<   |	d<   |
d<   |d<   |d<   Et          j        | j                                                            d          g|j        d	d         R  \  }}t!          ||          \  }}||fS )
z:Parse the time strings contained in val1 and get jd1, jd2.r&  c                 H    t          |                                 d          S Nr4  )encodingrL   rl  r   s    rE   <lambda>z+TimeString.get_jds_python.<locals>.<lambda>
      QVVXXPW9X9X9X rD   Nr  r  r  .r4  r
   )r{   r^   r   r   rL   r   r  r  r9  r@  r$  r>  r\   r<  r=  r  r   )rf   rg   rh   rR   	to_stringr  r   r  r  r  rG  rH  r  rb   rc   s                  rE   rE  zTimeString.get_jds_python  sc    &&t~66
 :?c))CC/X/X 	 94tT46 /fqBG9},	{:
 
 

 19 		0 		0,CRS$)C..C !!#w//333CS	S		 :J%%g..
191B1221F
 
 
S C%%SCxrD   c           
         |j         j        dk    ru|                    t          j        |j         j        dz  f          }t          j        |dk              rt          d          |                    t          j
                  }n+|                    t          j
        |j         j        f          }|                     |          }t          j        | j                                                            d          |d         |d         |d         |d	         |d
         |d                   \  }}t#          ||          S )zAUse fast C parser to parse time strings in val1 and get jd1, jd2.r&        zinput is not pure ASCIIr4  r  r  rn  r  r  r  )r   r   r  r   uint32r   r   rr   r8  r   dt_u1r"  r$  r>  r\   r<  r=  r   )rf   rg   rh   val1_uint32charstime_structrb   rc   s           rE   rF  zTimeString.get_jds_fast#  s"    :?c!! ))RY
0Cq0H$IJJKvkC'(( < !:;;;  &&|'9::EE II|14:3FGHHE ''..:J%%g.. !!
 
S S!!!rD   c           
   #     K   | j                                                             d          f}t          j        || j        | j        | j                  \  }}}}|                     | j	                  d         \  }}}d}d|v }	|d         }
|d         }|d         }|d         }t          j        ||||
|||gd	g
          D ]\  }}}}}}}|	r-t          j        |||                                          j        }t          |          t          |          t          |          t          |          t          |          t          |          t          |          |dV  dS )z
        Generator that yields a dict of values corresponding to the
        calendar date and time for the internal JD values.
        r4  r   Nz{yday:r  r  r  r   r  )r   )r  r(  rn  r  r*  r+  r<  yday)r\   r<  r=  r$  rS  r]   rb   r   r{   r_   r   r  r  	timetupletm_ydayr   )rf   r\   r  rT  rU  rV  r  str_fmtrY  has_ydayr  r  r  r  r  r  r  rG  rH  rI  r  s                        rE   
str_kwargszTimeString.str_kwargsD  s     
 !!##**7335 $
4>48T_!
 !
S#v
 ,,T_==a@1gw&c{ss57Y#sD%76
 6
 6
 	 	1BBT4  I(R44>>@@H B2ww2wwC4yy4yyx==	 	 	 	 	 		 	rD   c                      |j         di |S )zWrite time to a string using a given format.

        By default, just interprets str_fmt as a format string,
        but subclasses can add to this.
        rC   )r6  )rf   r\  rw   s      rE   format_stringzTimeString.format_stringi  s     w~'''''rD   c           
         |                      | j                  }|d         \  }}}| j        dk    r2|                    d          r|dt	          | j                  z   dz   z  }g }|                                 D ]0}|                    t	           | j        |fi |                     1t          j	        |          
                    | j        j                  S )Nr   z	{sec:02d}z.{fracsec:0zd})r{   r_   r]   endswithrL   r^  rP   r`  r   r   reshaperb   r   )rf   rR   r  r\  outsrw   s         rE   rn   zTimeString.valueq  s     &&t77
1g >A'"2"2;"?"?}s4>':'::TAAG oo'' 	D 	DFKK.D.wAA&AABBCCCCx~~%%dhn555rD   )r?   r@   rA   rB   ru   rd   r@  re   rE  rF  r^  r`  r   rn   r   r   s   @rE   r   r   o  s        & &P, , , , ,(  2R 2R 2Rh  2  B" " "B# # #J( ( ( 6 6 X6 6 6 6 6rD   r   c                        e Zd ZdZdZdZ ed ed           ed           ed           ed           ed           ed          fd	d
dd          Z fdZ	 xZ
S )r    a7  
    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
    rz  ))date_hmsz%Y-%m-%d %H:%M:%Sz;{year:d}-{mon:02d}-{day:02d} {hour:02d}:{min:02d}:{sec:02d})date_hmz%Y-%m-%d %H:%Mz1{year:d}-{mon:02d}-{day:02d} {hour:02d}:{min:02d}datez%Y-%m-%dz{year:d}-{mon:02d}-{day:02d}r   - :r	  r   rQ  r  
            r  r  r            r  r   r   r   r
   r   r
   r
   r  r  r  r  r  c                     |                     d          r$| j        dk    rt          d          |d d         }t                                          ||          S )NZr6   z3Time input terminating in 'Z' must have scale='UTC'r  )rb  r\   rr   rt   r@  )rf   r8  rR   rx   s      rE   r@  zTimeISO.parse_string  s\    C   	#zU"" !VWWWcrclGww##GW555rD   )r?   r@   rA   rB   rl   rR   r   ordr  r@  r   r   s   @rE   r    r      s        	 	 DG. t33s88SSXXss3xxS33s88SSXXN(' ,  6 6 6 6 6 6 6 6 6rD   r    c                       e Zd ZdZdZdZ ed ed           ed           ed           ed           ed           ed          fd	d
dd          ZdS )r!   a  
    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
    r  ))rf  z%Y-%m-%dT%H:%M:%Sz;{year:d}-{mon:02d}-{day:02d}T{hour:02d}:{min:02d}:{sec:02d})rg  z%Y-%m-%dT%H:%Mz1{year:d}-{mon:02d}-{day:02d}T{hour:02d}:{min:02d}rh  r   rj  Trl  r	  rm  rr  rv  rw  N	r?   r@   rA   rB   rl   rR   r   rz  r  rC   rD   rE   r!   r!     s          DG t33s88SSXXss3xxS33s88SSXXN(' ,  rD   r!   c                       e Zd ZdZdZdZ edd ed           ed           ed           ed           ed          fddd	d
          ZdS )r#   aq  
    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
    rY  ))rf  z%Y:%j:%H:%M:%Sz2{year:d}:{yday:03d}:{hour:02d}:{min:02d}:{sec:02d})rg  z%Y:%j:%H:%Mz({year:d}:{yday:03d}:{hour:02d}:{min:02d})ri  z%Y:%jz{year:d}:{yday:03d}r   rl  r	  )r   r  rQ  r            )r  r  r  rn  ro  rp  r  rv  r
   rw  Nr}  rC   rD   rE   r#   r#     s        
 
 DG. t1cc#hhC##c((CCHHcc#hhG(( ,  rD   r#   c                   B     e Zd ZdZd Z fdZe fd            Z xZS )r1   
datetime64c                     |j         j        dk    s8|j        dk    rt          d| j         d          t          j        g d          }|t          | j         d|           |d fS )NMr   r   z! class must be datetime64 objectsdatetime64[D]r  )r   r   r   r   rl   r   r   rr   r   s      rE   rd   zTimeDatetime64._check_val_type  s    z#%%y1}}T	TTT   xO449SSTSS   TzrD   c                 r   t          j        |          }t          j        |          }|r|                                }d||<   |j        j        dv r|                    d          }|                    d          }t                                          ||           |rt           j	        | j
        |<   d S d S )N2000)zdatetime64[M]zdatetime64[Y]r  r%  )r   isnatr   r   r   rl   r8  rt   re   nanrc   )rf   rg   rh   r   r   rx   s        rE   re   zTimeDatetime64.set_jds'  s    
 x~~ 	 99;;DDJ :?@@@;;//D{{3 	d###  	$VDHTNNN	$ 	$rD   c                 ~    | j         }d| _         t                      j        }|| _         |                    d          S )Nr   r  )r]   rt   rn   r8  )rf   r]   retrx   s      rE   rn   zTimeDatetime64.value>  s5    N	ggm"zz,'''rD   )	r?   r@   rA   rl   rd   re   r   rn   r   r   s   @rE   r1   r1     sq        D  $ $ $ $ $. ( ( ( ( X( ( ( ( (rD   r1   c                   j     e Zd ZdZdZdZ ed eD                       Zd Ze fd            Z	 xZ
S )r"   u  
    FITS format: "[±Y]YYYY-MM-DD[THH:MM:SS[.sss]]".

    ISOT but can give signed five-digit year (mostly for negative years);

    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).
    fits))rf  z_(?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*)?)z={year:04d}-{mon:02d}-{day:02d}T{hour:02d}:{min:02d}:{sec:02d})ri  z,(?P<year>\d{4})-(?P<mon>\d\d)-(?P<mday>\d\d)z{year:04d}-{mon:02d}-{day:02d})longdate_hmszc(?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*)?)z>{year:+06d}-{mon:02d}-{day:02d}T{hour:02d}:{min:02d}:{sec:02d})longdatez0(?P<year>[+-]\d{5})-(?P<mon>\d\d)-(?P<mday>\d\d)z{year:+06d}-{mon:02d}-{day:02d}c              #   J   K   | ]}|d          |d         dz   |d         fV  dS )r   r
   z0(\((?P<scale>\w+)(\((?P<realization>\w+)\))?\))?rJ   NrC   )r   r|   s     rE   r   zTimeFITS.<genexpr>w  sU         	 1I1IKK1I	
     rD   c                    |D ]\  }}}t          j        ||          }|r n t          d| d| j         d          |                                }|d         t          j        dt                     |d                                         }t          
                    ||                                          }|t          vr't          d|dt          t                               | j        || _        || j        k    rt          d	| j         d
          t!          |d                   t!          |d                   t!          |d                   t!          |
                    dd                    t!          |
                    dd                    t#          |
                    dd                    gS )z*Read time and deprecated scale if present.r  r1  r2  r\   Nz<FITS time strings should no longer have embedded time scale.zScale z is not in the allowed scales zInput strings for z, class must all have consistent time scales.r  r(  r)  r  r   r*  r+  rR  )rN   r6  rr   rl   r7  r  r  r   r<  FITS_DEPRECATED_SCALESr  lowerr   sortedr   r\   r   r   )rf   r8  rR   r  rW   rq  
fits_scaler\   s           rE   r@  zTimeFITS.parse_string  s    # 	R 	RKAua%))B  PWPPdiPPPQQQ\\^^ g;"MN)   G**,,J*..z:;K;K;M;MNNEK'' -U - -k**- -   {"#
"" 3 3 3 3  
 6
OO5	NN6
OOvq!!""ua  !!"&&$$%%
 	
rD   c                     d| j         vrU| j        | j        z   }|j        r?|                                dk     s|                                dk    rd| j         z   | _         t                      j        S )z<Convert times to strings, using signed 5 digit if necessary.r   g   QD:Ag    TA)r_   rb   rc   r   r*  maxrt   rn   )rf   r  rx   s     rE   rn   zTimeFITS.value  sj     (( DH$Bw ;BFFHHy00BFFHH	4I4I"(4?":ww}rD   )r?   r@   rA   rB   rl   rR   rQ   r@  r   rn   r   r   s   @rE   r"   r"   G  s          DG> e       G,
 ,
 ,
\     X    rD   r"   c                   B     e Zd ZdZdZd Z fdZ ee          Z xZ	S )r$   zE
    Base class for support of Besselian and Julian epoch dates.
    r5   c                     |                      | j                   t          t          | j                  } |||z             \  }}t          ||          \  | _        | _        d S r   )r   r   r   r$  epoch_to_jdr   rb   rc   )rf   rg   rh   r  rb   rc   s         rE   re   zTimeEpochDate.set_jds  s]    $+&&&dD$455;td{++S%c3//$(((rD   c                     t          t          | j                  } || j        | j                  } t                      j        d|t          j        d          d|S )NrR  r(  rC   )	r   r$  jd_to_epochrb   rc   rt   r   r   r  )rf   rw   r  rn   rx   s       rE   r   zTimeEpochDate.to_value  sV    dD$455DHdh//uwwIErz#II&IIIrD   )
r?   r@   rA   rB   r   re   r   r   rn   r   r   s   @rE   r$   r$     sb          N0 0 0J J J J J
 HXEEEEErD   r$   c                   .     e Zd ZdZdZdZdZ fdZ xZS )r%   zBesselian Epoch year as value(s) like 1950.0.

    Since for this format the length of the year varies, input needs to
    be floating point; it is not possible to use Quantity input, for
    which a year always equals 365.25 days.
    byearepb2jdepbc                 t    t          | j        ||           t                                          ||          S r   r0  r1  s      rE   rd   z"TimeBesselianEpoch._check_val_type  r2  rD   )	r?   r@   rA   rB   rl   r  r  rd   r   r   s   @rE   r%   r%     sS          DKK3 3 3 3 3 3 3 3 3rD   r%   c                   ,    e Zd ZdZdZej        ZdZdZ	dS )r&   z*Julian Epoch year as value(s) like 2000.0.jyearepj2jdepjN)
r?   r@   rA   rB   rl   r$  DJYr   r  r  rC   rD   rE   r&   r&     s*        44D8DKKKKrD   r&   c                   2    e Zd ZdZdZd Zed             ZdS )r*   zx
    Base class to support string Besselian and Julian epoch dates
    such as 'B1950.0' or 'J2000.0' respectively.
    r5   c           	         | j         }|j        j        dk    rt          nd }t	          j        |d g|j        t          j        gdg          }|D ]\  }}	  ||          }|d         |dd          }
}	t          |
          }|	                                |k    rt          	 ||d<   X# t          t          t          f$ r t          d| d	| j         d
          w xY w|                     | j                   t          t           | j                  } ||j        d                   \  }}t'          ||          \  | _        | _        d S )Nr&  c                 H    t          |                                 d          S rI  rK  rL  s    rE   rM  z-TimeEpochDateString.set_jds.<locals>.<lambda>  rN  rD   r  )r  r   r   r
   .r  r1  r2  r  )epoch_prefixr   r   rL   r   r  r9  r   r<  rr   
IndexErrorUnicodeEncodeErrorrl   r   r   r   r$  r  r  r   rb   rc   )rf   rg   rh   r  rO  r  r   yearstime_str
epoch_typeyear_strr  r  rb   rc   s                  rE   re   zTimeEpochDateString.set_jds  s|   ( :?c))CC/X/X 	 94LTZ$;M?
 
 
 # 
	" 
	"JC	"$9S>>'/{HQRRLH
X##%%55$$ 6
 "c

 
,>? R R R !P!P!Pdi!P!P!PQQQR
 	$+&&&dD$455;x0455S%c3//$(((s   AB''3Cc                 0   t          t          | j                  } || j        | j                  }| j        dz   t          | j                  z   dz   fd|j        D             }t          j
        |                              | j        j                  S )Nz%.r   c                     g | ]}|z  S rC   rC   )r   r  r\  s     rE   r   z-TimeEpochDateString.value.<locals>.<listcomp>  s    6664$666rD   )r   r$  r  rb   rc   r  rL   r]   r   r   r   rc  r   )rf   r  r  rd  r\  s       @rE   rn   zTimeEpochDateString.value  s    dD$455DHdh//#d*S-@-@@3F66665:666x~~%%dhn555rD   N)r?   r@   rA   rB   r   re   r   rn   rC   rD   rE   r*   r*     sO         
 N0 0 04 6 6 X6 6 6rD   r*   c                   "    e Zd ZdZdZdZdZdZdS )r+   z7Besselian Epoch year as string value(s) like 'B1950.0'.	byear_strr  r  BNr?   r@   rA   rB   rl   r  r  r  rC   rD   rE   r+   r+     s(        AADKKLLLrD   r+   c                   "    e Zd ZdZdZdZdZdZdS )r,   z4Julian Epoch year as string value(s) like 'J2000.0'.	jyear_strr  r  JNr  rC   rD   rE   r,   r,     s(        >>DKKLLLrD   r,   c                       e Zd ZdZeZd ZdS )r'   z*Base class for time delta representations.c                 P    |#|t           vrt          d| dt                      |S )zV
        Check that the scale is in the allowed list of scales, or is `None`.
        Nr   r   )TIME_DELTA_SCALESr   r   s     rE   r   zTimeDeltaFormat._check_scale-  sB     .?!?!?!RRR?PRR   rD   N)r?   r@   rA   rB   r.   rs   r   rC   rD   rE   r'   r'   (  s.        44"I	 	 	 	 	rD   r'   c                   :     e Zd Zd Z fdZ ee          Z xZS )r4   c                     |                      | j                   t          ||d| j        z            \  | _        | _        d S )Nr   re  )r   r   r   r   rb   rc   r   s      rE   re   zTimeDeltaNumeric.set_jds:  s?    $+&&&%dD#	/JJJ$(((rD   c                 x    d| j         z  }| j        |z  }| j        |z  } t                      j        d||d|S )Nr   r(  rC   )r   rb   rc   rt   r   )rf   rw   r   rb   rc   rx   s        rE   r   zTimeDeltaNumeric.to_value>  sL     tyhhuww;CS;;F;;;rD   )r?   r@   rA   re   r   r   rn   r   r   s   @rE   r4   r4   9  sO        K K K< < < < < HXEEEEErD   r4   c                   *    e Zd ZdZdZdej        z  ZdS )r(   zTime delta in SI seconds.r+  r   N)r?   r@   rA   rB   rl   r$  r|  r   rC   rD   rE   r(   r(   I  s%        ##DDDDrD   r(   c                       e Zd ZdZdZdZdS )r)   z-Time delta in Julian days (86400 SI seconds).r  r   N)r?   r@   rA   rB   rl   r   rC   rD   rE   r)   r)   P  s        77DDDDrD   r)   c                   8    e Zd ZdZdZd Zd Zed             ZdS )r0   z!Time delta in datetime.timedelta.r  c                     t          d |j        D                       st          d| j         d          |t	          | j         d|           |d fS )Nc              3   J   K   | ]}t          |t          j                  V  d S r   )rK   r  r  r  s     rE   r   z4TimeDeltaDatetime._check_val_type.<locals>.<genexpr>]  s/      LL3:c8#566LLLLLLrD   r   z) class must be datetime.timedelta objectsr  r  r   s      rE   rd   z!TimeDeltaDatetime._check_val_type\  s~    LL$)LLLLL 	XDIXXX   9SSTSS   TzrD   c                    |                      | j                   t          j        |d d gddgd t          j        t          j        g          }t          j        d          }|D ]6\  }}}t          |                                |          \  |d<   }||z  |d<   7t          |j
        d         |j
        d                   \  | _        | _        d S )	Nr  r  r  r
   )days.r  )r   r   r   r  r9  r  r  divmodrl  r   r  rb   rc   )	rf   rg   rh   r  rn  r   rb   rc   others	            rE   re   zTimeDeltaDatetime.set_jdsg  s    $+&&&94m,RY	2
 
 
  a(((% 	# 	#MCc$SXXZZ55OCHes{CHH%h&7&;X=Nr=RSS$(((rD   c                    t          j        | j        | j        d gddgd d t          g          }|D ]8\  }}}t          ||          \  }}t          j        ||dz  dz            |d<   9|                     |j	        d                   S )	Nr  r  r  iQ r  )r  microseconds.r  )
r   r  rb   rc   r  r   r  r  r   r  )rf   r  rb   rc   r  jd1_jd2_s          rE   rn   zTimeDeltaDatetime.valuev  s    9Xtx&m,T6*
 
 
 & 	V 	VMCc!#s++JD$)t$,QTBTUUUCHH""8#4R#8999rD   Nr  rC   rD   rE   r0   r0   W  s[        ++D	 	 	T T T : : X: : :rD   r0   c                    t          | t          t          f          r t          j        | t          j                  S t          | t          j                  rN| j        j        dk    r| j        j	        dk    s| j        j        dv r t          j        | t          j                  S t          | t          j
                  r"| j        j        dk    r| j        j	        dk    r| S t          d| dt          |                      )Nr   r   r   iuzJJD values must be arrays (possibly zero-dimensional) of floats but we got z	 of type )rK   r   r   r   r   float_genericr   r   r   r   r   r  )r  s    rE   r   r     s    "ucl## -x"),,,,"bj!! 


!2a!7!728=D;P;Px"),,,,	B
	#	# 
(<(<ARVWAWAW	>$&> >3788> >
 
 	
rD   c                 J   | j         |j         k    r| |fS t          j        | |          j         }| j         |k    r| }n+t          j        t          j        | |          ddg          }|j         |k    r|}n+t          j        t          j        ||          ddg          }||fS )NCW)requirements)r   r   	broadcastrequirer  )rb   rc   r   s_jd1s_jd2s        rE   r   r     s    
yCICx
 Lc""(E
yE
2?366c3ZPPP
yE
2?366c3ZPPP%<rD   )r  r   r   r?  )Pr  r   rN   r4  r  collectionsr   r   r   r   r$  numpyr   astropy.unitsunitsr   astropy.utils.decoratorsr   r   astropy.utils.exceptionsr   r	    r   r   r   r   r   r   r   __all____doctest_skip__r-   r.   r  r   rX   r   r3   r   r   r,  r   r   r   r   r   r   r   r  r   r  r   r2   r  r/   r   r    r!   r#   r1   r"   r$   r%   r&   r*   r+   r,   r'   r4   r(   r)   r0   r   r   corer  r   r   r?  rC   rD   rE   <module>r     s     				   0 0 0 0 0 0 0 0                  @ @ @ @ @ @ @ @ R R R R R R R R ' ' ' ' ' ' ' ' ' ' D D D D D D D D D D D D$ $ $L ## 
 {}} []] 
 

  O O O O O'9 O O O     FZ Z Z Z Z Z Z Zz
O O O O O* O O Od2 2 2 2 2[ 2 2 2     k   0
 
 
G G G G Gk G G GTl  l  l  l  l K l  l  l ^    }   *1 1 1 1 1( 1 1 1h           m   ./ / / / /= / / /d    =          C C C C Cj C C CLT T T T T: T T TnU( U( U( U( U( U( U( U(p1 1 1 1 18? 1 1 1hS6 S6 S6 S6 S6 S6 S6 S6l46 46 46 46 46j 46 46 46n& & & & &w & & &R- - - - -g - - -`/( /( /( /( /(X /( /( /(dp p p p pz p p pf    K   *3 3 3 3 3 3 3 3$    m   )6 )6 )6 )6 )6* )6 )6 )6X    2       /       j   "            #       "   +: +: +: +: +: +: +: +:\
 
 
   * H G G G G G G G G G G G G GrD   