def import_data(directory, channels, tcns=None, sl=slice(None), check=True, stage=1): """Import a channel's or channels' dataframe(s), cleaned of outliers. Optionally filter by list of tcns and slice. Set check to False to skip 'view outliers' prompt Input: ---------- directory : str path to HDF5 store channels : str or list channels for which to return data. If string, returns DataFrame rather than dictionary tcns : list list of tcns to include. tcns missing data will automatically be dropped sl : slice object slice for rows. check : bool If false, bypass checking and drop any outliers found by clean_outliers() Returns: ---------- time : Series corresponding time channel clean : dict (or DataFrame) cleaned data ready for use. """ return_single = False if isinstance(channels, str): channels = [channels] return_single = True time, fulldata = ob.openHDF5(os.fspath(directory), channels) t = time[sl] clean = {} for channel in channels: raw = fulldata[channel][sl] if tcns is not None: raw = raw.loc[:, tcns].dropna(how='all', axis=1) if check: clean[channel] = check_and_clean(raw, stage) else: clean[channel] = clean_outliers(raw, stage) if return_single: return t, clean[channel] else: return t, clean
@author: giguerf """ import os import numpy as np import pandas as pd import matplotlib.pyplot as plt from PMG.COM.openbook import openHDF5 import PMG.COM.data as data from PMG.COM.data import check_and_clean import PMG.COM.plotstyle as style import PMG.COM.table as tb THOR = os.fspath('P:/AHEC/Data/THOR/') chlist = ['11CHSTLEUPTHDSXB', '11CHSTRIUPTHDSXB', '11CHSTRILOTHDSXB', '11CHSTLELOTHDSXB'] time, fulldata = openHDF5(THOR, chlist) for ch in chlist: print(ch) fulldata[ch] = check_and_clean(fulldata[ch],1) table = tb.get('THOR') table = table[table.TYPE.isin(['Frontale/Véhicule']) & table.VITESSE.isin([48,56])] ok, slip = tb.tcns(tb.split(table, column='CBL_BELT', categories=['OK','SLIP'])) #%% if 0: cd = style.colordict(chlist) titles = dict(zip(chlist, ['Upper Left', 'Upper Right', 'Lower Right', 'Lower Left'])) plt.close('all')
import matplotlib.pyplot as plt from PMG.COM.openbook import openHDF5 from PMG.COM import table as tb from matplotlib.animation import FuncAnimation from matplotlib.widgets import Slider import matplotlib.gridspec as gridspec table = tb.get('SLED') SLED = 'P:/SLED/Data/' chlist = [ '12HEAD0000Y7ACXA', '12HEAD0000Y2ACXA', '12CHST0000Y7ACXC', '12CHST0000Y2ACXC', '12PELV0000Y7ACXA', '12PELV0000Y2ACXA' ] time, fulldata = openHDF5(SLED, chlist) raw = fulldata['12PELV0000Y7ACXA'].iloc[:, 0] #%% Animation fig, ax = plt.subplots(figsize=(5, 3)) #ax.set(xlim=(-3, 3), ylim=(-1, 1)) ax.plot(raw, 'k') line = ax.plot(raw, color='b', lw=2)[0] text = ax.text(0.1, 0.1, '0', transform=ax.transAxes) def run_animation(): anim_running = True
""" Created on Mon May 14 16:04:21 2018 @author: tangk """ from PMG.COM.openbook import openHDF5 from PMG.COM import arrange import pandas as pd from PMG.COM.get_props import * import matplotlib.pyplot as plt from PMG.COM.plotfuns import * cutoff = range(1600) directory = 'P:\\Rear Impact\\Data\\' t,fulldata = openHDF5(directory) chdata = arrange.test_ch_from_chdict(fulldata,cutoff) t = t.get_values()[cutoff] def ch_rename(name): return name[0:8] + name[12:15] chdata = chdata.rename(columns=ch_rename) iarv = pd.DataFrame([[60,180,700,73,193,779,87,154,390,73,193,779]],columns=chdata.columns) peaks = arrange.arrange_by_peak(chdata.applymap(peakval)) p_iarv = pd.DataFrame(index=chdata.index,columns=chdata.columns) for f in chdata.index: for ch in chdata.columns: p_iarv.set_value(f,ch,peaks[ch]['+tive'][f]/iarv[ch][0])