def assemblybias_mocks(i0, i1):
    ''' Pl(k) of assembly bias test mocks 
    '''
    for i_fid in range(i0, i1 + 1):
        print('Fiducial %i' % i_fid)
        for i_ab in range(20):
            print('  HOD %i' % i_hod)
            fplk = os.path.join(
                dat_dir, 'tests', 'plk',
                'plk.hod.quijote_fid_hr%i.z0p5.cmass_sgc.abias%i.bf' %
                (i_fid, i_ab))
            if not os.path.isfile(fplk):
                # read galaxy catalog
                fgal = os.path.join(
                    dat_dir, 'tests',
                    'hod.quijote_fid_hr%i.z0p5.cmass_sgc.abias%i.bf' %
                    (i_fid, i_ab))
                gals = UT.read_bf_hod(fgal)

                # construct corresponding randoms
                rand = FM.BOSS_randoms(gals, veto=True, sample='cmass-south')

                # measure power spectrum
                k, p0k, p2k, p4k = CosmoObs.Plk_survey(gals,
                                                       rand,
                                                       Ngrid=360,
                                                       dk=0.005,
                                                       P0=1e4,
                                                       silent=True)

                # save power spectrum to file
                hdr = 'k, p0k, p2k, p4k'
                np.savetxt(fplk,
                           np.array([k, p0k, p2k, p4k]).T,
                           fmt='%.5e %.5e %.5e %.5e',
                           delimiter='\t',
                           header=hdr)

    return None
Beispiel #2
0
hod = Galaxies.hodGalaxies(halos, theta_hod, seed=0)
print('HOD takes %f sec' % ((time.time() - t0)))

# apply forward model
t0 = time.time()
gals = FM.BOSS(hod,
               sample='lowz-south',
               seed=0,
               veto=True,
               fiber_collision=False,
               silent=False)
print('forward model takes %f sec' % ((time.time() - t0)))

# get random
t0 = time.time()
rand = FM.BOSS_randoms(gals, sample='lowz-south', veto=True)
print('randoms take %f sec' % ((time.time() - t0)))

# calculate power spectrum
t0 = time.time()
k, p0k, p2k, p4k = Obs.Plk_survey(gals,
                                  rand,
                                  Ngrid=360,
                                  dk=0.005,
                                  P0=1e4,
                                  silent=False)
print('plk take %f sec' % ((time.time() - t0)))

# plot power spectrum
fig = plt.figure(figsize=(5, 5))
sub = fig.add_subplot(111)
for i_lhc in range(i0, i1):
    print('LHC %i' % i_lhc)
    for i_hod in range(5):
        print('  HOD %i' % i_hod)
        fplk = os.path.join(
            dat_dir,
            'plk.hod.quijote_LH%i.z0p5.cmass_sgc.%i.dat' % (i_lhc, i_hod))
        if not os.path.isfile(fplk):
            # read galaxy catalog
            fgal = os.path.join(
                dat_dir,
                'hod.quijote_LH%i.z0p5.cmass_sgc.%i.bf' % (i_lhc, i_hod))
            gals = UT.read_bf_hod(fgal)

            # construct corresponding randoms
            rand = FM.BOSS_randoms(gals, veto=True, sample='cmass-south')

            # measure power spectrum
            k, p0k, p2k, p4k = CosmoObs.Plk_survey(gals,
                                                   rand,
                                                   Ngrid=360,
                                                   dk=0.005,
                                                   P0=1e4,
                                                   silent=True)

            # save power spectrum to file
            hdr = 'k, p0k, p2k, p4k'
            np.savetxt(fplk,
                       np.array([k, p0k, p2k, p4k]).T,
                       fmt='%.5e %.5e %.5e %.5e',
                       delimiter='\t',