CITT Dortmund läuft, Tests hinzugefügt
This commit is contained in:
@@ -5,19 +5,21 @@ from csv import reader
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
from paveit.labtest import DataSineLoad
|
||||
from torch import isin
|
||||
|
||||
|
||||
class CITTBase(DataSineLoad):
|
||||
|
||||
def _calc(self):
|
||||
return (self.df.mean().mean(), self.df.max().max())
|
||||
|
||||
|
||||
class CITT_KIT(DataSineLoad):
|
||||
|
||||
def _calc(self):
|
||||
return (self.df.mean().mean(), self.df.max().max())
|
||||
|
||||
def _process_data(self):
|
||||
logger.debug('convert bytes to pandas.DataFrame')
|
||||
self._logger.debug('convert bytes to pandas.DataFrame')
|
||||
|
||||
self.data.seek(0)
|
||||
with io.TextIOWrapper(self.data, encoding='latin-1') as read_obj:
|
||||
@@ -82,7 +84,6 @@ class CITT_KIT(DataSineLoad):
|
||||
idx = t[(t['ZEIT'] >= tmin) & (t['ZEIT'] < tmax)].index
|
||||
N[idx] = i
|
||||
|
||||
|
||||
t['N'] = N
|
||||
|
||||
res.append(t)
|
||||
@@ -96,8 +97,9 @@ class CITT_KIT(DataSineLoad):
|
||||
#define in class
|
||||
self.data = res.reset_index()
|
||||
|
||||
|
||||
class CITT_PTMDortmund(DataSineLoad):
|
||||
|
||||
|
||||
def _define_units(self):
|
||||
|
||||
self.unit_s = 1 #mm
|
||||
@@ -106,15 +108,16 @@ class CITT_PTMDortmund(DataSineLoad):
|
||||
|
||||
def update_parameter(self):
|
||||
|
||||
self.meta_names_of_parameter = {'sigma': ['Max. Spannung', 'Max Stress'],
|
||||
'f': ['Frequenz', 'Frequency'],
|
||||
'T': ['Versuchstemperatur', 'Target Test Temperature'],
|
||||
'Nfrom': ['Erster Aufzeichnungslastwechsel', 'Start Cycle'],
|
||||
'Nto': ['Letzer Aufzeichnungslastwechsel', 'Last Cycle'],
|
||||
't': ['Zeitfolgen', 'Time Series'],
|
||||
'speciment_diameter': ['Durchmesser (mm)', 'Diameter (mm)'],
|
||||
'speciment_height': ['Länge (mm)', 'Length (mm)'],
|
||||
} #list of names
|
||||
self.meta_names_of_parameter = {
|
||||
'sigma': ['Max. Spannung', 'Max Stress'],
|
||||
'f': ['Frequenz', 'Frequency'],
|
||||
'T': ['Versuchstemperatur', 'Target Test Temperature'],
|
||||
'Nfrom': ['Erster Aufzeichnungslastwechsel', 'Start Cycle'],
|
||||
'Nto': ['Letzer Aufzeichnungslastwechsel', 'Last Cycle'],
|
||||
't': ['Zeitfolgen', 'Time Series'],
|
||||
'speciment_diameter': ['Durchmesser (mm)', 'Diameter (mm)'],
|
||||
'speciment_height': ['Länge (mm)', 'Length (mm)'],
|
||||
} #list of names
|
||||
|
||||
self.data_column_names = {
|
||||
'time': ['Time Series'],
|
||||
@@ -132,7 +135,6 @@ class CITT_PTMDortmund(DataSineLoad):
|
||||
diameter = []
|
||||
height = []
|
||||
|
||||
|
||||
for sheetid in range(num_sheets):
|
||||
temp = pd.read_excel(self.data, sheetid, skiprows=97)
|
||||
temp = temp.drop(index=0)
|
||||
@@ -141,24 +143,23 @@ class CITT_PTMDortmund(DataSineLoad):
|
||||
for col in temp.columns:
|
||||
temp[col] = pd.to_numeric(temp[col])
|
||||
|
||||
|
||||
#read metadata from file
|
||||
|
||||
meta = pd.read_excel(self.data, sheetid,
|
||||
skiprows=1,
|
||||
nrows=80)
|
||||
meta = pd.read_excel(self.data, sheetid, skiprows=1, nrows=80)
|
||||
|
||||
meta = meta[meta.columns[[0, 2]]]
|
||||
meta = meta.set_index(
|
||||
meta.columns[0])
|
||||
|
||||
meta = meta.set_index(meta.columns[0])
|
||||
|
||||
meta = meta.dropna(axis=0)
|
||||
meta = meta[meta.columns[0]]
|
||||
|
||||
|
||||
meta = meta.to_dict()
|
||||
|
||||
|
||||
#remove whitespace in dict keys:
|
||||
meta = {x.strip(): v for x, v in meta.items() if isinstance(x, str)}
|
||||
meta = {
|
||||
x.strip(): v
|
||||
for x, v in meta.items() if isinstance(x, str)
|
||||
}
|
||||
|
||||
frequency_test = None
|
||||
# add metadata to dataframe
|
||||
@@ -167,21 +168,21 @@ class CITT_PTMDortmund(DataSineLoad):
|
||||
v = None
|
||||
for name in names:
|
||||
try:
|
||||
v = np.round(float(meta[name]),5)
|
||||
|
||||
v = np.round(float(meta[name]), 5)
|
||||
|
||||
if par == 'f':
|
||||
v = np.round(v,2)
|
||||
|
||||
v = np.round(v, 2)
|
||||
|
||||
break
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
assert v is not None
|
||||
temp[par] = v
|
||||
|
||||
|
||||
if par == 'f':
|
||||
frequency_test = v
|
||||
|
||||
|
||||
# read additional parameters
|
||||
names = self.meta_names_of_parameter['Nfrom']
|
||||
for name in names:
|
||||
@@ -191,7 +192,7 @@ class CITT_PTMDortmund(DataSineLoad):
|
||||
except:
|
||||
Nfrom = None
|
||||
assert Nfrom is not None
|
||||
|
||||
|
||||
names = self.meta_names_of_parameter['Nto']
|
||||
for name in names:
|
||||
try:
|
||||
@@ -209,32 +210,29 @@ class CITT_PTMDortmund(DataSineLoad):
|
||||
break
|
||||
except:
|
||||
time_idx = None
|
||||
assert time_idx is not None
|
||||
|
||||
temp['N'] = 0
|
||||
assert time_idx is not None
|
||||
|
||||
self._logger.info(f'cycles from {Nfrom} to {Nto}')
|
||||
temp['N'] = 0
|
||||
|
||||
#BUG: Ist in Messdatei falsch definiert und wird von PTM angepasst. '''
|
||||
#for cycle in range(Nfrom, Nto+1):
|
||||
|
||||
dt = 1.0/frequency_test
|
||||
|
||||
|
||||
dt = 1.0 / frequency_test
|
||||
|
||||
tmax = dt
|
||||
max_timeindex = max(time_idx)
|
||||
|
||||
|
||||
cycle = 0
|
||||
while tmax < max_timeindex:
|
||||
# time window
|
||||
tmin = (cycle) * dt
|
||||
tmin = (cycle) * dt
|
||||
tmax = (cycle + 1) * dt
|
||||
#filter data
|
||||
idx = temp[(time_idx >= tmin)
|
||||
& (time_idx < tmax)].index
|
||||
|
||||
idx = temp[(time_idx >= tmin) & (time_idx < tmax)].index
|
||||
|
||||
#set cycle number
|
||||
temp.loc[idx, 'N'] = cycle
|
||||
|
||||
|
||||
cycle += 1
|
||||
|
||||
# add diameter and height to list
|
||||
@@ -247,7 +245,7 @@ class CITT_PTMDortmund(DataSineLoad):
|
||||
v = None
|
||||
assert v is not None
|
||||
diameter.append(v)
|
||||
|
||||
|
||||
names = self.meta_names_of_parameter['speciment_height']
|
||||
for name in names:
|
||||
try:
|
||||
@@ -257,7 +255,7 @@ class CITT_PTMDortmund(DataSineLoad):
|
||||
v = None
|
||||
assert v is not None
|
||||
height.append(v)
|
||||
|
||||
|
||||
#append data to final dataframe
|
||||
res.append(temp)
|
||||
|
||||
@@ -270,13 +268,11 @@ class CITT_PTMDortmund(DataSineLoad):
|
||||
# self.metadata['speciment_diameter'] = np.mean(diameter)
|
||||
#if not 'speciment_height' in self.metadata:
|
||||
# self.metadata['speciment_height'] = np.mean(height)
|
||||
|
||||
|
||||
|
||||
#define in class
|
||||
self.data = res.reset_index()
|
||||
self.metadata.update(meta)
|
||||
|
||||
# log infos
|
||||
self._logger.debug(self.metadata)
|
||||
self._logger.debug(self.data.head())
|
||||
self._logger.info(self.metadata)
|
||||
self._logger.info(self.data.head())
|
||||
Reference in New Issue
Block a user