Skip to content

Commit

Permalink
Fix bugs in compare_gauges function
Browse files Browse the repository at this point in the history
  • Loading branch information
mandli committed Apr 30, 2019
1 parent d97a74b commit fded9a6
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/pyclaw/gauges.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,26 +235,28 @@ def compare_gauges(paths, gauge_id, fields='all'):

import matplotlib.pyplot as plt

if len(path) != 2:
if len(paths) != 2:
raise ValueError("Provide two paths to gauge files for comparison.")

gauges = []
for path in paths:
gauges = GaugeSolution(path=path, gauge_id=gauge_id)
gauges.append(GaugeSolution(path=path, gauge_id=gauge_id))

if fields.lower() == 'all':
fields = range(gauges[0].q.shape[0])
if isinstance(fields, str):
if fields.lower() == 'all':
fields = range(gauges[0].q.shape[0])

fig = plt.figure()
fig.suptitle("Gauge %s" % gauges[0].gauge_id)
fig.suptitle("Gauge %s" % gauges[0].id)
for (i, n) in enumerate(fields):
axes = fig.add_subplot(len(fields), 2, 2 * i + 1)
axes = fig.add_subplot(len(fields), 2, 2 * i + 1, )
axes.plot(gauges[0].t, gauges[0].q[n, :], 'ko', label="%s" % paths[0])
axes.plot(gauges[0].t, gauges[1].q[n, :], 'rx', label="%s" % paths[1])
axes.plot(gauges[1].t, gauges[1].q[n, :], 'rx', label="%s" % paths[1])
axes.set_xlabel("t")
axes.set_ylabel("q[%s, :]" % n)
axes.legend()

axes = fig.add_subplot(len(fields), 2, 2 * i + 1)
axes = fig.add_subplot(len(fields), 2, 2 * i + 2)
axes.plot(gauges[0].t,
numpy.abs(gauges[0].q[n, :] - gauges[1].q[n, :]), 'r')
axes.set_xlabel("t")
Expand Down Expand Up @@ -415,7 +417,7 @@ def check_old_gauge_data(path, gauge_id, new_gauge_path="./regression_data"):
fields can be specfied including 'all'.
"""

fields = [0]
fields = 'all'
gauge_id = 1
if len(sys.argv) < 3:
print(help_msg)
Expand Down

0 comments on commit fded9a6

Please sign in to comment.