diff options
author | Picca Frédéric-Emmanuel <picca@debian.org> | 2017-10-07 07:59:01 +0200 |
---|---|---|
committer | Picca Frédéric-Emmanuel <picca@debian.org> | 2017-10-07 07:59:01 +0200 |
commit | bfa4dba15485b4192f8bbe13345e9658c97ecf76 (patch) | |
tree | fb9c6e5860881fbde902f7cbdbd41dc4a3a9fb5d /examples/viewer3DVolume.py | |
parent | f7bdc2acff3c13a6d632c28c4569690ab106eed7 (diff) |
New upstream version 0.6.0+dfsg
Diffstat (limited to 'examples/viewer3DVolume.py')
-rw-r--r-- | examples/viewer3DVolume.py | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/examples/viewer3DVolume.py b/examples/viewer3DVolume.py index 7a95d8a..82022f9 100644 --- a/examples/viewer3DVolume.py +++ b/examples/viewer3DVolume.py @@ -101,6 +101,19 @@ def load(filename): return data +def default_isolevel(data): + """Compute a default isosurface level: mean + 1 std + + :param numpy.ndarray data: The data to process + :rtype: float + """ + data = data[numpy.isfinite(data)] + if len(data) == 0: + return 0 + else: + return numpy.mean(data) + numpy.std(data) + + def main(argv=None): # Parse input arguments parser = argparse.ArgumentParser( @@ -171,11 +184,11 @@ def main(argv=None): else: # Create dummy data _logger.warning('Not data file provided, creating dummy data') - size = 128 - z, y, x = numpy.mgrid[0:size, 0:size, 0:size] - data = numpy.asarray( - size**2 - ((x-size/2)**2 + (y-size/2)**2 + (z-size/2)**2), - dtype='float32') + coords = numpy.linspace(-10, 10, 64) + z = coords.reshape(-1, 1, 1) + y = coords.reshape(1, -1, 1) + x = coords.reshape(1, 1, -1) + data = numpy.sin(x * y * z) / (x * y * z) # Set ScalarFieldView data window.setData(data) @@ -195,9 +208,7 @@ def main(argv=None): window.addIsosurface(args.level, '#FF0000FF') else: # Add an iso-surface from a function - window.addIsosurface( - lambda data: numpy.mean(data) + numpy.std(data), - '#FF0000FF') + window.addIsosurface(default_isolevel, '#FF0000FF') window.show() return app.exec_() |