anuga.SWW_plotter

class anuga.SWW_plotter(swwfile='domain.sww', plot_dir='_plot', min_depth=0.001, absolute=False)[source]

A class to wrap ANUGA swwfile centroid values for stage, height, elevation xmomentum and ymomentum, and triangulation information.

Plotting functions are provided to plot depth, speed, speed_depth, stage and mesh, and to create animations of depth, speed, speed_depth (momentum) and stage.

Plotting based on matplotlib’s tripcolor and triplot functions.

Example:

Open an SWW file and plot various quantities.

>>> import anuga
>>> import matplotlib.pyplot as plt
>>>
>>> # Enable interactive mode
>>> plot.ion()
>>>
>>> # Create SWW plotter object by opening an SWW file
>>> splotter = anuga.SWW_plotter('domain.sww')
>>>
>>> # Find min and max depth for plotting
>>> vmin = splotter.depth.min()
>>> vmax = splotter.depth.max()
>>>
>>> # Plot depth at last frame.
>>> fig, ax = splotter.plot_depth_frame(-1, vmin=vmin, vmax=vmax)
>>> ax.set_title('Depth at final time')
>>> 
>>> # Plot speed at second frame
>>> fig, ax = splotter.plot_speed_frame(1)
>>> ax.set_title('Speed at second frame')
>>>
>>> # Plot Mesh
>>> fig, ax, im = splotter.plot_mesh()
>>> ax.set_title('Mesh')
>>>
>>> # Animate depth
>>> for frame in range(len(splotter.time)):
...     splotter.save_depth_frame(frame, vmin=vmin, vmax=vmax)
>>> anim = splotter.make_depth_animation()
__init__(swwfile='domain.sww', plot_dir='_plot', min_depth=0.001, absolute=False)[source]

Methods

__init__([swwfile, plot_dir, min_depth, ...])

get_flow_through_cross_section(polyline[, ...])

Calculate flow through a cross-section defined by a polyline.

get_triangles_inside_polygon(polygon[, verbose])

Get list of triangle IDs whose centroids lie within a given polygon.

make_depth_animation()

make_plot_dir([clobber])

Utility function to create a directory for storing a sequence of plot files, or if the directory already exists, clear out any old plots.

make_speed_animation()

make_speed_depth_animation()

make_stage_animation()

plot_depth_frame([frame, figsize, dpi, ...])

plot_mesh([figsize, dpi])

plot_speed_depth_frame([frame, figsize, ...])

plot_speed_frame([frame, figsize, dpi, ...])

plot_stage_frame([frame, figsize, dpi, ...])

save_depth_frame([frame, figsize, dpi, ...])

save_speed_depth_frame([frame, figsize, ...])

save_speed_frame([frame, figsize, dpi, ...])

save_stage_frame([frame, figsize, dpi, ...])

tripcolor([figsize, dpi])

Create a tripcolor plot of the mesh.

triplot([figsize, dpi])

Create a triplot of the mesh.

water_volume([per_unit_area, triangle_ids, ...])

Compute the water volume associated within a subset of triangles or within a polygon.