コード例 #1
0
 def test_threshold_filter_threhsold(self):
     src = self.make_src()
     self.e.add_source(src)
     threshold = Threshold()
     self.e.add_filter(threshold)
     threshold.upper_threshold = 20.
     self.assertTrue(
         20 >= np.nanmax(threshold.outputs[0].point_data.scalars.to_array())
     )
     return
コード例 #2
0
 def test_threshold_filter_threhsold(self):
     src = self.make_src()
     self.e.add_source(src)
     threshold = Threshold()
     self.e.add_filter(threshold) 
     threshold.upper_threshold = 20.
     self.assertTrue(20 >=
                      np.nanmax(
                         threshold.outputs[0].point_data.scalars.to_array()
                      ))
     return
コード例 #3
0
  def run(self):    
    from enthought.mayavi.sources.vtk_data_source import VTKDataSource
    from enthought.mayavi.filters.threshold import Threshold
    from enthought.mayavi.modules.surface import Surface
    from enthought.mayavi.modules.scalar_cut_plane import ScalarCutPlane

    self._setupScene()
    data = self._readData()

    script = self.script
    script.add_source(VTKDataSource(data=data))
    script.engine.current_object.name = "Error"
    error = script.engine.current_object

    threshold = Threshold()
    script.add_filter(threshold)
    threshold.lower_threshold = -3.0
    
    surf = Surface()
    script.add_filter(surf)

    if showSlice:
      surf.actor.property.opacity = 0.3
      script.engine.current_object = error
      slice = ScalarCutPlane()
      script.add_module(slice)
      slice.actor.property.opacity = 0.5
      slice.implicit_plane.origin = (12.0, 12.0, -12.0)
      slice.implicit_plane.normal = (0, -1.0, 0.0)

    for obj in [slice, surf]:
      colorbar = obj.module_manager.scalar_lut_manager
      colorbar.data_range = (threshold.lower_threshold, -2.0)
      colorbar.lut_mode = "hot"
      colorbar.reverse_lut = True
    colorbar.show_scalar_bar = True
    colorbar.number_of_labels = 6
    colorbar.scalar_bar.label_format = "%-3.1f"
    w,h = colorbar.scalar_bar.position2
    colorbar.scalar_bar.position2 = (w, 0.1)

    light = script.engine.current_scene.scene.light_manager.lights[0]
    light.elevation = 20.0
    light.azimuth = -45.0

    import vtk_geometry
    vtk_geometry.setCamera(script.engine.current_scene.scene.camera)
    return
コード例 #4
0
 def test_threshold_filter_nan(self):
     src = self.make_src(nan=True)
     self.e.add_source(src)
     threshold = Threshold()
     self.e.add_filter(threshold)
     self.assertEqual(
         np.nanmin(src.scalar_data),
         np.nanmin(threshold.outputs[0].point_data.scalars.to_array()))
     self.assertEqual(
         np.nanmax(src.scalar_data),
         np.nanmax(threshold.outputs[0].point_data.scalars.to_array()))
コード例 #5
0
#
# Begin to import the module and the filter first:
#
# <codecell>

from enthought.mayavi.modules.iso_surface import IsoSurface

from enthought.mayavi.filters.threshold import Threshold

# <markdowncell>

# then, set the threshold values:
#
# <codecell>

thh = Threshold()
script.add_filter(thh)
thh.lower_threshold = 0.4
thh.upper_threshold = 0.6
isosurf = IsoSurface()
thh.add_module(isosurf)
isosurf.contour.contours = [0.5]
isosurf.compute_normals = True
isosurf.actor.property.opacity = 0.2
isosurf.module_manager.scalar_lut_manager.data_range = [0, 1]

# <markdowncell>

# and you're done !
#
# This should look like this:
# 
# <codecell>


from enthought.mayavi.modules.iso_surface import IsoSurface

from enthought.mayavi.filters.threshold import Threshold

# <markdowncell>

# then, set the threshold values:
# 
# <codecell>


thh = Threshold()
script.add_filter(thh)
thh.lower_threshold = 0.4
thh.upper_threshold = 0.6
isosurf = IsoSurface()
thh.add_module(isosurf)
isosurf.contour.contours = [0.5]
isosurf.compute_normals = True
isosurf.actor.property.opacity = 0.2
isosurf.module_manager.scalar_lut_manager.data_range = [0, 1]

# <markdowncell>

# and you're done !
# 
# This should look like this: