Commit 2aa70499 authored by Michael Rudolf's avatar Michael Rudolf
Browse files

Better manual picks #7:

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