Commit 4260ec45 authored by Michael Rudolf's avatar Michael Rudolf
Browse files

Removed unnecessary modules and fixed small bug due to missing ','

parent dc779628
...@@ -10,16 +10,12 @@ import numpy as np ...@@ -10,16 +10,12 @@ import numpy as np
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec import matplotlib.gridspec as gridspec
import pandas as pd import pandas as pd
import glob
import shutil
import codecs import codecs
import csv import csv
from os.path import isfile, join, basename, splitext
import os import os
from nptdms import TdmsFile from nptdms import TdmsFile
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
from scipy import signal from scipy import signal
from pylab import *
from scipy import stats from scipy import stats
...@@ -105,7 +101,6 @@ def eval_shearstress(R, var): ...@@ -105,7 +101,6 @@ def eval_shearstress(R, var):
# %===================SMOOTHING FUCTION======================================== # %===================SMOOTHING FUCTION========================================
def savitzky_golay(y, window_size, order, deriv=0, rate=1): def savitzky_golay(y, window_size, order, deriv=0, rate=1):
import numpy as np
from math import factorial from math import factorial
try: try:
...@@ -122,7 +117,7 @@ def savitzky_golay(y, window_size, order, deriv=0, rate=1): ...@@ -122,7 +117,7 @@ def savitzky_golay(y, window_size, order, deriv=0, rate=1):
b = np.mat([[k**i for i in ord_rng] for k in range(-half_w, half_w+1)]) b = np.mat([[k**i for i in ord_rng] for k in range(-half_w, half_w+1)])
m = np.linalg.pinv(b).A[deriv] * rate**deriv * factorial(deriv) m = np.linalg.pinv(b).A[deriv] * rate**deriv * factorial(deriv)
# pad the signal at the extremes with values taken from the signal itself # pad the signal at the extremes with values taken from the signal itself
firstvals = y[0] - np.abs(y[1:half_w+1][::-1] - y[0]) firstvals = y[0]-np.abs(y[1:half_w+1][::-1] - y[0])
lastvals = y[-1]+np.abs(y[-half_w-1:-1][::-1] - y[-1]) lastvals = y[-1]+np.abs(y[-half_w-1:-1][::-1] - y[-1])
y = np.concatenate((firstvals, y, lastvals)) y = np.concatenate((firstvals, y, lastvals))
return np.convolve(m[::-1], y, mode='valid') return np.convolve(m[::-1], y, mode='valid')
...@@ -141,11 +136,11 @@ def rst_analmut(x, y): ...@@ -141,11 +136,11 @@ def rst_analmut(x, y):
M[k, j] = (y[k+j]-y[k])/(x[k+j]-x[k]) # calculate slope/ friction M[k, j] = (y[k+j]-y[k])/(x[k+j]-x[k]) # calculate slope/ friction
j += 1 j += 1
k += 1 k += 1
M[M == inf] = NaN # set inf to Nan M[M == np.inf] = np.nan # set inf to Nan
M[M == -inf] = NaN # set -inf to Nan M[M == -np.inf] = np.nan # set -inf to Nan
M[M == 0] = NaN # set 0 to Nan M[M == 0] = np.nan # set 0 to Nan
M[M < 0] = NaN # set <0 to Nan M[M < 0] = np.nan # set <0 to Nan
M[M > 1] = NaN # set 0 to Nan M[M > 1] = np.nan # set 0 to Nan
M_avg, M_std = stats.norm.fit(M[~np.isnan(M)]) # mean and standard deviation M_avg, M_std = stats.norm.fit(M[~np.isnan(M)]) # mean and standard deviation
for k in range(0, n-1): for k in range(0, n-1):
...@@ -154,9 +149,9 @@ def rst_analmut(x, y): ...@@ -154,9 +149,9 @@ def rst_analmut(x, y):
j = j+1 j = j+1
k = k+1 k = k+1
# calculation of cohesions (y axis intercept): # calculation of cohesions (y axis intercept):
C[C == inf] = NaN # set inf to Nan C[C == np.inf] = np.nan # set inf to Nan
C[C == -inf] = NaN # set -inf to Nan C[C == -np.inf] = np.nan # set -inf to Nan
C[C == 0.0] = NaN # set 0 to Nan C[C == 0.0] = np.nan # set 0 to Nan
C_avg, C_std = stats.norm.fit(C[~np.isnan(C)]) # mean and standard deviation C_avg, C_std = stats.norm.fit(C[~np.isnan(C)]) # mean and standard deviation
fric_mut = (M_avg, M_std, C_avg, C_std) fric_mut = (M_avg, M_std, C_avg, C_std)
data_mut = (M, C) data_mut = (M, C)
...@@ -267,7 +262,7 @@ def plothist(path, name, strength, data_mut): ...@@ -267,7 +262,7 @@ def plothist(path, name, strength, data_mut):
# ==============FRICTION COEFFICIENT======================== # ==============FRICTION COEFFICIENT========================
axrow[0].hist(coef[~np.isnan(coef)], axrow[0].hist(coef[~np.isnan(coef)],
bins=nbins, bins=nbins,
normed=True, density=True,
color='royalblue', color='royalblue',
edgecolor='black') edgecolor='black')
lnspc = np.linspace(np.nanmin(coef), np.nanmax(coef), len(coef)) lnspc = np.linspace(np.nanmin(coef), np.nanmax(coef), len(coef))
...@@ -292,7 +287,7 @@ def plothist(path, name, strength, data_mut): ...@@ -292,7 +287,7 @@ def plothist(path, name, strength, data_mut):
# ==============COHESION================================ # ==============COHESION================================
axrow[1].hist(coh[~np.isnan(coh)], axrow[1].hist(coh[~np.isnan(coh)],
bins=nbins, bins=nbins,
normed=True, density=True,
color='royalblue', color='royalblue',
edgecolor='black') edgecolor='black')
statscoh = stats.norm.fit(coh[~np.isnan(coh)]) statscoh = stats.norm.fit(coh[~np.isnan(coh)])
...@@ -339,12 +334,12 @@ def plotts(path, name, ts, sigma_sort, var): ...@@ -339,12 +334,12 @@ def plotts(path, name, ts, sigma_sort, var):
for i in range(0, t): for i in range(0, t):
sigma_legend = int(np.sum(sigma_sort[i*3:(i*3)+3])/3) sigma_legend = int(np.sum(sigma_sort[i*3:(i*3)+3])/3)
plt.plot(ts.iloc[:, 0], np.zeros(len(ts.iloc[:, 0])), plt.plot(ts.iloc[:, 0], np.zeros(len(ts.iloc[:, 0])),
linewidth=0.5 linewidth=0.5,
color=linecolor[i+1] color=linecolor[i+1],
label=str(sigma_legend)+' Pa') label=str(sigma_legend)+' Pa')
plt.plot(ts.iloc[:, 0], plt.plot(ts.iloc[:, 0],
ts.iloc[:, i*3+1:(i+1)*3+1] ts.iloc[:, i*3+1:(i+1)*3+1],
linewidth=0.5 linewidth=0.5,
color=linecolor[i+1]) color=linecolor[i+1])
plt.legend(fontsize=8, plt.legend(fontsize=8,
facecolor='w', facecolor='w',
...@@ -371,7 +366,7 @@ def saveTS(path, name, ts): ...@@ -371,7 +366,7 @@ def saveTS(path, name, ts):
index=None, index=None,
sep='\t', sep='\t',
mode='w', mode='w',
na_rep='NaN') # write to txt file na_rep='np.nan') # write to txt file
def saveStrength(path, name, strength): def saveStrength(path, name, strength):
......
...@@ -8,20 +8,7 @@ Created on Mon Jul 23 14:32:17 2018 ...@@ -8,20 +8,7 @@ Created on Mon Jul 23 14:32:17 2018
# %%===========================IMPORT========================================== # %%===========================IMPORT==========================================
import numpy as np import numpy as np
import pandas as pd import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
import csv
import pylab
from scipy import stats
import os import os
import fnmatch
import glob
import shutil
import pickle
from nptdms import TdmsFile
import collections
import itertools
from operator import itemgetter
import RST_Func import RST_Func
# %%==========================NAMES============================================ # %%==========================NAMES============================================
......
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