Commit faa2a80d authored by Michael Rudolf's avatar Michael Rudolf
Browse files

-Removed close after processing and added option for predefined normal stresses

parent e04add2d
......@@ -200,6 +200,9 @@ def eval_shearstress(cur_dat, var, review=None):
normstress = (
int(np.mean(cur_dat['normalstress'])/var['prec'])*var['prec']
)
if var['options']['pred_norm']:
normstress = checkNormStress(normstress, var['pred_norms'])
# Create plot
fig, ax = plt.subplots()
dpi = fig.get_dpi()
......@@ -323,6 +326,12 @@ def eval_shearstress(cur_dat, var, review=None):
sys.exit(0)
return (fig, ax)
def checkNormStress(calcnorm, prednorms):
""" Finds the closest predifined normal stress """
differences = [p - calcnorm for p in prednorms]
closest = prednorms[np.argmin(np.abs(differences))]
return closest
if not review:
picks = _auto_pick(cur_dat, var)
elif review == 'auto':
......@@ -339,6 +348,8 @@ def eval_shearstress(cur_dat, var, review=None):
(peak, dyn, stat, deltad, p_ind) = _evaluate_picks(cur_dat, picks)
# Further calculations for output
normal = int(np.mean(cur_dat['normalstress'])/var['prec'])*var['prec']
if var['options']['pred_norm']:
normal = checkNormStress(normal, var['pred_norms'])
# Calculate relative weakening (after Ritter et al., 2016)
weak = 1-(dyn[1]/peak[1])
weak_p = (peak[1]/dyn[1])-1
......@@ -495,7 +506,7 @@ def plotstd(path, name, strength, fricdata):
stre_max = np.zeros(3)
for i in range(0, 3):
x, y = strength[0], strength[i+1]
stre_max[i] = max(strength[i+1])
stre_max[i] = np.nanmax(strength[i+1])
fit = fricdata[i][4]
slope, std_slope = fricdata[i][0], fricdata[i][1]
intercept, std_intercept = fricdata[i][2], fricdata[i][3]
......@@ -514,8 +525,8 @@ def plotstd(path, name, strength, fricdata):
% (slope, std_slope, intercept, std_intercept))
plt.xlabel('Normal stress $\\sigma_N$ [Pa]')
plt.ylabel('Shear stress $\\tau$ [Pa]')
plt.xlim(0, max(strength[0])*1.125)
plt.ylim(0, round(max(stre_max), -2)*1.125)
plt.xlim(0, np.nanmax(strength[0])*1.125)
plt.ylim(0, round(np.nanmax(stre_max), -2)*1.125)
# Removed because 1000 is too large for experiments at small normal load
# plt.yticks(np.arange(0, round(max(stre_max), -2)*1.125, 1000))
......@@ -697,7 +708,7 @@ def plotVST(path, data, pfit, perr, name_fit):
ax1.set_ylabel('Friction', color='royalblue')
ax1.spines['left'].set_color('royalblue')
ax1.tick_params('y', which='both', colors='royalblue')
ax1.set_xlim(0, max(displ)+max(displ)/100)
ax1.set_xlim(0, np.nanmax(displ)+np.nanmax(displ)/100)
# Displacement vs. shear velocity:
ax2.plot(displ, vel, 'r', lw=1)
......@@ -707,7 +718,7 @@ def plotVST(path, data, pfit, perr, name_fit):
ax2.spines['right'].set_color('r')
ax2.spines['left'].set_color('royalblue')
ax2.tick_params('y', which='both', colors='r')
ax2.set_xlim(0, max(displ)+max(displ)/100)
ax2.set_xlim(0, np.nanmax(displ)+ np.nanmax(displ)/100)
# shear velocity vs. fricton:
ax3.plot(vel, fric, 'k.', ms=2)
......@@ -715,7 +726,7 @@ def plotVST(path, data, pfit, perr, name_fit):
ax3.set_xscale('log')
ax3.set_xlabel('Shear velocity $v$ [$\mathregular{mm s^{-1}}$]')
ax3.set_ylabel('Friction')
ax3.set_xlim(min(vel)-(min(vel)/5), max(vel)+max(vel)/5)
ax3.set_xlim(np.nanmin(vel)-(np.nanmin(vel)/5), np.nanmax(vel)+np.nanmax(vel)/5)
ax3.legend(fontsize=8,
facecolor='w',
edgecolor='k',
......
......@@ -3,7 +3,7 @@
# @Author: M. Rudolf, M. Warsitzka
# @Date: 2019-02-20 12:00:00
# @Last Modified by: M. Rudolf
# @Last Modified time: 2020-05-20 14:08:53
# @Last Modified time: 2020-07-09 17:52:48
"""
RST_pick_GUI.py
......@@ -13,6 +13,7 @@ GUI based approach for RSTpicking
"""
import configparser
import json
import logging
import os
import re
......@@ -44,7 +45,7 @@ class RST_pick_GUI(tk.Tk):
self.save_ts = tk.IntVar()
self.rev_pick = tk.IntVar()
self.is_VST = tk.IntVar()
self.quit_onprc = tk.IntVar()
self.pred_norm = tk.IntVar()
self.rst = tk.IntVar()
self.cfg = configparser.ConfigParser()
self.cfg.optionxform = str
......@@ -127,18 +128,18 @@ class RST_pick_GUI(tk.Tk):
anchor='w',
variable=self.rev_pick)
self.opt_revpick.grid(column=1, row=4, sticky='EW')
# Use predefined normal stress
self.opt_pred = tk.Checkbutton(self,
text='Use predefined normal stress',
anchor='w',
variable=self.pred_norm)
self.opt_pred.grid(column=1, row=5, sticky='EW')
# Is a VST-Test
self.opt_revpick = tk.Checkbutton(self,
text='VST-Test',
anchor='w',
variable=self.is_VST)
self.opt_revpick.grid(column=1, row=5, sticky='EW')
# Quit after processing
self.opt_quit = tk.Checkbutton(self,
text='Quit after processing',
anchor='w',
variable=self.quit_onprc)
self.opt_quit.grid(column=1, row=6, sticky='EW')
self.opt_revpick.grid(column=1, row=6, sticky='EW')
# More Options
self.button_options = tk.Button(self,
......@@ -243,14 +244,20 @@ class RST_pick_GUI(tk.Tk):
# Create Var dictionary and save to config:
Vars = dict()
for item in self.params:
Vars[item] = float(self.params[item].get())
try:
Vars[item] = float(self.params[item].get())
except ValueError as _:
Vars[item] = json.loads(self.params[item].get())
self.cfg['parameters'][item] = self.params[item].get()
self.cfg ['options']['plot_ts'] = str(self.plot_ts.get())
self.cfg ['options']['save_ts'] = str(self.save_ts.get())
self.cfg ['options']['rst'] = str(self.rst.get())
self.cfg ['options']['rev_pick'] = str(self.rev_pick.get())
self.cfg ['options']['is_VST'] = str(self.is_VST.get())
self.cfg ['options']['quit_onprc'] = str(self.quit_onprc.get())
self.cfg ['options']['pred_norm'] = str(self.pred_norm.get())
Vars['options'] = dict()
for opt in self.cfg['options'].keys():
Vars['options'][opt] = self.cfg['options'][opt]
with open(self.path_cfg.get(), 'w') as f:
self.cfg.write(f)
......@@ -273,9 +280,14 @@ class RST_pick_GUI(tk.Tk):
if self.rst.get() == 1:
# Evaluate all data sets and store results in a list
if self.rev_pick.get() == 1:
eval_data = [rfnc.eval_shearstress(cur_dat, Vars,
review='auto')
for cur_dat in exp_data]
eval_data = [
rfnc.eval_shearstress(
cur_dat,
Vars,
review='auto'
)
for cur_dat in exp_data
]
else:
eval_data = [rfnc.eval_shearstress(cur_dat, Vars)
for cur_dat in exp_data]
......@@ -355,9 +367,6 @@ class RST_pick_GUI(tk.Tk):
pfit, perr, name_fit = rfnc.vst_analysis(exp)
rfnc.plotVST(path_out, exp, pfit, perr, name_fit)
# ======= Exit if 'exit on processing' is selected =====
if self.quit_onprc.get() == 1:
sys.exit(0)
def closing_menu(self):
"""Shows a confirmation dialogue for closing"""
......@@ -379,7 +388,8 @@ class RST_pick_GUI(tk.Tk):
opt_dlg.label_item.grid(column=0, row=i + 1, sticky='e')
opt_dlg.entry_item = tk.Entry(opt_dlg,
textvariable=self.params[item[0]],
justify='right')
justify='right',
width=45)
opt_dlg.entry_item.grid(column=1, row=i + 1, sticky='EW')
opt_dlg.label_unit = tk.Label(opt_dlg,
text=self.cfg['units'][item[0]])
......@@ -397,7 +407,7 @@ class RST_pick_GUI(tk.Tk):
self.rst.set(self.cfg.getint('options', 'rst'))
self.rev_pick.set(self.cfg.getint('options', 'rev_pick'))
self.is_VST.set(self.cfg.getint('options', 'is_VST'))
self.quit_onprc.set(self.cfg.getint('options', 'quit_onprc'))
self.pred_norm.set(self.cfg.getint('options', 'pred_norm'))
# Read parameters and store them as a dictionary of StringVars
# This automatically links them to changes made in the Options dialog.
for item in self.cfg['parameters'].items():
......@@ -462,7 +472,7 @@ class RST_pick_GUI(tk.Tk):
'rst': 1, # if 1: automatic picking
'rev_pick': 1, # if 1: the user can review the picked peaks
'is_VST': 0, # if 1: the file is a VST-Test file
'quit_onprc': 0, # if 1: automatically quits after processing
'pred_norm': 1, # if 1: uses predefined normal stresses
}
config['parameters'] = {
......@@ -474,7 +484,8 @@ class RST_pick_GUI(tk.Tk):
'velnoise': 1e-2,
'stressnoise': 0.025,
'cellweight': 2185.3, # weight of shear cell
'smoothwindow': 5 # Smoothing Factor for plots
'smoothwindow': 5, # Smoothing Factor for plots
'pred_norms': [500, 1000, 2000, 4000, 8000, 16000, 20000]
}
config['units'] = {
......@@ -486,7 +497,8 @@ class RST_pick_GUI(tk.Tk):
'velnoise': 'mm/min',
'stressnoise': 'Pa',
'cellweight': 'g',
'smoothwindow': 'samples'
'smoothwindow': 'samples',
'pred_norms': 'Pa'
}
self.path_cfg.set(config['paths']['path_cfg'])
with open(self.path_cfg.get(), 'w') as f:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment