def plot_wedge(self,ax,mubin,plot_label,colour,r_power=2,nr=40,rmax_plot=200.,abs_mu=False): mumin = mubin[0] mumax = mubin[1] #Create the wedge, and wedgise the correlation. b = wedgize.wedge(mumin=mumin,mumax=mumax,rtmax=self.rtmax,nrt=self.nt, rpmin=self.rpmin,rpmax=self.rpmax,nrp=self.np,nr=nr,rmax=rmax_plot, absoluteMu=abs_mu) r, xi_wed, cov_wed = b.wedge(self.xi,self.cov) print(mubin) print(r[:4]) print(xi_wed[:4]) print(' ') #Get the errors. Nr = len(r) err_wed = np.zeros(Nr) for i in range(Nr): err_wed[i] = np.sqrt(cov_wed[i][i]) #Define the variables to plot, and plot them. cut = err_wed>0 r = r[cut] xi_wed = xi_wed[cut] err_wed = err_wed[cut] ar = ax.errorbar(r,(r**r_power) * xi_wed,yerr=(r**r_power) * err_wed,fmt='o',label=plot_label,color=colour) return ar, plot_label
def plot_wedge_fit(self,ax,mubin,plot_label,colour,r_power=2,nr=40,rmax_plot=200.,rmin_fit=None,rmax_fit=None,abs_mu=False): #Using data in picca fit mumin = mubin[0] mumax = mubin[1] b = wedgize.wedge(mumin=mumin,mumax=mumax,rtmax=self.rtmax,nrt=self.nt, rpmin=self.rpmin,rpmax=self.rpmax,nrp=self.np,nr=nr,rmax=rmax_plot, absoluteMu=abs_mu) """ #REMOVE NON_DIAGONALS FROM COV MATRIX for i in range(self.cov_grid.shape[0]): for j in range(self.cov_grid.shape[1]): if i!=j: self.cov_grid[i,j]=0 """ r, fit_xi_wed, _ = b.wedge(self.fit['xi_grid'],self.cov) if rmin_fit == None: rmin_fit = 0. if rmax_fit == None: rmax_fit = rmax_plot #Plot the fit up to rmax_plot in a dashed line. ax.plot(r,(r**r_power) * fit_xi_wed,c=colour,linestyle='--') #Plot the fit in the fitted region in a solid line. fit_bins = (r>rmin_fit) * (r<rmax_fit) ax.plot(r[fit_bins],(r[fit_bins]**r_power) * fit_xi_wed[fit_bins],c=colour,label=plot_label) return
def plot_xir2(self,mubin,plot_label): mumin = mubin[0] mumax = mubin[1] b = wedgize.wedge(mumin=mumin,mumax=mumax,rtmax=self.rtmax,nrt=self.nt, rpmin=self.rpmin,rpmax=self.rpmax,nrp=self.np,nr=self.nr, rmax=self.rmax) #REMOVE NON_DIAGONALS FROM COV MATRIX for i in range(self.cov_grid.shape[0]): for j in range(self.cov_grid.shape[1]): if i!=j: self.cov_grid[i,j]=0 r, xi_wed, cov_wed = b.wedge(self.xi_grid,self.cov_grid) Nr = len(r) err_wed = np.zeros(Nr) for i in range(Nr): err_wed[i] = np.sqrt(cov_wed[i][i]) cut = err_wed>0 plt.errorbar(r[cut],xi_wed[cut],yerr=err_wed[cut],fmt='o',label=plot_label) return
def plot_wedge_manual_model(self,ax,b1,b2,beta1,beta2,mubin,plot_label,colour,r_power=2,nr=40,rmax_plot=200.,abs_mu=False): #Using data in picca fit mumin = mubin[0] mumax = mubin[1] b = wedgize.wedge(mumin=mumin,mumax=mumax,rtmax=self.rtmax,nrt=self.nt, rpmin=self.rpmin,rpmax=self.rpmax,nrp=self.np,nr=nr,rmax=rmax_plot, absoluteMu=abs_mu) #Using our model model = 'Slosar11' r,xi = correlation_model.get_model_xi(model,self.quantity_1,self.quantity_2,b1,b2,beta1,beta2,self.zeff,mubin) indices = r<rmax_plot r = r[indices] xi = xi[indices] ax.plot(r,(r**r_power) * xi,c=colour,label=plot_label,linestyle=':') return
def get_plot_data(mumin,mumax,file_path): #Read data from the filename to know how to wedgize etc #filename format: ${CORRELTYPE}_${NPIXELS}_${BRANCH}_${OPTION}_${RSDOPTION}_rpmin${RPMIN}_rpmax${RPMAX}_rtmax${RTMAX}_np${NP}_nt${NT}_zmin${ZQSOMIN}_zmax${ZQSOMAX}.fits.gz parameters = get_parameters_from_filename(file_path) #file_parameters = {**file_parameters,**{filename:parameters}} h = fits.open(file_path) data = h[1].data b = wedgize.wedge(mumin=mumin,mumax=mumax,rtmax=parameters['rtmax'], nrt=int(parameters['nt']),rpmin=parameters['rpmin'], rpmax=parameters['rpmax'],nrp=int(parameters['np']), nr=int(parameters['nr']),rmax=parameters['rmax']) rp = data['RP'][:] rt = data['RT'][:] z = data['Z'][:] xi_grid = data['DA'][:] cov_grid = data['CO'][:] #REMOVE NON_DIAGONALS FROM COV MATRIX for i in range(cov_grid.shape[0]): for j in range(cov_grid.shape[1]): if i!=j: cov_grid[i,j]=0 r, xi_wed, cov_wed = b.wedge(xi_grid,cov_grid) Nr = len(r) err_wed = np.zeros(Nr) for i in range(Nr): err_wed[i] = np.sqrt(cov_wed[i][i]) cut = err_wed>0 return r, xi_wed, err_wed, cut, parameters
fout = open(args.out, 'w') for i in range(len(data.RP)): print(data.RP[i], data.RT[i], xid[i], file=fout) fout.close() if args.plot: P.figure() P.pcolormesh( sp.reshape(data.RP, (50, 50)), \ sp.reshape(data.RT, (50, 50)), \ sp.reshape(xid*(data.RP**2+data.RT**2), (50, 50)), \ vmin=-1, vmax=1. ) P.colorbar() for mus in [[0., 0.5], [0.5, 0.8], [0.8, 0.95], [0.95, 1.]]: w = wedge(rpmin=0.0, rpmax=200.0, nrp=50, \ rtmin=0.0, rtmax=200.0, nrt=50, \ rmin=0.0, rmax=200.0, nr=50, \ mumin=mus[0], mumax=mus[1], ss=10) r, wedm, wedcov = w.wedge(xid, data.CO) r, wed, wedcov = w.wedge(data.DA, data.CO) dwed = N.sqrt(N.diag(wedcov)) P.figure() #-- we multiply the wedges by r**2 so we can see the BAO peak P.errorbar(r, wed * r**2, dwed * r**2, fmt='o') P.plot(r, wedm * r**2) P.ylim(-1.2, 0.5) P.title(r'$%.1f < \mu < %.1f$' % (mus[0], mus[1])) P.xlabel('r [Mpc/h]') P.show()
rp = data['RP'][:] rt = data['RT'][:] z = data['Z'][:] xi_grid = data['DA'][:] cov_grid = data['CO'][:] #b = wedgize.wedge(mumin=0.0, mumax=1.0,rtmax=20.0,nrt=5,rpmax=20.0,nrp=5,nr=20,rmax=40) #b = wedgize.wedge(mumin=0.0, mumax=1.0,rtmax=40.0,nrt=10,rpmax=40.0,nrp=10,nr=40,rmax=80) #b = wedgize.wedge(mumin=0.0, mumax=1.0,rtmax=80.0,nrt=20,rpmax=80.0,nrp=20,nr=80,rmax=160) #b = wedgize.wedge(mumin=0.0, mumax=1.0,rtmax=100.0,nrt=25,rpmax=100.0,nrp=25,nr=100,rmax=200) #b = wedgize.wedge(mumin=0.0, mumax=1.0,rtmax=140.0,nrt=35,rpmax=140.0,nrp=35,nr=150,rmax=300) b = wedgize.wedge(mumin=wedgize_args[0], mumax=wedgize_args[1], rtmax=wedgize_args[2], nrt=wedgize_args[3], rpmax=wedgize_args[4], nrp=wedgize_args[5], nr=wedgize_args[6], rmax=wedgize_args[7]) r, xi_wed, cov_wed = b.wedge(xi_grid, cov_grid) Nr = len(r) err_wed = np.zeros(Nr) for i in range(Nr): err_wed[i] = np.sqrt(cov_wed[i][i]) print(i, err_wed[i], cov_wed[i][i]) cut = err_wed > 0 plt.errorbar(r[cut], xi_wed[cut] * (r[cut]**2),
def plot_wedge(self, x_power=0, mumin=-1., mumax=1., other=None, fontsize=18): list_corr = [self] if not other is None: list_corr += other for c in list_corr: rpmin = c._rp_min rpmax = c._rp_max nrp = c._np rtmin = c._rt_min rtmax = c._rt_max nrt = c._nt rmin = 0. rmax = c._rt_max nr = c._nt ss = 10 wed = wedgize.wedge(rpmin=rpmin, rpmax=rpmax, nrp=nrp, rtmin=rtmin, rtmax=rtmax, nrt=nrt, rmin=rmin, rmax=rmax, nr=nr, mumin=mumin, mumax=mumax, ss=ss) r, d, ivar = wed.wedge(c._da, c._co) e = sp.sqrt(sp.diag(ivar)) coef = sp.power(r, x_power) if not c._isfit: plt.errorbar(r, coef * d, yerr=coef * e, linewidth=1, label=r'$' + c._title + '$', fmt='.', color='c') else: plt.errorbar(r, coef * d, label=r'$' + c._title + '$', color='red') plt.title(r"$" + str(mumin) + " < \mu < " + str(mumax) + "$", fontsize=fontsize) plt.xlabel(r'$r \, [h^{-1} \, \mathrm{Mpc}]$', fontsize=fontsize) if (x_power == 0): plt.ylabel(r'$\xi^{qf}(r)$', fontsize=fontsize) if (x_power == 1): plt.ylabel(r'$r \cdot \xi^{qf}(r) \, [h^{-1} \, \mathrm{Mpc}]$', fontsize=fontsize) if (x_power == 2): plt.ylabel( r'$r^{2} \cdot \xi^{qf}(r) \, [(h^{-1} \, \mathrm{Mpc})^{2}]$', fontsize=fontsize) plt.legend(fontsize=8, numpoints=1, ncol=2) #plt.grid() #plt.tight_layout() #plt.show() return