示例#1
0
        field = np.zeros(GRID, dtype=np.float32)
        lo = dendec[d]
        hi = dendec[d+1]
        print("getting low mask: %.3e"%lo)
        mask1 = n_h >= lo
        print("low mask has %d cells in it"%np.sum(mask1))
        print("getting high mask: %.3e"%hi)
        mask2 = n_h < hi
        print("high mask has %d cells in it"%np.sum(mask2))
        mask = mask1 & mask2
        counts[d] = np.sum(mask)
        print("in the <%.3e bin there are %d cells, has average %.4e"%(hi, counts[d], np.mean(n_h[mask])))

        posmask = pos[mask,:]
        if m is "total":
            massmask = mass[mask] * f_neut_h[mask]
        else:
            massmask = mass[mask] * f_neut_h[mask] * (1-molfrac[mask])
        
        
        CICW(posmask,field,BOXSIZE,massmask)
        w.create_dataset("%s_<%.3e"%(m,dendec[d]), data=field, compression="gzip", compression_opts=9)
        field = np.zeros(GRID, dtype=np.float32)
        velmask = vel[:,mask]
        posmask = pos_redshift_space(posmask, velmask, BOXSIZE, LITTLE_H*100, REDSHIFT, AXIS)
        CICW(posmask,field,BOXSIZE,massmask)
        wrs.create_dataset("%s_<%.3e"%(m,dendec[d]), data=field, compression="gzip", compression_opts=9)
w.create_dataset("bin_counts",data=counts)
wrs.create_dataset("bin_counts", data=counts)
w.close()
示例#2
0
except KeyError:
    pnt.write("did not find any information in the file for %d" % CHUNK)
    found_file = False
field = np.zeros(GRID, dtype=np.float32)

w.close()

pnt.write('creating new grid for redshift space...')
field = np.zeros(GRID, dtype=np.float32)

pnt.write('starting loop for redshift-space...')
for p in ptltype:
    pnt.writeTab("getting data for %s" % p)
    if '1' in p:
        mass = np.ones(nptl[1]) * DMPTL
    else:
        mass = ptlfile[p]['Masses'][:] * 1e10 / LITTLE_H  # solar masses
    pos = ptlfile[p]['Coordinates'][:] / 1e3 * SCALE  # Mpc/h
    vel = ptlfile[p]['Velocities'][:] * np.sqrt(SCALE)  # km/s
    pnt.writeTab("moving positions to redshift space...")
    pos = pos_redshift_space(pos, vel, BOXSIZE, LITTLE_H * 100, REDSHIFT, AXIS)
    # assigning them into the field using the Mass Assignment Scheme given
    pnt.writeTab("assigning to redshift-space grid...")
    CICW(pos, field, BOXSIZE, mass)

pnt.write("saving redshift-space grid...")
wrs.create_dataset("particles",
                   data=field,
                   compression="gzip",
                   compression_opts=9)
wrs.close()
示例#3
0
pnt.write("getting the HI from Paco's method...")
pos, MHI = vnhi(PTLPATH + "snap_%03d.%d.hdf5" % (SNAPSHOT, CHUNK), TREECOOL)

# returns positions in cMpc, mass in solar masses/h
MHI *= 1 / LITTLE_H
pos *= SCALE_FACTOR  # to convert from comoving

vel = ptlfile['PartType0']['Velocities'][:] * np.sqrt(SCALE_FACTOR)  # km/s

pnt.write("creating the real-space grid...")
field = np.zeros(GRID, dtype=np.float32)

pnt.write("placing the real-space data into the grid...")
CICW(pos, field, BOXSIZE, MHI)
pnt.write("saving the real-space data...")
w.create_dataset("v-n", data=field, compression="gzip", compression_opts=9)

pnt.write("creating new grid for redshift-space...")
field = np.zeros(GRID, dtype=np.float32)

pnt.write("shifting the positions into redshift-space...")
rspos = pos_redshift_space(pos, vel, BOXSIZE, 100 * LITTLE_H, REDSHIFT, AXIS)

pnt.write("placing redshift-space data into the grid...")
CICW(rspos, field, BOXSIZE, MHI)
pnt.write("saving the redshift-space data...")
wrs.create_dataset("v-n", data=field, compression="gzip", compression_opts=9)
wrs.close()
w.close()
ptlfile.close()