Esempio n. 1
0
channels = ['11PCA00000THAV0B']
wherepeaks = np.array(['+tive'])
cutoff = range(1)

files1.sort()
files2.sort()
plotfigs = 0
savefigs = 0
writefiles = 0
bs_n_it = 5000
bs_alpha = 0.05
bs_nbin = [25, 25]

#%% read data
t, fulldata_1 = import_data(directory, channels, tcns=files1)
chdata_1 = arrange.test_ch_from_chdict(fulldata_1, cutoff)
t, fulldata_2 = import_data(directory, channels, tcns=files2)
chdata_2 = arrange.test_ch_from_chdict(fulldata_2, cutoff)
t = t.get_values()[cutoff]


#%% get values
def get_values(data):
    return data[0]


chdata_1 = chdata_1.applymap(get_values)
chdata_2 = chdata_2.applymap(get_values)

print('No-slip:')
Esempio n. 2
0
if __name__ == '__main__':
    from PMG.COM import table as tb

    path = os.fspath('P:/AHEC/DATA/Full Sample/48/')
    project = 'AHEC'
    plot_path = 'P:/AHEC/Plots/Clustering/THOR/'

    table = tb.get(project)
    tcns = table[table.SUBSET.isin(['HEV vs ICE'])
                 & table.VITESSE.isin([48])].CIBLE.tolist() + table[
                     table.SUBSET.isin(['HEV vs ICE'])
                     & table.VITESSE.isin([48])].BELIER.tolist()
    #    tcns = None

    time, raw = import_data(path,
                            '10CVEHCG0000ACXD',
                            tcns,
                            sl=slice(100, 1600))
    labels = make_labels(raw, project)

    clusters, data = cluster(time,
                             raw,
                             labels,
                             plot_path,
                             mode='both',
                             N=4,
                             norm=True,
                             smooth=True,
                             plot_all=True,
                             plot_data=True,
                             matrix=False,
                             tag='new')
Esempio n. 3
0
# -*- coding: utf-8 -*-
"""
Created on Mon Mar 19 12:23:40 2018

@author: giguerf
"""
import matplotlib.pyplot as plt
import numpy as np
from PMG.COM import data, plotstyle as style, table as tb

THOR = 'P:/AHEC/Data/THOR/'
chlist = ['11NECKLO00THFOXA', '11CHSTLELOTHDSXB','11CHST0000THACXC','11CHSTRILOTHDSXB','11CHSTRIUPTHDSXB','11SPIN0100THACYC','11SEBE0000B3FO0D']
time, fulldata = data.import_data(THOR, chlist, check=False)

table = tb.get('THOR')
table = table[table.TYPE.isin(['Frontale/Véhicule'])]
slips  = table[table.CBL_BELT.isin(['SLIP'])].CIBLE.tolist()
oks = table[table.CBL_BELT.isin(['OK'])].CIBLE.tolist()

#%%
my_color = 'tab:blue'
plt.close('all')
#plt.figure()
df = fulldata['11CHSTRILOTHDSXB'].loc[:,:].dropna(axis=1)
#for tcn in df.columns:
#    plt.plot(time, df[tcn], '.', color='tab:blue', markersize=0.5, alpha=1)

fig, axs = plt.subplots(1,2,sharex=True,sharey=True, figsize=(12,6))
ax = axs[0]
ax.plot(time, df, color=my_color, lw=1, alpha=1)
Esempio n. 4
0
#        else:
#            values = [cmap(n)[:3] for n in range(cmap.N)]
#
#
#    values = [values[k%len(values)] for k in range(len(keys))]
#    colors = dict(zip(keys, values))
#
#    return colors

if __name__ == '__main__':
    import PMG.COM.data as data
    import PMG.COM.table as tb
    import PMG.COM.plotstyle as style
    THOR = 'P:/AHEC/Data/THOR/'
    chlist = ['11NECKLO00THFOXA']
    time, fulldata = data.import_data(THOR, chlist)
    df = fulldata['11NECKLO00THFOXA'].dropna(axis=1)
    table = tb.get('THOR')
    table = table[table.TYPE.isin(['Frontale/Véhicule'])]
    slips = table[table.CBL_BELT.isin(['SLIP'])].CIBLE.tolist()
    oks = table[table.CBL_BELT.isin(['OK'])].CIBLE.tolist()
    plt.close('all')
    #%%
    plt.figure()
    colors = style.colordict(df, 'order', plt.cm.YlGnBu)
    for tcn in df.columns[:]:
        plt.plot(df.loc[:, tcn], color=colors[tcn])
    #%%
    df = df.loc[:, slips + oks]
    colors = style.colordict(df, 'max', plt.cm.YlGnBu_r)
    colors = style.colordict(df, 'max', ['tab:blue', 'tab:red'], 3)
Esempio n. 5
0
def plotbook(savedir, chlist, tcns=None):
    """
    Plot THOR-related basic overview plots. All pairs by channels and both
    groups with means/intervals by channels.
    """
    import pandas as pd
    import matplotlib.pyplot as plt
    from PMG.COM import plotstyle as style, data, table as tb

    descriptions = pd.read_excel('P:/AHEC/Descriptions.xlsx', index_col=0)
    description = descriptions.to_dict()[descriptions.columns[0]]

    time, fulldata = data.import_data('P:/AHEC/DATA/THOR/',
                                      chlist,
                                      tcns,
                                      check=False)
    #    for k,v in fulldata.items():
    #        fulldata[k] = data.check_and_clean(v, stage=2)

    table = tb.get('THOR')
    table = table[table.CIBLE.isin(tcns)]
    slips = table[table.CBL_BELT.isin(['SLIP'])].CIBLE.tolist()
    oks = table[table.CBL_BELT.isin(['OK'])].CIBLE.tolist()
    table = table[table.CIBLE.isin(slips + oks)]

    #%% FIGURE 1 - all pairs plotted individually

    xlim = (0, 0.3)
    xlabel = 'Time [s]'

    plt.close('all')
    for channel in chlist:
        slipdf = fulldata[channel].loc[:, slips]
        okdf = fulldata[channel].loc[:, oks]
        plotdata = pd.concat([slipdf, okdf], axis=1)

        if plotdata.empty:
            continue

        ylabel = style.ylabel(channel[12:14], channel[14:15])

        r, c = style.sqfactors(len(plotdata.columns.tolist()))
        fig, axs = style.subplots(r,
                                  c,
                                  sharex='all',
                                  sharey='all',
                                  visible=True,
                                  num='All Pairs: ' + channel)
        fig.suptitle('{ch} - {desc}'.format(ch=channel,
                                            desc=description.get(
                                                channel,
                                                'Description Unavailable')))

        for i, tcn in enumerate(table.CIBLE):
            ax = axs[i]
            ax.plot(time, plotdata.loc[:, tcn], color='tab:green', label=tcn)
            ax.set_xlim(*xlim)

            title = ' '.join(
                [tcn, table[table.CIBLE == tcn].CBL_MODELE.tolist()[0]])
            ax.set_title(title)
            ax.set_ylabel(ylabel)
            ax.set_xlabel(xlabel)
            ax.legend(loc=4)

        plt.tight_layout(rect=[0, 0, 1, 0.92])
        plt.savefig(savedir + 'All_Pairs_' + channel + '.png', dpi=200)
        plt.close('all')

    #%% FIGURE 2 - Vehicle groups and means

    plt.close('all')
    for channel in chlist:

        slipdf = fulldata[channel].loc[:, slips]
        okdf = fulldata[channel].loc[:, oks]

        ylabel = style.ylabel(channel[12:14], channel[14:15])

        fig, axs = style.subplots(2,
                                  2,
                                  sharex='all',
                                  sharey='all',
                                  num='Belt: ' + channel,
                                  figsize=(20, 12.5))
        fig.suptitle('{ch} - {desc}'.format(ch=channel,
                                            desc=description.get(
                                                channel,
                                                'Description Unavailable')))

        #FIRST SUBPLOT - 'SLIP' Group full data set
        ax = axs[0]
        ax.plot(time,
                slipdf,
                lw=1,
                color='tab:blue',
                label='n = {}'.format(slipdf.shape[1]))
        ax.set_title('Slipping Belts')
        ax.set_ylabel(ylabel)
        ax.set_xlabel(xlabel)
        style.legend(ax, loc=4)

        #THIRD SUBPLOT - 'OK' Group full data set
        ax = axs[2]
        ax.plot(time,
                okdf,
                lw=1,
                color='tab:orange',
                label='n = {}'.format(okdf.shape[1]))
        ax.set_title('Ok Belts')
        ax.set_ylabel(ylabel)
        ax.set_xlabel(xlabel)
        style.legend(ax, loc=4)

        #SECOND SUBPLOT - 'CIBLE' vs 'BELIER' Groups (median and intervals)
        ax = axs[1]
        data.tolerance(ax, time, slipdf, 'tab:blue')
        data.tolerance(ax, time, okdf, 'tab:orange')

        ax.set_title('All Belts (Mean and Intervals)')
        ax.set_ylabel(ylabel)
        ax.set_xlabel(xlabel)
        ax.legend(loc=4)

        ax.set_xlim(*xlim)
        #%%
        plt.subplots_adjust(top=0.893,
                            bottom=0.060,
                            left=0.048,
                            right=0.974,
                            hspace=0.222,
                            wspace=0.128)
        plt.savefig(savedir + 'Belt_' + channel + '.png', dpi=200)
        plt.close('all')
Esempio n. 6
0
# -*- coding: utf-8 -*-
"""
Created on Fri Apr  6 12:55:37 2018

@author: giguerf
"""
import matplotlib.pyplot as plt
import numpy as np
import scipy
from PMG.COM import data as dat

time, data = dat.import_data('P:/AHEC/Data/THOR/',
                             '11PELV0000THACXA',
                             check=False)
#time, data = dat.import_data('P:/SLED/Data/', '12PELV0000Y7ACXA', check=False)

#sl = slice(100,1600)
sl = slice(100, 1100)
#%%

x = np.linspace((sl.start - 100) / 10000, (sl.stop - 100) / 10000,
                sl.stop - sl.start)

A = 0.11
B = 0.08
C = -28
D = 1870
a = -2
b = 10000
c = 0.04
Esempio n. 7
0
import numpy as np
import pandas as pd
import matplotlib
import matplotlib.pyplot as plt
import PMG.COM.data as dat
import PMG.COM.table as tb
import PMG.COM.plotstyle as style
THOR = 'P:/Data Analysis/Projects/AHEC/Data/THOR/'
chlist = []
chlist.extend(['11NECKLO00THFOXA','11NECKLO00THFOYA','11FEMRLE00THFOZB'])
chlist.extend(['11CHSTLEUPTHDSXB','11CHSTRIUPTHDSXB','11CHSTLELOTHDSXB','11CHSTRILOTHDSXB'])
chlist.extend(['11HEAD0000THACXA','11SPIN0100THACXC', '11CHST0000THACXC', '11SPIN1200THACXC', '11PELV0000THACXA'])
chlist.extend(['11HEAD0000THACYA','11SPIN0100THACYC', '11CHST0000THACYC', '11SPIN1200THACYC', '11PELV0000THACYA'])
chlist.extend(['11SPIN0100THACYC','11THSP0100THAVXA','11THSP0100THAVZA'])
chlist = list(set(chlist))
time, fulldata = dat.import_data(THOR, chlist, check=False)
table = tb.get('THOR')
#table = table[table.TYPE.isin(['Frontale/Véhicule'])]
#table = table[table.TYPE.isin(['Frontale/Mur'])]
slips  = table[table.CBL_BELT.isin(['SLIP'])].CIBLE.tolist()
oks = table[table.CBL_BELT.isin(['OK'])].CIBLE.tolist()

plt.rcParams['font.size']= 10

#slip_color = 'tab:blue'
#ok_color = 'tab:red'

slip_color = '#5e3c99'
slide_color = '#fdb863'
ok_color = '#e66101'