Ejemplo n.º 1
0
import pandas as pd
import numpy as np
from matplotlib import pyplot
from os.path import join
import matplotlib as mp
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler
from concurrent import futures
import itertools

# setup the classifier hyperparameters
window_size = 30
zeta = 0.8
n_mc = 1000  # number of monte-carlo simulations

conf = utils.Configurations()
store = pd.read_excel(join(conf['data_root'], 'gw_features_complexamp.xlsx'),
                      index_col=(0, 1, 2), squeeze=True).applymap(complex)


def get_signals(sensor, impact):
    s = store.loc[pd.IndexSlice[sensor, impact, :], :]
    s.index = s.index.droplevel(['impact', 'sensor'])
    rpart = utkit.Signal2D(np.real(s), index=s.index, columns=s.columns)
    ipart = utkit.Signal2D(np.imag(s), index=s.index, columns=s.columns)
    return rpart, ipart


def main(args):
    sensor, impact = args
    print(sensor, impact)
Ejemplo n.º 2
0
Plot the images of the laser scans
"""
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')
"""
Saves the guided wave data which has been varied with temperature.
"""
import numpy as np
from packages import utils, scihdf
from glob import glob
from os.path import join, basename
from scipy.io import loadmat
import pandas as pd

conf = utils.Configurations()['guided_waves']


def _get_info_from_file(filename):
    """
    Extracts measurement information for a given guided wave measurement file from its filename.
    Parameters
    ----------
    filename : str
        Filename of the guided wave measurement.
    """
    # if fullpath is provided, extract the filename only
    filename = basename(filename)

    osc = int(filename[3])

    ind = filename.lower().find('khz')
    frequency = int(filename[5:ind])
    actuator = filename[ind + 3:ind + 5]

    impact_energy = float(filename[ind + 5:ind + 9])
"""
computes the subtraction of each feature from the baseline (no impact) data. That is, for each
sensor, subtract the values at impact 0 for all the other values at all impacts.

Note: Very slow, can be significantly improved...
"""
from packages import utils
import pandas as pd

conf = utils.Configurations()['journal_2017']['features']['complex_amp']

feat = pd.read_excel(conf['dump'], index_col=(0, 1, 2))
feat = feat.applymap(complex)
baseline = feat.loc[pd.IndexSlice[:, 0, :], :]

mux = pd.MultiIndex(levels=[[], [], [], []],
                    labels=[[], [], [], []],
                    names=['sensor', 'impact', 'baseline_index', 'index'])

out = pd.DataFrame(0, index=mux, columns=feat.columns)

for (sensor, _, baseline_index), b in baseline.iterrows():
    print('Sensor:', sensor, 'Baseline index:', baseline_index)
    for (_, impact,
         index), s in feat.loc[pd.IndexSlice[sensor, :, :], :].iterrows():
        out.loc[pd.IndexSlice[sensor, impact, baseline_index, index]] = s - b

# write to excel sheet
out.sort_index(axis=0, inplace=True)
writer = pd.ExcelWriter(conf['dump_baselined'])
out.astype(str).to_excel(writer)