コード例 #1
0
def saveMeanCorMatrix(ni,nj):
	'''

	Save the mean correlation matrix of the 100 correaltion matrix

	'''

	path       = '/home/gpfs/manip/mnt0607/bao/hdumasde/Mock_JMLG/v1547/noNoisenoCont/Box_00'
	pathToSave = '/home/gpfs/manip/mnt0607/bao/hdumasde/Mock_JMLG/v1547/noNoisenoCont/Results/xi_delta_QSO_result_'

	### Get the 0_0 simu
	cor1D = myTools.getCorrelationMatrix(numpy.load(path + '0/Simu_000/Results/subSampling_LYA_QSO_cov_1D.npy'))
	cor2D = myTools.getCorrelationMatrix(numpy.load(path + '0/Simu_000/Results/subSampling_LYA_QSO_cov_2D.npy'))

	for i in numpy.arange(ni):
		for j in numpy.arange(nj):

			if (i==0 and j==0): continue

			cor1D += myTools.getCorrelationMatrix(numpy.load(path + str(i)+'/Simu_00'+str(j)+'/Results/subSampling_LYA_QSO_cov_1D.npy'))
			cor2D += myTools.getCorrelationMatrix(numpy.load(path + str(i)+'/Simu_00'+str(j)+'/Results/subSampling_LYA_QSO_cov_2D.npy'))
	cor1D /= 100.
	cor2D /= 100.

	numpy.save(pathToSave+'cor_mean_1D', cor1D)
	numpy.save(pathToSave+'cor_mean_2D', cor2D)

	return
コード例 #2
0
def getResults():
    """
	
		Set the array of results and of data
	
	"""

    for i in numpy.arange(ni__):
        for j in numpy.arange(nj__):
            idx = i * nj__ + j

            pathData__ = (
                "/home/gpfs/manip/mnt0607/bao/hdumasde/Mock_JMLG/v1547/noNoisenoCont/Box_00"
                + str(i)
                + "/Simu_00"
                + str(j)
                + "/Results/BaoFit_q_f/bao"
                + type__
            )
            path__ = (
                "/home/gpfs/manip/mnt0607/bao/hdumasde/Mock_JMLG/v1547/noNoisenoCont/Box_00"
                + str(i)
                + "/Simu_00"
                + str(j)
                + "/Results/BaoFit_q_f/bao"
                + type__
            )
            pathOtherFit__ = (
                "/home/gpfs/manip/mnt0607/bao/hdumasde/Mock_JMLG/v1547/noNoisenoCont/Box_00"
                + str(i)
                + "/Simu_00"
                + str(j)
                + "/Results/BaoFit_q_f/bao"
                + type__
            )

            name2 = ".data"
            name1 = ".residuals.dat"
            name3 = ".save.pars"
            name4 = ".fit.chisq"
            name5 = ".save.pcov"

            ### Get data and fit
            data = numpy.loadtxt(path__ + name1)
            save0 = data[:, 0].astype(int)
            save4 = data[:, 4]
            save5 = data[:, 5]
            save7 = data[:, 7]
            save9 = data[:, 9]
            xxxAll__[:, idx][save0] = save4
            muuAll__[:, idx][save0] = save5
            xi_fitAll__[:, idx][save0] = save7
            xi_errAll__[:, idx][save0] = save9

            ### Get only data
            data = numpy.loadtxt(pathData__ + name2)
            save0 = data[:, 0].astype(int)
            save1 = data[:, 1]
            xi_datAll__[:, idx][save0] = save1

            ### Get the parameters of the fit
            data = numpy.loadtxt(path__ + name3)
            param__[:, 0, idx] = data[:, 1]
            param__[:, 1, idx] = data[:, 2]

            ### Get the chi2 of the fit
            data = numpy.loadtxt(path__ + name4)
            chi2__[:, idx] = data
            if otherFit__:
                data = numpy.loadtxt(pathOtherFit__ + name4)
                chi2OtherFit__[:, idx] = data

                ### Get correlation parameters
            data = numpy.loadtxt(path__ + name5)
            for el in data:
                covar__[el[0], el[1], idx] = el[2]

    numpy.save("param", param__)

    mean = numpy.average(param__[9, 0, :], weights=numpy.power(param__[9, 1, :], -2.0))
    err = numpy.power(numpy.sum(numpy.power(param__[9, 1, :], -2.0)), -0.5)
    print "  alpha_parallel = ", mean, "  +/-  ", err
    mean = numpy.average(param__[10, 0, :], weights=numpy.power(param__[10, 1, :], -2.0))
    err = numpy.power(numpy.sum(numpy.power(param__[10, 1, :], -2.0)), -0.5)
    print "  alpha_perp = ", mean, "  +/-  ", err

    mean = numpy.mean(param__[9, 0, :])
    err = numpy.sqrt(numpy.var(param__[9, 0, :]) / (ni__ * nj__))
    print "  alpha_parallel = ", mean, "  +/-  ", err
    mean = numpy.mean(param__[10, 0, :])
    err = numpy.sqrt(numpy.var(param__[10, 0, :]) / (ni__ * nj__))
    print "  alpha_perp = ", mean, "  +/-  ", err

    ### Pass from covariance matrix to correlation matrix
    for i in numpy.arange(nbMocks__).astype(int):
        covar__[:, :, i] = myTools.getCorrelationMatrix(covar__[:, :, i])

        ### Get the mean of all correlation-functions
    xi_resAll__[:] = (xi_datAll__ - xi_fitAll__) / xi_errAll__
    xxx__[:] = numpy.mean(xxxAll__, axis=1)[:]
    muu__[:] = numpy.mean(muuAll__, axis=1)[:]
    xi_dat__[:] = numpy.mean(xi_datAll__, axis=1)[:]
    xi_fit__[:] = numpy.mean(xi_fitAll__, axis=1)[:]
    xi_err__[:] = numpy.mean(xi_errAll__, axis=1)[:] / numpy.sqrt(nbMocks__)
    xi_res__[:] = numpy.mean((xi_datAll__ - xi_fitAll__) / xi_errAll__, axis=1)[:]

    return
コード例 #3
0
ファイル: test_cov.py プロジェクト: londumas/CrossCorrelation
nbBinY2D__ = 2*nbBin1D__

nbBin2D__  = nbBinX2D__*nbBinY2D__

### Mu
nbBinM__ = 25;


path1__ = '/home/gpfs/manip/mnt0607/bao/hdumasde/Results/Txt/Correlation_test2/'


i = 0
j = 0	
cov = numpy.load('/home/gpfs/manip/mnt0607/bao/hdumasde/Mock_JMLG/v1547/Box_00'+str(i)+'/Simu_00'+str(j)+'/Results_RandomPosInCell/subSampling_LYA_QSO_cov_2D.npy')
### If correlation matrix from another matrix
cor = myTools.getCorrelationMatrix(numpy.load('/home/gpfs/manip/mnt0607/bao/hdumasde/Mock_JMLG/v1547/Results_RandomPosInCell/xi_delta_QSO_result_cov_2D_meanSubSampling.npy'))
cov = myTools.getCovarianceMatrix(cor,numpy.diag(cov))

#myTools.plot2D(cov)
#myTools.plot2D(cor)

print cor.flatten()[ cor.flatten()<0.99 ].size
plt.hist(cor.flatten()[ cor.flatten()<0.99 ], bins=10000, histtype='step', label='<corr each simu> ~ 8000 realisation')

cor = myTools.getCorrelationMatrix(numpy.load('/home/gpfs/manip/mnt0607/bao/hdumasde/Mock_JMLG/v1547/Box_000/Simu_000/Results_RandomPosInCell/subSampling_LYA_QSO_cov_2D.npy'))
plt.hist(cor.flatten()[ cor.flatten()<0.99 ], bins=10000, histtype='step', label='Simu 0 0 = 80 realisation')

cor = myTools.getCorrelationMatrix(numpy.load('/home/gpfs/manip/mnt0607/bao/hdumasde/Mock_JMLG/v1547/Results_RandomPosInCell/xi_delta_QSO_result_cov_2D.npy'))
plt.hist(cor.flatten()[ cor.flatten()<0.99 ], bins=10000, histtype='step', label='100 realisation')

cor = numpy.load('/home/gpfs/manip/mnt0607/bao/hdumasde/Mock_JMLG/v1547/Results_RandomPosInCell/xi_delta_QSO_result_cor_2D_allSubSampling.npy')
コード例 #4
0



print data.size
print data[0].size
print data

data[ data==0. ] = numpy.float('nan')
myTools.plot2D(data)

print '  is diag <0.   : ', numpy.diag(data)[ numpy.diag(data)<0. ].size
print '  is diag ==0.  : ', numpy.diag(data)[ numpy.diag(data)==0. ].size


cor = myTools.getCorrelationMatrix(data)
print cor
print cor[ cor==1. ].size
print cor[ cor>1. ].size
print cor[ cor==0. ].size

#cor[ cor==0. ] = numpy.float('nan')
#cor[ cor==1. ] = numpy.float('nan')
#myTools.plot2D(cor)

plt.hist( numpy.diag(data), bins=100  )
plt.show()

plt.hist( cor[ numpy.logical_and( cor!=0., cor!=1.) ], bins=100  )
plt.show()
コード例 #5
0
plt.title(r'$1D: \, \delta_{LYA} \, - \, \delta_{LYA} $', fontsize=40)
plt.xlabel(r'$s \, [h^{-1}.Mpc]$', fontsize=40)
plt.ylabel(r'$\xi (s)$', fontsize=40)
myTools.deal_with_plot(False,False,True)
plt.xlim([ numpy.min(xi1D[:,0])-10., numpy.max(xi1D[:,0])+10. ])
plt.xlim([ 4., numpy.max(xi1D[:,0])+10. ])
plt.show()
		





cov1D = numpy.cov(numpy.load('/home/gpfs/manip/mnt0607/bao/hdumasde/Mock_JMLG/v1547/Results/xi_1D_delta_delta_LYA_result_cov.npy'))
myTools.plot2D(cov1D)
myTools.plot2D(myTools.getCorrelationMatrix(cov1D))