Commit 0290200c authored by Michael Rudolf's avatar Michael Rudolf
Browse files

Better manual picks:

 - Now manual picks on filtered data
 - Data is now filtered while reading
parent 31e92179
......@@ -12,7 +12,9 @@ import shutil
import nptdms
import numpy as np
import uncertainties as unc
from scipy.signal import medfilt
from tqdm import tqdm
from uncertainties import unumpy as unp
from rstevaluation import data as rstdat
......@@ -66,6 +68,19 @@ def convert(path, file_in, config):
data['displacement'] = np.cumsum(data['time'][1]*data['velocity'])
data['name'] = file_in
data['shear_smth_nom'] = medfilt(
data['shearstress'],
config.getint('parameters', 'smoothwindow')
)
data['shear_smth'] = unp.uarray(
data['shear_smth_nom'],
np.full_like(
data['shear_smth_nom'],
# estimated accuracy of machine (+-10 Pa)
# and error of sensor (0.5%)
np.sqrt(10**2 + (data['shear_smth_nom']*0.005)**2)
)
)
print(file_in+' read')
return data
......
......@@ -10,8 +10,6 @@ import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
import uncertainties as unc
from scipy.signal import medfilt
from uncertainties import unumpy as unp
# %%==================EVALUATION SHEAR CURVE DATA==============================
......@@ -73,21 +71,6 @@ def eval_shearstress(cur_dat, config, review=None):
def _auto_pick(cur_dat, config):
"""Helper function to automatically pick the points"""
# smoothing function: 1st#: window size, 2nd#: polynomial order
shear_smth = medfilt(
cur_dat['shearstress'],
config.getint('parameters', 'smoothwindow')
)
shear_smth = unp.uarray(
shear_smth,
np.full_like(
shear_smth,
# estimated accuracy of machine (+-10 Pa)
# and error of sensor (0.5%)
np.sqrt(10**2 + (shear_smth*0.005)**2)
)
)
# Searching for velocity changes to define data range
vel_above = np.nonzero(
cur_dat['velocity'] > config.getfloat('parameters', 'velnoise')
......@@ -98,16 +81,16 @@ def _auto_pick(cur_dat, config):
start_2 = end_1+np.max(np.diff(vel_above))+10
end_2 = vel_above[0][-1]
# Peak friction
i_peak = np.argmax(shear_smth[start_1:end_1])+start_1
tau_peak = shear_smth[i_peak]
i_peak = np.argmax(cur_dat['shear_smth'][start_1:end_1])+start_1
tau_peak = cur_dat['shear_smth'][i_peak]
# Dynamic friction
i_dyn = np.argmin(shear_smth[i_peak:end_1])+i_peak
tau_dyn = shear_smth[i_dyn]
i_dyn = np.argmin(cur_dat['shear_smth'][i_peak:end_1])+i_peak
tau_dyn = cur_dat['shear_smth'][i_dyn]
# Static friction (reactivation)
i_stat = np.argmax(shear_smth[start_2:end_2])+start_2
tau_stat = shear_smth[i_stat]
i_stat = np.argmax(cur_dat['shear_smth'][start_2:end_2])+start_2
tau_stat = cur_dat['shear_smth'][i_stat]
# Store picks in dictionary
picks = dict()
......@@ -153,7 +136,7 @@ def _manual_pick(cur_dat, config,
while not goodPick:
try:
(sel_dat, sel) = _select_data(cur_dat)
pdata = pick_func[pick](cur_dat['shearstress'][sel_dat])
pdata = pick_func[pick](cur_dat['shear_smth_nom'][sel_dat])
picked_val = unc.ufloat(
pdata, np.sqrt(10**2+pdata*.005**2)
)
......@@ -163,7 +146,7 @@ def _manual_pick(cur_dat, config,
ax.plot(
cur_dat['displacement'][sel_dat],
cur_dat['shearstress'][sel_dat],
cur_dat['shear_smth_nom'][sel_dat],
color=pick_col[pick]
)
plt.pause(0.001)
......@@ -261,12 +244,9 @@ def _pick_base_plot(cur_dat, config):
alpha=.5,
label='2$\sigma$ accuracy'
)
shear_smth = medfilt(
cur_dat['shearstress'], config.getint('parameters', 'smoothwindow')
)
ax.plot(
cur_dat['displacement'],
shear_smth,
cur_dat['shear_smth_nom'],
':',
label='filtered data',
color='C1'
......
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