Ejemplo n.º 1
0
y = 0.5 + numpy.arange(ny)[:,numpy.newaxis]

# pyxplotcontour only works with 1D arrays
xx = 0.5 + numpy.arange(nx)
yy = 0.5 + numpy.arange(ny)

x0, y0 = (float(nx)/2, float(ny)/2) # origin for function
r = numpy.sqrt((x - x0)**2 + (y - y0)**2) # radius from origin

# # Gaussian function
# sigma = float(n)/20		  # width
# z = numpy.exp(-r**2/sigma**2)

# Radius function
z = r

pixmargin = 0

figwidth = 10
figheight = (ny+2*pixmargin)*figwidth/(nx + 2*pixmargin)
g = pyxgraph.pyxgraph(xlimits=(-pixmargin, nx+pixmargin), 
		      ylimits=(-pixmargin, ny+pixmargin),
		      width=figwidth, height=figheight, key=None)
graymap = pyxgraph.ColMapper.ColorMapper("pm3d", pm3d=[3,3,3])
g.pyxplotarray(z, colmap=graymap, compressmode=None,
	       xpos=0.0, ypos=0.0, width=nx, height=ny, graphcoords=True)
g.pyxplotcontour(z, xx, yy, levels=4, colors='color', color='red')
# plot a big green cross where the peak should be
g.pyxplot(data=((x0,0,0,nx,nx),(y0,0,ny,0,ny)), style="points", color="green", ps=5, pt=0)
g.writePDFfile("contour-test")
xx = (worldwidth/nx)*xx
yy = (worldheight/ny)*yy
# xx = (worldwidth/nx)*(xx+1.0)
# yy = (worldheight/ny)*(yy+1.0)
contourlevels = 3

for title, bx, by, bz, bscale, xshift, yshift in [
    [title_i, bxi, byi, bzi, bi_scale, 0, figheight + margin],
    [title_n, bxn, byn, bzn, bn_scale, figwidth + margin, figheight + margin],
    [title_m, bxm, bym, bzm, bm_scale, figwidth + margin, 0],
    ]:
    g = pyxgraph.pyxgraph(
        xlimits = (0, worldwidth), ylimits = (0, worldheight), 
        width = figwidth, height = figheight,
        key = None,
        title = None, xlabel = None, ylabel = None, 
        # title = title,
        # xlabel=r'$x$ (pc)',
        # ylabel=r'$y$ (pc)',
        xtexter = False, ytexter = False,
        )

    # Grayscale of z component
    g.pyxplotarray(bz[::-1,:], colmap=mycolmap, 
                   minvalue=-bscale*args.los_bscale, maxvalue=bscale*args.los_bscale,
                   xpos=0.0, ypos=0.0, width=worldwidth, height=worldheight, graphcoords=True)

    # Plot vectors of plane-of-sky field
    b = N.sqrt(bx**2 + by**2)/bscale # normalized magnitude of B-field
    b.clip(0.0, 1.0, out=b)       # make sure we don't get arrows too big

    theta = N.arctan2(by, bx) # angle of B with x-axis
Ejemplo n.º 3
0
fx = N.cumsum(data['bx'][:,0])[:,N.newaxis] # \int B_x dy
fy = N.cumsum(data['by'], axis=1) # \int B_y dx
vecpot = fy - fx

# Do the graph
import pyxgraph, pyx
pyx.text.set(mode="latex")
pyx.text.preamble(r"""\usepackage{mathpazo}""")
ny, nx = vecpot.shape
figwidth = 10.0
worldheight = worldwidth*ny/nx
figheight = ny*figwidth/nx
gleft = pyxgraph.pyxgraph(xlimits=(0, worldheight),
			  ylimits=(0, worldwidth),
			  width=figwidth, height=figheight,
			  key=None,
			  title=plottitle,
			  xlabel='$x$ (pc)',
			  ylabel='$y$ (pc)',
		      )
gright = pyxgraph.pyxgraph(xlimits=(0, worldheight),
			   ylimits=(0, worldwidth),
			   width=figwidth, height=figheight,
			   key=None,
			   title=plottitle,
			   xlabel='$x$ (pc)',
			   ylabel=None, ytexter=False,
			   )
# image of the density
# pm3d=[3,3,3] means linear in each channel
# pm3d=[4,4,4] means x**2 in each channel
# pm3d=[7,7,7] means x**0.5 in each channel
Ejemplo n.º 4
0
import pyx, pyxgraph, contour

for Av, D in [
    [0.0, 0.3],
    [1.0, 0.3],
    [2.0, 0.3],
    [5.0, 0.3],
    [10.0, 0.3],
    [50.0, 0.3],
    [0.0, 1.0],
    [1.0, 1.0],
    [2.0, 1.0],
    [5.0, 1.0],
    [10.0, 1.0],
    [50.0, 1.0],
    [0.0, 2.0],
    [1.0, 2.0],
    [2.0, 2.0],
    [5.0, 2.0],
    [10.0, 2.0],
    [50.0, 2.0],
    ]:
    tcgrid = thermal_time_years(ddgrid, ttgrid, Av, D)
    g = pyxgraph.pyxgraph(xlimits=(dmin, dmax), ylimits=(tmin, tmax), width=10, height=10)
    cooltimes = [1./x for x in [1.e2, 1.e3, 1.e4, 3.e4, 1.e5, 1.e6]]
    g.pyxplotcontour(1./tcgrid, dgrid, tgrid,
		     levels=cooltimes, colors="color", color=pyx.color.rgb.blue, labels=True)
    g.pyxplotcontour(-1./tcgrid, dgrid, tgrid,
		      levels=cooltimes, colors="color", color=pyx.color.rgb.red, labels=True)
    g.writePDFfile("hc-tcool-contour-Av%.1f-D%.1f" % (Av, D))