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()
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_elev_frame([frame, figsize, dpi, vmin, ...])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_elev_delta_frame([frame, figsize, dpi, ...])Save one elevation-change frame (elev[t] - elev[0]) to disk.
save_elev_frame([frame, figsize, dpi, vmin, ...])Save one elevation frame to disk.
save_max_depth_frame([frame, figsize, dpi, ...])Save a single frame showing the maximum depth at each triangle.
save_max_speed_depth_frame([frame, figsize, ...])Save a single frame showing the maximum speed×depth at each triangle.
save_max_speed_frame([frame, figsize, dpi, ...])Save a single frame showing the maximum speed at each triangle.
save_max_stage_frame([frame, figsize, dpi, ...])Save a single frame showing the maximum stage at each triangle.
save_speed_depth_frame([frame, figsize, ...])save_speed_frame([frame, figsize, dpi, ...])save_stage_frame([frame, figsize, dpi, ...])set_epsg(epsg)Set (or override) the EPSG code and rebuild the absolute-coordinate triangulation used for basemap overlays.
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.
Attributes
elev_deltaBed elevation change from t=0: shape (n_time, n_tri), or None for static.
max_depthMax depth per triangle: precomputed from SWW if available, else max over time.
max_speedMax speed per triangle: precomputed from SWW if available, else max over time.
max_speed_depthMax momentum magnitude per triangle: precomputed (max_uh_c) or max over time.
max_stageMax stage per triangle: precomputed from SWW if available, else max over time.