Exemple #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)
Exemple #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()
Exemple #3
0
def xysimple(x, y, xlabel, ylabel):
    xmax = max(x)
    xmin = min(x)
    ymax = max(y)
    ymin = min(y)
    ppgplot.pgbox("", 0.0, 0, "", 0.0, 0)
    ppgplot.pgenv(xmin, xmax, ymin, ymax, 0)
    ppgplot.pglab(xlabel, ylabel, "")
    ppgplot.pgpt(x, y, 3)
Exemple #4
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/.')
Exemple #5
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()
Exemple #6
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()
def pgplot(slot, plotterHandle):
	print "We are about to plot: %s"%(slot)
	
	lightcurveView = ppgplot.pgopen('/xs')
	
	xValues = slot.photometry.times
	xValues = numpy.arange(0, len(xValues))
	yValues = slot.getColumn("Counts")
	
	ppgplot.pgenv(min(xValues), max(xValues), min(yValues), max(yValues), 0, 0)
	ppgplot.pgask(False)
	
	ppgplot.pgsci(2)	
	ppgplot.pgpt(xValues, yValues, 1)

	ppgplot.pgclos()
	return
	
Exemple #8
0
def compdiff(x, y, xlabel, ylabel):
    xmax = max(x)
    xmin = min(x)
    ymax = max(y)
    ymin = min(y)
    ave = N.average(N.compress((x < 21) & (im1.sn > 3), y))
    std = scipy.stats.std(N.compress((x < 21) & (im1.sn > 3), y))
    ppgplot.pgbox("", 0.0, 0, "", 0.0, 0)
    ppgplot.pgenv(xmin, xmax, -.8, .8, 0)
    ppgplot.pglab(xlabel, ylabel, "")
    ppgplot.pgpt(x, y, 3)
    x = N.arange((int(xmin) - 1), (int(xmax) + 2), 1)
    y = ave * x / x
    ppgplot.pgsci(2)
    ppgplot.pgline(x, y)
    ppgplot.pgsci(1)
    y1 = y - std
    ppgplot.pgline(x, y1)
    y1 = y + std
    ppgplot.pgline(x, y1)
Exemple #9
0
def plotoutlierpos():
    dm = 0.01
    xlabel = "x position of outliers"
    ylabel = "y position of outliers"
    delta = abs(im1.magap5 - im2.magap5)
    x = N.compress(delta > dm, im1.x)
    y = N.compress(delta > dm, im1.y)
    xmax = max(x)
    xmin = min(x)
    ymax = max(y)
    ymin = min(y)
    ppgplot.pgbox("", 0.0, 0, "", 0.0, 0)
    #ppgplot.pgenv(xmin,xmax,ymin,ymax,0)
    ppgplot.pgenv(0, 920, 0, 875, 0)
    ppgplot.pglab(xlabel, ylabel, "")
    ppgplot.pgpt(x, y, 3)
    x = N.compress(delta > dm, im2.x)
    y = N.compress(delta > dm, im2.y)
    diff = N.compress(delta > dm, delta)
    ppgplot.pgpt(x, y, 4)
    for i in range(len(x)):
        print x[i], y[i], diff[i]
def getChiSqByParameters(params, *args):
	global iteration, mainPlotWindow, currentPlotWindow, colour, inclination, phase
	print "Params:", params
	beta = params[0]
	log_lambda = params[1]
	scale_factor = params[2]
	linear_offset = params[3]
	print "Args:", args
	temperature = args[0]
	field = args[1]
	
	# cos(theta) = cos(i)cos(beta) - sin(i)sin(beta)cos(phi + pi/2)
	cosTheta = math.cos(radians(inclination)) * math.cos(radians(beta)) - math.sin(radians(inclination)) * math.sin(radians(beta))*math.cos(phase + math.pi/2.)
	angle = math.acos(cosTheta) / math.pi * 180
	print "Angle: %f [deg], Field: %f [MG], Temperature:%f [keV], log_lambda: %f, scale: %f, offset: %f"%(angle, field, temperature, log_lambda, scale_factor, linear_offset)
	model = getSampledModel(observedSpectrum.wavelengths, angle, field, temperature, log_lambda)
	model = [m * scale_factor + linear_offset for m in model]
	chi = computeChiSq(observedSpectrum, model)
	allChiSqs.append(chi)
	print "Chi-squared:", chi
	startWavelength = min(observedSpectrum.wavelengths)
	endWavelength = max(observedSpectrum.wavelengths)
	
	# Draw the most recent iteration
	ppgplot.pgslct(currentPlotWindow)
	ppgplot.pgsci(1)
	ppgplot.pgenv(startWavelength, endWavelength, lowerFlux, upperFlux, 0, 0)
	ppgplot.pgline(observedSpectrum.wavelengths, observedSpectrum.flux)
	ppgplot.pgsci(4)
	ppgplot.pgline(observedSpectrum.wavelengths, model)
	ppgplot.pgsci(1)
	ppgplot.pglab("wavelength", "flux", "Current fit: %d"%iteration)
	
	# Overplot the iteration on the original diagram
	print "overplotting"
	ppgplot.pgslct(mainPlotWindow)
	ppgplot.pgsci(colour)
	ppgplot.pgline(observedSpectrum.wavelengths, model)
	colour += 1
	if colour>15: colour = 1
	ppgplot.pgsci(1)
	
	# Re-generate the Chi-Squared plot
	ppgplot.pgslct(chiSqPlotWindow)
	
	if iteration > 9:
		ppgplot.pgenv(0, iteration+1, 0, max(allChiSqs), 0, 0)
	else:
		ppgplot.pgenv(0, 10, 0, max(allChiSqs), 0, 0)
	iterations = range(iteration+1)
	ppgplot.pgpt(iterations, allChiSqs, 2)
	minCh = min(allChiSqs)
	medCh = numpy.median(allChiSqs)
	maxCh = max(allChiSqs)
	ppgplot.pglab("Iteration [n]", "Chi-squared", "Chi-squared values [%.2f, %.2f, %.2f]"%(minCh, medCh, maxCh))
	
	
	iteration += 1
	return chi
Exemple #11
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()
Exemple #12
0
		print upper, MJD, expectedTime, phaseDifference, ominusc, ominusc*86400., error, terror, sigma, ocerror
		ocs.append(ominusc*86400.)
		cycles.append(upper)
		ocErrors.append(ocerror)
		
	for c, o, oe in zip(cycles, ocs, ocErrors):
		print c, o, oe
		
	plotname = "QSVir-oc"
	plotDevices = ["/xs", "%s.eps/ps"%plotname]
	for plotDevice in plotDevices:
		mainPGPlotWindow = ppgplot.pgopen(plotDevice)
		pgPlotTransform = [0, 1, 0, 0, 0, 1]
		ppgplot.pgpap(10, 0.618)
		ppgplot.pgsci(1)
		ppgplot.pgenv(min(cycles)*1.05, max(cycles)*1.05, min(ocs)*1.15, max(ocs)*1.15, 0, 0)
		ppgplot.pgslw(1)
		ppgplot.pgpt(cycles, ocs, 2)
		ppgplot.pgslw(1)
		ppgplot.pgerrb(2, cycles, ocs, ocErrors, 0)
		ppgplot.pgerrb(4, cycles, ocs, ocErrors, 0)
		ppgplot.pgsls(2)
		ppgplot.pglab("Cycle number", "O-C (seconds)", "")
		ppgplot.pgclos()
	
	""""# Map some colours
	oColours = []
	for o in observatories:
		index = o % len(colourMap)
		colour = colourMap[index]
		oColours.append(colour)
			window.setData(image)
			bkg_sigma = 1.48 * mad(image)
			sources = daofind(image, fwhm=4.0, threshold=3*bkg_sigma)   
			window.setSourcesAvoidBorders(sources)	
		else: 
			window.setBlankData(image)
		
		
		allWindows.append(window)
		
	(xmin, ymin, xmax, ymax) = determineFullFrameSize(allWindows)
	fullFramexsize = xmax - xmin
	fullFrameysize = ymax - ymin
	
	lightcurveView = ppgplot.pgopen('/xs')
	ppgplot.pgenv(startFrame, startFrame + frameRange, 0, 100, 0, 0)
	ppgplot.pgask(False)
	
	if (arg.preview):		
		bitmapView = ppgplot.pgopen('/xs')
		ppgplot.pgenv(0.,fullFramexsize,0.,fullFrameysize, 1, 0)
		pgPlotTransform = [0, 1, 0, 0, 0, 1]
		ppgplot.pgsfs(2)
	
					
	xValues = []
	yValues = []	
	yAxisMax= 100	
	referenceApertures = ultraspecClasses.referenceApertures()
	referenceApertures.initFromSourceList(sourceList)
	for frameIndex in range(2, frameRange + 1):
	
	# Snip out Halpha 
	spectrum.snipWavelengthRange(6550, 6570)
	
	lowerWavelength = min(spectrum.wavelengths)
	upperWavelength = max(spectrum.wavelengths)
	observedSpectrumRange = (lowerWavelength, upperWavelength)
	lowerFlux = min(spectrum.flux)
	upperFlux = max(spectrum.flux)
	lowerFlux = 0
	
	mainPlotWindow = ppgplot.pgopen(arg.device)	
	ppgplot.pgask(False)
	pgPlotTransform = [0, 1, 0, 0, 0, 1]
	ppgplot.pgsci(1)
	ppgplot.pgenv(lowerWavelength, upperWavelength, lowerFlux, upperFlux, 0, 0)
	ppgplot.pgline(spectrum.wavelengths, spectrum.flux)
	ppgplot.pglab("wavelength", "flux", spectrum.objectName)
	
	observedArea = spectrum.integrate()
	print "Wavelength range of observations:", observedSpectrumRange
		
	# modelPlotWindow = ppgplot.pgopen(arg.device)	
	# pgPlotTransform = [0, 1, 0, 0, 0, 1]	
	# ppgplot.pgask(False)
	
	currentPlotWindow = ppgplot.pgopen(arg.device)	
	ppgplot.pgask(False)
	pgPlotTransform = [0, 1, 0, 0, 0, 1]	
	ppgplot.pgslct(currentPlotWindow)
	ppgplot.pgenv(lowerWavelength, upperWavelength, lowerFlux, upperFlux, 0, 0)
Exemple #15
0
#! /usr/bin/env python
#
#  pgex1: freely taken after PGDEMO1.F
#
import ppgplot, numpy
import sys

# create an array 
xs=numpy.array([1.,2.,3.,4.,5.])
ys=numpy.array([1.,4.,9.,16.,25.])

# creat another array
yr = 0.1*numpy.array(range(0,60))
xr = yr*yr


# pgplotting
if len(sys.argv) > 1: # if we got an argument use the argument as devicename
	ppgplot.pgopen(sys.argv[1])
else:
	ppgplot.pgopen('/xwin')
ppgplot.pgenv(0.,10.,0.,20.,0,1)
ppgplot.pglab('(x)', '(y)', 'PGPLOT Example 1:  y = x\u2')
ppgplot.pgpt(xs,ys,9)
ppgplot.pgline(xr,yr)
ppgplot.pgclos()
Exemple #16
0
	
	fig = matplotlib.pyplot.gcf()
	fig.suptitle(runStr + ' ' + fileappendix, fontsize=20)

	matplotlib.pyplot.draw()
	matplotlib.pyplot.show(block = False)
	fig.savefig(runStr +'_%s.eps'%fileappendix,dpi=100, format='eps')
	fig.savefig(runStr +'_%s.png'%fileappendix,dpi=100, format='png')
	
	plotDevices = ["/xs", "%s.eps/ps"%fileappendix]
	for plotDevice in plotDevices:
		mainPGPlotWindow = ppgplot.pgopen(plotDevice)
		pgPlotTransform = [0, 1, 0, 0, 0, 1]
		ppgplot.pgpap(10, 0.618)
		ppgplot.pgsci(1)
		ppgplot.pgenv(min(x_values), max(x_values), yLims[0], yLims[1], 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.pgsls(2)
		ppgplot.pgline(xFit, yFit)
		ppgplot.pgsls(3)
		ppgplot.pgline([a3, a3], [yLims[0], yLims[1]])
		ppgplot.pgsls(1)
		ppgplot.pglab(xColumn + " - " + str(JDoffset), "flux ratio", "")
		ppgplot.pgclos()
	time.sleep(3)
	
	times = []
Exemple #17
0
    inclination = 81  # Inclination of orbit
    phi = 20  # Angle offset of magnetic axis to orbital axis (not used yet)

    phaseArray = []
    angleArray = []
    # Plot theta as a function of orbital phase for these parameters
    for phase in numpy.arange(0.5, 1.51, 0.01):
        theta = computeViewingAngle(phase, inclination, beta, phi)
        phaseArray.append(phase)
        angleArray.append(theta)

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

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

    for phase in numpy.arange(0.5, 1.6, 0.1):
	maxSources = int(round((numSources)*0.4))
	debug.write("Number of sources: %d, number of top sources: %d"%(numSources, maxSources), 2)
	if maxSources<1:
		debug.write("WARNING: Not enough sources for shift calculation, proceeding in '--noshift' mode.", 1)
		applyShift = False
	else:
		topSources = allSources[0:maxSources]
		masterApertureList = [ (x, y) for (x, y, flux) in topSources]
		
	
	# Plot the preview frame
	if (arg.keyimages):
		#stackedFigure = matplotlib.pyplot.figure(figsize=(10, 10))
		#matplotlib.pyplot.title("Initial 10 frame stacked image")
		stackedPreview = ppgplot.pgopen('/xs')
		ppgplot.pgenv(0.,fullFramexsize,0.,fullFrameysize, 1, 0)
		pgPlotTransform = [0, 1, 0, 0, 0, 1]
		ppgplot.pglab("x", "y", "Initial 10 frame stacked image.")
	
		# Display the image on the user's screen
		image = matplotlib.pyplot.imshow(boostedFullFrame, cmap='gray_r')
		for s in allSources:
			x, y = s[0], s[1]
			matplotlib.pyplot.gca().add_artist(matplotlib.pyplot.Circle((x,y), 10, color='green', fill=False, linewidth=1.0))
		if applyShift:
			for s in topSources:
				x, y = s[0], s[1]
				matplotlib.pyplot.gca().add_artist(matplotlib.pyplot.Circle((x,y), 10, color='blue', fill=False, linewidth=1.0))
		
		rows, cols = numpy.shape(boostedFullFrame)
		ppgplot.pggray(boostedFullFrame, 0, cols-1, 0, rows-1, 0, 255, pgPlotTransform)
Exemple #19
0
    n = 1.3

if ncl == 5:
    title = "MS1054"
    #a=.008
    #b=.165*a
    n = 1.45
if ncl == 6:
    title = "HDFN1"
    #a=.008
    #b=.165*a
    n = 1.45
ymin = -.05
ymax = max(aveaperr)
#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
	pgPlotTransform = [0, 1, 0, 0, 0, 1]
	ppgplot.pgask(False)
	ppgplot.pglab("wavelength", "flux", "spectrum")
	phases = []
	rvs = []
	wvshifts = []
	wvshiftErrors = []
	previousWavelengthFit = 8173.0
	for spectrum in spectra:
		spectrum.trimWavelengthRange(8000, 8400)
		lowerWavelength = min(spectrum.wavelengths)
		upperWavelength = max(spectrum.wavelengths)
		lowerFlux = min(spectrum.flux)
		upperFlux = max(spectrum.flux)
		ppgplot.pgsci(1)
		ppgplot.pgenv(lowerWavelength, upperWavelength, lowerFlux, upperFlux, 0, 0)
		ppgplot.pgline(spectrum.wavelengths, spectrum.flux)
		if hasEphemeris:
			phase = ephemeris.getPhase(spectrum.HJD)
			labelX = 8100
			labelY = spectrum.getNearestFlux(labelX) + 0.5
			print labelX, labelY
			ppgplot.pglab("Wavelength", "Flux", "Phase: %f"%phase)

		# Now remove the 8190 doublet from the data set
		continuum = copy.deepcopy(spectrum)
		continuum.snipWavelengthRange(8130, 8250)
		ppgplot.pgsci(3)
		ppgplot.pgline(continuum.wavelengths, continuum.flux)
		
		x_values = continuum.wavelengths
Exemple #21
0
		print image.bits, image.size, image.format, image.mode
		exposureTime = getExifValue(image, 'ExposureTime')
		print "Exposure time:", exposureTime
		
		if useDark:
			image = PIL.ImageChops.difference(image, dark)
		
		images.append(image)
	
	(width, height) = images[0].size
	
	previewWindow = ppgplot.pgopen('/xs')	
	ppgplot.pgask(False)
	pgPlotTransform = [0, 1, 0, 0, 0, 1]
	ppgplot.pgsci(1)
	ppgplot.pgenv(0, width-1, 0, height-1, 0, 0)
	
	outputWindow = ppgplot.pgopen('/xs')	
	ppgplot.pgask(False)
	pgPlotTransform = [0, 1, 0, 0, 0, 1]
	ppgplot.pgsci(1)
	ppgplot.pgenv(0, width-1, 0, height-1, 0, 0)
	
	redReference = numpy.array(images[0].split()[0])
	redTotal = numpy.zeros(numpy.shape(redReference))
	greenTotal = numpy.zeros(numpy.shape(redReference))
	blueTotal = numpy.zeros(numpy.shape(redReference))
	
	for frameIndex, image in enumerate(images):
		redData, greenData, blueData = image.split()
		# redData.show()
Exemple #22
0
	PGPlotWindow = ppgplot.pgopen(device) 
	pgPlotTransform = [0, 1, 0, 0, 0, 1]
	ppgplot.pgslct(PGPlotWindow)   
	ppgplot.pgsci(1)
	ppgplot.pgask(False)
	for index, o in enumerate(objects):
		MJD = o.getColumn('MJD')
		mag = o.getColumn('mag')
		err = o.getColumn('err')
		startDate = numpy.min(MJD)
		endDate = numpy.max(MJD)
		magMax = numpy.max(mag) + err[numpy.argmax(mag)]
		magMin = numpy.min(mag) - err[numpy.argmin(mag)]
		meanError = numpy.mean(err)
		print "%s Start date: %f, End date: %f"%(o.id, startDate, endDate)
		ppgplot.pgenv(startDate, endDate, magMax + meanError*2, magMin - meanError*2, 0, 0)
		ppgplot.pgpt(MJD, mag)
		ppgplot.pgerrb(2, MJD, mag, err, 0)
		ppgplot.pgerrb(4, MJD, mag, err, 0)
		ppgplot.pglab("MJD", "CRTS mag", "%s [%d]"%(o.id, len(MJD)))
	
	ppgplot.pgclos()	
	
	
	# Compute HJDs for the observations
	for o in objects:
		hasEphemeris = o.loadEphemeris()
		if hasEphemeris: o.computeHJDs()
	
			
Exemple #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()
Exemple #24
0
def draw_one(x):
    ppgplot.pgbbuf()
    ppgplot.pgenv(0, len(x), numpy.min(x) * 0.95, numpy.max(x) * 1.05)
    ppgplot.pgpt(numpy.arange(len(x)), x)
    ppgplot.pgebuf()
    time.sleep(4)
Exemple #25
0
# /usr/bin/env python
#
#  pgex1: freely taken after PGDEMO1.F
#
import ppgplot, Numeric
import sys

# create an array
xs = Numeric.array([1.0, 2.0, 3.0, 4.0, 5.0])
ys = Numeric.array([1.0, 4.0, 9.0, 16.0, 25.0])

# creat another array
yr = 0.1 * Numeric.array(range(0, 60))
xr = yr * yr


# pgplotting
if len(sys.argv) > 1:  # if we got an argument use the argument as devicename
    ppgplot.pgopen(sys.argv[1])
else:
    ppgplot.pgopen("?")
ppgplot.pgenv(0.0, 10.0, 0.0, 20.0, 0, 1)
ppgplot.pglab("(x)", "(y)", "PGPLOT Example 1:  y = x\u2")
ppgplot.pgpt(xs, ys, 9)
ppgplot.pgline(xr, yr)
ppgplot.pgclos()
Exemple #26
0
	
	
	
	if not arg.stacked:
		mainPGPlotWindow = ppgplot.pgopen(arg.device)	
		ppgplot.pgask(True)
		pgPlotTransform = [0, 1, 0, 0, 0, 1]
		yUpper = 2.5
		yLower = -0.5
		for spectrum in spectra:
			ppgplot.pgsci(1)
			lowerWavelength = min(spectrum.wavelengths)
			upperWavelength = max(spectrum.wavelengths)
			lowerFlux = min(spectrum.flux)
			upperFlux = max(spectrum.flux)
			ppgplot.pgenv(lowerWavelength, upperWavelength, lowerFlux, upperFlux, 0, 0)
			ppgplot.pgbin(spectrum.wavelengths, spectrum.flux)
			if hasEphemeris:
				ppgplot.pglab("wavelength [%s]"%spectrum.wavelengthUnits, "flux [%s]"%spectrum.fluxUnits, "%s [%f]"%(spectrum.objectName, spectrum.phase))
			else:
				ppgplot.pglab("wavelength [%s]"%spectrum.wavelengthUnits, "flux [%s]"%spectrum.fluxUnits, "%s [%s]"%(spectrum.objectName, spectrum.loadedFromFilename))
		
		
	
	if arg.stacked:
		mainPGPlotWindow = ppgplot.pgopen(arg.device)	
		ppgplot.pgask(True)
		pgPlotTransform = [0, 1, 0, 0, 0, 1]
		yLower = -0.5
		offset = 2.0
		yUpper = numSpectra * offset
Exemple #27
0
    else:
        print '# Warning: no sources found to match ', src
        os._exit(1)

    if _do_grace:
        #  -- switch lists to arrays (should have done that to begin with) for pgplot
        t = Numeric.array(date)  # time (in days)
        t = t - t0  # but relative to first date found
        f = Numeric.array(flux)  # flux
        e = 3 * Numeric.array(ferr)  # flux errors as 3 sigma
        g = Numeric.array(freq)  # freq

        p = gracePlot.gracePlot()
        p.plot(t, f, e, symbols=1)
        p.title('Fluxes for ' + src)
        p.xlabel('Days since ' + d0)
        p.ylabel('Flux (Jy)')
        for r in [[70, 100], [100, 120], [120, 250]]:
            n, x, y, dy = get_range(t, f, e, g, r[0], r[1], cut)
            if n: p.plot(x, y, dy, symbols=1)
            p.hold(1)
    elif _do_pgplot:
        t = Numeric.array(date)  # time (in days)
        t = t - t0  # but relative to first date found
        f = Numeric.array(flux)  # flux
        ppgplot.pgopen(pgp)
        ppgplot.pgenv(0, 1500, 0, 80, 0, 1)
        ppgplot.pglab('Days since %s' % d0, 'Flux(Jy)', 'Flux for %s' % src)
        ppgplot.pgpt(t, f, 9)
        ppgplot.pgline(t, f)
Exemple #28
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))
Exemple #29
0
#/usr/bin/env python
#
#  pgex1: freely taken after PGDEMO1.F
#
import ppgplot, Numeric
import sys

# create an array 
xs=Numeric.array([1.,2.,3.,4.,5.])
ys=Numeric.array([1.,4.,9.,16.,25.])

# creat another array
yr = 0.1*Numeric.array(range(0,60))
xr = yr*yr


# pgplotting
if len(sys.argv) > 1: # if we got an argument use the argument as devicename
	ppgplot.pgopen(sys.argv[1])
else:
	ppgplot.pgopen('?')
ppgplot.pgenv(0.,10.,0.,20.,0,1)
ppgplot.pglab('(x)', '(y)', 'PGPLOT Example 1:  y = x\u2')
ppgplot.pgpt(xs,ys,9)
ppgplot.pgline(xr,yr)
ppgplot.pgclos()
Exemple #30
0
	i_s = []
	for line in inputfile:
		if line[0] == '#':
			continue
		data = line.split()
		replaceExpChar(data[0])
		freqs.append(float(replaceExpChar(data[0])))
		i_0s.append(float(replaceExpChar(data[1])))
		i_1s.append(float(replaceExpChar(data[2])))
		i_s.append(float(replaceExpChar(data[3])))
		
		
	lowerFreq = min(freqs)
	upperFreq = max(freqs)
	upper_i0 = max(i_0s)
	lower_i0 = max(i_0s)
	upper_i1 = max(i_1s)
	lower_i1 = min(i_1s)
	upper_i = max(i_s)
	lower_i = min(i_s)
	
	mainPGPlotWindow = ppgplot.pgopen('/xs')	
	pgPlotTransform = [0, 1, 0, 0, 0, 1]
	ppgplot.pgenv(lowerFreq, upperFreq, lower_i, upper_i, 0, 0)
	ppgplot.pgsci(1)
	
	ppgplot.pgline(freqs, i_s)
	ppgplot.pglab("frequency", "i_", "")
		
			
Exemple #31
0
	mainPGPlotWindow = ppgplot.pgopen(arg.device)	
	ppgplot.pgask(True)
	ppgplot.pgpap(3.0, 1.8)
	# pgPlotTransform = [0, 1, 0, 0, 0, 1]
	spectrum = spectra[0] 
	xScale = (max(spectrum.wavelengths) - min(spectrum.wavelengths)) / xSize
	if hasEphemeris:
		yScale = numPhaseBins
	else:	
		yScale = len(spectra)
		
	pgPlotTransform = [min(spectrum.wavelengths), xScale, 0, 0, 0, 1/float(yScale)]
	lowerWavelength = min(spectrum.wavelengths)
	upperWavelength = max(spectrum.wavelengths)
	ppgplot.pgenv( min(spectrum.wavelengths), max(spectrum.wavelengths), 0, 2, 0, 0)
	ppgplot.pggray(generalUtils.percentiles(trailBitmap, 20, 99), 0, xSize-1 , 0, ySize-1 , 255, 0, pgPlotTransform)
	# ppgplot.pggray(trailBitmap, 0, xSize-1 , 0, ySize-1 , numpy.max(trailBitmap), numpy.min(trailBitmap), pgPlotTransform)
	
	epochs = [s.HJD for s in spectra]
	startHJD = min(epochs)
	endHJD = max(epochs)
	if arg.title is None:
		title = ""
	else: 
		title = arg.title
	if hasEphemeris: 
		# ppgplot.pglab("wavelength [%s]"%spectrum.wavelengthUnits, "Phase", "%s - %s"%(str(startHJD), str(endHJD)))
		ppgplot.pglab("wavelength [%s]"%spectrum.wavelengthUnits, "Phase", title)
	else:
		#ppgplot.pglab("wavelength [%s]"%spectrum.wavelengthUnits, "Spectrum number", "%s - %s"%(str(spectra[0].HJD), str(spectra[-1].HJD)))
Exemple #32
0
	PGPlotWindow = ppgplot.pgopen(device) 
	pgPlotTransform = [0, 1, 0, 0, 0, 1]
	ppgplot.pgslct(PGPlotWindow)   
	ppgplot.pgsci(1)
	ppgplot.pgask(False)
	for index, o in enumerate(objects):
		MJD = o.getColumn('MJD')
		mag = o.getColumn('mag')
		err = o.getColumn('err')
		startDate = numpy.min(MJD)
		endDate = numpy.max(MJD)
		magMax = numpy.max(mag) + err[numpy.argmax(mag)]
		magMin = numpy.min(mag) - err[numpy.argmin(mag)]
		meanError = numpy.mean(err)
		print "%s Start date: %f, End date: %f"%(o.id, startDate, endDate)
		ppgplot.pgenv(startDate, endDate, magMax + meanError*2, magMin - meanError*2, 0, 0)
		ppgplot.pgpt(MJD, mag)
		ppgplot.pgerrb(2, MJD, mag, err, 0)
		ppgplot.pgerrb(4, MJD, mag, err, 0)
		ppgplot.pglab("MJD", "CRTS mag", "%s [%d]"%(o.id, len(MJD)))
	
	ppgplot.pgclos()	
	
	
	# Compute HJDs for the observations
	for o in objects:
		hasEphemeris = o.loadEphemeris()
		if hasEphemeris: o.computeHJDs()
	
			
	# Load the PTF data
Exemple #33
0
	pgPlotTransform = [0, 1, 0, 0, 0, 1]
	ppgplot.pgslct(PGPlotWindow)   
	ppgplot.pgsci(1)
	ppgplot.pgask(False)
	for index, o in enumerate(objects):
		HJD = o.getColumn('HJD')
		mag = o.getColumn('mag')
		err = o.getColumn('err')
		startDate = numpy.min(HJD)
		dates = [ d - startDate for d in HJD]
		endDate = numpy.max(HJD)
		magMax = numpy.max(mag) + err[numpy.argmax(mag)]
		magMin = numpy.min(mag) - err[numpy.argmin(mag)]
		meanError = numpy.mean(err)
		print "%s Start date: %f, End date: %f"%(o.id, startDate, endDate)
		ppgplot.pgenv(0, numpy.max(dates), magMax + meanError*2, magMin - meanError*2, 0, 0)
		ppgplot.pgpt(dates, mag)
		ppgplot.pgerrb(2, dates, mag, err, 0)
		ppgplot.pgerrb(4, dates, mag, err, 0)
		ppgplot.pglab("Days since %f"%startDate, "PTF mag", "%s [%d]"%(o.id, len(HJD)))
	
	ppgplot.pgclos()	
	
	# Load the ephemerides
	for o in objects:
		hasEphemeris = o.loadEphemeris()
		print o.ephemeris
	
	
	# Write the object data to a textfile
	for o in objects:
Exemple #34
0
		o.calculateOffsets()
		o.calculateFluxes()
		
		o.addWavelengths(wavelengthLookup)

	PGPlotWindow = ppgplot.pgopen(arg.device) 
	pgPlotTransform = [0, 1, 0, 0, 0, 1]
	ppgplot.pgslct(PGPlotWindow)   
	ppgplot.pgsci(1)
	ppgplot.pgask(True)
	
	for o in objects:
		ppgplot.pgsch(1.6)
		wavelengths, fluxes, fluxerrors, bands = o.getFluxData()
		fluxMax = max(fluxes)
		fluxMin = min(fluxes)
		wavelengthMin = min(wavelengths)
		wavelengthMax = max(wavelengths)
		ppgplot.pgenv(500,25000 , 0, fluxMax*1.2, 0)
		ppgplot.pglab("wavelength [\A]", "f\d\gn\u [mJy]", o.objectID)
		ppgplot.pgsch(1.0)
		ppgplot.pgpt(wavelengths, fluxes)
		ppgplot.pgerrb(2, wavelengths, fluxes, fluxerrors, 0)
		ppgplot.pgerrb(4, wavelengths, fluxes, fluxerrors, 0)
	
	ppgplot.pgclos()	
	
	sys.exit()
	
	
		pgPlotTransform = [0, 1, 0, 0, 0, 1]
		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:
Exemple #36
0
	ppgplot.pgenv(0, 2, numpy.max(mag), numpy.min(mag), 0, 0)
	ppgplot.pglab("Phase", "PTF magnitude", "%s"%(arg.name))
	ppgplot.pgsch(1.0)
	ppgplot.pgpt(phases, mag)
	ppgplot.pgerrb(2, phases, mag, err, 0)
	ppgplot.pgerrb(4, phases, mag, err, 0)
	
	ppgplot.pgsci(2)
	model = modelledData.getColumn('mag')
	model.extend(model)
	ppgplot.pgsls(2)
	ppgplot.pgslw(7)
	ppgplot.pgline(phases, model)
	"""
	ppgplot.pgsch(1.6)
	ppgplot.pgenv(0, 2, 0, maxFlux, 0, 0)
	ppgplot.pglab("Phase", "PTF flux (mJy)", "%s"%(arg.name))
	ppgplot.pgsch(1.0)
	ppgplot.pgpt(phases, flux)
	ppgplot.pgerrb(2, phases, flux, flux_err, 0)
	ppgplot.pgerrb(4, phases, flux, flux_err, 0)
	
	ppgplot.pgsci(2)
	ppgplot.pgsls(2)
	ppgplot.pgslw(7)
	modelPhases = modelledData.getColumn('phase')
	temp = copy.deepcopy(modelPhases)
	for p in modelPhases: temp.append(p + 1.0)
	modelPhases = temp
	model = modelledData.getColumn('flux')
	model = [m * 3631E3 for m in model]
Exemple #37
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)
Exemple #38
0
	brightness = []
	for x in range(numPoints):
		times.append(seconds)
		brightness.append(sinecurve(seconds, period))
		seconds+= step
	
	lightCurve = lightCurve()
	lightCurve.initValues(times, brightness)
	lightCurve.period = period * 60.
	
	lightCurve.brightness[3] = 1.0
	
	lightCurvePlot = {}
	lightCurvePlot['pgplotHandle'] = ppgplot.pgopen('/xs')
	ppgplot.pgpap(8, 0.618)
	ppgplot.pgenv(0., lightCurve.period, 0.0, 1.0, 0, 0)
	ppgplot.pglab("seconds", "brightness", "Light curve")
	ppgplot.pgpt(lightCurve.time, lightCurve.brightness, 2)
	ppgplot.pgsci(2)
	ppgplot.pgline(lightCurve.time, lightCurve.brightness)
	ppgplot.pgask(False)
	
	connectedCount = 0
	connectedBulbs = []
	for b in bulbs:
		print b
		if b['connected'] == True:
			connectedCount+= 1
			connectedBulbs.append(b)
			print b['label'], "is connected!"
			
Exemple #39
0
def plot(command, data, group, cdata):
    """
    Plots dsets from a dictionary called data.

    Interactive usage:

    plot slots [device x1 x2 y1 y2 xoff ysep=0 pmask]

    Arguments:

    slots   -- range of slots as in '1-10', or just a single slot '9' to plot, or a group
               name such as 'ippeg'.
    device  -- plot device (e.g. '/xs', '3/xs', 'hardcopy.ps/cps')
    x1      -- left-hand plot limit
    x2      -- right-hand plot limit. Set = x1 for automatic determination
    y1      -- lower plot limit
    y2      -- upper plot limit.  Set = y1 for automatic determination
    xoff    -- offset to start X axis from, 0 for automatic determination.
    ysep    -- separation in y
    pmask   -- whether to plot masked data
    """

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

    # register parameters
    inpt.register('slots',  inp.Input.LOCAL, inp.Input.PROMPT)
    inpt.register('device', 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('xoff',   inp.Input.LOCAL, inp.Input.HIDE)
    inpt.register('ysep',   inp.Input.LOCAL, inp.Input.HIDE)
    inpt.register('pmask',  inp.Input.LOCAL, inp.Input.HIDE)

    # get inputs
    slots  = inpt.get_value('slots', 'slots to plot', '1')
    slist  = interp_slots(slots, True, data, group)

    device = inpt.get_value('device', 'plot device', '/xs')
    x1   = inpt.get_value('x1', 'left-hand plot limit', 0.0)
    x2   = inpt.get_value('x2', 'right-hand plot limit', 0.0)
    y1   = inpt.get_value('y1', 'lower plot limit', 0.0)
    y2   = inpt.get_value('y2', 'upper plot limit', 0.0)
    xoff = inpt.get_value('xoff', 'X offset', 0.0)
    inpt.set_default('ysep', 0.0)
    ysep = inpt.get_value('ysep', 'vertical separation between successive dsets', 0.0)
    pmask = inpt.get_value('pmask', 'do you want to plot the masked data too?', True)

    # Determine limits automatically if required
    if xoff !=0. or x1 == x2 or y1 == y2:
        xa1 = None
        xa2 = None
        ya1 = None
        ya2 = None
        yadd = 0.
        for i in slist:
            (xi1,xi2,yi1,yi2) = data[i].plimits()
            if xa1 is None:
                xa1 = xi1
            else:
                xa1 = min(xa1, xi1)

            if xa2 is None:
                xa2 = xi2
            else:
                xa2 = max(xa2, xi2)

            if ya1 is None and yi1 is not None:
                ya1 = yi1 + yadd
            elif yi1 is not None:
                ya1 = min(ya1, yi1 + yadd)

            if ya2 is None and yi2 is not None:
                ya2 = yi2 + yadd
            elif yi2 is not None:
                ya2 = max(ya2, yi2 + yadd)

            yadd += ysep

        if xa1 is None or xa2 is None or ya1 is None or ya2 is None:
            raise DintError('plot: no automatic limits could be evaluated; possibly no good data to plot?')

        if xoff == 0.0 and (xa2 - xa1) < (xa1+xa2)/2./100.:
            xoff = xa1
        xa1 -= xoff
        xa2 -= xoff

        if x1 == x2:
            x1 = xa1
            x2 = xa2

        if y1 == y2:
            y1 = ya1
            y2 = ya2

    try:

        pg.pgopen(device)
        pg.pgsci(4)
        pg.pgenv(x1, x2, y1, y2, 0, 0)
        pg.pgsci(2)
        first   = data[slist[0]]
        xlabel  = first.x.label if xoff == 0 else first.x.label + '-' + str(xoff)
        xlabel += ' (' + first.x.units + ')'
        ylabel  = first.y.label + ' (' + first.y.units + ')'
        pg.pglab(xlabel, ylabel, first.title)

        yadd = 0.
        for slot in slist:
            data[slot].plot(xoff,yoff=-yadd,masked=pmask)
            if not cdata.mute:
                print('Plotted slot ' + str(slot))
            yadd += ysep

        pg.pgclos()

    except pg.ioerror, err:
        raise DintError(str(err))
	inclination =81    	# Inclination of orbit
	phi = 20				# Angle offset of magnetic axis to orbital axis (not used yet)
	
	phaseArray = []
	angleArray = []
	# Plot theta as a function of orbital phase for these parameters
	for phase in numpy.arange(0.5, 1.51, 0.01):
		theta = computeViewingAngle(phase, inclination, beta, phi)
		phaseArray.append(phase)
		angleArray.append(theta)
		
	mainPlotWindow = ppgplot.pgopen("/xs")	
	ppgplot.pgask(False)
	pgPlotTransform = [0, 1, 0, 0, 0, 1]
	ppgplot.pgsci(1)
	ppgplot.pgenv(min(phaseArray), max(phaseArray), 0, 180, 0, 0)
	ppgplot.pgline(phaseArray, angleArray)
	ppgplot.pgsls(2)
	ppgplot.pgline([0.5, 1.5], [90, 90])
	ppgplot.pglab("orbital phase", "viewing angle", "Viewing angle \gh as a function of orbital phase.")
	ppgplot.pgtext(0.6, 150, "i:%2.0f \gb:%2.0f \gf:%2.0f"%(inclination, beta, phi))
		
	
	modelPlotWindow = ppgplot.pgopen("models_i_81_b_40.ps/ps")	
	pgPlotTransform = [0, 1, 0, 0, 0, 1]
	ppgplot.pgask(False)
	mainFluxMax = 0
	mainFluxMin = 1E99
	
	for phase in numpy.arange(0.5, 1.6, 0.1):
		
	fullFrameysize = ymax - ymin
	
	
	""" Set up the PGPLOT windows """
	xyPositionPlot = {}
	xyPositionPlot['pgplotHandle'] = ppgplot.pgopen('/xs')
	xyPositionPlot['yLimit'] = 1.0
	xyPositionPlot['numXYPanels'] = len(referenceApertures.sources)
	ppgplot.pgpap(6.18, 1.618)
	ppgplot.pgsubp(1, xyPositionPlot['numXYPanels'])
	ppgplot.pgsci(5)
	for panel in range(xyPositionPlot['numXYPanels']):
		currentSize = ppgplot.pgqch()
		ppgplot.pgsch(1)
		yLimit = xyPositionPlot['yLimit']
		ppgplot.pgenv(startFrame, startFrame + frameRange, -yLimit, yLimit, 0, -2)
		ppgplot.pgbox('A', 0.0, 0, 'BCG', 0.0, 0)
		ppgplot.pglab("", "%d"%panel, "")
		ppgplot.pgsch(currentSize)
	
	ppgplot.pgask(False)
	ppgplot.pgsci(1)
	
	
	if (arg.preview):		
		bitmapView = {}
		bitmapView['pgplotHandle'] = ppgplot.pgopen('/xs')
		ppgplot.pgpap(8, 1)
		
		ppgplot.pgenv(0.,fullFramexsize,0.,fullFrameysize, 1, 0)
		pgPlotTransform = [0, 1, 0, 0, 0, 1]
Exemple #42
0
h = 6.626e-26  #erg s
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()