def main():
    store = scihdf.SciHDF(conf['data']['rx_dump'], mode='a', complib='zlib')
    store_excite = scihdf.SciHDF(conf['data']['tx_dump'],
                                 mode='a',
                                 complib='zlib')

    fnames = glob(join(conf['data']['raw_dir'], '*.mat'))
    # loop over files containing different temperatures
    for fn in fnames:
        osc, info = _get_info_from_file(fn)

        if osc is None:
            continue

        d = loadmat(fn)['Data']
        act_sig = pd.Series(d[:, 1], index=d[:, 0], dtype=np.float32)

        for i, sig in enumerate(d[:, 2:].T):
            sensor_id = conf['experiment']['sensor_id'][3 * (osc - 1) + i]
            info.modify(sensor=sensor_id)
            print(info)
            sensor_sig = pd.Series(sig, index=d[:, 0], dtype=np.float32)
            store[info] = sensor_sig
            store_excite[info] = act_sig
    store.close()
    store_excite.close()
Example #2
0
"""
from packages import utils, utkit, scihdf
import matplotlib.pyplot as plt
import matplotlib as mpl

plt.style.use('plot_styles.mplstyle')
mpl.rc('figure.subplot',
       left=0.04,
       top=0.94,
       bottom=0.07,
       right=0.99,
       hspace=0.1,
       wspace=0.05)

conf = utils.Configurations()['laser']
store = scihdf.SciHDF(conf['dump'])

my_cmap = mpl.cm.get_cmap('bone')
my_cmap.set_under('w')

xlims, ylims = [60, 140], [20, 80]

fig, axarr = plt.subplots(2, 5, figsize=(7, 2.6), dpi=72)

for i, (ax, info) in enumerate(zip(*(axarr.ravel(), store))):
    print(info)
    scan = utkit.Signal2D(store[info])
    scan = scan.loc[ylims[0]:ylims[1], xlims[0]:xlims[1]]
    scan = scan.operate('n')

    # aspect = np.diff(ylims) / np.diff(xlims)
""" Save the time signal and the feature vectors."""
from packages import utkit, scihdf, utils
from matplotlib import pyplot
from os.path import join
import numpy as np


# pyplot.style.use('plot_styles.mplstyle')
conf = utils.Configurations()['guided_waves']
store = scihdf.SciHDF(conf['data']['rx_dump'])
infos = store.keys_with(sensor='5T', impact=0)

# -- save the windowed signal
s = utkit.Signal(store[infos[0]])
t = np.linspace(100e-6, 137e-6, 50)
s = s(t).window(win_fcn='hann')
np.savetxt('out.txt', s.values)

# -- save the ffts
x, y = [], []
for info in infos:
    s = utkit.Signal(store[info]).window(index1=160e-6, index2=197e-6, win_fcn='hann')
    S = s.fft(ssb=True)
    x.append(S.real(100e3))
    y.append(S.imag(100e3))
x = np.array(x)
y = np.array(y)
ind = x.argsort()
newx = []
for xi in x[ind]:
    newx.append('"' + str(xi))
Example #4
0
    """
    # if fullpath is provided, extract the filename only
    filename = basename(filename)

    impact_energy = float(filename[:4])
    parts = filename.split('_')

    if len(parts) == 2:
        impact_num = 0
    elif len(parts) == 3:
        impact_num = int(parts[1][0]) - 1
    else:
        raise ValueError('The filename provided does not follow required naming convention.')

    impact_idx = conf['guided_waves']['experiment']['impact_energy'].index(impact_energy) + \
                 impact_num
    return scihdf.Info(impact=impact_idx)


# Open the default laser HDF5 storage database
store = scihdf.SciHDF(conf['laser']['dump'], mode='a')
fnames = glob(join(conf['laser']['root_dir'], '*.mat'))

for fname in fnames:
    info = read_form_filename(fname)
    print(info)
    d = loadmat(fname)['Data'][0]
    store[info] = pd.DataFrame(d[2], index=d[1][:, 0], columns=d[0][0, :], dtype=np.float32)

store.close()
        raise ValueError('overlap cannot be larger than width.')
    idx, out = [], []
    while time_ + width <= s1.index[-1]:
        s1_wind = s1.window(index1=time_, index2=time_ + width, win_fcn='hann')
        s2_wind = s2.window(index1=time_, index2=time_ + width, win_fcn='hann')
        c = fftconvolve(s1_wind, s2_wind[::-1]) / np.sqrt(
            np.sum(s1_wind**2) * np.sum(s2_wind**2))
        out.append(np.max(c))
        idx.append(time_ + width / 2)
        time_ += tstep
    return pd.Series(out, index=idx)


conf = utils.Configurations()
featconf = conf['journal_2017']['features']['coherence']
store = scihdf.SciHDF(conf['guided_waves']['data']['rx_dump'])

# get the baseline signals
idx, baseline = [], []
for info in store.keys_with(frequency=featconf['frequency'],
                            actuator=featconf['actuator'],
                            impact=0):
    baseline.append(utkit.Signal(store[info]).loc[featconf['holdoff']:])
    idx.append([info.sensor, info.index])
mux = pd.MultiIndex.from_arrays(list(zip(*idx)), names=['sensor', 'index'])
baseline = pd.DataFrame(baseline, index=mux)
baseline.sort_index(axis=0, inplace=True)

idx, out = [], []
for info in store.keys_with(frequency=featconf['frequency'],
                            actuator=featconf['actuator']):