py/prospect/utilities.py
def match_catalog_to_spectra(zcat_in, spectra, return_index=False):
    """ Creates a subcatalog, matching a set of DESI spectra

    Parameters
    ----------
    zcat_in : :class:`~astropy.table.Table`, with TARGETID keys
    spectra : :class:`~desispec.spectra.Spectra`
    return_index : :class:`bool`, optional
        If ``True``, returns the list of indices in zcat_in which match spectra

    Returns
    -------
    :class:`~astropy.table.Table`
        A subtable of zcat_in, with rows matching input spectra's TARGETIDs
        If return_index is ``True``, returns (subtable, list of indices)

    Raises
    ------
    RuntimeError
        If a unique row in zcat_in is not found matching each of spectra's TARGETIDs
    """

    if zcat_in is None : return None

    zcat_out = Table(dtype=zcat_in.dtype)
    index_list = list()
    for i_spec in range(spectra.num_spectra()) :
        ww, = np.where((zcat_in['TARGETID'] == spectra.fibermap['TARGETID'][i_spec]))
        if len(ww)<1 :
            raise RuntimeError("No entry in zcat_in for TARGETID "+str(spectra.fibermap['TARGETID'][i_spec]))
        elif len(ww)>1 :
            raise RuntimeError("Several entries in zcat_in for TARGETID "+str(spectra.fibermap['TARGETID'][i_spec]))
        # zcat_out.add_row(zcat_in[ww[0]]) seems to convert '' to '0.0' (eg. SUBTYPE) with astropy 5.0 (?)
        #   so we use vstack instead
        zcat_out = vstack([zcat_out, zcat_in[ww[0]]])
        index_list.append(ww[0])
    if return_index:
        return (zcat_out, index_list)
    else:
        return zcat_out
 Creates a subcatalog, matching a set of DESI spectra

    Parameters
    ----------
    zcat_in : :class:`~astropy.table.Table`, with TARGETID keys
    spectra : :class:`~desispec.spectra.Spectra`
    return_index : :class:`bool`, optional
        If ``True``, returns the list of indices in zcat_in which match spectra

    Returns
    -------
    :class:`~astropy.table.Table`
        A subtable of zcat_in, with rows matching input spectra's TARGETIDs
        If return_index is ``True``, returns (subtable, list of indices)

    Raises
    ------
    RuntimeError
        If a unique row in zcat_in is not found matching each of spectra's TARGETIDs
    
Creates a subcatalog, matching a set of DESI spectra
Parameters



Returns
Creates a subcatalog matching a set of DESI spectra Parameters Returns
def match_catalog_to_spectra(zcat_in, spectra, return_index=False):
    if zcat_in is None : return None
    zcat_out = Table(dtype=zcat_in.dtype)
    index_list = list()
    for i_spec in range(spectra.num_spectra()) :
        ww, = np.where((zcat_in['TARGETID'] == spectra.fibermap['TARGETID'][i_spec]))
        if len(ww)<1 :
            raise RuntimeError("No entry in zcat_in for TARGETID "+str(spectra.fibermap['TARGETID'][i_spec]))
        elif len(ww)>1 :
            raise RuntimeError("Several entries in zcat_in for TARGETID "+str(spectra.fibermap['TARGETID'][i_spec]))
        zcat_out = vstack([zcat_out, zcat_in[ww[0]]])
        index_list.append(ww[0])
    if return_index:
        return (zcat_out, index_list)
    else:
        return zcat_out
def match_catalog_to_spectra ( zcat_in , spectra , return_index = False ) : if zcat_in is None : return None zcat_out = Table ( dtype = zcat_in . dtype ) index_list = list ( ) for i_spec in range ( spectra . num_spectra ( ) ) : ww , = np . where ( ( zcat_in [ 'TARGETID' ] == spectra . fibermap [ 'TARGETID' ] [ i_spec ] ) ) if len ( ww ) < 1 : raise RuntimeError ( "No entry in zcat_in for TARGETID " + str ( spectra . fibermap [ 'TARGETID' ] [ i_spec ] ) ) elif len ( ww ) > 1 : raise RuntimeError ( "Several entries in zcat_in for TARGETID " + str ( spectra . fibermap [ 'TARGETID' ] [ i_spec ] ) ) zcat_out = vstack ( [ zcat_out , zcat_in [ ww [ 0 ] ] ] ) index_list . append ( ww [ 0 ] ) if return_index : return ( zcat_out , index_list ) else : return zcat_out
Creates a subcatalog, matching a set of DESI spectra
Parameters
Creates a subcatalog matching a set of DESI spectra Parameters
""" Creates a subcatalog, matching a set of DESI spectra

    Parameters
    ----------
    zcat_in : :class:`~astropy.table.Table`, with TARGETID keys
    spectra : :class:`~desispec.spectra.Spectra`
    return_index : :class:`bool`, optional
        If ``True``, returns the list of indices in zcat_in which match spectra

    Returns
    -------
    :class:`~astropy.table.Table`
        A subtable of zcat_in, with rows matching input spectra's TARGETIDs
        If return_index is ``True``, returns (subtable, list of indices)

    Raises
    ------
    RuntimeError
        If a unique row in zcat_in is not found matching each of spectra's TARGETIDs
    """ # zcat_out.add_row(zcat_in[ww[0]]) seems to convert '' to '0.0' (eg. SUBTYPE) with astropy 5.0 (?) #   so we use vstack instead
zcat_in
spectra
return_index
class
`~astropy.table.Table`
A subtable of zcat_in, with rows matching input spectra's TARGETIDs
If return_index is ``True``, returns (subtable, list of indices)

Raises

RuntimeError
If a unique row in zcat_in is not found matching each of spectra's TARGETIDs
` ~astropy . table . Table ` A subtable of zcat_in with rows matching input spectra ' s TARGETIDs If return_index is ` ` True ` ` returns ( subtable list of indices ) Raises RuntimeError If a unique row in zcat_in is not found matching each of spectra ' s TARGETIDs