Esempio n. 1
0
def plot_selection_new(ident, dt=1.0, w=10.0):
    dx, dy = ident.x1 - ident.x0, ident.y1 - ident.y0
    ang = np.mod(np.arctan2(dy, dx), 2.0 * np.pi)
    r = np.sqrt(dx**2 + dy**2)
    drdt = r / (ident.t1 - ident.t0)
    sa, ca = np.sin(ang), np.cos(ang)

    dx = np.array([-dt, -dt, ident.t1 + dt, ident.t1 + dt, -dt]) * drdt
    dy = np.array([w, -w, -w, w, w])
    x = ca * dx - sa * dy + ident.x0
    y = sa * dx + ca * dy + ident.y0

    ppg.pgline(x, y)
    ppg.pgpt1(x[0], y[0], 17)
    ppg.pgpt1(x[1], y[1], 17)
    ppg.pgsch(0.65)
    ppg.pgslw(2)
    if (x[0] < x[1]) & (ident.x0 < ident.x1):
        ppg.pgptxt(x[1], y[1] - 1.5 * w, 0.0, 0.0, " %05d" % ident.norad)
    else:
        ppg.pgptxt(x[0], y[0] + 0.5 * w, 0.0, 0.0, " %05d" % ident.norad)
    ppg.pgsch(1.0)
    ppg.pgslw(1)

    return
Esempio n. 2
0
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()
Esempio n. 3
0
def plotdVdz():
    nv = 3.
    nr = 1.
    ppgplot.pgbeg("dVdz.ps/vcps", 1, 1)  #color port.
    ppgplot.pgpap(8., 1.25)
    ppgplot.pgpage
    ppgplot.pgsch(1.2)  #font size
    ppgplot.pgslw(3)  #line width

    # 1st panel with symbols w/ stddev errorbars

    x1 = .15
    x2 = .45
    x3 = .6
    x4 = .95
    y1 = .15
    y2 = .425
    y3 = .575
    y4 = .85
    xlabel = 14.1 - 14.
    ylabel = 1.15
    schdef = 1.2
    slwdef = 4
    ppgplot.pgsch(schdef)
    xmin = 0.
    xmax = 1.1
    ymin = 0.
    ymax = 1.2

    ppgplot.pgsvp(x1, x4, y1, y4)  #sets viewport
    ppgplot.pgslw(slwdef)  #line width
    ppgplot.pgswin(xmin, xmax, ymin, ymax)  #axes limits
    ppgplot.pgbox('bcnst', .2, 2, 'bcvnst', .2, 2)  #tickmarks and labeling
    ppgplot.pgmtxt('b', 2.5, 0.5, 0.5, "z")  #xlabel
    ppgplot.pgmtxt('l', 2.6, 0.5, 0.5, "(1/DH)\u3\d c dV\dc\u/dv/d\gW")

    z = N.arange(0., 5., .1)
    beta = ((1 + z)**2 - 1) / ((1 + z)**2 + 1)
    dV = N.zeros(len(z), 'd')
    for i in range(len(z)):
        #dz=dv/(1+z[i])*(1- ((1+z[i])**2 -1)/((1+z[i])**2+1))**(-2)
        #z1=z[i]-0.5*dz
        #z2=z[i]+0.5*dz
        #dV[i]=my.dL(z2,h) - my.dL(z1,h)
        dA = my.DA(z[i], h) * 206264. / 1000.
        dV[i] = DH * (1 + z[i]) * (dA)**2 / (my.E(
            z[i])) / (1 - beta[i])**2 / DH**3
        #dV[i]=DH*(1+z[i])**2*(dA)**2/(my.E(z[i]))/DH**3#for comparison w/Hogg
        if z[i] < 1:
            print i, z[i], dV[i], dV[i]**(1. / 3.)

    ppgplot.pgline(z, dV)

    ppgplot.pgend()
Esempio n. 4
0
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_)
Esempio n. 5
0
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_)
Esempio n. 6
0
def dm_time_plot(dms, times, sigmas, dm_arr, sigma_arr, time_arr,
                 Total_observed_time, xwin):
    """
    Plot DM vs Time subplot for the spd plots.
    Input: 
        dms: list of dms of single pulse events to be plotted.
        times: list of times of single pulse events to be plotted.
        sigmas: list of sigmas of single pulse events to be plotted.
        dm_arr: array of dms of the main single pulse group (plotted in black).
        sigma_arr: array of sigmas of the main single pulse group (plotted in black).
        time_arr: array of times of single pulse group (plotted in black).
        Total_observed_time: float : Total observation time 
        xwin: True or False. Use xwin or vcps window.
    """
    min_dm = Num.min(dms)
    max_dm = Num.max(dms)
    ppgplot.pgswin(0, Total_observed_time, min_dm, max_dm)
    ppgplot.pgsch(0.8)
    ppgplot.pgslw(3)
    ppgplot.pgbox("BCNST", 0, 0, "BCNST", 0, 0)
    ppgplot.pgslw(3)
    ppgplot.pgmtxt('B', 2.5, 0.5, 0.5, "Time (s)")
    ppgplot.pgmtxt('L', 1.8, 0.5, 0.5, "DM (pc cm\u-3\d)")
    snr_range = 12.0
    cand_symbols = []
    cand_symbols_group = []
    for i in range(len(sigmas)):
        if sigmas[i] > 20.00:
            sigmas[i] = 20.0
        cand_symbol = int((sigmas[i] - 5.0) / snr_range * 6.0 + 20.5)
        cand_symbols.append(min(cand_symbol, 26))
    cand_symbols = Num.array(cand_symbols)
    for i in range(len(dm_arr)):
        cand_symbol = int((sigma_arr[i] - 5.0) / snr_range * 6.0 + 20.5)
        cand_symbols_group.append(min(cand_symbol, 26))
    cand_symbols_group = Num.array(cand_symbols_group)
    dms = Num.array(dms)
    times = Num.array(times)
    dm_arr = Num.array(dm_arr)
    time_arr = Num.array(time_arr)
    for ii in [26, 25, 24, 23, 22, 21, 20]:
        inds = Num.nonzero(cand_symbols == ii)[0]
        ppgplot.pgshls(1, 0.0, 0.5, 0.0)
        ppgplot.pgpt(times[inds], dms[inds], ii)
    for ii in [26, 25, 24, 23, 22, 21, 20]:
        inds_1 = Num.nonzero(cand_symbols_group == ii)[0]
        if xwin:
            ppgplot.pgshls(1, 0.0, 0.8, 0.0)
        else:
            ppgplot.pgshls(1, 0.0, 0.0, 0.0)
        ppgplot.pgpt(time_arr[inds_1], dm_arr[inds_1], ii)
Esempio n. 7
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)
Esempio n. 8
0
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/.')
Esempio n. 9
0
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_)
Esempio n. 10
0
def dm_time_plot(dms, times, sigmas, dm_arr, sigma_arr, time_arr, Total_observed_time, xwin):
    """
    Plot DM vs Time subplot for the spd plots.
    Input: 
        dms: list of dms of single pulse events to be plotted.
        times: list of times of single pulse events to be plotted.
        sigmas: list of sigmas of single pulse events to be plotted.
        dm_arr: array of dms of the main single pulse group (plotted in black).
        sigma_arr: array of sigmas of the main single pulse group (plotted in black).
        time_arr: array of times of single pulse group (plotted in black).
        Total_observed_time: float : Total observation time 
        xwin: True or False. Use xwin or vcps window.
    """
    min_dm = Num.min(dms)
    max_dm = Num.max(dms)
    ppgplot.pgswin(0, Total_observed_time, min_dm, max_dm)
    ppgplot.pgsch(0.8)
    ppgplot.pgslw(3)
    ppgplot.pgbox("BCNST", 0, 0, "BCNST", 0, 0)
    ppgplot.pgslw(3)
    ppgplot.pgmtxt('B', 2.5, 0.5, 0.5, "Time (s)")
    ppgplot.pgmtxt('L', 1.8, 0.5, 0.5, "DM (pc cm\u-3\d)")
    snr_range = 12.0
    cand_symbols = []
    cand_symbols_group = []
    for i in range(len(sigmas)):
        if sigmas[i] > 20.00:
            sigmas[i] = 20.0
        cand_symbol = int((sigmas[i] - 5.0)/snr_range * 6.0 + 20.5)
        cand_symbols.append(min(cand_symbol, 26))
    cand_symbols = Num.array(cand_symbols)
    for i in range(len(dm_arr)):
        cand_symbol = int((sigma_arr[i] - 5.0)/snr_range * 6.0 + 20.5)
        cand_symbols_group.append(min(cand_symbol, 26))
    cand_symbols_group = Num.array(cand_symbols_group)
    dms = Num.array(dms)
    times = Num.array(times)
    dm_arr = Num.array(dm_arr)
    time_arr = Num.array(time_arr)
    for ii in [26, 25, 24, 23, 22, 21, 20]:
        inds = Num.nonzero(cand_symbols == ii)[0]
        ppgplot.pgshls(1, 0.0, 0.5, 0.0)
        ppgplot.pgpt(times[inds], dms[inds], ii)
    for ii in [26, 25, 24, 23, 22, 21, 20]:
        inds_1 = Num.nonzero(cand_symbols_group == ii)[0]
        if xwin:
            ppgplot.pgshls(1, 0.0, 0.8, 0.0)
        else:
            ppgplot.pgshls(1, 0.0, 0.0, 0.0)
        ppgplot.pgpt(time_arr[inds_1], dm_arr[inds_1], ii)
Esempio n. 11
0
def makeplot():
    psplotinit("noise.ps")

    DATAMIN = 0.
    DATAMAX = 15.

    ppgplot.pgbox("", 0.0, 0, "L", 0.0, 0)
    #print "making graph, ncl = ",ncl
    path = os.getcwd()
    f = path.split('/')
    #print path
    #print f
    prefix = f[4]
    title = prefix
    ymin = -.05
    ymax = max(aveaperr) + .1
    #ymax=10.
    ppgplot.pgenv(DATAMIN, DATAMAX, ymin, ymax, 0)
    ppgplot.pglab("linear size N of aperture (pixel)", "rms in Sky (ADU/s)",
                  title)
    ppgplot.pgsci(2)  #red
    ppgplot.pgslw(4)  #line width
    x = N.sqrt(avearea)
    y = aveaperr
    ppgplot.pgpt(x, y, 7)
    #errory(x,y,erry)
    ppgplot.pgsci(1)  #black
    #ppgplot.pgpt(isoarea,fluxerriso,3)
    #x1=N.sqrt(contsubisoarea)
    #y1=contsuberr

    #x1=N.sqrt(isoarea)
    #y1=fluxerriso
    #y=n*y1

    #ppgplot.pgpt(x1,y1,1)
    #ppgplot.pgsci(4)#blue
    #ppgplot.pgpt(x1,y,1)
    #ppgplot.pgsci(1)#black
    x = N.arange(0, 50, 1)
    y = x * (a + b * a * x)
    #y=N.sqrt(x)*.02
    ppgplot.pgline(x, y)
    #errory(x,y,erry)

    ppgplot.pgend()
Esempio n. 12
0
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()
Esempio n. 13
0
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()
Esempio n. 14
0
def dm_time_plot(dms, times, sigmas, dm_arr, sigma_arr, time_arr,
                 Total_observed_time, xwin):
    """
    Plot DM vs Time.
    """
    min_dm = Num.min(dms)
    max_dm = Num.max(dms)
    ppgplot.pgsvp(0.48, 0.97, 0.1, 0.54)
    ppgplot.pgswin(0, Total_observed_time, min_dm, max_dm)
    ppgplot.pgsch(0.8)
    ppgplot.pgslw(3)
    ppgplot.pgbox("BCNST", 0, 0, "BCNST", 0, 0)
    ppgplot.pgslw(3)
    ppgplot.pgmtxt('B', 2.5, 0.5, 0.5, "Time (s)")
    ppgplot.pgmtxt('L', 1.8, 0.5, 0.5, "DM (pc cm\u-3\d)")
    snr_range = 12.0
    cand_symbols = []
    cand_symbols_group = []
    for i in range(len(sigmas)):
        if sigmas[i] > 20.00:
            sigmas[i] = 20.0
        cand_symbol = int((sigmas[i] - 5.0) / snr_range * 6.0 + 20.5)
        cand_symbols.append(min(cand_symbol, 26))
    cand_symbols = Num.array(cand_symbols)
    for i in range(len(dm_arr)):
        cand_symbol = int((sigma_arr[i] - 5.0) / snr_range * 6.0 + 20.5)
        cand_symbols_group.append(min(cand_symbol, 26))
    cand_symbols_group = Num.array(cand_symbols_group)
    dms = Num.array(dms)
    times = Num.array(times)
    dm_arr = Num.array(dm_arr)
    time_arr = Num.array(time_arr)
    for ii in [26, 25, 24, 23, 22, 21, 20]:
        inds = Num.nonzero(cand_symbols == ii)[0]
        ppgplot.pgshls(1, 0.0, 0.5, 0.0)
        ppgplot.pgpt(times[inds], dms[inds], ii)
    for ii in [26, 25, 24, 23, 22, 21, 20]:
        inds_1 = Num.nonzero(cand_symbols_group == ii)[0]
        if xwin:
            ppgplot.pgshls(1, 0.0, 0.8, 0.0)
        else:
            ppgplot.pgshls(1, 0.0, 0.0, 0.0)
        ppgplot.pgpt(time_arr[inds_1], dm_arr[inds_1], ii)
Esempio n. 15
0
def dm_time_plot(dms, times, sigmas, dm_arr, sigma_arr, time_arr, Total_observed_time, xwin):
    """
    Plot DM vs Time.
    """
    min_dm = Num.min(dms)
    max_dm = Num.max(dms)
    ppgplot.pgsvp(0.48, 0.97, 0.1, 0.54)
    ppgplot.pgswin(0, Total_observed_time, min_dm, max_dm)
    ppgplot.pgsch(0.8)
    ppgplot.pgslw(3)
    ppgplot.pgbox("BCNST", 0, 0, "BCNST", 0, 0)
    ppgplot.pgslw(3)
    ppgplot.pgmtxt('B', 2.5, 0.5, 0.5, "Time (s)")
    ppgplot.pgmtxt('L', 1.8, 0.5, 0.5, "DM (pc cm\u-3\d)")
    snr_range = 12.0
    cand_symbols = []
    cand_symbols_group = []
    for i in range(len(sigmas)):
        if sigmas[i] > 20.00:
            sigmas[i] = 20.0
        cand_symbol = int((sigmas[i] - 5.0)/snr_range * 6.0 + 20.5)
        cand_symbols.append(min(cand_symbol, 26))
    cand_symbols = Num.array(cand_symbols)
    for i in range(len(dm_arr)):
        cand_symbol = int((sigma_arr[i] - 5.0)/snr_range * 6.0 + 20.5)
        cand_symbols_group.append(min(cand_symbol, 26))
    cand_symbols_group = Num.array(cand_symbols_group)
    dms = Num.array(dms)
    times = Num.array(times)
    dm_arr = Num.array(dm_arr)
    time_arr = Num.array(time_arr)
    for ii in [26, 25, 24, 23, 22, 21, 20]:
        inds = Num.nonzero(cand_symbols == ii)[0]
        ppgplot.pgshls(1, 0.0, 0.5, 0.0)
        ppgplot.pgpt(times[inds], dms[inds], ii)
    for ii in [26, 25, 24, 23, 22, 21, 20]:
        inds_1 = Num.nonzero(cand_symbols_group == ii)[0]
        if xwin:
            ppgplot.pgshls(1, 0.0, 0.8, 0.0)
        else:
            ppgplot.pgshls(1, 0.0, 0.0, 0.0)
        ppgplot.pgpt(time_arr[inds_1], dm_arr[inds_1], ii)
Esempio n. 16
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)
Esempio n. 17
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)
Esempio n. 18
0
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()
Esempio n. 19
0
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()
Esempio n. 20
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)
Esempio n. 21
0
def plotngalsigmaradcuts():
    nr = 1.
    nv = 3.
    bbJmax = -18.
    ppgplot.pgbeg("ngalmhalo-radcut.ps/vcps", 1, 1)  #color port.
    ppgplot.pgpap(8., 1.25)
    ppgplot.pgpage
    ppgplot.pgsch(1.2)  #font size
    ppgplot.pgslw(3)  #line width

    # 1st panel with symbols w/ stddev errorbars

    str1 = "R\dp\u < "
    str2 = " R\dv\u"
    x1 = .1
    x2 = .45
    x3 = .6
    x4 = .95
    y1 = .15
    y2 = .425
    y3 = .575
    y4 = .85
    xlabel = 14.25 - 14.
    ylabel = 1.14
    ppgplot.pgsvp(x1, x2, y3, y4)  #sets viewport
    g.cutonlbj(bbJmax)
    #print "within plotradcuts, after cutonlbj, len(g.x1) = ",len(g.x1)
    nr = 1.
    c.measurengalcontam(nv, nr, g)
    #print "nr = ",nr, " ave contam = ",N.average(c.contam)
    sub1plotngalmcl(c.mass, c.membincut, c.obsmembincut)
    ppgplot.pgsch(.8)
    ppgplot.pgslw(3)
    #label="R\dp\u < "+str(nr)+"R\dv\u"
    label = str1 + str(nr) + str2
    ppgplot.pgtext(xlabel, ylabel, label)

    nr = .5
    ppgplot.pgsvp(x1, x2, y1, y2)  #sets viewport
    #ppgplot.pgpanl(1,1)
    c.measurengalcontam(nv, nr, g)
    #print "nr = ",nr, " ave contam = ",N.average(c.contam)
    sub1plotngalmcl(c.mass, c.membincut, c.obsmembincut)
    label = str1 + str(nr) + str2
    ppgplot.pgsch(.8)
    ppgplot.pgslw(3)
    ppgplot.pgtext(xlabel, ylabel, label)

    ppgplot.pgend()
Esempio n. 22
0
def sub1plotngalmcl(x, y1, y2):
    schdef = 1.2
    slwdef = 4
    ppgplot.pgsch(schdef)
    xmin = -.5
    xmax = 1.
    ymin = 0.
    ymax = 60.
    #nbin=5
    ppgplot.pgslw(slwdef)  #line width
    ppgplot.pgswin(xmin, xmax, ymin, ymax)  #axes limits
    ppgplot.pgbox('bcnlst', 1.0, 0, 'bcvnst', 10., 2)  #tickmarks and labeling
    ppgplot.pgmtxt(
        'b', 2.5, 0.5, 0.5,
        "log\d10\u(10\u14\d M\dhalo\u/h\u-1\d M\d\(2281)\u)")  #xlabel
    ppgplot.pgmtxt('l', 2.1, 0.5, 0.5, "N\dgal\u")

    (xbin, ybin, ybinerr) = my.biniterr(x, y1, nbin)
    print y1
    print 'ybin for y1 = ', ybin

    xbin = N.log10(
        xbin) + 12. - 14.  #add back 10^12 Msun, then divide by 10^14
    ppgplot.pgsch(1.5)
    ppgplot.pgpt(xbin, ybin, 7)
    ppgplot.pgslw(3)
    ppgplot.pgerrb(6, xbin, ybin, ybinerr, 2.)
    #my.errory(xbin,ybin,ybinerr)
    (xbin, ybin, ybinerr) = my.biniterr(x, y2, nbin)
    print y2
    print 'ybin = ', ybin

    xbin = N.log10(
        xbin) + 12. - 14.  #add back 10^12 Msun, then divide by 10^14
    ppgplot.pgsch(1.75)
    ppgplot.pgpt(xbin, ybin, 17)
    ppgplot.pgsch(schdef)
    ppgplot.pgerrb(6, xbin, ybin, ybinerr, 2.)
    ppgplot.pgslw(slwdef)
Esempio n. 23
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()
Esempio n. 24
0
def setmask(command, data, cdata):
    """
    Sets the mask on a dset and dumps a file containing the mask which can be applied
    to other dsets using 'appmask'. This is an interactive routine which will request
    input from the user and is better not used in batch processing. Repeated calls of
    this routine can be used to build complex masks. The masks are always applied in
    the original order so that you can mask then partially unmask for example. Note that
    whatever slot you choose to define the mask will always end up masked; if you don't
    want this you may want to make a copy.

    Interactive usage:

    setmask slot mfile append [device reset x1 x2 y1 y2] mask type

    Arguments:

    slot      -- an example slot to plot.
    mfile     -- mask file
    append    -- append to an old mask file if possible
    device    -- plot device, e.g. '/xs'
    reset     -- rest plot limits or not
    x1        -- left X plot limit
    x2        -- right X plot limit
    y1        -- bottom Y plot limit
    y2        -- top Y plot limit
    mask      -- mask 'M', or unmask 'U' or quit 'Q'.
    type      -- type of mask: 'X' masks using ranges in X

    Mask types:

    X  -- mask a range in X
    Y  -- mask a range in Y
    I  -- mask a range of pixel indices
    P  -- mask in 'phase', i.e. a range that repeats periodically.
    """

    import trm.dnl.mask as mask

    # generate arguments
    inpt = inp.Input(DINT_ENV, DINT_DEF, inp.clist(command))

    # register parameters
    inpt.register('slot',   inp.Input.LOCAL, inp.Input.PROMPT)
    inpt.register('mfile',  inp.Input.GLOBAL,  inp.Input.PROMPT)
    inpt.register('append', inp.Input.LOCAL,  inp.Input.PROMPT)
    inpt.register('device', inp.Input.LOCAL,  inp.Input.HIDE)
    inpt.register('reset',  inp.Input.LOCAL,  inp.Input.HIDE)
    inpt.register('x1',     inp.Input.LOCAL,  inp.Input.HIDE)
    inpt.register('x2',     inp.Input.LOCAL,  inp.Input.HIDE)
    inpt.register('y1',     inp.Input.LOCAL,  inp.Input.HIDE)
    inpt.register('y2',     inp.Input.LOCAL,  inp.Input.HIDE)
    inpt.register('mask',   inp.Input.LOCAL,  inp.Input.PROMPT)
    inpt.register('type',   inp.Input.LOCAL,  inp.Input.PROMPT)

    # get inputs
    slots  = inpt.get_value('slot', 'slot to plot for mask definition', '1')
    slist  = interp_slots(slots, True, data, nfind=1)
    dset   = data[slist[0]]

    device = inpt.get_value('device', 'plot device', '/xs')

    # mask file
    mfile  = inpt.get_value('mfile',  'mask file to save results to', subs.Fname('mask','.msk', subs.Fname.NEW))
    append = inpt.get_value('append', 'add to an old mask file if possible', True)

    if append and mfile.exists():
        mptr  = open(mfile,'rb')
        gmask = pickle.load(mptr)
        gmask.app_mask(dset)
        mptr.close()
    else:
        gmask = mask.Gmask()

    # other parameters
    reset = inpt.get_value('reset',   'reset plot limits automatically?', True)

    # compute default limits
    (x1,x2,y1,y2) = dset.plimits()
    if (x2 - x1) < (x1+x2)/2./100.:
        xoff = x1
        x1   = 0.
        x2  -= xoff
    else:
        xoff = 0.
    yoff = 0.

    if reset:
        inpt.set_default('x1', x1)
        inpt.set_default('x2', x2)
        inpt.set_default('y1', y1)
        inpt.set_default('y2', y2)

    x1 = inpt.get_value('x1', 'left-hand limit of plot', x1)
    x2 = inpt.get_value('x2', 'right-hand limit of plot', x2)
    y1 = inpt.get_value('y1', 'bottom limit of plot', y1)
    y2 = inpt.get_value('y2', 'top limit of plot', y2)

    m_or_u    = inpt.get_value('mask', 'M(ask), U(nmask) or Q(uit)?', 'm', lvals=['m', 'M', 'u', 'U', 'q', 'Q'])
    if m_or_u.upper() == 'M':
        mtext = 'mask'
    else:
        mtext = 'unmask'

    mask_type = inpt.get_value('type', 'X, Y, P(hase), I(ndex) or Q(uit)?', 'x',
                               lvals=['x', 'X', 'y', 'Y', 'p', 'P', 'i', 'I', 'q', 'Q'])

    # initialise plot
    try:
        pg.pgopen(device)
        pg.pgsch(1.5)
        pg.pgscf(2)
        pg.pgslw(2)
        pg.pgsci(4)
        pg.pgenv(x1,x2,y1,y2,0,0)
        (xlabel,ylabel) = dset.plabel(xoff,yoff)
        pg.pgsci(2)
        pg.pglab(xlabel, ylabel, dset.title)

        # plot the dset
        dset.plot(xoff,yoff)

        x = (x1+x2)/2.
        y = (y1+y2)/2.

        # now define masks
        ch = 'X'
        while ch.upper() != 'Q':

            # go through mask options
            if mask_type.upper() == 'X':

                print('Set cursor at the one end of the X range, Q to quit')
                (xm1,y,ch) = pg.pgband(7,0,x,y)
                if ch.upper() != 'Q':
                    print('Set cursor at the other end of ' +
                          'the X range, Q to quit')
                    xm2,y,ch = pg.pgband(7,0,xm1,y)
                    if ch.upper() != 'Q':
                        if xm1 > xm2: xm1,xm2 = xm2,xm1
                        umask = mask.Xmask(xoff+xm1, xoff+xm2, m_or_u.upper() == 'M')

            elif mask_type.upper() == 'I':

                print('Place cursor near a point and click to ' +
                      mtext + ' it, Q to quit')
                x,y,ch = pg.pgband(7,0,x,y)
                if ch.upper() != 'Q':
                    xmm1,xmm2,ymm1,ymm2 = pg.pgqvp(2)
                    xscale  = (xmm2-xmm1)/(x2-x1)
                    yscale  = (ymm2-ymm1)/(y2-y1)

                    # only consider good data of opposite 'polarity' to the
                    # change we are making.
                    ok  = (dset.good == True) & \
                          (dset.mask == (m_or_u.upper() == 'M'))

                    if len(dset.x.dat[ok == True]):
                        # compute physical squared distance of cursor from
                        # points
                        sqdist  = npy.power(
                            xscale*(dset.x.dat[ok]-(xoff+x)),2) + \
                            npy.power(yscale*(dset.y.dat[ok]-(yoff+y)),2)

                        # select the index giving the minimum distance
                        indices = npy.arange(len(dset))[ok]
                        index   = indices[sqdist.min() == sqdist][0]
                        umask   = mask.Imask(index, m_or_u.upper() == 'M')
                    else:
                        print('There seem to be no data to ' + mtext +
                              '; data already ' + mtext + 'ed are ignored.')
                        umask = None

            if ch.upper() != 'Q' and umask is not None:
                gmask.append(umask)
                umask.app_mask(dset)

                print('overplotting data')
                # over-plot the dset
                dset.plot(xoff,yoff)

        pg.pgclos()
    except pg.ioerror, err:
        raise DintError(str(err))
Esempio n. 25
0
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)
Esempio n. 26
0
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)
Esempio n. 27
0
    else:
        l, b = w.wcs_pix2world([[x, y]], 1)[0]

    return l, b


if __name__ == "__main__":
    # Load stars
    s = Stars()

    # Load the master class
    m = Skymap()

    # Initialize plot
    ppgplot.pgopen("/xs")
    ppgplot.pgslw(2)
    ppgplot.pgpap(0.0, 0.75)

    # For ever loop
    redraw = True
    while True:
        # Redraw
        if redraw == True:
            # Update
            m.update()

            # Initialize window
            ppgplot.pgscr(0, 0., 0., 0.)
            ppgplot.pgeras()
            ppgplot.pgsvp(0.01, 0.99, 0.01, 0.99)
            ppgplot.pgwnad(-1.5 * m.w, 1.5 * m.w, -m.w, m.w)
Esempio n. 28
0
def prepplot(rangex, rangey, title=None, labx=None, laby=None, \
             rangex2=None, rangey2=None, labx2=None, laby2=None, \
             logx=0, logy=0, logx2=0, logy2=0, font=ppgplot_font_, \
             fontsize=ppgplot_font_size_, id=0, aspect=1, ticks='in', \
             panels=[1,1], device=ppgplot_device_):
    """
    prepplot(rangex, rangey, ...)
        Open a PGPLOT device for plotting.
            'rangex' and 'rangey' are sequence objects giving min and
                max values for each axis.
        The optional entries are:
            title:    graph title                 (default = None)   
            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))
            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)) 
            aspect:   Aspect ratio                (default = 1 (square))
            ticks:    Ticks point in or out       (default = 'in')   
            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_.
    """
    global ppgplot_dev_open_, ppgplot_dev_prep_
    # Check if we will use second X or Y axes
    # Note:  if using a 2nd X axis, the range should correspond
    #   to the minimum and maximum values of the 1st X axis.  If
    #   using a 2nd Y axis, the range should correspond to the
    #   scalerange() values of the 1st Y axis.
    if rangex2 is None:
        rangex2 = rangex
        otherxaxis = 0
    else:
        otherxaxis = 1
    if rangey2 is None:
        rangey2 = rangey
        otheryaxis = 0
    else:
        otheryaxis = 1
    # Open the plot device
    if (not ppgplot_dev_open_):
        ppgplot.pgopen(device)
        # Let the routines know that we already have a device open
        ppgplot_dev_open_ = 1
        # Set the aspect ratio
        ppgplot.pgpap(0.0, aspect)
        if (panels != [1, 1]):
            # Set the number of panels
            ppgplot.pgsubp(panels[0], panels[1])
            ppgplot.pgpage()
    # Choose the font
    ppgplot.pgscf(font)
    # Choose the font size
    ppgplot.pgsch(fontsize)
    # Choose the font size
    ppgplot.pgslw(ppgplot_linewidth_)
    # Plot the 2nd axis if needed first
    if otherxaxis or otheryaxis:
        ppgplot.pgvstd()
        ppgplot.pgswin(rangex2[0], rangex2[1], rangey2[0], rangey2[1])
        # Decide how the axes will be drawn
        if ticks == 'in': env = "CMST"
        else: env = "CMSTI"
        if logx2: lxenv = 'L'
        else: lxenv = ''
        if logy2: lyenv = 'L'
        else: lyenv = ''
        if otherxaxis and otheryaxis:
            ppgplot.pgbox(env + lxenv, 0.0, 0, env + lyenv, 0.0, 0)
        elif otheryaxis:
            ppgplot.pgbox("", 0.0, 0, env + lyenv, 0.0, 0)
        else:
            ppgplot.pgbox(env + lxenv, 0.0, 0, "", 0.0, 0)
    # Now setup the primary axis
    ppgplot.pgvstd()
    ppgplot.pgswin(rangex[0], rangex[1], rangey[0], rangey[1])
    # Decide how the axes will be drawn
    if ticks == 'in': env = "ST"
    else: env = "STI"
    if logx: lxenv = 'L'
    else: lxenv = ''
    if logy: lyenv = 'L'
    else: lyenv = ''
    if otherxaxis and otheryaxis:
        ppgplot.pgbox("BN" + env + lxenv, 0.0, 0, "BN" + env + lyenv, 0.0, 0)
    elif otheryaxis:
        ppgplot.pgbox("BCN" + env + lxenv, 0.0, 0, "BN" + env + lyenv, 0.0, 0)
    elif otherxaxis:
        ppgplot.pgbox("BN" + env + lxenv, 0.0, 0, "BCN" + env + lyenv, 0.0, 0)
    else:
        ppgplot.pgbox("BCN" + env + lxenv, 0.0, 0, "BCN" + env + lyenv, 0.0, 0)
    # Add labels
    if not title is None: ppgplot.pgmtxt("T", 3.2, 0.5, 0.5, title)
    ppgplot.pgmtxt("B", 3.0, 0.5, 0.5, labx)
    ppgplot.pgmtxt("L", 2.6, 0.5, 0.5, laby)
    if otherxaxis: ppgplot.pgmtxt("T", 2.0, 0.5, 0.5, labx2)
    if otheryaxis: ppgplot.pgmtxt("R", 3.0, 0.5, 0.5, laby2)
    # Add ID line if required
    if (id == 1): ppgplot.pgiden()
    # Let the routines know that we have already prepped the device
    ppgplot_dev_prep_ = 1
Esempio n. 29
0
def plot_rating_sheet(rating):
    """
    Plot a fact sheet on the ratings in the database corresponding to 'rating'.
    'rating' is a dictionary of information from the MySQL database (as returned
    by 'get_all_rating_types()'.
    """
    plot_utils.beginplot("rating_report%s.ps" % currdatetime.strftime('%y%m%d'), vertical=True)
    ch0 = ppgplot.pgqch()
    ppgplot.pgsch(0.5)
    ch = ppgplot.pgqch()
    ppgplot.pgsch(0.75)
    ppgplot.pgtext(0,1,"Rating Report for %s (%s) - page 1 of 2" % (rating["name"], currdatetime.strftime('%c')))
    ppgplot.pgsch(ch)
    
    # Plot Histograms
    
    all_ratings = get_ratings(rating["rating_id"]) 
    range = xmin,xmax = np.min(all_ratings), np.max(all_ratings)
    ppgplot.pgsci(1)
    ppgplot.pgslw(1)
    
    #===== Total/Classified/Unclassified
    # Get data
    ppgplot.pgsvp(0.1, 0.9, 0.75, 0.9)
    (tot_counts, tot_left_edges)=np.histogram(all_ratings, bins=NUMBINS, range=range)
    ppgplot.pgswin(xmin,xmax,0,np.max(tot_counts)*1.1)
    ppgplot.pgsch(0.5)
    ppgplot.pgbox("BCTS",0,5,"BCNTS",0,5)
    ppgplot.pgbin(tot_left_edges, tot_counts)
    (clsfd_counts, clsfd_left_edges)=np.histogram(get_ratings(rating["rating_id"], human_classification=(1,2,3,4,5,6,7)), bins=NUMBINS, range=range)
    ppgplot.pgsci(3) # plot classified in green
    ppgplot.pgbin(tot_left_edges, clsfd_counts)
    unclsfd_counts = tot_counts-clsfd_counts
    ppgplot.pgsci(2) # plot unclassified in red
    ppgplot.pgbin(tot_left_edges, unclsfd_counts)
    ppgplot.pgsci(1) # reset colour to black
    ppgplot.pgsch(0.75)
    ppgplot.pglab("","Counts","")

    #===== Class 1/2/3
    ppgplot.pgsvp(0.1, 0.9, 0.6, 0.75)
    (counts, left_edges)=np.histogram(get_ratings(rating["rating_id"], human_classification=(1,2,3)), bins=NUMBINS, range=range)
    ppgplot.pgswin(xmin,xmax,0,np.max(counts)*1.1)
    ppgplot.pgsch(0.5)
    ppgplot.pgbox("BCTS",0,5,"BCNTS",0,5)
    ppgplot.pgsci(1) # plot in black
    ppgplot.pgbin(tot_left_edges, counts)
    ppgplot.pgsci(1) # reset colour to black
    ppgplot.pgsch(0.75)
    ppgplot.pglab("","Class 1/2/3","")

    #===== RFI
    ppgplot.pgsvp(0.1, 0.9, 0.45, 0.6)
    rfi_ratings = get_ratings(rating["rating_id"], human_classification=(4,))
    (counts, left_edges)=np.histogram(rfi_ratings, bins=NUMBINS, range=range)
    ppgplot.pgswin(xmin,xmax,0,np.max(counts)*1.1)
    ppgplot.pgsch(0.5)
    ppgplot.pgbox("BCTS",0,5,"BCNTS",0,5)
    ppgplot.pgsci(1) # plot in black
    ppgplot.pgbin(tot_left_edges, counts)
    ppgplot.pgsci(1) # reset colour to black
    ppgplot.pgsch(0.75)
    ppgplot.pglab("","RFI","")

    #===== Noise
    ppgplot.pgsvp(0.1, 0.9, 0.3, 0.45)
    noise_ratings = get_ratings(rating["rating_id"], human_classification=(5,))
    (counts, left_edges)=np.histogram(noise_ratings, bins=NUMBINS, range=range)
    ppgplot.pgswin(xmin,xmax,0,np.max(counts)*1.1)
    ppgplot.pgsch(0.5)
    ppgplot.pgbox("BCTS",0,5,"BCNTS",0,5)
    ppgplot.pgsci(1) # plot in black
    ppgplot.pgbin(tot_left_edges, counts)
    ppgplot.pgsci(1) # reset colour to black
    ppgplot.pgsch(0.75)
    ppgplot.pglab("","Noise","")

    #===== Known/Harmonic
    ppgplot.pgsvp(0.1, 0.9, 0.15, 0.3)
    known_ratings = get_ratings(rating["rating_id"], human_classification=(6,7))
    (counts, left_edges)=np.histogram(known_ratings, bins=NUMBINS, range=range)
    ppgplot.pgswin(xmin,xmax,0,np.max(counts)*1.1)
    ppgplot.pgsch(0.5)
    ppgplot.pgbox("BCNTS",0,5,"BCNTS",0,5)
    ppgplot.pgsci(1) # plot in black
    ppgplot.pgbin(tot_left_edges, counts)
    ppgplot.pgsci(1) # reset colour to black
    ppgplot.pgsch(0.75)
    ppgplot.pglab(rating["name"],"Known/Harmonic","")

    #===== Second page for differential histograms
    plot_utils.nextpage(vertical=True)
    ppgplot.pgsch(0.75)
    ppgplot.pgtext(0,1,"Rating Report for %s (%s) - page 2 of 2" % (rating["name"], currdatetime.strftime('%c')))
    
    #===== RFI - Known
    ppgplot.pgsvp(0.1, 0.9, 0.75, 0.9)
    if rfi_ratings.size==0 or known_ratings.size==0:
        ppgplot.pgswin(0,1,0,1)
        ppgplot.pgbox("BC",0,0,"BC",0,0)
	ppgplot.pgsch(0.75)
        ppgplot.pglab("","RFI - Known","")
	ppgplot.pgsch(1.0)
	ppgplot.pgptxt(0.5, 0.5, 0.0, 0.5, "Not enough data")
    else:
        (known_counts, known_left_edges)=np.histogram(known_ratings, bins=NUMBINS, range=range, normed=True)
        (rfi_counts, rfi_left_edges)=np.histogram(rfi_ratings, bins=NUMBINS, range=range, normed=True)
        diff_counts = rfi_counts - known_counts
        ppgplot.pgswin(xmin,xmax,np.min(diff_counts)*1.1,np.max(diff_counts)*1.1)
	ppgplot.pgsch(0.5)
        ppgplot.pgbox("BCTS",0,5,"BCNTS",0,5)
        ppgplot.pgbin(tot_left_edges, diff_counts)
        ppgplot.pgsci(2) # set colour to red
        ppgplot.pgline(tot_left_edges, np.zeros_like(tot_left_edges))
        ppgplot.pgsci(1) # reset colour to black
	ppgplot.pgsch(0.75)
        ppgplot.pglab("","RFI - Known","")

    #===== RFI - Noise
    ppgplot.pgsvp(0.1, 0.9, 0.6, 0.75)
    if noise_ratings.size==0 or rfi_ratings.size==0:
        ppgplot.pgswin(0,1,0,1)
        ppgplot.pgbox("BC",0,0,"BC",0,0)
	ppgplot.pgsch(0.75)
        ppgplot.pglab("","RFI - Noise","")
	ppgplot.pgsch(1.0)
	ppgplot.pgptxt(0.5, 0.5, 0.0, 0.5, "Not enough data")
    else:
        (noise_counts, noise_left_edges)=np.histogram(noise_ratings, bins=NUMBINS, range=range, normed=True)
        (rfi_counts, rfi_left_edges)=np.histogram(rfi_ratings, bins=NUMBINS, range=range, normed=True)
        diff_counts = rfi_counts - noise_counts
        ppgplot.pgswin(xmin,xmax,np.min(diff_counts)*1.1,np.max(diff_counts)*1.1)
	ppgplot.pgsch(0.5)
        ppgplot.pgbox("BCTS",0,5,"BCNTS",0,5)
        ppgplot.pgbin(tot_left_edges, diff_counts)
        ppgplot.pgsci(2) # set colour to red
        ppgplot.pgline(tot_left_edges, np.zeros_like(tot_left_edges))
        ppgplot.pgsci(1) # reset colour to black
	ppgplot.pgsch(0.75)
        ppgplot.pglab("","RFI - Noise","")

    #===== Known - Noise
    ppgplot.pgsvp(0.1, 0.9, 0.45, 0.6)
    if noise_ratings.size==0 or known_ratings.size==0:
        ppgplot.pgswin(0,1,0,1)
        ppgplot.pgbox("BC",0,0,"BC",0,0)
	# Y-axis label is taken care of outside of if/else (below)
	ppgplot.pgsch(1.0)
	ppgplot.pgptxt(0.5, 0.5, 0.0, 0.5, "Not enough data")
    else:
        (noise_counts, noise_left_edges)=np.histogram(noise_ratings, bins=NUMBINS, range=range, normed=True)
        (known_counts, known_left_edges)=np.histogram(known_ratings, bins=NUMBINS, range=range, normed=True)
        diff_counts = known_counts - noise_counts
        ppgplot.pgswin(xmin,xmax,np.min(diff_counts)*1.1,np.max(diff_counts)*1.1)
	ppgplot.pgsch(0.5)
        ppgplot.pgbox("BCNTS",0,5,"BCNTS",0,5)
        ppgplot.pgbin(tot_left_edges, diff_counts)
        ppgplot.pgsci(2) # set colour to red
        ppgplot.pgline(tot_left_edges, np.zeros_like(tot_left_edges))
        ppgplot.pgsci(1) # reset colour to black
    ppgplot.pgswin(xmin,xmax,0,1)
    ppgplot.pgsch(0.5)
    ppgplot.pgbox("NTS",0,5,"",0,0)
    ppgplot.pgsch(0.75)
    ppgplot.pglab(rating["name"],"Known - Noise","")
    
    ppgplot.pgsch(ch0) # reset character height
Esempio n. 30
0
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)
Esempio n. 31
0
ppgplot.pgline(fdotcut, zs)
ppgplot.pgmtxt("B", 2.4, 0.5, 0.5, "Relative Power");

# f-fdot image
ppgplot.pgsvp(margin, margin+imfract, margin, margin+imfract)
ppgplot.pgswin(min(rs), max(rs), min(zs), max(zs))
ppgplot.pgmtxt("B", 2.4, 0.5, 0.5, labx);
ppgplot.pgmtxt("L", 2.0, 0.5, 0.5, laby);
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)
ppgplot.pgimag_s(pffdot, 0.0, 0.0, rgx[0], rgy[0], rgx[1], rgy[1])  
ppgplot.pgsci(1)
ppgplot.pgcont_s(pffdot, len(contours), contours, rgx[0], rgy[0], rgx[1], rgy[1])  
ppgplot.pgbox("BCST", 0.0, 0, "BCST", 0.0, 0)
ppgplot.pgsci(1)
ppgplot.pgbox("N", 0.0, 0, "N", 0.0, 0)

# gray axes
ppgplot.pgscr(1, 0.5, 0.5, 0.5)
ppgplot.pgsci(1)
ppgplot.pgslw(2)
ppgplot.pgline(rgx, num.asarray([0.0, 0.0]))
ppgplot.pgline(num.asarray([0.0, 0.0]), rgy)

ppgplot.pgclos()


Esempio n. 32
0
		ppgplot.pgpap(10, 0.618)
		ppgplot.pgask(arg.ask)
		
		for index, photometry in enumerate(allData):
			x_values = photometry[xColumn]
			y_values = photometry[yColumn]
			y_errors = photometry[yErrors]
			x_lower, x_upper = (min(x_values), max(x_values))
			numpoints = len(x_values)
			if "JD" in xColumn:
				x_offset = int(x_lower)
				x_values = [(x-x_offset) for x in x_values]
				xLabel= xColumn + " - %d"%x_lower
			ppgplot.pgsci(1)
			ppgplot.pgenv(min(x_values), max(x_values), lowerY, upperY, 0, 0)
			ppgplot.pgslw(7)
			ppgplot.pgpt(x_values, y_values, 1)
			ppgplot.pgslw(1)
			ppgplot.pgerrb(2, x_values, y_values, y_errors, 0)
			ppgplot.pgerrb(4, x_values, y_values, y_errors, 0)
			ppgplot.pglab(xLabel, yLabel, photometry["runName"])
			
		ppgplot.pgclos()
	if not hasEphemeris:
		sys.exit()
	
				
	# Restrict the light-curve to a subset of phase
	phaseLimits = (0.51, 0.70)
	for photometry in allData:
		pnew = []
Esempio n. 33
0
# Plot A (Airmass-Time)
########################
# PS OUTPUT 
###############################################################
filename=sys.argv[1]
psfile = str(filename)+".ps" # print ("psfile\n")
ppgplot.pgbegin(0,"psfile/VCPS", 1, 1)
# pgbegin(0,"psfile/PS", 1, 1)

# Plot Setting
####################################################################
ppgplot.pgpaper(8,1.25) # window/paper size (width(inch), aspect)

ppgplot.pgscf(2)   # characte font (1: normal, 2: roman, 3: italic, 4: script)
ppgplot.pgslw(3) # line width
ppgplot.pgsvp(0.15, 0.9, 0.53, 0.89) # viewport in the window (relative)
ppgplot.pglab("", "", "Local Time [hour]")
ppgplot.pgsvp(0.12, 0.9, 0.53, 0.88) # viewport in the window (relative)
ppgplot.pglabel("", "Airmass", "") # label settingoto s

ppgplot.pgsch(1.0) # character height (size)
ppgplot.pgslw(3) # line width
ppgplot.pgsvp(0.15, 0.9, 0.53, 0.88) # viewport in the window (relative)
ppgplot.pgswin(t_min, t_max, a_max, a_min) # MIN,MAX of coordinate

ppgplot.pgbox('BCTS', 0.0, 0, 'BCTSNV1', 0.1, 0) # coordinate settings
ppgplot.pgbox('0', 0.0, 0, 'BCTSMV1', 0.1, 0) # coordinate settings

# Put Header/ Axes Label
#####################################################################
Esempio n. 34
0
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)
Esempio n. 35
0
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()
Esempio n. 36
0
def prepplot(rangex, rangey, title=None, labx=None, laby=None, \
             rangex2=None, rangey2=None, labx2=None, laby2=None, \
             logx=0, logy=0, logx2=0, logy2=0, font=ppgplot_font_, \
             fontsize=ppgplot_font_size_, id=0, aspect=1, ticks='in', \
             panels=[1,1], device=ppgplot_device_):
    """
    prepplot(rangex, rangey, ...)
        Open a PGPLOT device for plotting.
            'rangex' and 'rangey' are sequence objects giving min and
                max values for each axis.
        The optional entries are:
            title:    graph title                 (default = None)   
            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))
            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)) 
            aspect:   Aspect ratio                (default = 1 (square))
            ticks:    Ticks point in or out       (default = 'in')   
            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_.
    """
    global ppgplot_dev_open_, ppgplot_dev_prep_
    # Check if we will use second X or Y axes
    # Note:  if using a 2nd X axis, the range should correspond
    #   to the minimum and maximum values of the 1st X axis.  If
    #   using a 2nd Y axis, the range should correspond to the
    #   scalerange() values of the 1st Y axis.
    if rangex2 is None:
        rangex2=rangex
        otherxaxis=0
    else: otherxaxis=1
    if rangey2 is None:
        rangey2=rangey
        otheryaxis=0
    else: otheryaxis=1
    # Open the plot device
    if (not ppgplot_dev_open_):
        ppgplot.pgopen(device)
	# My little add-on to switch the background to white
	if device == '/XWIN':
	    reset_colors()
	if device == '/AQT':
	    ppgplot.pgsci(0)
        # Let the routines know that we already have a device open
        ppgplot_dev_open_ = 1
        # Set the aspect ratio
        ppgplot.pgpap(0.0, aspect)
        if (panels != [1,1]):
            # Set the number of panels
            ppgplot.pgsubp(panels[0], panels[1])
            ppgplot.pgpage()
    # Choose the font  
    ppgplot.pgscf(font)
    # Choose the font size
    ppgplot.pgsch(fontsize)
    # Choose the font size
    ppgplot.pgslw(ppgplot_linewidth_)
    # Plot the 2nd axis if needed first
    if otherxaxis or otheryaxis:
        ppgplot.pgvstd()
        ppgplot.pgswin(rangex2[0], rangex2[1], rangey2[0], rangey2[1])
        # Decide how the axes will be drawn
        if ticks=='in': env = "CMST"
        else: env = "CMSTI"
        if logx2: lxenv='L'
        else: lxenv=''
        if logy2: lyenv='L'
        else: lyenv=''
        if otherxaxis and otheryaxis:
            ppgplot.pgbox(env+lxenv, 0.0, 0, env+lyenv, 0.0, 0)
        elif otheryaxis:
            ppgplot.pgbox("", 0.0, 0, env+lyenv, 0.0, 0)
        else:
            ppgplot.pgbox(env+lxenv, 0.0, 0, "", 0.0, 0)
    # Now setup the primary axis
    ppgplot.pgvstd()
    ppgplot.pgswin(rangex[0], rangex[1], rangey[0], rangey[1])
    # Decide how the axes will be drawn
    if ticks=='in': env = "ST"
    else: env = "STI"
    if logx: lxenv='L'
    else: lxenv=''
    if logy: lyenv='L'
    else: lyenv=''
    if otherxaxis and otheryaxis:
        ppgplot.pgbox("BN"+env+lxenv, 0.0, 0, "BN"+env+lyenv, 0.0, 0)
    elif otheryaxis:
        ppgplot.pgbox("BCN"+env+lxenv, 0.0, 0, "BN"+env+lyenv, 0.0, 0)
    elif otherxaxis:
        ppgplot.pgbox("BN"+env+lxenv, 0.0, 0, "BCN"+env+lyenv, 0.0, 0)
    else:
        ppgplot.pgbox("BCN"+env+lxenv, 0.0, 0, "BCN"+env+lyenv, 0.0, 0)
    # My little add-on to switch the background to white
    if device == '/AQT' or device == '/XWIN':
	reset_colors()
    # Add labels
    if not title is None: ppgplot.pgmtxt("T", 3.2, 0.5, 0.5, title)
    ppgplot.pgmtxt("B", 3.0, 0.5, 0.5, labx)
    ppgplot.pgmtxt("L", 2.6, 0.5, 0.5, laby)
    if otherxaxis: ppgplot.pgmtxt("T", 2.0, 0.5, 0.5, labx2)
    if otheryaxis: ppgplot.pgmtxt("R", 3.0, 0.5, 0.5, laby2)
    # Add ID line if required
    if (id==1): ppgplot.pgiden()
    # Let the routines know that we have already prepped the device
    ppgplot_dev_prep_ = 1
Esempio n. 37
0
def psplotinit(output):
    file=output+"/vcps"
    ppgplot.pgbeg(file,1,1)
    ppgplot.pgpap(8.,1.)
    ppgplot.pgsch(1.7) #font size
    ppgplot.pgslw(7)  #line width
Esempio n. 38
0
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)
Esempio n. 39
0
#os.system("sex j+n.fits,ncc105jalign3.fits \n")
os.system("sex ncc105jalign3.fits \n")
#os.system("sex c1054j2cna.fits \n")
im1 = Catalog()
im1.readcat()
#os.system("sex cnc105jalign2.fits,c1054j2cna.fits \n")
#os.system("sex j+n.fits,c1054j2cna.fits \n")
#os.system("sex c1054j2cna.fits,gediscsj.fits -MAG_ZEROPOINT 23.88\n")
#os.system("sex ncc105jalign3.fits,gediscsj.fits -MAG_ZEROPOINT 22.84\n")
os.system("sex ncc105jalign3.fits,ngdim20_mp.fits\n")
im2 = Catalog()
im2.readcat()

ppgplot.pgbeg("all.ps/vcps", 2, 2)
ppgplot.pgsch(2.)  #font size
ppgplot.pgslw(4)  #line width

xysimple(im1.magauto, im2.magauto, "magauto mask", "magauto")
ppgplot.pgpage
y = im1.magauto - im2.magauto
ave = N.average(y)
std = scipy.stats.std(y)
print "Ave diff in mag auto = ", ave, "+/-", std
xysimple(im1.magauto, y, "magauto mask", "magauto mask - magauto")
ppgplot.pgpage
y = im1.magiso - im2.magiso
ave = N.average(y)
std = scipy.stats.std(y)
print "Ave diff in iso mags = ", ave, "+/-", std
xysimple(im1.magiso, y, "magiso mask", "magiso mask - magiso")
ppgplot.pgpage