Datenstrukturen und Auswertung angepasst
This commit is contained in:
159
src/paveit/labtest/citt.py
Normal file → Executable file
159
src/paveit/labtest/citt.py
Normal file → Executable file
@@ -5,6 +5,7 @@ from csv import reader
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
from bson import ObjectId
|
||||
|
||||
from paveit import calc_nu, fit_cos
|
||||
from paveit.datamodels import CITTSiffness, CITTSiffnessResults
|
||||
from paveit.io import read_geosys
|
||||
@@ -135,14 +136,43 @@ class CITTBase(DataSineLoad):
|
||||
if not col in data.columns: continue
|
||||
|
||||
y = data[col].values
|
||||
|
||||
res = fit_cos(x, y, freq=freq)
|
||||
|
||||
for key, value in res.items():
|
||||
res_temp[f'fit_{col}_{key}'] = value
|
||||
|
||||
|
||||
res_temp[f'fit_{col}_max'] = max(y)
|
||||
res_temp[f'fit_{col}_min'] = min(y)
|
||||
# analyse cycle data
|
||||
|
||||
cycle_min = []
|
||||
cycle_max = []
|
||||
cycle_mean = []
|
||||
cycle_diff = []
|
||||
|
||||
for N, data_cycle in data.groupby('N'):
|
||||
y = data_cycle[col].values
|
||||
|
||||
cycle_min.append(y.min())
|
||||
cycle_max.append(y.max())
|
||||
cycle_mean.append(y.mean())
|
||||
cycle_diff.append(cycle_max[-1] - cycle_min[-1])
|
||||
|
||||
res_temp[f'fit_{col}_cycle_min'] = cycle_min
|
||||
res_temp[f'fit_{col}_min'] = np.mean(cycle_min)
|
||||
res_temp[f'fit_{col}_min_std'] = np.std(cycle_min)
|
||||
res_temp[f'fit_{col}_min_diff_rel'] = (np.max(cycle_min) - np.min(cycle_min))/np.mean(cycle_min)
|
||||
res_temp[f'fit_{col}_cycle_max'] = cycle_max
|
||||
res_temp[f'fit_{col}_max'] = np.mean(cycle_max)
|
||||
res_temp[f'fit_{col}_max_std'] = np.std(cycle_max)
|
||||
res_temp[f'fit_{col}_max_diff_rel'] = (np.max(cycle_max) - np.min(cycle_max))/np.mean(cycle_max)
|
||||
res_temp[f'fit_{col}_cycle_mean'] = cycle_mean
|
||||
res_temp[f'fit_{col}_mean'] = np.mean(cycle_mean)
|
||||
res_temp[f'fit_{col}_mean_std'] = np.std(cycle_mean)
|
||||
res_temp[f'fit_{col}_mean_diff_rel'] = (np.max(cycle_mean) - np.min(cycle_mean))/np.mean(cycle_mean)
|
||||
res_temp[f'fit_{col}_cycle_diff'] = cycle_diff
|
||||
res_temp[f'fit_{col}_diff'] = np.mean(cycle_diff)
|
||||
res_temp[f'fit_{col}_diff_std'] = np.std(cycle_diff)
|
||||
res_temp[f'fit_{col}_diff_diff_rel'] = (np.max(cycle_diff) - np.min(cycle_diff))/np.mean(cycle_diff)
|
||||
|
||||
# add more metadata
|
||||
res_temp['f_set'] = freq
|
||||
@@ -186,12 +216,9 @@ class CITTBase(DataSineLoad):
|
||||
self._logger.debug(self.fit['stiffness'])
|
||||
|
||||
def save(self,
|
||||
org_id: ObjectId,
|
||||
project_id: ObjectId,
|
||||
material_id: ObjectId,
|
||||
user_id: ObjectId,
|
||||
meta: dict = {},
|
||||
wp_id: ObjectId | None = None):
|
||||
task_id: ObjectId,
|
||||
meta: dict = {}
|
||||
):
|
||||
"""
|
||||
save results to mongodb
|
||||
"""
|
||||
@@ -200,16 +227,13 @@ class CITTBase(DataSineLoad):
|
||||
raise
|
||||
|
||||
# precheck data and results
|
||||
assert len(self.data) == len(self.fit)
|
||||
#assert len(self.data) == len(self.fit)
|
||||
|
||||
for idx_fit, fit in self.fit.iterrows():
|
||||
data = self.data[idx_fit]
|
||||
|
||||
meta['filehash'] = self.filehash
|
||||
meta['org_id'] = org_id
|
||||
meta['project_id'] = project_id
|
||||
meta['material'] = material_id
|
||||
meta['user_id'] = user_id
|
||||
meta['task_id'] = task_id
|
||||
|
||||
#check if result in db
|
||||
#n = CITTSiffness.objects(**meta).count()
|
||||
@@ -726,11 +750,13 @@ class CITT_LaborHart(CITTBase):
|
||||
data.columns = head
|
||||
|
||||
# FIX: Sigma nicht in Metadaten oder Messdaten enthalten
|
||||
sigma = float(
|
||||
os.path.split(self.filename)[-1].split('MPa')[0].strip().replace(
|
||||
',', '.'))
|
||||
print(meta)
|
||||
if not "sigma" in self.metadata:
|
||||
sigma = float(
|
||||
os.path.split(self.filename)[-1].split('MPa')[0].strip().replace(
|
||||
',', '.'))
|
||||
|
||||
meta['sigma'] = sigma
|
||||
meta['sigma'] = sigma
|
||||
|
||||
#clean data
|
||||
data = data.dropna(axis=1)
|
||||
@@ -847,3 +873,100 @@ class CITT_BAGKoeln(CITTBase):
|
||||
# log infos
|
||||
self._logger.info(self.metadata)
|
||||
self._logger.info(self.data.head())
|
||||
|
||||
class CITT_Braunschweig(CITTBase):
|
||||
|
||||
def _define_units(self):
|
||||
|
||||
self.unit_s = 1.0 #mm
|
||||
self.unit_F = -1000.0 #N
|
||||
self.unit_t = 1.0
|
||||
|
||||
def update_parameter(self):
|
||||
|
||||
self.meta_names_of_parameter = {
|
||||
't': ['t [s]'],
|
||||
} #list of names
|
||||
|
||||
self.data_column_names = {
|
||||
'time': ['t [s]'],
|
||||
'f': [ 'FREQUENZ_x10'],
|
||||
'F': [ 'F act [kN]'],
|
||||
's_hor_1': ['r 1A [mm]'],
|
||||
's_hor_2': ['r 1B [mm]'],
|
||||
's_piston': ['s piston [mm]'],
|
||||
}
|
||||
|
||||
def _process_data(self):
|
||||
|
||||
self._logger.info(self.metadata)
|
||||
|
||||
meta = {}
|
||||
|
||||
encoding = 'latin-1'
|
||||
|
||||
self.data.seek(0)
|
||||
|
||||
head = pd.read_csv(self.data,
|
||||
skiprows=14,
|
||||
sep=';',
|
||||
nrows=1,
|
||||
encoding=encoding,
|
||||
decimal=',',
|
||||
thousands='.',
|
||||
skip_blank_lines=True).columns
|
||||
|
||||
head = [h.strip() for h in head]
|
||||
|
||||
self.data.seek(0)
|
||||
data = pd.read_csv(self.data,
|
||||
skiprows=20,
|
||||
sep=';',
|
||||
encoding=encoding,
|
||||
decimal=',',
|
||||
thousands='.',
|
||||
header=None,
|
||||
skip_blank_lines=True)
|
||||
|
||||
data.columns = head
|
||||
|
||||
# add frequency
|
||||
## [start, ncycles]
|
||||
sel = {0.1: [0, 11], 1.0: [11, 20], 5.0: [30, 100], 10: [130, 111]}
|
||||
|
||||
N_f_dict = {}
|
||||
|
||||
Ns = 0
|
||||
for freq in sel.keys():
|
||||
|
||||
par = sel[freq]
|
||||
|
||||
N = par[0]
|
||||
dN = par[1]
|
||||
|
||||
for i in range(N, N + dN):
|
||||
|
||||
N_f_dict[Ns] = freq
|
||||
|
||||
Ns += 1
|
||||
|
||||
data['f'] = data['N'].replace(N_f_dict)
|
||||
data = data[data['f'] <= 10.0]
|
||||
|
||||
#sigma
|
||||
data['sigma'] = self.metadata['sigma']
|
||||
data['T'] = self.metadata['temperature']
|
||||
|
||||
#clean data
|
||||
#data = data.dropna(axis=0)
|
||||
#data = data.dropna(axis=1)
|
||||
|
||||
data = data.drop(columns=['Date Time'])
|
||||
|
||||
#define in class
|
||||
self.data = data
|
||||
self.metadata.update(meta)
|
||||
|
||||
# log infos
|
||||
self._logger.info(self.metadata)
|
||||
self._logger.info(self.data.head())
|
||||
|
||||
Reference in New Issue
Block a user