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

Functionality for large datasets.

 - Added several new options to handle data sets with many samples.
 - New options allow to specify to how many samples a dataset should
   be downsampled to, either with or without filtering. The default is
   using no filtering, which leads to much faster computing times.
parent faa2a80d
......@@ -20,12 +20,23 @@ import nptdms
import numpy as np
from scipy.optimize import least_squares, curve_fit
from scipy.stats import norm
from scipy.signal import medfilt
from scipy.signal import medfilt, resample
# %%==============CONVERSION===================================================
def convert(path, file_in, var):
"""Reads data from source files and returns a dictionary with data"""
def downsample(y, nsamples, dofilter=True):
""" Downsamples a filtered version of the input data. """
kernelsize = int((len(y)/nsamples)/2)
if dofilter:
y_filt = medfilt(y, kernel_size=kernelsize)
else:
y_filt = y
subset = np.linspace(0, len(y)-1, 10000).astype(int)
return (y_filt[subset])
# possible inputs and linked helper functions
file_convert = {'.asc': _readasc,
'.dat': _readdat,
......@@ -33,6 +44,23 @@ def convert(path, file_in, var):
(root, ext) = os.path.splitext(path+file_in)
data = file_convert[ext](path, file_in) # data contains basic content
nsamples = int(var['nsamples'])
if len(data['time']) > nsamples:
data['time'] = np.linspace(0, data['time'][-1], nsamples)
data['velocity'] = downsample(
data['velocity'], nsamples,
dofilter=var['downsample_filter']
)
data['shearforce'] = downsample(
data['shearforce'], nsamples,
dofilter=var['downsample_filter']
)
data['normalforce'] = downsample(
data['normalforce'], nsamples,
dofilter=var['downsample_filter']
)
print('Data to large... Downsampled to %i samples.' % nsamples)
# Corrections
data['time'] = data['time']-data['time'][0]
......
......@@ -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-07-09 17:52:48
# @Last Modified time: 2020-09-23 10:44:14
"""
RST_pick_GUI.py
......@@ -485,7 +485,9 @@ class RST_pick_GUI(tk.Tk):
'stressnoise': 0.025,
'cellweight': 2185.3, # weight of shear cell
'smoothwindow': 5, # Smoothing Factor for plots
'pred_norms': [500, 1000, 2000, 4000, 8000, 16000, 20000]
'pred_norms': [500, 1000, 2000, 4000, 8000, 16000, 20000],
'nsamples': 10000, # Maximum number of samples to use
'downsample_filter': 0, # Use downsampling filter or not.
}
config['units'] = {
......@@ -498,7 +500,9 @@ class RST_pick_GUI(tk.Tk):
'stressnoise': 'Pa',
'cellweight': 'g',
'smoothwindow': 'samples',
'pred_norms': 'Pa'
'pred_norms': 'Pa',
'nsamples': 'samples',
'downsample_filter': '(0 = No, 1 = Yes)',
}
self.path_cfg.set(config['paths']['path_cfg'])
with open(self.path_cfg.get(), 'w') as f:
......
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