コード例 #1
0
def plotCircles(objectTable, margins):
    margins = checkMargins(margins)
    ppgplot.pgsci(3)
    ppgplot.pgsfs(2)
    index = 0
    print ("Margins:", margins)
    for obj in objectTable:
        ra = obj["ra"]
        dec = obj["dec"]
        c = obj["class"]
        if ra > margins[1][0] and ra < margins[0][0] and dec < margins[0][1] and dec > margins[1][1]:
            # print index, ra, dec, x, y, c
            index += 1
            colour = 1
            if c == -9:
                colour = 2  # Red  = Saturated
            if c == 1:
                colour = 4  # Blue   = Galaxy
            if c == -3:
                colour = 5  # Cyan   = Probable Galaxy
            if c == -1:
                colour = 3  # Green = Star
            if c == -2:
                colour = 8  # Orange = Probable Star
            if c == 0:
                colour = 2  # Red    = Noise
            ppgplot.pgsci(colour)
            ppgplot.pgcirc(obj["x"], obj["y"], 5 + (5 * obj["pStar"]))
    return index + 1
コード例 #2
0
def redraw():
    ppgplot.pgslct(imagePlot['pgplotHandle'])
    ppgplot.pgslw(3)
    ppgplot.pggray(boostedImage, xlimits[0], xlimits[1] - 1, ylimits[0],
                   ylimits[1] - 1, imageMinMax[0], imageMinMax[1],
                   imagePlot['pgPlotTransform'])
    if plotSources: plotCircles(dr2Objects, margins)
    if plotHa:
        reduceddr2cat = []
        for selected in extendedHaSources:
            reduceddr2cat.append(dr2Objects[selected])
        plotCircles(reduceddr2cat, margins)
    if plotGrid:
        print("Plotting grid")
        ppgplot.pgsci(6)
        xVals = [p[0] for p in pixelGrid]
        yVals = [p[1] for p in pixelGrid]
        ppgplot.pgpt(xVals, yVals, 2)
    if plotPointings:

        ppgplot.pgsfs(2)
        ppgplot.pgslw(10)
        for p in pointings:
            if p['type'] == "Maximum": ppgplot.pgsci(2)
            if p['type'] == "Minimum": ppgplot.pgsci(4)
            ppgplot.pgcirc(p['x'], p['y'], 30)
        ppgplot.pgslw(1)
    if plotBrightStars:
        ppgplot.pgsci(3)
        ppgplot.pgsfs(2)
        ppgplot.pgslw(10)
        for b in brightStars:
            ppgplot.pgcirc(b['x'], b['y'], 40)
コード例 #3
0
def plotgal(xg,yg,final,finalsf,ncl):
    ppgplot.pgslw(6)
    ppgplot.pgsls(1)

    xmin = (-1.*c.pscale[ncl]*(c.xc[ncl]-1))
    xmax = (c.pscale[ncl]*(c.xmax[ncl]-c.xc[ncl]))    
    ymin = (-1.*c.pscale[ncl]*(c.yc[ncl]-1))
    ymax = (c.pscale[ncl]*(c.ymax[ncl]-c.yc[ncl]))
    ppgplot.pgbox("",0.0,0,"L",0.0,0)

    dx=5.
    ppgplot.pgenv(xmin-dx,xmax+dx,ymin-dx,ymax+dx,0)
    ppgplot.pglab("\gD DEC (\")","\gD RA (\")","")
    ppgplot.pgtext(-4,-4,"X")
    r = (0.5*c.r200pix[ncl]*c.pscale[ncl])
    ppgplot.pgslw(1)
    ppgplot.pgsls(2)
    ppgplot.pgsfs(2)
    ppgplot.pgcirc(0,0,r)
    #print "cluster ",ncl," r200: ",c.r200pix[ncl],c.r200Mpc[ncl], " Mpc"

    ppgplot.pgslw(3)
    ppgplot.pgsls(1)

    x = (xg - c.xc[ncl])*c.pscale[ncl]
    y = (yg - c.yc[ncl])*c.pscale[ncl]
    x = (N.compress((final > 0) & (finalsf < 1), xg) - c.xc[ncl])*c.pscale[ncl]
    y = (N.compress((final > 0) & (finalsf < 1), yg) - c.yc[ncl])*c.pscale[ncl]
    ppgplot.pgpt(x,y,22)
    x = (N.compress((final > 0) & (finalsf > 0), xg) - c.xc[ncl])*c.pscale[ncl]
    y = (N.compress((final > 0) & (finalsf > 0), yg) - c.yc[ncl])*c.pscale[ncl]
    ppgplot.pgpt(x,y,18)
コード例 #4
0
def redraw():
    ppgplot.pgslct(imagePlot["pgplotHandle"])
    ppgplot.pgslw(3)
    ppgplot.pggray(
        boostedImage,
        xlimits[0],
        xlimits[1] - 1,
        ylimits[0],
        ylimits[1] - 1,
        imageMinMax[0],
        imageMinMax[1],
        imagePlot["pgPlotTransform"],
    )
    if plotSources:
        plotCircles(dr2Objects, margins)
    if plotHa:
        reduceddr2cat = []
        for selected in extendedHaSources:
            reduceddr2cat.append(dr2Objects[selected])
        plotCircles(reduceddr2cat, margins)
    if plotGrid:
        print ("Plotting grid")
        ppgplot.pgsci(6)
        xVals = [p[0] for p in pixelGrid]
        yVals = [p[1] for p in pixelGrid]
        ppgplot.pgpt(xVals, yVals, 2)
    if plotPointings:

        ppgplot.pgsfs(2)
        ppgplot.pgslw(10)
        for p in pointings:
            if p["type"] == "Maximum":
                ppgplot.pgsci(2)
            if p["type"] == "Minimum":
                ppgplot.pgsci(4)
            ppgplot.pgcirc(p["x"], p["y"], 30)
        ppgplot.pgslw(1)
    if plotBrightStars:
        ppgplot.pgsci(3)
        ppgplot.pgsfs(2)
        ppgplot.pgslw(10)
        for b in brightStars:
            ppgplot.pgcirc(b["x"], b["y"], 40)
コード例 #5
0
def plotCircles(objectTable, margins):
    margins = checkMargins(margins)
    ppgplot.pgsci(3)
    ppgplot.pgsfs(2)
    index = 0
    print("Margins:", margins)
    for obj in objectTable:
        ra = obj['ra']
        dec = obj['dec']
        c = obj['class']
        if ra > margins[1][0] and ra < margins[0][0] and dec < margins[0][
                1] and dec > margins[1][1]:
            # print index, ra, dec, x, y, c
            index += 1
            colour = 1
            if c == -9: colour = 2  # Red  = Saturated
            if c == 1: colour = 4  # Blue   = Galaxy
            if c == -3: colour = 5  # Cyan   = Probable Galaxy
            if c == -1: colour = 3  # Green = Star
            if c == -2: colour = 8  # Orange = Probable Star
            if c == 0: colour = 2  # Red    = Noise
            ppgplot.pgsci(colour)
            ppgplot.pgcirc(obj['x'], obj['y'], 5 + (5 * obj['pStar']))
    return (index + 1)
コード例 #6
0
				xll = w.xll/w.xbin - xmin
				xsize = w.nx
				yll = w.yll/w.ybin - ymin
				ysize = w.ny
				fullFrame[yll:yll+ysize, xll:xll+xsize] = fullFrame[yll:yll+ysize, xll:xll+xsize] + boostedImage		
			
			rows, cols  = numpy.shape(fullFrame)
			
			# Draw the grayscale bitmap
			ppgplot.pggray(fullFrame, 0, cols-1 , 0, rows-1 , 0, 255, pgPlotTransform)
	
			# Draw the full reference aperture list
			ppgplot.pgsci(3)
			for s in sourceList.getSources():
				(x, y) = s.abs_position
				ppgplot.pgcirc(x, y, 10)
		
			# ppgplot.pgslct(bitmapView)
			ppgplot.pgsci(2)

				
		for index, s in enumerate(referenceApertures.getSources()):
			window = allWindows[s.windowIndex]
			center = s.latestPosition
			if s.recentFail:
				print "Recent fail... will try a position at least 5 frames back"
				positions = s.positionLog
				if len(positions)>5:
					center = positions[-5]['position']
				print "Using position:", center
			xcenterInt = int(center[0])
コード例 #7
0
                sra, sdec, m.az, m.alt, m.q, 3.0 * m.w, 2.0 * m.w)
            text = text + "L: %d; O: %s; m < %.1f; C: %s; l: %.0f s" % (
                m.level, m.orientation, m.maxmag, m.camera, m.length)
            ppgplot.pgmtxt("B", 1.0, 0.0, 0.0, text)
            ppgplot.pgsch(1.0)

            # Plot stars
            c = s.mag < m.maxmag
            aa = s.p[c].transform_to(AltAz(location=m.loc, obstime=m.t))
            mag = s.mag[c]
            rad = (m.maxrad + (m.minrad - m.maxrad) * (mag - m.minmag) /
                   (m.maxmag - m.minmag)) * m.w / 90.0
            rx, ry = forward(m.az, m.alt, aa.az.deg, aa.alt.deg)
            for i in range(len(rad)):
                ppgplot.pgsci(0)
                ppgplot.pgcirc(rx[i], ry[i], 1.3 * rad[i])
                ppgplot.pgsci(1)
                ppgplot.pgcirc(rx[i], ry[i], rad[i])

            # Plot grid
            m.plot_horizontal_grid()

            # Reset redraw
            redraw = False

        # Get cursor
        x, y, char = ppgplot.pgcurs()

        print(x, y, char)

        # Quit
コード例 #8
0
     % (position[1], position[0], superMax, superMin, variance,
        variance / numPixels))
 ppgplot.pgslct(spPreview['pgplotHandle'])
 boostedPreview = generalUtils.percentiles(superPixel, 20, 99)
 ppgplot.pggray(boostedPreview, 0, superPixelSize - 1, 0,
                superPixelSize - 1, 0, 255,
                imagePlot['pgPlotTransform'])
 ppgplot.pgsci(0)
 ppgplot.pgsch(5)
 ppgplot.pgtext(1, 2, "max: %d" % superMax)
 ppgplot.pgslct(imagePlot['pgplotHandle'])
 pointingObject = {'x': position[1], 'y': position[0]}
 pointings.append(pointingObject)
 ppgplot.pgsfs(2)
 ppgplot.pgsci(5)
 ppgplot.pgcirc(position[1], position[0], radius)
 xpts = [
     startX, startX, startX + superPixelSize,
     startX + superPixelSize
 ]
 ypts = [
     startY, startY + superPixelSize, startY + superPixelSize,
     startY
 ]
 ppgplot.pgsfs(2)
 ppgplot.pgsci(4)
 ppgplot.pgpoly(xpts, ypts)
 tempBitmap = numpy.zeros(numpy.shape(imageCopy))
 tempBitmap = gridCircle(position[0], position[1], radius,
                         tempBitmap)
 additionalMask = numpy.ma.make_mask(tempBitmap)
コード例 #9
0
		image = matplotlib.pyplot.imshow(boostedFullFrame, cmap='gray_r')
		for s in allSources:
			x, y = s[0], s[1]
			matplotlib.pyplot.gca().add_artist(matplotlib.pyplot.Circle((x,y), 10, color='green', fill=False, linewidth=1.0))
		if applyShift:
			for s in topSources:
				x, y = s[0], s[1]
				matplotlib.pyplot.gca().add_artist(matplotlib.pyplot.Circle((x,y), 10, color='blue', fill=False, linewidth=1.0))
		
		rows, cols = numpy.shape(boostedFullFrame)
		ppgplot.pggray(boostedFullFrame, 0, cols-1, 0, rows-1, 0, 255, pgPlotTransform)
		ppgplot.pgsfs(2)   # Set fill style to 'outline'
		ppgplot.pgsci(3)   # Set the colour to 'green'
		for s in allSources:
			x, y = s[0], s[1]
			ppgplot.pgcirc(x,y, 10)
		
		
	""" End of the prework """

	rdat.set(1)		# Reset back to the first frame
	
	frameRange = maximumFrames - startFrame + 1
	
	if arg.numframes!=None:
		requestedNumFrames = arg.numframes
		if requestedNumFrames<(frameRange):
			frameRange = requestedNumFrames
	
	startTime = datetime.datetime.now()
	timeLeftString = "??:??"
コード例 #10
0
                    % (position[1], position[0], superMax, superMin, variance, variance / numPixels)
                )
                ppgplot.pgslct(spPreview["pgplotHandle"])
                boostedPreview = generalUtils.percentiles(superPixel, 20, 99)
                ppgplot.pggray(
                    boostedPreview, 0, superPixelSize - 1, 0, superPixelSize - 1, 0, 255, imagePlot["pgPlotTransform"]
                )
                ppgplot.pgsci(0)
                ppgplot.pgsch(5)
                ppgplot.pgtext(1, 2, "max: %d" % superMax)
                ppgplot.pgslct(imagePlot["pgplotHandle"])
                pointingObject = {"x": position[1], "y": position[0]}
                pointings.append(pointingObject)
                ppgplot.pgsfs(2)
                ppgplot.pgsci(5)
                ppgplot.pgcirc(position[1], position[0], radius)
                xpts = [startX, startX, startX + superPixelSize, startX + superPixelSize]
                ypts = [startY, startY + superPixelSize, startY + superPixelSize, startY]
                ppgplot.pgsfs(2)
                ppgplot.pgsci(4)
                ppgplot.pgpoly(xpts, ypts)
                tempBitmap = numpy.zeros(numpy.shape(imageCopy))
                tempBitmap = gridCircle(position[0], position[1], radius, tempBitmap)
                additionalMask = numpy.ma.make_mask(tempBitmap)
                booleanMask = numpy.ma.mask_or(booleanMask, additionalMask)

                maskedImageCopy = numpy.ma.masked_array(imageCopy, booleanMask)
                print "Number of masked elements", numpy.ma.count_masked(maskedImageCopy)
                print "Number of non-masked elements", numpy.ma.count(maskedImageCopy)
                # imageCopy = numpy.ma.filled(maskedImageCopy, 0)
                # time.sleep(1)
コード例 #11
0
ファイル: ediscslocal.py プロジェクト: rfinn/pythonCode
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()