Datenmodelle angepasst, einige Firmen in CITT übernommen
This commit is contained in:
@@ -40,6 +40,12 @@ class DataSineLoad():
|
||||
|
||||
self._pre_run()
|
||||
|
||||
def _which_machine(self):
|
||||
"""
|
||||
check the file and try to get the machine from the data
|
||||
"""
|
||||
pass
|
||||
|
||||
def _set_parameter(self):
|
||||
self._logger.debug('run _set_parameter')
|
||||
|
||||
@@ -120,6 +126,15 @@ class DataSineLoad():
|
||||
encoding = 'utf-8'
|
||||
self.data = pd.read_csv(self.data, encoding=encoding)
|
||||
|
||||
def _meta_to_float(self):
|
||||
|
||||
for key, d in self.metadata.items():
|
||||
try:
|
||||
f = float(d.replace(',', '.'))
|
||||
self.metadata[key] = f
|
||||
except:
|
||||
pass
|
||||
|
||||
def _standardize_data(self):
|
||||
self._logger.debug('run _standardize_data')
|
||||
|
||||
@@ -143,12 +158,24 @@ class DataSineLoad():
|
||||
|
||||
break
|
||||
|
||||
def _modify_meta(self):
|
||||
pass
|
||||
|
||||
def _validate_data(self):
|
||||
self._logger.debug('run _validate_data')
|
||||
|
||||
for name in self.val_col_names:
|
||||
if not name in self.data.columns:
|
||||
raise
|
||||
|
||||
# check if value in metadata:
|
||||
if name in self.metadata.keys():
|
||||
|
||||
self.data[name] = self.metadata[name]
|
||||
|
||||
else:
|
||||
|
||||
print(name)
|
||||
raise
|
||||
|
||||
def _validate_meta(self):
|
||||
self._logger.debug('run _validate_meta')
|
||||
@@ -157,6 +184,17 @@ class DataSineLoad():
|
||||
if not name in self.metadata:
|
||||
raise
|
||||
|
||||
def _post_string_to_float(self):
|
||||
|
||||
sel = self.data.select_dtypes(include=['object'])
|
||||
|
||||
if sel.empty:
|
||||
return
|
||||
|
||||
for col in sel.columns:
|
||||
self.data[col] = pd.to_numeric(self.data[col].str.replace(
|
||||
',', '.'))
|
||||
|
||||
def _post_apply_units(self):
|
||||
|
||||
for col in ['s_hor_sum', 's_hor_1', 's_hor_2']:
|
||||
@@ -209,6 +247,13 @@ class DataSineLoad():
|
||||
|
||||
for idx, d in data_gp:
|
||||
|
||||
if d.empty: continue
|
||||
|
||||
if any(d['f'] <= 0.0): continue
|
||||
|
||||
#reset N
|
||||
d['N'] = d['N'] - d['N'].iloc[0] + 1
|
||||
|
||||
idx_diff = np.diff(d.index)
|
||||
dt_mean = idx_diff.mean()
|
||||
|
||||
@@ -249,129 +294,27 @@ class DataSineLoad():
|
||||
(a): Based on window of TP-Asphalt
|
||||
(b) last N cycles
|
||||
|
||||
DUMMY FUNCTION
|
||||
"""
|
||||
|
||||
self._logger.debug('run _fit_select_data')
|
||||
|
||||
def sel_df(df, num=5):
|
||||
|
||||
N = df['N'].unique()
|
||||
freq = float(df['f'].unique()[0])
|
||||
|
||||
# define cycles to select
|
||||
if freq == 10.0:
|
||||
Nfrom = 98
|
||||
Nto = 103
|
||||
elif freq == 5.0:
|
||||
Nfrom = 93
|
||||
Nto = 97
|
||||
elif freq == 3.0:
|
||||
Nfrom = 43
|
||||
Nto = 47
|
||||
elif freq == 1.0:
|
||||
Nfrom = 13
|
||||
Nto = 17
|
||||
elif freq == 0.3:
|
||||
Nfrom = 8
|
||||
Nto = 12
|
||||
elif freq == 0.1:
|
||||
Nfrom = 3
|
||||
Nto = 7
|
||||
else:
|
||||
Nfrom = None
|
||||
Nto = None
|
||||
|
||||
# Fall 1: nicht alle LW in Datei
|
||||
if (max(N) < Nto) & (len(N) >= num):
|
||||
df_sel = df[(df['N'] >= N[-num]) & (df['N'] <= N[-1])]
|
||||
|
||||
# Fall 2:
|
||||
else:
|
||||
|
||||
if Nfrom != None:
|
||||
if len(N) > Nto - Nfrom:
|
||||
df_sel = df[(df['N'] >= Nfrom) & (df['N'] <= Nto)]
|
||||
|
||||
return df_sel
|
||||
|
||||
if not isinstance(self.data, list):
|
||||
if self.number_of_load_cycles_for_analysis > 1:
|
||||
df_sel = [
|
||||
sel_df(self.data,
|
||||
num=self.number_of_load_cycles_for_analysis)
|
||||
]
|
||||
else:
|
||||
df_sel = [self.data]
|
||||
|
||||
else:
|
||||
df_sel = []
|
||||
for d in self.data:
|
||||
if self.number_of_load_cycles_for_analysis > 1:
|
||||
d_sel = sel_df(d,
|
||||
num=self.number_of_load_cycles_for_analysis)
|
||||
else:
|
||||
d_sel = d
|
||||
|
||||
df_sel.append(d_sel)
|
||||
|
||||
# replace data
|
||||
self.data = df_sel
|
||||
pass
|
||||
|
||||
def _calc(self):
|
||||
"""
|
||||
Calculate Results
|
||||
DUMMY FUNCTION
|
||||
"""
|
||||
|
||||
self.fit = []
|
||||
for idx_data, data in enumerate(self.data):
|
||||
self._logger.info('run _calc base')
|
||||
print('run BASE')
|
||||
|
||||
if data is None: continue
|
||||
if len(data) < 10: continue
|
||||
def save(self):
|
||||
'''
|
||||
save results to database
|
||||
|
||||
DUMMY FUNCTION
|
||||
'''
|
||||
|
||||
data.index = data.index - data.index[0]
|
||||
|
||||
res_temp = {}
|
||||
|
||||
x = data.index.values
|
||||
|
||||
freq = np.round(float(data['f'].unique()), 2)
|
||||
sigma = float(data['sigma'].unique())
|
||||
temperature = float(data['T'].unique())
|
||||
|
||||
for idxcol, col in enumerate(self.columns_analyse):
|
||||
|
||||
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)
|
||||
|
||||
res_temp['f'] = freq
|
||||
res_temp['sigma'] = sigma
|
||||
res_temp['T'] = temperature
|
||||
|
||||
## Stiffness
|
||||
deltaF = res_temp['fit_F_amp']
|
||||
nu = calc_nu(temperature)
|
||||
res_temp['nu'] = nu
|
||||
|
||||
h = float(self.metadata['speciment_height'])
|
||||
|
||||
deltaU = res_temp['fit_s_hor_sum_amp']
|
||||
|
||||
res_temp['E'] = (deltaF * (0.274 + nu)) / (h * deltaU)
|
||||
|
||||
self.fit.append(res_temp)
|
||||
|
||||
self.fit = pd.DataFrame.from_records(self.fit)
|
||||
|
||||
self.fit = self.fit.set_index(['T', 'f', 'sigma'])
|
||||
|
||||
nsamples = len(self.fit)
|
||||
self._logger.info(f'fitting finished, add {nsamples} samples')
|
||||
self._logger.debug(self.fit['E'])
|
||||
pass
|
||||
|
||||
def _pre_run(self):
|
||||
|
||||
@@ -379,6 +322,7 @@ class DataSineLoad():
|
||||
self._read_from_s3_to_bytesio()
|
||||
|
||||
self._calc_hash_of_bytesio()
|
||||
self._which_machine()
|
||||
self._set_parameter()
|
||||
self.update_parameter()
|
||||
self._define_units()
|
||||
@@ -387,12 +331,15 @@ class DataSineLoad():
|
||||
self._logger.info('run task')
|
||||
|
||||
self._process_data()
|
||||
self._meta_to_float()
|
||||
|
||||
self._standardize_data()
|
||||
self._standardize_meta()
|
||||
self._modify_meta()
|
||||
self._validate_data()
|
||||
self._validate_meta()
|
||||
|
||||
self._post_string_to_float()
|
||||
self._post_select_importent_columns()
|
||||
self._post_apply_units()
|
||||
self._post_calc_missiong_values()
|
||||
|
||||
Reference in New Issue
Block a user