本文整理汇总了Python中vispy.io.load_data_file函数的典型用法代码示例。如果您正苦于以下问题:Python load_data_file函数的具体用法?Python load_data_file怎么用?Python load_data_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了load_data_file函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
示例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)
示例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)
示例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
示例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
示例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)
示例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)
示例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
示例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
示例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()
示例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
示例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)
示例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()
示例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
示例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)