Skip to content

Commit

Permalink
Update animate.py
Browse files Browse the repository at this point in the history
Add in another argument for min_depth
  • Loading branch information
stoiver committed Aug 6, 2019
1 parent b6361c7 commit 62c44c4
Showing 1 changed file with 34 additions and 14 deletions.
48 changes: 34 additions & 14 deletions anuga/utilities/animate.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ class Domain_plotter:
"""


def __init__(self, domain, plot_dir='_plot'):
def __init__(self, domain, plot_dir='_plot', min_depth=0.01):

self.plot_dir = plot_dir
self.make_plot_dir()

self.min_depth = min_depth

self.nodes = domain.nodes
self.triangles = domain.triangles
self.x = domain.nodes[:, 0]
Expand Down Expand Up @@ -47,17 +49,19 @@ def _depth_frame(self, figsize, dpi, vmin, vmax):

name = self.domain.get_name()
time = self.domain.get_time()

md = self.min_depth

fig = plt.figure(figsize=figsize, dpi=dpi)

plt.title('Depth: Time {0:0>4}'.format(time))

self.triang.set_mask(self.depth > 0.01)
self.triang.set_mask(self.depth > md)
plt.tripcolor(self.triang,
facecolors=self.elev,
cmap='Greys_r')

self.triang.set_mask(self.depth < 0.01)
self.triang.set_mask(self.depth < md)
plt.tripcolor(self.triang,
facecolors=self.depth,
cmap='viridis',
Expand Down Expand Up @@ -140,17 +144,19 @@ def _stage_frame(self, figsize, dpi, vmin, vmax):

name = self.domain.get_name()
time = self.domain.get_time()

md = self.min_depth

fig = plt.figure(figsize=figsize, dpi=dpi)

plt.title('Stage: Time {0:0>4}'.format(time))

self.triang.set_mask(self.depth > 0.01)
self.triang.set_mask(self.depth > md)
plt.tripcolor(self.triang,
facecolors=self.elev,
cmap='Greys_r')

self.triang.set_mask(self.depth < 0.01)
self.triang.set_mask(self.depth < md)
plt.tripcolor(self.triang,
facecolors=self.stage,
cmap='viridis',
Expand Down Expand Up @@ -234,17 +240,19 @@ def _speed_frame(self, figsize, dpi, vmin, vmax):

name = self.domain.get_name()
time = self.domain.get_time()

md = self.min_depth

fig = plt.figure(figsize=figsize, dpi=dpi)

plt.title('Speed: Time {0:0>4}'.format(time))

self.triang.set_mask(self.depth > 0.01)
self.triang.set_mask(self.depth > md)
plt.tripcolor(self.triang,
facecolors=self.elev,
cmap='Greys_r')

self.triang.set_mask(self.depth < 0.01)
self.triang.set_mask(self.depth < md)
plt.tripcolor(self.triang,
facecolors=self.speed,
cmap='viridis',
Expand Down Expand Up @@ -352,10 +360,13 @@ class SWW_plotter:
"""

def __init__(self, swwfile='domain.sww', plot_dir='_plot',
minimum_allowed_depth=1.0e-03):
min_depth = 0.01,
minimum_allowed_depth=1.0e-03):

self.plot_dir = plot_dir
self.make_plot_dir()

self.min_depth = min_depth

import matplotlib.tri as tri
import numpy as np
Expand Down Expand Up @@ -411,6 +422,9 @@ def _depth_frame(self, figsize, dpi, frame, vmin, vmax):
name = self.name
time = self.time[frame]
depth = self.depth[frame, :]

md = self.min_depth

try:
elev = self.elev[frame, :]
except:
Expand All @@ -422,12 +436,12 @@ def _depth_frame(self, figsize, dpi, frame, vmin, vmax):

plt.title('Depth: Time {0:0>4}'.format(time))

self.triang.set_mask(depth > 0.01)
self.triang.set_mask(depth > md)
plt.tripcolor(self.triang,
facecolors=elev,
cmap='Greys_r')

self.triang.set_mask(depth < 0.01)
self.triang.set_mask(depth < md)
plt.tripcolor(self.triang,
facecolors=depth,
cmap='viridis',
Expand Down Expand Up @@ -470,6 +484,9 @@ def _stage_frame(self, figsize, dpi, frame, vmin, vmax):
time = self.time[frame]
stage = self.stage[frame, :]
depth = self.depth[frame, :]

md = self.min_depth

try:
elev = self.elev[frame, :]
except:
Expand All @@ -481,12 +498,12 @@ def _stage_frame(self, figsize, dpi, frame, vmin, vmax):

plt.title('Stage: Time {0:0>4}'.format(time))

self.triang.set_mask(depth > 0.01)
self.triang.set_mask(depth > md)
plt.tripcolor(self.triang,
facecolors=elev,
cmap='Greys_r')

self.triang.set_mask(depth < 0.01)
self.triang.set_mask(depth < md)
plt.tripcolor(self.triang,
facecolors=stage,
cmap='viridis',
Expand Down Expand Up @@ -528,6 +545,9 @@ def _speed_frame(self, figsize, dpi, frame, vmin, vmax):
name = self.name
time = self.time[frame]
depth = self.depth[frame, :]

md = self.min_depth

try:
elev = self.elev[frame, :]
except:
Expand All @@ -540,12 +560,12 @@ def _speed_frame(self, figsize, dpi, frame, vmin, vmax):

plt.title('Speed: Time {0:0>4}'.format(time))

self.triang.set_mask(depth > 0.01)
self.triang.set_mask(depth > md)
plt.tripcolor(self.triang,
facecolors=elev,
cmap='Greys_r')

self.triang.set_mask(depth < 0.01)
self.triang.set_mask(depth < md)
plt.tripcolor(self.triang,
facecolors=speed,
cmap='viridis',
Expand Down

0 comments on commit 62c44c4

Please sign in to comment.