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
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)
Exemple #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)
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)
Exemple #5
0
    def startPlotter(self):
        if self.plotDeviceIsOpened:
            raise ValueError("You already started a plot!")

        devId = pgplot.pgopen(self.deviceName)
        self.plotDeviceIsOpened = True

        if not self.widthInches is None:
            pgplot.pgpap(self.widthInches, self.yOnXRatio)

        # For devices /xs, /xw, /png etc, should make the paper white and the ink black. Only for /ps does pgplot default to that.
        #
        deviceWithoutFile = self.deviceName.split('/')[-1]
        if deviceWithoutFile == 'xs' or deviceWithoutFile == 'xw' or deviceWithoutFile == 'png':
            pgplot.pgscr(0, 1.0, 1.0, 1.0)
            pgplot.pgscr(1, 0.0, 0.0, 0.0)

        pgplot.pgsvp(self._vXLo, self._vXHi, self._vYLo, self._vYHi)

        if self.fixAspect:
            pgplot.pgwnad(self.worldXLo, self.worldXHi, self.worldYLo,
                          self.worldYHi)
        else:
            pgplot.pgswin(self.worldXLo, self.worldXHi, self.worldYLo,
                          self.worldYHi)
        pgplot.pgsfs(2)

        pgplot.pgslw(1)
        pgplot.pgsch(self._charHeight)

        self._setColourRepresentations()

        # Set up things so calling pgplot.pggray() won't overwrite the CR of any of the colours in self.colours.
        #
        (minCI, maxCI) = pgplot.pgqcir()
        if minCI <= self.maxCI:
            pgplot.pgscir(self.maxCI + 1, maxCI)

        (xLoPixels, xHiPixels, yLoPixels, yHiPixels) = pgplot.pgqvsz(3)
        (xLoInches, xHiInches, yLoInches, yHiInches) = pgplot.pgqvsz(1)
        self.xPixelWorld = (xHiInches - xLoInches) / (xHiPixels - xLoPixels)
        self.yPixelWorld = (yHiInches - yLoInches) / (yHiPixels - yLoPixels)
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)
		ppgplot.pgbox('A', 0.0, 0, 'BCG', 0.0, 0)
		ppgplot.pglab("", "%d"%panel, "")
		ppgplot.pgsch(currentSize)
	
	ppgplot.pgask(False)
	ppgplot.pgsci(1)
	
	
	if (arg.preview):		
		bitmapView = {}
		bitmapView['pgplotHandle'] = ppgplot.pgopen('/xs')
		ppgplot.pgpap(8, 1)
		
		ppgplot.pgenv(0.,fullFramexsize,0.,fullFrameysize, 1, 0)
		pgPlotTransform = [0, 1, 0, 0, 0, 1]
		ppgplot.pgsfs(2)
	
	if (arg.watch!=None) and (arg.watch<numReferenceApertures):
		watch = arg.watch
		watchView = {}
		watchView['pgplotHandle'] = ppgplot.pgopen('/xs')
		ppgplot.pgpap(10, 1)
		ppgplot.pgsvp(0.1, 0.7, 0.3, 0.9)
		ppgplot.pgswin(-margins, margins, -margins, margins)
		# ppgplot.pgenv(-margins, margins, -margins, margins, 1, 0)
		# ppgplot.pgenv(-margins, margins, 0, 10, 0, 0)
		watchView['pgPlotTransform'] = [-11, 1, 0, -11, 0, 1]
	else:
		watch=-1
	
	""" End of PGPLOT set up """
Exemple #8
0
                ppgplot.pgscr(0, 0.0, 0.0, 0.2)
            elif m.sunalt > -18.0:
                ppgplot.pgscr(0, 0.0, 0.0, 0.1)
            else:
                ppgplot.pgscr(0, 0.0, 0.0, 0.0)
            ppgplot.pgsci(0)

            # Plot box
            ppgplot.pgrect(-1.5 * m.w, 1.5 * m.w, -m.w, m.w)
            ppgplot.pgsci(1)
            ppgplot.pgsch(1.0)
            ppgplot.pgbox("BC", 0., 0, "BC", 0., 0)
            ppgplot.pgpt1(0., 0., 2)

            # Plot field-of-view
            ppgplot.pgsfs(2)
            ppgplot.pgrect(-m.fw, m.fw, -m.fh, m.fh)
            ppgplot.pgsfs(1)

            # Top left string
            ppgplot.pgsch(0.8)
            text = "%s UTC; %s (%04d) [%+.4f\\u\\(2218)\\d, %+.4f\\u\\(2218)\\d, %.0fm]" % (
                m.t.isot, m.observer, m.site, m.lat, m.lon, m.elev)
            ppgplot.pgmtxt("T", 0.6, 0., 0., text)

            # Bottom string
            sra = m.ra.to_string(sep=":",
                                 unit="hourangle",
                                 pad=True,
                                 precision=2)
            sdec = m.dec.to_string(sep=":", unit="deg", pad=True, precision=1)
Exemple #9
0
 def setFill(self, doFill=True):
     if doFill:
         pgplot.pgsfs(1)
     else:
         pgplot.pgsfs(2)
		pgPlotTransform = [0, 1, 0, 0, 0, 1]
		ppgplot.pglab("x", "y", "Initial 10 frame stacked image.")
	
		# Display the image on the user's screen
		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):
Exemple #11
0
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()