def getBias(file):
    fileN = os.path.basename(file)
    boxN = file.split('/')[3]
    boxZN = fileN.split('_')[1]
    f = open(file, 'r')
    bin_xi3D, xis, DR, volume, dV, pairCount, pairs, Ntotal, nD, nR, vbinsL, vbinsH = cPickle.load(
        f)
    f.close()

    rr = (bin_xi3D[1:] + bin_xi3D[:-1]) / 2.
    # print file
    m0 = float(fileN.split('_')[3])
    m1 = float(fileN.split('_')[4])

    m_low = 10**(m0) / cosmoMD.h
    m_high = 10**(m1) / cosmoMD.h
    m_mean = 10**((m0 + m1) / 2.) / cosmoMD.h
    print('masses', m_low, m_mean, m_high)
    boxLength, boxName, boxRedshift, logmp, boxLengthComoving, massCorrection = get_basic_info(
        file, int(boxZN), delta_wrt='mean')
    print('logMP, nData', logmp, nD)
    if m_mean > NminParticles * 10**logmp and nD > 10000:
        sig_low = m2sigma(m_high)
        sig_high = m2sigma(m_low)
        sig_mean = m2sigma(m_mean)
        print('sigma', sig_low, sig_mean, sig_high, sig_low < sig_mean,
              sig_mean < sig_high)
        xi = DR * volume / (dV * pairCount) - 1.
        ok = (rr > rmin) & (rr < rmax)
        scale = (n.min(rr[ok]) + n.max(rr[ok])) / 2.
        bias = n.mean(xi[ok] / linXi(rr[ok]))
        biasErr = n.std(xi[ok] / linXi(rr[ok]))
        #print [sig_low, sig_high, sig_mean, scale, bias, biasErr, volume, afactor]
        print('bias', bias)
        return [
            sig_low, sig_high, sig_mean, scale, bias, biasErr, volume, afactor,
            logmp
        ]

    else:
        #print [-99.99, -99.99, -99.99, -99.99, -99.99, -99.99, -99.99, -99.99, -99.99]
        return [
            -99.99, -99.99, -99.99, -99.99, -99.99, -99.99, -99.99, -99.99,
            -99.99
        ]
vmins = ["65.0", "72.9", "81.8", "91.8", "103.0", "115.5", "129.6", "145.5", "163.2", "183.1", "205.5", "230.6","258.7", "290.3", "325", "365.5", "410.1", "460.1", "516.3", "579.3", "650.0", "729.3", "818.3", "918.1", "1030.1", "1155.8", "1296.9"]

for vmin in vmins:
	list44 = n.array(glob.glob(join("..","MD_1Gpc","halo_bias","clustering","hlist_0.50320_vmax_"+vmin+"*rmax_050_xiR.pkl")))
	list42 = n.array(glob.glob(join("..","MD_0.4Gpc","halo_bias","clustering","hlist_0.50000_vmax_"+vmin+"*rmax_050_xiR.pkl")))
	list41 = n.array(glob.glob(join("..","MD_2.5Gpc","halo_bias","clustering","hlist_11_vmax_"+vmin+"*rmax_140_xiR.pkl")))
	list43 = n.array(glob.glob(join("..","MD_4Gpc","halo_bias","clustering","hlist_97_vmax_"+vmin+"*rmax_140_xiR.pkl")))
	list40=n.hstack((list41, list42, list43, list44))
	list40.sort()
	print list40
	p.figure(0,(11,6))
	p.axes([0.15,0.15,0.6,0.75])
	for ii in range(len(list40)):
		f=open(list40[ii],'r')
		bin_xi3D,xis, DR, volume, dV, pairCount, pairs, Ntotal, nD, nR, vbinsL, vbinsH = cPickle.load(f)
		f.close()
		if list40[ii].split('\\')[1] == "MD_0.4Gpc":
			color = 'w'
			volume = 400**3.
		if list40[ii].split('\\')[1] == "MD_1Gpc":
			color = 'b'
			volume = 1000**3.
		if list40[ii].split('\\')[1] == "MD_2.5Gpc":
			color = 'r'
			volume = 2500**3.
		if list40[ii].split('\\')[1] == "MD_4Gpc":
			color = 'm'
			volume = 4000**3.
		
		DR_rb = DR[::2][:-1] + DR[1::2]
		dV_rb =  dV[::2][:-1] + dV[1::2]
Beispiel #3
0
            join("..", "MD_2.5Gpc", "halo_bias", "clustering",
                 "hlist_11_vmax_" + vmin + "*rmax_140_xiR.pkl")))
    list43 = n.array(
        glob.glob(
            join("..", "MD_4Gpc", "halo_bias", "clustering",
                 "hlist_97_vmax_" + vmin + "*rmax_140_xiR.pkl")))
    list40 = n.hstack((list41, list42, list43, list44))
    list40.sort()
    print list40
    p.figure(0, (11, 6))
    p.axes([0.15, 0.15, 0.6, 0.75])
    for ii in range(len(list40)):
        f = open(list40[ii], 'r')
        bin_xi3D, xis, DR, volume, dV, pairCount, pairs, Ntotal, nD, nR, vbinsL, vbinsH = cPickle.load(
            f)
        f.close()
        if list40[ii].split('\\')[1] == "MD_0.4Gpc":
            color = 'w'
            volume = 400**3.
        if list40[ii].split('\\')[1] == "MD_1Gpc":
            color = 'b'
            volume = 1000**3.
        if list40[ii].split('\\')[1] == "MD_2.5Gpc":
            color = 'r'
            volume = 2500**3.
        if list40[ii].split('\\')[1] == "MD_4Gpc":
            color = 'm'
            volume = 4000**3.

        DR_rb = DR[::2][:-1] + DR[1::2]
        dV_rb = dV[::2][:-1] + dV[1::2]
Beispiel #4
0
def getBias(file):
		f=open(file,'r')
		bin_xi3D,xis, DR, volume, dV, pairCount, pairs, Ntotal, nD, nR, vbinsL, vbinsH = cPickle.load(f)
		f.close()
		rr = (bin_xi3D[1:] + bin_xi3D[:-1])/2.
		# print file
		aon = float(file.split('_')[-7])
		vlow= float(file.split('_')[-5])
		vhigh = float(file.split('_')[-4])
		vmean = (vlow * vhigh)**0.5
		if file.split('\\')[1] == "MD_0.4Gpc" and vlow>limits_04[0]:
			volume = 400**3.
			xi = DR*volume/(dV * pairCount) -1.
			ok = (rr>8)&(rr<20)
			vol = volume
			Rs, xiR  = n.loadtxt(join(dir,"Pk_DM_CLASS","multidark00_z"+a2snap[a0[n.searchsorted(a0,aon)]]+"_xi.dat"), unpack = True)
			linXi = interp1d(Rs,xiR)
			scale = (n.min(rr[rr>8])+n.max(rr[rr>8]))/2.
			bias = n.mean(xi[(rr>8)]/linXi(rr[(rr>8)]))
			biasErr = n.std(xi[(rr>8)]/linXi(rr[(rr>8)]))
			# print [vlow, vhigh,vmean, scale, bias, biasErr, vol, aon]
			return [vlow, vhigh,vmean, scale, bias, biasErr, vol, aon]
			
		if file.split('\\')[1] == "MD_1Gpc" and vlow>limits_10[0]:
			volume = 1000**3.
			xi = DR*volume/(dV * pairCount) -1.
			ok = (rr>8)&(rr<20)
			vol = volume
			Rs, xiR  = n.loadtxt(join(dir,"Pk_DM_CLASS","multidark00_z"+a2snap[a0[n.searchsorted(a0,aon)]]+"_xi.dat"), unpack = True)
			linXi = interp1d(Rs,xiR)
			scale = (n.min(rr[rr>8])+n.max(rr[rr>8]))/2.
			bias = n.mean(xi[(rr>8)]/linXi(rr[(rr>8)]))
			biasErr = n.std(xi[(rr>8)]/linXi(rr[(rr>8)]))
			# print [vlow, vhigh,vmean, scale, bias, biasErr, vol, aon]
			return [vlow, vhigh,vmean, scale, bias, biasErr, vol, aon]
			
		if file.split('\\')[1] == "MD_2.5Gpc" and vlow>limits_25[0]:
			n25, a25 = n.loadtxt(join("..","MD_2.5Gpc","redshift-list.txt"),unpack=True)
			aa = a25[(n25 == aon)][0]
			volume = 2500**3.
			xi = DR*volume/(dV * pairCount) -1.
			ok = (rr>8)&(rr<20)
			vol = volume
			Rs, xiR  = n.loadtxt(join(dir,"Pk_DM_CLASS","multidark00_z"+a2snap[a0[n.searchsorted(a0,aa)]]+"_xi.dat"), unpack = True)
			linXi = interp1d(Rs,xiR)
			scale = (n.min(rr[rr>8])+n.max(rr[rr>8]))/2.
			bias = n.mean(xi[(rr>8)]/linXi(rr[(rr>8)]))
			biasErr = n.std(xi[(rr>8)]/linXi(rr[(rr>8)]))
			# print [vlow, vhigh,vmean, scale, bias, biasErr, vol, a25[(n25 == aon)][0] ]
			return [vlow, vhigh,vmean, scale, bias, biasErr, vol,  aa]
			
		if file.split('\\')[1] == "MD_4Gpc" and vlow>limits_40[0]:
			n40, a40 = n.loadtxt(join("..","MD_4Gpc","redshift-list.txt"),unpack=True)
			aa = a40[(n40 == aon)][0]
			volume = 4000**3.
			xi = DR*volume/(dV * pairCount) -1.
			ok = (rr>8)&(rr<20)
			vol = volume
			Rs, xiR  = n.loadtxt(join(dir,"Pk_DM_CLASS","multidark00_z"+a2snap[a0[n.searchsorted(a0,aa)]]+"_xi.dat"), unpack = True)
			linXi = interp1d(Rs,xiR)
			scale = (n.min(rr[rr>8])+n.max(rr[rr>8]))/2.
			bias = n.mean(xi[(rr>8)]/linXi(rr[(rr>8)]))
			biasErr = n.std(xi[(rr>8)]/linXi(rr[(rr>8)]))
			# print [vlow, vhigh,vmean, scale, bias, biasErr, vol, a40[(n40 == aon)][0] ]
			return [vlow, vhigh,vmean, scale, bias, biasErr, vol, aa ]