source: anuga_core/source/anuga/visualiser/commandline_viewer.py @ 5485

Last change on this file since 5485 was 3963, checked in by jack, 17 years ago

Added new method get_quantity_names to domain.py for use by the visualiser.
Made commandline_viewer.py correctly start and stop the thread.
Made realtime.py only use public interfaces rather than dealing with the internals of the domain and quantity data structures

File size: 2.1 KB
Line 
1""" VTK sww Visualiser for ANUGA
2
3python vtk_viewer swwfile.sww
4"""
5
6import sys, os
7from anuga.visualiser import OfflineVisualiser
8
9def get_filename():
10    if len(sys.argv) > 1:
11        filename = sys.argv[1]
12
13        root, ext = os.path.splitext(filename)
14           
15        if ext <> '.sww':
16            print 'WARNING: I only view sww files.' %filename
17     
18        return filename
19
20
21
22if __name__ == '__main__':
23
24   
25    filename = get_filename()
26    if filename is not None:
27        # The argument to OfflineVisualiser is the path to a sww file
28        o = OfflineVisualiser(filename)
29
30        # Specify the height-based-quantities to render.
31        # Remember to set dynamic=True for time-varying quantities
32        o.render_quantity_height("elevation", dynamic=False)
33        o.render_quantity_height("stage", dynamic=True)
34
35        # Colour the stage:
36        # Either with an RGB value as a 3-tuple of Floats,
37        # o.colour_height_quantity('stage', (0.0, 0.0, 0.8))
38        # Or with a function of the quantities at that point, such as
39        # the stage height:
40        # 0 and 10 are the minimum and maximum values of the stage.
41        o.colour_height_quantity('stage', (lambda q: q['stage'], 0, 10))
42        # Or with the magnitude of the momentum at that point:
43        # Needs the sqrt function from Numeric. Again, 0 and 10
44        # define the colour range.
45        # o.colour_height_quantity('stage',
46        #                          (lambda q:sqrt((q['xmomentum'] ** 2) +
47        #                                         (q['ymomentum'] ** 2)),
48        #                                          0, 10))
49
50        # Draw some axes on the visualiser so we can see how big the wave is
51        o.render_axes()
52
53        # Precaching the height-based quantities reduces the time taken
54        # to draw each frame, but increases the time taken when the
55        # visualiser starts.
56        o.precache_height_quantities()
57
58        # Start the visualiser (in its own thread).
59        o.start()
60        # Wait for the visualiser to terminate before shutdown
61        o.join()
62       
Note: See TracBrowser for help on using the repository browser.