本文整理汇总了Python中myTools.deal_with_plot函数的典型用法代码示例。如果您正苦于以下问题:Python deal_with_plot函数的具体用法?Python deal_with_plot怎么用?Python deal_with_plot使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了deal_with_plot函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plotDataAndFit_S
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
示例2: compare_each_simu
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
示例3: plot
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
示例4: loadBootMap
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
示例5: plotWe
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()
示例6: plotXi
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()
示例7: plotXi
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: plot_1d
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
示例9: fit_CAMB
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
示例10: plotXi
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: difTemplate
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: getQsoCatalogueAllObjects
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)
示例13: plotXi
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()
示例14: plot_histo_residuals
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
示例15: plotDataAndFit_1D
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