py/prospect/utilities.py
def create_zcat_from_redrock_cat(redrock_cat, fit_num=0):
    """ Extract a catalog with unique redshift fits from a redrock catalog containing several fit results per TARGETID

    Parameters
    ----------
    redrock_cat : :class:`~astropy.table.Table`
        Catalog with rows as defined in `match_rrdetails_to_spectra()`
    fit_num : :class:`int`, optional
        The (fit_num)th fit in redrock_cat is extracted (default: 0 ie. redrock's best fit)

    Returns
    -------
    :class:`~astropy.table.Table`
        Table with the following columns: TARGETID, CHI2, COEFF, Z, ZERR, ZWARN, SPECTYPE, SUBTYPE, DELTACHI2.
    """

    rr_cat_num_best_fits = redrock_cat['Z'].shape[1]
    if (fit_num >= rr_cat_num_best_fits):
        raise ValueError("fit_num too large wrt redrock_cat")
    zcat_dtype=[('TARGETID', '<i8'), ('CHI2', '<f8'), ('COEFF', '<f8', (10,)),
                ('Z', '<f8'), ('ZERR', '<f8'), ('ZWARN', '<i8'),
                ('SPECTYPE', '<U6'), ('SUBTYPE', '<U2'), ('DELTACHI2', '<f8')]
    zcat_out = Table( data=np.zeros(len(redrock_cat), dtype=zcat_dtype) )
    zcat_out['TARGETID'] = redrock_cat['TARGETID']
    for key in ['CHI2', 'DELTACHI2', 'COEFF', 'SPECTYPE', 'SUBTYPE', 'Z', 'ZERR', 'ZWARN']:
        zcat_out[key] = redrock_cat[key][:,fit_num]

    return zcat_out
 Extract a catalog with unique redshift fits from a redrock catalog containing several fit results per TARGETID

    Parameters
    ----------
    redrock_cat : :class:`~astropy.table.Table`
        Catalog with rows as defined in `match_rrdetails_to_spectra()`
    fit_num : :class:`int`, optional
        The (fit_num)th fit in redrock_cat is extracted (default: 0 ie. redrock's best fit)

    Returns
    -------
    :class:`~astropy.table.Table`
        Table with the following columns: TARGETID, CHI2, COEFF, Z, ZERR, ZWARN, SPECTYPE, SUBTYPE, DELTACHI2.
    
Extract a catalog with unique redshift fits from a redrock catalog containing several fit results per TARGETID
Parameters



Returns
Extract a catalog with unique redshift fits from a redrock catalog containing several fit results per TARGETID Parameters Returns
def create_zcat_from_redrock_cat(redrock_cat, fit_num=0):
    rr_cat_num_best_fits = redrock_cat['Z'].shape[1]
    if (fit_num >= rr_cat_num_best_fits):
        raise ValueError("fit_num too large wrt redrock_cat")
    zcat_dtype=[('TARGETID', '<i8'), ('CHI2', '<f8'), ('COEFF', '<f8', (10,)),
                ('Z', '<f8'), ('ZERR', '<f8'), ('ZWARN', '<i8'),
                ('SPECTYPE', '<U6'), ('SUBTYPE', '<U2'), ('DELTACHI2', '<f8')]
    zcat_out = Table( data=np.zeros(len(redrock_cat), dtype=zcat_dtype) )
    zcat_out['TARGETID'] = redrock_cat['TARGETID']
    for key in ['CHI2', 'DELTACHI2', 'COEFF', 'SPECTYPE', 'SUBTYPE', 'Z', 'ZERR', 'ZWARN']:
        zcat_out[key] = redrock_cat[key][:,fit_num]
    return zcat_out
def create_zcat_from_redrock_cat ( redrock_cat , fit_num = 0 ) : rr_cat_num_best_fits = redrock_cat [ 'Z' ] . shape [ 1 ] if ( fit_num >= rr_cat_num_best_fits ) : raise ValueError ( "fit_num too large wrt redrock_cat" ) zcat_dtype = [ ( 'TARGETID' , '<i8' ) , ( 'CHI2' , '<f8' ) , ( 'COEFF' , '<f8' , ( 10 , ) ) , ( 'Z' , '<f8' ) , ( 'ZERR' , '<f8' ) , ( 'ZWARN' , '<i8' ) , ( 'SPECTYPE' , '<U6' ) , ( 'SUBTYPE' , '<U2' ) , ( 'DELTACHI2' , '<f8' ) ] zcat_out = Table ( data = np . zeros ( len ( redrock_cat ) , dtype = zcat_dtype ) ) zcat_out [ 'TARGETID' ] = redrock_cat [ 'TARGETID' ] for key in [ 'CHI2' , 'DELTACHI2' , 'COEFF' , 'SPECTYPE' , 'SUBTYPE' , 'Z' , 'ZERR' , 'ZWARN' ] : zcat_out [ key ] = redrock_cat [ key ] [ : , fit_num ] return zcat_out
Extract a catalog with unique redshift fits from a redrock catalog containing several fit results per TARGETID
Parameters
Extract a catalog with unique redshift fits from a redrock catalog containing several fit results per TARGETID Parameters
""" Extract a catalog with unique redshift fits from a redrock catalog containing several fit results per TARGETID

    Parameters
    ----------
    redrock_cat : :class:`~astropy.table.Table`
        Catalog with rows as defined in `match_rrdetails_to_spectra()`
    fit_num : :class:`int`, optional
        The (fit_num)th fit in redrock_cat is extracted (default: 0 ie. redrock's best fit)

    Returns
    -------
    :class:`~astropy.table.Table`
        Table with the following columns: TARGETID, CHI2, COEFF, Z, ZERR, ZWARN, SPECTYPE, SUBTYPE, DELTACHI2.
    """
redrock_cat
fit_num
class
None