def plotDataAndFit_S():
    """
	
		Plot \\xi( |s| )
	
	"""

    binSize = 4.0

    sss = numpy.arange(0.0, 50.0) * 4.0 + 2.0
    yyy_dat = numpy.zeros(shape=(50, 2))
    yyy_fit = numpy.zeros(shape=(50, 2))

    cut = numpy.logical_and((xxx__ != 0.0), (xxx__ < 200.0))
    xxx = xxx__[cut]
    xi_dat = xi_dat__[cut]
    xi_fit = xi_fit__[cut]
    xi_err = 1.0 / (xi_err__[cut] ** 2.0)

    for i in range(0, xxx.size):
        sIdx = int(xxx[i] / binSize)
        yyy_dat[sIdx][0] += xi_dat[i] * xi_err[i]
        yyy_dat[sIdx][1] += xi_err[i]
        yyy_fit[sIdx][0] += xi_fit[i] * xi_err[i]
        yyy_fit[sIdx][1] += xi_err[i]

    yyy_dat[:, 0] /= yyy_dat[:, 1]
    yyy_dat[:, 1] = numpy.sqrt(1.0 / yyy_dat[:, 1])
    yyy_fit[:, 0] /= yyy_fit[:, 1]
    yyy_fit[:, 1] = numpy.sqrt(1.0 / yyy_fit[:, 1])

    ### Plot the results

    for i in numpy.arange(0, 3):

        a = ""
        if i == 1:
            a += "|s|."
        elif i == 2:
            a += "|s|^{2}."

        coef = numpy.power(sss, 1.0 * i)

        plt.errorbar(
            sss,
            coef * yyy_dat[:, 0],
            yerr=coef * yyy_dat[:, 1],
            linestyle="",
            marker="o",
            color="blue",
            label=r"$<Simu>$",
        )
        plt.errorbar(sss, coef * yyy_fit[:, 0], color="red", label=r"$<Fit>$")
        plt.xlabel(r"$|s| \, [h^{-1} Mpc]$")
        plt.ylabel(r"$" + a + "\\xi(|s|)$")
        myTools.deal_with_plot(False, False, True)

        plt.show()

    return
def compare_each_simu():

	pathSimu    = '/home/gpfs/manip/mnt0607/bao/hdumasde/Mock_JMLG/v_second_generation/Box_000/Simu_000/Data/'
	rawPathSimu = '/home/gpfs/manip/mnt0607/bao/hdumasde/Mock_JMLG/v_second_generation/'
	chunckNb = 10
	simulNb  = 10

	## Distribution redshift QSO
	nb_qso = numpy.zeros(chunckNb*simulNb)
	for i in range(0,chunckNb):
		for j in range(0,simulNb):
			catSimu = pyfits.open(rawPathSimu+'Box_00'+str(i)+'/Simu_00'+str(j)+'/Data/QSO_withRSD.fits',memmap=True)[1].data
			nb_qso[i*10+j] = catSimu.size
	print 	numpy.mean(nb_qso)

	###
	plt.errorbar(numpy.arange(chunckNb*simulNb),nb_qso,fmt='o')
	plt.plot(numpy.arange(chunckNb*simulNb), numpy.ones(chunckNb*simulNb)*numpy.mean(nb_qso),color='red',label='Mean')
	plt.xlabel(r'$Mock \, index$', fontsize=40)
	plt.ylabel(r'$\# \, nb \, QSO$', fontsize=40)
	plt.xlim( [-1,chunckNb*simulNb] )
	myTools.deal_with_plot(False,False,True)
	plt.show()
	###
	plt.hist(nb_qso)
	plt.xlabel(r'$nb \, QSO$', fontsize=40)
	plt.ylabel(r'$\#$', fontsize=40)
	myTools.deal_with_plot(False,False,True)
	plt.show()




	return
def plot():

	if (forest__=='LYA'):
		lines = LYA_lines
		names = LYA_lines_names
	if (forest__=='CIV'):
		lines = CIV_lines
		names = CIV_lines_names
	if (forest__=='MGII'):
		lines = MGII_lines
		names = MGII_lines_names
	if (forest__=='LYB'):
		lines = LYB_lines
		names = LYB_lines_names
	if (forest__=='SIIV'):
		lines = SIIV_lines
		names = SIIV_lines_names
	if (forest__=='LYA_JMC'):
		lines = numpy.array([])
		names = numpy.array([])

	path = path__ +'xi_1DlRF_delta_delta_'+forest__+'.txt'
	print path
	data = numpy.loadtxt(path)
	xxx  = data[:,1]
	yyy  = data[:,1]
	yer  = data[:,]

	### remove empty pixels
	xxx = data[:,2][ (data[:,5]!=0.) ]/data[:,4][ (data[:,5]!=0.) ]
	yyy = data[:,0][ (data[:,5]!=0.) ]/data[:,4][ (data[:,5]!=0.) ]
	yer = numpy.sqrt( (data[:,1][ (data[:,5]!=0.) ]/data[:,4][ (data[:,5]!=0.) ] -yyy**2.)/data[:,5][ (data[:,5]!=0.) ]  )
	
	plt.errorbar(xxx, yyy, yerr=yer, marker='o')

	### Show lines in the correlation
	xMax    = numpy.amax(xxx)
	yMin    = numpy.amin(yyy)
	yMax    = numpy.amax(yyy)
	nbLines = lines.size
	for i in range(0,nbLines):
		for j in range(0,i):
			#if (names[i][:3]!=forest__ and names[j][:3]!=forest__): continue
			line = abs(lines[i]-lines[j])
			if (line==0. or line>xMax): continue
			xLi = [line,line]
			yLi = [yMin,yMax]
			name = names[i]+' - '+names[j]
			plt.plot(xLi,yLi,color='green')
			plt.text(line, yMax, name, rotation='vertical', fontsize=20)


	plt.title(r'$1D: \, \delta_{'+forest__+'} \, - \, \delta_{'+forest__+'} $', fontsize=40)
	plt.xlabel(r'$\Delta \lambda_{R.F.} \, [\AA]$', fontsize=40)
	plt.ylabel(r'$\xi(\Delta \lambda_{R.F.})$', fontsize=40)
	myTools.deal_with_plot(False,False,False)
	plt.xlim([ numpy.min(xxx)-10., numpy.max(xxx)+10. ])
	plt.show()
	
	return
def loadBootMap():
	'''
	'''

	path = '/home/gpfs/manip/mnt0607/bao/hdumasde/Results/Txt/map.txt'
	
	data = numpy.loadtxt(path)
	re = data[:,0].astype(int)
	ra = data[:,1]
	de = data[:,2]
	
	for i in range(0,numpy.amax(re)+1):
		cut = (re==i)
		plt.plot(ra[cut], de[cut], linestyle="", marker="o")

	#plt.xlim([0,360.])
	#plt.ylim([-90.,90.])
	plt.ticklabel_format(style='sci', axis='z', scilimits=(0,0))
	plt.grid()
	plt.xlabel(r'$R.A. (\degree)$')
	plt.ylabel(r'$Dec. (\degree)$')
	myTools.deal_with_plot(False,False,True)
	plt.show()
	
	return
def plotWe(rescale):

	a = ['0.8 < |\mu|', '0.5 < |\mu| \leq 0.8', '|\mu| \leq 0.5']

	for i in range(0,3):

		###
		cut = (xiWe_[:,i,2]!=0.)

		if (xiWe_[:,i,0][cut].size==0):
			continue

		xxx = xiWe_[:,i,0][cut]
		yyy = xiWe_[:,i,1][cut]
		yer = xiWe_[:,i,2][cut]
		coef = numpy.power(xxx,rescale)
		

		plt.errorbar(xxx, coef*yyy, yerr=coef*yer, fmt='o', label=r'$'+a[i]+'$')
	
		if (rescale==0):
			plt.ylabel(r'$\xi^{qf} (|s|)$', fontsize=40)
			plt.legend(fontsize=30, frameon=False, numpoints=1,ncol=2, loc=4)
		if (rescale==1):
			plt.ylabel(r'$|s|.\xi^{qf} (|s|) \, [h^{-1}.Mpc]$', fontsize=40)
			plt.legend(fontsize=30, frameon=False, numpoints=1,ncol=2, loc=4)
		if (rescale==2):
			plt.ylabel(r'$|s|^{2}.\xi^{qf} (|s|) \, [(h^{-1}.Mpc)^{2}]$', fontsize=40)
			plt.legend(fontsize=30, frameon=False, numpoints=1,ncol=2, loc=2)
	
	plt.title(r'$\delta_{'+forest1__+'} \, - \, '+qso1__+'$', fontsize=40)
	plt.xlabel(r'$|s| \, [h^{-1}.Mpc]$', fontsize=40)
	myTools.deal_with_plot(False,False,False)
	plt.xlim([ numpy.min(xxx)-10., numpy.max(xxx)+10. ])
	plt.show()
def plotXi(rescale):

	xxx = xi1D_[:,0]
	yyy = xi1D_[:,1]
	yer = xi1D_[:,2]

	cut = (yer!=0.)
	xxx = xxx[ cut ]
	yyy = yyy[ cut ]
	yer = yer[ cut ]



	if (rescale==0):
		plt.errorbar(xxx, yyy, yerr=yer, fmt='o')
		plt.ylabel(r'$\xi^{qf} (|s|)$', fontsize=40)
	if (rescale==1):
		plt.errorbar(xxx, xxx*yyy, yerr=xxx*yer, fmt='o')
		plt.ylabel(r'$|s|.\xi^{qf} (|s|) \, [h^{-1}.Mpc]$', fontsize=40)
	if (rescale==2):
		plt.errorbar(xxx, xxx*xxx*yyy, yerr=xxx*xxx*yer, fmt='o')
		plt.ylabel(r'$|s|^{2}.\xi^{qf} (|s|) \, [(h^{-1}.Mpc)^{2}]$', fontsize=40)
	
	plt.title(r'$\delta_{'+forest1__+'} \, - \, '+qso1__+'$', fontsize=40)
	plt.xlabel(r'$|s| \, [h^{-1}.Mpc]$', fontsize=40)
	myTools.deal_with_plot(False,False,False)
	plt.xlim([ numpy.min(xxx)-10., numpy.max(xxx)+10. ])
	plt.show()
def plotXi():

	xxx = xi1D_[:,0]
	yyy = xi1D_[:,1]
	yer = xi1D_[:,2]

	cut = (yer!=0.)
	xxx = xxx[ cut ]
	yyy = yyy[ cut ]
	yer = yer[ cut ]

	yMin    = numpy.min(yyy)
	yMax    = numpy.max(yyy)
	nbLines = lines.size
	for i in range(0,nbLines):
		for j in range(0,i):
			if ( lines[i]!=lambdaRFLine and lines[j]!=lambdaRFLine ): continue
			line = max( lines[i]/lines[j], lines[j]/lines[i])
			if (line<min1D__ or line>max1D__): continue
			xLi  = [line,line]
			yLi  = [yMin,yMax]
			name = names[i] + ' - ' + names[j]
			plt.plot(xLi,yLi,color='green',linewidth=2)
			plt.text(line, yMax, name, rotation='vertical', fontsize=20)

	plt.errorbar(xxx, yyy, yerr=yer, fmt='o')
	plt.ylabel(r'$\xi^{ff}$', fontsize=40)
	plt.xlabel(r'$\lambda_{Obs.,2}/\lambda_{Obs.,1}$', fontsize=40)
	plt.xlim([ min1D__-0.01, max1D__+0.01 ])
	myTools.deal_with_plot(False,False,False)

	plt.show()
示例#8
0
	def plot_1d(self,x_power=0):

		xxx = self._xi0[:,0]
		yyy = self._xi0[:,1]
		coef = numpy.power(xxx,x_power)
		plt.errorbar(xxx,coef*yyy,fmt='o')

		xxx = self._xi2[:,0]
		yyy = self._xi2[:,1]
		coef = numpy.power(xxx,x_power)
		plt.errorbar(xxx,coef*yyy,fmt='o')

		xxx = self._xi4[:,0]
		yyy = self._xi4[:,1]
		coef = numpy.power(xxx,x_power)

		plt.errorbar(xxx,coef*yyy,fmt='o')
		if (x_power==0):
			plt.ylabel(r'$ \xi (|s|)$', fontsize=40)
		if (x_power==1):
			plt.ylabel(r'$|s|.\xi (|s|) \, [h^{-1}.Mpc]$', fontsize=40)
		if (x_power==2):
			plt.ylabel(r'$|s|^{2}.\xi (|s|) \, [(h^{-1}.Mpc)^{2}]$', fontsize=40)
		plt.xlabel(r'$|s| \, [h^{-1}.Mpc]$', fontsize=40)
		plt.xlim([ numpy.amin(xxx)-10., numpy.amax(self._xi0[:,0])+10. ])
		myTools.deal_with_plot(False,False,False)
		plt.show()

		return
	def fit_CAMB(self,distortion=False,dic=None):

		### Get the data
		xxx = self._xi[:,0]
		yyy = self._xi[:,1]
		yer = self._xi[:,2]
		xMin = numpy.amin(xxx)
		xMax = numpy.amax(xxx)

		### Get CAMB
		camb = CAMB.CAMB(dic)._xi0
		xxx_Camb = copy.deepcopy(xxx)
		yyy_Camb = numpy.interp(xxx,camb[:,0],camb[:,1])

		if (distortion):
			path = self._path_to_txt_file_folder + self._prefix + '_distortionMatrix_'+ self._middlefix + '.txt'
			matrix = numpy.loadtxt(path)
			xxx_Camb = numpy.append(xxx_Camb,numpy.zeros(2100-xxx.size) )
			yyy_Camb = numpy.append(yyy_Camb,numpy.zeros(2100-yyy_Camb.size) )
			yyy_Camb = numpy.dot(matrix,yyy_Camb)
			yyy_Camb = yyy_Camb[(xxx_Camb!=0.)]
			xxx_Camb = xxx_Camb[(xxx_Camb!=0.)]
		b = 0.15
		#b = 0.05

		'''
		### Chi^{2}
		def chi2(b):
			model = yyy_Camb*b
			return numpy.sum( numpy.power( (yyy-model)/yer ,2.) )
	
		### Init and perform the fit
		m = Minuit(chi2, b=1.,error_b=0.1,print_level=-1, errordef=0.01) 	
		m.migrad()

		b = m.values['b']
		#b = 0.01
		print b
		'''

		for i in numpy.arange(1):
			coef = numpy.power(xxx,i)
			plt.errorbar(xxx, coef*yyy, yerr=coef*yer, fmt='o',color='blue')

			coef = numpy.power(xxx_Camb,i)
			plt.errorbar(xxx_Camb,coef*b*yyy_Camb,color='red')

			plt.title(r'$'+self._title+'$', fontsize=40)
			plt.xlabel(r'$'+self._xTitle+'$', fontsize=40)
			plt.ylabel(r'$'+self._yTitle+'$', fontsize=40)

			if (self._correlation=='f_f_r' or self._correlation=='f_f2_r' or self._correlation=='f_f_lRF' or self._correlation=='f_f_lRF'):
				plt.xlim([ numpy.min(xxx)-10., numpy.max(xxx)+10. ])
			if (self._correlation=='f_f_lRF_devide' or self._correlation=='f_f2_lRF_devide'):
				plt.xlim([ 0.99*xMin, 1.01*xMax ])

			myTools.deal_with_plot(False,False,False)
			plt.show()

		return
def plotXi(rescale):

	cut = (xi1D_[:,2] != 0.)
	xxx = xi1D_[:,0][cut]
	yyy = xi1D_[:,1][cut]
	yer = xi1D_[:,2][cut]

	#yyy -= yyy[-1]

	if (rescale==0):
		plt.errorbar(xxx, yyy, yerr=yer, fmt='o')
		plt.ylabel(r'$\xi^{ff} (|s|)$', fontsize=40)
	if (rescale==1):
		plt.errorbar(xxx, xxx*yyy, yerr=xxx*yer, fmt='o')
		plt.ylabel(r'$|s|.\xi^{ff} (|s|) \, [h^{-1}.Mpc]$', fontsize=40)
	if (rescale==2):
		plt.errorbar(xxx, xxx*xxx*yyy, yerr=xxx*xxx*yer, fmt='o')
		plt.ylabel(r'$|s|^{2}.\xi^{ff} (|s|) \, [(h^{-1}.Mpc)^{2}]$', fontsize=40)
	
	plt.title(r'$\delta_{'+forest__+'} \, - \, \delta_{'+forest__+'}$', fontsize=40)
	plt.xlabel(r'$|s| \, [h^{-1}.Mpc]$', fontsize=40)
	myTools.deal_with_plot(False,False,False)
	plt.xlim([ numpy.min(xxx)-10., numpy.max(xxx)+10. ])
	plt.ticklabel_format(style='sci', axis='y', scilimits=(0,0))
	plt.show()
	
	return
示例#11
0
def difTemplate():

	''' 
	Look at the differences between the templates

	'''

	path = "/home/gpfs/manip/mnt0607/bao/hdumasde/Results/Txt/chain_annalys_delta/"

	data1 = numpy.loadtxt(path + 'template_0_0.txt')
	templateData1 = interpolate.interp1d(data1[:,0],data1[:,1],bounds_error=False,fill_value=0)
	plt.errorbar(data1[:,0], data1[:,1]/templateData1(1150.), fmt='o', label=r'$Simu$',color='red')

	data = numpy.loadtxt(path + 'template.txt')
	templateData = interpolate.interp1d(data[:,0],data[:,1],bounds_error=False,fill_value=0)
	plt.errorbar(data[:,0], data[:,1]/templateData(1150.), fmt='o', label=r'$Data$',color='blue')

	data3 = numpy.loadtxt(path + 'template_0_0_MocksColab.txt')
	templateData3 = interpolate.interp1d(data3[:,0],data3[:,1],bounds_error=False,fill_value=0)
	plt.errorbar(data3[:,0], data3[:,1]/templateData3(1150.), fmt='o', label=r'$Mock \, colab$',color='green')


	plt.title(r'$Template$', fontsize=40)
	plt.xlabel(r'$\lambda_{R.F.} \, [\AA]$', fontsize=40)
	plt.ylabel(r'$f(\lambda_{R.F.}) / f(1150.)$', fontsize=40)
	myTools.deal_with_plot(False,False,True)
	plt.show()
	

	plt.errorbar(data[:,0], (data1[:,1]/templateData1(1150.)-data[:,1]/templateData(1150.))/(data1[:,1]/templateData1(1150.)) , fmt='o')
	plt.xlabel(r'$\lambda_{R.F.} \, [\AA]$', fontsize=40)
	plt.ylabel(r'$( (f(\lambda_{R.F.}) / f(1150.))_{Data} - (f(\lambda_{R.F.}) / f(1150.))_{Simu} ) / (f(\lambda_{R.F.}) / f(1150.))_{Data})$', fontsize=40)
	myTools.deal_with_plot(False,False,True)
	plt.show()
示例#12
0
def getQsoCatalogueAllObjects():
	'''

	'''

	path = '/home/gpfs/manip/mnt0607/bao/hdumasde/Data/Catalogue/'
	listPAth = [path+'QSO_DR7_DR12_EBOSS_2016_01_08.fits',
			path+'DLA_all.fits',
			path+'all_Britt.fits',
			path+'VIPERS.fits',
			path+'QSO_3DHST.fits',
			path+'LOWZ_all.fits',
			path+'CMASS_all.fits']
	name = ['QSO','DLA','Britt','VIPERS','3DHST','LOWZ','CMASS']

	## Distribution redshift
	for i in numpy.arange(len(listPAth)):
		cat = pyfits.open(listPAth[i], memmap=True )[1].data
		cat = cat[ (cat['Z']>0.1) ]
		cat = cat[ (cat['Z']<7.) ]
		if (cat.size==0): continue
		plt.hist(cat['Z'], bins=100,histtype='step',label=name[i])

	plt.xlabel("Z")
	plt.ylabel("#")
	myTools.deal_with_plot(False,False,True)
	plt.show()

	### Merge everyThing
	cat = pyfits.open(listPAth[0], memmap=True )[1].data
	ra = cat['RA']
	de = cat['DEC']
	zz = cat['Z']
	for i in numpy.arange(1,len(listPAth)):
		cat = pyfits.open(listPAth[i], memmap=True )[1].data
		ra = numpy.append(ra, cat['RA'])
		de = numpy.append(de, cat['DEC'])
		zz = numpy.append(zz, cat['Z'])

	## Map
	plt.ticklabel_format(style='sci', axis='z', scilimits=(0,0))	
	plt.grid()
	plt.plot(ra, de, linestyle="", marker="o")
	plt.xlabel("Right Ascension (degree)")
	plt.ylabel("Declination (degree)")
	plt.show()
	## Distribution redshift
	plt.ticklabel_format(style='sci', axis='z', scilimits=(0,0))
	plt.grid()
	plt.hist(zz, bins=200)
	plt.xlabel("Z")
	plt.ylabel("#")
	plt.show()

	### Save	
	col_ra              = pyfits.Column(name='RA',  format='D', array=ra, unit='deg')
	col_de              = pyfits.Column(name='DEC', format='D', array=de, unit='deg')
	col_zz              = pyfits.Column(name='Z',   format='D', array=zz)
	tbhdu = pyfits.BinTableHDU.from_columns([col_ra, col_de, col_zz])
	tbhdu.writeto('/home/gpfs/manip/mnt0607/bao/hdumasde/Data/Catalogue/ALL_EVERY_OBJECTS_2016_01_08.fits', clobber=True)
def plotXi():

	xxx = xi1D_[:,0]
	yyy = xi1D_[:,1]
	yer = xi1D_[:,2]

	cut = (yer!=0.)
	xxx = xxx[ cut ]
	yyy = yyy[ cut ]
	yer = yer[ cut ]

	yMin    = numpy.min(yyy)
	yMax    = numpy.max(yyy)
	nbLines = lines.size
	for i in range(0,nbLines):
		line = lines[i]/lambdaRFLine
		if (line<min1D__ or line>max1D__): continue
		#print ' ||  QSO - ', names[i], ' || ', line, ' || ', lambdaRFLine, ' || ', lines[i], ' || '
		xLi  = [line,line]
		yLi  = [yMin,yMax]
		name = 'QSO - ' + names[i]
		plt.plot(xLi,yLi,color='green',linewidth=2)
		plt.text(line, 0.7*yMin, name, rotation='vertical', fontsize=20)

	plt.errorbar(xxx, yyy, yerr=yer, fmt='o')
	plt.ylabel(r'$\xi^{qf} \, (\theta<'+str(maxTheta_)+' \, rad)$', fontsize=40)
	plt.xlabel(r'$\lambda_{Obs., pix}/\lambda_{Obs., QSO}$', fontsize=40)
	
	myTools.deal_with_plot(False,False,False)

	plt.show()
	def plot_histo_residuals(self, other=[]):

		### Constants
		nbBins=100

		list_of_fit = numpy.append( [self],other )

		### histo
		fig = plt.figure()
		ax = fig.add_subplot(111)

		for el in list_of_fit:
			yyy = numpy.array([])
			for el in self._listFit:
				xi2D = el.get_residuals()
				tmp_yyy  = (xi2D[:,:,1][ (xi2D[:,:,2]>0.) ]).flatten()
				yyy = numpy.append(yyy,tmp_yyy)

			ax.hist(yyy, bins=nbBins, histtype='step', linewidth=2,alpha=0.6)

		plt.xlabel(r'$\frac{data-fit}{\sigma_{data}}$')
		plt.ylabel(r'$\#$')
		myTools.deal_with_plot(False,False,False)
		
		mng = plt.get_current_fig_manager()
		textstr = '$nb=%u$\n$\mu=%.5e$\n$\sigma=%.5e$'%(yyy.size, numpy.mean(yyy), numpy.std(yyy))
		props = dict(boxstyle='round', facecolor='wheat', alpha=0.5)
		ax.text(0.05, 0.95, textstr, transform=ax.transAxes, fontsize=30, verticalalignment='top', bbox=props)
		
		plt.show()

		return
def plotDataAndFit_1D():
    """
	"""

    if type__ == "1D":
        xxx = numpy.arange(0.0, nbBin__) * 4.0 + 2.0
        xxx[(xxx__ != 0.0)] = xxx__[(xxx__ != 0.0)]
        b = "|s|"
    elif type__ == "2D":
        xxx = numpy.arange(0.0, nbBin__)
        b = "s"

    for i in numpy.arange(0, 3):

        if i == 0:
            a = ""
            c = ""
        elif i == 1:
            a = "|s|."
            c = " \, [h^{-1}.Mpc]"
        else:
            a = "|s|^{2}."
            c = " \, [(h^{-1}.Mpc)^{2}]"

        coef = numpy.power(xxx__, 1.0 * i)

        plt.errorbar(xxx, coef * xi_dat__, yerr=coef * xi_err__, linestyle="", marker="o", color="blue")
        plt.errorbar(xxx, coef * xi_fit__, color="red")
        plt.xlabel(r"$" + b + " \, [h^{-1}.Mpc] $")
        plt.ylabel(r"$" + a + "\\xi(" + b + ") " + c + "$")
        myTools.deal_with_plot(False, False, True)
        plt.show()

    return
示例#16
0
def seePowerSpectrum():
	'''

	'''

	### Constants
	pathToPk = '/home/gpfs/manip/mnt0607/bao/hdumasde/Code/Python/CreateRandomField/DR9LyaMocks_matterpower.dat'

	### Get the power spectra
	pk = scipy.loadtxt(pathToPk)
	pkInterpolate = interpolate.interp1d(pk[:,0],pk[:,1],bounds_error=False,fill_value=0)

	for i in numpy.arange(3):
		coef = numpy.power(pk[:,0],i)
		yLabel = 'P(k)'
		if (i==1):
			yLabel = 'k.' + yLabel + '\, [h/Mpc]'
		elif (i==2):
			yLabel = 'k^{2}.' + yLabel + '\, [(h/Mpc)^{2}]'

		plt.plot(pk[:,0],coef*pk[:,1],marker='o')
		plt.xlabel(r'$k \, [h/Mpc]$', fontsize=40)
		plt.ylabel(r'$'+yLabel+'$', fontsize=40)
		myTools.deal_with_plot(False,False,False)
		plt.show()
def plot(xi1D):


	if (forest__=='LYA'):
		lines = LYA_lines
		names = LYA_lines_names
	if (forest__=='CIV'):
		lines = CIV_lines
		names = CIV_lines_names
	if (forest__=='MGII'):
		lines = MGII_lines
		names = MGII_lines_names
	if (forest__=='LYB'):
		lines = LYB_lines
		names = LYB_lines_names
	if (forest__=='SIIV'):
		lines = SIIV_lines
		names = SIIV_lines_names

	xxx = xi1D[:,0]
	yyy = xi1D[:,1]
	yer = xi1D[:,2]


	### Show lines in the correlation
	xMax    = numpy.amax(xxx)
	yMin    = numpy.amin(yyy)
	yMax    = numpy.amax(yyy)
	nbLines = lines.size
	for i in range(0,nbLines):
		for j in range(0,i):
			#if (names[i][:3]!=forest__ and names[j][:3]!=forest__): continue
			line = lines[j]/lines[i]

			
			#isPresent = False
			#for k in strongLines_CIV:
			#	if (abs(line-k)<=0.00005): isPresent = True
			#if (not isPresent): continue
			
			line = numpy.abs( find_dist_correlation_lines(meanZ__,lines[j],lines[i]) )
			if (line>xMax): continue
			#print line

			xLi = [line,line]
			yLi = [yMin,yMax]
			name = names[i]+' - '+names[j]
			plt.plot(xLi,yLi,color='green')
			plt.text(line, yMax, name, rotation='vertical', fontsize=20)



	plt.errorbar(xxx,yyy, yerr=yer, fmt='o')
	plt.title(r'$1D: \, \delta_{'+forest__+'} \, - \, \delta_{'+forest__+'} $', fontsize=40)
	plt.xlabel(r'$s \, [h^{-1}.Mpc]$', fontsize=40)
	plt.ylabel(r'$\xi (s)$', fontsize=40)
	myTools.deal_with_plot(False,False,False)
	plt.xlim([ numpy.min(xxx)-10., numpy.max(xxx)+10. ])
	plt.show()
示例#18
0
def plotCovarDifferentMethod():
	'''

	'''

	dim = '1D'

	path = '/home/gpfs/manip/mnt0607/bao/hdumasde/Results/Txt/FitsFile_DR12_Guy/'
	listPath = [    path+'subSampling_LYA_QSO_cov_'+dim+'.npy',
			path+'shuffleQSO_LYA_QSO_cov_'+dim+'.npy',
			path+'randomQSO_LYA_QSO_cov_'+dim+'.npy',
			path+'shuffleForest_LYA_QSO_cov_'+dim+'.npy',
			'/home/gpfs/manip/mnt0607/bao/hdumasde/Mock_JMLG/v1547/Results_RandomPosInCell/xi_delta_QSO_result_cov_'+dim+'.npy',
			'/home/gpfs/manip/mnt0607/bao/hdumasde/Mock_JMLG/v1547/Results_RandomPosInCell/xi_delta_QSO_result_cov_'+dim+'_meanSubSampling.npy',
			]
	listPath2 = [   path+'subSampling_LYA_QSO_'+dim+'.npy',
			path+'shuffleQSO_LYA_QSO_'+dim+'.npy',
			path+'randomQSO_LYA_QSO_'+dim+'.npy',
			path+'shuffleForest_LYA_QSO_'+dim+'.npy',
			'/home/gpfs/manip/mnt0607/bao/hdumasde/Mock_JMLG/v1547/Results_RandomPosInCell/xi_delta_QSO_result_'+dim+'.npy',
			]
	listName = ['Data \, subsampling',
			'Data \, shuffle \, QSO',
			'Data \, random \, QSO',
			'Data \, shuffle \, forest',
			'Mocks',
			'< Mock \, subsampling >',
			]

	real = [ numpy.load(i) for i in listPath2 ]
	cov  = [ numpy.load(i) for i in listPath ]

	### Plot the realisation
	for i in numpy.arange(len(real)):
		print listName[i]
		for j in numpy.arange(real[i][0,:].size):
			plt.errorbar(numpy.arange(real[i][:,j].size), real[i][:,j],fmt='o',color='blue',alpha=0.1)
		plt.errorbar(numpy.arange(real[i][:,j].size), numpy.mean(real[i],axis=1),fmt='o',color='red',label=r'$Mean$')
		plt.xlabel(r'$bin \, index$', fontsize=40)
		plt.ylabel(r'$\xi(|s|)$', fontsize=40)
		plt.title(r'$'+listName[i]+'$', fontsize=40)
		myTools.deal_with_plot(False,False,True)
		plt.xlim([ -1., cov[i][0,:].size+1 ])
		plt.show()


	### Plot diagonal
	for i in numpy.arange(len(cov)):
		plt.errorbar(numpy.arange(cov[i][0,:].size), numpy.diag(cov[i]),fmt='o',label=r'$'+listName[i]+'$')
	plt.xlabel(r'$bin \, index$', fontsize=40)
	plt.ylabel(r'$Var(|s|)$', fontsize=40)
	myTools.deal_with_plot(False,False,True)
	plt.xlim([ -1., cov[i][0,:].size+1 ])
	plt.show()

	myTools.plotCovar(cov,listName)

	return
示例#19
0
    def plot_given_2d(self, x_power=0, xi2D=None, label=None):

        if xi2D is None:
            print "  annalyseBAOFIT::plot_2d::  xi2D==None"
            xi2D = self._xi2D
        if label is None:
            label = self._label

        origin = "lower"
        extent = [self._minX2D, self._maxX2D, self._minY2D, self._maxY2D]
        if self._correlation == "q_f" or self._correlation == "f_f2":
            origin = "upper"
            extent = [self._minX2D, self._maxX2D, self._maxY2D, self._minY2D]

        xxx = numpy.transpose(xi2D[:, :, 0])
        yyy = numpy.transpose(xi2D[:, :, 1])
        yer = numpy.transpose(xi2D[:, :, 2])

        cut = yer == 0
        if xxx[cut].size == xxx.size:
            return
        yyy[cut] = float("nan")
        coef = numpy.power(xxx, x_power)

        fig = plt.figure()
        ax = fig.add_subplot(111)
        ax.set_xticks([i for i in numpy.arange(self._minX2D - 50.0, self._maxX2D + 50.0, 50.0)])
        ax.set_yticks([i for i in numpy.arange(self._minY2D - 50.0, self._maxY2D + 50.0, 50.0)])

        plt.imshow(coef * yyy, origin=origin, extent=extent, interpolation="None")
        cbar = plt.colorbar()

        if x_power == 0:
            cbar.set_label(r"$" + label + "(r_{\parallel},r_{\perp})$", size=40)
        if x_power == 1:
            cbar.set_label(r"$r \cdot " + label + "(r_{\parallel},r_{\perp}) \, [\\rm{h}^{-1} \, \\rm{Mpc}]$", size=40)
        if x_power == 2:
            cbar.set_label(
                r"$r^{2} \cdot " + label + "(r_{\parallel},r_{\perp}) \, [(\\rm{h}^{-1} \, \\rm{Mpc})^{2}]$", size=40
            )

            # plt.plot( [0.,200.],[0.,4*200.],color='white',linewidth=2 )
            # plt.plot( [0.,200.],[0.,-4*200.],color='white',linewidth=2 )
            # plt.plot( [0.,200.],[0.,200.],color='white',linewidth=2 )
            # plt.plot( [0.,200.],[0.,-200.],color='white',linewidth=2 )

            # plt.title(r'$'+self._title+'$', fontsize=40)
        plt.xlabel(r"$r_{\perp} \, [\rm{h}^{-1} \, \rm{Mpc}]$", fontsize=40)
        plt.ylabel(r"$r_{\parallel} \, [\rm{h}^{-1} \, \rm{Mpc}]$", fontsize=40)
        plt.grid(True)
        cbar.formatter.set_powerlimits((0, 0))
        cbar.update_ticks()
        myTools.deal_with_plot(False, False, False)

        plt.show()

        return
示例#20
0
def haveAlookForest():	

	cat = pyfits.open('/home/gpfs/manip/mnt0607/bao/hdumasde/Mock_JMc/new_mock_1280_0_0.fits', memmap=True)[1].data
	print cat.size
	print numpy.amin(cat['RA']), numpy.amax(cat['RA'])
	print numpy.amin(cat['DEC']), numpy.amax(cat['DEC'])
	print numpy.amin(cat['Z_VI']), numpy.amax(cat['Z_VI'])

	ar_cut          = (cat['NORM_FLUX_IVAR']>0.)
	ar_lambdaObs    = cat['LAMBDA_OBS'][ ar_cut ]
	ar_lambdaRF     = cat['LAMBDA_RF'][ ar_cut ]
	ar_flux         = cat['NORM_FLUX'][ ar_cut ]
	ar_zi           = cat['LAMBDA_OBS'][ ar_cut ]/(lambdaRFLine__) -1.
	ar_weight       = cat['DELTA_WEIGHT'][ ar_cut ] #numpy.ones(shape=(cat.size,cat['NORM_FLUX'][0].size))[ ar_cut ]

	print numpy.amin(ar_zi), numpy.amax(ar_zi)

	### deltaLoglambda (mock_JMc)    = 0.00023025850929947467
	### deltaLoglambda (data)        = 0.00023002222870971423
	### deltaLoglambda (mock Julian) = 0.00023002222870971423,

	### delta vs. lambda_RF
	xxx, yyy, eyyy, nyyy = myTools.Get_TProfile(ar_lambdaRF,ar_flux, lambdaRFTemplateBinEdges__, ar_weight)
	plt.errorbar(xxx, yyy, yerr=eyyy, marker="o")
	plt.xlabel(r'$\lambda_{R.F.} \, [\AA]$', fontsize=40)
	plt.ylabel(r'$flux$', fontsize=40)
	myTools.deal_with_plot(False,False,False)
	plt.show()
	### delta vs. lambda_RF
	xxx, yyy, eyyy, nyyy = myTools.Get_TProfile(ar_lambdaObs,ar_flux, lambdaObsBinEdges__, ar_weight)
	plt.errorbar(xxx, yyy, yerr=eyyy, marker="o")
	plt.xlabel(r'$\lambda_{R.F.} \, [\AA]$', fontsize=40)
	plt.ylabel(r'$flux$', fontsize=40)
	myTools.deal_with_plot(False,False,False)
	plt.show()
	### Distribution redshift
	plt.hist(ar_zi, bins=50)
	plt.xlabel(r'$z_{pixel}$')
	plt.ylabel(r'$\#$')
	myTools.deal_with_plot(False,False,False)
	plt.show()
	### Map
	plt.plot(cat['RA'],cat['DEC'], linestyle="", marker="o")
	plt.xlabel(r'$X [Mpc]$')
	plt.ylabel(r'$Y [Mpc]$')
	myTools.deal_with_plot(False,False,False)
	plt.show()
	### Distribution redshift
	plt.hist(cat['Z_VI'], bins=50)
	plt.xlabel(r'$z_{qso}$')
	plt.ylabel(r'$\#$')
	myTools.deal_with_plot(False,False,False)
	plt.show()

	return
	def plot_data_and_fit_1d(self,x_power,path_to_mapping_1D):

		### Load the mapping from 2D to 1D
		mapping_2D_to_1D = numpy.load( path_to_mapping_1D )

		### Fit
		xi1D_data = numpy.zeros(shape=(self._nbBin1D,3))
		xi1D_fit  = numpy.zeros(shape=(self._nbBin1D,3))
		for i in numpy.arange(self._nbBinX2D):
			for j in numpy.arange(self._nbBinY2D):

				if (self._xi2D_fit[i,j,8]<=0.): continue
				ivar = 1./( self._xi2D_fit[i,j,8]*self._xi2D_fit[i,j,8]  )
				for k in numpy.arange(self._nbBin1D):
					coef = mapping_2D_to_1D[i,j,k]
					if (coef==0.): continue
					xi1D_data[k,0] += coef*ivar*self._xi2D[i,j,0]
					xi1D_data[k,1] += coef*ivar*self._xi2D[i,j,1]
					xi1D_data[k,2] += coef*ivar

					xi1D_fit[k,0] += coef*ivar*self._xi2D_fit[i,j,3]
					xi1D_fit[k,1] += coef*ivar*self._xi2D_fit[i,j,6]
					xi1D_fit[k,2] += coef*ivar

		### Data
		cut = (xi1D_data[:,2]>0.)
		xi1D_data[:,0][cut] /= xi1D_data[:,2][cut]
		xxx = xi1D_data[:,0][cut]
		xi1D_data[:,1][cut] /= xi1D_data[:,2][cut]
		xi1D_data[:,2][cut]  = 1./numpy.sqrt(xi1D_data[:,2][cut])
		coef = numpy.power(xi1D_data[:,0][cut],x_power)
		plt.errorbar(xi1D_data[:,0][cut], coef*xi1D_data[:,1][cut], yerr=coef*xi1D_data[:,2][cut], fmt='o', label=r'$'+self._name+'$', markersize=10,linewidth=2)
		### Fit
		cut = (xi1D_fit[:,2]>0.)
		xi1D_fit[:,0][cut] /= xi1D_fit[:,2][cut]
		xi1D_fit[:,1][cut] /= xi1D_fit[:,2][cut]
		xi1D_fit[:,2][cut]  = 1./numpy.sqrt(xi1D_fit[:,2][cut])
		coef = numpy.power(xi1D_fit[:,0][cut],x_power)
		plt.errorbar(xi1D_fit[:,0][cut], coef*xi1D_fit[:,1][cut], label=r'$Fit$', color='red',linewidth=2)

		if (x_power==0):
			plt.ylabel(r'$'+self._label+' (|s|)$', fontsize=40)
		if (x_power==1):
			plt.ylabel(r'$|s|.'+self._label+' (|s|) \, [h^{-1}.Mpc]$', fontsize=40)
		if (x_power==2):
			plt.ylabel(r'$|s|^{2}.'+self._label+' (|s|) \, [(h^{-1}.Mpc)^{2}]$', fontsize=40)
		
		plt.title(r'$'+self._title+'$', fontsize=40)
		plt.xlabel(r'$|s| \, [h^{-1}.Mpc]$', fontsize=40)
		plt.xlim([ numpy.amin(xxx)-10., numpy.amax(xxx)+10. ])
		myTools.deal_with_plot(False,False,True)
		plt.show()
		
		return
	def plot_1d(self, with_lines=False, other=[], verbose=False):
	
		list_corr_to_plot = numpy.append( [self],other )
		
                xMin = numpy.amin(self._xi1D[:,0])
                xMax = numpy.amax(self._xi1D[:,0])
                yMin = numpy.amin(self._xi1D[:,1])
                yMax = numpy.amax(self._xi1D[:,1])

                for el in list_corr_to_plot:

			cut = (el._xi1D[:,2]>0.)
			xxx = el._xi1D[:,0][cut]
			yyy = el._xi1D[:,1][cut]
			yer = el._xi1D[:,2][cut]
			plt.errorbar(self._line_RF*xxx, yyy, yerr=yer, fmt='o', label=r'$'+el._name+'$')
			plt.errorbar(self._line_RF*xxx, yyy, color='blue')

			xMin = min(xMin, numpy.amin(xxx) )
                        xMax = max(xMax, numpy.amax(xxx) )
                        yMin = min(yMin, numpy.amin(yyy) )
                        yMax = max(yMax, numpy.amax(yyy) )

		if (with_lines):

			if (verbose): print ' ||  name_1 - name_2 || line || lambda_rf_1 || lamnda_rf_2 || '

			yLi = [yMin,yMax]
			nbLines1 = self._lines1.size

			for i in range(0,nbLines1):
				nbLines2 = 1

				for j in range(0,nbLines2):
					line = self._lines1[i] #/self._line_RF

					if (line<self._line_RF*xMin or line>self._line_RF*xMax): continue
					xLi = [line,line]
					plt.plot(xLi,yLi,color='green')

					if (verbose): print ' ||  ', self._name_line1[i] ,' - QSO || ', line, ' || ', self._lines1[i], ' || ', self._line_RF, ' || '
					name = self._name_line1[i]+' - QSO '
		
					plt.text(line, yMax, name, rotation='vertical', fontsize=20)



		plt.title(r'$'+self._title+'$', fontsize=40)
		plt.xlabel(r'$'+self._xTitle+'$', fontsize=40)
		plt.ylabel(r'$'+self._yTitle+'$', fontsize=40)
		myTools.deal_with_plot(False,False,True)
		plt.show()

		return
示例#23
0
def plot():

    data = numpy.loadtxt("/home/gpfs/manip/mnt0607/bao/hdumasde/Code/Python/All_Spectrum/spectrum.txt")

    xxx = data[:, 0]
    yyy = data[:, 1]
    yer = data[:, 2]

    plt.errorbar(xxx, yyy, yerr=yer, marker="o")
    myTools.deal_with_plot(False, False, False)
    plt.show()
def getChiScan1D():
	'''
		get the \chi^2 scan 
		1st line: 
		2nd line: settings
		3rd line: best fit
		4-end lines: scan
	'''

	### idex of the alpha
	idxAlpha = 11
	
	### Constants
	name = '.scan.dat'
	
	### Create a file in /tmp with the scan minus the two first lines
	idx = 0
	f     = open(path__+name)
	tmp_f = open('/tmp/scan.txt','w')
	for line in f:
		if (idx>=2): tmp_f.write(line)
		idx += 1
	tmp_f.close()
	f.close()
	
	### Data
	data = numpy.loadtxt('/tmp/scan.txt')
	
	### Best Fit
	alpha_bestFit = data[0][idxAlpha]
	chi2_bestFit  = data[0][-1]
	print data[0][9], data[0][10], param__[idxAlpha,0], param__[idxAlpha,1]
	
	### Scan
	alpha = data[1:,idxAlpha]
	chi2  = data[1:,-1]-chi2_bestFit

	### Chi^2 scan
	plt.errorbar(alpha,chi2,fmt='o')
	### Best fit
	plt.errorbar([alpha_bestFit],[0.],xerr=param__[idxAlpha,1],fmt='o',color='red',label='Best fit')
	### 1,2,3,4 sigma lines
	plt.plot(alpha,numpy.ones(alpha.size)*1.,color='green')
	plt.plot(alpha,numpy.ones(alpha.size)*4.,color='green')
	plt.plot(alpha,numpy.ones(alpha.size)*9.,color='green')
	plt.plot(alpha,numpy.ones(alpha.size)*16.,color='green')
	plt.xlabel(r'$'+paramName__[idxAlpha]+'$', fontsize=40)
	plt.ylabel(r'$\Delta \chi^{2} = \chi^{2}-\chi^{2}_{best \, fit}$', fontsize=40)
	plt.ylim([ -2., numpy.amax(chi2)+2. ])
	myTools.deal_with_plot(False,False,True)
	plt.show()
	
	return
def plotAllParameters():
    """

	"""

    for i in numpy.arange(paramName__.size):

        ### If the parameter isn't fitted
        if param__[i, 1, 0] == 0.0:
            continue

        ### all:
        plt.errorbar(numpy.arange(nbMocks__), param__[i, 0, :], yerr=param__[i, 1, :], linestyle="", marker="o")
        plt.xlabel(r"$index \, mock$")
        plt.ylabel(r"$" + paramName__[i] + "$")
        plt.xlim(-1, nbMocks__ + 1)
        myTools.deal_with_plot(False, False, True)
        plt.show()

        ### hist:
        yyy = param__[i, 0, :]
        fig = plt.figure()
        ax = fig.add_subplot(111)
        ax.hist(yyy, bins=20)
        myTools.deal_with_plot(False, False, False)
        plt.xlabel(r"$" + paramName__[i] + "$")
        plt.ylabel(r"$\#$")
        textstr = "$Nb=%d$ \n $\mu=%.5e  +/-  %.2e$ \n $\sigma=%.5e$" % (
            yyy.size,
            numpy.mean(yyy),
            numpy.std(yyy) / numpy.sqrt(yyy.size),
            numpy.std(yyy),
        )
        props = dict(boxstyle="round", facecolor="wheat", alpha=0.5)
        ax.text(0.05, 0.95, textstr, transform=ax.transAxes, fontsize=30, verticalalignment="top", bbox=props)
        plt.show()

        """
		### hist pull:
		yyy = (param__[i,0,:]-1.)/param__[i,1,:]
		fig = plt.figure()
		ax = fig.add_subplot(111)
		ax.hist(yyy, bins=20)
		myTools.deal_with_plot(False,False,False)
		plt.xlabel(r'$('+paramName__[i]+'-1)/err$')
		plt.ylabel(r'$\#$')
		textstr = '$Nb=%d$ \n $\mu=%.5e  +/-  %.2e$ \n $\sigma=%.5e$'%(yyy.size,numpy.mean(yyy),numpy.std(yyy)/numpy.sqrt(yyy.size),numpy.std(yyy))
		props = dict(boxstyle='round', facecolor='wheat', alpha=0.5)
		ax.text(0.05, 0.95, textstr, transform=ax.transAxes, fontsize=30, verticalalignment='top', bbox=props)
		plt.show()
		"""
    return
def plotWe(rescale):

	a = ["theta < 0.0001", "0.0001 < theta < 0.0002"]

	yMin    = 0.
	yMax    = 0.005
	nbLines = lines.size
	for i in range(0,nbLines):
		for j in range(0,i):
			#if ( lines[i]!=1550.77845 and lines[j]!=1550.77845 and lines[i]!=1548.2049 and lines[j]!=1548.2049 ): continue
			#if ( lines[i]!=1402.77291 and lines[j]!=1402.77291 and lines[i]!=1393.76018 and lines[j]!=1393.76018 ): continue
			if ( lines[i]!=1215.67 and lines[j]!=1215.67): continue
			line = max( lines[i]/lines[j], lines[j]/lines[i])
			if (line<min1D__ or line>max1D__): continue
			xLi  = [line,line]
			yLi  = [yMin,yMax]
			name = names[i] + ' - ' + names[j]
			plt.plot(xLi,yLi,color='green',linewidth=2)
			plt.text(line, yMax, name, rotation='vertical', fontsize=20)

	for i in range(0,2):

		#if (i>=1):
		#	xiWe_[:,i,1] += 0.05
		#if (i>=2):
		#	xiWe_[:,i,1] += 0.05	

		###
		cut = (xiWe_[:,i,2]!=0.)

		if (xiWe_[:,i,0][cut].size==0):
			continue

		xxx = xiWe_[:,i,0][cut]
		yyy = xiWe_[:,i,1][cut]
		yer = xiWe_[:,i,2][cut]
		coef = numpy.power(xxx,rescale)
		

		plt.errorbar(xxx, coef*yyy, yerr=coef*yer, marker='o', label=r'$'+a[i]+'$')
		plt.legend(fontsize=30, frameon=False, numpoints=1,ncol=2, loc=1)
	
	plt.ylabel(r'$\xi^{ff}$', fontsize=40)
	plt.xlabel(r'$\lambda_{Obs.,2}/\lambda_{Obs.,1}$', fontsize=40)
	plt.xlim([ min1D__-0.01, max1D__+0.01 ])
	myTools.deal_with_plot(False,False,False)

	


	plt.show()
def plotCorrelationFunction():

    ####################################################################
    ### Simu

    ###
    for i in range(0, nbMocks__):
        plt.errorbar(numpy.arange(nbBin__), xi_dat__[:, i], fmt="o")
    plt.xlabel(r"$index \, bin$")
    plt.ylabel(r"$\xi_{Simu}(s)$")
    myTools.deal_with_plot(False, False, True)
    plt.show()

    ### mean:
    meanXi2D = numpy.mean(xi_dat__, axis=1)
    plt.errorbar(numpy.arange(nbBin__), meanXi2D, fmt="o")
    plt.xlabel(r"$index \, bin$")
    plt.ylabel(r"$<\xi_{Simu}(s)>$")
    myTools.deal_with_plot(False, False, True)
    plt.show()

    ### 2D:
    meanXi2D = myTools.convert1DTo2D(meanXi2D, nbBinY2D__, nbBinX2D__)
    myTools.plot2D(
        meanXi2D,
        [minX2D__, maxX2D__, minY2D__, maxY2D__],
        "s_{\perp} \, [h^{-1} Mpc]",
        "s_{\parallel} \, [h^{-1} Mpc]",
        "\\xi_{Simu}^{qf}",
    )

    ####################################################################
    ### Fit

    ###
    for i in range(0, nbMocks__):
        plt.errorbar(numpy.arange(nbBin__), xi_fit__[:, i], fmt="o")
    plt.xlabel(r"$index \, bin$")
    plt.ylabel(r"$\xi_{Fit}(s)$")
    myTools.deal_with_plot(False, False, True)
    plt.show()

    ### mean:
    meanXi2D = numpy.mean(xi_fit__, axis=1)
    plt.errorbar(numpy.arange(nbBin__), meanXi2D, fmt="o")
    plt.xlabel(r"$index \, bin$")
    plt.ylabel(r"$<\xi_{Fit}(s)>$")
    myTools.deal_with_plot(False, False, True)
    plt.show()

    ### 2D:
    meanXi2D = myTools.convert1DTo2D(meanXi2D, nbBinY2D__, nbBinX2D__)
    myTools.plot2D(
        meanXi2D,
        [minX2D__, maxX2D__, minY2D__, maxY2D__],
        "s_{\perp} \, [h^{-1} Mpc]",
        "s_{\parallel} \, [h^{-1} Mpc]",
        "\\xi_{Fit}^{qf}",
    )
	def plot_function(self,function_index):
		"""
		Plot the F1 and F2 function

		"""

		
		if (function_index==0):
			func = self._F1
		elif (function_index==1):
			func = self._F2

		### Plot selection function
		def func2(x):
			return numpy.exp(-0.5*numpy.power(x/self._sigma_gauss,2.))/(numpy.sqrt(2.*numpy.pi)*self._sigma_gauss)
		xxx = numpy.arange(-10.,10.,0.01)
		yyy = func(xxx)
		plt.plot(xxx,yyy, markersize=10,linewidth=2,label=r'$Selection$')
		yyy = func2(xxx)
		plt.plot(xxx,yyy, markersize=10,linewidth=2,label=r'$Gauss$')
		plt.xlabel(r'$\delta$')
		plt.ylabel(r'$Proba$')
		myTools.deal_with_plot(False,False,True)
		plt.show()

		### Plot results
		meanF = self.get_mean_function(function_index)
		def func2(x):
			return func(x)*numpy.exp(-0.5*numpy.power(x/self._sigma_gauss,2.))/(numpy.sqrt(2.*numpy.pi)*self._sigma_gauss)
		
		xxx = numpy.arange(-10.,10.,0.01)
		yyy = func2(xxx)
		def func2(x):
			return numpy.exp(-0.5*numpy.power(x/self._sigma_gauss,2.))/(numpy.sqrt(2.*numpy.pi)*self._sigma_gauss)
		meanF =  scipy.integrate.quad(func2,-numpy.inf,numpy.inf)[0]

		xxx2 = numpy.arange(-10.,10.,0.01)
		yyy2 = func2(xxx)

		plt.plot(xxx2,yyy2, markersize=10,linewidth=2)
		plt.plot(xxx,yyy, markersize=10,linewidth=2)
		plt.xlabel(r'$\delta$')
		plt.ylabel(r'$F(\delta) \cdot Gauss$')
		myTools.deal_with_plot(False,False,False)
		plt.show()

		return
示例#29
0
    def plot_data_and_fit_we(self, we_index, x_power, path_to_mapping, title=True):

        xi1D_data, xi1D_fit = self.get_data_and_fit_we(path_to_mapping)

        cut = self._xiWe[:, we_index, 2] > 0.0
        if self._xiWe[:, we_index, 0][cut].size == 0:
            return

        cut = xi1D_data[:, we_index, 2] > 0.0
        xxx = xi1D_data[:, we_index, 0][cut]
        yyy = xi1D_data[:, we_index, 1][cut]
        yer = xi1D_data[:, we_index, 2][cut]
        coef = numpy.power(xxx, x_power)
        plt.errorbar(
            xxx,
            coef * yyy,
            yerr=coef * yer,
            fmt="o",
            label=r"$" + self._label_wedge[we_index] + "$",
            color="red",
            markersize=10,
            linewidth=2,
        )

        cut = xi1D_fit[:, we_index, 2] > 0.0
        xxxF = xi1D_fit[:, we_index, 0][cut]
        yyyF = xi1D_fit[:, we_index, 1][cut]
        yerF = xi1D_fit[:, we_index, 2][cut]
        coefF = numpy.power(xxxF, x_power)
        plt.errorbar(xxxF, coefF * yyyF, color="blue", linewidth=2)

        if x_power == 0:
            plt.ylabel(r"$" + self._label + " (r)$", fontsize=40)
        if x_power == 1:
            plt.ylabel(r"$r \cdot " + self._label + " (r) \, [\\rm{h}^{-1} \, \\rm{Mpc}]$", fontsize=40)
        if x_power == 2:
            plt.ylabel(r"$r^{2} \cdot " + self._label + " (r) \, [(\\rm{h}^{-1} \, \\rm{Mpc})^{2}]$", fontsize=40)

        if title:
            plt.title(r"$" + self._title + "$", fontsize=40)
        plt.xlabel(r"$r \, [\rm{h}^{-1} \, \rm{Mpc}]$", fontsize=40)
        plt.xlim([numpy.amin(xxx) - 10.0, numpy.amax(xxx) + 10.0])
        myTools.deal_with_plot(False, False, False)
        plt.legend(fontsize=40, numpoints=1, ncol=1, loc=0)
        plt.show()

        return
def plotWe(rescale):

	###
	cut = (xiWe_[:,0,2]!=0.)
	xxx0 = xiWe_[:,0,0][cut]
	yyy0 = xiWe_[:,0,1][cut]
	yer0 = xiWe_[:,0,2][cut]
	#yyy0 -= yyy0[-1]
	###
	cut = (xiWe_[:,1,2]!=0.)
	xxx1 = xiWe_[:,1,0][cut]
	yyy1 = xiWe_[:,1,1][cut]
	yer1 = xiWe_[:,1,2][cut]
	#yyy1 -= yyy1[-1]
	###
	cut = (xiWe_[:,2,2]!=0.)
	xxx2 = xiWe_[:,2,0][cut]
	yyy2 = xiWe_[:,2,1][cut]
	yer2 = xiWe_[:,2,2][cut]
	#yyy2 -= yyy2[-1]

	if (rescale==0):
		plt.errorbar(xxx0, yyy0, yerr=yer0, fmt='o', label=r'$0.8 < |\mu|$')
		plt.errorbar(xxx1, yyy1, yerr=yer1, fmt='o', label=r'$0.5 < |\mu| \leq 0.8$')
		plt.errorbar(xxx2, yyy2, yerr=yer2, fmt='o', label=r'$|\mu| \leq 0.5$')
		plt.ylabel(r'$\xi (|s|)$', fontsize=40)
		plt.legend(fontsize=30, frameon=False, numpoints=1,ncol=2, loc=4)
	if (rescale==1):
		plt.errorbar(xxx0, xxx0*yyy0, yerr=xxx0*yer0, fmt='o', label=r'$0.8 < |\mu|$')
		plt.errorbar(xxx1, xxx1*yyy1, yerr=xxx1*yer1, fmt='o', label=r'$0.5 < |\mu| \leq 0.8$')
		plt.errorbar(xxx2, xxx2*yyy2, yerr=xxx2*yer2, fmt='o', label=r'$|\mu| \leq 0.5$')
		plt.ylabel(r'$|s|.\xi (|s|) \, [h^{-1}.Mpc]$', fontsize=40)
		plt.legend(fontsize=30, frameon=False, numpoints=1,ncol=2, loc=4)
	if (rescale==2):
		plt.errorbar(xxx0, xxx0*xxx0*yyy0, yerr=xxx0*xxx0*yer0, fmt='o', label=r'$0.8 < |\mu|$')
		plt.errorbar(xxx1, xxx1*xxx1*yyy1, yerr=xxx1*xxx1*yer1, fmt='o', label=r'$0.5 < |\mu| \leq 0.8$')
		plt.errorbar(xxx2, xxx2*xxx2*yyy2, yerr=xxx2*xxx2*yer2, fmt='o', label=r'$|\mu| \leq 0.5$')
		plt.ylabel(r'$|s|^{2}.\xi (|s|) \, [(h^{-1}.Mpc)^{2}]$', fontsize=40)
		plt.legend(fontsize=30, frameon=False, numpoints=1,ncol=2, loc=2)
	
        plt.title(r'$\delta_{'+forest1+'} \, - \, \delta_{'+forest2+'}$', fontsize=40)
	plt.xlabel(r'$|s| \, [h^{-1}.Mpc]$', fontsize=40)
	myTools.deal_with_plot(False,False,False)
	plt.xlim([ numpy.min(xxx0)-10., numpy.max(xxx0)+10. ])
	plt.ticklabel_format(style='sci', axis='y', scilimits=(0,0))
	plt.show()