Exemple #1
0
def BM_histogram(n=20, runs=100, **kwargs):
	plotter.Plotter.show_plots = False
	logger.VERBOSE = False

	Model = models.BooleanModel
	pbar = ProgressBar(maxval=runs)

	all_data = []
	pbar.start()
	for i in range(runs):
		e_num = round(n * 2.33)
		act = round(2133/(2133+1768) * e_num)
		inh = e_num-act
		#print(n, e_num, act, inh)

		g = utils.GraphGenerator.get_random_graph(n, activating_edges=act, inhibiting_edges=inh)

		sim = g.system.simulate(Model, **kwargs)
		all_data.extend(sim.flatten())
		pbar.update(i)
	pbar.finish()

	plt.gca().set_xscale('log')
	plt.gca().set_yscale('log')

	utils.present(
        'Histogram of simulated gene expression vector (%s, %s)' % (Model.info['name'], 'time norm' if models.BooleanModel.info['norm_time'] else 'gene norm'), plotter.Plotter.plot_histogram,
        'gene concentration', 'count', all_data,
		bins=np.logspace(-4, 0, 200)
    )
def main():
    vol, top = load_data()
    downsample = 3

    fig = mlab.figure(bgcolor=(1,1,1))

    x, y, z = hor2xyz(top, vol, downsample)
    build_sides(vol, x, y, z, vol.nz)

    # Build top
    seafloor = top_texture(top, vol)
    top_mesh = mlab.mesh(x, y, z)
    texture(top_mesh, np.flipud(seafloor.T), cm.gray)

    build_base(x, y, z, vol)
    utils.present(fig)
def main():
    z, x, y = read('data/alaska/clipped_elev.tif')
    rgb, _, _ = read('data/alaska/clipped_map.tif')
    rgb = np.swapaxes(rgb.T, 0, 1)

    fig = mlab.figure()

    surf = mlab.mesh(x[::2, ::2], y[::2, ::2], z[::2, ::2])
    utils.texture(surf, rgb)
    build_sides(x, y, z, -1000)
    build_bottom(x, y, z, -1000)

    
    utils.scale(fig, (1, 1, 2.5))
    utils.scale(fig, 0.00001)
#    shapeways_io.save_vrml(fig, 'models/alaska_textured_sides.zip')
    utils.present(fig)
def main():
    vol, coh, base, top = load_data()
    downsample = 3
    _, _, zbase = hor2xyz(base, vol, downsample)
    x, y, ztop = hor2xyz(top, vol, downsample)

    fig = mlab.figure(bgcolor=(1,1,1))

    build_sides(vol, x, y, ztop, zbase.min(), zbase)

    # Build Base
    base_mesh = mlab.mesh(x, y, zbase)
    chan = bottom_texture(base, vol)
    texture(base_mesh, np.flipud(chan.T), cm.gray)

    # Build top
    x, y, ztop = hor2xyz(top, vol, downsample)
    seafloor = top_texture(top, coh)
    top_mesh = mlab.mesh(x, y, ztop)
    texture(top_mesh, np.flipud(seafloor.T), cm.gray)

    utils.present(fig)
The boy surface is a mathematical parametric surface, see
http://en.wikipedia.org/wiki/Boy%27s_surface . We display it by sampling
the two parameters of the surface on a grid and using the mlab's mesh
function: :func:`mayavi.mlab.mesh`.
"""

# Author: Gael Varoquaux <*****@*****.**>
# Copyright (c) 2007, Enthought, Inc.
# License: BSD Style.


from numpy import sin, cos, mgrid, pi, sqrt
from mayavi import mlab

import utils

fig = mlab.figure(fgcolor=(0, 0, 0), bgcolor=(1, 1, 1))
u, v = mgrid[-0.035:pi:0.01, -0.035:pi:0.01]

X = 2 / 3.0 * (cos(u) * cos(2 * v) + sqrt(2) * sin(u) * cos(v)) * cos(u) / (sqrt(2) - sin(2 * u) * sin(3 * v))
Y = 2 / 3.0 * (cos(u) * sin(2 * v) - sqrt(2) * sin(u) * sin(v)) * cos(u) / (sqrt(2) - sin(2 * u) * sin(3 * v))
Z = -sqrt(2) * cos(u) * cos(u) / (sqrt(2) - sin(2 * u) * sin(3 * v))
S = sin(u)

mlab.mesh(X, Y, Z, scalars=S, colormap="YlGnBu")

# Nice view from the front
mlab.view(0.0, -5.0, 4)

utils.present(fig)