def readpsoutput(self,file,z): input=open(file,'r') mass=[] frac=[] for line in input: t=line.split() mass.append(float(t[2])) frac.append(float(t[3])) #try: #frac.append(float(t[3])) #except: # frac.append(1.e-10) input.close() mass=N.array(mass,'d') sigma=((mass/(1.2e15/h)*N.sqrt(.7+.3*(1+z)**3))**(1./3.))*1000. frac=N.array(frac,'d') sigma=N.log10(sigma) #maccret=(frac*mass) maccret=N.zeros(len(mass),'d') for i in range(len(mass)): maccret[i]=mass[i]*frac[i] print i,mass[i],frac[i],maccret[i] frac=N.log10(frac) self.sigma=sigma self.mass=mass self.frac=frac self.maccret=maccret
def makeplotsub(c): plot(c.f24, c.fap4 * 1.67, 'bo', markersize=4) #plot(c.f24,c.fap4,'ro',markersize=4) #plot(c.f24,c.fap3,'go',markersize=2) #plot(c.f24,c.fap2,'yo',markersize=2) #plot(c.f24,c.fap1,'co',markersize=2) x = N.arange(1., max(c.f24), 100.) y = x plot(x, y, 'k-') y2 = y + N.log10(2.) plot(x, y2, 'k--') y2 = y + N.log10(.5) plot(x, y2, 'k--') y = 3. * x #plot(x,y,'k-') y = 4. * x #plot(x,y,'k-') y = 5. * x #plot(x,y,'k-') ax = gca() text(.1, .8, c.prefix, horizontalalignment='left', verticalalignment='center', transform=ax.transAxes) #xlabel('Mopex F(24)',fontsize=fsize) #ylabel('Ap Flux ',fontsize=fsize) axis([20., 4000., 20., 4000.]) ax.set_xscale('log') ax.set_yscale('log')
def gwritefiles(self,clusters,j): outfile=clusters[:(len(clusters)-4)]+'2.dat' out=open(outfile,'w') infile=open(clusters,'r') i=0 ds5=[] ds10=[] k=0 for line in infile: if line.find('#') > -1: out.write(line) continue if k < 1: out.write('# 27 Sigma_5 calculated from spec sample \n') out.write('# 28 Sigma_10 calculated from spec sample \n') out.write('# 29 Sigma_5 calculated from phot sample \n') out.write('# 30 Sigma_10 calculated from phot sample \n') out.write('# 31 Sigma_5 calculated from spec sample extended to 2xR200 \n') out.write('# 32 Sigma_10 calculated from spec sample extended to 2xR200\n') out.write('# 33 M_V (h100 = 0.7) corrected to cluster redshift \n') k=1 fields=line.split() dLgal=my.dL(float(fields[4]),h100) dm=5.*N.log10(dLgal/c.dL[j])#correct abs mag to cluster redshift m=float(fields[22])+dm m=m-0.77#convert to h100=0.7 if (m > mabscut):#keep only galaxies that meet mag cut out.write(line) #print "didn't make mag cut",m,mabscut, continue distmod=5.*N.log10(dLgal)+25. g=float(fields[10])-0.77+ distmod r=float(fields[11])-0.77+ distmod if (g > 18.0): #print "didn't make g cut, g = ",g,fields[10],m,distmod continue if (r > 17.7): #print "didn't make r cut, g = ",r,fields[11],m continue if (abs(float(fields[25])/(c.z[j]+1)*3.e5) > 3*c.sigma[j]):#keep only galaxies w/in 3 sigma out.write(line) #print "didn't make vel cut" continue #print i, 'writing output ',len(self.sig5),len(self.sig5),len(self.sig10),len(self.sig5phot),len(self.sig10phot),len(line) nline=line[:(len(line)-2)]+" %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f\n"%(self.sig5[i],self.sig10[i],self.sig5phot[i],self.sig10phot[i], self.sig52r200[i],self.sig102r200[i], self.V[i]) d5=(self.sig5phot[i]-self.sig5[i]) d10=(self.sig10phot[i]-self.sig10[i]) #print " %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f \n"%((self.sig5phot[i]-self.sig5[i]),(self.sig10phot[i]-self.sig10[i]),self.sig5[i],self.sig10[i],self.sig5phot[i],self.sig10phot[i]) out.write(nline) ds5.append(d5) ds10.append(d10) i=i+1 out.close() infile.close() return ds5, ds10
def greadfiles(self, clusters, i): infile = open(clusters, 'r') distmod = (5. * N.log10(c.dL[i]) + 25.) for line in infile: if line.find('#') > -1: continue fields = line.split() #print fields[25] dLgal = my.dL(float(fields[4]), h100) dm = 5. * N.log10( dLgal / c.dL[i]) #correct abs mag to cluster redshift m = float(fields[22]) + dm m = m - 0.77 #convert to h100=0.7 if (m > mabscut): #keep only galaxies that meet mag cut continue #apply color selection to mimic ediscs selection distmod = 5. * N.log10(dLgal) + 25. g = float(fields[10]) - 0.77 + distmod r = float(fields[11]) - 0.77 + distmod if (g > 18.0): #print "didn't make g cut, g = ",g,fields[10],m,distmod continue if (r > 17.7): #print "didn't make r cut, g = ",r,fields[11],m continue if (abs(float(fields[25]) / (c.z[i] + 1) * 3.e5) > 3 * c.sigma[i]): #keep only galaxies w/in 3 sigma continue self.z.append(float(fields[4])) self.ra.append(float(fields[5])) self.dec.append(float(fields[6])) self.o2.append(float(fields[7])) self.erro2.append(float(fields[8])) self.u.append(float(fields[9])) self.g.append(float(fields[10])) self.r.append(float(fields[11])) self.i.append(float(fields[12])) self.zm.append(float(fields[13])) self.gpetrext.append(float(fields[14])) self.rpetrext.append(float(fields[15])) self.ipetrext.append(float(fields[16])) self.zpetrext.append(float(fields[17])) self.V.append(m) self.distBCG.append(float(fields[23])) self.distBCGR200.append(float(fields[23])) self.dz.append(float(fields[25])) infile.close()
def calculate_spectrogram(input_array, framesize, hopsize, window_function = numarray.linear_algebra.mlab.hanning, keep_bands_until = 0, axis = 0): """Calculate the spectrogram.""" do_fft = lambda arr: abs(numarray.fft.real_fft(arr, axis = axis))[:keep_bands_until] keep_bands_until = keep_bands_until or int(framesize / 2) input_shape = map(None, numarray.shape(input_array)) window = window_function(framesize) if len(input_shape) > 1: window = transpose(array([list(window)] * input_shape[1])) # print "input_shape:", shape(input_array) zeros_shape = input_shape # this allows for both 1 and 2 dim inputs zeros_shape[0] = framesize / 2 input_array_plus_zeros = numarray.concatenate((numarray.zeros(zeros_shape), input_array, numarray.zeros(zeros_shape))) fft_range = range(0, len(input_array) - framesize, hopsize) fft_array = numarray.zeros(([len(fft_range)] + map(None, numarray.shape(do_fft(window)))), # do_fft(window) is used here because it gives the right shape numarray.Float32) * 1.0 # this *1.0 is necessary! for result_counter, input_counter in enumerate(fft_range): frame = window * input_array_plus_zeros[input_counter : input_counter + framesize] fft_array[result_counter] = 10 * numarray.log10(0.1 + do_fft(frame)) return fft_array
def getsdssspeccats(self): #get photometric sources within 2R200 print "elapsed time = ", time.clock() - starttime self.mcut = N.zeros(len(self.z), 'f') for i in range(len(self.z)): dL = self.dL[i] print "getting spec cat for cluster abell", self.id[i] r200arcmin = self.r200deg[i] * 60. drsearch = 3. * r200arcmin #2xR200 in arcmin for sdss query #Vg=0.3556-0.7614*((self.avegr)-0.6148)#(V-g) from Blanton et al 2003 mr = mabscut - 0.1331 + 5. * N.log10(dL) + 25. + self.kcorr[i] print i, self.z[i], dL, mr self.mcut[i] = mr dz = 3 * self.sigma[i] / (3.e5) * (1 + self.z[i]) zmax = self.z[i] + .5 * dz zmin = self.z[i] - .5 * dz print "ra, dec, dr, mr = %12.8f %12.8f %8.3f %5.2f" % ( self.ra[i], self.dec[i], drsearch, mr) query = "select g.ra, g.dec, g.u, g.g, g.r, g.i, g.z, g.objid, g.specObjID,g.extinction_u, g.extinction_g, g.extinction_r, g.extinction_i, g.extinction_z, l.ew, l.ewErr, l2.ew, l2.ewErr from galaxy g, specobj s, SpecLine l, SpecLine l2, dbo.fGetNearbyObjEq(%12.8f,%12.8f,%8.3f) n where g.objID = n.objID and g.objID = s.bestobjid and s.specobjID=l.specobjID and s.specobjID=l2.specobjID and (g.g < %5.2f) and (g.PrimTarget & 0x00000040) > 0 and (s.z > %6.4f) and (s.z < %6.4f) and l.LineID = 3727 and l2.LineID = 6565" % ( self.ra[i], self.dec[i], drsearch, (mr + 3), zmin, zmax) # query="select g.ra, g.dec, g.u, g.g, g.r, g.i, g.z, g.objid, g.specObjID,g.extinction_u, g.extinction_g, g.extinction_r, g.extinction_i, g.extinction_z, l.ew, l.ewErr, l2.ew, l2.ewErr from galaxy g, specobj s, SpecLine l, SpecLine l2, dbo.fGetNearbyObjEq(%12.8f,%12.8f,%8.3f) n where g.objID = n.objID and g.objID = s.bestobjid and s.specobjID=l.specobjID and s.specobjID=l2.specobjID and (g.g < %5.2f) and (g.PrimTarget & 0x00000040) > 0 and l.LineID = 3727 and l2.LineID = 6565" % (self.ra[i],self.dec[i],drsearch,(mr)) lines = sqlcl.query(query).readlines() #print query print "got number+1 spec objects w/in 2R200= ", len(lines) #print lines output = "abell" + str(self.id[i]) + ".spec2r200.dat" outfile = open(output, 'w') outfile.write("#%s " % (lines[0])) for line in lines[1:]: outfile.write("%s " % (line)) outfile.close()
def binitbinsmabs(xmin, xmax, nbin, x, y): #use equally spaced bins y = 10.**(y) dx = float((xmax - xmin) / (nbin)) xbin = N.arange(xmin, (xmax), dx) + dx / 2. ybin = N.zeros(len(xbin), 'd') ybinerr = N.zeros(len(xbin), 'd') xbinnumb = N.array(len(x), 'd') x1 = N.compress((x >= xmin) & (x <= xmax), x) y1 = N.compress((x >= xmin) & (x <= xmax), y) x = x1 y = y1 xbinnumb = ((x - xmin) * nbin / (xmax - xmin) ) #calculate x bin number for each point j = -1 for i in range(len(xbin)): ydata = N.compress(abs(xbinnumb - float(i)) < .5, y) try: ybin[i] = N.log10(N.average(ydata)) #ybin[i]=pylab.median(ydata) ybinerr[i] = pylab.std(ydata) / N.sqrt(float(len(ydata))) except ZeroDivisionError: ybin[i] = -99. ybinerr[i] = -99. return xbin, ybin, ybinerr
def fig3b(t, m, w, p): """ Plot image of age,metallicity weights -- nearest neighbor interpolation""" NREP = 50 xi = pylab.linspace(0.1, 15, 512) yi = pylab.linspace(-2.5, 0.9, 512) z = numarray.zeros((len(xi), len(yi)), numarray.Float) # create t, metallicity array y = numarray.repeat(m, NREP) dt = t[1] - t[0] x = numarray.arange(t[0], t[-1] + 2 * dt, dt / NREP) x = x[0:len(y)] x = 10.**x / 1.e9 weight = numarray.repeat(w, NREP) # Find the indices in the array xindex = numarray.searchsorted(xi, x) print "shape(x), shape(y), shape(weight)", numarray.shape( x), numarray.shape(y), numarray.shape(weight) if p.sigma > 0: if p.dsigmadlogt == 0.: for i in range(len(y)): nstars = weight[i] * normgauss(yi, y[i], p.sigma) j = xindex[i] z[j, :] += nstars if p.dsigmadlogt != 0.: for i in range(len(y)): logt0 = numarray.log10(x[0]) logt = numarray.log10(x[i]) sigma = p.sigma + p.dsigmadlogt * (logt - logt0) nstars = weight[i] * normgauss(yi, y[i], sigma) j = xindex[i] z[j, :] += nstars else: sigma = 0.01 for i in range(len(y)): nstars = weight[i] * normgauss(yi, y[i], sigma) j = xindex[i] z[j, :] += nstars # yindex = numarray.searchsorted(yi,y) # z[xindex,yindex] = z[xindex,yindex] + weight # increment the 2-d array zz = numarray.transpose(z) pylab.imshow(zz, extent=[0.1, 15, -2.5, 0.9], aspect='auto') pylab.xlabel("Age (Gyr)") pylab.ylabel("[Fe/H]") return xi, yi, zz
def plotsig10sffall(sigspec, sigphot, sf, file, nbin): psplot = file + ".ps" psplotinit(psplot) ppgplot.pgbox("", 0.0, 0, "L", 0.0, 0) ymin = -.01 ymax = 1.01 #xmin=min(sigspec)-10. #xmax=max(sig)-200. #xmax=400. xmin = -1. xmax = 2.7 ppgplot.pgenv(xmin, xmax, ymin, ymax, 0, 10) ppgplot.pglab("\gS\d10\u (gal/Mpc\u2\d)", "Fraction EW([OII])>4 \(2078)", "") ppgplot.pgsls(1) #dotted ppgplot.pgslw(4) #line width tot = N.ones(len(sf), 'f') (sigbin, sfbin) = my.binitsumequal(sigspec, sf, nbin) (sigbin, totbin) = my.binitsumequal(sigspec, tot, nbin) (sff, sfferr) = my.ratioerror(sfbin, totbin) #sig=N.array(sig,'f') #sff=N.array(sff,'f') ppgplot.pgsci(2) sigbin = N.log10(sigbin) ppgplot.pgline(sigbin, sff) ppgplot.pgsci(1) ppgplot.pgpt(sigbin, sff, 17) my.errory(sigbin, sff, sfferr) (sigbin, sfbin) = my.binitsumequal(sigphot, sf, nbin) (sigbin, totbin) = my.binitsumequal(sigphot, tot, nbin) (sff, sfferr) = my.ratioerror(sfbin, totbin) #sig=N.array(sig,'f') #sff=N.array(sff,'f') ppgplot.pgslw(4) #line width ppgplot.pgsci(4) sigbin = N.log10(sigbin) ppgplot.pgline(sigbin, sff) ppgplot.pgsci(1) ppgplot.pgpt(sigbin, sff, 21) #my.errory(sigbin,sff,sfferr) ppgplot.pgend()
def plotsighaall(sig, psig, o2b, file, nbin): o2b = N.array(o2b, 'f') sig = N.array(sig, 'f') psig = N.array(psig, 'f') #o2b=o2b+4. o2 = N.compress(o2b > -500., o2b) sig = N.compress(o2b > -500., sig) psig = N.compress(o2b > -500., psig) psplot = file + ".ps" psplotinit(psplot) #ppgplot.pgsch(0.7) ppgplot.pgslw(7) (sigbin, o2bin) = my.binit(sig, o2, nbin) #print 'dude', sigbin, o2bin sigbin = N.log10(sigbin) ppgplot.pgswin(-2., 2., -5., 20.) ppgplot.pgbox('blcnst', 0.0, 0.0, 'bcvnst', 0.0, 0.0) #tickmarks and labeling ppgplot.pgsch(1.0) ppgplot.pgmtxt('b', 2.5, 0.5, 0.5, "\gS\d10\u (gal/Mpc\u2\d)") #xlabel ppgplot.pgsch(1.2) ppgplot.pgmtxt('l', 2.6, 0.5, 0.5, 'EW(H\ga) (\(2078))') ppgplot.pgsls(1) #dotted ppgplot.pgslw(4) #line width ppgplot.pgpt(sigbin, o2bin, 17) ppgplot.pgpt(N.log10(sig), o2, 1) #my.errory(sigbin,o2bin,yerr) #print 'dude2', sigbin, o2bin ppgplot.pgsci(2) ppgplot.pgline(sigbin, o2bin) (sigbin, o2bin) = my.binit(psig, o2, nbin) #print 'dude', sigbin, o2bin sigbin = N.log10(sigbin) ppgplot.pgsci(1) ppgplot.pgpt(sigbin, o2bin, 21) #my.errory(sigbin,o2bin,yerr) ppgplot.pgsci(4) ppgplot.pgline(sigbin, o2bin) ppgplot.pgsci(1) ppgplot.pgend()
def isovalues(isos,isow): x = numarray.zeros(len(isos))*0. # age y = numarray.zeros(len(isos))*0. # metallicity z = numarray.zeros(len(isos))*0. # metallicity for i in range(len(isos)): feh,age = iso.scaled2real(isos[i][0],isos[i][1]) y[i] = feh x[i] = numarray.log10(age) z[i] = isow[i] return x,y,z
def isovalues(isos, isow): x = numarray.zeros(len(isos)) * 0. # age y = numarray.zeros(len(isos)) * 0. # metallicity z = numarray.zeros(len(isos)) * 0. # metallicity for i in range(len(isos)): feh, age = iso.scaled2real(isos[i][0], isos[i][1]) y[i] = feh x[i] = numarray.log10(age) z[i] = isow[i] return x, y, z
def fig3b(t,m,w,p): """ Plot image of age,metallicity weights -- nearest neighbor interpolation""" NREP = 50 xi = pylab.linspace(0.1,15,512) yi = pylab.linspace(-2.5,0.9,512) z = numarray.zeros((len(xi),len(yi)),numarray.Float) # create t, metallicity array y = numarray.repeat(m,NREP) dt = t[1]-t[0] x = numarray.arange(t[0],t[-1]+2*dt,dt/NREP) x = x[0:len(y)] x = 10.**x/1.e9 weight = numarray.repeat(w,NREP) # Find the indices in the array xindex = numarray.searchsorted(xi,x) print "shape(x), shape(y), shape(weight)", numarray.shape(x),numarray.shape(y), numarray.shape(weight) if p.sigma > 0: if p.dsigmadlogt == 0.: for i in range(len(y)): nstars = weight[i]*normgauss(yi,y[i],p.sigma) j = xindex[i] z[j,:] += nstars if p.dsigmadlogt != 0.: for i in range(len(y)): logt0 = numarray.log10(x[0]) logt = numarray.log10(x[i]) sigma = p.sigma + p.dsigmadlogt*(logt-logt0) nstars = weight[i]*normgauss(yi,y[i],sigma) j = xindex[i] z[j,:] += nstars else: sigma = 0.01 for i in range(len(y)): nstars = weight[i]*normgauss(yi,y[i],sigma) j = xindex[i] z[j,:] += nstars # yindex = numarray.searchsorted(yi,y) # z[xindex,yindex] = z[xindex,yindex] + weight # increment the 2-d array zz = numarray.transpose(z) pylab.imshow(zz,extent=[0.1,15,-2.5,0.9],aspect='auto') pylab.xlabel("Age (Gyr)") pylab.ylabel("[Fe/H]") return xi,yi,zz
def azmr(self): x=N.compress((self.mpaflag > 0.1) & (self.ew > 4.) & (self.Mabs < -18.),self.Mabs) y=N.compress((self.mpaflag > 0.1) & (self.ew > 4.) & (self.Mabs < -18.),self.ar) x1=N.compress((self.mpaflag > 0.1) & (self.ew > 4.) & (self.Mabs < -20.38),self.Mabs) y1=N.compress((self.mpaflag > 0.1) & (self.ew > 4.) & (self.Mabs < -20.38),self.ar) y=2.5*N.log10(y) #pylab.plot(x,y,'k.',markersize=0.1,zorder=1) print "average Ar for Mr < -20.38 = %5.2f +/- %5.2f"%(N.average(y1),pylab.std(y1)) (xbin,ybin)=my.binit(x1,y1,20) #(xbin,ybin,ybinerr)=my.biniterr(x,y,20) for i in range(len(xbin)): print i,xbin[i],ybin[i] print "Average of binned values = ",N.average(ybin) print "average Ar for Mr < -20.38 = %5.2f +/- %5.2f"%(N.average(N.log10(y1)),pylab.std(N.log10(y1))) #pylab.axis([-26.,-12.,0.1,30.]) pylab.xlabel(r'$\rm{M_r}$',fontsize=28.) pylab.ylabel(r'$\rm{A_r}$',fontsize=28.) (xbin,ybin)=my.binit(x,y,20) #(xbin,ybin,ybinerr)=my.biniterr(x,y,20) for i in range(len(xbin)): print i,xbin[i],ybin[i] pylab.plot(xbin,ybin,'r-',lw=5) ax=pylab.gca() xmin=-24. xmax=-18. ymin=-1. ymax=3. my.contourf(x,y,xmin,xmax,ymin,ymax) pylab.axvline(x=-20.6,linewidth=3,ls='--',c='g') xl=N.arange(-23.,-20.5,.2) yl=0.76*N.ones(len(xl),'f') pylab.plot(xl,yl,'b-',lw=3) pylab.axis([-24.,-18,-1.,2.4]) #ax.set_yscale('log') #pylab.show() pylab.savefig('armr.eps') print "fraction w/MPA stellar mass and Az = ",N.sum(self.mpaflag)/(1.*len(self.mpaflag))
def plotsigo2all(sig, psig, o2b, file, nbin): #o2=N.zeros(len(o2b),'f') #for i in range(len(o2b)): #print i, sig[i], psig[i], o2b[i] # if o2b[i] < 0: # o2[i]=-1*o2b[i] #print "hey", o2[i] o2 = o2b psplot = file + ".ps" psplotinit(psplot) ppgplot.pgsch(0.7) (sigbin, o2bin) = my.binit(sig, o2, nbin) #print 'dude', sigbin, o2bin sigbin = N.log10(sigbin) ppgplot.pgswin(-1., 3., -.5, 10.) ppgplot.pgbox('bcnst', 0.0, 0.0, 'bcvnst', 0.0, 0.0) #tickmarks and labeling ppgplot.pgsch(1.0) ppgplot.pgmtxt('b', 2.5, 0.5, 0.5, "\gS\d10\u (gal/Mpc\u2\d)") #xlabel ppgplot.pgsch(1.2) ppgplot.pgmtxt('l', 2.6, 0.5, 0.5, 'EW([OII]) (\(2078))') ppgplot.pgsls(1) #dotted ppgplot.pgslw(4) #line width ppgplot.pgsci(2) ppgplot.pgpt(sigbin, o2bin, 17) #print 'dude2', sigbin, o2bin ppgplot.pgline(sigbin, o2bin) (sigbin, o2bin) = my.binit(psig, o2, nbin) #print 'dude', sigbin, o2bin sigbin = N.log10(sigbin) ppgplot.pgsci(4) ppgplot.pgpt(sigbin, o2bin, 21) ppgplot.pgline(sigbin, o2bin) ppgplot.pgsci(1) ppgplot.pgend()
def greadphotfiles(self, gphotfile, dL, kcorr): self.photra = [] self.photdec = [] self.phu = [] self.phMv = [] for line in open(gphotfile): if line.find('#') > -1: continue if len(line) < 10: #phot files have blank line at end - skip it continue #print line fields = line.split(',') #print fields[0], fields[1], line #need to implement a mag cut g = float(fields[3]) r = float(fields[4]) if (g > 18.0): continue if (r > 17.7): continue g01 = g + 0.3134 + 0.4608 * ((g - r) * -0.6148) g01 = g01 + .01 #convert to vega r01 = g - 0.4118 - .8597 * ((g - r) * -0.6148) r01 = r01 - .04 #convert to vega V = g01 - 0.6689 - 0.9264 * ((g01 - r01) - 0.7252) g = g - (-0.08) #convert to vega r = r - (.16) #convert to vega #g=g-float(fields[10])#correct for extinction #r=r-float(fields[11])#correct for extinction V = g - 0.3556 - 0.7614 * ((g - r) - 0.6148) #mv=V - (5.*N.log10(dL)+25.+kcorr) mv = V - (5. * N.log10(dL) + 25.) if ((mv) < mabscut): self.photra.append(float(fields[0])) self.photdec.append(float(fields[1])) self.phu.append(float(fields[2])) self.phMv.append(float(mv)) #self.photra.append(float(fields[0])) #self.photdec.append(float(fields[1])) #self.phu.append(float(fields[2])) #self.phMv.append(float(mv)) self.photra = N.array(self.photra, 'f') self.photdec = N.array(self.photdec, 'f') self.phu = N.array(self.phu, 'f') self.phMv = N.array(self.phMv, 'f')
def eblPlot(model=pySources.Primack05): atten = pySources.EblAtten(model) tau = [] for z in zvalues: foo = FunctionWrapper(lambda energy: atten(energy, z)) tau.append(foo(energies)) tau = num.array(tau) disp = plot.image(tau, num.log10(energies) - 3, num.log10(zvalues), xname='log10(E/GeV)', yname='log10(z)', zname='tau', aspect=1) disp.setPointRep(plot.prf.create('Contour')) disp.setContourLevels((0.5, 1, 2, 3, 5)) disp.setRange('z', 0, 6) plot.canvas.selectDisplay(disp) for id in blazars: plot.hline(num.log10(blazars[id])) plot.vline(num.log10(20. / 2e3)) plot.vline(num.log10(2e5 / 2e3)) return disp
def getsdssspeccats(self): #get photometric sources within 2R200 print "elapsed time = ",time.clock()-starttime self.mcut=N.zeros(len(self.z),'f') for i in range(len(self.z)): dL = self.dL[i] print "getting spec cat for cluster abell",self.id[i] r200arcmin=self.r200deg[i]*60. drsearch=3.*r200arcmin#2xR200 in arcmin for sdss query #Vg=0.3556-0.7614*((self.avegr)-0.6148)#(V-g) from Blanton et al 2003 mr=mabscut - 0.1331 + 5.*N.log10(dL)+25.+self.kcorr[i] print i, self.z[i], dL, mr self.mcut[i]=mr dz=3*self.sigma[i]/(3.e5)*(1+self.z[i]) zmax=self.z[i]+.5*dz zmin=self.z[i]-.5*dz
def azhist(self): x=N.compress((self.mpaflag > 0.1) & (self.ew > 4.),self.Mabs) y=N.compress((self.mpaflag > 0.1) & (self.ew > 4.),self.ar) y=2.5*N.log10(y) m1=-18. self.azhistsub(x,y,m1,'b') #m1=-19. #self.azhistsub(x,y,m1,'r') m1=-20. self.azhistsub(x,y,m1,'g') #m1=-21. #self.azhistsub(x,y,m1,'k') m1=-22. self.azhistsub(x,y,m1,'y') #m1=-23. #self.azhistsub(x,y,m1,'c') #pylab.show() #ax=pylab.gca() #ax.set_xscale('log') pylab.legend(loc='upper right') pylab.savefig('azhist.eps')
def getsdssphotcats(self): #get photometric sources within 2R200 print "elapsed time = ",time.clock()-starttime self.mcut=N.zeros(len(self.z),'f') cl=N.arange(17,len(self.z),1) self.nphot=N.zeros(len(self.z),'f') self.nspec=N.zeros(len(self.z),'f') for i in range(len(self.z)): #for i in cl: dL = self.dL[i] print "getting phot cat for cluster abell",self.id[i] r200arcmin=self.r200deg[i]*60. #drsearch=2.*r200arcmin#2xR200 in arcmin for sdss query drsearch=1.*r200arcmin#2xR200 in arcmin for sdss query #Vg=0.3556-0.7614*((self.avegr)-0.6148)#(V-g) from Blanton et al 2003 mr=mabscut - 0.1331 + 5.*N.log10(dL)+25.+self.kcorr[i] print i, self.z[i], dL, mr self.mcut[i]=mr print "ra, dec, dr, mr = %12.8f %12.8f %8.3f %5.2f" % (self.ra[i],self.dec[i],drsearch,mr) #query="select g.ra, g.dec, g.u, g.g, g.r, g.i, g.z, g.plate_ID, g.MJD, from galaxy g, dbo.fGetNearbyObjEq(%12.8f,%12.8f,%8.3f) n where g.objID = n.objID and (g.g < %5.2f) and ((0.384*g.g + 0.716*g.r)< %5.2f)" % (self.ra[i],self.dec[i],drsearch,(mr+1.5),mr) query="select g.ra, g.dec, g.u, g.g, g.r, g.i, g.z, g.objid, g.specObjID,g.extinction_u, g.extinction_g, g.extinction_r, g.extinction_i, g.extinction_z from galaxy g, dbo.fGetNearbyObjEq(%12.8f,%12.8f,%8.3f) n where g.objID = n.objID and (g.g < %5.2f) and (g.PrimTarget & 0x00000040) > 0 " % (self.ra[i],self.dec[i],drsearch,(mr)) lines=sqlcl.query(query).readlines() #print query print "got number+1 phot objects = ",len(lines) #print lines self.nphot[i]=1.*len(lines) query="select g.ra, g.dec, g.u, g.g, g.r, g.i, g.z, g.objid, g.specObjID,g.extinction_u, g.extinction_g, g.extinction_r, g.extinction_i, g.extinction_z, l.ew, l.ewErr, l2.ew, l2.ewErr from galaxy g, specobj s, SpecLine l, SpecLine l2, dbo.fGetNearbyObjEq(%12.8f,%12.8f,%8.3f) n where g.objID = n.objID and g.objID = s.bestobjid and s.specobjID=l.specobjID and s.specobjID=l2.specobjID and (g.g < %5.2f) and (g.PrimTarget & 0x00000040) > 0 and l.LineID = 3727 and l2.LineID = 6565" % (self.ra[i],self.dec[i],drsearch,(mr)) lines=sqlcl.query(query).readlines() #print query print "got number+1 spec objects w/in R200= ",len(lines) #print lines self.nspec[i]=1.*len(lines) self.compl=self.nspec/self.nphot print "average completeness of sdss spectroscopy is = ",N.average(self.compl), pylab.std(self.compl)
def getsdssphotcats(self): #get photometric sources within 2R200 print "elapsed time = ", time.clock() - starttime self.mcut = N.zeros(len(self.z), 'f') cl = N.arange(17, len(self.z), 1) for i in range(len(self.z)): #for i in cl: dL = self.dL[i] print "getting phot cat for cluster abell", self.id[i] r200arcmin = self.r200deg[i] * 60. #drsearch=2.*r200arcmin#2xR200 in arcmin for sdss query drsearch = 3. * r200arcmin #2xR200 in arcmin for sdss query #Vg=0.3556-0.7614*((self.avegr)-0.6148)#(V-g) from Blanton et al 2003 mr = mabscut - 0.1331 + 5. * N.log10(dL) + 25. + self.kcorr[i] print i, self.z[i], dL, mr self.mcut[i] = mr print "ra, dec, dr, mr = %12.8f %12.8f %8.3f %5.2f" % ( self.ra[i], self.dec[i], drsearch, mr) #query="select g.ra, g.dec, g.u, g.g, g.r, g.i, g.z, g.plate_ID, g.MJD, from galaxy g, dbo.fGetNearbyObjEq(%12.8f,%12.8f,%8.3f) n where g.objID = n.objID and (g.g < %5.2f) and ((0.384*g.g + 0.716*g.r)< %5.2f)" % (self.ra[i],self.dec[i],drsearch,(mr+1.5),mr) query = "select g.ra, g.dec, g.u, g.g, g.r, g.i, g.z, g.objid, g.specObjID,g.extinction_u, g.extinction_g, g.extinction_r, g.extinction_i, g.extinction_z from galaxy g, dbo.fGetNearbyObjEq(%12.8f,%12.8f,%8.3f) n where g.objID = n.objID and (g.g < %5.2f) and (g.PrimTarget & 0x00000040) > 0 " % ( self.ra[i], self.dec[i], drsearch, (mr)) #line from sdssinter.py code #query="select n.distance from galaxy g, dbo.fGetNearbyObjEq(%12.8f,%12.8f,%8.3f) n where g.objID = n.objID and g.r< %5.2f and (g.PrimTarget & 0x00000040) > 0 order by distance" % (self.ra[i],self.dec[i],drsearch,mr)#added flags to get rid of saturated objects, stars, etc #query="select g.ra, g.dec, g.u, g.g, g.r, g.i, g.z from galaxy g, dbo.fGetNearbyObjEq(%12.8f,%12.8f,%8.3f) n where g.objID = n.objID" % (self.ra[i],self.dec[i],drsearch)#no mag cut #query="select g.ra, g.dec, g.u, g.g, g.r, g.i, g.z from galaxy g, dbo.fGetNearbyObjEq(%12.8f,%12.8f,%8.3f) n where g.objID = n.objID and g.r<17.7 and g.g<18.0" % (self.ra[i],self.dec[i],drsearch) lines = sqlcl.query(query).readlines() #print query print "got number+1 phot objects = ", len(lines) #print lines output = "abell" + str(self.id[i]) + ".phot.dat" outfile = open(output, 'w') outfile.write("#%s " % (lines[0])) for line in lines[1:]: outfile.write("%s " % (line)) outfile.close()
def mratiopg(): ppgplot.pgbeg("maccratio.ps/vcps",1,1) #color port. ppgplot.pgpap(8.,1.) ppgplot.pgpage ppgplot.pgsch(1.3) #font size ppgplot.pgslw(7) #line width # 1st panel with symbols w/ stddev errorbars #ylabel="SFR (M\d\(2281) \u yr\u-1\d)" ylabel="L(H\ga) (10\u41\d erg s\u-1\d)" xlabel="M\dr\u " x1=.15 x2=.5 x3=.5 x4=.85 y1=x1 y2=x2 y3=x3 y4=x4 emarker=18 smarker=23 xmin=N.log10(1.e14) xmax=N.log10(2.5e15) #ymin=-1. #ymax=3. ymin=0. ymax=25. ppgplot.pgsvp(x1,x4,y1,y4) #sets viewport ppgplot.pgswin(xmin,xmax,ymin,ymax) #axes limits ppgplot.pgbox('blncst',1.,2,'bcvnst',2.,2) #tickmarks and labeling for i in range(len(lz1lm.mass)): m=lz1lm.mass[i] l=lz1lm.maccret[i] h=hz1lm.maccret[i] r=h/l print i,m,l,h,r #print lz1lm.maccret #print hz1lm.maccret #print hz3lm.maccret r3lm=(hz3lm.maccret)/(lz3lm.maccret) r3hm=(hz3hm.maccret)/(lz3hm.maccret) #for i in range(len(r3)): # print i,lz3.sigma[i],hz3.sigma[i],lz3.mass[i],hz3.mass[i] # print i,lz01.sigma[i],hz01.sigma[i],lz01.mass[i],hz01.mass[i] r1lm=hz1lm.maccret/lz1lm.maccret r1hm=hz1hm.maccret/lz1hm.maccret #ra=N.array(hz01.maccret,'d') #rb=N.array(lz01.maccret,'d') #r01=ra/rb #for i in range(len(r01)): #print "ratio ",hz01.maccret[i],lz01.maccret[i],ra[i],rb[i],r01[i] ppgplot.pgsci(14) ppgplot.pgsls(1) ppgplot.pgline(N.log10(lz3lm.mass),r3lm) ppgplot.pgsls(2) ppgplot.pgline(N.log10(lz3hm.mass),r3hm) ppgplot.pgsci(1) ppgplot.pgsls(1) ppgplot.pgline(N.log10(lz1lm.mass),r1lm) ppgplot.pgsls(2) ppgplot.pgline(N.log10(lz1hm.mass),r1hm) xlabel='M\dcl\u (M\d\(2281)\u)' ylabel='M\dacc\u(z=0.75) / M\dacc\u(z=0.07)' ppgplot.pgsch(1.8) ppgplot.pgslw(7) ppgplot.pgmtxt('b',2.2,0.5,0.5,ylabel) #xlabel ppgplot.pgmtxt('l',2.5,0.5,0.5,xlabel) ppgplot.pgend()
def greadspecfiles(self, gphotfile, dL, kcorr, j): self.sra = [] self.sdec = [] self.su = [] self.sg = [] self.sr = [] self.sV = [] self.so2 = [] self.sha = [] for line in open(gphotfile): if line.find('#') > -1: continue if len(line) < 10: #phot files have blank line at end - skip it continue #print line fields = line.split(',') #print fields[0], fields[1] #need to implement a mag cut g = float(fields[3]) r = float(fields[4]) if (g > 18.0): continue if (r > 17.7): continue g01 = g + 0.3134 + 0.4608 * ((g - r) * -0.6148) g01 = g01 + .01 #convert to vega r01 = g - 0.4118 - .8597 * ((g - r) * -0.6148) r01 = r01 - .04 #convert to vega V = g01 - 0.6689 - 0.9264 * ((g01 - r01) - 0.7252) g = g - (-0.08) #convert to vega r = r - (.16) #convert to vega #g=g-float(fields[10])#correct for extinction #r=r-float(fields[11])#correct for extinction V = g - 0.3556 - 0.7614 * ((g - r) - 0.6148) #mv=V - (5.*N.log10(dL)+25.+kcorr) mv = V - (5. * N.log10(dL) + 25.) if ((mv) < mabscut): self.sra.append(float(fields[0])) self.sdec.append(float(fields[1])) self.su.append(float(fields[2])) self.sg.append(float(fields[3])) self.sr.append(float(fields[4])) self.sV.append(float(mv)) self.so2.append(float(fields[14])) #14-o2, 16 - Halpha self.sha.append(float(fields[16])) #14-o2, 16 - Halpha self.sra = N.array(self.sra, 'f') self.sdec = N.array(self.sdec, 'f') self.su = N.array(self.su, 'f') self.sg = N.array(self.sg, 'f') self.sr = N.array(self.sr, 'f') self.sV = N.array(self.sV, 'f') self.so2 = N.array(self.so2, 'f') self.sha = N.array(self.sha, 'f') self.sdistBCGR200 = N.sqrt((c.ra[j] - self.sra)**2 + (c.dec[j] - self.sdec)**2) / c.r200deg[j] self.smemb = N.zeros(len(self.sdistBCGR200), 'f') self.ssf = N.zeros(len(self.sdistBCGR200), 'f') self.stot = N.ones(len(self.sdistBCGR200), 'f') for i in range(len(self.smemb)): if (self.sdistBCGR200[i] < 4): self.smemb[i] = 1. if (self.so2[i] > 4.): self.ssf[i] = 1. if (self.so2[i] < -50.): self.smemb[i] = 0.
def stellarmr(self): pylab.cla() x=N.compress((self.mpaflag > 0.1),self.Mabs) y=N.compress((self.mpaflag > 0.1),self.stellarmass) print "len x,y,Mabs = ",len(x),len(y),len(self.Mabs) #x=[] #y=[] #for i in range(len(self.Mabs)): # if self.mpaflag[i] > 0.1: # x.append(self.Mabs[i]) # y.append(self.stellarmass[i]) #print "len x,y,Mabs =",len(x),len(y),len(self.Mabs) #x=N.array(x,'d') #y=N.array(y,'d') y=N.log10(y/1.e11) xmin=-24. xmax=-18. ymin=-3. ymax=2. #my.contour(x,y,xmin,xmax,ymin,ymax) #pylab.plot(x,y,'k.',markersize=.01,zorder=1) pylab.xlabel(r'$\rm{M_r}$',fontsize=28.) pylab.ylabel(r'$\rm{log_{10}(M_* / 10^{11} \ M_\odot)}$',fontsize=28.) #(a,b)=fitpowerlaw(x,y) xtrans=-21.5 b=-13.8 m=-.63 xl=N.arange(xtrans,-18.,.05) xl=N.array(xl,'f') yl=N.zeros(len(xl),'f') yl=m*(xl)+b #xl=-1.*xl #print xl #print yl pylab.plot(xl,yl,'b-',lw=4,label='_nolegend_') m2=-.47 b2=(m-m2)*xtrans+b print "b2 = ",b2 xl=N.arange(-24.,(xtrans+.05),.05) xl=N.array(xl,'f') yl=N.zeros(len(xl),'f') yl=m2*(xl)+b2 #xl=-1.*xl #print xl #print yl pylab.plot(xl,yl,'c-',lw=4,label='_nolegend_') pylab.axvline(x=-20.6,linewidth=3,ls='--',c='g') #(xbin,ybin,ybinerr)=my.binitbinsfix(xl,(xl+0.5),x,y) #pylab.plot(xbin,ybin,'b-',linewidth=4.) pylab.hold() my.contourf(x,y,xmin,xmax,ymin,ymax) ax=pylab.gca() #ax.set_yscale('log') pylab.axis([-24.5,-17.5,-3.,1.2]) pylab.savefig('stellarmr.eps')
def gotoit(): nbin = 10 #c=Cluster() #g=Galaxy() clusterfile = "clusters.spec.dat" print "reading in cluster file to get cluster parameters" c.creadfiles(clusterfile) print "got ", len(c.z), " clusters" c.convarray() c.Kcorr() go2 = [] #combined arrays containing all galaxies gsf = [] #combined arrays containing all galaxies gsig5 = [] gsig10 = [] gsig52r200 = [] #spec catalogs extended out to 2xR200 gsig102r200 = [] #spec catalogs extended out to 2xR200 gsig5phot = [] gsig10phot = [] sgo2 = [] #combined arrays containing all galaxies sgha = [] #combined arrays containing all galaxies sgsf = [] #combined arrays containing all galaxies sgsig5 = [] sgsig10 = [] sgsig52r200 = [] #spec catalogs extended out to 2xR200 sgsig102r200 = [] #spec catalogs extended out to 2xR200 sgsig5phot = [] sgsig10phot = [] if (mode < 1): c.getsdssphotcats() c.getsdssspeccats() gr = [] #list of median g-r colors psplotinit('summary.ps') x1 = .1 x2 = .45 x3 = .6 x4 = .95 y1 = .15 y2 = .45 y3 = .55 y4 = .85 ppgplot.pgsch(1.2) #font size ppgplot.pgslw(2) #for i in range(len(c.z)): cl = [10] (xl, xu, yl, yu) = ppgplot.pgqvp(0) print "viewport = ", xl, xu, yl, yu complall = [] for i in range(len(c.z)): #for i in cl: gname = "g" + str(i) gname = Galaxy() gspecfile = "abell" + str(c.id[i]) + ".spec.dat" gname.greadfiles(gspecfile, i) print "number of members = ", len(gname.z) if len(gname.z) < 10: print "less than 10 members", len(gname.z) continue gname.convarray() #gname.cullmembers() #gname.getmemb()#get members w/in R200 #gr.append(N.average(gname.g-gname.r)) gspec2r200file = "abell" + str(c.id[i]) + ".spec2r200.dat" gname.greadspecfiles(gspec2r200file, c.dL[i], c.kcorr[i], i) print i, c.id[i], " getnearest, first call", len(gname.ra), len( gname.sra), sum(gname.smemb) #gname.getnearest(i) (gname.sig52r200, gname.sig102r200) = gname.getnearestgen( gname.ra, gname.dec, gname.sra, gname.sdec, i ) #measure distances from ra1, dec1 to members in catalog ra2, dec2 sig52r200 = N.compress(gname.memb > 0, gname.sig52r200) gsig52r200[len(gsig5phot):] = sig52r200 sig102r200 = N.compress(gname.memb > 0, gname.sig102r200) gsig102r200[len(gsig10phot):] = sig102r200 gphotfile = "abell" + str(c.id[i]) + ".phot.dat" gname.greadphotfiles(gphotfile, c.dL[i], c.kcorr[i]) gname.getnearest(i) #print "len of local density arrays = ",len(gname.sig5),len(gname.sig5phot) #print gspecfile, c.z[i],c.kcorr[i] (ds5, ds10) = gname.gwritefiles(gspecfile, i) o2 = N.compress(gname.memb > 0, gname.o2) go2[len(go2):] = o2 sf = N.compress(gname.memb > 0, gname.sf) gsf[len(gsf):] = sf sig5 = N.compress(gname.memb > 0, gname.sig5) gsig5[len(gsig5):] = sig5 sig10 = N.compress(gname.memb > 0, gname.sig10) gsig10[len(gsig10):] = sig10 sig5phot = N.compress(gname.memb > 0, gname.sig5phot) gsig5phot[len(gsig5phot):] = sig5phot sig10phot = N.compress(gname.memb > 0, gname.sig10phot) gsig10phot[len(gsig10phot):] = sig10phot ds5 = N.array(ds5, 'f') ds10 = N.array(ds10, 'f') #print len(ds5),len(ds10) #ppgplot.pgsvp(xl,xu,yl,yu) ppgplot.pgsvp(0.1, .9, .08, .92) ppgplot.pgslw(7) label = 'Abell ' + str( c.id[i]) + ' (z=%5.2f, \gs=%3.0f km/s)' % (c.z[i], c.sigma[i]) ppgplot.pgtext(0., 1., label) ppgplot.pgslw(2) ppgplot.pgsvp(x1, x2, y1, y2) #sets viewport #ppgplot.pgbox("",0.0,0,"",0.0) ppgplot.pgswin(-1., 3., -1., 3.) #axes limits ppgplot.pgbox('bcnst', 1, 2, 'bcvnst', 1, 2) #tickmarks and labeling ppgplot.pgmtxt('b', 2.5, 0.5, 0.5, "\gS\d10\u(phot) (gal/Mpc\u2\d)") #xlabel ppgplot.pgmtxt('l', 2.6, 0.5, 0.5, "\gS\d10\u(spec) (gal/Mpc\u2\d)") x = N.arange(-5., 10., .1) y = x ppgplot.pgsls(1) #dotted ppgplot.pgslw(4) #line width ppgplot.pgline(x, y) x = N.log10(sig10phot) y = N.log10(sig10) ppgplot.pgsch(.7) ppgplot.pgpt(x, y, 17) xp = N.array([-0.5], 'f') yp = N.array([2.5], 'f') ppgplot.pgpt(xp, yp, 17) ppgplot.pgtext((xp + .1), yp, 'spec(1.2xR200) vs phot') ppgplot.pgsci(4) xp = N.array([-0.5], 'f') yp = N.array([2.2], 'f') ppgplot.pgpt(xp, yp, 21) ppgplot.pgtext((xp + .1), yp, 'spec(2xR200) vs phot') y = N.log10(sig102r200) ppgplot.pgsch(.9) ppgplot.pgpt(x, y, 21) ppgplot.pgsch(1.2) ppgplot.pgslw(2) #line width ppgplot.pgsci(1) #ppgplot.pgenv(-200.,200.,-1.,20.,0,0) #ppgplot.pgsci(2) #ppgplot.pghist(len(ds5),ds5,-200.,200.,30,1) #ppgplot.pgsci(4) #ppgplot.pghist(len(ds10),ds10,-200.,200.,30,1) #ppgplot.pgsci(1) #ppgplot.pglab("\gD\gS","Ngal",gspecfile) #ppgplot.pgpanl(1,2) g = N.compress(gname.memb > 0, gname.g) r = N.compress(gname.memb > 0, gname.r) V = N.compress(gname.memb > 0, gname.V) dmag = N.compress(gname.memb > 0, gname.dmagnearest) dnearest = N.compress(gname.memb > 0, gname.nearest) dz = N.compress(gname.memb > 0, gname.dz) #ppgplot.pgsvp(x3,x4,y1,y2) #sets viewport #ppgplot.pgenv(-.5,3.,-1.,5.,0,0) #ppgplot.pgpt((g-V),(g-r),17) #ppgplot.pgsci(1) #ppgplot.pglab("g - M\dV\u",'g-r',gspecfile) ppgplot.pgsvp(x1, x2, y3, y4) #sets viewport #ppgplot.pgbox("",0.0,0,"",0.0) ppgplot.pgswin( (c.ra[i] + 2. * c.r200deg[i] / N.cos(c.dec[i] * N.pi / 180.)), (c.ra[i] - 2 * c.r200deg[i] / N.cos(c.dec[i] * N.pi / 180.)), (c.dec[i] - 2. * c.r200deg[i]), (c.dec[i] + 2. * c.r200deg[i])) ppgplot.pgbox('bcnst', 0.0, 0.0, 'bcvnst', 0.0, 0.0) #tickmarks and labeling ppgplot.pgmtxt('b', 2.5, 0.5, 0.5, "RA") #xlabel ppgplot.pgmtxt('l', 2.6, 0.5, 0.5, "Dec") #ppgplot.pglab("RA",'Dec',gspecfile) ppgplot.pgsfs(2) ppgplot.pgcirc(c.ra[i], c.dec[i], c.r200deg[i]) ppgplot.pgsls(4) ppgplot.pgcirc(c.ra[i], c.dec[i], 1.2 * c.r200deg[i]) ppgplot.pgsls(1) #ppgplot.pgcirc(c.ra[i],c.dec[i],c.r200deg[i]/N.cos(c.dec[i]*N.pi/180.)) ppgplot.pgsci(2) ppgplot.pgpt(gname.ra, gname.dec, 17) ppgplot.pgsci(4) ppgplot.pgpt(gname.photra, gname.photdec, 21) ppgplot.pgsci(1) #calculate completeness w/in R200 dspec = N.sqrt((gname.ra - c.ra[i])**2 + (gname.dec - c.dec[i])**2) dphot = N.sqrt((gname.photra - c.ra[i])**2 + (gname.photdec - c.dec[i])**2) nphot = 1. * len(N.compress(dphot < c.r200deg[i], dphot)) nspec = 1. * len(N.compress(dspec < c.r200deg[i], dspec)) s = "Completeness for cluster Abell %s = %6.2f (nspec=%6.1f,nphot= %6.1f)" % ( str(c.id[i]), float(nspec / nphot), nspec, nphot) print s complall.append(float(nspec / nphot)) ppgplot.pgsvp(x3, x4, y3, y4) #sets viewport #ppgplot.pgsvp(x1,x2,y3,y4) #sets viewport #ppgplot.pgbox("",0.0,0,"",0.0) ppgplot.pgswin(-0.005, .05, -1., 1.) ppgplot.pgbox('bcnst', .02, 2, 'bcvnst', 1, 4) #tickmarks and labeling ppgplot.pgsch(1.0) ppgplot.pgmtxt('b', 2.5, 0.5, 0.5, "Dist to nearest phot neighbor (deg)") #xlabel ppgplot.pgsch(1.2) ppgplot.pgmtxt('l', 2.6, 0.5, 0.5, 'M\dV\u(phot) - M\dV\u(spec)') ppgplot.pgsci(2) ppgplot.pgpt(dnearest, dmag, 17) ppgplot.pgsci(1) x = N.arange(-30., 30., 1.) y = 0 * x ppgplot.pgsci(1) ppgplot.pgsls(2) ppgplot.pgline(x, y) ppgplot.pgsls(1) ppgplot.pgsci(1) dm = N.compress(dnearest < 0.01, dmag) std = '%5.3f (%5.3f)' % (pylab.mean(dm), pylab.std(dm)) #ppgplot.pgslw(7) #label='Abell '+str(c.id[i]) #ppgplot.pgtext(0.,1.,label) ppgplot.pgslw(2) label = '\gDM\dV\u(err) = ' + std ppgplot.pgsch(.9) ppgplot.pgtext(0., .8, label) #label = "z = %5.2f"%(c.z[i]) #ppgplot.pgtext(0.,.8,label) ppgplot.pgsch(1.2) #ppgplot.pgsvp(x3,x4,y3,y4) #sets viewport #ppgplot.pgenv(-.15,.15,-3.,3.,0,0) #ppgplot.pgsci(2) #ppgplot.pgpt(dz,dmag,17) #ppgplot.pgsci(1) #ppgplot.pglab("z-z\dcl\u",'\gD Mag',gspecfile) ppgplot.pgsvp(x3, x4, y1, y2) #sets viewport ppgplot.pgswin(-3., 3., -1., 1.) ppgplot.pgbox('bcnst', 1, 2, 'bcvnst', 1, 4) #tickmarks and labeling ppgplot.pgmtxt('b', 2.5, 0.5, 0.5, "\gDv/\gs") #xlabel ppgplot.pgmtxt('l', 2.6, 0.5, 0.5, 'M\dV\u(phot) - M\dV\u(spec)') ppgplot.pgsci(2) dv = dz / (1 + c.z[i]) * 3.e5 / c.sigma[i] ppgplot.pgpt(dv, dmag, 17) ppgplot.pgsci(1) x = N.arange(-30., 30., 1.) y = 0 * x ppgplot.pgsci(1) ppgplot.pgsls(2) ppgplot.pgline(x, y) ppgplot.pgsls(1) ppgplot.pgsci(1) #ppgplot.pgsvp(x1,x2,y1,y2) #sets viewport #ppgplot.pgenv(0.,3.5,-3.,3.,0,0) #ppgplot.pgsci(4) #ppgplot.pgpt((g-r),dmag,17) #ppgplot.pgsci(1) #ppgplot.pglab("g-r",'\gD Mag',gspecfile) #ppgplot.pgsvp(x1,x2,y1,y2) #sets viewport #ppgplot.pgenv(-25.,-18.,-1.,1.,0,0) #ppgplot.pgsci(4) #ppgplot.pgpt((V),dmag,17) #x=N.arange(-30.,30.,1.) #y=0*x #ppgplot.pgsci(1) #ppgplot.pgsls(2) #ppgplot.pgline(x,y) #ppgplot.pgsls(1) #ppgplot.pgsci(1) #ppgplot.pglab("M\dV\u(spec)",'M\dV\u(phot) - M\dV\u(spec)',gspecfile) #ppgplot.pgpage() #ppgplot.pgpage() #combine galaxy data ppgplot.pgpage() (sssig5, sssig10) = gname.getnearestgen(gname.sra, gname.sdec, gname.sra, gname.sdec, i) #get spec-spec local density (spsig5, spsig10) = gname.getnearestgen(gname.sra, gname.sdec, gname.photra, gname.photdec, i) #get spec-phot local density o2 = N.compress(gname.smemb > 0, gname.so2) sgo2[len(sgo2):] = o2 ha = N.compress(gname.smemb > 0, gname.sha) sgha[len(sgha):] = ha sf = N.compress(gname.smemb > 0, gname.ssf) sgsf[len(sgsf):] = sf sig5 = N.compress(gname.smemb > 0, sssig5) sgsig5[len(sgsig5):] = sig5 sig10 = N.compress(gname.smemb > 0, sssig10) sgsig10[len(sgsig10):] = sig10 sig5phot = N.compress(gname.smemb > 0, spsig5) sgsig5phot[len(sgsig5phot):] = sig5phot sig10phot = N.compress(gname.smemb > 0, spsig10) sgsig10phot[len(sgsig10phot):] = sig10phot #gr=N.array(gr,'f') #c.assigncolor(gr) #for i in range(len(c.z)): # print c.id[i],c.z[i],c.r200[i],c.r200deg[i] print "Average Completeness w/in R200 = ", N.average(N.array( complall, 'f')) print "sig o2", len(gsig10), len(gsig10phot), len(go2) print "sig o2 large", len(sgsig10), len(sgsig10phot), len(sgo2) plotsigo2all(gsig10, gsig10phot, go2, 'o2vsig10spec', nbin) #plotsigo2(gsig5phot,-1*go2,'o2vsig5phot',nbin) plotsigsff(gsig5, gsf, 'sffvsig5spec', nbin) #sf frac versus sigma plotsigsff(gsig5phot, gsf, 'sffvsig5phot', nbin) #sf frac versus sigma plotsigsffall(gsig5, gsig5phot, gsf, 'sffvsig5all', nbin) #sf frac versus sigma plotsig10sffall(gsig10, gsig10phot, gsf, 'sffvsig10all', nbin) #sf frac versus sigma #plotsighaall(gsig10,gsig10phot,gha,'havsig10spec',20) #plotsigo2all(sgsig10,sgsig10phot,sgo2,'o2vsig10spec.large',30) plotsighaall(sgsig10, sgsig10phot, sgha, 'havsig10spec.large', 10) #plotsigsffall(sgsig5,sgsig5phot,sgsf,'sffvsig5.large',nbin)#sf frac versus sigma #plotsig10sffall(sgsig10,sgsig10phot,sgsf,'sffvsig10.large',nbin)#sf frac versus sigma psplotinit('one2one.ps') ppgplot.pgenv(-1.5, 2.5, -1.5, 2.5, 0) ppgplot.pglab("\gS\d10\u(phot) (gal/Mpc\u2\d)", "\gS\d10\u(spec) (gal/Mpc\u2\d)", "") x = N.arange(-5., 10., .1) y = x ppgplot.pgsls(1) #dotted ppgplot.pgslw(4) #line width ppgplot.pgline(x, y) x = N.log10(gsig10phot) y = N.log10(gsig10) ppgplot.pgsch(.7) ppgplot.pgpt(x, y, 17) ppgplot.pgsch(1.) ppgplot.pgsci(1) ppgplot.pgend()