ConvertVSTTDMStoTXT.py 1.8 KB
Newer Older
Michael Rudolf's avatar
Michael Rudolf committed
1
2
3
4
5
6
7
8
9
10
11
# -*- coding: utf-8 -*-
"""
Converts all *.tdms files in the folder given in `path_in` and creates a
velocity stepping plot for each of them in the folder `path_out`. This script
requires `rstevaluation` to be installed on the system.

@author: M.Rudolf
"""
import os

import numpy as np
12
13
14
import rstevaluation.analysis as rstanalysis
import rstevaluation.files as rstfiles
import rstevaluation.plots as rstplots
Michael Rudolf's avatar
Michael Rudolf committed
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53


def main():
    projectname = '393-01_01_Foamglass100'

    path_in = 'Legacy/FileConversion/input'
    path_out = 'Legacy/FileConversion/output'
    # =========== PARAMETERS & VARIABLES ============
    var = {
        'A':  0.022619,  # area of shear zone (= surface area of lid) (m^2)
        'li': 0.0776,  # inner lever (center cell to center of shear zone)
        'lo': 0.1250,  # outer lever (center cell to hinge point)
        'le': 1.611655493,  # load point level
        'v':  30,  # shear velocity (mm/min)
        'g': 9.81,  # acceleration due to gravity
        'prec': 125,  # rounding precision for normal load in file names
        'velnoise': 1e-2,
        'stressnoise': 0.025,
        'smoothwindow': 51,  # define window for smooth shear stress curve
        'nsamples': 10**6  # Maximum number of samples for downsampling
    }
    exp_data = [
        rstfiles.convert(path_in, f, var)
        for f in os.listdir(path_in)
        if f.endswith('.tdms')
    ]
    normal_stresses = [
        '%i' % (np.floor(np.mean(d['normalstress'])/var['prec'])*var['prec'])
        for d in exp_data
    ]

    for exp in exp_data:
        pfit, perr, name_fit = rstanalysis.vst_analysis(exp)
        rstplots.plotVST(path_out, exp, pfit, perr, name_fit)
    rstfiles.saveTS(path_out, projectname, exp_data, normal_stresses)


if __name__ == '__main__':
    main()