Esempio n. 1
0
def _visualize(map):
  try:
#    from alife.simulators.mayavi.plot3D import plot3d
    from mayavi import mlab
  except:
    print "Can't show you nice picture; couldn't import mayavi"
    return
#  plot3d(map)
  mlab.barchart(map, scale_factor=0.6) 
  mlab.show()
    def test_barchart(self):
        s = np.random.random((10, 10))
        x, y = np.indices(s.shape)
        bar1 = mlab.barchart(x, y, s)
        bar2 = mlab.barchart(s)
        bar3 = mlab.barchart(s, auto_scale=False)

        # Check that auto scaling worked well in the different
        # configurations
        for bar in bar1, bar2, bar3:
            self.assertEqual(bar.glyph.glyph_source.glyph_source.y_length, 0.9)
Esempio n. 3
0
    def test_barchart(self):
        s = np.random.random((10, 10))
        x, y = np.indices(s.shape)
        bar1 = mlab.barchart(x, y, s)
        bar2 = mlab.barchart(s)
        bar3 = mlab.barchart(s, auto_scale=False)

        # Check that auto scaling worked well in the different
        # configurations
        for bar in bar1, bar2, bar3:
            self.assertEqual(bar.glyph.glyph_source.glyph_source.y_length, 0.9)
Esempio n. 4
0
def analyze():
    mcs = []
    import mayavi.mlab as mlab
    
    for gamma_b in linspace(2*pi*1e3, 2*pi*17e3, 5):
        mc = MonteCarlo()
        mc.run_stats(35.5e-6, 0.1e-6, 300, gamma_b=gamma_b)
        mcs.append(mc)
        mlab.figure()
        mlab.barchart(mc.cov)
        mlab.axes()
        mlab.title("gamma_b/2pi = "+str(gamma_b/(2*pi)))
    return mcs
        
Esempio n. 5
0
 def plot_3d_barchart(self, data_dict, Type, Freq):
     ''' Using the mayavi library, plot a 3D barchart of the data of requested type, and freq.'''
 
     extent_dim = self._get_extent(3)
     Xlocs,Xlabels,Ylocs,Ylabels = self._get_ticks(5,5,extent_dim)
     data = self.get_data_type(data_dict, Type)
     v_min,v_max = self.get_data_scale(data_dict, Type)
     freq_array = data_dict['freq']
     freq_ind = self.get_nearest_freq(freq_array,Freq)
     
     from mayavi import mlab
     mlab.figure( bgcolor=(0.5,0.5,0.5) )# grey bg
     mlab.barchart(data[freq_ind,:,:],vmin=v_min,vmax=v_max,auto_scale=False,colormap='jet',extent = extent_dim)
     mlab.title('Freq %.3e' %freq_array[freq_ind],size=5,height=0.1)
     mlab.show()
Esempio n. 6
0
def build_from_bin(mp):
    boundary = mp.boundary
    start_index = mp.start_index
    _build_surface(start_index, boundary)

    bld_cells = filter(lambda cell: cell.tag == str2tag["Building"], mp.cells)
    bld_vecs = _build_buildings(bld_cells)
    return mb.barchart(*bld_vecs, colormap="summer")
Esempio n. 7
0
def mayavi_barchart():
    """
    绘制barchart图
    :return:
    """
    mlab.figure(fgcolor=(0, 0, 0), bgcolor=(1, 1, 1))  # 更改背景色
    # s = np.random.rand(3, 3)
    # print(s)
    # mlab.barchart(s)
    # mlab.vectorbar()
    # mlab.show()

    x, y = np.mgrid[-5:5:20j, -5:5:20j]
    # print(x, y)
    s = peaks(x, y)
    mlab.barchart(x, y, s)
    mlab.vectorbar()
    mlab.show()
Esempio n. 8
0
    def test_barchart(self):
        """Test the barchart function."""

        s = np.abs(np.random.random((3,3)))
        b = mlab.barchart(s)
        self.assertEqual(b.glyph.glyph.scale_mode,
                         'scale_by_vector_components')
        s += 1
        b.mlab_source.update()
        self.assertEqual(b.glyph.glyph.scale_mode,
                         'scale_by_vector_components')
    def test_barchart(self):
        """Test the barchart function."""

        s = np.abs(np.random.random((3, 3)))
        b = mlab.barchart(s)
        self.assertEqual(b.glyph.glyph.scale_mode,
                         'scale_by_vector_components')
        s += 1
        b.mlab_source.update()
        self.assertEqual(b.glyph.glyph.scale_mode,
                         'scale_by_vector_components')
Esempio n. 10
0
def build_from_json(m_dict):
    boundary = m_dict[strBoundary]
    start_index = m_dict.get(strLocation, [0, 0, 0])
    fig = _build_surface(start_index, boundary)
    if m_dict.get(strBuilding) is None:
        return fig

    all_list = [], [], [], []
    for bld_dict in m_dict[strBuilding]:
        location = bld_dict[strLocation]
        boundary = bld_dict[strBoundary]
        ret = _build_building(location, boundary)
        map(lambda item, item_list: item_list.extend(item), ret, all_list)

    return mb.barchart(*all_list, colormap="summer")
Esempio n. 11
0
from pylab import *

from mayavi import mlab

if __name__ == '__main__':

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

    mlab.barchart(np.random.random((3, 3)))

    mlab.savefig(sys.argv[1], size = (3000, 3000))
Esempio n. 12
0
def creator(name, curDir):
    saveName = name.split('.')[0]
    data = np.load(curDir+'/'+name)
    plotter = np.array([data[0]]).reshape(160,160)*255
    mlab.barchart(plotter, auto_scale=False, reset_zoom=False)
    mlab.savefig('../../mayaHist/'+saveName+'.png')
Esempio n. 13
0
import fileinput

class odor():
  def __init__(self, index, name, glom_weights):
    self.index = index
    self.name = name
    self.glom_weights = glom_weights

odors = {} # by name

for line in fileinput.input('input-odors.txt'):
  data = line.split('\t')
  odors.update({data[0]: odor(fileinput.lineno(), data[0], [float(i) for i in data[1:]])})

if __name__ == '__main__':
  for name in odors:
    print name, odors[name].index
  from mayavi.mlab import barchart, show
  barchart([odors[name].glom_weights for name in odors])
  show()
Esempio n. 14
0
def test_barchart():
    """ Demo the bar chart plot with a 2D array."""
    s = np.abs(np.random.random((3, 3)))
    return mlab.barchart(s)
Esempio n. 15
0
    # Coloque o bloco recem criado na lista auxiliar
    blocosaux.append(new_bloco)

    vetx.append(new_bloco[0])
    vety.append(new_bloco[1])
    vetz.append(new_bloco[2])

f.scene.disable_render = False

for cont1 in range(len(vetx)):

    if cont1 < 100:

        mlab.barchart(vetx[(cont1 - 1):cont1],
                      vety[(cont1 - 1):cont1],
                      vetz[(cont1 - 1):cont1],
                      resolution=20)
        camera.yaw(ang)

    else:
        if cont1 < 1000:
            limite = 10
            if cont1 % limite == 0:
                camera.yaw(ang)
                mlab.barchart(vetx[(cont1 - limite):cont1],
                              vety[(cont1 - limite):cont1],
                              vetz[(cont1 - limite):cont1],
                              resolution=20)
                #print cont1

        else:
Esempio n. 16
0
import numpy as np
import matplotlib.pyplot as plt
from scipy.special import gamma
# plot complex function

N = 300
# make scale
x = np.linspace(-5, 5, N)
y = np.linspace(-5, 5, N)
xx, yy = np.meshgrid(x, y)
z = xx + yy * 1.0j

# complex function
w = np.abs(gamma(z))
w[np.where(w > 10)] = 10
from mayavi import mlab

mlab.barchart(xx, yy, w)
mlab.show()
# color mapping
plt.pcolor(x, y, np.abs(w))
# countor line
# plt.contour(x, y, np.abs(w))
plt.colorbar()
plt.show()

Esempio n. 17
0
def anim():
    f = mlab.gcf()
    print("showing map")

    mlab.barchart(A1)
    mlab.barchart(A2)
    mlab.barchart(A3)
    mlab.barchart(A4)

    s = mlab.gcf()
    s.scene.background = (1, 1, 1)
    source = s.children[0]
    colors = source.children[0]
    # colors = manager.children[0]
    # print(colors)
    colors.scalar_lut_manager.lut_mode = "Blues"
    colors = s.children[1].children[0]
    colors.scalar_lut_manager.lut_mode = "Wistia"
    colors = s.children[2].children[0]
    colors.scalar_lut_manager.lut_mode = "RdYlBu"
    colors = s.children[3].children[0]
    colors.scalar_lut_manager.lut_mode = "OrRd"
    mlab.points3d(0,
                  0,
                  0,
                  mode='cube',
                  color=(1, 1, 0),
                  scale_mode='none',
                  scale_factor='0.5')
    mlab.points3d(9,
                  9,
                  0,
                  mode='cube',
                  color=(1, 1, 0),
                  scale_mode='none',
                  scale_factor='0.5')

    for scene_cnt in range(0, 27):
        print('Updating scene...  the number is ', scene_cnt)
        # mlab.clf(figure=None)
        num = scene_cnt
        plan_path_Hybrid1 = "plan_path_Hybrid_temp" + str(num) + ".npy"
        plan_path_Hybrid = np.load(file=plan_path_Hybrid1)
        # print("综合规划路径数组类型输出:",plan_path_Hybrid.shape)
        # print("输出Hybird路径:\n")
        # print(plan_path_Hybrid)
        # print("x=0时:")
        # print(plan_path_Hybrid[0])
        # print("测试...取第一维高度:")
        # print(plan_path_Hybrid[:,0])
        x1 = plan_path_Hybrid[:, 1]
        x1 = np.insert(x1, 0, 0)
        x1 = np.append(x1, 9)
        y1 = plan_path_Hybrid[:, 2]
        y1 = np.insert(y1, 0, 0)
        y1 = np.append(y1, 9)
        z1 = plan_path_Hybrid[:, 0] + 0.5
        z1 = np.insert(z1, 0, 0)
        z1 = np.append(z1, 0)

        # camera状态改变可视化过程
        camera_path = "plan_path_Hybrid_temp" + str(num) + ".npy"
        camera_path = np.load(file=camera_path)

        # print("测试...取摄像机开关状态:")
        c = plan_path_Hybrid[:, 3]
        # print(c)
        # print(len(c))
        # print(c[0])
        cc = []  # cc表示改变摄像机状态的点的位置集合
        for i in range(len(c)):
            if c[i] != c[i - 1]:
                # print(i-1,c[i-1])
                cc.append(i - 1)
        # print("改变摄像机状态的点的位置集合:",cc)
        ccc = []
        n = 2
        for i in range(0, len(cc), n):
            # print(cc[i:i + n])
            ccc.append(cc[i:i + n])
        # print("将状态的位置集合拆分成两两的线段:",ccc)
        # print("改变camera状态的线段的条数:",len(ccc))
        # print("####",np.shape(ccc)[0])

        # mlab.plot3d(x, y, z, color=(0.23, 0.6, 1), colormap='Spectral')
        mlab.plot3d(x1,
                    y1,
                    z1,
                    color=(0, 0, 1),
                    opacity=1,
                    tube_radius=None,
                    colormap='Spectral')
        mlab.plot3d(x,
                    y,
                    z,
                    color=(0, 0, 0),
                    opacity=1,
                    tube_radius=None,
                    colormap='Spectral')

        for i in range(np.shape(ccc)[0]):
            c1 = plan_path_Hybrid[ccc[i][0]:(ccc[i][1] + 1), 0:3]
            # print("******",c1)
            np.savetxt("c" + str(i) + ".txt", c1, fmt='%d', delimiter=' ')
            camera_path_1 = np.loadtxt("c" + str(i) + ".txt",
                                       delimiter=' ',
                                       dtype=int)
            # print("@@@@@@@@@",camera_path_1)
            X = camera_path_1[:, 1]
            Y = camera_path_1[:, 2]
            Z = camera_path_1[:, 0] + 0.5
            for i in range(np.shape(ccc)[0]):
                mlab.plot3d(X,
                            Y,
                            Z,
                            color=(0, 1, 0),
                            opacity=1,
                            tube_radius=None,
                            colormap='Spectral')

        a = plan_path_Hybrid[num][0]
        b = plan_path_Hybrid[num][1]
        c = plan_path_Hybrid[num][2]
        # print(c, a, b)
        mlab.points3d(b,
                      c,
                      a + 0.5,
                      mode='sphere',
                      color=(1, 1, 0),
                      scale_mode='none',
                      scale_factor='0.5')
        # mlab.view(focalpoint='auto')
        yield
Esempio n. 18
0
        reference_path = "reference_path2" + ".npy"
        reference = np.load(file=reference_path)
        # print(reference)

        x = reference[:, 1]
        x = np.insert(x, 0, 0)
        x = np.append(x, 18)
        # print("x的内容",x)
        y = reference[:, 2]
        y = np.insert(y, 9, 9)
        y = np.append(y, 9)
        z = reference[:, 0] + 0.5
        z = np.insert(z, 0, 0)
        z = np.append(z, 0)

        mlab.barchart(A1)
        # mlab.barchart(A2)
        # mlab.barchart(A3)
        mlab.barchart(A4)
        s = mlab.gcf()
        s.scene.background = (1, 1, 1)
        source = s.children[0]
        colors = source.children[0]
        colors.scalar_lut_manager.lut_mode = "Blues"
        colors = s.children[1].children[0]
        colors.scalar_lut_manager.lut_mode = "OrRd"
        # colors = s.children[2].children[0]
        # colors.scalar_lut_manager.lut_mode = "RdYlBu"
        # colors = s.children[3].children[0]
        # colors.scalar_lut_manager.lut_mode = "Wistia"
Esempio n. 19
0
  # integer toward 0 min, max, inc where min is 0, if not in interval
  #return False
  if (x < d[0] or x > d[1]):
    return False
  return int((x - d[0])/d[2])


def compute():
  for i in range(nhost):
    pc.submit(f, i)
  den = numpy.zeros(matrank)
  while(pc.working()):
    den += pc.pyret()  
  return den

if __name__ == '__main__':
  pc.runworker()
  density = compute()
  pc.done()
  print "density max = ", density.max()
  density = density * (20/density.max())

  import pickle
  pickle.dump(density, open('density.dat', 'w'))

#following works on linux if using openmpi
from mayavi.mlab import barchart,show
barchart(density)
show()

Esempio n. 20
0
import numpy as np
from mayavi import mlab

ZP = np.load("orderbook_shorter.npy")
X, Y = np.mgrid[0:ZP.shape[0]:1, 0:ZP.shape[1]:1]
print(X.shape, Y.shape, ZP.shape)

s = mlab.barchart(X, Y, ZP)
mlab.show()
Esempio n. 21
0
cNorm = colors.Normalize(vmin=0, vmax=vv[-1])
scalarMap = cmx.ScalarMappable(norm=cNorm, cmap=cm)
colorVals = [scalarMap.to_rgba(i) for i in range(ly)]

# generate plot data
xpos = np.arange(0,lx,1)
ypos = np.arange(0,ly,1)
xpos, ypos = np.meshgrid(xpos+0.25, ypos+0.25)
xpos = xpos.flatten()
ypos = ypos.flatten()
zpos = np.zeros(n)
dx = 0.5*np.ones_like(zpos)
dy = dx.copy()
dz = dat.flatten()
cc = np.tile(range(lx), (ly,1))
cc = cc.T.flatten()

# generate plot
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
opacity = 1

mlab.barchart(xpos,ypos,dz*100)

# for i in range(n):
#     ax.bar3d(xpos[i], ypos[i], zpos[i], dx[i], dy[i], dz[i],
#              color=colorVals[cc[i]], alpha=opacity, zsort='max')
#
# plt.autoscale(enable=True, axis='both', tight=True)
# plt.grid()
# plt.show()
Esempio n. 22
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy as np
import mayavi.mlab as mlab

mlab.figure(fgcolor=(0, 0, 0), bgcolor=(1, 1, 1))  #更改背景色
p = np.random.normal(size=(20, 20))
mlab.barchart(p)  #x,y为矩阵p的坐标,可以省略
mlab.vectorbar()  #颜色bar
mlab.show()
Esempio n. 23
0
regions = lulu.decompose(img)

value_maxes = []
height = 0
for area in sorted(regions.keys()):
    pulses = regions[area]

    if len(pulses) == 0 or area < 280 or area > 300:
        continue

    values = [crh.get_value(p) for p in pulses]
    height_diff = max(values) - min(values)
    value_maxes.append(height_diff)
    centre = height + height_diff / 2.0

    pulse_values = np.zeros_like(img)
    for p in pulses:
        crh.set_array(pulse_values, p, crh.get_value(p))

    y, x = np.where(pulse_values)
    s = pulse_values[y, x]

    mlab.barchart(x, y, [height + centre] * len(s), s,
                  opacity=1.0, scale_factor=1.5)

    height += height_diff + 0.5

scene = mlab.get_engine().scenes[0]
scene.scene.parallel_projection = True
mlab.show()
Esempio n. 24
0
#					if check_on(events,i,j,k,ioct,t2):
#						s[i][j][k] = ioct+1.0
#
#
#	mlab.barchart(s,vmin=0,vmax=8,scale_mode='none',line_width=5.0,lateral_scale=1.0,transparent=True)
#	return mlab.screenshot(antialiased=True)

frames = []
for t in np.linspace(0., (duration), int(fps * duration)):
    data.append(get_data(t))

temp_view = data[0]
bar = mlab.barchart(temp_view,
                    vmin=0.0,
                    vmax=9.0,
                    scale_mode='none',
                    line_width=2.0,
                    lateral_scale=0.99,
                    auto_scale=False)
lut = bar.module_manager.scalar_lut_manager.lut.table.to_array()

#for i in range(8):
#	lut[i+1] = lut[255*i/9]
lut[0] = [0, 0, 0, 10]
bar.module_manager.scalar_lut_manager.lut.table = lut

data2 = []
for view in data:
    data2.append(np.reshape(view, np.product(view.shape)))

#for view in data:
for node in G.nodes():
	#Function call Kwalk(G,node,k_walk_length,numOfRandomWalks)
	Kwalk(G,node,k_walk_length,numOfRandomWalks)
	

# Flag_Node_Pair = [ ( Number of Flags,Node ) , ( , ) ..............]
Flag_Node_Pair = Flagger.items()
total=sum(Flagger.values())
s =[]
for i in range(m):
	x = []
	for j in range(n):
		x.append(Flagger[(i,j)]*600/float(total))
	s.append(x)
m = numpy.array([i for i in s ])
mlab.barchart(m)
mlab.show()
"""
for i in range(len(Flag_Node_Pair)):
	Flag_Node_Pair[i] = (Flag_Node_Pair[i][1],Flag_Node_Pair[i][0])

#Sorting the Flag_Node_Pair, to find the nodes which have most frequently visited !

Flag_Node_Pair.sort()
Flag_Node_Pair.reverse()


for length_set in range(1,len(Flag_Node_Pair)):
	DominatingSet = [i[1] for i in Flag_Node_Pair[:length_set]] 
	if Correctness_Of_DominatingSet(G,k_walk_length,numOfRandomWalks,DominatingSet) :
		break
Esempio n. 26
0
import fileinput


class odor():
    def __init__(self, index, name, glom_weights):
        self.index = index
        self.name = name
        self.glom_weights = glom_weights


odors = {}  # by name

for line in fileinput.input('input-odors.txt'):
    data = line.split('\t')
    odors.update({
        data[0]:
        odor(fileinput.lineno(), data[0], [float(i) for i in data[1:]])
    })

if __name__ == '__main__':
    for name in odors:
        print name, odors[name].index
    from mayavi.mlab import barchart, show
    barchart([odors[name].glom_weights for name in odors])
    show()
Esempio n. 27
0
def main_plot4():
    __import__("matplotlib").rcParams.update({'axes.labelsize': 20,
                                              'axes.titlesize': 20})
    from mayavi import mlab

    names = ['res5.json', 'res24.json', 'res26.json', 'res29.json']
    ps = _load_jsons(names, 'ps')
    ns = _load_jsons(names, 'ns')

    size = 20
    t_size = 50

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

    T_fine = r_[0:len(ps) - 1:(t_size + 1) * 1j].astype(int)
    N_fine = r_[:size + 1]
    T_fine, N_fine = np.meshgrid(T_fine, N_fine)

    P_all = array([(array(p[:len(p) // 2]) + p[len(p) // 2:]) for p in ps])
    P_fine = P_all[T_fine, N_fine]
    # No idea what's wrong with the extent here ....
    surf = mlab.barchart(P_fine * size, colormap='blue-red',
                         extent=[0, size, 0, size, 0, 1 + 2. / size],
                         figure=fig)
    # surf.module_manager.scalar_lut_manager.reverse_lut = True

    ax0 = new_axis(fig)
    ax0.axes.x_label = "State (n)"
    ax0.axes.y_label = "Time"
    ax0.axes.z_label = "Population"
    ax0.axes.x_axis_visibility = False
    ax0.axes.y_axis_visibility = False
    ax0.axes.z_axis_visibility = True
    ax0.axes.number_of_labels = 3
    ax0.axes.use_data_bounds = False
    ax0.axes.bounds = [0, size, 0, size, 0, size]
    ax0.axes.ranges = [0, len(N_fine) - 1, 0, 1, 0, 1]
    ax0.axes.use_ranges = True
    ax0.axes.label_format = '%.1f'

    ax1 = new_axis(fig)
    ax1.axes.x_label = "State (n)"
    ax1.axes.y_label = "Time"
    ax1.axes.z_label = "Population"
    ax1.axes.x_axis_visibility = False
    ax1.axes.y_axis_visibility = True
    ax1.axes.z_axis_visibility = False
    ax1.axes.number_of_labels = 6
    ax1.axes.use_data_bounds = False
    ax1.axes.bounds = [0, size, 0, size, 0, size]
    ax1.axes.ranges = [0, len(N_fine) - 1, 0, 1, 0, 1]
    ax1.axes.use_ranges = True
    ax1.axes.label_format = '%.1f'

    ax2 = new_axis(fig)
    ax2.axes.x_label = "State (n)"
    ax2.axes.y_label = "Time"
    ax2.axes.z_label = "Population"
    ax2.axes.x_axis_visibility = True
    ax2.axes.y_axis_visibility = False
    ax2.axes.z_axis_visibility = False
    ax2.axes.number_of_labels = 6
    ax2.axes.use_data_bounds = False
    ax2.axes.bounds = [0, size, 0, size, 0, size]
    ax2.axes.ranges = [0, len(N_fine) - 1, 0, 1, 0, 1]
    ax2.axes.use_ranges = True
    ax2.axes.label_format = '%.0f'
    ax2.title_text_property.vertical_justification = 'center'
    ax2.label_text_property.vertical_justification = 'center'
    ax2.label_text_property.justification = 'right'

    mlab.outline(surf, color=(0., 0., 0.),
                 extent=[0, size, 0, size, 0, size])
    # mlab.show_pipeline()
    mlab.view(290, 90)
    mlab.show()
Esempio n. 28
0
#		for k in range(nz):
#			for j in range(ny):
#				for i in range(nx):
#					if check_on(events,i,j,k,ioct,t2):
#						s[i][j][k] = ioct+1.0
#			
#		
#	mlab.barchart(s,vmin=0,vmax=8,scale_mode='none',line_width=5.0,lateral_scale=1.0,transparent=True)
#	return mlab.screenshot(antialiased=True)

frames = []
for t in np.linspace(0.,(duration),int(fps*duration)):
	data.append(get_data(t))

temp_view = data[0];
bar = mlab.barchart(temp_view,vmin=0.0,vmax=9.0,scale_mode='none',line_width=2.0,lateral_scale=0.99,auto_scale=False)
lut = bar.module_manager.scalar_lut_manager.lut.table.to_array()

#for i in range(8):
#	lut[i+1] = lut[255*i/9]
lut[0] = [0,0,0,10]
bar.module_manager.scalar_lut_manager.lut.table = lut

data2 = []
for view in data:
	data2.append(np.reshape(view,np.product(view.shape)))

#for view in data:
#	bar.mlab_source.set(scalars=np.reshape(view,np.product(view.shape)))

Esempio n. 29
0
    # print used_ip
    tmp = sorted([int(re.search("\d+$", each).group()) for each in used_ip])
    print tmp

    tmp = np.zeros(16 * 16)
    for each in get_ip_last_num(used_ip):
        tmp[each] = 1
    # fig = plt.figure()
    # ax = fig.add_subplot(111, projection='3d')

    # print tmp
    # ax.bar3d(range(16)*16, get_y(), np.zeros(16*16), 1, 1, tmp, 'b', alpha=0.8)
    #
    # fig.show()

    mlab.barchart(range(16) * 16, get_y(), tmp + 0.01)
    last_time = last_time - 1

    #必须加入show()才能正常显示。。
    mlab.show()

    #     sleep(30)
    # ip_nums_file.close()

    # while (1):
    # g = IP2MAC()
    # for each in used_ip:
    # print each, g.getMac(each)

    # # used_ip.sort()
    # for each in used_ip:
Esempio n. 30
0
'''

import numpy as np
import mayavi.mlab as mlab

sig = np.array([[1.75, 1.88, 2.79],
                [1.56, 1.81, 2.13],
                [1.18, 4.11, 3.77]], dtype='f')
#sig_max = np.max(sig)
#sig /= sig_max

kappa = np.array([[1.4519, 2.5000, 6.7886],
                  [5.2363, 13.6182, 16.9232],
                  [14.4421, 22.9346, 39.0977]], dtype='f')
#kmax = np.max(kappa)
#kappa /= kmax

thickness = np.array([8, 14, 20], dtype='f')[:, None] * np.ones_like(sig)
angle = np.array([0, 10, 20], dtype='f')[None, :] * np.ones_like(sig)


mlab.figure(bgcolor=(1, 1, 1))
#mlab.barchart(thickness, angle, kappa, lateral_scale=0.4)
mlab.barchart(thickness, angle, sig, lateral_scale=0.4)

mlab.axes(xlabel='thickness',
          ylabel='angle',
          zlabel='crack initiation stress', nb_labels=3)

mlab.show()
Esempio n. 31
0
import mayavi.mlab as mlab
import xml_loader as loader

CHAIN = loader.xml_dataloader("../build/chain_nor.xml", "Nor")

mlab.figure(size=(1920, 1080))

barc = mlab.barchart(CHAIN,
                     lateral_scale=1,
                     colormap='viridis',
                     scale_factor=0.5)  #colormap='viridis'

mlab.colorbar(object=barc, orientation='vertical', nb_labels=10)
mlab.view(azimuth=270, elevation=0)
mlab.gcf().scene.parallel_projection = True

cam = barc.scene.camera

cam.zoom(1.2)
mlab.draw()

# mlab.savefig(filename='color_'+file_name)

mlab.show()
Esempio n. 32
0
		blocos.append(new_bloco);
	
	# Coloque o bloco recem criado na lista auxiliar
	blocosaux.append(new_bloco)

	vetx.append(new_bloco[0]);
	vety.append(new_bloco[1]);
	vetz.append(new_bloco[2]);
	
f.scene.disable_render = False

for cont1 in range(len(vetx)): 
		
	if cont1 < 100:
        
		mlab.barchart(vetx[(cont1-1):cont1], vety[(cont1-1):cont1], vetz[(cont1-1):cont1], resolution = 20)
		camera.yaw(ang)

	else:
		if cont1 < 1000:
			limite = 10
			if cont1%limite == 0:
				camera.yaw(ang)
				mlab.barchart(vetx[(cont1-limite):cont1], vety[(cont1-limite):cont1], vetz[(cont1-limite):cont1], resolution = 20)
				#print cont1
				
		else:
			limite = 100
			if cont1%limite == 0:
				camera.yaw(-ang)
				mlab.barchart(vetx[(cont1-limite):cont1], vety[(cont1-limite):cont1], vetz[(cont1-limite):cont1], resolution = 20)
Esempio n. 33
0
def make_frame(t):
    # x = volumes_data[:, :, :, int(t * 100/5/2)]
    # vol.mlab_source.set(scalars=x)
    mlab.clf(figure=None)
    print(int(t * 100 / 5 / 2))
    mlab.barchart(A1)
    mlab.barchart(A2)
    mlab.barchart(A3)
    mlab.barchart(A4)

    mlab.points3d(0,
                  0,
                  0,
                  mode='cube',
                  color=(1, 1, 0),
                  scale_mode='none',
                  scale_factor='0.5')
    mlab.points3d(A.shape[0] - 1,
                  A.shape[1] - 1,
                  0,
                  mode='cube',
                  color=(1, 1, 0),
                  scale_mode='none',
                  scale_factor='0.5')
    num = int(t)
    # plan_path_Hybrid1 = "plan_path_Hybrid_temp" + str(num) + ".npy"
    plan_path_Hybrid1 = "plan_path_PP_temp" + str(num) + ".npy"
    plan_path_Hybrid = np.load(file=plan_path_Hybrid1)
    # print("综合规划路径数组类型输出:",plan_path_Hybrid.shape)
    # print("输出Hybird路径:\n")
    # print(plan_path_Hybrid)
    # print("x=0时:")
    # print(plan_path_Hybrid[0])
    # print("测试...取第一维高度:")
    # print(plan_path_Hybrid[:,0])
    x1 = plan_path_Hybrid[:, 1]
    x1 = np.insert(x1, 0, 0)
    x1 = np.append(x1, A.shape[0] - 1)
    y1 = plan_path_Hybrid[:, 2]
    y1 = np.insert(y1, 0, 0)
    y1 = np.append(y1, A.shape[1] - 1)
    z1 = plan_path_Hybrid[:, 0] + 0.5
    z1 = np.insert(z1, 0, 0)
    z1 = np.append(z1, 0)

    # camera状态改变可视化过程
    # camera_path = "plan_path_Hybrid_temp" + str(num) + ".npy"
    camera_path = "plan_path_PP_temp" + str(num) + ".npy"
    camera_path = np.load(file=camera_path)

    # print("测试...取摄像机开关状态:")
    c = plan_path_Hybrid[:, 3]
    # print(c)
    # print(len(c))
    # print(c[0])
    cc = []  # cc表示改变摄像机状态的点的位置集合
    for i in range(len(c)):
        if c[i] != c[i - 1]:
            # print(i-1,c[i-1])
            cc.append(i - 1)
    # print("改变摄像机状态的点的位置集合:",cc)
    ccc = []
    n = 2
    for i in range(0, len(cc), n):
        # print(cc[i:i + n])
        ccc.append(cc[i:i + n])
    # print("将状态的位置集合拆分成两两的线段:",ccc)
    # print("改变camera状态的线段的条数:",len(ccc))
    # print("####",np.shape(ccc)[0])

    # mlab.plot3d(x, y, z, color=(0.23, 0.6, 1), colormap='Spectral')
    mlab.plot3d(x1,
                y1,
                z1,
                color=(0, 0, 1),
                opacity=1,
                tube_radius=None,
                colormap='Spectral')
    mlab.plot3d(x,
                y,
                z,
                color=(0, 0, 0),
                opacity=1,
                tube_radius=None,
                colormap='Spectral')

    for i in range(np.shape(ccc)[0]):
        c1 = plan_path_Hybrid[ccc[i][0]:(ccc[i][1] + 1), 0:3]
        # print("******",c1)
        np.savetxt("c" + str(i) + ".txt", c1, fmt='%d', delimiter=' ')
        camera_path_1 = np.loadtxt("c" + str(i) + ".txt",
                                   delimiter=' ',
                                   dtype=int)
        # print("@@@@@@@@@",camera_path_1)
        X = camera_path_1[:, 1]
        Y = camera_path_1[:, 2]
        Z = camera_path_1[:, 0] + 0.5
        for i in range(np.shape(ccc)[0]):
            mlab.plot3d(X,
                        Y,
                        Z,
                        color=(0, 1, 0),
                        opacity=1,
                        tube_radius=None,
                        colormap='Spectral')

    a = plan_path_Hybrid[num][0]
    b = plan_path_Hybrid[num][1]
    c = plan_path_Hybrid[num][2]
    # print(c, a, b)
    mlab.points3d(b,
                  c,
                  a + 0.5,
                  mode='cube',
                  color=(1, 1, 0),
                  scale_mode='none',
                  scale_factor='0.5')

    s = mlab.gcf()
    s.scene.background = (1, 1, 1)
    source = s.children[0]
    colors = source.children[0]
    # colors = manager.children[0]
    # print(colors)
    colors.scalar_lut_manager.lut_mode = "Blues"
    colors = s.children[1].children[0]
    colors.scalar_lut_manager.lut_mode = "Wistia"
    colors = s.children[2].children[0]
    colors.scalar_lut_manager.lut_mode = "RdYlBu"
    colors = s.children[3].children[0]
    colors.scalar_lut_manager.lut_mode = "OrRd"
    mlab.move(forward=-4, right=-4)

    mlab.savefig('abc.png', figure=mlab.gcf(), magnification=2)

    # mlab.show()

    # return mlab.screenshot(antialiased=True)
    print(mlab.screenshot(figure=None, mode='rgb', antialiased=False))
    return mlab.screenshot(figure=None, mode='rgb', antialiased=False)
Esempio n. 34
0
 def plot_cov(self):
     import mayavi.mlab as mlab
     mlab.figure()
     mlab.barchart(self.cov)
     mlab.axes()
Esempio n. 35
0
n = len(p1)
n_side = int(math.sqrt(n))

# zigzag_idx = zigzag(n_side)     # make zigzag index
# prime_digits = p1[zigzag_idx]    # put primes sequence in zigzag

# uncomment one; this or zizzag(above) for differnet arrangement
spiral_idx = spiral(n_side) - 1  # make spiral index
prime_digits = p1[spiral_idx]  # put primes sequence in spiral

x = np.arange(0, n_side, 1)
xs = np.tile(x, n_side)

y = np.arange(1, n_side + 1, 1)
ys = np.repeat(y, n_side)

dz = np.ravel(prime_digits)

fig = mlab.figure(bgcolor=(0, 0, 0), size=(1280, 1024))

s = mlab.barchart(xs,
                  ys,
                  dz,
                  opacity=1,
                  colormap='spectral',
                  extent=(0, 2, 0, 2, 0, 0.001))
s.glyph.color_mode = 'color_by_vector'

mlab.savefig('babylon_1.obj')
mlab.show()
Esempio n. 36
0
height = 0
for area in sorted(regions.keys()):
    pulses = regions[area]

    if len(pulses) == 0 or area < 280 or area > 300:
        continue

    values = [crh.get_value(p) for p in pulses]
    height_diff = max(values) - min(values)
    value_maxes.append(height_diff)
    centre = height + height_diff / 2.0

    pulse_values = np.zeros_like(img)
    for p in pulses:
        crh.set_array(pulse_values, p, crh.get_value(p))

    y, x = np.where(pulse_values)
    s = pulse_values[y, x]

    mlab.barchart(x,
                  y, [height + centre] * len(s),
                  s,
                  opacity=1.0,
                  scale_factor=1.5)

    height += height_diff + 0.5

scene = mlab.get_engine().scenes[0]
scene.scene.parallel_projection = True
mlab.show()