def read_data(): tc = [ 'TC13-130', 'TC13-133', 'TC13-207', 'TC16-111', 'TC16-113', 'TC16-104', 'TC16-104', 'TC12-212', 'TC17-113', 'TC15-111', 'TC14-016', 'TC12-004', 'TC17-205', 'TC16-127', 'TC18-110', 'TC16-129', 'TC18-105', 'TC17-207', 'TC16-140' ] channels = ['14CHST0000Y7ACXC', '16CHST0000Y7ACXC'] tests, _ = get_test_info() tc = [i for i in tc if i in tests] _, t, chdata = initialize('P:\\', channels, cutoff, tc=tc) return t, chdata
'11NECKUP00THFOXA', '11NECKUP00THFOZA', '11NECKLO00THFOXA', '11NECKLO00THFOZA', '11HEAD003SH3ACRA', '11CHST003SH3ACRC', '11HEAD0000H3ACXA', '11HEAD0000H3ACRA', '11CHST0000H3ACXC', '11CHST0000H3ACRC', '11PELV0000H3ACXA', '11HICR0015H3ACRA', '11CHST0000H3DSXB', '11FEMRLE00H3FOZB', '11FEMRRI00H3FOZB', '11SEBE0000B3FO0D', '11SEBE0000B6FO0D', '11NECKUP00H3FOZA', '13HEAD0000HFACXA', '13HEAD0000HFACRA', '13NECKUP00HFFOXA', '13NECKUP00HFFOYA', '13NECKUP00HFFOZA', '13NECKUP00HFFORA', '13CHST0000HFACXC', '13CHST0000HFACRC', '13CHST0000HFDSXB', '13LUSP0000HFFOXA', '13ILACLE00HFFOXA', '13ILACRI00HFFOXA', '13PELV0000HFACXA', '13FEMRLE00HFFOZB', '13FEMRRI00HFFOZB', '13SEBE0000B3FO0D', '13SEBE0000B6FO0D', '13HEAD003SHFACRA', '13CHST003SHFACRC', '13BRIC0000HFAV0D' ] table, t, chdata = initialize(directory, channels, cutoff, verbose=False) #%% preprocessing preprocess_channels = [ '11CHSTLEUPTHDSXB', '11CHSTRIUPTHDSXB', '11CHSTLELOTHDSXB', '11CHSTRILOTHDSXB' ] chdata[preprocess_channels] = chdata[preprocess_channels].applymap( lambda x: x - x[0]) if 'TC13-006' in chdata.index: chdata.at['TC13-006', '11SEBE0000B6FO0D'] = -chdata.at['TC13-006', '11SEBE0000B6FO0D'] chdata.at['TC18-030', '10SIMELE00INACXD'] = np.tile(np.nan, len(cutoff)) #%% feature extraction
cutoff = range(100, 1600) channels = [ '11HICR0000TH00RA', '11HICR0036TH00RA', '11HICR0015TH00RA', '11HICR0000THACRA', '11HICR0036THACRA', '11HICR0015THACRA', '11BRIC0000THAV0D', '11HEAD0000THACXA', '11HEAD0000THACZA', '11HEAD0000THACRA', '11NECKUP00THFOXA', '11NECKUP00THFOYA', '11NECKUP00THFOZA', '11NECKLO00THFOXA', '11NECKLO00THFOYA', '11NECKLO00THFOZA', '11CLAVLEOUTHFOXA', '11CLAVLEINTHFOXA', '11SPIN0100THACXC', '11SPIN0100THACYC', '11CHST0000THACXC', '11CHST0000THACYC', '11CHSTLEUPTHDSXB', '11CHSTRILOTHDSXB', '11CHSTLELOTHDSXB', '11CHSTRIUPTHDSXB', '11THSP0100THAVZA', '11PELV0000THACXA', '11FEMRLE00THFOZB', '11FEMRRI00THFOZB' ] table, t, chdata = initialize(directory, channels, cutoff) #%% feature extraction def get_all_features(write_csv=False): i_to_t = get_i_to_t(t) feature_funs = { 'Min_': [get_min], 'Max_': [get_max], 'Tmin_': [get_argmin, i_to_t], 'Tmax_': [get_argmax, i_to_t] } features = pd.concat(chdata.chdata.get_features(feature_funs).values(), axis=1, sort=True)
'11PELV0000H3ACXA', '11PELV0000H3ACZA', '11PELV0000H3ACRA', '11HICR0015H3ACRA', '11NIJCIPTEH300YX', '11NIJCIPTFH300YX', '11NIJCIPCFH300YX', '11NIJCIPCEH300YX', '11CHST0000H3DSXB', '11FEMRLE00H3FOZB', '11FEMRRI00H3FOZB', '10SIMELE00INACXD', '10SIMERI00INACXD'] drop = [] table, t, chdata, se_names = initialize(directory,channels,cutoff) table = table.drop(drop) preprocess = ['11CHSTLEUPTHDSRB','11CHSTRIUPTHDSRB','11CHSTLELOTHDSRB','11CHSTRILOTHDSRB'] chdata[preprocess] = chdata[preprocess].applymap(lambda x: x-x[0]) chdata['11CHST0000THDSRB'] = chdata[preprocess].applymap(max).max(axis=1).apply(lambda x: [x]) #chdata = chdata.drop(preprocess,axis=1) #%% if __name__=='__main__': def i_to_t(i): if not np.isnan(i): return t[int(i)] else: return np.nan
'S0SLED000000VEXD' ] query_list = [['DUMMY', ['Y2', 'Y7']], ['INSTALL', ['H1', 'H3', 'HB', 'LB', 'C1', 'B0', 'B11', 'B12']]] exclude = [ 'SE16-0343', # <- this is Summit H3 'SE16-0395', 'SE16-0399', 'SE17-0018_2' ] table, t, chdata = initialize(directory, channels, cutoff, drop=exclude, query_list=query_list) append = [chdata] #%% angle stuff displacement = get_se_angle(chdata.index) se_angles = displacement.apply( get_angle, axis=1).apply(lambda x: x - x[0]).rename('Angle') abs_angles = displacement.apply(get_angle, axis=1).rename('Abs_Angle') angle_t = displacement['Time'] / 1000 position = displacement.drop('Time', axis=1) displacement = position.applymap(lambda x: x - x[0]).rename(lambda x: 'D' + x, axis=1) # shift certain signals
from PMG.COM.easyname import renameISO from PMG.COM.arrange import sep_by_peak, t_ch_from_test_ch directory = 'C:\\Users\\tangk\\Desktop\\AHEC EV\\' dummy = 'H3' cutoff = range(100, 1600) n = 1 channels = [ '13HEAD0000HFACXA', '13CHST0000HFACXC', '13PELV0000HFACXA', '13FEMRLE00HFFOZB', '13FEMRRI00HFFOZB', '13SEBE0000B3FO0D', '13SEBE0000B6FO0D', '13ILACLE00HFFOXA', '13ILACRI00HFFOXA' ] table, t, chdata, se_names = initialize(directory, channels, cutoff, query='ID13==\'HF\'') #%% pairs = { 'Cruze': ['TC17-025', 'TC15-035'], 'Camry': ['TC15-162', 'TC17-028'], 'Civic': ['TC15-155', 'TC17-203'], 'Sentra': ['TC16-205', 'TC17-206'], 'Explorer': ['TC11-233', 'TC11-234'], 'Tiguan': ['TC15-029', 'TC15-030'] } lp_abs = {} up_abs = {} for ch in channels:
chlist = [ '11HEAD0000THACXA', '11HEAD0000THACRA', '11NECKUP00THFOXA', '11CHST0000THACXC', '11CHST0000THACRC', '11PELV0000THACXA', '11HEAD0000H3ACXA', '11HEAD0000H3ACRA', '11NECKUP00H3FOXA', '11CHST0000H3ACXC', '11CHST0000H3ACRC', '11PELV0000H3ACXA', 'Max_11HEAD0000THACRA', 'Max_11HEAD0000H3ACRA', 'Min_11HEAD0000THACXA', 'Min_11HEAD0000H3ACXA', 'Max_11NECKUP00THFOZA', 'Max_11NECKUP00H3FOZA', 'Max_11CHST0000THACRC', 'Max_11CHST0000H3ACRC', 'Min_11CHST0000THACXC', 'Min_11CHST0000H3ACXC', 'Min_11PELV0000THACXA', 'Min_11PELV0000H3ACXA', '10CVEHCG0000ACXD', '10SIMELE00INACXD', '10SIMERI00INACXD' ] chlist = list(set(chlist)) table, t, chdata = initialize('P:/Data Analysis/Projects/AHEC EV/', chlist, range(100, 1600)) #%% table.Type_2 = table.Type_2.fillna(table.Type) pairs = table[table.Type.isin(['ICE']) & table.Speed.isin([48]) & table.Series_1.isin([1])].Pair.reset_index() pairs.columns = ['ICE', 'EV'] series2 = table[table.Speed.isin([48]) & table.Series_2.isin([1])].iloc[:, :10].reset_index() s_left = series2.loc[series2.Type.isin(['ICE']), ['TC', 'Model', 'Counterpart']] s_right = series2.loc[:, ['TC', 'Model', 'Counterpart']] pairs2 = s_left.merge(s_right, left_on='Model', right_on='Counterpart').loc[:, ['TC_x', 'TC_y']] pairs2.columns = ['ICE', 'EV']
'11CHST0000H3ACXC', '11CHST0000H3ACYC', '11CHST0000H3ACZC', '11PELV0000H3ACXA', '11HICR0015H3ACRA', '11CHST0000H3DSXB', '11FEMRLE00H3FOZB', '11FEMRRI00H3FOZB', '11SEBE0000B3FO0D', '11SEBE0000B6FO0D', '11NIJCIPTEH300YX', '11NIJCIPTFH300YX', '11NIJCIPCFH300YX', '11NIJCIPCEH300YX'] table, t, chdata = initialize(directory,channels,cutoff,query='Subset==\'PAIRED\'') preprocess = ['11CHSTLEUPTHDSXB','11CHSTRIUPTHDSXB','11CHSTLELOTHDSXB','11CHSTRILOTHDSXB'] chdata[preprocess] = chdata[preprocess].applymap(lambda x: x-x[0]) if 'TC13-006' in chdata.index: chdata['11SEBE0000B6FO0D']['TC13-006'] = -chdata['11SEBE0000B6FO0D']['TC13-006'] #chdata['11CHST0000THDSXB'] = chdata[preprocess] #%% define testing parameters #if __init__ == '__main__': # to_JSON = {'project_name': 'THOR_vs_H3_Driver', # 'directory' : directory, # 'cat' : {'THOR_paired' : list(table.query('Subset==\'PAIRED\' and ID11==\'TH\'').index), # 'H3_paired' : list(table.query('Subset==\'PAIRED\' and ID11==\'H3\'').index),
'11CHSTLELOTHDSXB', '11HEAD0000H3ACXA', '11HEAD0000H3ACZA', '11HEAD0000H3ACRA', '11NECKUP00H3FOZA', '11NECKUP00H3MOYB', '11CHST0000H3ACXC', '11PELV0000H3ACXA', '11HICR0015H3ACRA', '11CHST0000H3DSXB', '11FEMRLE00H3FOZB', '11FEMRRI00H3FOZB', '11SEBE0000B3FO0D', '11SEBE0000B6FO0D'] table, t, chdata, se_names = initialize(directory,channels,cutoff,query='SUBSET==\'PAIRED\'') preprocess = ['11CHSTLEUPTHDSXB','11CHSTRIUPTHDSXB','11CHSTLELOTHDSXB','11CHSTRILOTHDSXB'] chdata[preprocess] = chdata[preprocess].applymap(lambda x: x-x[0]) #chdata['11CHST0000THDSXB'] = chdata[preprocess] #%% for ch in channels: if len(chdata[ch].iloc[0])==1 or 'DSX' in ch or 'H3' in ch: continue fig, axs = plt.subplots(nrows=1,ncols=2,sharey=True,figsize=(15,5)) if 'TH' in ch: th = chdata[ch] h3 = chdata[ch[:10] + 'H3' + ch[12:]] else: