Exemplo n.º 1
0
def write_legacysurvey_randoms(input_fn, truth_fn, randoms_fn, bricknames=[], seed=None):
    """Build Obiwan randoms from legacysurvey randoms and truth table."""
    randoms = SimCatalog(input_fn)
    logger.info('Selecting randoms in %s' % bricknames)
    mask = np.in1d(randoms.brickname,bricknames)
    randoms = randoms[mask]
    randoms.rename('targetid','id')
    logger.info('Selected random catalog of size = %d.' % randoms.size)
    randoms.keep_columns('id','ra','dec','maskbits','photsys','brickname')

    for photsys in ['N','S']:
        truth = get_truth(truth_fn,south=photsys=='S')
        mask = randoms.photsys == photsys
        if mask.any():
            randoms.fill(sample_from_truth(randoms[mask],truth,seed=seed),index_self=mask,index_other=None)

    randoms.writeto(randoms_fn)
Exemplo n.º 2
0
def get_truth(truth_fn, south=True):
    """Build truth table."""
    truth = SimCatalog(truth_fn)
    mask = (truth.g >= 22.) & (truth.g <= 24.)
    for b in ['g','r','z']:
        mask &= (~np.isnan(truth.get(b))) & (~np.isinf(truth.get(b)))
    logger.info('Target selection: %d/%d objects' % (mask.sum(),mask.size))
    truth = truth[mask]
    truth.rename('objid','id_truth')
    truth.rename('rhalf','shape_r')
    #truth.shape_r = 1e-5*truth.ones()
    truth.rename('hsc_mizuki_photoz_best','redshift')
    truth.sersic = truth.ones(dtype=int)
    truth.sersic[truth.type=='DEV'] = 4
    return truth
Exemplo n.º 3
0
def get_truth(truth_fn, south=True):
    """Build truth table."""
    truth = SimCatalog(truth_fn)
    mask = isELG_colors(south=south,
                        gmarg=0.5,
                        grmarg=0.5,
                        rzmarg=0.5,
                        **{
                            '%sflux' % b: utils.mag2nano(truth.get(b))
                            for b in ['g', 'r', 'z']
                        })
    for b in ['g', 'r', 'z']:
        mask &= (~np.isnan(truth.get(b))) & (~np.isinf(truth.get(b)))
    logger.info('Target selection: %d/%d objects' % (mask.sum(), mask.size))
    truth = truth[mask]
    truth.rename('objid', 'id_truth')
    truth.rename('rhalf', 'shape_r')
    #truth.shape_r = 1e-5*truth.ones()
    truth.rename('hsc_mizuki_photoz_best', 'redshift')
    truth.sersic = truth.ones(dtype=int)
    truth.sersic[truth.type == 'DEV'] = 4
    return truth