示例#1
0
def make_data():
    """Make some test numpy data and create a TVTK data object from it
    that we will visualize.
    """    
    x = numpy.arange(-7., 7.05, 0.1)
    y = numpy.arange(-5., 5.05, 0.05)
    s = mlab.SurfRegular(x, y, f)
    return s.data
示例#2
0
def make_data():
    """Make some test numpy data and create a TVTK data object from it
    that we will visualize.
    """
    def f(x, y):
        """Some test function.
        """
        return numpy.sin(x * y) / (x * y)

    x = numpy.arange(-7., 7.05, 0.1)
    y = numpy.arange(-5., 5.05, 0.05)
    s = mlab.SurfRegular(x, y, f)
    return s.data
示例#3
0
# it in !MayaVi2. A more detailed version of this script is given in the
# examples pages [:Cookbook/MayaVi/Examples].
#
# <codecell>

import numpy


def f(x, y):
    return numpy.sin(x * y) / (x * y)


x = numpy.arange(-7., 7.05, 0.1)
y = numpy.arange(-5., 5.05, 0.05)
from enthought.tvtk.tools import mlab
s = mlab.SurfRegular(x, y, f)
from enthought.mayavi.sources.vtk_data_source import VTKDataSource
d = VTKDataSource()
d.data = s.data
mayavi.add_source(d)
from enthought.mayavi.filters.warp_scalar import WarpScalar
w = WarpScalar()
mayavi.add_filter(w)
from enthought.mayavi.modules.outline import Outline
from enthought.mayavi.modules.surface import Surface
o = Outline()
s = Surface()
mayavi.add_module(o)
mayavi.add_module(s)

# <markdowncell>
示例#4
0
 def add_surface_data_immediate(self, xrange, yrange, f):
     s1 = mlab.SurfRegular(xrange,
                           yrange,
                           scipy.vectorize(f),
                           scale=self.scale)
     self.add_source_data(s1.data)
示例#5
0
 def run(self):
     s1 = mlab.SurfRegular(self.xrange,
                           self.yrange,
                           scipy.vectorize(self.f),
                           scale=self.p.scale)
     GUI.invoke_later(self.p.add_source_data, s1.data)
示例#6
0

def add_data(tvtk_data):
    """Add a TVTK data object `tvtk_data` to the mayavi pipleine.
    """
    d = VTKDataSource()
    d.data = tvtk_data
    mayavi.add_source(d)
    return d


def surf_regular(source):
    """Now visualize the data as done in mlab.
    """
    w = WarpScalar()
    source.add_child(w)
    s = Surface()
    w.add_child(s)


# 3D visualization of f:

if __name__ == "__main__":
    mayavi.new_scene()
    for r in riskfree:
        riskFreeQuote.setValue(r)
        s1 = mlab.SurfRegular(spot, vol, scipy.vectorize(f), scale=[1, 100, 1])
        s1.lut.alpha_range = (0.2, 0.2)
        d = add_data(s1.data)
        surf_regular(d)