
    HR-eO                         d Z ddlZddlZddlmZ ddlmZ dZ	dZ
de	z   e
z   Z ej        e          Zd Zdd	Zd
 ZddZd ZdS )zm
Module for parsing astronomical object names to extract embedded coordinates
eg: '2MASS J06495091-0737408'.
    N)SkyCoordz)()([0-2]\d)([0-5]\d)([0-5]\d)\.?(\d{0,3})z-([+-])(\d{1,2})([0-5]\d)([0-5]\d)\.?(\d{0,3})z(.*?J)c                     | \  }}}}}|dk    rdnd}d                     ||f          }|t          j        |||gt                    z  S )N-   .)joinnparrayfloat)gsignhmsfracs         ;lib/python3.11/site-packages/astropy/coordinates/jparser.py_sexagesimalr      sU    D!Q4#++22AD!TA"(Aq!9e,,,,    Fc                 `    t                               |           }||rt          d          |S )z$Regex match for coordinates in name.NzNo coordinate match found!)JPARSERsearch
ValueError)nameraise_matchs      r   r   r      s2     NN4  E}}5666Lr   c                 p   t          | d                                          }t          j        |ddg          \  }}}t	          |          dz  t
          j        z                                  }t	          |          t
          j        t
          j	        t
          j
        fz                                  }||fS )z7get RA in hourangle and DEC in degrees by parsing name.Tr      )r   <   i  )r   groupsr
   splitr   u	houranglesumdegarcminarcsec)r   r    prefixhmsdmsradecs          r   to_ra_dec_anglesr-   $   s    D$&&((FxA//FC
s

.
.
<	A	A	C	CBqx::
?
?
A
ACs7Nr   icrsc                 4    t          t          |           d|iS )z(Convert to `name` to `SkyCoords` object.frame)r   r-   )r   r0   s     r   to_skycoordr1   -   s    %d++95999r   c           
      z    t          |           }d                    |                    dddddd                    S )a~  Produce a shortened version of the full object name.

    The shortened name is built from the prefix (usually the survey name) and RA (hour,
    minute), DEC (deg, arcmin) parts.
    e.g.: '2MASS J06495091-0737408' --> '2MASS J0649-0737'

    Parameters
    ----------
    name : str
        Full object name with J-coords embedded.

    Returns
    -------
    shortName: str
     r               	   )r   r	   group)r   r   s     r   shortenr:   2   s7      4LLE775;;q!Q1a00111r   )F)r.   )__doc__renumpyr
   astropy.unitsunitsr"   astropy.coordinatesr   RA_REGEX	DEC_REGEXJCOORD_REGEXcompiler   r   r   r-   r1   r:    r   r   <module>rF      s    
 
			           ( ( ( ( ( (7<	("Y.
"*\
"
"- - -     : : : :
2 2 2 2 2r   