Commit 1cbb84db authored by Michael Rudolf's avatar Michael Rudolf
Browse files

Rounding in saveTS and plotTS

parent 5df8d28c
......@@ -721,12 +721,11 @@ def plotVST(path, data, pfit, perr, name_fit):
# %%========================SAVE===============================================
def saveTS(path, name, exp_data):
def saveTS(path, name, exp_data, normal_stress):
""" Saves time series in a txt file """
# create header
header = ['Time [s]']
n_stress = ['%.0f' % np.mean(m['normalstress']) for m in exp_data]
for n in n_stress:
for n in normal_stress:
header.append(n)
# position of longest measurement
......@@ -736,11 +735,15 @@ def saveTS(path, name, exp_data):
time_max = exp_data[pos_dfmax]['time']
# create array to save to file
ts_data = np.zeros((max_len, len(exp_data)+1))
ts_data[:, 0] = time_max
for i, ex in enumerate(exp_data):
# ts_data = np.zeros((max_len, len(exp_data)+1))
ts_data = ['%.5f' % t for t in time_max]
for ex in exp_data:
pads = np.ones(max_len-len(ex['shearstress']))*np.nan
ts_data[:, i+1] = np.hstack((ex['shearstress'], pads))
next = np.hstack((np.around(ex['shearstress'], 2), pads))
next_str = ['%.2f' % n for n in next]
ts_data = np.vstack((ts_data, next_str))
ts_data = ts_data.T
# create file and save it
with open(path+name+'_ts.txt', 'w+') as f:
......@@ -781,30 +784,30 @@ def saveFric(path, name, fricmut, fricstd):
f_string = ''
f_string += 'Peak friction:' + \
'\t' + \
str(fricstd[0][0]) + \
'\t'+str(fricstd[0][1]) + \
'\t'+str(fricstd[0][2]) + \
'\t'+str(fricstd[0][3]) + \
str(np.around(fricstd[0][0], 4)) + \
'\t'+str(np.around(fricstd[0][1], 4)) + \
'\t'+str(np.around(fricstd[0][2], 4)) + \
'\t'+str(np.around(fricstd[0][3], 4)) + \
'\n'
f_string += 'Dynamic friction:' + \
'\t' + \
str(fricstd[1][0]) + \
str(np.around(fricstd[1][0], 4)) + \
'\t' + \
str(fricstd[1][1]) + \
str(np.around(fricstd[1][1], 4)) + \
'\t' + \
str(fricstd[1][2]) + \
str(np.around(fricstd[1][2], 4)) + \
'\t' + \
str(fricstd[1][3]) + \
str(np.around(fricstd[1][3], 4)) + \
'\n'
f_string += 'Reactivation friction:' + \
'\t' + \
str(fricstd[2][0]) + \
str(np.around(fricstd[2][0], 4)) + \
'\t' + \
str(fricstd[2][1]) + \
str(np.around(fricstd[2][1], 4)) + \
'\t' + \
str(fricstd[2][2]) + \
str(np.around(fricstd[2][2], 4)) + \
'\t' + \
str(fricstd[2][3]) + \
str(np.around(fricstd[2][3], 4)) + \
'\n'
write_f = f.write(f_string)
f.closed
......@@ -813,33 +816,33 @@ def saveFric(path, name, fricmut, fricstd):
f_string = ''
f_string += 'Peak friction:' + \
'\t' + \
str(fricmut[0][0]) + \
str(np.around(fricmut[0][0], 4)) + \
'\t' + \
str(fricmut[0][1]) + \
str(np.around(fricmut[0][1], 4)) + \
'\t' + \
str(fricmut[0][2]) + \
str(np.around(fricmut[0][2], 4)) + \
'\t' + \
str(fricmut[0][3]) + \
str(np.around(fricmut[0][3], 4)) + \
'\n'
f_string += 'Dynamic friction:' + \
'\t' + \
str(fricmut[1][0]) + \
str(np.around(fricmut[1][0], 4)) + \
'\t' + \
str(fricmut[1][1]) + \
str(np.around(fricmut[1][1], 4)) + \
'\t' + \
str(fricmut[1][2]) + \
str(np.around(fricmut[1][2], 4)) + \
'\t' + \
str(fricmut[1][3]) + \
str(np.around(fricmut[1][3], 4)) + \
'\n'
f_string += 'Reactivation friction:' + \
'\t' + \
str(fricmut[2][0]) + \
str(np.around(fricmut[2][0], 4)) + \
'\t' + \
str(fricmut[2][1]) + \
str(np.around(fricmut[2][1], 4)) + \
'\t' + \
str(fricmut[2][2]) + \
str(np.around(fricmut[2][2], 4)) + \
'\t' + \
str(fricmut[2][3])+'\n'
str(np.around(fricmut[2][3], 4))+'\n'
write_f = f.write(f_string)
f.closed
......
......@@ -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-16 15:35:52
# @Last Modified time: 2020-05-16 16:04:24
"""
RST_pick_GUI.py
......@@ -286,7 +286,7 @@ class RST_pick_GUI(tk.Tk):
for cur_dat in exp_data]
# Create lists of parameters for analysis
normal_stress = [ev[0] for ev in eval_data]
normal_stress = [int(ev[0]) for ev in eval_data]
peak_stress = [ev[1][1] for ev in eval_data]
dyn_stress = [ev[2][1] for ev in eval_data]
stat_stress = [ev[3][1] for ev in eval_data]
......@@ -347,7 +347,7 @@ class RST_pick_GUI(tk.Tk):
print('>>> There is no prop file! Going on as usual.')
if self.save_ts.get() == 1:
rfnc.saveTS(path_out, projectname, exp_data)
rfnc.saveTS(path_out, projectname, exp_data, normal_stress)
print('>>> Time series data saved')
else:
print('Velocity Stepping Test')
......
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