Example #1
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)
Example #2
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()
Example #3
0
def plot_report_coversheet(rating_objects):
    """
    'rating_objects' is a list of DatabaseRater objects.
    """
    ppgplot.pgtext(0,1,"Demo Ratings Report (%s)" % currdatetime.strftime('%c'))

    top = 0.9
    for r in rating_objects:
	formatted_description = ' '.join([line.strip() for line in r.description.splitlines()])
	formatted_name = ("%s:" % r.name).ljust(LINELENGTH-1)
	text = ("%s %s" % (formatted_name, formatted_description))
	lines = []
	while text:
	    if len(text) > LINELENGTH:
		index = text.rfind(' ',0, LINELENGTH)
		lines.append(text[0:index])
		text = text[index+1:]
	    else:
		lines.append(text)
		text = ''
	if (top - len(lines)*LINESPACING) < 0:
	    # text will spill over bottom of page
	    plot_utils.nextpage(vertical=True)
	    ppgplot.pgtext(0,1,"Demo Ratings Report (%s) (cont'd)" % currdatetime.strftime('%c'))
	    top = 0.9
	for line in lines:
	    ppgplot.pgtext(0,top, line)
	    top -= LINESPACING
	top -= PARASPACING
Example #4
0
def plot_candidate_sheet(rating_objects, pdm_cand_id, cand_ratings, description):
    plot_utils.beginplot("cand_rating_report%s(%d).ps" % (currdatetime.strftime('%y%m%d'),pdm_cand_id), vertical=True)
    ppgplot.pgtext(0,1,"%d: %s" % (pdm_cand_id, description))
    top = 0.5
    first = True
    for ratobj, rating in zip(rating_objects,cand_ratings):
	if (top - PARASPACING) < 0:
	    if first:
		#
		# Add P, DM, subints, subbands?
		#
                pfd = rating_utils.get_pfd_by_cand_id(pdm_cand_id)
                prof = rating_utils.prep_profile(pfd)
                ppgplot.pgsvp(0.10, 0.90, 0.60, 0.90)
                ppgplot.pgswin(0, NUMPHASE, 1.1*np.min(prof), 1.1*np.max(prof))
                ppgplot.pgbox('BCNTS', 0.25,5,'BC',0.0,0)
		onephase = np.linspace(0,1,prof.size, endpoint=False)
		manyphase = np.resize(onephase,prof.size*NUMPHASE)+np.arange(0,NUMPHASE).repeat(prof.size)
                ppgplot.pgline(manyphase, np.resize(prof, (NUMPHASE*prof.size,)))
		first = False
	    plot_utils.nextpage(vertical=True)
	    ppgplot.pgtext(0,1,"%d: %s (cont'd)" % (pdm_cand_id, description))
	    top = 0.9
	ppgplot.pgtext(0,top, '%s: %s' % (ratobj.name, rating))
	top -= PARASPACING
    if first:
	pfd = rating_utils.get_pfd_by_cand_id(pdm_cand_id)
        prof = rating_utils.prep_profile(pfd)
        ppgplot.pgsvp(0.10, 0.90, 0.60, 0.90)
        ppgplot.pgswin(0, NUMPHASE, 1.1*np.min(prof), 1.1*np.max(prof))
        ppgplot.pgbox('BCNTS', 0.25,5,'BC',0.0,0)
        ppgplot.pgline(np.linspace(0,NUMPHASE,prof.size*NUMPHASE), np.resize(prof, (NUMPHASE*prof.size,)))
Example #5
0
def linelabel(xlabel, ylabel, dx, ystep, dxl, dyl, label):  #draw key
    schdef = ppgplot.pgqch()
    ppgplot.pgsch(1.1)
    ppgplot.pgtext(xlabel, ylabel, label)
    ppgplot.pgsch(1.1)
    ylabel = ylabel - 2. * ystep
    xs = N.arange(xlabel, (xlabel + dx), .01)
    ys = ylabel * N.ones(len(xs), 'd')
    ppgplot.pgsls(1)
    ppgplot.pgline(xs, ys)
    ppgplot.pgtext((xlabel + dxl + dx), (ylabel - dyl), "Memb")
    ylabel = ylabel - ystep
    ys = ylabel * N.ones(len(xs), 'd')
    ppgplot.pgsls(4)
    ppgplot.pgline(xs, ys)
    ppgplot.pgtext((xlabel + dxl + dx), (ylabel - dyl), "Contam")
    ppgplot.pgsch(schdef)
    ppgplot.pgsls(1)
def main(args):
    with open(os.path.join(os.path.dirname(__file__),
        'precisiondata.cpickle')) as filedata:
        exptimes, crosspoints, satpoints = pickle.load(filedata)

    x_range = [9, 14]

    interpcross = interp1d(exptimes, crosspoints, kind='linear')
    interpsat = interp1d(exptimes, satpoints, kind='linear')


    N = 5
    colours = np.arange(2, 2 + N, 1)
    exptimes = np.arange(1, N + 1) * 10
    if args.besancon:
        all_vmags = get_besancon_mag_data()
        yhigh = 0.3
        title = 'Besancon'
    else:
        all_vmags = get_nomad_mag_data()
        yhigh = 0.4
        title = 'NOMAD'

    ytot = yhigh * len(all_vmags)


    with pgh.open_plot(args.output):

        pg.pgvstd()


        pg.pgswin(x_range[0], x_range[1], 0, yhigh)
        for exptime, colour in zip(exptimes, colours):
            satpoint = interpsat(exptime)
            crosspoint = interpcross(exptime)

            selected = all_vmags[(all_vmags > satpoint) & (all_vmags <=
                crosspoint)]
            print(exptime, len(selected))


            xdata, ydata = cumulative_hist(np.array(selected),
                    min_val=x_range[0], max_val=x_range[1], norm=len(all_vmags))
            ydata /= float(len(all_vmags))

            with pgh.change_colour(colour):
                pg.pgbin(xdata, ydata, False)


        pg.pgbox('bcnst', 0, 0, 'bcnst', 0, 0)
        pg.pglab(r'V magnitude', 'High precision fraction', title)
        # Label the right hand side
        pg.pgswin(x_range[0], x_range[1], 0, ytot)
        pg.pgbox('', 0, 0, 'smt', 0, 0)
        pg.pgmtxt('r', 2., 0.5, 0.5, 'N')

        # Create the legend
        pg.pgsvp(0.7, 0.9, 0.1, 0.3)
        pg.pgswin(0., 1., 0., 1.)

        for i, (exptime, colour) in enumerate(zip(exptimes, colours)):
            yval = 0.1 + 0.8 * i / len(exptimes)

            with pgh.change_colour(colour):
                pg.pgline(np.array([0.2, 0.4]), np.ones(2) * yval)

            pg.pgtext(0.5, yval, r'{:d} s'.format(exptime))
Example #7
0
    for phase in numpy.arange(0.5, 1.51, 0.01):
        theta = computeViewingAngle(phase, inclination, beta, phi)
        phaseArray.append(phase)
        angleArray.append(theta)

    mainPlotWindow = ppgplot.pgopen("/xs")
    ppgplot.pgask(False)
    pgPlotTransform = [0, 1, 0, 0, 0, 1]
    ppgplot.pgsci(1)
    ppgplot.pgenv(min(phaseArray), max(phaseArray), 0, 180, 0, 0)
    ppgplot.pgline(phaseArray, angleArray)
    ppgplot.pgsls(2)
    ppgplot.pgline([0.5, 1.5], [90, 90])
    ppgplot.pglab("orbital phase", "viewing angle",
                  "Viewing angle \gh as a function of orbital phase.")
    ppgplot.pgtext(0.6, 150,
                   "i:%2.0f \gb:%2.0f \gf:%2.0f" % (inclination, beta, phi))

    modelPlotWindow = ppgplot.pgopen("models_i_81_b_40.ps/ps")
    pgPlotTransform = [0, 1, 0, 0, 0, 1]
    ppgplot.pgask(False)
    mainFluxMax = 0
    mainFluxMin = 1E99

    for phase in numpy.arange(0.5, 1.6, 0.1):

        ppgplot.pgsci(1)
        theta = computeViewingAngle(phase, inclination, beta, phi)
        intensities = ["i", "i_0", "i_1"]
        lineStyles = [1, 2, 3]

        index = 0
Example #8
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()
Example #9
0
 superMax = numpy.ma.max(superPixel)
 superMin = numpy.ma.min(superPixel)
 variance = numpy.ma.var(superPixel)
 numPixels = numpy.ma.count(superPixel)
 print(
     "[%d, %d] \tmax: %d \tmin: %d \t variance: %f \t variance/pixel: %f"
     % (position[1], position[0], superMax, superMin, variance,
        variance / numPixels))
 ppgplot.pgslct(spPreview['pgplotHandle'])
 boostedPreview = generalUtils.percentiles(superPixel, 20, 99)
 ppgplot.pggray(boostedPreview, 0, superPixelSize - 1, 0,
                superPixelSize - 1, 0, 255,
                imagePlot['pgPlotTransform'])
 ppgplot.pgsci(0)
 ppgplot.pgsch(5)
 ppgplot.pgtext(1, 2, "max: %d" % superMax)
 ppgplot.pgslct(imagePlot['pgplotHandle'])
 pointingObject = {'x': position[1], 'y': position[0]}
 pointings.append(pointingObject)
 ppgplot.pgsfs(2)
 ppgplot.pgsci(5)
 ppgplot.pgcirc(position[1], position[0], radius)
 xpts = [
     startX, startX, startX + superPixelSize,
     startX + superPixelSize
 ]
 ypts = [
     startY, startY + superPixelSize, startY + superPixelSize,
     startY
 ]
 ppgplot.pgsfs(2)
Example #10
0
 superMax = numpy.ma.max(superPixel)
 superMin = numpy.ma.min(superPixel)
 variance = numpy.ma.var(superPixel)
 numPixels = numpy.ma.count(superPixel)
 print (
     "[%d, %d] \tmax: %d \tmin: %d \t variance: %f \t variance/pixel: %f"
     % (position[1], position[0], superMax, superMin, variance, variance / numPixels)
 )
 ppgplot.pgslct(spPreview["pgplotHandle"])
 boostedPreview = generalUtils.percentiles(superPixel, 20, 99)
 ppgplot.pggray(
     boostedPreview, 0, superPixelSize - 1, 0, superPixelSize - 1, 0, 255, imagePlot["pgPlotTransform"]
 )
 ppgplot.pgsci(0)
 ppgplot.pgsch(5)
 ppgplot.pgtext(1, 2, "max: %d" % superMax)
 ppgplot.pgslct(imagePlot["pgplotHandle"])
 pointingObject = {"x": position[1], "y": position[0]}
 pointings.append(pointingObject)
 ppgplot.pgsfs(2)
 ppgplot.pgsci(5)
 ppgplot.pgcirc(position[1], position[0], radius)
 xpts = [startX, startX, startX + superPixelSize, startX + superPixelSize]
 ypts = [startY, startY + superPixelSize, startY + superPixelSize, startY]
 ppgplot.pgsfs(2)
 ppgplot.pgsci(4)
 ppgplot.pgpoly(xpts, ypts)
 tempBitmap = numpy.zeros(numpy.shape(imageCopy))
 tempBitmap = gridCircle(position[0], position[1], radius, tempBitmap)
 additionalMask = numpy.ma.make_mask(tempBitmap)
 booleanMask = numpy.ma.mask_or(booleanMask, additionalMask)
Example #11
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
	# Plot theta as a function of orbital phase for these parameters
	for phase in numpy.arange(0.5, 1.51, 0.01):
		theta = computeViewingAngle(phase, inclination, beta, phi)
		phaseArray.append(phase)
		angleArray.append(theta)
		
	mainPlotWindow = ppgplot.pgopen("/xs")	
	ppgplot.pgask(False)
	pgPlotTransform = [0, 1, 0, 0, 0, 1]
	ppgplot.pgsci(1)
	ppgplot.pgenv(min(phaseArray), max(phaseArray), 0, 180, 0, 0)
	ppgplot.pgline(phaseArray, angleArray)
	ppgplot.pgsls(2)
	ppgplot.pgline([0.5, 1.5], [90, 90])
	ppgplot.pglab("orbital phase", "viewing angle", "Viewing angle \gh as a function of orbital phase.")
	ppgplot.pgtext(0.6, 150, "i:%2.0f \gb:%2.0f \gf:%2.0f"%(inclination, beta, phi))
		
	
	modelPlotWindow = ppgplot.pgopen("models_i_81_b_40.ps/ps")	
	pgPlotTransform = [0, 1, 0, 0, 0, 1]
	ppgplot.pgask(False)
	mainFluxMax = 0
	mainFluxMin = 1E99
	
	for phase in numpy.arange(0.5, 1.6, 0.1):
		
		ppgplot.pgsci(1)
		theta = computeViewingAngle(phase, inclination, beta, phi)
		intensities = ["i", "i_0", "i_1"]
		lineStyles = [1, 2, 3]
	
Example #13
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)
Example #14
0
def extract_tracks(fname, trkrmin, drdtmin, trksig, ntrkmin):
    # Read four frame
    ff = fourframe(fname)

    # Skip saturated frames
    if np.sum(ff.zavg > 240.0) / float(ff.nx * ff.ny) > 0.95:
        return

    # Read satelite IDs
    try:
        f = open(fname + ".id")
    except OSError:
        print("Cannot open", fname + ".id")
    else:
        lines = f.readlines()
        f.close()

    # ppgplot arrays
    tr = np.array([-0.5, 1.0, 0.0, -0.5, 0.0, 1.0])
    heat_l = np.array([0.0, 0.2, 0.4, 0.6, 1.0])
    heat_r = np.array([0.0, 0.5, 1.0, 1.0, 1.0])
    heat_g = np.array([0.0, 0.0, 0.5, 1.0, 1.0])
    heat_b = np.array([0.0, 0.0, 0.0, 0.3, 1.0])

    # Loop over identifications
    for line in lines:
        # Decode
        id = satid(line)

        # Skip slow moving objects
        drdt = np.sqrt(id.dxdt**2 + id.dydt**2)
        if drdt < drdtmin:
            continue

        # Extract significant pixels
        x, y, t, sig = ff.significant(trksig, id.x0, id.y0, id.dxdt, id.dydt,
                                      trkrmin)

        # Fit tracks
        if len(t) > ntrkmin:
            # Get times
            tmin = np.min(t)
            tmax = np.max(t)
            tmid = 0.5 * (tmax + tmin)
            mjd = ff.mjd + tmid / 86400.0

            # Skip if no variance in time
            if np.std(t - tmid) == 0.0:
                continue

            # Very simple polynomial fit; no weighting, no cleaning
            px = np.polyfit(t - tmid, x, 1)
            py = np.polyfit(t - tmid, y, 1)

            # Extract results
            x0, y0 = px[1], py[1]
            dxdt, dydt = px[0], py[0]
            xmin = x0 + dxdt * (tmin - tmid)
            ymin = y0 + dydt * (tmin - tmid)
            xmax = x0 + dxdt * (tmax - tmid)
            ymax = y0 + dydt * (tmax - tmid)

            cospar = get_cospar(id.norad)
            obs = observation(ff, mjd, x0, y0)
            iod_line = "%s" % format_iod_line(id.norad, cospar, ff.site_id,
                                              obs.nfd, obs.ra, obs.de)

            print(iod_line)

            if id.catalog.find("classfd.tle") > 0:
                outfname = "classfd.dat"
            elif id.catalog.find("inttles.tle") > 0:
                outfname = "inttles.dat"
            else:
                outfname = "catalog.dat"

            f = open(outfname, "a")
            f.write("%s\n" % iod_line)
            f.close()

            # Plot
            ppgplot.pgopen(
                fname.replace(".fits", "") + "_%05d.png/png" % id.norad)
            #ppgplot.pgopen("/xs")
            ppgplot.pgpap(0.0, 1.0)
            ppgplot.pgsvp(0.1, 0.95, 0.1, 0.8)

            ppgplot.pgsch(0.8)
            ppgplot.pgmtxt(
                "T", 6.0, 0.0, 0.0,
                "UT Date: %.23s  COSPAR ID: %04d" % (ff.nfd, ff.site_id))
            if (3600.0 * ff.crres[0] < 1e-3
                ) | (3600.0 * ff.crres[1] < 1e-3) | (
                    ff.crres[0] / ff.sx > 2.0) | (ff.crres[1] / ff.sy > 2.0):
                ppgplot.pgsci(2)
            else:
                ppgplot.pgsci(1)
            ppgplot.pgmtxt(
                "T", 4.8, 0.0, 0.0,
                "R.A.: %10.5f (%4.1f'') Decl.: %10.5f (%4.1f'')" %
                (ff.crval[0], 3600.0 * ff.crres[0], ff.crval[1],
                 3600.0 * ff.crres[1]))
            ppgplot.pgsci(1)
            ppgplot.pgmtxt(
                "T", 3.6, 0.0, 0.0,
                "FoV: %.2f\\(2218)x%.2f\\(2218) Scale: %.2f''x%.2f'' pix\\u-1\\d"
                % (ff.wx, ff.wy, 3600.0 * ff.sx, 3600.0 * ff.sy))
            ppgplot.pgmtxt(
                "T", 2.4, 0.0, 0.0, "Stat: %5.1f+-%.1f (%.1f-%.1f)" %
                (np.mean(ff.zmax), np.std(ff.zmax), ff.vmin, ff.vmax))
            ppgplot.pgmtxt("T", 0.3, 0.0, 0.0, iod_line)

            ppgplot.pgsch(1.0)
            ppgplot.pgwnad(0.0, ff.nx, 0.0, ff.ny)
            ppgplot.pglab("x (pix)", "y (pix)", " ")
            ppgplot.pgctab(heat_l, heat_r, heat_g, heat_b, 5, 1.0, 0.5)

            ppgplot.pgimag(ff.zmax, ff.nx, ff.ny, 0, ff.nx - 1, 0, ff.ny - 1,
                           ff.vmax, ff.vmin, tr)
            ppgplot.pgbox("BCTSNI", 0., 0, "BCTSNI", 0., 0)
            ppgplot.pgstbg(1)

            ppgplot.pgsci(0)
            if id.catalog.find("classfd.tle") > 0:
                ppgplot.pgsci(4)
            elif id.catalog.find("inttles.tle") > 0:
                ppgplot.pgsci(3)
            ppgplot.pgpt(np.array([x0]), np.array([y0]), 4)
            ppgplot.pgmove(xmin, ymin)
            ppgplot.pgdraw(xmax, ymax)
            ppgplot.pgsch(0.65)
            ppgplot.pgtext(np.array([x0]), np.array([y0]), " %05d" % id.norad)
            ppgplot.pgsch(1.0)
            ppgplot.pgsci(1)

            ppgplot.pgend()

        elif id.catalog.find("classfd.tle") > 0:
            # Track and stack
            t = np.linspace(0.0, ff.texp)
            x, y = id.x0 + id.dxdt * t, id.y0 + id.dydt * t
            c = (x > 0) & (x < ff.nx) & (y > 0) & (y < ff.ny)

            # Skip if no points selected
            if np.sum(c) == 0:
                continue

            # Compute track
            tmid = np.mean(t[c])
            mjd = ff.mjd + tmid / 86400.0
            xmid = id.x0 + id.dxdt * tmid
            ymid = id.y0 + id.dydt * tmid
            ztrk = ndimage.gaussian_filter(ff.track(id.dxdt, id.dydt, tmid),
                                           1.0)
            vmin = np.mean(ztrk) - 2.0 * np.std(ztrk)
            vmax = np.mean(ztrk) + 6.0 * np.std(ztrk)

            # Select region
            xmin = int(xmid - 100)
            xmax = int(xmid + 100)
            ymin = int(ymid - 100)
            ymax = int(ymid + 100)
            if xmin < 0: xmin = 0
            if ymin < 0: ymin = 0
            if xmax > ff.nx: xmax = ff.nx - 1
            if ymax > ff.ny: ymax = ff.ny - 1

            # Find peak
            x0, y0, w, sigma = peakfind(ztrk[ymin:ymax, xmin:xmax])
            x0 += xmin
            y0 += ymin

            # Skip if peak is not significant
            if sigma < trksig:
                continue

            # Skip if point is outside selection area
            if inside_selection(id, xmid, ymid, x0, y0) == False:
                continue

            # Format IOD line
            cospar = get_cospar(id.norad)
            obs = observation(ff, mjd, x0, y0)
            iod_line = "%s" % format_iod_line(id.norad, cospar, ff.site_id,
                                              obs.nfd, obs.ra, obs.de)

            print(iod_line)

            if id.catalog.find("classfd.tle") > 0:
                outfname = "classfd.dat"
            elif id.catalog.find("inttles.tle") > 0:
                outfname = "inttles.dat"
            else:
                outfname = "catalog.dat"

            f = open(outfname, "a")
            f.write("%s\n" % iod_line)
            f.close()

            # Plot
            ppgplot.pgopen(
                fname.replace(".fits", "") + "_%05d.png/png" % id.norad)
            ppgplot.pgpap(0.0, 1.0)
            ppgplot.pgsvp(0.1, 0.95, 0.1, 0.8)

            ppgplot.pgsch(0.8)
            ppgplot.pgmtxt(
                "T", 6.0, 0.0, 0.0,
                "UT Date: %.23s  COSPAR ID: %04d" % (ff.nfd, ff.site_id))
            ppgplot.pgmtxt(
                "T", 4.8, 0.0, 0.0,
                "R.A.: %10.5f (%4.1f'') Decl.: %10.5f (%4.1f'')" %
                (ff.crval[0], 3600.0 * ff.crres[0], ff.crval[1],
                 3600.0 * ff.crres[1]))
            ppgplot.pgmtxt(
                "T", 3.6, 0.0, 0.0,
                "FoV: %.2f\\(2218)x%.2f\\(2218) Scale: %.2f''x%.2f'' pix\\u-1\\d"
                % (ff.wx, ff.wy, 3600.0 * ff.sx, 3600.0 * ff.sy))
            ppgplot.pgmtxt(
                "T", 2.4, 0.0, 0.0, "Stat: %5.1f+-%.1f (%.1f-%.1f)" %
                (np.mean(ff.zmax), np.std(ff.zmax), ff.vmin, ff.vmax))
            ppgplot.pgmtxt("T", 0.3, 0.0, 0.0, iod_line)

            ppgplot.pgsch(1.0)
            ppgplot.pgwnad(0.0, ff.nx, 0.0, ff.ny)
            ppgplot.pglab("x (pix)", "y (pix)", " ")
            ppgplot.pgctab(heat_l, heat_r, heat_g, heat_b, 5, 1.0, 0.5)

            ppgplot.pgimag(ztrk, ff.nx, ff.ny, 0, ff.nx - 1, 0, ff.ny - 1,
                           vmax, vmin, tr)
            ppgplot.pgbox("BCTSNI", 0., 0, "BCTSNI", 0., 0)
            ppgplot.pgstbg(1)

            plot_selection(id, xmid, ymid)

            ppgplot.pgsci(0)
            if id.catalog.find("classfd.tle") > 0:
                ppgplot.pgsci(4)
            elif id.catalog.find("inttles.tle") > 0:
                ppgplot.pgsci(3)
            ppgplot.pgpt(np.array([id.x0]), np.array([id.y0]), 17)
            ppgplot.pgmove(id.x0, id.y0)
            ppgplot.pgdraw(id.x1, id.y1)
            ppgplot.pgpt(np.array([x0]), np.array([y0]), 4)
            ppgplot.pgsch(0.65)
            ppgplot.pgtext(np.array([id.x0]), np.array([id.y0]),
                           " %05d" % id.norad)
            ppgplot.pgsch(1.0)
            ppgplot.pgsci(1)

            ppgplot.pgend()
Example #15
0
			extendPhases = copy.deepcopy(phases)
			for p in phases:
				extendPhases.append(p + 1.0)
			phases = extendPhases
			mag.extend(mag)
			err.extend(err)
			# print phases
			magMax = numpy.max(mag) + err[numpy.argmax(mag)]
			magMin = numpy.min(mag) - err[numpy.argmin(mag)]
			meanError = numpy.mean(err)
			if extraColumn: ppgplot.pgsch(1.8)
			ppgplot.pgsch(1.6)
			ppgplot.pgenv(0. ,2.0 , magMax + meanError*2, magMin - meanError*2, 0, 0)
			# ppgplot.pglab("Phase", "CRTS mag", "Phase plot: %s [%d]"%(o.id, len(phases)/2) )
			ppgplot.pglab("Phase", "CRTS mag", "WD%s"%o.id)
			ppgplot.pgtext(0.1, magMax + meanError*2 - 0.01, "%.2f d"%(o.ephemeris.Period))
			ppgplot.pgsch(1.0)
			ppgplot.pgpt(phases, mag)
			ppgplot.pgerrb(2, phases, mag, err, 0)
			ppgplot.pgerrb(4, phases, mag, err, 0)
			matplotlib.pyplot.xlabel("Phase", size = labelSize)
			matplotlib.pyplot.ylabel('CRTS magnitude', size = labelSize)
			matplotlib.pyplot.errorbar(phases, mag, color='k', yerr=err, fmt = '.', ecolor='0.75', capsize=0)

			if extraColumn:
				additionalData = o.getColumn(extraColumnName)
				additionalData.extend(additionalData)
				dataRange = numpy.max(additionalData) - numpy.min(additionalData)
				ppgplot.pgsch(1.8)
				ppgplot.pgenv(0, 2, numpy.min(additionalData), numpy.max(additionalData), 0, 0)
				ppgplot.pglab("Phase", extraColumnName, "")
Example #16
0
day   =  sys.argv[4]#ARGV[3]

# print "TODAY   year month day\n "

# Read LMST 
########################################################

#calendar_buf =  `echo m 1 year | skycalendar`
#calendar_buf =~ m/month day\//g
#(calendar) = split (/\n/, ')

(buf, buf,buf, jdmid, hour,min,sec,ss_hour, ss_min, twie_hour,twie_min, twib_hour, twib_min, sr_hour, sr_min) = calendar.split()#/\s+/, calendar)
ppgplot.pgsch(0.8) # character height (size)
ppgplot.pgslw(2) # line width

ppgplot.pgtext(6.5,0.80,filename)

ppgplot.pgsch(0.6) # character height (size)
ppgplot.pgtext(-10.32,0.80,str(year))
ppgplot.pgtext(-9.5,0.80,str(month))
ppgplot.pgtext(-8.9,0.80,str(day))

ppgplot.pgtext(-8,0.80,"LMST Midnight")
ppgplot.pgtext(-4.8,0.80,"hour")
ppgplot.pgtext(-4.25,0.80,"min")
ppgplot.pgtext(-3.75,0.80,"sec")

ppgplot.pgtext(-8,0.84,"Sun Set")
ppgplot.pgtext(-4.8,0.84,"ss_hour")
ppgplot.pgtext(-4.25,0.84,"ss_min")
Example #17
0
labx = 'Fourier Frequency Offset (bins)'
laby = 'Fourier Frequency Derivative (bins)'
contours = num.asarray([0.1, 0.3, 0.5, 0.7, 0.9])

imfract = 0.65
margin = 0.08

ppgplot.pgopen(device)
ppgplot.pgpap(0.0, 1.0)
ppgplot.pgpage()

# Give z and w values and power change
ppgplot.pgsvp(margin + imfract, 1.0 - margin / 2, margin + imfract,
              1.0 - margin / 2)
ppgplot.pgswin(0.0, 1.0, 0.0, 1.0)
ppgplot.pgtext(0.1, 0.8, "Frac Recovered" % frp)
ppgplot.pgtext(0.2, 0.65, "Power = %.3f" % frp)
ppgplot.pgtext(0.1, 0.4, "signal z = %.1f" % z)
ppgplot.pgtext(0.1, 0.25, "signal w = %.1f" % w)

# freq cut
ppgplot.pgsvp(margin, margin + imfract, margin + imfract, 1.0 - margin / 2)
ppgplot.pgswin(min(rs), max(rs), -0.1, 1.1)
ppgplot.pgbox("BCST", 0.0, 0, "BCNST", 0.0, 0)
ppgplot.pgline(rs, freqcut)
ppgplot.pgmtxt("L", 2.0, 0.5, 0.5, "Relative Power")

#fdot cut
ppgplot.pgsvp(margin + imfract, 1.0 - margin / 2, margin, margin + imfract)
ppgplot.pgswin(-0.1, 1.1, min(zs), max(zs))
ppgplot.pgbox("BCNST", 0.0, 0, "BCST", 0.0, 0)
Example #18
0
device='/XWIN'
labx='Fourier Frequency Offset (bins)'
laby='Fourier Frequency Derivative (bins)'
contours = num.asarray([0.1, 0.3, 0.5, 0.7, 0.9])

imfract = 0.65
margin = 0.08

ppgplot.pgopen(device)
ppgplot.pgpap(0.0, 1.0)
ppgplot.pgpage()

# Give z and w values and power change
ppgplot.pgsvp(margin+imfract, 1.0-margin/2, margin+imfract, 1.0-margin/2)
ppgplot.pgswin(0.0, 1.0, 0.0, 1.0)
ppgplot.pgtext(0.1, 0.8, "Frac Recovered" % frp)
ppgplot.pgtext(0.2, 0.65, "Power = %.3f" % frp)
ppgplot.pgtext(0.1, 0.4, "signal z = %.1f" % z)
ppgplot.pgtext(0.1, 0.25, "signal w = %.1f" % w)

# freq cut
ppgplot.pgsvp(margin, margin+imfract, margin+imfract, 1.0-margin/2)
ppgplot.pgswin(min(rs), max(rs), -0.1, 1.1)
ppgplot.pgbox("BCST", 0.0, 0, "BCNST", 0.0, 0)
ppgplot.pgline(rs, freqcut)
ppgplot.pgmtxt("L", 2.0, 0.5, 0.5, "Relative Power");

#fdot cut
ppgplot.pgsvp(margin+imfract, 1.0-margin/2, margin, margin+imfract)
ppgplot.pgswin(-0.1, 1.1, min(zs), max(zs))
ppgplot.pgbox("BCNST", 0.0, 0, "BCST", 0.0, 0)
Example #19
0
def extract_tracks(fname, trkrmin, drdtmin, trksig, ntrkmin, path,
                   results_path):
    # Read four frame
    ff = fourframe(fname)

    # Skip saturated frames
    if np.sum(ff.zavg > 240.0) / float(ff.nx * ff.ny) > 0.95:
        return

    # Read satelite IDs
    try:
        f = open(fname + ".id")
    except OSError:
        print("Cannot open", fname + ".id")
    else:
        lines = f.readlines()
        f.close()

    tr = np.array([-0.5, 1.0, 0.0, -0.5, 0.0, 1.0])

    # Parse identifications
    idents = [satid(line) for line in lines]

    # Identify unknowns
    for ident0 in idents:
        if ident0.catalog == "unidentified":
            for ident1 in idents:
                if ident1.catalog == "unidentified":
                    continue

                # Find matches
                p1 = inside_selection(ident1, ident0.t0, ident0.x0, ident0.y0)
                p2 = inside_selection(ident1, ident0.t1, ident0.x1, ident0.y1)

                # Match found
                if p1 and p2:
                    # Copy info
                    ident0.norad = ident1.norad
                    ident0.catalog = ident1.catalog
                    ident0.state = ident1.state
                    ident1.state = "remove"
                    break

    # Loop over identifications
    for ident in idents:
        # Skip superseded unknowns
        if ident.state == "remove":
            continue

        # Skip slow moving objects
        drdt = np.sqrt(ident.dxdt**2 + ident.dydt**2)
        if drdt < drdtmin:
            continue

        # Extract significant pixels along a track
        x, y, t, sig = ff.significant_pixels_along_track(
            trksig, ident.x0, ident.y0, ident.dxdt, ident.dydt, trkrmin)

        # Fit tracks
        if len(t) > ntrkmin:
            # Get times
            tmin = np.min(t)
            tmax = np.max(t)
            tmid = 0.5 * (tmax + tmin)
            mjd = ff.mjd + tmid / 86400.0

            # Skip if no variance in time
            if np.std(t - tmid) == 0.0:
                continue

            # Very simple polynomial fit; no weighting, no cleaning
            px = np.polyfit(t - tmid, x, 1)
            py = np.polyfit(t - tmid, y, 1)

            # Extract results
            x0, y0 = px[1], py[1]
            dxdt, dydt = px[0], py[0]
            xmin = x0 + dxdt * (tmin - tmid)
            ymin = y0 + dydt * (tmin - tmid)
            xmax = x0 + dxdt * (tmax - tmid)
            ymax = y0 + dydt * (tmax - tmid)

            cospar = get_cospar(ident.norad, ff.nfd)
            obs = observation(ff, mjd, x0, y0)
            iod_line = "%s" % format_iod_line(ident.norad, cospar, ff.site_id,
                                              obs.nfd, obs.ra, obs.de)

            # Create diagnostic plot
            plot_header(fname.replace(".fits", "_%05d.png/png" % ident.norad),
                        ff, iod_line)

            ppg.pgimag(ff.zmax, ff.nx, ff.ny, 0, ff.nx - 1, 0, ff.ny - 1,
                       ff.zmaxmax, ff.zmaxmin, tr)
            ppg.pgbox("BCTSNI", 0., 0, "BCTSNI", 0., 0)
            ppg.pgstbg(1)

            ppg.pgsci(0)
            if ident.catalog.find("classfd.tle") > 0:
                ppg.pgsci(4)
            elif ident.catalog.find("inttles.tle") > 0:
                ppg.pgsci(3)

            ppg.pgpt(np.array([x0]), np.array([y0]), 4)
            ppg.pgmove(xmin, ymin)
            ppg.pgdraw(xmax, ymax)
            ppg.pgsch(0.65)
            ppg.pgtext(np.array([x0]), np.array([y0]), " %05d" % ident.norad)
            ppg.pgsch(1.0)
            ppg.pgsci(1)

            ppg.pgend()

            # Store results
            store_results(ident, fname, results_path, iod_line)

        elif ident.catalog.find("classfd.tle") > 0:
            # Track and stack
            t = np.linspace(0.0, ff.texp)
            x, y = ident.x0 + ident.dxdt * t, ident.y0 + ident.dydt * t
            c = (x > 0) & (x < ff.nx) & (y > 0) & (y < ff.ny)

            # Skip if no points selected
            if np.sum(c) == 0:
                store_not_seen(ident, fname, results_path)
                continue

            # Compute track
            tmid = np.mean(t[c])
            mjd = ff.mjd + tmid / 86400.0
            xmid = ident.x0 + ident.dxdt * tmid
            ymid = ident.y0 + ident.dydt * tmid
            ztrk = ndimage.gaussian_filter(
                ff.track(ident.dxdt, ident.dydt, tmid), 1.0)
            vmin = np.mean(ztrk) - 2.0 * np.std(ztrk)
            vmax = np.mean(ztrk) + 6.0 * np.std(ztrk)

            # Select region
            xmin = int(xmid - 100)
            xmax = int(xmid + 100)
            ymin = int(ymid - 100)
            ymax = int(ymid + 100)
            if xmin < 0:
                xmin = 0
            if ymin < 0:
                ymin = 0
            if xmax > ff.nx:
                xmax = ff.nx - 1
            if ymax > ff.ny:
                ymax = ff.ny - 1

            # Find peak
            x0, y0, w, sigma = peakfind(ztrk[ymin:ymax, xmin:xmax])
            x0 += xmin
            y0 += ymin

            # Skip if peak is not significant
            if sigma < trksig:
                store_not_seen(ident, fname, results_path)
                continue

            # Skip if point is outside selection area
            if inside_selection(ident, tmid, x0, y0) is False:
                store_not_seen(ident, fname, results_path)
                continue

            # Format IOD line
            cospar = get_cospar(ident.norad, ff.nfd)
            obs = observation(ff, mjd, x0, y0)
            iod_line = "%s" % format_iod_line(ident.norad, cospar, ff.site_id,
                                              obs.nfd, obs.ra, obs.de)

            # Create diagnostic plot
            pngfile = fname.replace(".fits", "_%05d.png" % ident.norad)
            plot_header(pngfile + "/png", ff, iod_line)

            ppg.pgimag(ztrk, ff.nx, ff.ny, 0, ff.nx - 1, 0, ff.ny - 1, vmax,
                       vmin, tr)
            ppg.pgbox("BCTSNI", 0., 0, "BCTSNI", 0., 0)
            ppg.pgstbg(1)

            plot_selection(ident, xmid, ymid)

            ppg.pgsci(0)
            if ident.catalog.find("classfd.tle") > 0:
                ppg.pgsci(4)
            elif ident.catalog.find("inttles.tle") > 0:
                ppg.pgsci(3)
            ppg.pgpt(np.array([ident.x0]), np.array([ident.y0]), 17)
            ppg.pgmove(ident.x0, ident.y0)
            ppg.pgdraw(ident.x1, ident.y1)
            ppg.pgpt(np.array([x0]), np.array([y0]), 4)
            ppg.pgsch(0.65)
            ppg.pgtext(np.array([ident.x0]), np.array([ident.y0]),
                       " %05d" % ident.norad)
            ppg.pgsch(1.0)
            ppg.pgsci(1)

            ppg.pgend()

            # Store results
            store_results(ident, fname, results_path, iod_line)
Example #20
0
k = 1.2807e-16  #erg K

l = N.arange(2000., 50000., 1000.)  #wavelength in A
l = l * 1.e-8  #convert to cm

T = 40000.  #K
B = 2. * h * c**2 / (l**5) / (N.exp(h * c / (l * k * T)) - 1) / 1.e14
l = l * 1.e4
xmin = 1.15 * min(l)
xmax = max(l)
ymin = min(B)
ymax = 1.2 * max(B)
my.psplotinit("blackbody.ps")
ppgplot.pgbox("", 0.0, 0, "", 0.0, 0)
ppgplot.pgenv(xmin, xmax, ymin, ymax, 0, 0)
ppgplot.pglab("Wavelength", "Energy Output/second", "")
ppgplot.pgsci(4)
ppgplot.pgline(l, B)
ppgplot.pgtext(.6, 3., 'Star A')
ppgplot.pgtext(.6, -.5, 'Blue')
#T=20000.#K
#B=2.*h*c**2/(l**5)/(N.exp(h*c/(l*k*T))-1)
l = (l * 1.e-4 + 20000e-8) * 1.e4
ppgplot.pgsci(2)
ppgplot.pgline(l, B)
ppgplot.pgtext(2.6, 3., 'Star B')
ppgplot.pgtext(3.6, -.5, 'Red')
ppgplot.pgsci(1)

ppgplot.pgend()