# -*- coding: utf-8 -*-
"""
Created on Tue Nov  9 16:16:41 2021
Versuch der Auswertung der Daten der Praktikantin Stephanie Kröll (07.2021)

@author: csag4207
"""

import sys
sys.path.append('C:/Users/csag4207/Documents/forschung/python/scripts')
import zwick_extract

from os import listdir
import matplotlib.pyplot as plt
import numpy as np

from PIL import Image

data = {}

raw_data = zwick_extract.extraction('C:/Users/csag4207/Documents/forschung/arbeit/2021/2021.07/T-Peel_Stefanie_CA_Cellophan_01_07_21_T2_4.xls', metadata=True)

metadata = {}
metadata['all'] = raw_data.pop('meta')

# for more than 2 metas joining the dictionaries leads to pop of one meta data
data = {}
k = 0
for i in raw_data:
    data[raw_data[i][0, 0] + '_' + str(k)] = np.array(raw_data[i][3:]).astype('float')
    k = k+1

del raw_data

#%% add a smoothing using a Savitzky-Golay Filter
# from https://scipy.github.io/old-wiki/pages/Cookbook/SavitzkyGolay

def savitzky_golay(y, window_size, order, deriv=0, rate=1):
    r"""Smooth (and optionally differentiate) data with a Savitzky-Golay filter.
    The Savitzky-Golay filter removes high frequency noise from data.
    It has the advantage of preserving the original shape and
    features of the signal better than other types of filtering
    approaches, such as moving averages techniques.
    Parameters
    ----------
    y : array_like, shape (N,)
        the values of the time history of the signal.
    window_size : int
        the length of the window. Must be an odd integer number.
    order : int
        the order of the polynomial used in the filtering.
        Must be less then `window_size` - 1.
    deriv: int
        the order of the derivative to compute (default = 0 means only smoothing)
    Returns
    -------
    ys : ndarray, shape (N)
        the smoothed signal (or it's n-th derivative).
    Notes
    -----
    The Savitzky-Golay is a type of low-pass filter, particularly
    suited for smoothing noisy data. The main idea behind this
    approach is to make for each point a least-square fit with a
    polynomial of high order over a odd-sized window centered at
    the point.
    Examples
    --------
    t = np.linspace(-4, 4, 500)
    y = np.exp( -t**2 ) + np.random.normal(0, 0.05, t.shape)
    ysg = savitzky_golay(y, window_size=31, order=4)
    import matplotlib.pyplot as plt
    plt.plot(t, y, label='Noisy signal')
    plt.plot(t, np.exp(-t**2), 'k', lw=1.5, label='Original signal')
    plt.plot(t, ysg, 'r', label='Filtered signal')
    plt.legend()
    plt.show()
    References
    ----------
    .. [1] A. Savitzky, M. J. E. Golay, Smoothing and Differentiation of
       Data by Simplified Least Squares Procedures. Analytical
       Chemistry, 1964, 36 (8), pp 1627-1639.
    .. [2] Numerical Recipes 3rd Edition: The Art of Scientific Computing
       W.H. Press, S.A. Teukolsky, W.T. Vetterling, B.P. Flannery
       Cambridge University Press ISBN-13: 9780521880688
    """
    import numpy as np
    from math import factorial
    
    try:
        window_size = np.abs(np.int(window_size))
        order = np.abs(np.int(order))
    except ValueError:
        raise ValueError("window_size and order have to be of type int")
    if window_size % 2 != 1 or window_size < 1:
        raise TypeError("window_size size must be a positive odd number")
    if window_size < order + 2:
        raise TypeError("window_size is too small for the polynomials order")
    order_range = range(order+1)
    half_window = (window_size -1) // 2
    # precompute coefficients
    b = np.mat([[k**i for i in order_range] for k in range(-half_window, half_window+1)])
    m = np.linalg.pinv(b).A[deriv] * rate**deriv * factorial(deriv)
    # pad the signal at the extremes with
    # values taken from the signal itself
    firstvals = y[0] - np.abs( y[1:half_window+1][::-1] - y[0] )
    lastvals = y[-1] + np.abs(y[-half_window-1:-1][::-1] - y[-1])
    y = np.concatenate((firstvals, y, lastvals))
    return np.convolve( m[::-1], y, mode='valid')

#%% throw what seems to be out

special = {}

special['0.5pc_Breite_1cm_UL_2cm_V5_falsch_geklebt_7'] = data.pop('0.5pc_Breite_1cm_UL_2cm_V5_falsch_geklebt_7')
special['2.5pc_Breite_1cm_UL_2cm_V3_vorzeitg_Bruch_10'] = data.pop('2.5pc_Breite_1cm_UL_2cm_V3_vorzeitg_Bruch_10')
special['2.5pc_Breite_1cm_UL_2cm_V4_vorzeitiger_Bruch_14'] = data.pop('2.5pc_Breite_1cm_UL_2cm_V4_vorzeitiger_Bruch_14')

#%% throw more that seems to have had problems

special['Cellophan_only_Breite_1cm_Lang_4cm_V2_47'] = data.pop('Cellophan_only_Breite_1cm_Lang_4cm_V2_47')
special['1pc_Breite_1cm_UL_1cm_leicht-schief_44'] = data.pop('1pc_Breite_1cm_UL_1cm_leicht-schief_44')

#no info on NaOH concentration
data.pop('CA_Probe_Breite_2_cm_1cm_UL_1')
data.pop('CA_Probe_Breite_1_cm_V2_1cm_UL_0')
data.pop('CA_Breite_2cm_UL_2cm_0.5pc_V4_P1_2')

listing = []
for i in data: 
    if 'Specimen' in i:
        listing.append(i)

[data.pop(i) for i in listing]

#%% one could cut all minor values below 0.1 N

# plt.figure()
# plt.scatter(data['Cellophan_only_Breite_1cm_Lang_4cm_V3_48'][:,0], data['Cellophan_only_Breite_1cm_Lang_4cm_V3_48'][:,1], label=i)
# plt.show()

#%% only take all data once it is above 0,15 N and then set the distance travelled to 0

for i in data:
    buff = data[i][np.argmin(np.abs(data[i][:,1]-0.15))].reshape((1,2))
    data[i] = data[i][data[i][:,1]>0.15]
    data[i] = np.subtract(data[i], buff)

#%% get an overview of the data and compare with the production method

# Single lap shear test

# Namensgebung wie folgt: a_Breite_xcm_UL_xcm_V?_No#

# a concentration of NaOH solution 2.5pc is 2.5% wt. 
# Breite der Viskosefolie/cellophanabschnitte in x cm
# Ul Überlagert auf einer Länge von x cm (Breite mal Länge entspricht der Klebefläche)
# Konzentration der CA-Lösung derzeit unbekannt (Annahme 10 pc)

# special cases: 
# Ohne CA: no glue, only swollen NaOH foils on each other
# CA only: only condensate from evaporation of acetone
# Cellophan only:

#%% one has to mean over the respective data sets

unique = set(['_'.join(i.split('_')[:5]) for i in data])

unique_cut={}
for i in unique:
    unique_cut[i] = -10

#these values could also be adapted on an individual level later, the first look from the plots below is ok, only for hte 1cm/2cm 1% NaOH seems to be big differences, however cutting the data further on on an individual-run-level
unique_cut['CA_only_Breite_1cm_Länge'] = -25
unique_cut['2.5pc_Breite_1cm_UL_2cm'] = -30
unique_cut['1pc_Breite_1cm_UL_2cm'] = -50
unique_cut['1pc_Breite_1cm_UL_1cm'] = -30
unique_cut['Cellophan_only_Breite_1cm_Lang'] = -25
unique_cut['Viscose_only_Breite_1cm_Lang'] = -20

to_mean={}

for i in unique:
    buff = {}
    # buffed = []
    for j in data:
        if i in j:
            buff[j] = data[j][:unique_cut[i]]
    to_mean[i] = buff
    # buffed = np.vstack(buff)
    # mean_data[i] = buffed[buffed[:,0].argsort()]

# to_mean_smooth={}

# for i in unique:
#     buff = {}
#     # buffed = []
#     for j in data:
#         if i in j:
#             buff[j] = np.hstack((data[j][:unique_cut[i],0].reshape((data[j][:unique_cut[i],0].shape[0], 1)), savitzky_golay(data[j][:unique_cut[i],1], 1201,3).reshape((data[j][:unique_cut[i],1].shape[0], 1))))
#     to_mean_smooth[i] = buff

#%% see how much of the late evolution of a test run can be cut

for i in to_mean:
    plt.figure()
    plt.title(i)
    for j in to_mean[i]:
        plt.scatter(to_mean[i][j][:,0], to_mean[i][j][:,1], label=j)
    plt.legend()
    plt.show()

#%% just try a simple mean before trying np.ma.mean (the simple mean does not seem to work)
# https://stackoverflow.com/questions/10058227/calculating-mean-of-arrays-with-different-lengths
# look for the second solution, which is just an automatisation of the first to fill the masked array
# however the 2-dimensional array has to be cut to a 1-dimensional.
# Assuming that the zwick moves at the same speed over the test and the data recording frequency is constant, each of the different tests should have the same extension travelled at the same time, therefore it is acceptable to neglect minor extension differences and assume all to have the same amount of extension

def tolerant_mean(arrs):
    lens = [len(i) for i in arrs]
    arr = np.ma.empty((np.max(lens), len(arrs)))
    arr.mask = True
    for idx, l in enumerate(arrs):
        arr[:len(l),idx] = l[:,1]
        if len(l) == np.max(lens):
            draw_values = l[:,0]
    return draw_values, arr.mean(axis = -1), arr.std(axis=-1)

mean_data={}

for i in to_mean:
    mean_data[i] = tolerant_mean(to_mean[i].values())
    
# test, test_x, error = tolerant_mean(mean_data['0.5pc_ohne_CA_Breite_1cm'].values())
# ax.plot(np.arange(len(y))+1, y, color='green')


# mean_smooth={}
# for i in to_mean_smooth:
#     mean_smooth[i] = tolerant_mean(to_mean_smooth[i].values())

# smoothed={}

# for i in mean_data:
#     smoothed[i] = savitzky_golay(mean_data[i][1], 1201, 3)

# #%%

# # combine plots where possible

# plt.figure(figsize=(12,8))
# # plt.plot(mean_data['CA_only_Breite_1cm_Länge'][0], mean_data['CA_only_Breite_1cm_Länge'][1], label = 'CA_only_Breite_1cm_Länge')
# plt.plot(mean_data['CA_only_Breite_1cm_Länge'][0], smoothed['CA_only_Breite_1cm_Länge'], label = 'CA_only_Breite_1cm_Länge', color='r', linestyle=':')
# plt.fill_between(mean_data['CA_only_Breite_1cm_Länge'][0], np.subtract(smoothed['CA_only_Breite_1cm_Länge'], mean_data['CA_only_Breite_1cm_Länge'][2]), np.add(smoothed['CA_only_Breite_1cm_Länge'],mean_data['CA_only_Breite_1cm_Länge'][2]),alpha=.4)

# # plt.plot(mean_data['Viscose_only_Breite_1cm_Lang'][0], mean_data['Viscose_only_Breite_1cm_Lang'][1], label = 'Viscose_only_Breite_1cm_Lang', color = 'g')
# plt.plot(mean_data['Viscose_only_Breite_1cm_Lang'][0], smoothed['Viscose_only_Breite_1cm_Lang'], label = 'Viscose_only_Breite_1cm_Lang', color = 'r', linestyle=':')
# plt.fill_between(mean_data['Viscose_only_Breite_1cm_Lang'][0], np.subtract(mean_data['Viscose_only_Breite_1cm_Lang'][1], mean_data['Viscose_only_Breite_1cm_Lang'][2]), np.add(mean_data['Viscose_only_Breite_1cm_Lang'][1],mean_data['Viscose_only_Breite_1cm_Lang'][2]), color = 'g', alpha=.4)


# # plt.plot(mean_data['2.5pc_Breite_1cm_UL_2cm'][0], mean_data['2.5pc_Breite_1cm_UL_2cm'][1], label = '2.5pc_Breite_1cm_UL_2cm')
# plt.plot(mean_data['2.5pc_Breite_1cm_UL_2cm'][0], smoothed['2.5pc_Breite_1cm_UL_2cm'], color='r', linestyle=':', label = '2.5pc_Breite_1cm_UL_2cm')
# plt.fill_between(mean_data['2.5pc_Breite_1cm_UL_2cm'][0], np.subtract(mean_data['2.5pc_Breite_1cm_UL_2cm'][1], mean_data['2.5pc_Breite_1cm_UL_2cm'][2]), np.add(mean_data['2.5pc_Breite_1cm_UL_2cm'][1],mean_data['2.5pc_Breite_1cm_UL_2cm'][2]),alpha=.4)

# plt.legend()
# plt.show()
#%%test the solution with the masked arrays

plt.figure()
plt.plot(mean_data['CA_only_Breite_1cm_Länge'][0], mean_data['CA_only_Breite_1cm_Länge'][1], label = 'CA_only_Breite_1cm_Länge')
plt.fill_between(mean_data['CA_only_Breite_1cm_Länge'][0], np.subtract(mean_data['CA_only_Breite_1cm_Länge'][1], mean_data['CA_only_Breite_1cm_Länge'][2]), np.add(mean_data['CA_only_Breite_1cm_Länge'][1],mean_data['CA_only_Breite_1cm_Länge'][2]),alpha=.2)
plt.show()

#%% change the plot parameter

font = {'family' : 'normal',
        'weight' : 'bold',
        'size'   : 16}

plt.rc('font', **font)

#%%which comparisons are of interest

# NaoH influence (0.5 to 1 to 2.5 pc) 1cm/2m with and without CA
# cellophane/Ca/viskose foil only
# comparison with without CA (0.5, 1 and 2% NaOH)

# combine plots where possible

cmap = plt.get_cmap('tab20')
colors = [cmap(i) for i in np.linspace(0, 0.3, 3)]

plt.figure(figsize=(12,8))
plt.plot(mean_data['CA_only_Breite_1cm_Länge'][0], mean_data['CA_only_Breite_1cm_Länge'][1], color=colors[0], label = 'CA_only_Breite_1cm_Länge')
plt.fill_between(mean_data['CA_only_Breite_1cm_Länge'][0], np.subtract(mean_data['CA_only_Breite_1cm_Länge'][1], mean_data['CA_only_Breite_1cm_Länge'][2]), np.add(mean_data['CA_only_Breite_1cm_Länge'][1],mean_data['CA_only_Breite_1cm_Länge'][2]), color=colors[0], alpha=.4)

plt.plot(mean_data['Viscose_only_Breite_1cm_Lang'][0], mean_data['Viscose_only_Breite_1cm_Lang'][1], color=colors[1], label = 'Viscose_only_Breite_1cm_Lang')
plt.fill_between(mean_data['Viscose_only_Breite_1cm_Lang'][0], np.subtract(mean_data['Viscose_only_Breite_1cm_Lang'][1], mean_data['Viscose_only_Breite_1cm_Lang'][2]), np.add(mean_data['Viscose_only_Breite_1cm_Lang'][1], mean_data['Viscose_only_Breite_1cm_Lang'][2]), color = colors[1], alpha=.4)


plt.plot(mean_data['2.5pc_Breite_1cm_UL_2cm'][0], mean_data['2.5pc_Breite_1cm_UL_2cm'][1], color=colors[2], label = '2.5pc_Breite_1cm_UL_2cm')
plt.fill_between(mean_data['2.5pc_Breite_1cm_UL_2cm'][0], np.subtract(mean_data['2.5pc_Breite_1cm_UL_2cm'][1], mean_data['2.5pc_Breite_1cm_UL_2cm'][2]), np.add(mean_data['2.5pc_Breite_1cm_UL_2cm'][1],mean_data['2.5pc_Breite_1cm_UL_2cm'][2]), color=colors[2], alpha=.4)

# plt.legend()
plt.ylabel('force /N')
plt.xlabel('extension /mm')
plt.ylim([0, 58])
plt.xlim([0, 58])
plt.show()

# plt.savefig('C:/Users/csag4207/Documents/forschung/arbeit/2021/cerdia/pic/ca-visc/composite_stress-strain.png', dpi=500)
# to_save= Image.open('C:/Users/csag4207/Documents/forschung/arbeit/2021/cerdia/pic/ca-visc/composite_stress-strain.png').convert('RGB')
# to_save.save('C:/Users/csag4207/Documents/forschung/arbeit/2021/cerdia/pic/ca-visc/composite_stress-strain.jpg')


#%% 

colors = [cmap(i) for i in np.linspace(0.4, 1, 3)]


selection = ['0.5pc_Breite_1cm_UL_2cm', '1pc_Breite_1cm_UL_2cm', '2.5pc_Breite_1cm_UL_2cm']
selection_2 = ['0.5pc_ohne_CA_Breite_1cm', '1pc_ohne_CA_Breite_1cm', '2.5pc_ohne_CA_Breite_1cm']

sele_0 = [selection[0], selection_2[0]]
sele_1 = [selection[-1], selection_2[-1]]

fig, axs = plt.subplots(nrows=1, ncols=2, figsize=(14,8))

k=0
for i in selection:
    axs[0].plot(mean_data[i][0], mean_data[i][1], color=colors[k], label = i)
    axs[0].fill_between(mean_data[i][0], np.subtract(mean_data[i][1], mean_data[i][2]), np.add(mean_data[i][1],mean_data[i][2]), color=colors[k], alpha=0.3)
    k=k+1

axs[0].set_ylim([0,50])
# axs[0].set_xlim([0,34])
axs[0].set_ylabel('force /N')
axs[0].set_xlabel('extension /mm')
# axs[0].legend()

k=0
for j in selection_2:
    axs[1].plot(mean_data[j][0], mean_data[j][1],  color=colors[k], label = j)
    axs[1].fill_between(mean_data[j][0], np.subtract(mean_data[j][1], mean_data[j][2]), np.add(mean_data[j][1],mean_data[j][2]),color=colors[k], alpha=0.3)
    k=k+1

axs[1].set_ylim([0,50])
# axs[1].set_xlim([0,34])
axs[1].set_xlabel('extension /mm')

plt.show()

# plt.savefig('C:/Users/csag4207/Documents/forschung/arbeit/2021/cerdia/pic/ca-visc/composite_stress-strain_systems.png', dpi=500)
# to_save= Image.open('C:/Users/csag4207/Documents/forschung/arbeit/2021/cerdia/pic/ca-visc/composite_stress-strain_systems.png').convert('RGB')
# to_save.save('C:/Users/csag4207/Documents/forschung/arbeit/2021/cerdia/pic/ca-visc/composite_stress-strain_systems.jpg')

#%% 

selection = ['0.5pc_Breite_1cm_UL_2cm', '1pc_Breite_1cm_UL_2cm', '2.5pc_Breite_1cm_UL_2cm']
selection_2 = ['0.5pc_ohne_CA_Breite_1cm', '1pc_ohne_CA_Breite_1cm', '2.5pc_ohne_CA_Breite_1cm']

sele_0 = [selection[0], selection_2[0]]
sele_2 = [selection[1], selection_2[1]]
sele_1 = [selection[-1], selection_2[-1]]

fig, axs = plt.subplots(nrows=1, ncols=3, figsize=(18,8), sharey=True)

for i in sele_0:
    axs[0].plot(mean_data[i][0], mean_data[i][1], label = i)
    axs[0].fill_between(mean_data[i][0], np.subtract(mean_data[i][1], mean_data[i][2]), np.add(mean_data[i][1],mean_data[i][2]),alpha=.4)

axs[0].legend()

for j in sele_2:
    axs[1].plot(mean_data[j][0], mean_data[j][1], label = j)
    axs[1].fill_between(mean_data[j][0], np.subtract(mean_data[j][1], mean_data[j][2]), np.add(mean_data[j][1],mean_data[j][2]),alpha=.4)

axs[1].legend()


for j in sele_1:
    axs[2].plot(mean_data[j][0], mean_data[j][1], label = j)
    axs[2].fill_between(mean_data[j][0], np.subtract(mean_data[j][1], mean_data[j][2]), np.add(mean_data[j][1],mean_data[j][2]),alpha=.4)

axs[2].legend()

plt.show()

#%% see the difference between 1 and 2cm of glueing

plt.figure()

plt.plot(mean_data['1pc_Breite_1cm_UL_1cm'][0], mean_data['1pc_Breite_1cm_UL_1cm'][1], label = '1pc_Breite_1cm_UL_1cm')
plt.fill_between(mean_data['1pc_Breite_1cm_UL_1cm'][0], np.subtract(mean_data['1pc_Breite_1cm_UL_1cm'][1], mean_data['1pc_Breite_1cm_UL_1cm'][2]), np.add(mean_data['1pc_Breite_1cm_UL_1cm'][1],mean_data['1pc_Breite_1cm_UL_1cm'][2]),alpha=.4)

plt.plot(mean_data['1pc_Breite_1cm_UL_2cm'][0], mean_data['1pc_Breite_1cm_UL_2cm'][1], label = '1pc_Breite_1cm_UL_2cm', color = 'r')
plt.fill_between(mean_data['1pc_Breite_1cm_UL_2cm'][0], np.subtract(mean_data['1pc_Breite_1cm_UL_2cm'][1], mean_data['1pc_Breite_1cm_UL_2cm'][2]), np.add(mean_data['1pc_Breite_1cm_UL_2cm'][1],mean_data['1pc_Breite_1cm_UL_2cm'][2]), color = 'r', alpha=.4)

plt.legend()
plt.show()


#%% savitzky golay (leave for now, as the representation above ist quite fine)

def savitzky_golay(y, window_size, order, deriv=0, rate=1):
    r"""Smooth (and optionally differentiate) data with a Savitzky-Golay filter.
    The Savitzky-Golay filter removes high frequency noise from data.
    It has the advantage of preserving the original shape and
    features of the signal better than other types of filtering
    approaches, such as moving averages techniques.
    Parameters
    ----------
    y : array_like, shape (N,)
        the values of the time history of the signal.
    window_size : int
        the length of the window. Must be an odd integer number.
    order : int
        the order of the polynomial used in the filtering.
        Must be less then `window_size` - 1.
    deriv: int
        the order of the derivative to compute (default = 0 means only smoothing)
    Returns
    -------
    ys : ndarray, shape (N)
        the smoothed signal (or it's n-th derivative).
    Notes
    -----
    The Savitzky-Golay is a type of low-pass filter, particularly
    suited for smoothing noisy data. The main idea behind this
    approach is to make for each point a least-square fit with a
    polynomial of high order over a odd-sized window centered at
    the point.
    Examples
    --------
    t = np.linspace(-4, 4, 500)
    y = np.exp( -t**2 ) + np.random.normal(0, 0.05, t.shape)
    ysg = savitzky_golay(y, window_size=31, order=4)
    import matplotlib.pyplot as plt
    plt.plot(t, y, label='Noisy signal')
    plt.plot(t, np.exp(-t**2), 'k', lw=1.5, label='Original signal')
    plt.plot(t, ysg, 'r', label='Filtered signal')
    plt.legend()
    plt.show()
    References
    ----------
    .. [1] A. Savitzky, M. J. E. Golay, Smoothing and Differentiation of
       Data by Simplified Least Squares Procedures. Analytical
       Chemistry, 1964, 36 (8), pp 1627-1639.
    .. [2] Numerical Recipes 3rd Edition: The Art of Scientific Computing
       W.H. Press, S.A. Teukolsky, W.T. Vetterling, B.P. Flannery
       Cambridge University Press ISBN-13: 9780521880688
    """
    import numpy as np
    from math import factorial
    
    try:
        window_size = np.abs(np.int(window_size))
        order = np.abs(np.int(order))
    except ValueError:
        raise ValueError("window_size and order have to be of type int")
    if window_size % 2 != 1 or window_size < 1:
        raise TypeError("window_size size must be a positive odd number")
    if window_size < order + 2:
        raise TypeError("window_size is too small for the polynomials order")
    order_range = range(order+1)
    half_window = (window_size -1) // 2
    # precompute coefficients
    b = np.mat([[k**i for i in order_range] for k in range(-half_window, half_window+1)])
    m = np.linalg.pinv(b).A[deriv] * rate**deriv * factorial(deriv)
    # pad the signal at the extremes with
    # values taken from the signal itself
    firstvals = y[0] - np.abs( y[1:half_window+1][::-1] - y[0] )
    lastvals = y[-1] + np.abs(y[-half_window-1:-1][::-1] - y[-1])
    y = np.concatenate((firstvals, y, lastvals))
    return np.convolve( m[::-1], y, mode='valid')

# #%% show on a plot

# # yhat = savitzky_golay(y, 51, 3)

# plt.figure()
# plt.scatter(mean_data['2.5pc_Breite_1cm_UL_2cm'][0][:1200], mean_data['2.5pc_Breite_1cm_UL_2cm'][1][:1200], label='2.5pc_Breite_1cm_UL_2cm')
# plt.scatter(mean_data['2.5pc_Breite_1cm_UL_2cm'][0], savitzky_golay(mean_data['2.5pc_Breite_1cm_UL_2cm'][1], 51, 6), label='2.5pc_Breite_1cm_UL_2cm')

# plt.legend()
# plt.show()
