• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python io.load_data_file函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中vispy.io.load_data_file函数的典型用法代码示例。如果您正苦于以下问题:Python load_data_file函数的具体用法?Python load_data_file怎么用?Python load_data_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了load_data_file函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(self):
        self.program = gloo.Program(self.VERT_SHADER, self.FRAG_SHADER)

        brain = np.load(load_data_file('brain/brain.npz', force_download='2014-09-04'))
        data = brain['vertex_buffer']
        faces = brain['index_buffer']

        self.theta, self.phi = -80, 180
        self.translate = 3

        self.faces = gloo.IndexBuffer(faces)
        self.program.bind(gloo.VertexBuffer(data))

        self.model = translate(np.eye(4), 0, 0, -5)
        self.program['model'] = self.model

        self.view = np.eye(4)
        self.program['view'] = self.view
        self.program['u_color'] = 1, 1, 1, 1
        self.program['u_light_position'] = (1., 1., 1.)
        self.program['u_light_intensity'] = (1., 1., 1.)


        self.projection = np.eye(4)
        self.program['projection'] = self.projection
开发者ID:jpanikulam,项目名称:visar,代码行数:25,代码来源:brain.py


示例2: __init__

    def __init__(self, param=None):
        """Main Window for holding the Vispy Canvas and the parameter
        control menu.
        """
        QtWidgets.QMainWindow.__init__(self)

        self.resize(1067, 800)
        icon = load_data_file('wiggly_bar/spring.ico')
        self.setWindowIcon(QtGui.QIcon(icon))
        self.setWindowTitle('Nonlinear Physical Model Simulation')

        self.parameter_object = SetupWidget(self)
        self.parameter_object.param = (param
                                       if param is not None else
                                       self.parameter_object.param)
        self.parameter_object.changed_parameter_sig.connect(self.update_view)

        self.view_box = WigglyBar(**self.parameter_object.param.props)

        self.view_box.create_native()
        self.view_box.native.setParent(self)

        splitter = QtWidgets.QSplitter(QtCore.Qt.Horizontal)
        splitter.addWidget(self.parameter_object)
        splitter.addWidget(self.view_box.native)

        self.setCentralWidget(splitter)
开发者ID:vispy,项目名称:vispy,代码行数:27,代码来源:wiggly_bar.py


示例3: __init__

    def __init__(self):
        visuals.Visual.__init__(self)

        # Create an interesting mesh shape for demonstration.
        fname = io.load_data_file('orig/triceratops.obj.gz')
        vertices, faces, normals, tex = io.read_mesh(fname)

        self._ibo = gloo.IndexBuffer(faces)

        self.program = visuals.shaders.ModularProgram(vertex_shader,
                                                      fragment_shader)
        self.program.vert['position'] = gloo.VertexBuffer(vertices)
开发者ID:sonalranjit,项目名称:shapetrace-Python,代码行数:12,代码来源:pointcloud-Pan.py


示例4: __init__

    def __init__(self):
        visuals.Visual.__init__(self, vertex_shader, fragment_shader)

        # Create an interesting mesh shape for demonstration.
        fname = io.load_data_file('orig/triceratops.obj.gz')
        vertices, faces, normals, tex = io.read_mesh(fname)

        self._ibo = gloo.IndexBuffer(faces)

        self.shared_program.vert['position'] = gloo.VertexBuffer(vertices)
        # self.program.vert['normal'] = gloo.VertexBuffer(normals)
        self.set_gl_state('additive', cull_face=False)
        self._draw_mode = 'triangles'
        self._index_buffer = self._ibo
开发者ID:Eric89GXL,项目名称:vispy,代码行数:14,代码来源:T05_viewer_location.py


示例5: _setup_textures

 def _setup_textures(self, fname):
     data = imread(load_data_file('jfa/' + fname))[::-1].copy()
     self.texture_size = data.shape
     self.orig_tex = Texture2D(data, format='luminance', wrapping='repeat',
                               interpolation='nearest')
     self.comp_texs = []
     data = np.zeros(self.texture_size + (4,), np.float32)
     for _ in range(2):
         tex = Texture2D(data, format='rgba', wrapping='clamp_to_edge',
                         interpolation='nearest')
         self.comp_texs.append(tex)
     self.fbo_to[0].color_buffer = self.comp_texs[0]
     self.fbo_to[1].color_buffer = self.comp_texs[1]
     for program in self.programs:
         program['texw'], program['texh'] = self.texture_size
开发者ID:Zulko,项目名称:vispy,代码行数:15,代码来源:jfa_vispy.py


示例6: test_show_vispy

def test_show_vispy():
    """Some basic tests of show_vispy"""
    if has_matplotlib():
        n = 200
        t = np.arange(n)
        noise = np.random.RandomState(0).randn(n)
        # Need, image, markers, line, axes, figure
        plt.figure()
        ax = plt.subplot(211)
        ax.imshow(read_png(load_data_file('pyplot/logo.png')))
        ax = plt.subplot(212)
        ax.plot(t, noise, 'ko-')
        plt.draw()
        canvases = plt.show()
        canvases[0].close()
    else:
        assert_raises(ImportError, plt.show)
开发者ID:NoriVicJr,项目名称:vispy,代码行数:17,代码来源:test_show_vispy.py


示例7: __init__

    def __init__(self):
        app.Canvas.__init__(self, title='Molecular viewer',
                            keys='interactive')
        self.size = 1200, 800

        self.translate = 40
        self.program = gloo.Program(vertex, fragment)
        self.view = translate((0, 0, -self.translate))
        self.model = np.eye(4, dtype=np.float32)
        self.projection = np.eye(4, dtype=np.float32)

        fname = load_data_file('molecular_viewer/micelle.npz')
        self.load_molecule(fname)
        self.load_data()

        self.theta = 0
        self.phi = 0

        self._timer = app.Timer('auto', connect=self.on_timer, start=True)
开发者ID:rreilink,项目名称:vispy,代码行数:19,代码来源:molecular_viewer.py


示例8: _setup_textures

    def _setup_textures(self, fname):
        img = Image.open(load_data_file('jfa/' + fname))
        self.texture_size = tuple(img.size)
        data = np.array(img, np.ubyte)[::-1].copy()
        self.orig_tex = Texture2D(data, format='luminance')
        self.orig_tex.wrapping = 'repeat'
        self.orig_tex.interpolation = 'nearest'

        self.comp_texs = []
        data = np.zeros(self.texture_size + (4,), np.float32)
        for _ in range(2):
            tex = Texture2D(data, format='rgba')
            tex.interpolation = 'nearest'
            tex.wrapping = 'clamp_to_edge'
            self.comp_texs.append(tex)
        self.fbo_to[0].color_buffer = self.comp_texs[0]
        self.fbo_to[1].color_buffer = self.comp_texs[1]
        for program in self.programs:
            program['texw'], program['texh'] = self.texture_size
开发者ID:gbaty,项目名称:vispy,代码行数:19,代码来源:jfa_vispy.py


示例9: loadShapeTexture

def loadShapeTexture(filename, texID):
    """loadShapeTexture - load 8-bit shape texture data
    from a TGA file and set up the corresponding texture object."""
    data, texw, texh = loadImage(load_data_file('jfa/' + filename))
    gl.glActiveTexture(gl.GL_TEXTURE0)
    gl.glBindTexture(gl.GL_TEXTURE_2D, texID)
    # Load image into texture
    gl.glTexImage2D(gl.GL_TEXTURE_2D, 0, gl.GL_LUMINANCE, texw, texh, 0,
                    gl.GL_LUMINANCE, gl.GL_UNSIGNED_BYTE, data)
    # This is the input image. We want unaltered 1-to-1 pixel values,
    # so specify nearest neighbor sampling to be sure.
    gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER,
                       gl.GL_NEAREST)
    gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER,
                       gl.GL_NEAREST)
    gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_S, gl.GL_REPEAT)
    gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_T, gl.GL_REPEAT)
    checkGLError()
    return texw, texh
开发者ID:gbaty,项目名称:vispy,代码行数:19,代码来源:jfa_translation.py


示例10: __init__

  def __init__(self):
    app.Canvas.__init__(self, keys='interactive', size=(800, 600))

    dirname = path.join(path.abspath(path.curdir),'data')
    positions, faces, normals, texcoords = \
      read_mesh(load_data_file('cube.obj', directory=dirname))

    self.filled_buf = gloo.IndexBuffer(faces)

    if False:
      self.program = gloo.Program(VERT_TEX_CODE, FRAG_TEX_CODE)
      self.program['a_position'] = gloo.VertexBuffer(positions)
      self.program['a_texcoord'] = gloo.VertexBuffer(texcoords)
      self.program['u_texture'] = gloo.Texture2D(load_crate())
    else:
      self.program = gloo.Program(VERT_COLOR_CODE, FRAG_COLOR_CODE)
      self.program['a_position'] = gloo.VertexBuffer(positions)
      self.program['u_color'] = 1, 0, 0, 1

    self.view = translate((0, 0, -5))
    self.model = np.eye(4, dtype=np.float32)

    gloo.set_viewport(0, 0, self.physical_size[0], self.physical_size[1])
    self.projection = perspective(45.0, self.size[0] /
                                  float(self.size[1]), 2.0, 10.0)

    self.program['u_projection'] = self.projection

    self.program['u_model'] = self.model
    self.program['u_view'] = self.view

    self.theta = 0
    self.phi = 0

    gloo.set_clear_color('gray')
    gloo.set_state('opaque')
    gloo.set_polygon_offset(1, 1)

    self._timer = app.Timer('auto', connect=self.on_timer, start=True)

    self.show()
开发者ID:jay3sh,项目名称:vispy,代码行数:41,代码来源:objloader.py


示例11: get_image

def get_image():
    """Load an image from the demo-data repository if possible. Otherwise,
    just return a randomly generated image.
    """
    from vispy.io import load_data_file, read_png
    
    try:
        return read_png(load_data_file('mona_lisa/mona_lisa_sm.png'))
    except Exception as exc:
        # fall back to random image
        print("Error loading demo image data: %r" % exc)

    # generate random image
    image = np.random.normal(size=(100, 100, 3))
    image[20:80, 20:80] += 3.
    image[50] += 3.
    image[:, 50] += 3.
    image = ((image - image.min()) *
             (253. / (image.max() - image.min()))).astype(np.ubyte)
    
    return image
开发者ID:Eric89GXL,项目名称:vispy,代码行数:21,代码来源:image_visual.py


示例12: test_wavefront

def test_wavefront():
    """Test wavefront reader"""
    fname_mesh = load_data_file('orig/triceratops.obj.gz')
    fname_out = op.join(temp_dir, 'temp.obj')
    mesh1 = read_mesh(fname_mesh)
    assert_raises(IOError, read_mesh, 'foo.obj')
    assert_raises(ValueError, read_mesh, op.abspath(__file__))
    assert_raises(ValueError, write_mesh, fname_out, *mesh1, format='foo')
    write_mesh(fname_out, mesh1[0], mesh1[1], mesh1[2], mesh1[3])
    assert_raises(IOError, write_mesh, fname_out, *mesh1)
    write_mesh(fname_out, *mesh1, overwrite=True)
    mesh2 = read_mesh(fname_out)
    assert_equal(len(mesh1), len(mesh2))
    for m1, m2 in zip(mesh1, mesh2):
        if m1 is None:
            assert_equal(m2, None)
        else:
            assert_allclose(m1, m2, rtol=1e-5)
    # test our efficient normal calculation routine
    assert_allclose(mesh1[2], _slow_calculate_normals(mesh1[0], mesh1[1]),
                    rtol=1e-7, atol=1e-7)
开发者ID:Peque,项目名称:vispy,代码行数:21,代码来源:test_io.py


示例13: __init__

    def __init__(self):
        app.Canvas.__init__(self, title='Molecular viewer',
                            keys='interactive', size=(1200, 800))
        self.ps = self.pixel_scale

        self.translate = 40
        self.program = gloo.Program(vertex, fragment)
        self.view = translate((0, 0, -self.translate))
        self.model = np.eye(4, dtype=np.float32)
        self.projection = np.eye(4, dtype=np.float32)

        self.apply_zoom()

        fname = load_data_file('molecular_viewer/micelle.npz')
        self.load_molecule(fname)
        self.load_data()

        self.theta = 0
        self.phi = 0

        gloo.set_state(depth_test=True, clear_color='black')
        self._timer = app.Timer('auto', connect=self.on_timer, start=True)

        self.show()
开发者ID:Calvarez20,项目名称:vispy,代码行数:24,代码来源:molecular_viewer.py


示例14: show

n = 200
freq = 10
fs = 100.
t = np.arange(n) / fs
tone = np.sin(2*np.pi*freq*t)
noise = np.random.RandomState(0).randn(n)
signal = tone + noise
magnitude = np.abs(np.fft.fft(signal))
freqs = np.fft.fftfreq(n, 1. / fs)
flim = n // 2

# Signal
fig = plt.figure()
ax = plt.subplot(311)
ax.imshow(read_png(load_data_file('pyplot/logo.png')))

ax = plt.subplot(312)
ax.plot(t, signal, 'k-')

# Frequency content
ax = plt.subplot(313)
idx = np.argmax(magnitude[:flim])
ax.text(freqs[idx], magnitude[idx], 'Max: %s Hz' % freqs[idx],
        verticalalignment='top')
ax.plot(freqs[:flim], magnitude[:flim], 'r-o')

plt.draw()

# NOTE: show() has currently been overwritten to convert to vispy format, so:
# 1. It must be called to show the results, and
开发者ID:chipmuenk,项目名称:A2SRC,代码行数:30,代码来源:plot_vispy_test_b.py


示例15: Copyright

# -*- coding: utf-8 -*-
# Copyright (c) Vispy Development Team. All Rights Reserved.
# Distributed under the (new) BSD License. See LICENSE.txt for more info.
"""
Plot data with different styles
"""

import numpy as np

from vispy import plot as vp
from vispy.io import load_data_file

data = np.load(load_data_file('electrophys/iv_curve.npz'))['arr_0']
time = np.arange(0, data.shape[1], 1e-4)

fig = vp.Fig(size=(800, 800), show=False)

x = np.linspace(0, 10, 20)
y = np.cos(x)
line = fig[0, 0].plot((x, y), symbol='o', width=3, title='I/V Curve',
                      xlabel='Current (pA)', ylabel='Membrane Potential (mV)')
grid = vp.visuals.GridLines(color=(0, 0, 0, 0.5))
grid.set_gl_state('translucent')
fig[0, 0].view.add(grid)


if __name__ == '__main__':
    fig.show(run=True)
开发者ID:Eric89GXL,项目名称:vispy,代码行数:28,代码来源:plot.py


示例16: main

FRAG_CODE = """
uniform sampler2D u_texture;
varying vec2 v_texcoord;

void main()
{
    float ty = v_texcoord.y;
    float tx = sin(ty*50.0)*0.01 + v_texcoord.x;
    gl_FragColor = texture2D(u_texture, vec2(tx, ty));
}
"""


# Read cube data
positions, faces, normals, texcoords = read_mesh(load_data_file("orig/cube.obj"))
colors = np.random.uniform(0, 1, positions.shape).astype("float32")

faces_buffer = gloo.IndexBuffer(faces.astype(np.uint16))


class Canvas(app.Canvas):
    def __init__(self, **kwargs):
        app.Canvas.__init__(self, size=(400, 400), **kwargs)

        self.program = gloo.Program(VERT_CODE, FRAG_CODE)

        # Set attributes
        self.program["a_position"] = gloo.VertexBuffer(positions)
        self.program["a_texcoord"] = gloo.VertexBuffer(texcoords)
开发者ID:bdvd,项目名称:vispy,代码行数:29,代码来源:glsl_sandbox_cube.py


示例17: __init__

    def __init__(self):
        app.Canvas.__init__(self, keys='interactive', size=(800, 600))
        brain = np.load(load_data_file('brain/brain.npz', force_download='2014-09-04'))

        #brain1 = scipy.io.loadmat('NewBESATri.mat')
        brain2 = brain1['t']


        from numpy import genfromtxt
        my_data = genfromtxt('BESACOORD61.csv', delimiter=',')

        dataTest = brain['vertex_buffer']
        color = dataTest['a_color']
        color = color[750:1500]
        facesTest = brain['index_buffer']

        n = 750
        ps = 100
        data = np.zeros(n, [('a_position', np.float32, 3),
                            ('a_normal', np.float32, 3),
                            ('a_color', np.float32, 3)])
                            #('a_size', np.float32, 1)])

        import scipy.spatial
        tri = scipy.spatial.Delaunay(my_data) # points: np.array() of 3d points
        convex = tri.convex_hull
        indices = tri.simplices
        vertices = my_data[indices]
        data['a_position'] = my_data
        data['a_color'] = np.random.uniform(0, 1, (n, 3))
        faces = brain2
        faces = faces-1
        vertices = my_data
        norm = np.zeros( vertices.shape, dtype=vertices.dtype )
        #Create an indexed view into the vertex array using the array of three indices for triangles
        tris = vertices[faces]

        #Calculate the normal for all the triangles, by taking the cross product of the vectors v1-v0, and v2-v0 in each triangle
        n = np.cross( tris[::,1 ] - tris[::,0]  , tris[::,2 ] - tris[::,0] )
        # n is now an array of normals per triangle. The length of each normal is dependent the vertices,
        # we need to normalize these, so that our next step weights each normal equally.
        lens = np.sqrt( n[:,0]**2 + n[:,1]**2 + n[:,2]**2 )
        n[:,0] /= lens
        n[:,1] /= lens
        n[:,2] /= lens



        norm[ faces[:,0] ] += n
        norm[ faces[:,1] ] += n
        norm[ faces[:,2] ] += n

        ''' Normalize a numpy array of 3 component vectors shape=(n,3) '''
        lens = np.sqrt( norm[:,0]**2 + norm[:,1]**2 + norm[:,2]**2 )
        norm[:,0] /= lens
        norm[:,1] /= lens
        norm[:,2] /= lens

        data['a_normal'] = norm #np.random.uniform(0, 1.0, (n, 3)) #10, 3, 3
        #data['a_size'] = np.random.uniform(5*ps, 10*ps, n)
        u_linewidth = 1.0
        u_antialias = 1.0



        brain2 = np.uint32(brain2)
        convex = np.uint32(convex)
        data = data
        faces = brain2-1

        #data = dataTest
        #faces = facesTest

        self.meshes = []
        self.rotation = MatrixTransform()

        # Generate some data to work with
        global mdata
        mdata = create_sphere(20, 40, 1.0)
        #mdata['_faces'] =faces
        #mdata['_vertices']=data
        # Mesh with pre-indexed vertices, uniform color
        meshData=vispy.geometry.MeshData(vertices=data['a_position'], faces=None, edges=None, vertex_colors=None, face_colors=None)
        meshData._vertices = data['a_position']
        meshData._faces = faces
        #meshData._face_colors = data['a_color']
        #meshData._vertex_colors = data['a_color']

        self.meshes.append(visuals.MeshVisual(meshdata=meshData, color='b'))
        #for mesh in self.meshes:
        #    mesh.draw()

        # Mesh with pre-indexed vertices, per-face color
        # Because vertices are pre-indexed, we get a different color
        # every time a vertex is visited, resulting in sharp color
        # differences between edges.
        tris = vertices[faces]
        verts = data['a_position'] #mdata.get_vertices(indexed='faces')

        nf = 1496#verts.size//9
#.........这里部分代码省略.........
开发者ID:esmam,项目名称:MRATPython27,代码行数:101,代码来源:Normalise.py


示例18:

* 1: flip x dimenstion
* 2: flip y dimension
* 3: flip z dimenstion
* 4: cycle through up-vectors
* 5: cycle through cameras
"""

from itertools import cycle

import numpy as np

from vispy import app, scene, io
from vispy.ext.six import next

# Read volume
vol1 = np.load(io.load_data_file("volume/stent.npz"))["arr_0"]

# Prepare canvas
canvas = scene.SceneCanvas(keys="interactive", size=(800, 600), show=True)
canvas.measure_fps()

# Set up a viewbox to display the image with interactive pan/zoom
view = canvas.central_widget.add_view()

# Create the volume visuals, only one is visible
volume1 = scene.visuals.Volume(vol1, parent=view.scene, threshold=0.5)
# volume1.method = 'iso'
volume1.threshold = 0.1

# Plot a line that shows where positive x is, with at the end a small
# line pointing at positive y
开发者ID:ringw,项目名称:vispy,代码行数:31,代码来源:flipped_axis.py


示例19:

* 1: flip x dimension
* 2: flip y dimension
* 3: flip z dimension
* 4: cycle through up-vectors
* 5: cycle through cameras
"""

from itertools import cycle

import numpy as np

from vispy import app, scene, io
from vispy.ext.six import next

# Read volume
vol1 = np.load(io.load_data_file('volume/stent.npz'))['arr_0']

# Prepare canvas
canvas = scene.SceneCanvas(keys='interactive', size=(800, 600), show=True)
canvas.measure_fps()

# Set up a viewbox to display the image with interactive pan/zoom
view = canvas.central_widget.add_view()

# Create the volume visuals, only one is visible
volume1 = scene.visuals.Volume(vol1, parent=view.scene, threshold=0.5)
#volume1.method = 'iso'
volume1.threshold = 0.1

# Plot a line that shows where positive x is, with at the end a small
# line pointing at positive y
开发者ID:Calvarez20,项目名称:vispy,代码行数:31,代码来源:flipped_axis.py


示例20: main

FRAG_CODE = """
uniform sampler2D u_texture;
varying vec2 v_texcoord;

void main()
{
    float ty = v_texcoord.y;
    float tx = sin(ty*50.0)*0.01 + v_texcoord.x;
    gl_FragColor = texture2D(u_texture, vec2(tx, ty));
}
"""


# Read cube data
positions, faces, normals, texcoords = \
    read_mesh(load_data_file('orig/cube.obj'))
colors = np.random.uniform(0, 1, positions.shape).astype('float32')

faces_buffer = gloo.IndexBuffer(faces.astype(np.uint16))


class Canvas(app.Canvas):

    def __init__(self, **kwargs):
        app.Canvas.__init__(self, size=(400, 400), **kwargs)

        self.program = gloo.Program(VERT_CODE, FRAG_CODE)

        # Set attributes
        self.program['a_position'] = gloo.VertexBuffer(positions)
        self.program['a_texcoord'] = gloo.VertexBuffer(texcoords)
开发者ID:jay3sh,项目名称:vispy,代码行数:31,代码来源:glsl_sandbox_cube.py



注:本文中的vispy.io.load_data_file函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python testing.assert_equal函数代码示例发布时间:2022-05-26
下一篇:
Python program.Program类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap