def plotsigsff(sig, sf, file, nbin): psplot = file + ".ps" psplotinit(psplot) tot = N.ones(len(sf), 'f') (sigbin, sfbin) = my.binitsumequal(sig, sf, nbin) (sigbin, totbin) = my.binitsumequal(sig, tot, nbin) print sfbin print totbin (sff, sfferr) = my.ratioerror(sfbin, totbin) ppgplot.pgbox("", 0.0, 0, "L", 0.0, 0) ymin = -.05 ymax = 1.05 xmin = min(sig) - 10. #xmax=max(sig)-200. xmax = 350. ppgplot.pgenv(xmin, xmax, ymin, ymax, 0) ppgplot.pglab("\gS\d5\u (gal/Mpc\u2\d)", "Fraction EW([OII])>4 \(2078)", "") ppgplot.pgsls(1) #dotted ppgplot.pgslw(4) #line width sig = N.array(sig, 'f') sff = N.array(sff, 'f') ppgplot.pgsci(2) ppgplot.pgline(sigbin, sff) ppgplot.pgsci(1) ppgplot.pgpt(sigbin, sff, 17) my.errory(sigbin, sff, sfferr) ppgplot.pgend()
def resetdefaults(): """ resetdefaults(): Reset global plotting variables to default values. """ global ppgplot_font_, ppgplot_linestyle_, ppgplot_linewidth_, \ ppgplot_color_, ppgplot_font_size_ ppgplot.pgscf(ppgplot_font_) ppgplot.pgsls(ppgplot_linestyle_) ppgplot.pgslw(ppgplot_linewidth_) ppgplot.pgsci(ppgplot_colors_[ppgplot_color_]) ppgplot.pgsch(ppgplot_font_size_)
def resetdefaults(): """ resetdefaults(): Reset global plotting variables to default values. """ global ppgplot_font_, ppgplot_linestyle_, ppgplot_linewidth_, \ ppgplot_color_, ppgplot_font_size_ ppgplot.pgscf(ppgplot_font_) ppgplot.pgsls(ppgplot_linestyle_) ppgplot.pgslw(ppgplot_linewidth_) ppgplot.pgsci(ppgplot_colors_[ppgplot_color_]) # My little add-on to switch the background to white reset_colors() ppgplot.pgsch(ppgplot_font_size_)
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 plot_horizontal_grid(self): sch, sls, sci = ppgplot.pgqch(), ppgplot.pgqls(), ppgplot.pgqci() ppgplot.pgsci(15) ppgplot.pgsls(2) # Altitudes for alt in np.arange(0.0, 90.0, 20.0): az = np.arange(0.0, 360.0) rx, ry = forward(self.az, self.alt, az, alt * np.ones_like(az)) for i in range(len(rx)): if i == 0: ppgplot.pgmove(rx[i], ry[i]) if (np.abs(rx[i]) <= 1.5 * self.w) & (np.abs(ry[i]) <= self.w): ppgplot.pgdraw(rx[i], ry[i]) else: ppgplot.pgmove(rx[i], ry[i]) # Azimuths for az in np.arange(0.0, 360.0, 30.0): alt = np.arange(0.0, 80.0) rx, ry = forward(self.az, self.alt, az * np.ones_like(alt), alt) for i in range(len(rx)): if i == 0: ppgplot.pgmove(rx[i], ry[i]) if (np.abs(rx[i]) <= 1.5 * self.w) & (np.abs(ry[i]) <= self.w): ppgplot.pgdraw(rx[i], ry[i]) else: ppgplot.pgmove(rx[i], ry[i]) ppgplot.pgsci(1) ppgplot.pgsls(1) # Horizon az = np.arange(0.0, 360.0) rx, ry = forward(self.az, self.alt, az, np.zeros_like(az)) for i in range(len(rx)): if i == 0: ppgplot.pgmove(rx[i], ry[i]) if (np.abs(rx[i]) <= 1.5 * self.w) & (np.abs(ry[i]) <= self.w): ppgplot.pgdraw(rx[i], ry[i]) else: ppgplot.pgmove(rx[i], ry[i])
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 plotsigo2(sig, o2, file, nbin): psplot = file + ".ps" psplotinit(psplot) (sigbin, o2bin) = my.binit(sig, o2, nbin) ppgplot.pgbox("", 0.0, 0, "L", 0.0, 0) ymin = -10. ymax = 2. xmin = min(sig) - 10. #xmax=max(sig)-200. xmax = 350. ppgplot.pgenv(xmin, xmax, ymin, ymax, 0) ppgplot.pglab("\gS\d5\u (gal/Mpc\u2\d)", "EW([OII]) (\(2078))", "") ppgplot.pgsls(1) #dotted ppgplot.pgslw(4) #line width sig = N.array(sig, 'f') o2 = N.array(o2, 'f') ppgplot.pgpt(sig, o2, 1) ppgplot.pgsci(2) ppgplot.pgline(sigbin, o2bin) ppgplot.pgsci(1) ppgplot.pgend()
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 linelabel(xlabel, ylabel, dx, ystep, dxl, dyl, label): #draw key schdef = ppgplot.pgqch() ppgplot.pgsch(1.1) ppgplot.pgtext(xlabel, ylabel, label) ppgplot.pgsch(1.1) ylabel = ylabel - 2. * ystep xs = N.arange(xlabel, (xlabel + dx), .01) ys = ylabel * N.ones(len(xs), 'd') ppgplot.pgsls(1) ppgplot.pgline(xs, ys) ppgplot.pgtext((xlabel + dxl + dx), (ylabel - dyl), "Memb") ylabel = ylabel - ystep ys = ylabel * N.ones(len(xs), 'd') ppgplot.pgsls(4) ppgplot.pgline(xs, ys) ppgplot.pgtext((xlabel + dxl + dx), (ylabel - dyl), "Contam") ppgplot.pgsch(schdef) ppgplot.pgsls(1)
def plot2d(z, x=None, y=None, title=None, rangex=None, rangey=None, \ rangez=None, labx='', laby='', rangex2=None, rangey2=None, \ labx2='', laby2='', image=ppgplot_palette_, contours=None, \ logx=0, logy=0, logx2=0, logy2=0, \ line=ppgplot_linestyle_, width=ppgplot_linewidth_, \ color=ppgplot_color_, labels=ppgplot_labels_, \ labelint=ppgplot_labelint_, labelmin=ppgplot_labelmin_, \ font=ppgplot_font_, id=0, noscale=0, aspect=1, \ fontsize=ppgplot_font_size_, ticks='out', panels=[1,1], \ device=ppgplot_device_): """ plot2d(z, ...) An interface to make various 2D plots using PGPLOT. 'z' is the 2D Numpy array to be plotted. The optional entries are: x: x values (default = 0, 1, ...) y: y values (default = 0, 1, ...) title: graph title (default = None) rangex: range for the x-axis (default = automatic) rangey: range for the y-axis (default = automatic) rangez: range for the z-axis (default = automatic) labx: label for the x-axis (default = None) laby: label for the y-axis (default = None) rangex2: range for 2nd x-axis (default = None) rangey2: range for 2nd y-axis (default = None) labx2: label for the 2nd x-axis (default = None) laby2: label for the 2nd y-axis (default = None) logx: make the 1st x-axis log (default = 0 (no)) logy: make the 1st y-axis log (default = 0 (no)) logx2: make the 2nd x-axis log (default = 0 (no)) logy2: make the 2nd y-axis log (default = 0 (no)) image: color palette for image (default = 'rainbow') contours: list of contour values (default = None) line: contour line style (default = 1 (solid)) width: contour line width (default = 1 (thin)) color: contour line color (default = 'white') labels: color of contour labels (default = None) labelint: contour label spacing (default = 20) labelmin: min contour label spacing (default = 20) font: PGPLOT font to use (default = 1 (normal)) fontsize: PGPLOT font size to use (default = 1.0 (normal)) id: show ID line on plot (default = 0 (no)) noscale: turn off auto scaling (default = 0 (no)) aspect: Aspect ratio (default = 1 (square)) ticks: Ticks point in or out (default = 'out') panels: Number of subpanels [r,c] (default = [1,1]) device: PGPLOT device to use (default = '/XWIN') Note: Many default values are defined in global variables with names like ppgplot_font_ or ppgplot_device_. """ # Make sure the input data is a 2D array z = Num.asarray(z) if not len(z.shape) == 2: print 'Input data array must be 2 dimensional.' return # Announce the global variables we will be using global ppgplot_dev_open_, ppgplot_dev_prep_, pgpalette # Define the X and Y axis limits if needed if x is None: x = Num.arange(z.shape[1], dtype='f') else: x = Num.asarray(x) if y is None: y = Num.arange(z.shape[0], dtype='f') else: y = Num.asarray(y) # Determine the scaling to use for the axes if rangex is None: dx = x[-1] - x[-2] rangex = [x[0], x[-1] + dx] if rangey is None: dy = y[-1] - y[-2] rangey = [y[0], y[-1] + dy] if rangez is None: rangez=[Num.minimum.reduce(Num.ravel(z)), \ Num.maximum.reduce(Num.ravel(z))] # Prep the plotting device... if (not ppgplot_dev_prep_): prepplot(rangex, rangey, title, labx, laby, \ rangex2, rangey2, labx2, laby2, logx, logy, \ logx2, logy2, font, fontsize, id, aspect, \ ticks, panels, device=device) if image is not None: # Set the color indices and the color table lo_col_ind, hi_col_ind = ppgplot.pgqcol() lo_col_ind = lo_col_ind + 2 ppgplot.pgscir(lo_col_ind, hi_col_ind) pgpalette.setpalette(image) ppgplot.pgctab(pgpalette.l, pgpalette.r, pgpalette.g, pgpalette.b) # Construct the image ppgplot.pgimag_s(z, 0.0, 0.0, rangex[0], rangey[0], \ rangex[1], rangey[1]) reset_colors() if contours is not None: contours = Num.asarray(contours) # Choose the line style ppgplot.pgsls(line) # Choose the line width ppgplot.pgslw(width) # Choose the line color for the contourlines if type(color) == types.StringType: ppgplot.pgsci(ppgplot_colors_[color]) else: ppgplot.pgsci(color) # Construct the contours ppgplot.pgcont_s(z, len(contours), contours, rangex[0], \ rangey[0], rangex[1], rangey[1]) # Label the contours if requested if labels is not None: # Choose the line color for the contourlines if type(labels) == types.StringType: ppgplot.pgsci(ppgplot_colors_[labels]) else: ppgplot.pgsci(labels) for i in range(len(contours)): ppgplot.pgconl_s(z, contours[i], str(contours[i]), labelint, labelmin)
def plothistsfr(): DATAMIN = -4. DATAMAX = 15. NBIN = int((DATAMAX-DATAMIN)*2.) #print "ngal = ",len(g0.sfr) ppgplot.pgbox("",0.0,0,"L",0.0,0) ppgplot.pgenv(DATAMIN,DATAMAX,0,45,0) ppgplot.pglab("SFR (h\d100\u\u-2\d M\d\(2281)\u yr\u-1 \d)","Number of Galaxies","") ppgplot.pgsls(1)#dotted ppgplot.pgslw(4) #line width #ppgplot.pgsci(4) #x=N.compress((abs(g0.ew) > ewmin),g0.sfr) x=N.compress((g0.final > 0),g0.sfrc) ppgplot.pghist(len(x),x,DATAMIN,DATAMAX,NBIN,5) xlabel = 6.5 ylabel = 38. ystep = 3. dy=.4 dxl=3 dxr=.5 ppgplot.pgslw(deflw) #line width ppgplot.pgtext(xlabel,ylabel,"CL1040") xlin = N.array([xlabel-dxl,xlabel-dxr],'f') ylin = N.array([ylabel+dy,ylabel+dy],'f') ppgplot.pgslw(4) #line width ppgplot.pgline(xlin,ylin) ppgplot.pgslw(5) ppgplot.pgsls(3)#dot-dash-dot-dash #ppgplot.pgsci(3) #x=N.compress((abs(g1.ew) > ewmin),g1.sfr) x=N.compress((g1.final > 0),g1.sfrc) ppgplot.pghist(len(x),x,DATAMIN,DATAMAX,NBIN,5) ylabel = ylabel - ystep xlin = N.array([xlabel-dxl,xlabel-dxr],'f') ylin = N.array([ylabel+dy,ylabel+dy],'f') ppgplot.pgline(xlin,ylin) ppgplot.pgsls(1) ppgplot.pgslw(deflw) ppgplot.pgtext(xlabel,ylabel,"CL1054-12") ppgplot.pgsls(1)#dot-dash-dot-dash #ppgplot.pgsci(2) ppgplot.pgslw(2) #line width #x=N.compress((abs(g2.ew) > ewmin),g2.sfr) x=N.compress((g2.final > 0),g2.sfrc) ppgplot.pghist(len(x),x,DATAMIN,DATAMAX,NBIN,5) ylabel = ylabel - ystep ppgplot.pgslw(deflw) #line width ppgplot.pgtext(xlabel,ylabel,"CL1216") xlin = N.array([xlabel-dxl,xlabel-dxr],'f') ylin = N.array([ylabel+dy,ylabel+dy],'f') ppgplot.pgslw(2) #line width ppgplot.pgline(xlin,ylin) #print "Number in g2.ratios = ",len(g2.ratio) #for ratio in g2.ratio: # print ratio #drawbinned(x,y,5) ppgplot.pgsci(1)
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()
def plotxy(y, x=None, title=None, rangex=None, rangey=None, \ labx='', laby='', rangex2=None, rangey2=None, \ labx2='', laby2='', symbol=ppgplot_symbol_, \ line=ppgplot_linestyle_, width=ppgplot_linewidth_, \ color=ppgplot_color_, font=ppgplot_font_, logx=0, logy=0, \ logx2=0, logy2=0, errx=None, erry=None, id=0, noscale=0, \ aspect=0.7727, fontsize=ppgplot_font_size_, ticks='in', \ panels=[1,1], device=ppgplot_device_, setup=1): """ plotxy(y, ...) An interface to make various XY style plots using PGPLOT. 'y' is the 1D sequence object to plot. The optional entries are: x: x values (default = 0, 1, ...) title: graph title (default = None) rangex: ranges for the x-axis (default = automatic) rangey: ranges for the y-axis (default = automatic) labx: label for the x-axis (default = None) laby: label for the y-axis (default = None) rangex2: ranges for 2nd x-axis (default = None) rangey2: ranges for 2nd y-axis (default = None) labx2: label for the 2nd x-axis (default = None) laby2: label for the 2nd y-axis (default = None) logx: make the 1st x-axis log (default = 0 (no)) logy: make the 1st y-axis log (default = 0 (no)) logx2: make the 2nd x-axis log (default = 0 (no)) logy2: make the 2nd y-axis log (default = 0 (no)) errx: symmetric x errors (default = None) erry: symmetric y errors (default = None) symbol: symbol for points (default = None) line: line style (default = 1 (solid)) width: line width (default = 1 (thin)) color: line and/or symbol color (default = 'white') font: PGPLOT font to use (default = 1 (normal)) fontsize: PGPLOT font size to use (default = 1.0 (normal)) id: show ID line on plot (default = 0 (no)) noscale: turn off auto scaling (default = 0 (no)) aspect: aspect ratio (default = 0.7727 (rect)) ticks: Ticks point in or out (default = 'in') panels: Number of subpanels [r,c] (default = [1,1]) device: PGPLOT device to use (default = '/XWIN') setup: Auto-setup the plot (default = 1) Note: Many default values are defined in global variables with names like ppgplot_font_ or ppgplot_device_. """ # Make sure the input data is an array y = Num.asarray(y) # Announce the global variables we will be using global ppgplot_dev_open_, ppgplot_dev_prep_, ppgplot_colors_ # Define the X axis limits if needed if x is None: x = Num.arange(len(y), dtype='f') else: x = Num.asarray(x) # Determine the scaling to use for the first axis if rangex is None: rangex = [x.min(), x.max()] if rangey is None: if noscale: rangey = [y.min(), y.max()] else: rangey = scalerange(y) # Prep the plotting device... if (not ppgplot_dev_prep_ and setup): prepplot(rangex, rangey, title, labx, laby, \ rangex2, rangey2, labx2, laby2, \ logx, logy, logx2, logy2, font, fontsize, \ id, aspect, ticks, panels, device=device) # Choose the line color if type(color) == types.StringType: ppgplot.pgsci(ppgplot_colors_[color]) else: ppgplot.pgsci(color) # Plot symbols (and errors) if requested if not symbol is None: ppgplot.pgpt(x, y, symbol) # Error bars if errx is not None: if not logx: errx = Num.asarray(errx) ppgplot.pgerrx(x + errx, x - errx, y, 1.0) else: errx = 10.0**Num.asarray(errx) ppgplot.pgerrx(Num.log10(10.0**x + errx), Num.log10(10.0**x - errx), y, 1.0) if erry is not None: if not logy: erry = Num.asarray(erry) ppgplot.pgerry(x, y + erry, y - erry, 1.0) else: erry = 10.0**Num.asarray(erry) ppgplot.pgerry(x, Num.log10(10.0**y + erry), Num.log10(10.0**y - erry), 1.0) # Plot connecting lines if requested if not line is None: # Choose the line style ppgplot.pgsls(line) # Choose the line width ppgplot.pgslw(width) ppgplot.pgline(x, y)
l_max=8 ppgplot.pgslw(3) # line width ppgplot.pgslw(2) # line width ppgplot.pgsch(1.0) # character height (size) for (l=l_min l<=12 l+=1){ ppgplot.pgtext(-12.012+l*0.974,0.96,"l") } for (l=1 l<=l_max l+=1){ ppgplot.pgtext(-0.012+l*0.974,0.96,"l") } ppgplot.pgslw(1) # line width ppgplot.pgsls(1) # line sytle 1: --- 2: --- 3: .-. : 4 ... 5: -... ppgplot.pgbox('G', 1.0, 0, '0', 0.1, 0) # coordinate settings ppgplot.pgsls(1) # line sytle 1: --- 2: --- 3: .-. : 4 ... 5: -... ppgplot.pgslw(1) # line width ppgplot.pgsls(4) # line sytle 1: --- 2: --- 3: .-. : 4 ... 5: -... ppgplot.pgbox('0', 1.0, 0, 'G', 0.1, 0) # coordinate settings ppgplot.pgsls(1) # line sytle 1: --- 2: --- 3: .-. : 4 ... 5: -... ppgplot.pgslw(3) # line width ppgplot.pgsls(1) # line sytle 1: --- 2: --- 3: .-. : 4 ... 5: -... ppgplot.pgbox('G', 8.0, 0, 'G', 0.5, 0) # coordinate settings ppgplot.pgsls(1) # line sytle 1: --- 2: --- 3: .-. : 4 ... 5: -... ppgplot.pgend
phaseArray = [] angleArray = [] # Plot theta as a function of orbital phase for these parameters for phase in numpy.arange(0.5, 1.51, 0.01): theta = computeViewingAngle(phase, inclination, beta, phi) phaseArray.append(phase) angleArray.append(theta) mainPlotWindow = ppgplot.pgopen("/xs") ppgplot.pgask(False) pgPlotTransform = [0, 1, 0, 0, 0, 1] ppgplot.pgsci(1) ppgplot.pgenv(min(phaseArray), max(phaseArray), 0, 180, 0, 0) ppgplot.pgline(phaseArray, angleArray) ppgplot.pgsls(2) ppgplot.pgline([0.5, 1.5], [90, 90]) ppgplot.pglab("orbital phase", "viewing angle", "Viewing angle \gh as a function of orbital phase.") ppgplot.pgtext(0.6, 150, "i:%2.0f \gb:%2.0f \gf:%2.0f" % (inclination, beta, phi)) modelPlotWindow = ppgplot.pgopen("models_i_81_b_40.ps/ps") pgPlotTransform = [0, 1, 0, 0, 0, 1] ppgplot.pgask(False) mainFluxMax = 0 mainFluxMin = 1E99 for phase in numpy.arange(0.5, 1.6, 0.1): ppgplot.pgsci(1)
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()
#power = signal.lombscargle(x, y, ang_freqs) # normalize the power #N = len(x) # power *= 2 / (N * y.std() ** 2) ppgplot.pgenv(min(frequency), max(frequency), 0, max(power), 0, 0) ppgplot.pgline(frequency, power) #ppgplot.pgenv(min(periods), max(periods), 0, max(power), 0, 0) #ppgplot.pgline(periods, power) ppgplot.pglab("Frequency (d\u-1\d)", "Amplitude", "Lomb-Scargle: " + o.id) bestFrequency = frequency[numpy.argmax(power)] lc = ppgplot.pgqci() ls = ppgplot.pgqls() ppgplot.pgsci(3) ppgplot.pgsls(2) ppgplot.pgline([bestFrequency, bestFrequency], [0, max(power)]) ppgplot.pgsci(lc) ppgplot.pgsls(ls) print "Best frequency: %f cycles per day"%bestFrequency bestPeriod = 1/bestFrequency print "%s Best period: %f days or %f hours"%(o.id, bestPeriod, bestPeriod * 24.) print o.ephemeris o.ephemeris.Period = bestPeriod matplotlib.pyplot.plot(frequency, power, linewidth=1.0, color='k', alpha=0.75) matplotlib.pyplot.ylim([0, 1.2 * max(power)]) matplotlib.pyplot.plot([1/o.ephemeris.Period, 1/o.ephemeris.Period], [0, 1.2 * max(power)], linewidth=1.5, linestyle='--', color='r', alpha=1) matplotlib.pyplot.plot([bestFrequency, bestFrequency], [0, 1.2 * max(power)], linewidth=1.5, linestyle='--', color='b', alpha=1) matplotlib.pyplot.draw() matplotlib.pyplot.show()
def plot2d(z, x=None, y=None, title=None, rangex=None, rangey=None, \ rangez=None, labx='', laby='', rangex2=None, rangey2=None, \ labx2='', laby2='', image=ppgplot_palette_, contours=None, \ logx=0, logy=0, logx2=0, logy2=0, \ line=ppgplot_linestyle_, width=ppgplot_linewidth_, \ color=ppgplot_color_, labels=ppgplot_labels_, \ labelint=ppgplot_labelint_, labelmin=ppgplot_labelmin_, \ font=ppgplot_font_, id=0, noscale=0, aspect=1, \ fontsize=ppgplot_font_size_, ticks='out', panels=[1,1], \ device=ppgplot_device_): """ plot2d(z, ...) An interface to make various 2D plots using PGPLOT. 'z' is the 2D Numpy array to be plotted. The optional entries are: x: x values (default = 0, 1, ...) y: y values (default = 0, 1, ...) title: graph title (default = None) rangex: range for the x-axis (default = automatic) rangey: range for the y-axis (default = automatic) rangez: range for the z-axis (default = automatic) labx: label for the x-axis (default = None) laby: label for the y-axis (default = None) rangex2: range for 2nd x-axis (default = None) rangey2: range for 2nd y-axis (default = None) labx2: label for the 2nd x-axis (default = None) laby2: label for the 2nd y-axis (default = None) logx: make the 1st x-axis log (default = 0 (no)) logy: make the 1st y-axis log (default = 0 (no)) logx2: make the 2nd x-axis log (default = 0 (no)) logy2: make the 2nd y-axis log (default = 0 (no)) image: color palette for image (default = 'rainbow') contours: list of contour values (default = None) line: contour line style (default = 1 (solid)) width: contour line width (default = 1 (thin)) color: contour line color (default = 'white') labels: color of contour labels (default = None) labelint: contour label spacing (default = 20) labelmin: min contour label spacing (default = 20) font: PGPLOT font to use (default = 1 (normal)) fontsize: PGPLOT font size to use (default = 1.0 (normal)) id: show ID line on plot (default = 0 (no)) noscale: turn off auto scaling (default = 0 (no)) aspect: Aspect ratio (default = 1 (square)) ticks: Ticks point in or out (default = 'out') panels: Number of subpanels [r,c] (default = [1,1]) device: PGPLOT device to use (default = '/XWIN') Note: Many default values are defined in global variables with names like ppgplot_font_ or ppgplot_device_. """ # Make sure the input data is a 2D array z = Num.asarray(z); if not len(z.shape)==2: print 'Input data array must be 2 dimensional.' return # Announce the global variables we will be using global ppgplot_dev_open_, ppgplot_dev_prep_, pgpalette # Define the X and Y axis limits if needed if x is None: x=Num.arange(z.shape[1], dtype='f') else: x = Num.asarray(x) if y is None: y=Num.arange(z.shape[0], dtype='f') else: y = Num.asarray(y) # Determine the scaling to use for the axes if rangex is None: rangex=[Num.minimum.reduce(x), \ Num.maximum.reduce(x)] if rangey is None: rangey=[Num.minimum.reduce(y), \ Num.maximum.reduce(y)] if rangez is None: rangez=[Num.minimum.reduce(Num.ravel(z)), \ Num.maximum.reduce(Num.ravel(z))] # Prep the plotting device... if (not ppgplot_dev_prep_): prepplot(rangex, rangey, title, labx, laby, \ rangex2, rangey2, labx2, laby2, logx, logy, \ logx2, logy2, font, fontsize, id, aspect, \ ticks, panels, device=device) if image is not None: # Set the color indices and the color table lo_col_ind, hi_col_ind = ppgplot.pgqcol() lo_col_ind = lo_col_ind + 2 ppgplot.pgscir(lo_col_ind, hi_col_ind) pgpalette.setpalette(image) ppgplot.pgctab(pgpalette.l,pgpalette.r,pgpalette.g,pgpalette.b) # Construct the image ppgplot.pgimag_s(z, 0.0, 0.0, rangex[0], rangey[0], \ rangex[1], rangey[1]) reset_colors() if contours is not None: contours = Num.asarray(contours) # Choose the line style ppgplot.pgsls(line) # Choose the line width ppgplot.pgslw(width) # Choose the line color for the contourlines if type(color) == types.StringType: ppgplot.pgsci(ppgplot_colors_[color]) else: ppgplot.pgsci(color) # Construct the contours ppgplot.pgcont_s(z, len(contours), contours, rangex[0], \ rangey[0], rangex[1], rangey[1]) # Label the contours if requested if labels is not None: # Choose the line color for the contourlines if type(labels) == types.StringType: ppgplot.pgsci(ppgplot_colors_[labels]) else: ppgplot.pgsci(labels) for i in range(len(contours)): ppgplot.pgconl_s(z, contours[i], str(contours[i]), labelint, labelmin)
def plotxy(y, x=None, title=None, rangex=None, rangey=None, \ labx='', laby='', rangex2=None, rangey2=None, \ labx2='', laby2='', symbol=ppgplot_symbol_, \ line=ppgplot_linestyle_, width=ppgplot_linewidth_, \ color=ppgplot_color_, font=ppgplot_font_, logx=0, logy=0, \ logx2=0, logy2=0, errx=None, erry=None, id=0, noscale=0, \ aspect=0.7727, fontsize=ppgplot_font_size_, ticks='in', \ panels=[1,1], device=ppgplot_device_, setup=1): """ plotxy(y, ...) An interface to make various XY style plots using PGPLOT. 'y' is the 1D sequence object to plot. The optional entries are: x: x values (default = 0, 1, ...) title: graph title (default = None) rangex: ranges for the x-axis (default = automatic) rangey: ranges for the y-axis (default = automatic) labx: label for the x-axis (default = None) laby: label for the y-axis (default = None) rangex2: ranges for 2nd x-axis (default = None) rangey2: ranges for 2nd y-axis (default = None) labx2: label for the 2nd x-axis (default = None) laby2: label for the 2nd y-axis (default = None) logx: make the 1st x-axis log (default = 0 (no)) logy: make the 1st y-axis log (default = 0 (no)) logx2: make the 2nd x-axis log (default = 0 (no)) logy2: make the 2nd y-axis log (default = 0 (no)) errx: symmetric x errors (default = None) erry: symmetric y errors (default = None) symbol: symbol for points (default = None) line: line style (default = 1 (solid)) width: line width (default = 1 (thin)) color: line and/or symbol color (default = 'white') font: PGPLOT font to use (default = 1 (normal)) fontsize: PGPLOT font size to use (default = 1.0 (normal)) id: show ID line on plot (default = 0 (no)) noscale: turn off auto scaling (default = 0 (no)) aspect: aspect ratio (default = 0.7727 (rect)) ticks: Ticks point in or out (default = 'in') panels: Number of subpanels [r,c] (default = [1,1]) device: PGPLOT device to use (default = '/XWIN') setup: Auto-setup the plot (default = 1) Note: Many default values are defined in global variables with names like ppgplot_font_ or ppgplot_device_. """ # Make sure the input data is an array y = Num.asarray(y); # Announce the global variables we will be using global ppgplot_dev_open_, ppgplot_dev_prep_, ppgplot_colors_ # Define the X axis limits if needed if x is None: x=Num.arange(len(y), dtype='f') else: x = Num.asarray(x) # Determine the scaling to use for the first axis if rangex is None: rangex=[x.min(), x.max()] if rangey is None: if noscale: rangey=[y.min(), y.max()] else: rangey=scalerange(y) # Prep the plotting device... if (not ppgplot_dev_prep_ and setup): prepplot(rangex, rangey, title, labx, laby, \ rangex2, rangey2, labx2, laby2, \ logx, logy, logx2, logy2, font, fontsize, \ id, aspect, ticks, panels, device=device) # Choose the line color if type(color) == types.StringType: ppgplot.pgsci(ppgplot_colors_[color]) else: ppgplot.pgsci(color) # Plot symbols (and errors) if requested if not symbol is None: ppgplot.pgpt(x, y, symbol) # Error bars if errx is not None: if not logx: errx = Num.asarray(errx) if errx.size == 1: errx = errx.repeat(x.size) #ppgplot.pgerrx(x+errx, x-errx, y, 1.0) ppgplot.pgerrb(5, x, y, errx, 1.0) else: errx = 10.0**Num.asarray(errx) if errx.size == 1: errx = errx.repeat(x.size) #ppgplot.pgerrx(Num.log10(10.0**x + errx), # Num.log10(10.0**x - errx), y, 1.0) ppgplot.pgerrb(5, x, y, Num.log10(errx), 1.0) if erry is not None: if not logy: erry = Num.asarray(erry) if erry.size == 1: erry = erry.repeat(y.size) #ppgplot.pgerry(x, y+erry, y-erry, 1.0) ppgplot.pgerrb(6, x, y, erry, 1.0) else: erry = 10.0**Num.asarray(erry) if erry.size == 1: erry = erry.repeat(y.size) #ppgplot.pgerry(x, Num.log10(10.0**y + erry), # Num.log10(10.0**y - erry), 1.0) ppgplot.pgerrb(6, x, y, Num.log10(erry), 1.0) # Plot connecting lines if requested if not line is None: # Choose the line style ppgplot.pgsls(line) # Choose the line width ppgplot.pgslw(width) ppgplot.pgline(x, y)
def plotold(): xmin=2.2 xmax=3.2 ymin=-2.5 ymax=-.5 psplotinit('fSsigma3Gyr.ps') ppgplot.pgbox("",0.0,0,"",0.0,0) ppgplot.pgenv(xmin,xmax,ymin,ymax,0,30) ppgplot.pglab("\gs (km/s)",'fS(10\u11\d:10\u13\d)',"") ppgplot.pgsci(1) ppgplot.pgline(sigma,frac) ppgplot.pgsls(2) ppgplot.pgsci(2) ppgplot.pgline(sigma08,frac08) ppgplot.pgsls(1) ppgplot.pgsci(1) ppgplot.pgend() xmin=2.2 xmax=3.2 ymin=11. ymax=14.2 psplotinit('maccretsigma3Gyr.ps') ppgplot.pgbox("",0.0,0,"",0.0,0) ppgplot.pgenv(xmin,xmax,ymin,ymax,0,30) ppgplot.pglab("\gs (km/s)",'M\dacc\u (M\d\(2281)\u)',"") ppgplot.pgsci(1) ppgplot.pgline(sigma,maccret) ppgplot.pgsls(2) ppgplot.pgsci(2) ppgplot.pgline(sigma08,maccret08) ppgplot.pgsls(1) ppgplot.pgsci(1) mylines=N.arange(-20.,20.,.4) mylineswidth=3 ppgplot.pgsls(4) ppgplot.pgslw(mylineswidth) x=N.arange(0.,5.,1.) lines=mylines for y0 in lines: y=3*x +y0 ppgplot.pgline(x,y) ppgplot.pgsls(1) ppgplot.pgend() os.system('cp maccretsigma.ps /Users/rfinn/SDSS/paper/.') os.system('cp fSsigma.ps /Users/rfinn/SDSS/paper/.')
# Graph of the x-direction ppgplot.pgsvp(0.1, 0.7, 0.1, 0.2) yMax = numpy.max(xCollapsed) * 1.1 yMin = numpy.min(xCollapsed) * 0.9 ppgplot.pgswin(-margins, margins, yMin, yMax) ppgplot.pgsci(1) ppgplot.pgbox('ABI', 1.0, 10, 'ABI', 0.0, 0) xPoints = [x - margins for x in range(len(xCollapsed))] ppgplot.pgsci(2) ppgplot.pgbin(xPoints, xCollapsed, True) numPolyPoints = 50 xFit = [float(i) * len(xCollapsed)/numPolyPoints for i in range(numPolyPoints)] yFit = [xPoly[0]*x*x + xPoly[1]*x + xPoly[2] for x in xFit] ppgplot.pgsci(3) ppgplot.pgline([x - margins for x in xFit], yFit) ppgplot.pgsls(2) ppgplot.pgline([newxPeak-margins, newxPeak-margins], [yMin, yMax]) ppgplot.pgsci(4) ppgplot.pgline([xBestOffset, xBestOffset], [yMin, yMax]) ppgplot.pgsls(1) ppgplot.pgline(xGaussian, xGaussianFit) # Graph of the y-direction ppgplot.pgsvp(0.8, 0.9, 0.3, 0.9) yMax = numpy.max(yCollapsed) * 1.1 yMin = numpy.min(yCollapsed) * 0.9 ppgplot.pgswin(yMin, yMax, -margins, margins) ppgplot.pgsci(1) ppgplot.pgbox('ABI', 0.0, 0, 'ABI', 1.0, 10) xPoints = [x - margins for x in range(len(yCollapsed))] ppgplot.pgsci(2)
timeToNextStep = lightCurve.period - lightCurve.time[n] else: timeToNextStep = lightCurve.time[n+1] - lightCurve.time[n] print n, lightCurve.time[n], lightCurve.brightness[n], timeToNextStep ppgplot.pgeras() ppgplot.pgsci(1) ppgplot.pgenv(0., lightCurve.period, 0.0, 1.0, 0, 0) ppgplot.pglab("seconds", "brightness", "Light curve") ppgplot.pgpt(lightCurve.time, lightCurve.brightness, 2) ppgplot.pgsci(2) ppgplot.pgline(lightCurve.time, lightCurve.brightness) ppgplot.pgsci(3) ppgplot.pgpt([lightCurve.time[n]], [lightCurve.brightness[n]], 3) currentLineStyle = ppgplot.pgqls() ppgplot.pgsls(2) ppgplot.pgline([lightCurve.time[n], lightCurve.time[n]], [ 0, 1]) ppgplot.pgsls(currentLineStyle) params = {"brightness": str(lightCurve.brightness[n]), "duration": str(timeToNextStep)} print "Sending params:", params response = requests.put("https://api.lifx.com/v1beta1/lights/all/state", headers=headers, params=params) # print response.text time.sleep(timeToNextStep) ppgplot.pgclos() sys.exit()