
    HR-eO             
          d dl Z d dlZd dlZ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
 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 dd	lmZ dd
lmZ ddlmZmZ ddlmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZOmPZPmQZQmRZRmSZSmTZTmUZU 	 ddlmVZV dZWn# eX$ r dZWY nw xY wg dZYdZZdZ[d Z\d Z]d Z^d Z_d Z`dHdZadHdZbdHdZcdHdZd G d d          Ze G d d          Zf G d  d!          Zg G d" d#          Zh G d$ d%          Zi G d& d'          Zj G d( d)          Zk G d* d+ek          Zl G d, d-el          Zm G d. d/elee          Zn G d0 d1emeeegeh          Zo G d2 d3ekee          Zp G d4 d5eleeefegehei          Zq G d6 d7eq          Zr G d8 d9el          Zs G d: d;el          Zt G d< d=elehei          Zu G d> d?elehei          Zv G d@ dAekeeefeheiej          Zw G dB dCekeeefeiej          Zx G dD dEekeeefehej          Zy G dF dGekeeej          ZzdS )I    N)ma)__version__)fits)HomogeneousList)AstropyDeprecationWarning)	XMLWriter   )
converters)ucd)utilxmlutil)9E06E08E09E10E11E12E13E15E16E17E18E19E20E21E22E23E25W06W07W08W09W10W11W12W13W15W17W18W19W20W21W22W26W27W28W29W32W33W35W36W37W38W40W41W42W43W44W45W50W52W53W54vo_raise
vo_reraisevo_warnwarn_or_raisewarn_unknown_attrs)tablewriterTF)LinkInfoValuesFieldParamCooSysTimeSysFieldRefParamRefGroupTableResourceVOTableFileElement   g      ?c                     t          j        |f| j                  }t          t	          |           |          }| d|         |d|<   |S )z
    Masked arrays can not be resized inplace, and `np.resize` and
    `ma.resize` are both incompatible with structured arrays.
    Therefore, we do all this.
    dtypeN)r   zerosrY   minlen)maskednew_size	new_arraylengths       7lib/python3.11/site-packages/astropy/io/votable/tree.py_resizerb   z   sM     (FL999IVh''FIgvg    c                 R     d fd	d fd	}|r	||_         |S |_         S )a  
    Creates a function useful for looking up an element by a given
    attribute.

    Parameters
    ----------
    attr : str
        The attribute name

    unique : bool
        Should be `True` if the attribute is unique and therefore this
        should return only one value.  Otherwise, returns a list of
        values.

    iterator : generator
        A generator that iterates over some arbitrary set of elements

    element_name : str
        The XML element name of the elements being iterated over (used
        for error messages only).

    doc : str
        A docstring to apply to the generated function.

    Returns
    -------
    factory : function
        A function that looks up an element by the given attribute.
    Nc              3      K    t          |                       D ][}||u r<t          |d          |k    r$t           d|j        |j        t                      dS t          |d          |k    r|V  \dS )a/  
        Given a string *ref*, finds the first element in the iterator
        where the given attribute == *ref*.  If *before* is provided,
        will stop searching at the object *before*.  This is
        important, since "forward references" are not allowed in the
        VOTABLE format.
        N references itself)getattrrB   _config_posKeyError)selfrefbeforeelementattrelement_nameiterators       ra   lookup_by_attrz/_lookup_by_attr_factory.<locals>.lookup_by_attr   s       /wtX..00 	 	G&  7D$//366';;; 	   wd++s22	 	rc   c                 v     | ||          D ]}|c S t          d                    |                    )Nrm   z2No {} with {} '{}' found before the referencing {})rj   format)rk   rl   rm   rn   ro   rp   rr   s       ra   lookup_by_attr_uniquez6_lookup_by_attr_factory.<locals>.lookup_by_attr_unique   sZ    %~dC??? 	 	GNNN@GGdC 
 
 	
rc   N__doc__)ro   uniquerq   rp   docrv   rr   s   ` ``  @ra   _lookup_by_attr_factoryr|      s}    >       *
 
 
 
 
 
 
 
  (+%$$!$rc   c                 &     d fd	}||_         |S )z_
    Like `_lookup_by_attr_factory`, but looks in both the "ID" and
    "name" attributes.
    Nc                     t          |                       D ]P}||u r6||j        |j        fv r$t           d|j        |j        t                      n||j        |j        fv r|c S Qt          d                    |                    )a:  
        Given an key *ref*, finds the first element in the iterator
        with the attribute ID == *ref* or name == *ref*.  If *before*
        is provided, will stop searching at the object *before*.  This
        is important, since "forward references" are not allowed in
        the VOTABLE format.
        rf   z:No {} with ID or name '{}' found before the referencing {})rg   IDnamerB   rh   ri   rj   ru   )rk   rl   rm   rn   rp   rq   s       ra   lookup_by_id_or_namez;_lookup_by_id_or_name_factory.<locals>.lookup_by_id_or_name   s     /wtX..00 	 	G&  7:w|444';;; 	   wz7<000 1HOOc< 
 
 	
rc   rw   rx   )rq   rp   r{   r   s   ``  ra   _lookup_by_id_or_name_factoryr      s8    
 
 
 
 
 
 
4 $' rc   c                     | d         rdS dS )zG
    Get the default unit format as specified in the VOTable spec.
    version_1_4_or_latervounitcds )configs    ra   _get_default_unit_formatr      s     $% xurc   c                 `    |                      d          t          |           }n| d         }|S )z9
    Get the unit format based on the configuration.
    unit_format)getr   )r   ru   s     ra   _get_unit_formatr      s4     zz-  ()&11&Mrc   c                 v    | 6t          j        d|           !t          t          t          || f||           dS dS )a  
    Raises a `~astropy.io.votable.exceptions.VOTableSpecError` if
    *year* is not a valid astronomical year as defined by the VOTABLE
    standard.

    Parameters
    ----------
    year : str
        An astronomical year string

    field : str
        The name of the field this year was found in (used for error
        message)

    config, pos : optional
        Information about the source of the value
    Nz^[JB]?[0-9]+([.][0-9]*)?$FT)rematchrE   r    )yearfieldr   poss       ra   check_astroyearr   	  s@    $ BH%A4HHPc3vs;;;u4rc   c                 r    | 4t          | t                    st          t          t          |||           dS dS )a  
    Raises a `~astropy.io.votable.exceptions.VOTableSpecError` if
    *string* is not a string or Unicode string.

    Parameters
    ----------
    string : str
        An astronomical year string

    attr_name : str
        The name of the field this year was found in (used for error
        message)

    config, pos : optional
        Information about the source of the value
    NFT)
isinstancestrrE   r!   )string	attr_namer   r   s       ra   check_stringr   !  s9    " *VS"9"9c3	63777u4rc   c                 L    | !|t          t          t          d||           |S | S Nr   )rE   r"   )r   idr   r   s       ra   
resolve_idr   8  s+    	zbnc3FC000	Irc   c                    |i }|                     d          r	 t          j        | |                     dd          |                     dd                     n# t          $ r}|                     dd          dk    r't	          t
          | t          |          f||           nL|                     dd          d	k    r,t          t
          | t          |          f||           Y d}~dS Y d}~dS Y d}~nd}~ww xY wd
S )aK  
    Warns or raises a
    `~astropy.io.votable.exceptions.VOTableSpecError` if *ucd* is not
    a valid `unified content descriptor`_ string as defined by the
    VOTABLE standard.

    Parameters
    ----------
    ucd : str
        A UCD string.

    config, pos : optional
        Information about the source of the value
    Nversion_1_1_or_laterversion_1_2_or_laterF)check_controlled_vocabulary	has_colonverifyignore	exceptionwarnT)r   ucd_mod	parse_ucd
ValueErrorrB   r   r   rD   )r   r   r   es       ra   	check_ucdr   ?  s2    ~zz()) 	,2JJ7Mu,U,U **%;UCC    
  	 	 	zz(H--<<sCFFmVS9999Hh//699c3q66]FC888uuuuuuuuuu :9999	 4s   ?A 
C<%BC77C<c                   d    e Zd Zed             Zej        d             Zej        d             ZdS )_IDPropertyc                     | j         S )zn
        The XML ID_ of the element.  May be `None` or a string
        conforming to XML ID_ syntax.
        _IDrk   s    ra   r   z_IDProperty.IDf  s     xrc   c                 V    t          j        |d| j        | j                   || _        d S )Nr   )r   check_idrh   ri   r   rk   r   s     ra   r   z_IDProperty.IDn  s(    T4<;;;rc   c                     d | _         d S rw   r   r   s    ra   r   z_IDProperty.IDs  s    rc   N)__name__
__module____qualname__propertyr   setterdeleterr   rc   ra   r   r   e  sg          X Y  Y Z  Z  rc   r   c                   d    e Zd Zed             Zej        d             Zej        d             ZdS )_NamePropertyc                     | j         S )z!An optional name for the element._namer   s    ra   r   z_NameProperty.namey       zrc   c                 V    t          j        |d| j        | j                   || _        d S Nr   )r   check_tokenrh   ri   r   rk   r   s     ra   r   z_NameProperty.name~  s(    D&$,	BBB


rc   c                     d | _         d S rw   r   r   s    ra   r   z_NameProperty.name      


rc   N)r   r   r   r   r   r   r   r   rc   ra   r   r   x  sg          X 
[  [ 
\  \  rc   r   c                   d    e Zd Zed             Zej        d             Zej        d             ZdS )_XtypePropertyc                     | j         S )zExtended data type information._xtyper   s    ra   xtypez_XtypeProperty.xtype       {rc   c                     |I| j                             d          s/t          t          t          d| j        df| j         | j                   t          |d| j         | j                   || _        d S )Nr   r   1.2)rh   r   rE   r0   _element_nameri   r   r   )rk   r   s     ra   r   z_XtypeProperty.xtype  sn    T\%5%56L%M%MS7D$6>di   	UGT\49===rc   c                     d | _         d S rw   r   r   s    ra   r   z_XtypeProperty.xtype      rc   N)r   r   r   r   r   r   r   r   rc   ra   r   r     sg          X \  \ ]  ]  rc   r   c                   h    e Zd ZdZed             Zej        d             Zej        d             ZdS )_UtypePropertyFc                     | j         S )z4The usage-specific or `unique type`_ of the element._utyper   s    ra   utypez_UtypeProperty.utype  r   rc   c                     | j         rK|I| j                            d          s/t          t          t          d| j        df| j        | j                   t          |d| j        | j                   || _        d S )Nr   r   r   )	_utype_in_v1_2rh   r   rE   r0   r   ri   r   r   )rk   r   s     ra   r   z_UtypeProperty.utype  s     	!L$$%;<< " S7D$6>di   	UGT\49===rc   c                     d | _         d S rw   r   r   s    ra   r   z_UtypeProperty.utype  r   rc   N)r   r   r   r   r   r   r   r   r   rc   ra   r   r     sl        N  X \
 
 \
 ]  ]  rc   r   c                   h    e Zd ZdZed             Zej        d             Zej        d             ZdS )_UcdPropertyFc                     | j         S )z2The `unified content descriptor`_ for the element._ucdr   s    ra   r   z_UcdProperty.ucd       yrc   c                 &   ||                                 dk    rd }|k| j        rI| j                            d          s/t	          t
          t
          d| j        df| j        | j                   t          || j        | j                   || _	        d S )N r   r   r   )
strip_ucd_in_v1_2rh   r   rE   r0   r   ri   r   r   )rk   r   s     ra   r   z_UcdProperty.ucd  s    ?syy{{b00C?  )9)9:P)Q)Q D.6LI   c4<333			rc   c                     d | _         d S rw   r   r   s    ra   r   z_UcdProperty.ucd      			rc   N)r   r   r   r   r   r   r   r   r   rc   ra   r   r     sl        L  X 	Z  Z 	[  [  rc   r   c                   d    e Zd Zed             Zej        d             Zej        d             ZdS )_DescriptionPropertyc                     | j         S )zn
        An optional string describing the element.  Corresponds to the
        DESCRIPTION_ element.
        _descriptionr   s    ra   descriptionz _DescriptionProperty.description  s       rc   c                     || _         d S rw   r   )rk   r   s     ra   r   z _DescriptionProperty.description      'rc   c                     d | _         d S rw   r   r   s    ra   r   z _DescriptionProperty.description       rc   N)r   r   r   r   r   r   r   r   rc   ra   r   r     sk        ! ! X! ( ( ( ! ! ! ! !rc   r   c                   8    e Zd ZdZdZg Zd Zd Zd Zd Z	d Z
dS )	rU   z[
    A base class for all classes that represent XML elements in the
    VOTABLE file.
    r   c                 @    t          t          t          |||           d S rw   )rE   r#   rk   rq   tagdatar   r   s         ra   _add_unknown_tagzElement._add_unknown_tag  s    c3VS11111rc   c                 N    t          ||                                ||           d S rw   )rF   keysr   s         ra   _ignore_addzElement._ignore_add  s$    3		VS99999rc   c                     |                     d          rt          t          t          d||           t          ||                                ||           d S )Nr   r   )r   rE   r-   rF   r   r   s         ra   _add_definitionszElement._add_definitions  sO    ::,-- 	5#sB4443		VS99999rc   c                     t                      )a  
        For internal use. Parse the XML content of the children of the
        element.

        Parameters
        ----------
        iterator : xml iterable
            An iterator over XML elements as returned by
            `~astropy.utils.xml.iterparser.get_xml_iterator`.

        config : dict
            The configuration dictionary that affects how certain
            elements are read.

        Returns
        -------
        self : `~astropy.io.votable.tree.Element`
            Returns self as a convenience.
        NotImplementedError)rk   rq   r   s      ra   parsezElement.parse  s    ( "###rc   c                     t                      )a  
        For internal use. Output the element to XML.

        Parameters
        ----------
        w : astropy.utils.xml.writer.XMLWriter object
            An XML writer to write to.
        **kwargs : dict
            Any configuration parameters to control the output.
        r   rk   wkwargss      ra   to_xmlzElement.to_xml  s     "###rc   N)r   r   r   ry   r   
_attr_listr   r   r   r  r  r   rc   ra   rU   rU     su         
 MJ2 2 2: : :: : :
$ $ $,$ $ $ $ $rc   rU   c                   *    e Zd ZdZd Zd Zd Zd ZdS )SimpleElement
    A base class for simple elements, such as FIELD, PARAM and INFO
    that don't require any special parsing or outputting machinery.
    c                 :    t                               |            d S rw   )rU   __init__r   s    ra   r  zSimpleElement.__init__%  s    rc   c                     t          j                    }t                              | t	          |                     |                                                                S rw   )ioStringIOr
  r  r   getvaluer   rk   buffs     ra   __repr__zSimpleElement.__repr__(  sC    {}}T9T??333}}$$&&&rc   c                     |D ];\  }}}}|r%|| j         k    r|                     |||||           .|| j         k    r n<| S rw   )r   r   rk   rq   r   startr   r   r   s          ra   r  zSimpleElement.parse-  sm    %- 	 	!E3c  222%%hT63GGGG*** + rc   c                 p    |                     | j        |                    | | j                             d S Nattrib)rn   r   object_attrsr  r  s      ra   r  zSimpleElement.to_xml6  s1    			$$Q^^D$/-R-R	SSSSSrc   N)r   r   r   ry   r  r  r  r  r   rc   ra   r
  r
    s_         
  ' ' '
  T T T T Trc   r
  c                   z    e Zd ZdZd Zd Zd Zed             Zej	        d             Zej
        d             ZdS )	SimpleElementWithContentr  c                 H    t                               |            d | _        d S rw   )r
  r  _contentr   s    ra   r  z!SimpleElementWithContent.__init__@  s!    t$$$rc   c                     |D ]D\  }}}}|r%|| j         k    r|                     |||||           .|| j         k    r|r|| _         nE| S rw   )r   r   contentr  s          ra   r  zSimpleElementWithContent.parseE  s|    %- 	 	!E3c  222%%hT63GGGG*** (#'DL +
 rc   c                 |    |                     | j        | j        |                    | | j                             d S r  )rn   r   r   r  r  r  s      ra   r  zSimpleElementWithContent.to_xmlP  sE    			M>>$88 	 	
 	
 	
 	
 	
rc   c                     | j         S )zThe content of the element.r   r   s    ra   r"  z SimpleElementWithContent.contentW       }rc   c                 L    t          |d| j        | j                   || _        d S Nr"  r   rh   ri   r   rk   r"  s     ra   r"  z SimpleElementWithContent.content\  %    WityAAArc   c                     d | _         d S rw   r%  r   s    ra   r"  z SimpleElementWithContent.contenta      rc   N)r   r   r   ry   r  r  r  r   r"  r   r   r   rc   ra   r  r  :  s         
  
	 	 	
 
 
   X ^    ^  _  _  rc   r  c                   T   e Zd ZdZg dZdZ	 	 	 	 	 	 	 	 ddZed             Zej	        d             Zej
        d             Zed	             Zej	        d
             Zej
        d             Zed             Zej	        d             Zej
        d             Zd Zed             ZdS )rH   z
    LINK_ elements: used to reference external documents and servers through a URI.

    The keyword arguments correspond to setting members of the same
    name, documented below.
    )r   content_rolecontent_typetitlevaluehrefactionLINKNc	                    |i }|| _         || _        t                              |            |	                    d          p|	                    d          }
|	                    d          p|	                    d          }d|	v rt          t          t          d||           t          ||||          | _        |
| _	        || _
        || _        || _        || _        || _        t          d|	                                ||g d           d S )	Ncontent-roler/  content-typer0  grefr   r5  )r7  r/  r8  r0  r9  )rh   ri   r
  r  r   rE   r$   r   r   r/  r0  r1  r2  r3  r4  rF   r   )rk   r   r1  r2  r3  r4  r   r   r   r  r/  r0  s               ra   r  zLink.__init__y  s    >F	t$$$zz.11OVZZ5O5Ozz.11OVZZ5O5OV#sB444RVS11((

	KKMMTTT	
 	
 	
 	
 	
rc   c                     | j         S )zDefines the MIME role of the referenced object.

        Must be one of:

          None, 'query', 'hints', 'doc', 'location' or 'type'
        _content_roler   s    ra   r/  zLink.content_role  s     !!rc   c                     |dk    r| j         d         r|dvr"t          t          |f| j         | j                   || _        d S )Ntypeversion_1_3_or_later)Nqueryhintsr{   location)rh   rD   r=   ri   r<  )rk   r/  s     ra   r/  zLink.content_role  sP     F""4<8N+O"!LLLC,$,	BBB)rc   c                     d | _         d S rw   r;  r   s    ra   r/  zLink.content_role      !rc   c                     | j         S )z7Defines the MIME content type of the referenced object._content_typer   s    ra   r0  zLink.content_type  s     !!rc   c                 T    t          j        || j        | j                   || _        d S rw   )r   check_mime_content_typerh   ri   rG  )rk   r0  s     ra   r0  zLink.content_type  s)    'dlDINNN)rc   c                     d | _         d S rw   rF  r   s    ra   r0  zLink.content_type  rD  rc   c                     | j         S )zo
        A URI to an arbitrary protocol.  The vo package only supports
        http and anonymous ftp.
        _hrefr   s    ra   r3  z	Link.href       zrc   c                 T    t          j        || j        | j                   || _        d S rw   )r   check_anyurirh   ri   rM  )rk   r3  s     ra   r3  z	Link.href  s&    T4<;;;


rc   c                     d | _         d S rw   rL  r   s    ra   r3  z	Link.href  r   rc   c                     i }| j         D ]}t          | |d           }||||<   |j                            dg            |j        d                             |           d S )Nlinks)r  rg   meta
setdefaultappendrk   columnrT  keyvals        ra   to_table_columnzLink.to_table_column  sq    ? 	  	 C$T**CS	w+++G##D)))))rc   c                      | di |S r   r   )clsds     ra   from_table_columnzLink.from_table_column  s    sxxQxxrc   NNNNNNNN)r   r   r   ry   r  r   r  r   r/  r   r   r0  r3  r[  classmethodr_  r   rc   ra   rH   rH   f  s          J M '
 '
 '
 '
R " " X" * * * " " " " " X" * * * " " "   X 
[  [ 
\  \* * *   [  rc   rH   c                      e Zd ZdZdZg dZeg dz   ZdZ	 	 	 	 	 	 	 	 	 	 	 ddZe	d             Z
e
j        d	             Z
e	d
             Zej        d             Ze	d             Zej        d             Zej        d             Ze	d             Zej        d             Zej        d             Ze	d             Zej        d             Zej        d             Zd ZdS )rI   z
    INFO_ elements: arbitrary key-value pairs for extensions to the standard.

    The keyword arguments correspond to setting members of the same
    name, documented below.
    INFO)r   r   r2  )r   rl   unitr   r   TNc                    |
i }
|
| _         || _        t                              |            t	          |||
|          pt          j        ||
|          | _        || _        || _	        || _
        || _        || _        || _        |	| _        |
                    d          r| j        | _        nu| j        | _        |t'          ddg|
|           |t'          ddg|
|           |t'          ddg|
|           |t'          ddg|
|           |	t'          ddg|
|           t'          d|                                |
|           d S )Nr   rc  r   rl   rd  r   r   )rh   ri   r  r  r   r   fix_idr   r   r2  r   rl   rd  r   r   r   _attr_list_12r  _attr_list_11rF   r   )rk   r   r   r2  r   r   rl   rd  r   r   r   r   extras                ra   r  zInfo.__init__  sb    >F	 ))$///RVS11VW^D&RU5V5V	

	
::,-- 	C"0DOO"0DO "6G9fcBBB"6E7FC@@@"6F8VSAAA"6E7FC@@@ "6G9fcBBB65::<<=====rc   c                     | j         S )z+[*required*] The key of the key-value pair.r   r   s    ra   r   z	Info.name#  r   rc   c                     |'t          t          t          d| j        | j                   t	          j        |d| j        | j                   || _        d S r   )rE   r4   rh   ri   r   r   r   r   s     ra   r   z	Info.name(  sG    <#sFDL$)DDDD&$,	BBB


rc   c                     | j         S )zw
        [*required*] The value of the key-value pair.  (Always stored
        as a string or unicode string).
        _valuer   s    ra   r2  z
Info.value/       {rc   c                     |'t          t          t          d| j        | j                   t	          |d| j        | j                   || _        d S )Nr2  )rE   r4   rh   ri   r   rn  rk   r2  s     ra   r2  z
Info.value7  sD    =#sGT\49EEEUGT\49===rc   c                     | j         S )z$The content inside the INFO element.r%  r   s    ra   r"  zInfo.content>  r&  rc   c                 L    t          |d| j        | j                   || _        d S r(  r)  r*  s     ra   r"  zInfo.contentC  r+  rc   c                     d | _         d S rw   r%  r   s    ra   r"  zInfo.contentH  r-  rc   c                     | j         S )zd
        Refer to another INFO_ element by ID_, defined previously in
        the document.
        _refr   s    ra   rl   zInfo.refL       yrc   c                     |A| j                             d          s't          t          t          d| j         | j                   t          j        |d| j         | j                   || _        d S )Nr   )rl   rc  r   rl   )rh   r   rE   r0   ri   r   r   rw  rk   rl   s     ra   rl   zInfo.refT  s_    ?4<#3#34J#K#K?#s$:DL$)TTTeT\49===  			rc   c                     d | _         d S rw   rv  r   s    ra   rl   zInfo.refj  r   rc   c                     | j         S )z-A string specifying the units_ for the INFO_._unitr   s    ra   rd  z	Info.unitn  r   rc   c                    |	d | _         d S ddlm} | j                            d          s't          t          t          d| j        | j                   t          | j                  }|	                    ||d          }t          ||j                  r(t          t          t          |f| j        | j                   t          | j                  }||k    r|	                    ||d          }|| _         d S )Nr   unitsr   )rd  rc  r   silentru   parse_strict)r~  astropyr  rh   r   rE   r0   ri   r   Unitr   UnrecognizedUnitr>   r   rk   rd  udefault_formatunit_objru   s         ra   rd  z	Info.units  s    <DJF&&&&&&| 677 	V#s$;T\49UUU 2$,??66$~H6MMh 233 	F#sTGT\49EEE!$,//^##vvd6vIIH


rc   c                     d | _         d S rw   r}  r   s    ra   rd  z	Info.unit  r   rc   c                     |                     | | j                  }d|v r| j                            d          |d<   |                    | j        | j        |           d S )Nrd  r   r  )r  r  rd  	to_stringrn   r   r   )rk   r  r  r  s       ra   r  zInfo.to_xml  s^    do66V!Y0077F6N			$$dmF	CCCCCrc   )NNNNNNNNNNN)r   r   r   ry   r   rh  rg  r   r  r   r   r   r2  r"  r   rl   rd  r  r   rc   ra   rI   rI     s         M+++M!$L$L$LLMN .> .> .> .>`   X 
[  [   X \  \   X ^    ^  _  _   X 	Z  Z* 	[  [   X 
[  [. 
\  \D D D D Drc   rI   c                      e Zd ZdZ	 	 	 	 	 	 	 d dZd Zed             Zej        d             Zej	        d             Zed	             Z
e
j        d
             Z
ed             Zej        d             Zej	        d             Zed             Zej        d             Zej	        d             Zed             Zej        d             Zej	        d             Zed             Zej        d             Zej	        d             Zed             Zej        d             Zej	        d             Zed             Zd Zd Zd Zd Zd ZdS )!rJ   z
    VALUES_ element: used within FIELD_ and PARAM_ elements to define the domain of values.

    The keyword arguments correspond to setting members of the same
    name, documented below.
    Nlegalc
                 `   |i }|| _         |	| _        t                              |            || _        || _        t          ||||	          | _        || _        || _	        || _
        d | _        d | _        d| _        d| _        g | _        t!          d|
                                ||	           d S )NTVALUES)rh   ri   rU   r  _votable_fieldr   r   nullrw  r>  r[   maxmin_inclusivemax_inclusive_optionsrF   r   )rk   votabler   r   r  rl   r>  r   r   r   extrass              ra   r  zValues.__init__  s     >F	RVS11			!!8V[[]]FC@@@@@rc   c                     t          j                    }|                     t          |                     |                                                                S rw   )r  r  r  r   r  r   r  s     ra   r  zValues.__repr__  s?    {}}IdOO$$$}}$$&&&rc   c                     | j         S )zm
        For integral datatypes, *null* is used to define the value
        used for missing values.
        _nullr   s    ra   r  zValues.null  rN  rc   c                 |   |t          |t                    r	 | j        j                            || j        | j                  d         }nj# t          $ r[ t          t          t          || j        | j                   | j        j                            d| j        | j                  d         }Y nw xY w|}|| _
        d S )Nr   0)r   r   r  	converterparse_scalarrh   ri   	ExceptionrE   r5   r  )rk   r  null_vals      ra   r  zValues.null  s    
4 5 5;0==$,	     c3dlDIFFF;0==ty  H


s   1A A"B0/B0c                     d | _         d S rw   r  r   s    ra   r  zValues.null  r   rc   c                     | j         S )al  Defines the applicability of the domain defined by this VALUES_ element [*required*].

        Must be one of the following strings:

          - 'legal': The domain of this column applies in general to
            this datatype. (default)

          - 'actual': The domain of this column applies only to the
            data enclosed in the parent table.
        _typer   s    ra   r>  zValues.type       zrc   c                 ^    |dvr!t          t          || j        | j                   || _        d S )N)r  actual)rB   r   rh   ri   r  rk   r>  s     ra   r>  zValues.type  1    ***S$di888


rc   c                     | j         S )z
        Refer to another VALUES_ element by ID_, defined previously in
        the document, for MIN/MAX/OPTION information.
        rv  r   s    ra   rl   z
Values.ref  rx  rc   c                    t          j        |d| j        | j                   |	 | j                            ||           }|j        | _        |j        | _        |j        | _        |j	        | _	        |j
        | _
        |j        | _        |j        | j        d d <   n@# t          $ r3 t          t           t           d| j        f| j        | j                   d }Y nw xY w|| _        d S )Nrl   rt   r  )r   r   rh   ri   r  get_values_by_idr  r>  r[   r  r  r  optionsr  rj   rE   r;   rl   rw  )rk   rl   others      ra   rl   z
Values.ref  s    eT\49===?166s46HH
 "J	!J	 9%*%8" 9%*%8"#(=aaa      c348(<dlDIVVV 			s   B :CCc                     d | _         d S rw   rv  r   s    ra   rl   z
Values.ref  r   rc   c                     | j         S )zN
        The minimum value of the domain.  See :attr:`min_inclusive`.
        _minr   s    ra   r[   z
Values.min      
 yrc   c                     t          | j        d          r.|,| j        j                            |          d         | _        d S || _        d S Nr  r   )hasattrr  r  r  r  )rk   r[   s     ra   r[   z
Values.min  H    4;,, 	-33C88;DIIIDIIIrc   c                     d | _         d S rw   r  r   s    ra   r[   z
Values.min#  r   rc   c                     | j         S )z3When `True`, the domain includes the minimum value._min_inclusiver   s    ra   r  zValues.min_inclusive'       ""rc   c                 j    |dk    r	d| _         d S |dk    r	d| _         d S t          |          | _         d S NyesTnoF)r  boolrk   	inclusives     ra   r  zValues.min_inclusive,  H    "&D$"'D"&y//Drc   c                     d| _         d S NTr  r   s    ra   r  zValues.min_inclusive5      "rc   c                     | j         S )zN
        The maximum value of the domain.  See :attr:`max_inclusive`.
        _maxr   s    ra   r  z
Values.max9  r  rc   c                     t          | j        d          r.|,| j        j                            |          d         | _        d S || _        d S r  )r  r  r  r  r  )rk   r  s     ra   r  z
Values.max@  r  rc   c                     d | _         d S rw   r  r   s    ra   r  z
Values.maxG  r   rc   c                     | j         S )z3When `True`, the domain includes the maximum value._max_inclusiver   s    ra   r  zValues.max_inclusiveK  r  rc   c                 j    |dk    r	d| _         d S |dk    r	d| _         d S t          |          | _         d S r  )r  r  r  s     ra   r  zValues.max_inclusiveP  r  rc   c                     d| _         d S r  r  r   s    ra   r  zValues.max_inclusiveY  r  rc   c                     | j         S )z
        A list of string key-value tuples defining other OPTION
        elements for the domain.  All options are ignored -- they are
        stored for round-tripping purposes only.
        )r  r   s    ra   r  zValues.options]       }rc   c           	         | j         O|D ]J\  }}}}|rt          t          t          |||           '|dk    rt          t          t          |||            n|D ]\  }}}}|r|dk    rkd|vrt          t          d||           |d         | _        |                    dd          | _        t          d|	                                ||ddg           ||dk    rkd|vrt          t          d||           |d         | _
        |                    dd          | _        t          d|	                                ||ddg           |dk    rd|vrt          t          d||           t          j        |                    d          d||           | j                            |                    d          |                    d          f           t          d|	                                ||ddg           |dk    r n| S )	Nr  MINr2  r  r  MAXOPTIONr   )rl   rE   r<   rB   r   r[   r   r  rF   r   r  r  r   r   r  rV  r  s          ra   r  zValues.parsef  s?   8)1  %sD# !#sC====h%c3VSAAA)1  %sD# e||"$..$S%===#'=-1XXk5-I-I**!499;;g{=S    "$..$S%===#'=-1XXk5-I-I**!499;;g{=S    "$..$S(FC@@@+DHHV,<,<ffcRRR++TXXf-=-=txx?P?P,QRRR*$diikk63&@Q   H__E % rc   c                 r    | j         du o.| j        du o%| j        du o| j        du o| j        du o
| j        g k    S )zg
        Are the settings on this ``VALUE`` element all the same as the
        XML defaults?.
        N)rl   r  r   r  r[   r  r   s    ra   is_defaultszValues.is_defaults  sc     H #	T!#4# D # D 	#
 "	
rc   c                    d }|                                  rd S | j        .|                    d|                    | dg                     d S |                    d|                    | g d                    5  | j        I|                    d| j        j                            | j        d           || j	                             | j
        I|                    d	| j        j                            | j
        d           || j                             | j        D ]\  }}|                    d
||           	 d d d            d S # 1 swxY w Y   d S )Nc                     | rdS dS )Nr  r  r   )r2  s    ra   yes_nozValues.to_xml.<locals>.yes_no  s     u4rc   r  rl   r  )r   r  rl   r  Fr2  r  r  r  )r   r2  )r  rl   rn   r  r   r[   r  r  outputr  r  r  r  )rk   r  r  r  r   r2  s         ra   r  zValues.to_xml  s   	 	 	
  	F8IIhq~~dUG'D'DIEEEEExt=R=R=R(S(STT @ @8'II"k3::48UKK"(&);"<"<    
 8'II"k3::48UKK"(&);"<"<    
 $(< @ @KD%IIhTI????@@ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @s   <CEEEc                    i }dD ]}t          | |d           }||||<   | j        | j        | j        d|d<   | j        | j        | j        d|d<   t          | j                  rt          | j                  |d<   ||j        d<   d S )Nr   r  r  r[   r  r  values)	rg   r[   r  r  r  r\   r  dictrT  rW  s        ra   r[  zValues.to_table_column  s    ! 	  	 C$T**CS	8$(H4;MNNDK8$(H4;MNNDKt| 	1"4<00DO $Hrc   c                    |j         j        d|j         j        vrd S |j         j        d         }dD ]+}|                    |d           }|t          | ||           ,d|v r&|d         d         | _        |d         d         | _        d|v r&|d         d         | _        |d         d         | _        d|v r.t          |d         	                                          | _
        d S d S )Nr  r  r[   r2  r  r  r  )inforT  r   setattrr[   r  r  r  listitemsr  rW  s        ra   r_  zValues.from_table_column  s    ;#xv{7G'G'GF{)! 	( 	(C((3%%Cc3'''D==E{7+DH!%e[!9DD==E{7+DH!%e[!9D i!6!6!8!899DMMM rc   )NNNr  NNN)r   r   r   ry   r  r  r   r  r   r   r>  rl   r[   r  r  r  r  r  r  r  r[  r_  r   rc   ra   rJ   rJ     s         !A !A !A !AF' ' '
   X 
[  [ 
\  \   X 
[  [
   X 	Z  Z$ 	[  [   X 	Z  Z 	[  [ # # X# 2 2 2 # # #   X 	Z  Z 	[  [ # # X# 2 2 2 # # #   X' ' 'R
 
 
 @ @ @8% % % : : : : :rc   rJ   c                   :   e Zd ZdZg dZedgz   ZdZ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d%dZed             Z	d Z
ed	             Zej        d
             Zed             Zej        d             Zej        d             Zed             Zej        d             Zej        d             Zed             Zej        d             Zej        d             Zed             Zej        d             Zej        d             Zed             Zej        d             Zej        d             Zed             Zej        d             Zej        d             Zed             Zej        d             Zej        d             Zed              Zd! Zd" Zd# Zed$             ZdS )&rK   a  
    FIELD_ element: describes the datatype of a particular column of data.

    The keyword arguments correspond to setting members of the same
    name, documented below.

    If *ID* is provided, it is used for the column name in the
    resulting recarray of the table.  If no *ID* is provided, *name*
    is used instead.  If neither is provided, an exception will be
    raised.
    )
r   r   datatype	arraysizer   rd  width	precisionr   rl   r   FIELDNc           
         |'t          |d          r|                                }ni }|| _        || _        t                              |            |                    d          r| j        | _        n&| j	        | _        |t          | j        dg||           |                    dd          dk    r3|dk    r-|dk    r'|dk    r!|d	k    rd
}d}t          t          d||           d | _        || _        t!          ||||          pt#          j        |||          | _        || _        |O| j        dk    r|                    d          sn"t+          t,          t,          | j        ||           | j        | _        | j        |t1          t2          | j        ||           d
dddddd	ddd	}|                    |                    di                      ||v r-t+          t6          t6          |||         f||           ||         }|| _        || _        || _        || _        || _         || _!        |	| _"        |
| _#        || _$        tK          tL                    | _'        | j        | _(        tS          | j        |           | _*        || _+        | ,                    ||           t          | j        |-                                ||           d S )N_get_version_checksr   r   r   r   r   cprojectionzVOX:WCS_CoordProjectiondoublechar3r   PARAMr   unicodeCharshortintlongfloat)	r   unicodeStringint16int32int64float32float64unsignedIntunsignedShortdatatype_mapping).r  r  rh   ri   r
  r  r   rg  r  rh  rF   r   rD   r8   r   r  r   r   rf  r   r   rE   r'   r   rB   r%   updater&   rl   r  r  r   rd  r  r  r   r>  r   rH   _linksr1  rJ   r  r   _setupr   )rk   r  r   r   r  r  r   rd  r  r  r   rl   r>  r   r   r   r   ri  r  s                      ra   r  zField.__init__  s   ( >w 566  4466	t$$$::,-- 	O"0DOO"0DO "4#5y&#NNN JJx**k99%%m##000H$$HICVS)))  RVS11VW^D&RU5V5V	<!W,,VZZ@V5W5W,c3(:FCHHHDI8S$,fc::: *!"
 
 	

+=r B BCCC'''#sX/?/I$JFTWXXX'1H "	
"
	%d++Y
T]D11
FC   4-uzz||VSIIIIIrc   c                    i }|D ]j}d}|j         }||v r|j         d|dz   }|dz  }||v ||j         k    r(t          t          |j         |f|j        |j                   ||_         |j         ||<   k|D ]}d}|j        
|j         }d}n	|j        }d}||j         k    r||v r|j        d|dz   }|dz  }||v |s3||j        k    r(t          t          |j        |f|j        |j                   ||_        |j        ||<   dS )	z
        Make sure that all names and titles in a list of fields are
        unique, by appending numbers if necessary.
           _r^  r	   NTF )r   rD   r2   rh   ri   r   r3   _unique_name)r]  fieldsrz   r   inew_idnew_nameimplicits           ra   uniqify_nameszField.uniqify_namesm  sj     		& 		&EAXFF""IIII-Q F"" !!eh/
KKKEH"XF6NN 	* 	*EAz! 8 : 58##&(($zIIII5HFA &((  PEJ 6 6ej(3U]EJOOO!)E$zF8!	* 	*rc   c                     | j         j        | j         j        | j         _        t          j        | ||          | _        d S rw   )r  rw  rl   r
   get_converterr  rk   r   r   s      ra   r
  zField._setup  s5    ;'"k.DKO#1$DDrc   c                     | j         S )a  The datatype of the column [*required*].

        Valid values (as defined by the spec) are:

          'boolean', 'bit', 'unsignedByte', 'short', 'int', 'long',
          'char', 'unicodeChar', 'float', 'double', 'floatComplex', or
          'doubleComplex'

        Many VOTABLE files in the wild use 'string' instead of 'char',
        so that is also a valid option, though 'string' will always be
        converted to 'char' when writing the file back out.
        )	_datatyper   s    ra   r  zField.datatype  s     ~rc   c                    |H| j                             d          r,t          t          t          | j        | j         | j                   d}|t          j        vr(t          t          || j
        f| j         | j                   || _        d S )Nr   r  )rh   r   rE   r   r   ri   r
   converter_mappingrB   r   r   r  )rk   r  s     ra   r  zField.datatype  s|    | 677 Uc3(:DL$)TTTH:777S8TW-t|TYGGG!rc   c                     | j         S )am  
        Along with :attr:`width`, defines the `numerical accuracy`_
        associated with the data.  These values are used to limit the
        precision when writing floating point values back to the XML
        file.  Otherwise, it is purely informational -- the Numpy
        recarray containing the data itself does not use this
        information.
        
_precisionr   s    ra   r  zField.precision  s     rc   c                     |6t          j        d|          s!t          t          || j        | j                   || _        d S )Nz^[FE]?[0-9]+$)r   r   rB   r   rh   ri   r  )rk   r  s     ra   r  zField.precision  s=     2BI)N)N S)T\49===#rc   c                     d | _         d S rw   r  r   s    ra   r  zField.precision      rc   c                     | j         S )aq  
        Along with :attr:`precision`, defines the `numerical
        accuracy`_ associated with the data.  These values are used to
        limit the precision when writing floating point values back to
        the XML file.  Otherwise, it is purely informational -- the
        Numpy recarray containing the data itself does not use this
        information.
        _widthr   s    ra   r  zField.width  s     {rc   c                     |6t          |          }|dk    r!t          t          || j        | j                   || _        d S )Nr   )r  rB   r   rh   ri   r%  )rk   r  s     ra   r  zField.width  s?    JJEzzeT\49===rc   c                     d | _         d S rw   r$  r   s    ra   r  zField.width  r   rc   c                     | j         S )z
        On FIELD_ elements, ref is used only for informational
        purposes, for example to refer to a COOSYS_ or TIMESYS_ element.
        rv  r   s    ra   rl   z	Field.ref  rx  rc   c                 V    t          j        |d| j        | j                   || _        d S Nrl   r   r   rh   ri   rw  rz  s     ra   rl   z	Field.ref  (    eT\49===			rc   c                     d | _         d S rw   rv  r   s    ra   rl   z	Field.ref  r   rc   c                     | j         S )z.A string specifying the units_ for the FIELD_.r}  r   s    ra   rd  z
Field.unit  r   rc   c                 l   |	d | _         d S ddlm} t          | j                  }|                    ||d          }t          ||j                  r(t          t          t          |f| j        | j
                   t          | j                  }||k    r|                    ||d          }|| _         d S )Nr   r  r  r  )r~  r  r  r   rh   r  r   r  rE   r>   ri   r   r  s         ra   rd  z
Field.unit  s    <DJF&&&&&& 2$,??66$~H6MMh 233 	F#sTGT\49EEE!$,//^##vvd6vIIH


rc   c                     d | _         d S rw   r}  r   s    ra   rd  z
Field.unit  r   rc   c                     | j         S )z
        Specifies the size of the multidimensional array if this
        FIELD_ contains more than a single value.

        See `multidimensional arrays`_.
        
_arraysizer   s    ra   r  zField.arraysize  s     rc   c                     |6t          j        d|          s!t          t          || j        | j                   || _        d S )Nz^([0-9]+x)*[0-9]*[*]?(s\W)?$)r   r   rB   r   rh   ri   r3  )rk   r  s     ra   r  zField.arraysize  sC     +Y*
 *
  S)T\49===#rc   c                     d | _         d S rw   r2  r   s    ra   r  zField.arraysize"  r"  rc   c                     | j         S )zb
        The type attribute on FIELD_ elements is reserved for future
        extensions.
        r  r   s    ra   r>  z
Field.type&  rN  rc   c                     || _         d S rw   r  r  s     ra   r>  z
Field.type.  r   rc   c                     d | _         d S rw   r  r   s    ra   r>  z
Field.type2  r   rc   c                     | j         S )zc
        A :class:`Values` instance (or `None`) defining the domain
        of the column.
        _valuesr   s    ra   r  zField.values6       |rc   c                 F    |t          |t                    sJ || _        d S rw   )r   rJ   r;  )rk   r  s     ra   r  zField.values>  s$    ~FF!;!;~~~rc   c                     d | _         d S rw   r:  r   s    ra   r  zField.valuesC      rc   c                     | j         S )z
        A list of :class:`Link` instances used to reference more
        details about the meaning of the FIELD_.  This is purely
        informational and is not used by the `astropy.io.votable`
        package.
        r	  r   s    ra   rS  zField.linksG  s     {rc   c                 "   |D ]%\  }}}}|r|dk    r8 | j         j        | j        | f||d| | j                             ||           H|dk    r@t	          d||d|}| j                            |           |                    ||           |dk    r%t          d|                                ||           || j	        k    r| 
                    |||||           |dk    r4| j        "t          t          t          | j	        ||           |pd | _        || j	        k    r n'| j        <d                    d | j                                        D                       | _        n| j        | _        |                     ||           | S )Nr  r   r   r5  DESCRIPTIONr  c              3   >   K   | ]}|                                 V  d S rw   )r   .0xs     ra   	<genexpr>zField.parse.<locals>.<genexpr>j  s*      !S!S!''))!S!S!S!S!S!Src   r   )r  r  r  r  rH   rS  rV  rF   r   r   r   r   rE   r(   join
splitlinesr1  r   r
  )rk   rq   r   r  r   r   r   links           ra   r  zField.parseQ  s   %- 	 	!E3c (??(DK(t4: GK   K%%h7777F]]?v3??$??DJ%%d+++JJx0000M))&}diikk63OOOOD...))(CvsKKK-'''3%c30BFCPPP'+|tD$$D...E / '!S!ST5E5P5P5R5R!S!S!SSSDJJDJFC   rc   c                    |                     | | j                  }d|v r| j                            d          |d<   |                    | j        |          5  | j        |                    d| j        d           | j        	                                s | j        j
        |fi | | j        D ]} |j
        |fi | 	 d d d            d S # 1 swxY w Y   d S )Nrd  r   r  rD  Twrap)r  r  rd  r  r   r   r   rn   r  r  r  rS  )rk   r  r  r  rL  s        ra   r  zField.to_xmlr  sB   do66V!Y0077F6NUU4%fU55 	) 	)+		-)9	EEE;**,, 0""1/////
 ) )A(((((()	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)s   A)CCCc                 ~   dD ]}t          | |d          }|
||j        |<    | j                                        s| j                            |           | j        D ]}|                    |           | j        | j        |_        | j        | j        |_        t          | j	        t          j                  r#| j	        j        dk    r| j	        j        |_        dS t          | j	        t          j                  rd|j        j        d<   dS t          | j	        t          j                  rd|j        j        d<   dS dS )z
        Sets the attributes of a given `astropy.table.Column` instance
        to match the information in this `Field`.
        r   r  r  r   r   Nz{!r:>}r  _votable_string_dtyper  )rg   rT  r  r  r[  rS  r   rd  r   r  r
   FloatingPointoutput_formatru   Charr  UnicodeChar)rk   rX  rY  rZ  rL  s        ra   r[  zField.to_table_column~  sO   
 C 	' 	'C$T**C#&C {&&(( 	0K''///J 	) 	)D  (((('!%!1F9 )FKt~z'?@@	F,88 N8FMMM
88 	F8>FK4555
(>?? 	F8EFK4555	F 	Frc   c                    i }|j         j        }|r"dD ]}|                    |d          }||||<    |j         j        |j         j        |d<   |j         j        |d<   t          j        |          }|                    |            | |fi |}|j         j        |j         j        |_        |j	        
                    |           |rAd|v r=|d         D ]4}	|j                            t          
                    |	                     5|S )zc
        Restores a `Field` instance from a given
        `astropy.table.Column` instance.
        rQ  Nrd  r   rS  )r  rT  r   rd  r   r
    table_column_to_votable_datatyper  r   r  r_  rS  rV  rH   )
r]  r  rX  r  rT  rY  rZ  resultr   rL  s
             ra   r_  zField.from_table_column  s.    { 	&F & &hhsD))?"%F3K;'#[-F6N)v<VDDfG&&v&&;". & 7E&&v... 	AGtOOW A A""4#9#9$#?#?@@@@ rc   )NNNNNNNNNNNNNNN)r   r   r   ry   rh  rg  r   r  ra  r  r
  r   r  r   r  r   r  rl   rd  r  r>  r  rS  r  r  r[  r_  r   rc   ra   rK   rK     s       
 
  M "WI-MM
 #jJ jJ jJ jJX !* !* [!*FE E E
   X _" " _" 	 	 X	 $ $ $
    	 	 X	 \  \ ]  ]   X 	Z  Z 	[  [   X 
[  [( 
\  \   X $ $ $      X 
[  [ 
\  \   X ]  ] ^  ^   X  B
) 
) 
)F F F8   [  rc   rK   c                       e Zd ZdZej        dgz   Zej        dgz   ZdZ	 	 	 	 	 	 	 	 	 	 	 	 	 	 d
dZe	d             Z
e
j        d             Z
d Zd	 ZdS )rL   z
    PARAM_ element: constant-valued columns in the data.

    :class:`Param` objects are a subclass of :class:`Field`, and have
    all of its methods and members.  Additionally, it defines :attr:`value`.
    r2  r  Nc                 T    || _         t          j        | |f|||||||
|||||d| d S )N)r   r   r  r  r   rd  r  r   r>  r   r   r   )rn  rK   r  )rk   r  r   r   r2  r  r  r   rd  r  r  r   r>  r   r   r   ri  s                    ra   r  zParam.__init__  si    & 	
 	
 	
 	
 	
 	
 	
 	
rc   c                     | j         S )z
        [*required*] The constant value of the parameter.  Its type is
        determined by the :attr:`~Field.datatype` member.
        rm  r   s    ra   r2  zParam.value  ro  rc   c                     |d}t          |t                    r3| j                            || j        | j                  d         | _        d S || _        d S )Nr   r   )r   r   r  r  rh   ri   rn  rq  s     ra   r2  zParam.value  sQ    =EeS!! 	 ...udlDINNqQDKKKDKKKrc   c                 V    t                               | ||           | j        | _        d S rw   )rK   r
  rn  r2  r  s      ra   r
  zParam._setup  s%    T63'''[


rc   c                     | j         }| j                            |d          | _         | j         d| _         t          j        | |fi | || _         d S )NFr   )rn  r  r  rK   r  )rk   r  r  	tmp_values       ra   r  zParam.to_xml  sV    K	n++Iu==;DKT1'''''rc   )NNNNNNNNNNNNNN)r   r   r   ry   rK   rh  rg  r   r  r   r2  r   r
  r  r   rc   ra   rL   rL     s          '7)3M'7)3MM
 !$
 $
 $
 $
L   X \    \ ! ! !         rc   rL   c                   l   e Zd ZdZg dZdZ	 	 	 	 	 	 	 ddZed             Zej	        d             Zed             Z
e
j	        d	             Z
e
j        d
             Z
ed             Zej	        d             Zej        d             Zed             Zej	        d             Zej        d             ZdS )rM   z
    COOSYS_ element: defines a coordinate system.

    The keyword arguments correspond to setting members of the same
    name, documented below.
    )r   equinoxepochsystemCOOSYSNc                    |i }|| _         || _        |                    d          r2|                    d          st          t          t          d||           t
                              |            t          ||||          | _        || _	        || _
        || _        t          d|                                ||           d S )Nr   r?  r   re  )rh   ri   r   rE   r/   r
  r  r   r   rb  rc  rd  rF   r   )	rk   r   rb  rc  rd  r   r   r   ri  s	            ra   r  zCooSys.__init__  s     >F	 ::,-- 	5fjj"7
 7
 	5 #sB444t$$$RVS11
8UZZ\\63?????rc   c                     | j         S )z
        [*required*] The XML ID of the COOSYS_ element, used for
        cross-referencing.  May be `None` or a string conforming to
        XML ID_ syntax.
        r   r   s    ra   r   z	CooSys.ID6       xrc   c                     | j                             d          r#|!t          t          d| j         | j                   t          j        |d| j         | j                   || _        d S )Nr   r   r   )rh   r   rB   r   ri   r   r   r   r   s     ra   r   z	CooSys.ID?  s^    <233 	;zb$,	:::T4<;;;rc   c                     | j         S )zSpecifies the type of coordinate system.

        Valid choices are:

          'eq_FK4', 'eq_FK5', 'ICRS', 'ecl_FK4', 'ecl_FK5', 'galactic',
          'supergalactic', 'xy', 'barycentric', or 'geo_app'
        _systemr   s    ra   rd  zCooSys.systemG  s     |rc   c                 j    |dvr't          t          t          || j        | j                   || _        d S )N)
eq_FK4eq_FK5ICRSecl_FK4ecl_FK5galacticsupergalacticxybarycentricgeo_app)rE   r   rh   ri   rl  )rk   rd  s     ra   rd  zCooSys.systemR  s;     
 
 
 #sFDL$)DDDrc   c                     d | _         d S rw   rk  r   s    ra   rd  zCooSys.systemc  r?  rc   c                     | j         S )z
        A parameter required to fix the equatorial or ecliptic systems
        (as e.g. "J2000" as the default "eq_FK5" or "B1950" as the
        default "eq_FK4").
        _equinoxr   s    ra   rb  zCooSys.equinoxg  r  rc   c                 L    t          |d| j        | j                   || _        d S )Nrb  )r   rh   ri   r{  )rk   rb  s     ra   rb  zCooSys.equinoxp  s%    DL$)DDDrc   c                     d | _         d S rw   rz  r   s    ra   rb  zCooSys.equinoxu  r-  rc   c                     | j         S )zu
        Specifies the epoch of the positions.  It must be a string
        specifying an astronomical year.
        _epochr   s    ra   rc  zCooSys.epochy  ro  rc   c                 L    t          |d| j        | j                   || _        d S )Nrc  )r   rh   ri   r  )rk   rc  s     ra   rc  zCooSys.epoch  s%    wdi@@@rc   c                     d | _         d S rw   r  r   s    ra   rc  zCooSys.epoch  r   rc   NNNNNNN)r   r   r   ry   r  r   r  r   r   r   rd  r   rb  rc  r   rc   ra   rM   rM     s         655JM @ @ @ @>   X Y  Y   X ]  ]  ^  ^   X ^    ^  _  _   X \  \ ]  ]  rc   rM   c                   l   e Zd ZdZg dZdZ	 	 	 	 	 	 	 ddZed             Zej	        d             Zed             Z
e
j	        d	             Z
e
j        d
             Z
ed             Zej	        d             Zej        d             Zed             Zej	        d             Zej        d             ZdS )rN   z
    TIMESYS_ element: defines a time system.

    The keyword arguments correspond to setting members of the same
    name, documented below.
    r   
timeorigin	timescalerefpositionTIMESYSNc                 Z   |i }|| _         || _        |d         s#t          t          t          |d         ||           t                              |            t          ||||          | _        || _        || _	        || _
        t          d|                                ||g d           d S )Nr   versionr  r  )rh   ri   rE   rA   r
  r  r   r   r  r  r  rF   r   )	rk   r   r  r  r  r   r   r   ri  s	            ra   r  zTimeSys.__init__  s     >F	 ,- 	D#sF9$5vsCCCt$$$RVS11$"&JJLL<<<	
 	
 	
 	
 	
rc   c                     | j         S )z
        [*required*] The XML ID of the TIMESYS_ element, used for
        cross-referencing.  Must be a string conforming to
        XML ID_ syntax.
        r   r   s    ra   r   z
TimeSys.ID  rh  rc   c                     |!t          t          d| j        | j                   t	          j        |d| j        | j                   || _        d S )Nr   r   )rB   r   rh   ri   r   r   r   r   s     ra   r   z
TimeSys.ID  sE    :S"dlDI666T4<;;;rc   c                     | j         S )u  
        Specifies the time origin of the time coordinate,
        given as a Julian Date for the the time scale and
        reference point defined. It is usually given as a
        floating point literal; for convenience, the magic
        strings "MJD-origin" (standing for 2400000.5) and
        "JD-origin" (standing for 0) are also allowed.

        The timeorigin attribute MUST be given unless the
        time’s representation contains a year of a calendar
        era, in which case it MUST NOT be present. In VOTables,
        these representations currently are Gregorian calendar
        years with xtype="timestamp", or years in the Julian
        or Besselian calendar when a column has yr, a, or Ba as
        its unit and no time origin is given.
        _timeoriginr   s    ra   r  zTimeSys.timeorigin  s    $ rc   c                     |T|dk    rN|dk    rH	 t          |          }n7# t          $ r* t          t          t          || j        | j                   Y nw xY w|| _        d S )Nz
MJD-originz	JD-origin)r  r   rE   r   rh   ri   r  )rk   r  s     ra   r  zTimeSys.timeorigin  s     "l**k))M":..

 M M Mc3
DL$)LLLLLM%s     1AAc                     d | _         d S rw   r  r   s    ra   r  zTimeSys.timeorigin  s    rc   c                     | j         S )z
        [*required*] String specifying the time scale used. Values
        should be taken from the IVOA timescale vocabulary (documented
        at http://www.ivoa.net/rdf/timescale).
        
_timescaler   s    ra   r  zTimeSys.timescale  s     rc   c                     || _         d S rw   r  )rk   r  s     ra   r  zTimeSys.timescale  s    #rc   c                     d | _         d S rw   r  r   s    ra   r  zTimeSys.timescale  r"  rc   c                     | j         S )z
        [*required*] String specifying the reference position. Values
        should be taken from the IVOA refposition vocabulary (documented
        at http://www.ivoa.net/rdf/refposition).
        _refpositionr   s    ra   r  zTimeSys.refposition  s       rc   c                     || _         d S rw   r  )rk   r  s     ra   r  zTimeSys.refposition  r   rc   c                     d | _         d S rw   r  r   s    ra   r  zTimeSys.refposition  r   rc   r  )r   r   r   ry   r  r   r  r   r   r   r  r   r  r  r   rc   ra   rN   rN     s         BAAJM !
 !
 !
 !
F   X Y  Y     X & 
& 
& 
&         X $ $ $    ! ! X! ( ( ( ! ! ! ! !rc   rN   c                       e Zd ZdZdgZeddgz   ZdZdZdZ	 ddZ	e
d	             Zej        d
             Zej        d             Zd ZdS )rO   z_
    FIELDref_ element: used inside of GROUP_ elements to refer to remote FIELD_ elements.
    rl   r   r   FIELDrefTNc                 `   |i }|| _         || _        t                              |            || _        || _        || _        || _        |                    d          r| j	        | _
        dS | j        | _
        |t          | j        dg||           |t          | j        dg||           dS dS )z
        *table* is the :class:`Table` object that this :class:`FieldRef`
        is a member of.

        *ref* is the ID to reference a :class:`Field` object defined
        elsewhere.
        Nr   r   r   )rh   ri   r
  r  _tablerl   r   r   r   rg  r  rh  rF   r   )rk   tablerl   r   r   r   r   ri  s           ra   r  zFieldRef.__init__  s     >F	t$$$
::,-- 	O"0DOOO"0DO"4#5wLLL "4#5y&#NNNNN ! rc   c                     | j         S )z5The ID_ of the FIELD_ that this FIELDref_ references.rv  r   s    ra   rl   zFieldRef.ref:  r   rc   c                 V    t          j        |d| j        | j                   || _        d S r*  r+  rz  s     ra   rl   zFieldRef.ref?  r,  rc   c                     d | _         d S rw   rv  r   s    ra   rl   zFieldRef.refD  r   rc   c                     | j         j                                        D ]+}t          |t                    r|j        | j        k    r|c S ,t          d| j         d| j        | j	        t                     dS )zd
        Lookup the :class:`Field` instance that this :class:`FieldRef`
        references.
        zNo field named ''N)r  r  iter_fields_and_paramsr   rK   r   rl   rB   rh   ri   rj   rk   r   s     ra   get_refzFieldRef.get_refH  sz    
 [)@@BB 	 	E%'' EH,@,@/DH///ty(SSSSSrc   NNNNr   r   r   ry   rh  rg  r   r   r   r  r   rl   r   r   r  r   rc   ra   rO   rO     s          GM!UG$44MMNL BFO O O O<   X 	Z  Z 	[  [T T T T Trc   rO   c                       e Zd ZdZdgZeddgz   ZdZdZdZddZ	e
d	             Zej        d
             Zej        d             Zd ZdS )rP   a4  
    PARAMref_ element: used inside of GROUP_ elements to refer to remote PARAM_ elements.

    The keyword arguments correspond to setting members of the same
    name, documented below.

    It contains the following publicly-accessible members:

      *ref*: An XML ID referring to a <PARAM> element.
    rl   r   r   PARAMrefTNc                 `   |i }|| _         || _        t                              |            || _        || _        || _        || _        |                    d          r| j	        | _
        d S | j        | _
        |t          | j        dg||           |t          | j        dg||           d S d S )Nr   r   r   )rh   ri   rU   r  r  rl   r   r   r   rg  r  rh  rF   r   )rk   r  rl   r   r   r   r   s          ra   r  zParamRef.__init__e  s    >F	
::,-- 	O"0DOOO"0DO"4#5wLLL "4#5y&#NNNNN ! rc   c                     | j         S )z5The ID_ of the PARAM_ that this PARAMref_ references.rv  r   s    ra   rl   zParamRef.ref{  r   rc   c                 V    t          j        |d| j        | j                   || _        d S r*  r+  rz  s     ra   rl   zParamRef.ref  r,  rc   c                     d | _         d S rw   rv  r   s    ra   rl   zParamRef.ref  r   rc   c                     | j         j                                        D ]+}t          |t                    r|j        | j        k    r|c S ,t          d| j         d| j        | j	        t                     dS )zf
        Lookup the :class:`Param` instance that this :class:``PARAMref``
        references.
        zNo params named 'r  N)r  r  r  r   rL   r   rl   rB   rh   ri   rj   )rk   params     ra   r  zParamRef.get_ref  sz    
 [)@@BB 	 	E%'' EH,@,@0TX000$,	8TTTTTrc   r  r  r   rc   ra   rP   rP   S  s        	 	 GM!UG$44MMNLO O O O,   X 	Z  Z 	[  [U U U U Urc   rP   c                       e Zd ZdZ	 	 	 	 	 	 	 	 ddZd Zed             Zej        d             Zej	        d             Zed             Z
d	 Zd
 Zd Zd Zd Zd Zd Zd ZdS )rQ   az  
    GROUP_ element: groups FIELD_ and PARAM_ elements.

    This information is currently ignored by the vo package---that is
    the columns in the recarray are always flat---but the grouping
    information is stored so that it can be written out again to the
    XML file.

    The keyword arguments correspond to setting members of the same
    name, documented below.
    Nc
                    |i }|| _         |	| _        t                              |            || _        t          ||||	          pt          j        |||	          | _        || _	        || _
        || _        || _        d | _        t          t          t           t"          t$          f          | _        t)          d|
                                ||	           d S )NGROUP)rh   ri   rU   r  r  r   r   rf  r   r   rl   r   r   r   r   rO   rP   rQ   rL   _entriesrF   r   )rk   r  r   r   rl   r   r   r   r   r   ri  s              ra   r  zGroup.__init__  s     >F	RVS11VW^D&RU5V5V	
'8UE(JKK7EJJLL&#>>>>>rc   c                 2    dt          | j                   dS )Nz<GROUP>... z entries ...</GROUP>)r\   r  r   s    ra   r  zGroup.__repr__  s    ES//EEEErc   c                     | j         S )zg
        Currently ignored, as it's not clear from the spec how this is
        meant to work.
        rv  r   s    ra   rl   z	Group.ref  rx  rc   c                 V    t          j        |d| j        | j                   || _        d S r*  r+  rz  s     ra   rl   z	Group.ref  r,  rc   c                     d | _         d S rw   rv  r   s    ra   rl   z	Group.ref  r   rc   c                     | j         S )z
        [read-only] A list of members of the GROUP_.  This list may
        only contain objects of type :class:`Param`, :class:`Group`,
        :class:`ParamRef` and :class:`FieldRef`.
        )r  r   s    ra   entrieszGroup.entries  r  rc   c                 d    t          | j        f||d|}| j                            |           d S NrC  )rO   r  r  rV  )rk   rq   r   r   r   r   fieldrefs          ra   _add_fieldrefzGroup._add_fieldref  <    DKHCHH4HHH%%%%%rc   c                 d    t          | j        f||d|}| j                            |           d S r  )rP   r  r  rV  )rk   rq   r   r   r   r   paramrefs          ra   _add_paramrefzGroup._add_paramref  r  rc   c                     t          | j        t                    r| j        }n| j        j        }t	          |f||d|}| j                            |           |                    ||           d S r  )r   r  rT   r  rL   r  rV  r  )rk   rq   r   r   r   r   r  r  s           ra   
_add_paramzGroup._add_param  su    dk;// 	+kGGk*Gg>f#>>>>E"""Hf%%%%%rc   c                     t          | j        f||d|}| j                            |           |                    ||           d S r  )rQ   r  r  rV  r  rk   rq   r   r   r   r   groups          ra   
_add_groupzGroup._add_group  sP    dkB&cBBTBBE"""Hf%%%%%rc   c                 *   | j         | j        | j        | j        | j        d}|D ]n\  }}}}|r) |                    || j                  |||||           2|dk    r.| j        t          t          t          d||           |pd | _        f|dk    r no| S )N)r  r  r  r  rD  rD  r  )
r  r  r  r  r   r   r   r   rE   r(   )rk   rq   r   tag_mappingr  r   r   r   s           ra   r  zGroup.parse  s    **__+
 
 &. 	 	!E3c 
;T%:;;c4    -'''3%c3EEE'+|tD$$G^^E $rc   c                    |                     d|                    | g d                    5  | j        |                    d| j        d           | j        D ]} |j        |fi | 	 d d d            d S # 1 swxY w Y   d S )Nr  r   r   rl   r   r   r  rD  TrN  )r   r  r   rn   r  r  )rk   r  r  entrys       ra   r  zGroup.to_xml	  s    UUANN41V1V1VWW  
 
 	* 	* +		-)9	EEE * *Q))&))))*	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*s   =A99A= A=c              #      K   | j         D ]K}t          |t                    r|V  t          |t                    r|                                E d{V  LdS )zf
        Recursively iterate over all :class:`Param` elements in this
        :class:`Group`.
        N)r  r   rL   rQ   r  rk   r  s     ra   r  zGroup.iter_fields_and_params	  sw      
 \ 	: 	:E%'' :E5)) : 77999999999		: 	:rc   c              #      K   | j         D ]5}t          |t                    r|V  |                                E d{V  6dS )zk
        Recursively iterate over all sub-:class:`Group` instances in
        this :class:`Group`.
        N)r  r   rQ   iter_groupsr  s     ra   r  zGroup.iter_groups&	  sc      
 \ 	/ 	/E%'' / ,,.........	/ 	/rc   r`  )r   r   r   ry   r  r  r   rl   r   r   r  r  r  r  r  r  r  r  r  r   rc   ra   rQ   rQ     sG       
 
 ? ? ? ?@F F F   X 	Z  Z 	[  [   X& & && & && & && & &
  .* * *	: 	: 	:/ / / / /rc   rQ   c                   r   e Zd ZdZ	 	 	 	 	 	 	 	 	 d5dZd Zd Zd Zed             Z	e	j
        d             Z	e	j        d	             Z	ed
             Zej
        d             Zed             Zed             Zed             Zed             Zed             Zed             Zd Zd6dZd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd  Z d! Z!d" Z"d7d$Z#e$d%             Z%d& Z& e'd'd(d)d*d+          Z( e)d)d*d,          Z* e'd-d#d)d*d.          Z+d/ Z, e'd'd(d0d1d2          Z- e'd-d#d0d1d3          Z.d4 Z/dS )8rR   a  
    TABLE_ element: optionally contains data.

    It contains the following publicly-accessible and mutable
    attribute:

        *array*: A Numpy masked array of the data itself, where each
        row is a row of votable data, and columns are named and typed
        based on the <FIELD> elements of the table.  The mask is
        parallel to the data array, except for variable-length fields.
        For those fields, the numpy array's column type is "object"
        (``"O"``), and another masked array is stored there.

    If the Table contains no data, (for example, its enclosing
    :class:`Resource` has :attr:`~Resource.type` == 'meta') *array*
    will have zero-length.

    The keyword arguments correspond to setting members of the same
    name, documented below.
    Nc                 $   |	i }	|	| _         |
| _        d| _        t                              |            || _        t          |||	|
          pt          j        ||	|
          | _	        || _
        t          j        |d|	|
           || _        || _        || _        |$t          |          }|dk     rt!          d          || _        d | _        d| _        t)          t*                    | _        t)          t.                    | _        t)          t2                    | _        t)          t6                    | _        t)          t:                    | _        t?          j         g           | _         tC          d|"                                |	|
           d S )NFrl   r   z'nrows' cannot be negative.	tabledataTABLE)#rh   ri   _emptyrU   r  r  r   r   rf  r   r   r   rw  r   r   r  r   _nrowsr   ru   r   rK   _fieldsrL   _paramsrQ   _groupsrH   r	  rI   _infosr   arrayrF   r   )rk   r  r   r   rl   r   r   nrowsr   r   r   ri  s               ra   r  zTable.__init__G	  sU    >F	RVS11VW^D&RU5V5V	eVS111	
JJEqyy !>???!&u--&u--&u--%d++%d++Xb\\
7EJJLL&#>>>>>rc   c                 D    t          |                                           S rw   )reprto_tabler   s    ra   r  zTable.__repr__v	  s    DMMOO$$$rc   c                 D    t          |                                           S rw   )bytesr  r   s    ra   	__bytes__zTable.__bytes__y	  s    T]]__%%%rc   c                 D    t          |                                           S rw   )r   r  r   s    ra   __str__zTable.__str__|	  s    4==??###rc   c                     | j         S rw   rv  r   s    ra   rl   z	Table.ref	  s
    yrc   c                    t          j        |d| j        | j                   |	 | j                            ||           }|j        | _        |j        | _	        |j
        | _        |j        | _        nh# t          $ r3 t          t           t           d| j        f| j        | j                   d}Y n,w xY w| j        dd= | j	        dd= | j        dd= | j        dd= || _        dS )z
        Refer to another TABLE, previously defined, by the *ref* ID_
        for all metadata (FIELD_, PARAM_ etc.) information.
        rl   Nrt   r  )r   r   rh   ri   r  get_table_by_idr  r  paramsr  groupsr  rS  r	  rj   rE   r;   rl   rw  )rk   rl   r  s      ra   rl   z	Table.ref	  s     	eT\49===?	*55c$5GG
  %|$|$|#k    c3$((;T\49UUU QQQQQQQQQAAA			s   A2 2:B/.B/c                     d | _         d S rw   rv  r   s    ra   rl   z	Table.ref	  r   rc   c                     | j         S )a  The serialization format of the table [*required*].

        Must be one of:

          'tabledata' (TABLEDATA_), 'binary' (BINARY_), 'binary2' (BINARY2_)
          'fits' (FITS_).

        Note that the 'fits' format, since it requires an external
        file, can not be written out.  Any file read in with 'fits'
        format will be read out, by default, in 'tabledata' format.

        See :ref:`astropy:votable-serialization`.
        )_formatr   s    ra   ru   zTable.format	  s     |rc   c                 .   |                                 }|dk    r!t          d| j        | j        t                     |dk    r)| j        d         st          d| j        | j                   n#|dvrt          d| d| j        | j                   || _        d S )	Nr   z.fits format can not be written out, only read.binary2r?  z.binary2 only supported in votable 1.3 or later)r  binaryzInvalid format 'r  )lowerrB   rh   ri   r  r  )rk   ru   s     ra   ru   zTable.format	  s    V@	#	   Y< 67 DLI  
 22211114<KKKrc   c                     | j         S )zf
        [*immutable*] The number of rows in the table, as specified in
        the XML file.
        )r  r   s    ra   r  zTable.nrows	  ro  rc   c                     | j         S )zl
        A list of :class:`Field` objects describing the types of each
        of the data columns.
        )r  r   s    ra   r  zTable.fields	  r<  rc   c                     | j         S )z
        A list of parameters (constant-valued columns) for the
        table.  Must contain only :class:`Param` objects.
        r  r   s    ra   r  zTable.params	  r<  rc   c                     | j         S )z
        A list of :class:`Group` objects describing how the columns
        and parameters are grouped.  Currently this information is
        only kept around for round-tripping and informational
        purposes.
        r  r   s    ra   r  zTable.groups	  s     |rc   c                     | j         S )z
        A list of :class:`Link` objects (pointers to other documents
        or servers through a URI) for the table.
        rA  r   s    ra   rS  zTable.links	  ro  rc   c                     | j         S )zr
        A list of :class:`Info` objects for the table.  Allows for
        post-operational diagnostics.
        r  r   s    ra   infoszTable.infos	  ro  rc   c                     | j         S )z
        Returns True if this table doesn't contain any real data
        because it was skipped over by the parser (through use of the
        ``table_number`` kwarg).
        )r  r   s    ra   is_emptyzTable.is_empty	  ro  rc   r   c                 F   |d}| j         }t          |          dk    r0t          j        |fd          }t          j        |fd          }n7t
                              |           g }|D ]I}|j        |j        k    r|j        }n|j        |j        f}|	                    ||j
        j        f           Jt          j        |ft          j        |                    }g }	|j        j        D ]}
|
d         d         dk    rdpd}t          |
          dk    r|		                    |
d         |f           It          |
          d	k    r$|		                    |
d         ||
d         f           t          j        |f|	          }t          j        ||
          | _        dS )a  
        Create a new array to hold the data based on the current set
        of fields, and store them in the *array* and member variable.
        Any data in the existing array will be lost.

        *nrows*, if provided, is the number of rows to allocate.
        Nr   OrX   br	   r  r     mask)r  r\   nprecarrayrZ   rK   r  r  r   rV  r  ru   rY   descrr   r  )rk   r  r   r  r  r  rY   rH  r   
descr_maskr^  new_types               ra   create_arrayszTable.create_arrays
  s    =Ev;;!K444E8UHC000DD '''E 7 7>QT))BB.!$/Bb!+"456666K@@@EJ[& > >aDGsN2s=vq66Q;;%%qtX&67777VVq[[%%qtXqt&<===8UHJ777DXe$///


rc   c                 d    |dk    rdS t          t          j        |t          z                      S )z
        Return a new (larger) size based on size, used for
        reallocating an array when it fills up.  This is in its own
        function so the resizing strategy can be easily replaced.
        r   i   )r  r  ceilRESIZE_AMOUNT)rk   sizes     ra   _resize_strategyzTable._resize_strategy,
  s/     1993274-/00111rc   c                     t          | j        f||d|}| j                            |           |                    ||           d S r  )rK   r  r  rV  r  )rk   rq   r   r   r   r   r   s          ra   
_add_fieldzTable._add_field8
  P    dmDFDDtDD5!!!Hf%%%%%rc   c                     t          | j        f||d|}| j                            |           |                    ||           d S r  rL   r  r  rV  r  rk   rq   r   r   r   r   r  s          ra   r  zTable._add_param=
  r  rc   c                     t          | f||d|}| j                            |           |                    ||           d S r  rQ   r  rV  r  r  s          ra   r  zTable._add_groupB
  N    d;6s;;d;;5!!!Hf%%%%%rc   c                     t          d||d|}| j                            |           |                    ||           d S NrC  r   rH   rS  rV  r  rk   rq   r   r   r   r   rL  s          ra   	_add_linkzTable._add_linkG
  L    36s33d33
$

8V$$$$$rc   c                     |                     d          st          t          t          d||           t          d||d|}| j                            |           |                    ||           d S )Nr   rc  r  r   rC  r   )r   rE   r.   rI   r  rV  r  rk   rq   r   r   r   r   r  s          ra   	_add_infozTable._add_infoL
  sy    zz011 	K#s$<fcJJJ36s33d33
$

8V$$$$$rc   c           	      T   |                     d          }|                     d          }|                     d          }d}|!|dxx         dz  cc<   |||k    r	d}d| _        |                     d          }||| j        k    r	d}d| _        | j        | j        | _        |D ]s\  }}	}
}|r-|	dk    r&t	          d|
                                ||            n?6|	d	k    r| c S |	d
k    r-| j        t          t          t          d||           |
pd | _        tn3| j	        | j
        | j        | j        | j        | j        d}|D ]\  }}	}
}|r|	dk    r[t          | j                  dk    rt          t"          t"          d ||           t	          d|
                                ||            n |                     |	| j                  ||	|
||           |	d
k    r.| j        t          t          t          d||           |
pd | _        |	d	k    r:t&                              | j                   |                     d|           | c S 
|                     | j        |           | j        }d |D             |s+t/          t1          t          |                              }nt3          |t4                    r|g}t7          j        |          }t;          |j        j        t6          j                   rOt7          j!        |dk               s%t7          j!        |t          |          k              rtE          d          |}ndt;          |j        j        t6          j#                  r1	 fd|D             }n0# tD          $ r tE          d| d          w xY wtI          d          |st          |          dk    r|D ]\  }}	}
}|r|	dk    rDt	          d|
                                ||           | %                    ||||          | _&         nj|	dk    rFt	          d|
                                ||           | '                    d|||||          | _&         n|	dk    rL|d         s#t          tP          tP          |d         ||           | '                    d|||||          | _&         n|	dk    rt	          d|
                                ||dg           	 tS          |
                     dd                    }|dk     rtE          d          n'# tD          $ r tU          tV          d||           Y nw xY w| ,                    |||          | _&         n!t          tZ          tZ          |	||            n|D ]\  }}	}
}|s|	dk    r n|D ]\  }}	}
}|rx|	dk    rr|                     d           st          t\          t\          d!||           t_          d||d"|
}| j0        1                    |           |2                    ||           |s|	d	k    r n| S )#Ncolumnstable_number_current_table_numberFr	   Ttable_idDATAr  rD  RESOURCE)r  r  r  r5  rc  rD  r   )r  r   c                     g | ]	}|j         
S r   r   rF  s     ra   
<listcomp>zTable.parse.<locals>.<listcomp>
  s    &&&!&&&rc   z*Some specified column numbers out of rangec                 :    g | ]}                     |          S r   )index)rG  rH  namess     ra   r.  zTable.parse.<locals>.<listcomp>
  s#    !B!B!BQ%++a..!B!B!Brc   z	Columns 'z' not found in fields listzInvalid columns list	TABLEDATABINARYBINARY2r?  r  r  FITSextnumz'extnum' cannot be negative.r   rc  r   r"  rC  )3r   r  r   rl   rF   r   r   rE   r(   r  r  r  r  r$  r   r\   r  r   r   rK   r  r  r  r  ranger   r   r  asarray
issubclassrY   r>  integeranyr   	character	TypeError_parse_tabledatar  _parse_binaryr?   r  rB   r   _parse_fitsr6   r.   rI   r  rV  r  )rk   rq   r   r&  r'  current_table_number
skip_tabler)  r  r   r   r   r  r  
colnumbersr6  r  r1  s                    @ra   r  zTable.parseS
  s   **Y'' zz.11%zz*ABB
+*+++q0+++'L<P,P,P!
"::j))47""!
"8 xDH)1 8 8%sD# 
8f}}*6499;;LLL % g~~#--+7)#sJLLL+/<4( #/ K *2 $ $%sD# $f}}t{++q00)#sD&#FFF*6499;;LLL?KOOC)>?? #tVS    m+++7)#sJLLL+/<4((++DK888 **6*BBB# ( 	V<<<&&v&&& 	8eCKK0011JJ'3'' $")j))G'-,bj99 
86'A+&& S"&3v;;1F*G*G S$%QRRR$

GM.== 8V!B!B!B!B'!B!B!BJJ! V V V$%T%T%T%TUUUV   6777 "	Vq)1 ! !%sD#  k))*;		VSQQQ%)%:%:$j&&& &
 *8TYY[[&#NNN%)%7%7xVVS& &
 	))%&<= T)#sF94EvsSSS%)%7%7xVVS& &
 *6499;;hZXXX;%((A)>)>%?%?F%zz&01O&P&P P  *) ; ; ;$S"fc:::::;%)%5%5h%O%O
%c3VSAAAA D &. 	 	!E3c SF]]%- 	 	!E3c zz"899 S!#s,DfcRRR;6s;;d;;
!!$'''

8V,,,, sg~~s   /M> >N'8T  !UUc                 <	   |                     dd          }| j        }| `d |D             }d |D             }d}	t          |          }
fdt          t          |                    D             }d |D             }dgt          |          z  }g }g }|                     d	t                    }|D ]S\  }}}}|d
k    r:|d d          }|d d          }d}|D ]"\  }}}}|rA|                     dd           dk    }t          ||                                ||dg           K|dk    r|t          |          k    r$t          t          t          |          ||           ||         ri	 |rt          j
        |                    d                    }t          j        |          }|                    d           	  ||         |j                  \  }}n# t           $ rH}t#          |||d                    t          |          ||         j                             Y d }~nud }~ww xY w	  ||         |||          \  }}nU# t           $ rH}t#          |||d                    t          |          ||         j                             Y d }~nd }~ww xY w|||<   |||<   nP# t           $ r!}|dk    rt#          |||           Y d }~n*d }~ww xY wn!|d
k    r n |                     |||||           |dz  }$|t          |          k     r&t          t*          |t          |          f||           |                    t/          |                     |                    t/          |                     t          |          |k    rl|	|z   |
k    r|                     |
          }
|	|z   |
k    |
t          |          k    rt3          ||
          }|||	|	|z   <   ||j        |	|	|z   <   |	|z  }	g }g }I|s|dk    r nU|	t          |          z   }
t3          ||
          }|||	d <   |
dk    r||j        |	d <   |	t          |          z  }	| j        :| j        dk    r/| j        |	k    r$t9          t:          t:          | j        |	f||           |	| _        |S )Ninvalidr   c                 &    g | ]}|j         j        S r   )r  r  rG  r   s     ra   r.  z*Table._parse_tabledata.<locals>.<listcomp>
  s    ===U5?(===rc   c                 &    g | ]}|j         j        S r   r  binparserG  s     ra   r.  z*Table._parse_tabledata.<locals>.<listcomp>
      CCC5eo.CCCrc   r   c                     g | ]}|v S r   r   )rG  r  rC  s     ra   r.  z*Table._parse_tabledata.<locals>.<listcomp>
  s    GGGq1
?GGGrc   c                 &    g | ]}|j         j        S r   r  defaultrF  s     ra   r.  z*Table._parse_tabledata.<locals>.<listcomp>
  s    ;;;qq{*;;;rc   T
chunk_sizeTRencodingbase64TDascii(in row {:d}, col '{}')r	   r2  )r   r  r\   r7  DEFAULT_CHUNK_SIZErF   r   rB   r   rS  	b64decodeencoder  BytesIOseekreadr  rC   ru   r   r   r   rV  tupler  rb   r  r  rE   r)   r  )rk   rq   rC  r  r   rE  r  parsers
binparsersnumrows
alloc_rowscolnumbers_bitsrow_defaultmask_defaultarray_chunk
mask_chunkrP  r  r   r   r   rowrow_maskr  r  rawdatabufr2  
mask_valuer   s     `                           ra   r>  zTable._parse_tabledata
  s   
 **Y44 
J==f===CCFCCC
ZZ
GGGGE#f++4F4FGGG;;F;;;vF+
ZZ.@AA
%- L	 L	!E3cd{{!!!!n'?-5 2 2)E3c 1!%*d!;!;x!G*3		VS:,WWWW$;; CKK// (c&kk63 G G G.q1 $=#!='- %.282B4;;wCWCW2X2X.0j.A.A(+
).@M
1ch@W@W,=E::/8 ). ). ).,60106030I0P0P474D4DfQil12 12	-. -. -. -. -. -. -. -.).).@J
04fcA. A.,=E:: 09 ). ). ).,60106030I0P0P474D4DfQil12 12	-. -. -. -. -. -. -. -.). .3CF2<HQKK (1 !C !C !C'.+'='=(21fc(B(B(B!C?$=J !D[[!E 11(CvsSSSQs6{{??S1c&kk"2FC@@@""5::...!!%//222{##z11!J.;;%)%:%::%F%F
 "J.;;!SZZ// 'z : :<GE'Gj$889AKEJw:)==>z)G"$K!#J sk11 s;///
z**%ghh??#-EJwxx 3{###:!djAoo$*:O:O#sTZ$963GGGsm   ,AJ&?GJ&
H+#>H&!J&&H++J&/IJ&
J>JJ&JJ&&
K0KKc           	         d}|D ]\  }}}}|dk    r|rt          d|                                ||g d           d|vrNd}|                    dd           dk    r1t          t          t          |                    dd           ||           |d         }t          j        |||           |                    dd           }	|}
 n|rXt          j        |
	                    d                    }
t          j        |
          }|                    d	           |j        n|                    d
          s!t          d| j        | j        t$                     t&          j                            |          }|	_|	dk    rt-          j        |d|          }nA|	dk    rt1          j        |d          }n%t          d|	 d| j        | j        t$                     |j        fd}|S )NFSTREAMr>  r3  actuaterR  expiresrightsr3  TrR  rS  rU  r   httpftpfileBThe vo package only supports remote data through http, ftp or filegziprbfileobjUnknown encoding type 'r  c                 R     |           }t          |          | k    rt          |S rw   )r\   EOFError)r`   rY  r\  s     ra   careful_readz3Table._get_binary_data_stream.<locals>.careful_read  s+    T&\\F6{{f$$Mrc   )rF   r   r   rE   r7   r   rP  rS  rX  rY  r  rZ  r[  r\  
startswithrB   rh   ri   r  urllibrequesturlopenrw  GzipFilecodecsEncodedFile)rk   rq   r   have_local_streamr  r   r   r   r3  rR  buffer	string_iofdr~  r\  s                 @ra   _get_binary_data_streamzTable._get_binary_data_stream\  s<   !%- 	 	!E3ch & 		TTT   T)),0)88J55AA) #S$((:t*D*Dfc    $F|,T63???#'88J#=#=!FE+ .  	%fmmG&<&<==F
6**INN1>DD??#:;; $LI'   ''--B#v%%tT2>>>BB))+B99BB=(===	+	   7D	 	 	 	 	 rc   c                    | j         }|                     ||          }| j        }| `d |D             }	d}
t          |          }	 |
|k    r%|                     |          }t          ||          }g }g }	 |dk    r |t          t          |          dz   dz                      }t          t          j	        |t          |                              }t          |          D ](\  }}||         r|j        dk    s|j        dk    rd	||<   )t          |	          D ]\  }}	  ||          \  }}nF# t          $ r  t          $ r/}t          |||d
|
dd||         j         d           Y d }~nd }~ww xY w|                    |           |dk    r|                    |           ||         p|||<   n# t          $ r Y nnw xY wd |D             }d	gt          |          z  }|D ]}||         ||<   ||         ||<   t#          |          ||
<   t#          |          |j        |
<   |
dz  }
t          ||
          }|S )Nc                 &    g | ]}|j         j        S r   rI  rG  s     ra   r.  z'Table._parse_binary.<locals>.<listcomp>  rK  rc   r   Tr        r  r  F(in row r^  , col '')r	   c                 &    g | ]}|j         j        S r   rN  rF  s     ra   r.  z'Table._parse_binary.<locals>.<listcomp>  s    77711;&777rc   )r  r  r  r\   r  rb   r  r  r
   bitarray_to_bool	enumerater  r}  r  rC   r   rV  r]  r  )rk   moderq   rC  r  r   r   r~  r  r_  r`  ra  row_datarow_mask_data	mask_bitsr  frJ  r2  
value_maskr   rg  rh  s                          ra   r?  zTable._parse_binary  s   33HfEE 
JCCFCCC
ZZ
3	*$$!22:>>
z22HM 199 ,S#f++/Q1F-G-G H HI$("3Is6{{KK% %M
 !*& 1 1 5 51(+ 5J&00AJ-4O4O/4M!,#,Z#8#8 J JKAx
,4H\,B,B)zz#   $   ""IwIIIIII	        OOE***qyy%,,Z8888+8+;+Iza((!J"     87777CwV,H / /!!A+A."3ZZE'N"'//EJwqLGg3	j w''s>   5B,F7 "D10F7 1E4%E/*F7 /E44AF7 7
GGc           	         |D ]W\  }}}}|dk    rJ|rFt          d|                                ||g d           |d         }|                    dd           }	U nX|                    d          s!t	          d| j        | j        t                     t          j	        
                    |          }
|	_|	dk    rt          j        |d|
	          }
nA|	d
k    rt          j        |
d
          }
n%t	          d|	 d| j        | j        t                     t          j        |
          }|t#          |                   j        }|j        | j        j        k    r't+          t,          t,          d| j        | j                   |S )Nrm  rn  r3  rR  rr  rv  rw  rry  rS  r{  r  r   )rF   r   r   r  rB   rh   ri   r  r  r  r  rw  r  r  r  r   openr  r   rY   r  rE   r*   )rk   rq   r6  r   r  r   r   r   r3  rR  r  hdulistr  s                ra   r@  zTable._parse_fits  s   %- 	 	!E3ch & 		TTT    <D#xx
D99HHE  677 	T	#	   ^##D))6!!]4b999X%%'H559h999LI'	   )B--F$);$****#sBdi@@@rc   c                    |                     d          }||}n| j        }|dk    rd}|                    d|                    | d                    5  | j        |                    d| j        d	           | j        | j        fD ]}|D ]}|                    i d            | j	        1| j        | j        | j
        | j        fD ]}|D ]} |j        |fi | nc|d
         r[t          | j                                                                      |           }t#          | d|           } |j        |fi | t%          | j                  rm|                    d          5  |dk    r | j        |fi | n+|dk    r | j        d|fi | n|dk    r | j        d|fi | d d d            n# 1 swxY w Y   |d
         r| j        D ]} |j        |fi | d d d            d S # 1 swxY w Y   d S )Ntabledata_formatr   r  r  )r   r   rl   r   r   r  r  rD  TrN  r   _gr-  r*  r  r	   r  r  )r   ru   r   r  r   rn   r  r  r
  rl   r  rS  r  r  r  iter_tablesr0  rQ   r\   r  _write_tabledata_write_binaryr  )	rk   r  r  specified_formatru   element_setrn   r0  r  s	            ra   r  zTable.to_xml  s.   !::&899'%FF[FV FUU>>$(VWW  
 
 	0 	0 +		-)9	EEE $T[9 - -* - -GNN2t,,,,- x$(Kdk4:#V 4 4K#. 4 4&q33F333344 ./ *T]668899??EEd|E||444Q))&)))4: ;UU6]] ; ;,,--a::6::::8++**1a::6::::9,,**1a::6:::; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ,- 0#{ 0 0G"GN1//////?	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0s8   DG/*AF7+G/7F;	;G/>F;	?#G//G36G3c                 j   | j         }| j        }|                    d          5  |                                 t          rq                    d          s\fd|D             }d |D             }t          |j                  dz
  }t          j	        |j
        |j        |j        |||d           ni|j
        }|                                }|dz   }	|dz   }
|d	z   }|d
z   }fdt          |          D             }t          t          |                    D ]} ||	           |j        |         }|j        |         }|D ]\  }}}||         }||         }|r t!          j        |          r ||           8	  |||          }nL# t$          $ r?}t'          |d                    || j         |         j                             Y d }~nd }~ww xY wt          |          r ||                    |                      ||            ||
           d d d            d S # 1 swxY w Y   d S )Nr2  _debug_python_based_parserc                 D    g | ]}|j                                       S r   )r  supports_empty_values)rG  r   r  s     ra   r.  z*Table._write_tabledata.<locals>.<listcomp>A  s6     ) ) )FKEO99&AA) ) )rc   c                 &    g | ]}|j         j        S r   )r  r  rG  s     ra   r.  z*Table._write_tabledata.<locals>.<listcomp>D  s    EEEU%/0EEErc   r	   rV   z<TR>
z</TR>
z <TD>{}</TD>
z <TD/>
c                 d    g | ],\  }}||j         j        |j                                       f-S r   )r  r  r  )rG  r  r   r  s      ra   r.  z*Table._write_tabledata.<locals>.<listcomp>V  sO        !5	 .==fEE  rc   rV  
additional)r  r  r   _flush_has_c_tabledata_writerr   r\   _tagsrG   write_tabledatawriter   r  get_indentation_spacesr  r7  r  allr  rC   ru   r   )rk   r  r  r  r  r  indentr  indent_spacestr_starttr_endtdtd_emptyrg  	array_rowmask_rowr  r  r   r]   rZ  r   s     `                   ra   r  zTable._write_tabledata:  s   
UU; 7	" 7	"HHJJJ& 5"vzz:V/W/W 5") ) ) )OU) ) )% FEfEEEQW)+GJJ)     ! 8 8 : :(83&2"%55(:5    %.f$5$5   !U,, " "CE(OOO %
3I$z#H<B 0 086#8(|!)!0 0RVF^^ 0!E(OOOO"&,fT6&:&:#, " " " *$%/H/O/O(+T[^->0& 0&!" !" !" !" !" !" !" !" !""  #3xx 0 %biinn 5 5 5 5 %hE&MMMMo7	" 7	" 7	" 7	" 7	" 7	" 7	" 7	" 7	" 7	" 7	" 7	" 7	" 7	" 7	" 7	" 7	" 7	"s=   EH(;FH(
G	5G	H(G	A
H((H,/H,c                 *   | j         }| j        }|dk    rd}nd}|                    |          5  |                    dd          5  d t          |          D             }t	          j                    }t          t          |                    D ]}	|j        |	         }
|j	        |	         }|dk    rEt          j        d	 |D                       }|                    t          j        |                     |D ]\  }}	  ||
|         ||                   }t          |          t          k    sJ n;# t           $ r.}t#          |d
|	dd||         j         d           Y d }~nd }~ww xY w|                    |           |                                 |                    t)          j        |                                                              d                     d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nr	   r3  r4  rm  rS  )rR  c                 0    g | ]\  }}||j         j        fS r   )r  	binoutput)rG  r  r   s      ra   r.  z'Table._write_binary.<locals>.<listcomp>  s3          7A5Q12     rc   r  c                 6    g | ]}t          j        |          S r   )r  r  rF  s     ra   r.  z'Table._write_binary.<locals>.<listcomp>  s     -L-L-LAbfQii-L-L-Lrc   r  r^  r  r  r  rU  )r  r  r   r  r  rZ  r7  r\   r   r  r  r  r
   bool_to_bitarrayr>  r  r  rC   r   r  rS  	b64encoder  decode)rk   r  r  r  r  r  tag_namefields_basicr   rg  r  
array_mask	flattenedr  r  chunkr   s                    ra   r  zTable._write_binaryw  s   
199HH HUU8__ 	K 	Kx(33 K K   ENvEVEV      z|| U,, * *C %
3I!&CJqyy$&H-L-L-L-L-L$M$M	

:#>y#I#IJJJ(4 * *9$-IilJqM$J$JE#';;%#7#7#7#7#7(   & !.W.W.W.Wvay|.W.W.W         

5))))* 


(99@@IIJJJ3K K K K K K K K K K K K K K K	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	Ksa   HB7G0?2D21G02
E*<$E% G0%E**A:G0$H0G4	4H7G4	8HHHFc                    ddl m} i }dD ]}t          | |d          }||||<   |rWd | j        D             }g }t	          |          D ]1\  }}	|	}
d}|
|v r|	 | }
|dz  }|
|v |                    |
           2|}nd | j        D             } || j        ||	          }t          || j                  D ]"\  }	}||	         }|                    |           #|S )
a  
        Convert this VO Table to an `astropy.table.Table` instance.

        Parameters
        ----------
        use_names_over_ids : bool, optional
           When `True` use the ``name`` attributes of columns as the
           names of columns in the `astropy.table.Table` instance.
           Since names are not guaranteed to be unique, this may cause
           some columns to be renamed by appending numbers to the end.
           Otherwise (default), use the ID attributes as the column
           names.

        .. warning::
           Variable-length array fields may not be restored
           identically when round-tripping through the
           `astropy.table.Table` instance.
        r   )rR   )r   r   rl   r   r   r   Nc                     g | ]	}|j         
S r   )r   rG  s     ra   r.  z"Table.to_table.<locals>.<listcomp>  s    999EUZ999rc   r  r	   c                     g | ]	}|j         
S r   r-  rG  s     ra   r.  z"Table.to_table.<locals>.<listcomp>  s    777%UX777rc   )r1  rT  )	astropy.tablerR   rg   r  r  rV  r  zipr[  )rk   use_names_over_idsrR   rT  rY  rZ  r1  unique_namesr  r   r  r  r   rX  s                 ra   r  zTable.to_table  sP   & 	('''''G 	  	 C$T**CS	 	899T[999EL$U++ . .4,.."&|||HFA ,.. ##H---- EE774;777EdjD999udk22 	* 	*KD%4[F!!&))))rc   c                    i }dD ]#}|j                             |          }||||<   $ | |fi |}d|j         v r|j         d         |_        |j        D ]=}||         }|j                            t                              ||                     >|j        ,t          j
        t          j        |                    |_
        nDt          j
        t          j        |          t          j        |j                            |_
        |S )z`
        Create a `Table` instance from a given `astropy.table.Table`
        instance.
        r  Nr   r  )rT  r   r   colnamesr  rV  rK   r_  r  r   r  r  r8  )	r]  r  r  r  rY  rZ  	new_tablecolnamerX  s	            ra   
from_tablezTable.from_table  s
    8 	" 	"C*..%%C!sC**6**	EJ&&$)J}$=I!~ 	N 	NG7^F##E$;$;GV$L$LMMMM: hrz%'8'899IOO hrz%'8'8rz%*?U?UVVVIOrc   c              #      K   | j         E d{V  | j        E d{V  | j        D ]}|                                E d{V  dS )z]
        Recursively iterate over all FIELD and PARAM elements in the
        TABLE.
        N)r  r  r  r  rk   r  s     ra   r  zTable.iter_fields_and_params  s~      
 ;;[ 	6 	6E335555555555	6 	6rc   r   Tr  zFIELD or PARAMzD
        Looks up a FIELD or PARAM element by the given ID.
        zL
        Looks up a FIELD or PARAM element by the given ID or name.
        r   z|
        Looks up a FIELD or PARAM element by the given utype and
        returns an iterator emitting all matches.
        c              #   Z   K   | j         D ] }|V  |                                E d{V  !dS )zK
        Recursively iterate over all GROUP elements in the TABLE.
        N)r  r  r  s     ra   r  zTable.iter_groups  sS       [ 	+ 	+EKKK((**********	+ 	+rc   r  r  zh
        Looks up a GROUP element by the given ID.  Used by the group's
        "ref" attribute
        zs
        Looks up a GROUP element by the given utype and returns an
        iterator emitting all matches.
        c              #   $   K   | j         E d {V  d S rw   )r  r   s    ra   	iter_infozTable.iter_info+  s&      :rc   )	NNNNNNNNN)r   N)F)0r   r   r   ry   r  r  r  r  r   rl   r   r   ru   r  r  r  r  rS  r  r   r  r  r  r  r  r  r$  r  r>  r  r?  r@  r  r  r  r  ra  r  r  r|   get_field_by_idr   get_field_by_id_or_nameget_fields_by_utyper  get_group_by_idget_groups_by_utyper  r   rc   ra   rR   rR   1	  s        0 -? -? -? -?^% % %& & &$ $ $   X 	Z  Z8 	[  [   X  ]  ](   X   X   X   X   X   X  &0 &0 &0 &0P
2 
2 
2& & &
& & &
& & &
% % %
% % %R R Rhs s sj= = =~E E EN, , ,\(0 (0 (0T;" ;" ;"z"K "K "KH/ / / /b   [26 6 6 .- 	 O <; 	  21 		 	+ + + .-		 	O 21		 	    rc   rR   c                      e Zd ZdZ	 	 	 	 	 	 	 d dZd Zed             Zej        d             Zed             Z	ed	             Z
ed
             Zed             Zed             Zed             Zed             Zed             Zed             Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z dS )!rS   z
    RESOURCE_ element: Groups TABLE_ and RESOURCE_ elements.

    The keyword arguments correspond to setting members of the same
    name, documented below.
    Nresultsc                    |i }|| _         || _        t                              |            || _        t          ||||          | _        || _        || _        || _	        d | _
        t          t                    | _        t          t                    | _        t          t                     | _        t          t$                    | _        t          t(                    | _        t          t,                    | _        t          t0                    | _        t          t4                    | _        t9          d|                                ||           d S )Nr+  )rh   ri   rU   r  r   r   r   r   r>  _extra_attributesr   r   rM   _coordinate_systemsrN   _time_systemsrQ   r  rL   r  rI   r  rH   r	  rR   _tablesrS   
_resourcesrF   r   )	rk   r   r   r   r>  r   r   r   r  s	            ra   r  zResource.__init__9  s    >F		RVS11
	!'#26#:#: ,W55&u--&u--%d++%d++&u--)(33:v{{}}fcBBBBBrc   c                     t          j                    }t          |          }|                    | j        |                    | | j                             |                                                                S r  )	r  r  r   rn   r   r  r  r  r   )rk   r  r  s      ra   r  zResource.__repr__\  s[    {}}dOO			$$Q^^D$/-R-R	SSS}}$$&&&rc   c                     | j         S )a  The type of the resource [*required*].

        Must be either:

          - 'results': This resource contains actual result values
            (default)

          - 'meta': This resource contains only datatype descriptions
            (FIELD_ elements), but no actual data.
        r  r   s    ra   r>  zResource.typeb  r  rc   c                 ^    |dvr!t          t          || j        | j                   || _        d S )N)r  rT  )rB   r   rh   ri   r  r  s     ra   r>  zResource.typep  r  rc   c                     | j         S )aJ  Dictionary of extra attributes of the RESOURCE_ element.

        This is dictionary of string keys to string values containing any
        extra attributes of the RESOURCE_ element that are not defined
        in the specification. The specification explicitly allows
        for extra attributes here, but nowhere else.
        )r  r   s    ra   extra_attributeszResource.extra_attributesv  s     %%rc   c                     | j         S )z
        A list of coordinate system definitions (COOSYS_ elements) for
        the RESOURCE_.  Must contain only `CooSys` objects.
        r  r   s    ra   coordinate_systemszResource.coordinate_systems       ''rc   c                     | j         S )z
        A list of time system definitions (TIMESYS_ elements) for
        the RESOURCE_.  Must contain only `TimeSys` objects.
        r  r   s    ra   time_systemszResource.time_systems       !!rc   c                     | j         S )z
        A list of informational parameters (key-value pairs) for the
        resource.  Must only contain `Info` objects.
        r  r   s    ra   r  zResource.infos  ro  rc   c                     | j         S )z#
        A list of groups.
        r  r   s    ra   r  zResource.groups  s    
 |rc   c                     | j         S )z~
        A list of parameters (constant-valued columns) for the
        resource.  Must contain only `Param` objects.
        r  r   s    ra   r  zResource.params  r<  rc   c                     | j         S )z
        A list of links (pointers to other documents or servers
        through a URI) for the resource.  Must contain only `Link`
        objects.
        rA  r   s    ra   rS  zResource.links  s     {rc   c                     | j         S )z_
        A list of tables in the resource.  Must contain only
        `Table` objects.
        )r  r   s    ra   tableszResource.tables  r<  rc   c                     | j         S )zq
        A list of nested resources inside this resource.  Must contain
        only `Resource` objects.
        r  r   s    ra   	resourceszResource.resources       rc   c                     t          | j        f||d|}| j                            |           |                    ||           d S r  )rR   r  r  rV  r  )rk   rq   r   r   r   r   r  s          ra   
_add_tablezResource._add_table  r  rc   c                     t          d||d|}| j                            |           |                    ||           d S r  rI   r  rV  r  r#  s          ra   r$  zResource._add_info  r   rc   c                     t          | f||d|}| j                            |           |                    ||           d S r  r  r  s          ra   r  zResource._add_group  r  rc   c                     t          | j        f||d|}| j                            |           |                    ||           d S r  r  r  s          ra   r  zResource._add_param  r  rc   c                     t          d||d|}| j                            |           |                    ||           d S r  rM   r  rV  r  rk   rq   r   r   r   r   coosyss          ra   _add_coosyszResource._add_coosys  M    7v377$77&&v...Xv&&&&&rc   c                     t          d||d|}| j                            |           |                    ||           d S r  rN   r  rV  r  rk   rq   r   r   r   r   timesyss          ra   _add_timesyszResource._add_timesys  M    9S99D99  )))h'''''rc   c                     t          d||d|}| j                            |           |                    | j        ||           d S r  )rS   r  rV  r  r  rk   rq   r   r   r   r   resources          ra   _add_resourcezResource._add_resource  sP    ;6s;;d;;h'''t}h77777rc   c                     t          d||d|}| j                            |           |                    ||           d S r  r  r  s          ra   r  zResource._add_link  r   rc   c           
      l   || _         | j        | j        | j        | j        | j        | j        | j        | j        | j	        d	}|D ]n\  }}}}|r) |
                    || j                  |||||           2|dk    r.| j        t          t          t          d||           |pd | _        f|dk    r no| ` | S )N)	r  rc  r  r  re  r  r+  r5  rD  rD  r+  )r  r   r$  r  r  r	  r  r  r  r   r   r   r   rE   r(   )	rk   r  rq   r   r  r  r   r   r   s	            ra   r  zResource.parse  s     _N__&(*N+

 

 &. 
	 
	!E3c 	;T%:;;c4    %%#/!#sJDDD#'<4  
"" # Mrc   c                    |                     | d          }|                    | j                   |                    d|          5  | j        |                    d| j        d           | j        | j        | j        | j	        | j
        | j        | j        fD ]}|D ]} |j        |fi | 	 d d d            d S # 1 swxY w Y   d S )N)r   r>  r   r+  r  rD  TrN  )r  r  r  r   r   rn   r  r  r  r  rS  r  r  r  )rk   r  r  attrsr  rn   s         ra   r  zResource.to_xml  s7   t%<==T*+++UU:eU,, 	0 	0+		-)9	EEE'!

  
0 
0  + 0 0G"GN1//////0
0	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0s   A'B==CCc              #   l   K   | j         E d{V  | j        D ]}|                                E d{V  dS )zd
        Recursively iterates over all tables in the resource and
        nested resources.
        N)r  r  r  rk   r  s     ra   r  zResource.iter_tables  sd      
 ; 	. 	.H++----------	. 	.rc   c              #      K   | j         E d{V  | j        D ]}|                                E d{V  | j        D ]}|                                E d{V  dS )z
        Recursively iterates over all FIELD_ and PARAM_ elements in
        the resource, its tables and nested resources.
        N)r  r  r  r  rk   r  r  s      ra   r  zResource.iter_fields_and_params#  s      
 ;[ 	6 	6E335555555555 	9 	9H668888888888	9 	9rc   c              #   l   K   | j         E d{V  | j        D ]}|                                E d{V  dS )zr
        Recursively iterates over all the COOSYS_ elements in the
        resource and nested resources.
        Nr  r  iter_coosysr  s     ra   r  zResource.iter_coosys.  e      
 ******** 	. 	.H++----------	. 	.rc   c              #   l   K   | j         E d{V  | j        D ]}|                                E d{V  dS )zs
        Recursively iterates over all the TIMESYS_ elements in the
        resource and nested resources.
        Nr  r  iter_timesysr  s     ra   r#  zResource.iter_timesys7  e      
 $$$$$$$$ 	/ 	/H,,..........	/ 	/rc   c              #      K   | j         E d{V  | j        D ]}|                                E d{V  | j        D ]}|                                E d{V  dS )zp
        Recursively iterates over all the INFO_ elements in the
        resource and nested resources.
        N)r  r  r  r  r  s      ra   r  zResource.iter_info@  s      
 :[ 	) 	)E(((((((((( 	, 	,H))++++++++++	, 	,rc   )NNNr  NNN)!r   r   r   ry   r  r  r   r>  r   r  r  r  r  r  r  rS  r  r  r   r$  r  r  r	  r  r  r  r  r  r  r  r  r#  r  r   rc   ra   rS   rS   /  si         !C !C !C !CF' ' '   X 
[  [
 & & X& ( ( X( " " X"   X   X   X   X   X   X& & &
% % %
& & &
& & &
' ' '
( ( (
8 8 8
% % %
  >0 0 0$. . .	9 	9 	9. . ./ / /	, 	, 	, 	, 	,rc   rS   c                       e Zd ZdZdJdZd Zed             Zej        d             Zed             Z	ed	             Z
ed
             Zed             Zed             Zed             Zd Zd Zd Zd Zd Zd Zd ZdddddddddddddddddZd Z	 	 	 	 dKd Zd! Zd" Z ed#d$d%d&d'          Z ed(dd%d&d)          Zd* Zd+ Z ed#d$d,d-d.          Z  ed(dd,d-d/          Z! e"d,d-d0          Z#d1 Z$ ed#d$d2d3d4          Z%d5 Z& ed#d$d6d7d8          Z' ed(dd6d7d9          Z(d: Z) ed#d$d;d<d=          Z*d> Z+ ed#d$d?d@dA          Z,dB Z- ed#d$dCdDdE          Z. edFddCdDdG          Z/dH Z0e1dLdI            Z2dS )MrT   a  
    VOTABLE_ element: represents an entire file.

    The keyword arguments correspond to setting members of the same
    name, documented below.

    *version* is settable at construction time only, since conformance
    tests for building the rest of the structure depend on it.
    N1.4c                    |i }|| _         || _        t                              |            t	          ||||          | _        d | _        t          t                    | _	        t          t                    | _        t          t                    | _        t          t                    | _        t          t                     | _        t          t$                    | _        t)          |          }|dk    rt+          j        dt.                     n<|dk    r6|| j        vr-d                    | j                  }t5          d| d          || _        d S )Nz1.0zXVOTable 1.0 support is deprecated in astropy 4.3 and will be removed in a future release', 'z 'version' should be in ('1.0', 'z').)rh   ri   rU   r  r   r   r   r   rM   r  rN   r  rL   r  rI   r  rS   r  rQ   r  r   warningsr   r   _version_namespace_maprJ  r   _version)rk   r   r   r   r   r  allowed_from_maps          ra   r  zVOTableFile.__init__W  s3   >F	RVS11#26#:#: ,W55&u--%d++)(33&u--g,,eM.)   
 WD4O%O%O%{{4+FGGU@PUUUVVVrc   c                 j    t          t          |                                                     }d| dS )Nz<VOTABLE>... z tables ...</VOTABLE>)r\   r  r  )rk   n_tabless     ra   r  zVOTableFile.__repr__u  s4    tD,,..//00>x>>>>rc   c                     | j         S )zN
        The version of the VOTable specification that the file uses.
        )r,  r   s    ra   r  zVOTableFile.versiony  s    
 }rc   c                     t          |          }|| j        vr-d                    | j                  }t          d| d          || _        d S )Nr)  z3astropy.io.votable only supports VOTable versions 'r  )r   r+  rJ  r   r,  )rk   r  r-  s      ra   r  zVOTableFile.version  sf    g,,$555%{{4+FGG)%) ) )    rc   c                     | j         S )zu
        A list of coordinate system descriptions for the file.  Must
        contain only `CooSys` objects.
        r  r   s    ra   r  zVOTableFile.coordinate_systems  r  rc   c                     | j         S )zp
        A list of time system descriptions for the file.  Must
        contain only `TimeSys` objects.
        r  r   s    ra   r  zVOTableFile.time_systems  r  rc   c                     | j         S )z
        A list of parameters (constant-valued columns) that apply to
        the entire file.  Must contain only `Param` objects.
        r  r   s    ra   r  zVOTableFile.params  r<  rc   c                     | j         S )z
        A list of informational parameters (key-value pairs) for the
        entire file.  Must only contain `Info` objects.
        r  r   s    ra   r  zVOTableFile.infos  ro  rc   c                     | j         S )zz
        A list of resources, in the order they appear in the file.
        Must only contain `Resource` objects.
        r  r   s    ra   r  zVOTableFile.resources  r  rc   c                     | j         S )z
        A list of groups, in the order they appear in the file.  Only
        supported as a child of the VOTABLE element in VOTable 1.2 or
        later.
        r  r   s    ra   r  zVOTableFile.groups  s     |rc   c                     t          | f||d|}| j                            |           |                    ||           d S r  )rL   r  rV  r  r  s          ra   r  zVOTableFile._add_param  r  rc   c                     t          d||d|}| j                            |           |                    | ||           d S r  )rS   r  rV  r  r  s          ra   r  zVOTableFile._add_resource  sN    ;6s;;d;;h'''tXv.....rc   c                     t          d||d|}| j                            |           |                    ||           d S r  r  r  s          ra   r	  zVOTableFile._add_coosys  r
  rc   c                     t          d||d|}| j                            |           |                    ||           d S r  r  r  s          ra   r  zVOTableFile._add_timesys  r  rc   c                     t          d||d|}| j                            |           |                    ||           d S r  r  r#  s          ra   r$  zVOTableFile._add_info  r   rc   c                     |                     d          st          t          t          d||           t          | f||d|}| j                            |           |                    ||           d S )Nr   )r  VOTABLEr   rC  )r   rE   r.   rQ   r  rV  r  r  s          ra   r  zVOTableFile._add_group  s{    zz011 	N#s$?MMMd;6s;;d;;5!!!Hf%%%%%rc   c                    i }t          j        | j        d          dk    |d<   t          j        | j        d          dk    |d<   t          j        | j        d          dk    |d<   t          j        | j        d          dk    |d	<   |S )
N1.1r   r   r   r   1.3r?  r'  r   )r   version_comparer  )rk   r   s     ra   r  zVOTableFile._get_version_checks  s    )-)=dlE)R)RVW)W%&)-)=dlE)R)RVW)W%&)-)=dlE)R)RVW)W%&)-)=dlE)R)RVW)W%&rc   z$http://www.ivoa.net/xml/VOTable/v1.1zxsi:noNamespaceSchemaLocation)namespace_urischema_location_attrschema_location_valuez$http://www.ivoa.net/xml/VOTable/v1.2z$http://www.ivoa.net/xml/VOTable/v1.3zxsi:schemaLocationzThttp://www.ivoa.net/xml/VOTable/v1.3 http://www.ivoa.net/xml/VOTable/VOTable-1.3.xsdzThttp://www.ivoa.net/xml/VOTable/v1.3 http://www.ivoa.net/xml/VOTable/VOTable-1.4.xsd)r@  r   rA  r'  c           	         d|d<   |D ]\  }}}}|r}|dk    r|dk    rXd|vr-t          t          t          | j        ||           | j        |d<   n|d         x|d<   | _        |d                                                             d          r=t          t          t          |d         ||           |d         dd          x| _        |d<   |d         | j        vrt          t          |d         ||           d|v rb| j        
                    |d         i           }|
                    d	          }|d         |k    rt          t          ||d         f||           nt          t          d
||            nt          t          d
||           |                    |                                            | j        | j        | j        | j        | j        | j        | j        | j        d}	|D ]e\  }}}}|r) |	
                    || j                  |||||           2|dk    r-| j        t          t6          t6          d||           |pd | _        ft9          | j                  s%|d         rt          t<          t<          d
||           | S )Nr   r(  xmlr>  r  vr	   xmlnsrC  r   )r  r+  re  r  rc  DEFINITIONSrD  r  rD  r   )rE   r+   r  r,  r  r  r1   r+  rD   r,   r   r9   r:   rB   r   r  r  r  r  r	  r  r$  r   r   r  r   r   r(   r\   r  r@   )
rk   rq   r   r  r   r   r   ns_info
correct_nsr  s
             ra   r  zVOTableFile.parse  s   *+&'%- 	3 	3!E3c 3%<<I%% ,,%c3fcJJJ,0Ly))<@OKy)DM!),2244??DD V)#sF94EvsSSS@Fy@QRSRTRT@UUDMF9,=!),D4OOO#C	):FCHHH$"&"="A"A&BSUW"X"X%,[[%A%A
=J66#C*d7m)DfcRRRR555ES"fc222d..00111 _*&(N0+_	
 	
 &. 	0 	0!E3c 0;T%:;;c4    %%#/!#sIvsCCC#'<4 4>"" 	5v.D'E 	5#sB444rc   Fc           	         |.|                                 dvrt          dt           d          | j        ||dd}|                    |                                            t          j        ||          5 }t          |          }| j        }|t          }	n|}	d}
|
                     |
                                j        di t                                 |d	d
}| j                            |i           }|                    d          }|r||d<   |                    d          }|                    d          }|r|r|||<   |                    d|          5  | j        |                    d| j        d           | j        | j        | j        | j        | j        g}|d         r
| j        |d<   |D ]}|D ]} |j        |fi | 	 ddd           n# 1 swxY w Y   ddd           dS # 1 swxY w Y   dS )a  
        Write to an XML file.

        Parameters
        ----------
        fd : str or file-like
            Where to write the file. If a file-like object, must be writable.

        compressed : bool, optional
            When `True`, write to a gzip-compressed file.  (Default:
            `False`)

        tabledata_format : str, optional
            Override the format of the table(s) data to write.  Must
            be one of ``tabledata`` (text representation), ``binary`` or
            ``binary2``.  By default, use the format that was specified
            in each `Table` object as it was created or read in.  See
            :ref:`astropy:votable-serialization`.
        N)r  r  r  zUnknown format type 'r  r	   )r  r  r  _group_number)
compressedz
<?xml version="1.0" encoding="utf-8"?>
<!-- Produced with astropy.io.votable version {lib_version}
     http://www.astropy.org/ -->
z)http://www.w3.org/2001/XMLSchema-instance)r  z	xmlns:xsirC  rI  rD  rE  r>  rD  TrN  r   r   r   )r  r   ru   r  r  r  r   convert_to_writable_fileliker   astropy_versionr  lstriplocalsr+  r   r   r   rn   r  r  r  r  r  r  r  )rk   r  rO  r  r  _astropy_versionr  r  r  lib_version
xml_headervotable_attrrK  rC  rD  rE  element_setsr  rn   s                      ra   r  zVOTableFile.to_xmlI  s   6 '%%''/QQQ !B!B!B!BCCC | 0*D	
 
 	d..00111.rjIII *	4R"AlG'-.&J GG.J%%''.::::;;; #H L 155grBBG#KK88M 6(5W%#*;;/E#F#F $+KK0G$H$H!# K(= K5J12y,// 4 4#/IImT-=DIIII+%KJN  01 2&*kLO#/ 4 4K#. 4 4&q33F3333444 4 4 4 4 4 4 4 4 4 4 4 4 4 49*	4 *	4 *	4 *	4 *	4 *	4 *	4 *	4 *	4 *	4 *	4 *	4 *	4 *	4 *	4 *	4 *	4 *	4s8   :C(G6"A/GG6G"	"G6%G"	&G66G:=G:c              #   R   K   | j         D ]}|                                E d{V  dS )z~
        Iterates over all tables in the VOTable file in a "flat" way,
        ignoring the nesting of resources etc.
        N)r  r  r  s     ra   r  zVOTableFile.iter_tables  sJ      
  	. 	.H++----------	. 	.rc   c                 ~    |                                  D ]}|                                s|c S t          d          )z
        Often, you know there is only one table in the file, and
        that's all you need.  This method returns that first table.
        zNo table found in VOTABLE file.)r  r   
IndexErrorrk   r  s     ra   get_first_tablezVOTableFile.get_first_table  sN    
 %%'' 	 	E>>## :;;;rc   r   Tr  r  zh
        Looks up a TABLE_ element by the given ID.  Used by the table
        "ref" attribute.
        r   zu
        Looks up a TABLE_ element by the given utype, and returns an
        iterator emitting all matches.
        c                     t          |                                           D ]\  }}||k    r|c S t          d|dd          )zB
        Get a table by its ordinal position in the file.
        zNo table at index r^  z found in VOTABLE file.)r  r  r[  )rk   idxr  r  s       ra   get_table_by_indexzVOTableFile.get_table_by_index  s_     "$"2"2"4"455 	 	HAuCxx LcLLLLMMMrc   c              #   R   K   | j         D ]}|                                E d{V  dS )zg
        Recursively iterate over all FIELD_ and PARAM_ elements in the
        VOTABLE_ file.
        N)r  r  r  s     ra   r  z"VOTableFile.iter_fields_and_params  sJ      
  	9 	9H668888888888	9 	9rc   r  r  zk
        Looks up a FIELD_ element by the given ID_.  Used by the field's
        "ref" attribute.
        zt
        Looks up a FIELD_ element by the given utype and returns an
        iterator emitting all matches.
        zE
        Looks up a FIELD_ element by the given ID_ or name.
        c              #   J   K   |                                  D ]}|j        V  dS )z]
        Recursively iterate over all VALUES_ elements in the VOTABLE_
        file.
        N)r  r  r  s     ra   iter_valueszVOTableFile.iter_values  s>      
 0022 	 	E,	 	rc   rc  r  zj
        Looks up a VALUES_ element by the given ID.  Used by the values
        "ref" attribute.
        c              #   l   K   |                                  D ]}|                                E d{V  dS )z\
        Recursively iterate over all GROUP_ elements in the VOTABLE_
        file.
        N)r  r  r\  s     ra   r  zVOTableFile.iter_groups  sT      
 %%'' 	+ 	+E((**********	+ 	+rc   r  r  zi
        Looks up a GROUP_ element by the given ID.  Used by the group's
        "ref" attribute
        zt
        Looks up a GROUP_ element by the given utype and returns an
        iterator emitting all matches.
        c              #   l   K   | j         E d{V  | j        D ]}|                                E d{V  dS )z]
        Recursively iterate over all COOSYS_ elements in the VOTABLE_
        file.
        Nr  r  s     ra   r  zVOTableFile.iter_coosys$  r   rc   r  re  z+Looks up a COOSYS_ element by the given ID.c              #   l   K   | j         E d{V  | j        D ]}|                                E d{V  dS )z^
        Recursively iterate over all TIMESYS_ elements in the VOTABLE_
        file.
        Nr"  r  s     ra   r#  zVOTableFile.iter_timesys5  r$  rc   r#  r  z,Looks up a TIMESYS_ element by the given ID.c              #   l   K   | j         E d{V  | j        D ]}|                                E d{V  dS )z[
        Recursively iterate over all INFO_ elements in the VOTABLE_
        file.
        N)r  r  r  r  s     ra   r  zVOTableFile.iter_infoF  sd      
 : 	, 	,H))++++++++++	, 	,rc   r  rc  z(Looks up a INFO element by the given ID.r   z.Returns all INFO children with the given name.c                 B    |                                  D ]	}||_        
dS )zJ
        Set the output storage format of all tables in the file.
        N)r  ru   )rk   ru   r  s      ra   set_all_tables_formatz!VOTableFile.set_all_tables_format[  s2     %%'' 	" 	"E!ELL	" 	"rc   c                      |             }t                      }t                              ||          }|||_        |j                            |           |j                            |           |S )z
        Create a `VOTableFile` instance from a given
        `astropy.table.Table` instance.

        Parameters
        ----------
        table_id : str, optional
            Set the given ID attribute on the returned Table instance.
        )rS   rR   r  r   r  rV  r  )r]  r  r)  votable_filer  r  s         ra   r  zVOTableFile.from_tableb  sm     suu::""<77!GJw'''%%h///rc   )NNNNr'  )FNFNrw   )3r   r   r   ry   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  get_tables_by_utyper`  r  r  r  r   r  rc  r  r  r  r  r  get_coosys_by_idr#  get_timesys_by_idr  get_info_by_idget_infos_by_nameri  ra  r  r   rc   ra   rT   rT   L  s               <? ? ?   X ^    ^  ( ( X( " " X"   X   X   X   X& & &
/ / /
' ' '
( ( (
% % %
& & &   D$C%K
 
 D$C%K
 
 D$8C	
 
 D$8C	
 
A( (T8 8 8z #(Q4 Q4 Q4 Q4f. . .< < < .-		 	O 21		 	N N N9 9 9 .- 		 	O 21 		 	 <; 	    /.		 	+ + + .-		 	O 21		 	. . . /.9 / / / 0/: , , , -,dK)W N 0/< " " "    [  rc   rT   )NN){rS  r  rw  r  r   urllib.requestr  r*  numpyr  r   r  r   rQ  
astropy.ior   astropy.utils.collectionsr   astropy.utils.exceptionsr   astropy.utils.xml.writerr   r   r
   r   r   r   r   
exceptionsr   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)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   r  ImportError__all__rW  r  rb   r|   r   r   r   r   r   r   r   r   r   r   r   r   r   rU   r
  r  rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   r   rc   ra   <module>rz     s  
    				 				                3 2 2 2 2 2       5 5 5 5 5 5 > > > > > > . . . . . .                    : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :x$" $ $ $#$  (  
 
 
B B BJ!  !  ! H	 	 	     0   .   ! ! ! !L       &               (       4       :! ! ! ! ! ! ! !(5$ 5$ 5$ 5$ 5$ 5$ 5$ 5$pT T T T TG T T T6) ) ) ) )} ) ) )X} } } } }=+ } } }@mD mD mD mD mD#[.. mD mD mD`E: E: E: E: E:Wk E: E: E:P
Z Z Z Z ZZ Z ZzN  N  N  N  N E N  N  N b| | | | |] | | |~C! C! C! C! C!m C! C! C!L?T ?T ?T ?T ?T}nl ?T ?T ?TD>U >U >U >U >U}nl >U >U >UBZ/ Z/ Z/ Z/ Z/Z/ Z/ Z/z{ { { { {G[-?S { { {|Z, Z, Z, Z, Z,[-9MZ, Z, Z,zh h h h h';(< h h h h hs   C C#"C#