Skip to content
Snippets Groups Projects
Commit d373e0cd authored by podlesny's avatar podlesny
Browse files

change units display in plots, add spatial slip event visualization

parent e14172a6
No related branches found
No related tags found
No related merge requests found
......@@ -21,6 +21,7 @@ from support.io import read_h5file
from support.iterations import iterations
from support.friction_stats import friction_stats
from support.slip_rates import slip_rates
def build_patch(coords, percentage):
x_coords = coords[:, 0]
......@@ -53,7 +54,7 @@ params = {
h5file = read_h5file()
print(list(h5file.keys()))
interval = [0.75*FINAL_TIME, FINAL_TIME]
interval = [10, 13] #[0.75*FINAL_TIME, FINAL_TIME]
iterations(h5file, FINAL_TIME, interval)
......@@ -67,7 +68,8 @@ for body_ID in range(NBODIES):
patch = build_patch(coords, 1.0)
friction_stats(h5file, body_ID, FINAL_TIME, patch, interval)
slip_rates(h5file, body_ID, FINAL_TIME, patch, interval, 0)
plt.show()
h5file.close()
\ No newline at end of file
......@@ -31,7 +31,7 @@ def friction_stats(h5file, body_ID, FINAL_TIME, patch=[], interval=[], TANGENTIA
#ax_slip.plot(time, min_v, color='gray', linestyle='--')
ax_slip.plot(time, avg_v, color='black', linestyle='-')
#ax_slip.plot(time, max_v, color='gray', linestyle='--')
ax_slip.set_ylabel('slip rate V')
ax_slip.set_ylabel('slip rate V [m/s]')
ax_slip.set_yscale('log')
ax_slip.set_ylim([1e-6,1e-2])
#-------------------------
......@@ -54,7 +54,7 @@ def friction_stats(h5file, body_ID, FINAL_TIME, patch=[], interval=[], TANGENTIA
ax_state.plot(time, avg_states, color='black', linestyle='-')
#ax_state.plot(time, max_states, color='gray', linestyle='--')
ax_state.set_ylabel('state')
ax_state.set_xlabel('time in s')
ax_state.set_xlabel('time [s]')
#-------------------------
# friction coefficient
......
......@@ -35,7 +35,7 @@ def iterations(h5file, FINAL_TIME, interval = []):
ax_mg = fig.add_subplot(2, 1, 2)
ax_mg.plot(time, multigrid_final[t], color='black', linestyle='-')
ax_mg.set_ylabel('multigrid iter.')
ax_mg.set_xlabel('time in s')
ax_mg.set_xlabel('time [s]')
#-------------------------
#ax_tau = fig.add_subplot(3, 1, 3)
......
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cm as cm
TANGENTIAL_COORDS = 1
def local_to_global(coords, SORT_COORD=0):
return coords[:, SORT_COORD].argsort()
def slip_rates(h5file, body_ID, FINAL_TIME, patch=[], interval=[], SORT_COORD=0):
body = 'body' + str(body_ID) # 'frictionalBoundary' 'body' + str(body_ID)
coords = np.array(h5file[body + '/coordinates'])
if len(patch) == 0:
patch = np.linspace(0, len(coords)-1, len(coords), endpoint=True, dtype='int8')
# local to global
local_global = local_to_global(coords, SORT_COORD)
local_global = local_global[patch]
patch_size = coords[local_global[-1], SORT_COORD] - coords[local_global[0], SORT_COORD]
# read time
time = np.array(h5file['relativeTime']) * FINAL_TIME
time = np.delete(time, 0)
if len(interval) == 0:
interval = [0, FINAL_TIME]
t = [i for i in range(len(time)) if time[i]>=interval[0] and time[i]<=interval[1]]
time = time[t]
fig = plt.figure()
# velocity data
v = abs(np.array(h5file[body + '/velocity']))
v_t = v[t,:,TANGENTIAL_COORDS]
v_tx = v_t[:,local_global]
# plot
ax_slip = fig.add_subplot(1, 1, 1)
ax_slip.imshow(v_tx, interpolation='nearest', cmap=cm.Greys_r, aspect='auto', origin='lower', extent=[0, patch_size, time[0], time[-1]])
#ax_slip.set_ylim([time[-1], time[0]])
ax_slip.set_ylabel('time [s]')
ax_slip.set_xlabel('horizontal coordinate [m]')
#ax_slip.set_yscale('log')
# ax_slip.set_ylim([1e-6,1e-2])
#-------------------------
fig.canvas.draw()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment