{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "import sklearn\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "def calulate_density(travel):\n",
    "    return 2710/(6293-travel)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "def filter_data(df):\n",
    "    # filter data\n",
    "    df['P.Zeit'] = pd.to_timedelta(df['P.Zeit'])\n",
    "\n",
    "    df=df[df['Pyrometer'] >460].copy()\n",
    "    df=df[df['AV Force'] > 55].copy()\n",
    "\n",
    "    minPistonTravel = df['Abs. Piston Trav'].min()\n",
    "    df['TravelRelative'] = ((df['Abs. Piston Trav'] - minPistonTravel)*1000).astype(int)\n",
    "    df['TravelRelativeCorrected'] = np.maximum.accumulate(df['TravelRelative'])\n",
    "    minTemperature = df['Pyrometer'].min()\n",
    "    df['TravelRelativeCorrected'] = df['TravelRelativeCorrected'].rolling(window=10).mean()\n",
    "    df.loc[pd.isnull(df['TravelRelativeCorrected']), 'TravelRelativeCorrected'] =  0\n",
    "    df['TravelRelativeTempCorrected']=df['TravelRelativeCorrected']+(df['Pyrometer']-minTemperature)*1.241\n",
    "    #df['TravelRelativeCorrected'] = df['TravelRelativeCorrected'].ewm(span=10, adjust=False).mean()\n",
    "    df.loc[pd.isnull(df['TravelRelativeCorrected']), 'TravelRelativeCorrected'] =  0\n",
    "\n",
    "    #df['TravelDelta'] = df['TravelDelta'].rolling(window=60).mean()\n",
    "    #df.loc[pd.isnull(df['TravelDelta']), 'TravelDelta'] =  0\n",
    "\n",
    "    #df.loc[(df['TravelDelta']<0), 'TravelDelta'] =  0\n",
    "    #df['TravelDelta'] = df['TravelDelta'].astype(int)\n",
    "    df['TravelDeltaOriginal'] = df['Abs. Piston Trav'] - df['Abs. Piston Trav'].shift(1)\n",
    "    #df = df.drop(columns=['Abs. Piston Trav'])\n",
    "    \n",
    "    df['seconds'] = df['P.Zeit'].dt.total_seconds()\n",
    "    df['seconds'] = df['seconds'].astype(int)\n",
    "    minSeconds = df['seconds'].min()\n",
    "    df['seconds'] = (df['seconds'] - minSeconds+1)\n",
    "    df = df.drop(columns=['P.Zeit'])\n",
    "    \n",
    "    df['Heating'] = (df['Heating power']*10).astype(int)\n",
    "    df = df.drop(columns=['Heating power'])\n",
    "    \n",
    "    df = df.iloc[::10]\n",
    "\n",
    "    df['TravelDelta'] = df['TravelRelativeTempCorrected'] - df['TravelRelativeTempCorrected'].shift(1)\n",
    "    df['TravelDelta2'] = df['TravelRelativeCorrected'] - df['TravelRelativeCorrected'].shift(1)\n",
    "    df.loc[pd.isnull(df['TravelDelta']), 'TravelDelta'] =  0\n",
    "\n",
    "    df['TravelRelativeCorrectedShifted'] = df['TravelRelativeCorrected'].shift(-1)\n",
    "    df['TravelRelativeCorrectedShifted'] = df['TravelRelativeCorrectedShifted'].fillna(0)\n",
    "    df['TravelRelativeTempCorrectedShifted'] = df['TravelRelativeTempCorrected'].shift(-1)\n",
    "    #df['TravelRelativeTempCorrectedShifted'] = df['TravelRelativeTempCorrectedShifted'].fillna(df['TravelRelativeTempCorrectedShifted'].iloc[-2])\n",
    "    df['PyrometerShifted'] = df['Pyrometer'].shift(-1)\n",
    "    df['Density'] =  calulate_density(df['TravelRelativeTempCorrected'])\n",
    "    #df['PyrometerShifted'] = df['PyrometerShifted'].fillna(df['PyrometerShifted'].iloc[-2])\n",
    "\n",
    "    df = df.drop(df.index[-1])\n",
    "\n",
    "    return df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "def filter_dataEmpty(df):\n",
    "    # filter data\n",
    "    df['seconds'] = df['No.']\n",
    "    df = df.drop(columns=['No.'])\n",
    "    df['Pyrometer'] = df['AV Pyro top']\n",
    "    df = df.drop(columns=['AV Pyro top'])\n",
    "\n",
    "    df=df[df['Pyrometer'] >460].copy()\n",
    "    df=df[df['AV Force'] >15].copy()\n",
    "\n",
    "    minPistonTravel = df['AV Abs. Piston T'].min()\n",
    "    df['TravelRelative'] = ((df['AV Abs. Piston T'] - minPistonTravel)*1000).astype(int)\n",
    "    # maxPistonTravel = df['TravelRelative'].max()\n",
    "    # df['TravelRelative'] = -(df['TravelRelative']-maxPistonTravel)\n",
    "    #df['TravelRelativeCorrected'] = np.maximum.accumulate(df['TravelRelative'])\n",
    "    df['TravelRelativeCorrected'] = df['TravelRelative']\n",
    "    df['TravelRelativeCorrected'] = df['TravelRelativeCorrected'].rolling(window=60).mean()\n",
    "    #df['TravelRelativeCorrected'] = df['TravelRelativeCorrected'].ewm(span=10, adjust=False).mean()\n",
    "    df['TravelDelta'] = df['TravelRelativeCorrected'] - df['TravelRelativeCorrected'].shift(1)\n",
    "    df.loc[pd.isnull(df['TravelDelta']), 'TravelDelta'] =  0\n",
    "\n",
    "    #df['TravelDelta'] = df['TravelDelta'].rolling(window=60).mean()\n",
    "    #df.loc[pd.isnull(df['TravelDelta']), 'TravelDelta'] =  0\n",
    "\n",
    "    #df.loc[(df['TravelDelta']<0), 'TravelDelta'] =  0\n",
    "    #df['TravelDelta'] = df['TravelDelta'].astype(int)\n",
    "    df = df.drop(columns=['AV Abs. Piston T'])\n",
    "    \n",
    "    \n",
    "    df['Heating'] = (df['AV Heating Power']*10).astype(int)\n",
    "    df = df.drop(columns=['AV Heating Power'])\n",
    "    \n",
    "\n",
    "\n",
    "\n",
    "    return df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "data1000 = pd.read_csv('data/160508-1021-1000,0min,56kN.csv',sep = ';', skiprows=[1],decimal=',',\n",
    "                    usecols=['P.Zeit','MTC1','MTC2','Pyrometer','AV Abs. Press. 2','yPower','AV Force','AV Speed','I RMS','Pulse Time','Pause Time','U RMS','Heating power','Rel. Piston Trav','Abs. Piston Trav']) \n",
    "                   # usecols=['P.Zeit','Pyrometer','AV Force','Heating power','Abs. Piston Trav']) \n",
    "                    #usecols=['P.Zeit','Pyrometer','Heating power','Abs. Piston Trav']) \n",
    "data900 = pd.read_csv('data/160508-1022-900,0min,56kN.csv',sep = ';', skiprows=[1],decimal=',',\n",
    "                    usecols=['P.Zeit','MTC1','MTC2','Pyrometer','AV Abs. Press. 2','yPower','AV Force','AV Speed','I RMS','Pulse Time','Pause Time','U RMS','Heating power','Rel. Piston Trav','Abs. Piston Trav']) \n",
    "data1350 = pd.read_csv('data/200508-1023-1350,0min,56kN.csv',sep = ';', skiprows=[1],decimal=',',\n",
    "                    usecols=['P.Zeit','MTC1','MTC2','Pyrometer','AV Abs. Press. 2','yPower','AV Force','AV Speed','I RMS','Pulse Time','Pause Time','U RMS','Heating power','Rel. Piston Trav','Abs. Piston Trav']) \n",
    "data1200 = pd.read_csv('data/200508-1024-1200,0min,56kN.csv',sep = ';', skiprows=[1],decimal=',',\n",
    "                    usecols=['P.Zeit','MTC1','MTC2','Pyrometer','AV Abs. Press. 2','yPower','AV Force','AV Speed','I RMS','Pulse Time','Pause Time','U RMS','Heating power','Rel. Piston Trav','Abs. Piston Trav']) \n",
    "dataN1200 = pd.read_csv('data/050608-1037-1200,0min,70kN.csv',sep = ';', skiprows=[1],decimal=',',\n",
    "                    usecols=['P.Zeit','MTC1','MTC2','Pyrometer','AV Abs. Press. 2','yPower','AV Force','AV Speed','I RMS','Pulse Time','Pause Time','U RMS','Heating power','Rel. Piston Trav','Abs. Piston Trav']) \n",
    "dataN1100 = pd.read_csv('data/290508-1033-1100,0min,70kN.csv',sep = ';', skiprows=[1],decimal=',',\n",
    "                    usecols=['P.Zeit','MTC1','MTC2','Pyrometer','AV Abs. Press. 2','yPower','AV Force','AV Speed','I RMS','Pulse Time','Pause Time','U RMS','Heating power','Rel. Piston Trav','Abs. Piston Trav']) \n",
    "dataEmpty1= pd.read_csv('data/fct20-082 graphite 4f 1800 (100) 16kN 5 min d20.csv',sep = ';', skiprows=[1],decimal=',',\n",
    "                    usecols=['No.','AV Pyro top','AV Force','AV Abs. Piston T','AV Heating Power','U RMS','I RMS']) \n",
    "dataEmpty2= pd.read_csv('data/fct20-083 graphite for fct20-075 1800 (100) 16kN 5 min d20.csv',sep = ';', skiprows=[1],decimal=',',\n",
    "                    usecols=['No.','AV Pyro top','AV Force','AV Abs. Piston T','AV Heating Power','U RMS','I RMS']) \n",
    "\n",
    "data1000 = filter_data(data1000)\n",
    "data900 = filter_data(data900)\n",
    "data1350 = filter_data(data1350)\n",
    "data1200 = filter_data(data1200)\n",
    "dataN1200 = filter_data(dataN1200)\n",
    "dataN1100 = filter_data(dataN1100)\n",
    "\n",
    "dataN1200['TravelRelativeTempCorrected'] = dataN1200['TravelRelativeTempCorrected']/2\n",
    "dataN1200['TravelRelativeTempCorrectedShifted'] = dataN1200['TravelRelativeTempCorrectedShifted']/2\n",
    "#dataN1200['TravelRelativeTempCorrected'] = dataN1200['TravelRelativeTempCorrected']/2\n",
    "#dataN1200['TravelRelativeTempCorrectedShifted'] = dataN1200['TravelRelativeTempCorrectedShifted']/2\n",
    "\n",
    "dataEmpty1 = filter_dataEmpty(dataEmpty1)\n",
    "dataEmpty2 = filter_dataEmpty(dataEmpty2)\n",
    "\n",
    "\n",
    "\n",
    "#dataEmpty1.describe()\n",
    "#dataN1200.dtypes\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>MTC1</th>\n",
       "      <th>MTC2</th>\n",
       "      <th>Pyrometer</th>\n",
       "      <th>AV Abs. Press. 2</th>\n",
       "      <th>yPower</th>\n",
       "      <th>AV Force</th>\n",
       "      <th>AV Speed</th>\n",
       "      <th>I RMS</th>\n",
       "      <th>Pulse Time</th>\n",
       "      <th>Pause Time</th>\n",
       "      <th>...</th>\n",
       "      <th>TravelRelativeTempCorrected</th>\n",
       "      <th>TravelDeltaOriginal</th>\n",
       "      <th>seconds</th>\n",
       "      <th>Heating</th>\n",
       "      <th>TravelDelta</th>\n",
       "      <th>TravelDelta2</th>\n",
       "      <th>TravelRelativeCorrectedShifted</th>\n",
       "      <th>TravelRelativeTempCorrectedShifted</th>\n",
       "      <th>PyrometerShifted</th>\n",
       "      <th>Density</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>432</th>\n",
       "      <td>104</td>\n",
       "      <td>84</td>\n",
       "      <td>462</td>\n",
       "      <td>853</td>\n",
       "      <td>30</td>\n",
       "      <td>56</td>\n",
       "      <td>0.03</td>\n",
       "      <td>1.47</td>\n",
       "      <td>20.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>68</td>\n",
       "      <td>0.000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>9.0</td>\n",
       "      <td>23.892</td>\n",
       "      <td>474.0</td>\n",
       "      <td>0.430637</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>442</th>\n",
       "      <td>108</td>\n",
       "      <td>86</td>\n",
       "      <td>474</td>\n",
       "      <td>965</td>\n",
       "      <td>29</td>\n",
       "      <td>56</td>\n",
       "      <td>0.10</td>\n",
       "      <td>1.39</td>\n",
       "      <td>20.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>...</td>\n",
       "      <td>23.892</td>\n",
       "      <td>0.00</td>\n",
       "      <td>11</td>\n",
       "      <td>63</td>\n",
       "      <td>23.892</td>\n",
       "      <td>9.0</td>\n",
       "      <td>17.8</td>\n",
       "      <td>43.861</td>\n",
       "      <td>483.0</td>\n",
       "      <td>0.432278</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>452</th>\n",
       "      <td>111</td>\n",
       "      <td>87</td>\n",
       "      <td>483</td>\n",
       "      <td>957</td>\n",
       "      <td>29</td>\n",
       "      <td>56</td>\n",
       "      <td>0.08</td>\n",
       "      <td>1.43</td>\n",
       "      <td>20.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>...</td>\n",
       "      <td>43.861</td>\n",
       "      <td>0.00</td>\n",
       "      <td>21</td>\n",
       "      <td>64</td>\n",
       "      <td>19.969</td>\n",
       "      <td>8.8</td>\n",
       "      <td>28.9</td>\n",
       "      <td>64.889</td>\n",
       "      <td>491.0</td>\n",
       "      <td>0.433660</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>462</th>\n",
       "      <td>114</td>\n",
       "      <td>89</td>\n",
       "      <td>491</td>\n",
       "      <td>968</td>\n",
       "      <td>28</td>\n",
       "      <td>57</td>\n",
       "      <td>0.09</td>\n",
       "      <td>1.38</td>\n",
       "      <td>20.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>...</td>\n",
       "      <td>64.889</td>\n",
       "      <td>0.01</td>\n",
       "      <td>31</td>\n",
       "      <td>62</td>\n",
       "      <td>21.028</td>\n",
       "      <td>11.1</td>\n",
       "      <td>44.0</td>\n",
       "      <td>89.917</td>\n",
       "      <td>499.0</td>\n",
       "      <td>0.435124</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>472</th>\n",
       "      <td>116</td>\n",
       "      <td>90</td>\n",
       "      <td>499</td>\n",
       "      <td>984</td>\n",
       "      <td>29</td>\n",
       "      <td>56</td>\n",
       "      <td>0.11</td>\n",
       "      <td>1.41</td>\n",
       "      <td>20.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>...</td>\n",
       "      <td>89.917</td>\n",
       "      <td>0.00</td>\n",
       "      <td>41</td>\n",
       "      <td>63</td>\n",
       "      <td>25.028</td>\n",
       "      <td>15.1</td>\n",
       "      <td>63.9</td>\n",
       "      <td>118.504</td>\n",
       "      <td>506.0</td>\n",
       "      <td>0.436880</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1195</th>\n",
       "      <td>329</td>\n",
       "      <td>238</td>\n",
       "      <td>1065</td>\n",
       "      <td>1006</td>\n",
       "      <td>70</td>\n",
       "      <td>56</td>\n",
       "      <td>0.44</td>\n",
       "      <td>3.91</td>\n",
       "      <td>20.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>...</td>\n",
       "      <td>3873.823</td>\n",
       "      <td>0.01</td>\n",
       "      <td>764</td>\n",
       "      <td>249</td>\n",
       "      <td>116.093</td>\n",
       "      <td>25.5</td>\n",
       "      <td>3286.6</td>\n",
       "      <td>4195.012</td>\n",
       "      <td>1194.0</td>\n",
       "      <td>1.120216</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1207</th>\n",
       "      <td>348</td>\n",
       "      <td>253</td>\n",
       "      <td>1194</td>\n",
       "      <td>1005</td>\n",
       "      <td>0</td>\n",
       "      <td>56</td>\n",
       "      <td>2.64</td>\n",
       "      <td>0.07</td>\n",
       "      <td>20.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>...</td>\n",
       "      <td>4195.012</td>\n",
       "      <td>0.04</td>\n",
       "      <td>776</td>\n",
       "      <td>0</td>\n",
       "      <td>321.189</td>\n",
       "      <td>161.1</td>\n",
       "      <td>3667.4</td>\n",
       "      <td>4615.524</td>\n",
       "      <td>1226.0</td>\n",
       "      <td>1.291714</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1217</th>\n",
       "      <td>357</td>\n",
       "      <td>261</td>\n",
       "      <td>1226</td>\n",
       "      <td>1007</td>\n",
       "      <td>0</td>\n",
       "      <td>56</td>\n",
       "      <td>1.75</td>\n",
       "      <td>0.04</td>\n",
       "      <td>20.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>...</td>\n",
       "      <td>4615.524</td>\n",
       "      <td>0.03</td>\n",
       "      <td>786</td>\n",
       "      <td>0</td>\n",
       "      <td>420.512</td>\n",
       "      <td>380.8</td>\n",
       "      <td>3908.5</td>\n",
       "      <td>4950.940</td>\n",
       "      <td>1302.0</td>\n",
       "      <td>1.615522</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1227</th>\n",
       "      <td>358</td>\n",
       "      <td>263</td>\n",
       "      <td>1302</td>\n",
       "      <td>1002</td>\n",
       "      <td>0</td>\n",
       "      <td>56</td>\n",
       "      <td>1.09</td>\n",
       "      <td>0.04</td>\n",
       "      <td>20.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>...</td>\n",
       "      <td>4950.940</td>\n",
       "      <td>0.02</td>\n",
       "      <td>796</td>\n",
       "      <td>0</td>\n",
       "      <td>335.416</td>\n",
       "      <td>241.1</td>\n",
       "      <td>4065.5</td>\n",
       "      <td>5151.375</td>\n",
       "      <td>1337.0</td>\n",
       "      <td>2.019284</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1237</th>\n",
       "      <td>355</td>\n",
       "      <td>262</td>\n",
       "      <td>1337</td>\n",
       "      <td>1001</td>\n",
       "      <td>0</td>\n",
       "      <td>56</td>\n",
       "      <td>0.73</td>\n",
       "      <td>0.03</td>\n",
       "      <td>20.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>...</td>\n",
       "      <td>5151.375</td>\n",
       "      <td>0.01</td>\n",
       "      <td>806</td>\n",
       "      <td>0</td>\n",
       "      <td>200.435</td>\n",
       "      <td>157.0</td>\n",
       "      <td>4185.6</td>\n",
       "      <td>5282.644</td>\n",
       "      <td>1346.0</td>\n",
       "      <td>2.373809</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>78 rows × 25 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      MTC1  MTC2  Pyrometer  AV Abs. Press. 2  yPower  AV Force  AV Speed  \\\n",
       "432    104    84        462               853      30        56      0.03   \n",
       "442    108    86        474               965      29        56      0.10   \n",
       "452    111    87        483               957      29        56      0.08   \n",
       "462    114    89        491               968      28        57      0.09   \n",
       "472    116    90        499               984      29        56      0.11   \n",
       "...    ...   ...        ...               ...     ...       ...       ...   \n",
       "1195   329   238       1065              1006      70        56      0.44   \n",
       "1207   348   253       1194              1005       0        56      2.64   \n",
       "1217   357   261       1226              1007       0        56      1.75   \n",
       "1227   358   263       1302              1002       0        56      1.09   \n",
       "1237   355   262       1337              1001       0        56      0.73   \n",
       "\n",
       "      I RMS  Pulse Time  Pause Time  ...  TravelRelativeTempCorrected  \\\n",
       "432    1.47        20.0         5.0  ...                        0.000   \n",
       "442    1.39        20.0         5.0  ...                       23.892   \n",
       "452    1.43        20.0         5.0  ...                       43.861   \n",
       "462    1.38        20.0         5.0  ...                       64.889   \n",
       "472    1.41        20.0         5.0  ...                       89.917   \n",
       "...     ...         ...         ...  ...                          ...   \n",
       "1195   3.91        20.0         5.0  ...                     3873.823   \n",
       "1207   0.07        20.0         5.0  ...                     4195.012   \n",
       "1217   0.04        20.0         5.0  ...                     4615.524   \n",
       "1227   0.04        20.0         5.0  ...                     4950.940   \n",
       "1237   0.03        20.0         5.0  ...                     5151.375   \n",
       "\n",
       "      TravelDeltaOriginal  seconds  Heating  TravelDelta  TravelDelta2  \\\n",
       "432                   NaN        1       68        0.000           NaN   \n",
       "442                  0.00       11       63       23.892           9.0   \n",
       "452                  0.00       21       64       19.969           8.8   \n",
       "462                  0.01       31       62       21.028          11.1   \n",
       "472                  0.00       41       63       25.028          15.1   \n",
       "...                   ...      ...      ...          ...           ...   \n",
       "1195                 0.01      764      249      116.093          25.5   \n",
       "1207                 0.04      776        0      321.189         161.1   \n",
       "1217                 0.03      786        0      420.512         380.8   \n",
       "1227                 0.02      796        0      335.416         241.1   \n",
       "1237                 0.01      806        0      200.435         157.0   \n",
       "\n",
       "      TravelRelativeCorrectedShifted  TravelRelativeTempCorrectedShifted  \\\n",
       "432                              9.0                              23.892   \n",
       "442                             17.8                              43.861   \n",
       "452                             28.9                              64.889   \n",
       "462                             44.0                              89.917   \n",
       "472                             63.9                             118.504   \n",
       "...                              ...                                 ...   \n",
       "1195                          3286.6                            4195.012   \n",
       "1207                          3667.4                            4615.524   \n",
       "1217                          3908.5                            4950.940   \n",
       "1227                          4065.5                            5151.375   \n",
       "1237                          4185.6                            5282.644   \n",
       "\n",
       "      PyrometerShifted   Density  \n",
       "432              474.0  0.430637  \n",
       "442              483.0  0.432278  \n",
       "452              491.0  0.433660  \n",
       "462              499.0  0.435124  \n",
       "472              506.0  0.436880  \n",
       "...                ...       ...  \n",
       "1195            1194.0  1.120216  \n",
       "1207            1226.0  1.291714  \n",
       "1217            1302.0  1.615522  \n",
       "1227            1337.0  2.019284  \n",
       "1237            1346.0  2.373809  \n",
       "\n",
       "[78 rows x 25 columns]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\n",
    "#dataEmpty1.describe()\n",
    "selectedData=dataEmpty2[dataEmpty2['Pyrometer'] >1200].copy()\n",
    "selectedData=selectedData[selectedData['Pyrometer'] <1210].copy()\n",
    "dataN1100.head(10000)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Figure size 1000x600 with 0 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 84728 characters]",
      "text/plain": [
       "<Figure size 1000x600 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(10, 6))\n",
    "fig, ax1 = plt.subplots( figsize=(10, 6))\n",
    "ax1.plot(dataEmpty1['Pyrometer'], dataEmpty1['TravelRelative'], color='orange') \n",
    "ax1.plot(dataEmpty2['Pyrometer'], dataEmpty2['TravelRelative'], color='red') \n",
    "\n",
    "minTemperature = data1000['Pyrometer'].min()\n",
    "data1000['TravelRelative2']=data1000['TravelRelative']+(data1000['Pyrometer']-minTemperature)*1.241\n",
    "sc = ax1.plot(data1000['Pyrometer'], data1000['TravelRelative'], color='green') \n",
    "sc = ax1.plot(data1000['Pyrometer'], data1000['TravelRelative2'], color='blue') \n",
    "\n",
    "\n",
    "#minTemperature = data1200['Pyrometer'].min()\n",
    "#data1200['TravelRelative2']=data1200['TravelRelative']+(data1200['Pyrometer']-minTemperature)*1.241\n",
    "#sc = ax1.plot(data1200['Pyrometer'], data1200['TravelRelative'], color='green') \n",
    "#sc = ax1.plot(data1200['Pyrometer'], data1200['TravelRelative2'], color='blue') \n",
    "\n",
    "#sc = plt.scatter(setToPlot['seconds'], setToPlot['Pyrometer'],color='red')  \n",
    "#sc = plt.scatter(setToPlot['seconds'], setToPlot['Heating'], color='green') \n",
    "# Add color bar to show the color scale\n",
    "ax1.set_ylabel('Хід поршня, μм')\n",
    "#ax1.set_ylim(400, 1000)\n",
    "#ax1.set_xlim(300, 1400)\n",
    "ax1.set_title('Спікання без порошку, визначення коєфіцієнта термічного розширення')\n",
    "ax1.set_xlabel('Температура, °C')\n",
    "ax1.grid(True)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Figure size 4000x600 with 0 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 54612 characters]",
      "text/plain": [
       "<Figure size 2000x600 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(40, 6))\n",
    "fig, ax1 = plt.subplots( figsize=(20, 6))\n",
    "#sc = ax1.plot(data900['seconds'], data900['Pyrometer'], color='red') \n",
    "#sc = ax1.plot(data1000['seconds'], data1000['Pyrometer'], color='red') \n",
    "#sc = ax1.plot(data1000['seconds'], data1000['Density'], color='green')\n",
    "#sc = ax1.plot(data1200['seconds'], data1200['Density'], color='red')\n",
    "#sc = ax1.plot(data1000['Density'], data1000['TravelDelta'], color='green')\n",
    "#sc = ax1.plot(data900['Density'], data900['TravelDelta'], color='black')\n",
    "sc = ax1.plot(data1200['Density'], data1200['TravelDelta'], color='red')\n",
    "#sc = ax1.plot(data1000['seconds'], data1000['TravelRelativeTempCorrected'], color='blue') \n",
    "#sc = ax1.plot(data1200['seconds'], data1200['Pyrometer'], color='green') \n",
    "#sc = ax1.plot(data1350['seconds'], data1350['Pyrometer'], color='black') \n",
    "#sc = ax1.plot(dataN1200['seconds'], dataN1200['Pyrometer'], color='purple') \n",
    "#sc = ax1.plot(dataN1100['seconds'], dataN1100['Pyrometer'], color='orange') \n",
    "#sc = plt.scatter(setToPlot['seconds'], setToPlot['Pyrometer'],color='red')  \n",
    "#sc = plt.scatter(setToPlot['seconds'], setToPlot['Heating'], color='green') \n",
    "# Add color bar to show the color scale\n",
    "ax1.set_ylabel('Швидкість ущільнення')\n",
    "#ax1.set_ylim(400, 1000)\n",
    "#ax1.set_xlim(300, 1400)\n",
    "#ax1.set_title('title')\n",
    "ax1.set_xlabel('Відносна щільність')\n",
    "ax1.grid(True)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Figure size 4000x600 with 0 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 185780 characters]",
      "text/plain": [
       "<Figure size 4000x600 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(40, 6))\n",
    "fig, ax1 = plt.subplots( figsize=(40, 6))\n",
    "sc = ax1.plot(data900['seconds'], data900['AV Force'], color='red') \n",
    "sc = ax1.plot(data1000['seconds'], data1000['AV Force'], color='blue') \n",
    "sc = ax1.plot(data1200['seconds'], data1200['AV Force'], color='green') \n",
    "sc = ax1.plot(data1350['seconds'], data1350['AV Force'], color='black') \n",
    "sc = ax1.plot(dataN1200['seconds'], dataN1200['AV Force'], color='purple') \n",
    "sc = ax1.plot(dataN1100['seconds'], dataN1100['AV Force'], color='orange') \n",
    "#sc = plt.scatter(setToPlot['seconds'], setToPlot['Pyrometer'],color='red')  \n",
    "#sc = plt.scatter(setToPlot['seconds'], setToPlot['Heating'], color='green') \n",
    "# Add color bar to show the color scale\n",
    "ax1.set_ylabel('AV Force')\n",
    "#ax1.set_ylim(400, 1000)\n",
    "#ax1.set_xlim(300, 1400)\n",
    "ax1.set_title('title')\n",
    "ax1.set_xlabel('seconds')\n",
    "ax1.grid(True)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Figure size 2000x600 with 0 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 96528 characters]",
      "text/plain": [
       "<Figure size 3000x600 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "\n",
    "plt.figure(figsize=(20, 6))\n",
    "fig, ax1 = plt.subplots( figsize=(30, 6))\n",
    "#sc = ax1.plot(data900['seconds'], data900['TravelDelta'], color='red')  \n",
    "#sc = ax1.plot(data1000['seconds'], data1000['TravelDelta'], color='green') \n",
    "sc = ax1.plot(data1200['seconds'], data1200['TravelDeltaOriginal']*1000, color='gray') \n",
    "sc = ax1.plot(data1200['seconds'], data1200['TravelDelta2'], color='red') \n",
    "\n",
    "##sc = ax1.plot(data1200['seconds'], data1200['TravelDelta'], color='green') \n",
    "#sc = ax1.plot(dataN1200['seconds'], dataN1200['TravelDelta'], color='purple') \n",
    "#sc = ax1.plot(dataN1100['seconds'], dataN1100['TravelDelta'], color='orange') \n",
    "#sc = ax1.plot(data1350['seconds'], data1350['TravelDelta'], color='black') \n",
    "#sc = plt.scatter(setToPlot['seconds'], setToPlot['Pyrometer'],color='red')  \n",
    "#sc = plt.scatter(setToPlot['seconds'], setToPlot['Heating'], color='green') \n",
    "# Add color bar to show the color scale\n",
    "ax1.set_ylabel('Швидкість ходу поршня, μm/с')\n",
    "#ax1.set_ylim(400, 1000)\n",
    "#ax1.set_xlim(300, 1400)\n",
    "ax1.set_title('Швидкість ходу поршня до і після усереднення')\n",
    "ax1.set_xlabel('час, с')\n",
    "ax1.grid(True)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "def plot_data_Travel(data, title):\n",
    "    setToPlot = data.copy()\n",
    "    #setToPlot = setToPlot[(setToPlot['seconds'] > 0) & (setToPlot['seconds'] <650)].copy()\n",
    "    #setToPlot = setToPlot[(setToPlot['Heating'] > 0)].copy()\n",
    "\n",
    "    #setToPlot = setToPlot[(setToPlot['Pyrometer'] < 900)].copy()\n",
    "    #setToPlot = setToPlot[(setToPlot['seconds'] < 850)].copy()\n",
    "    plt.figure(figsize=(40, 6))\n",
    "    fig, ax1 = plt.subplots( figsize=(40, 6))\n",
    "    sc2 = ax1.plot(setToPlot['seconds'], setToPlot['TravelRelative'], color='red')\n",
    "    sc2 = ax1.plot(setToPlot['seconds'], setToPlot['TravelRelative'], color='red')\n",
    "    TravelDeltaOriginal\n",
    "    #sc2 = ax1.plot(setToPlot['seconds'], setToPlot['TravelRelativeCorrected'], color='green')\n",
    "    #sc2 = ax1.plot(setToPlot['seconds'], setToPlot['TravelRelativeCorrectedShifted'], color='blue')\n",
    "    sc2 = ax1.plot(setToPlot['seconds'], setToPlot['TravelRelativeTempCorrected'], color='orange')\n",
    "\n",
    "    \n",
    "    ax1.set_ylabel('TrevelRelative')\n",
    "    #ax1.set_ylim(0, 800)\n",
    "    #ax1.set_ylim(0, 4000)\n",
    "    ax1.set_title(title)\n",
    "    ax1.set_xlabel('seconds')\n",
    "    ax1.grid(True)\n",
    "    plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'TravelDeltaOriginal' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[31m---------------------------------------------------------------------------\u001b[39m",
      "\u001b[31mNameError\u001b[39m                                 Traceback (most recent call last)",
      "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[13]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m \u001b[43mplot_data_Travel\u001b[49m\u001b[43m(\u001b[49m\u001b[43mdata900\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[33;43m'\u001b[39;49m\u001b[33;43m900\u001b[39;49m\u001b[33;43m'\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[32m      2\u001b[39m plot_data_Travel(data1000, \u001b[33m'\u001b[39m\u001b[33m1000\u001b[39m\u001b[33m'\u001b[39m)\n\u001b[32m      3\u001b[39m plot_data_Travel(data1200, \u001b[33m'\u001b[39m\u001b[33m1200\u001b[39m\u001b[33m'\u001b[39m)\n",
      "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[12]\u001b[39m\u001b[32m, line 12\u001b[39m, in \u001b[36mplot_data_Travel\u001b[39m\u001b[34m(data, title)\u001b[39m\n\u001b[32m     10\u001b[39m sc2 = ax1.plot(setToPlot[\u001b[33m'\u001b[39m\u001b[33mseconds\u001b[39m\u001b[33m'\u001b[39m], setToPlot[\u001b[33m'\u001b[39m\u001b[33mTravelRelative\u001b[39m\u001b[33m'\u001b[39m], color=\u001b[33m'\u001b[39m\u001b[33mred\u001b[39m\u001b[33m'\u001b[39m)\n\u001b[32m     11\u001b[39m sc2 = ax1.plot(setToPlot[\u001b[33m'\u001b[39m\u001b[33mseconds\u001b[39m\u001b[33m'\u001b[39m], setToPlot[\u001b[33m'\u001b[39m\u001b[33mTravelRelative\u001b[39m\u001b[33m'\u001b[39m], color=\u001b[33m'\u001b[39m\u001b[33mred\u001b[39m\u001b[33m'\u001b[39m)\n\u001b[32m---> \u001b[39m\u001b[32m12\u001b[39m \u001b[43mTravelDeltaOriginal\u001b[49m\n\u001b[32m     13\u001b[39m \u001b[38;5;66;03m#sc2 = ax1.plot(setToPlot['seconds'], setToPlot['TravelRelativeCorrected'], color='green')\u001b[39;00m\n\u001b[32m     14\u001b[39m \u001b[38;5;66;03m#sc2 = ax1.plot(setToPlot['seconds'], setToPlot['TravelRelativeCorrectedShifted'], color='blue')\u001b[39;00m\n\u001b[32m     15\u001b[39m sc2 = ax1.plot(setToPlot[\u001b[33m'\u001b[39m\u001b[33mseconds\u001b[39m\u001b[33m'\u001b[39m], setToPlot[\u001b[33m'\u001b[39m\u001b[33mTravelRelativeTempCorrected\u001b[39m\u001b[33m'\u001b[39m], color=\u001b[33m'\u001b[39m\u001b[33morange\u001b[39m\u001b[33m'\u001b[39m)\n",
      "\u001b[31mNameError\u001b[39m: name 'TravelDeltaOriginal' is not defined"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<Figure size 4000x600 with 0 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 40840 characters]",
      "text/plain": [
       "<Figure size 4000x600 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plot_data_Travel(data900, '900')\n",
    "plot_data_Travel(data1000, '1000')\n",
    "plot_data_Travel(data1200, '1200')\n",
    "plot_data_Travel(dataN1200, 'N1200')\n",
    "#plot_data_Travel(dataN1100, 'N1100')\n",
    "#plot_data_Travel(data1350, '1350')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def plot_data_TravelDelta(data, title):\n",
    "    setToPlot = data.copy()\n",
    "    #setToPlot = setToPlot[(setToPlot['seconds'] > 0) & (setToPlot['seconds'] <650)].copy()\n",
    "    #setToPlot = setToPlot[(setToPlot['Heating'] > 0)].copy()\n",
    "\n",
    "    #setToPlot = setToPlot[(setToPlot['Pyrometer'] < 900)].copy()\n",
    "    #setToPlot = setToPlot[(setToPlot['seconds'] < 850)].copy()\n",
    "\n",
    "    # setToPlot['Heating'] = (setToPlot['Heating']*10).astype(int)\n",
    "    plt.figure(figsize=(40, 6))\n",
    "    fig, ax1 = plt.subplots( figsize=(40, 6))\n",
    "    sc = ax1.plot(setToPlot['Pyrometer'], setToPlot['TravelDelta'], color='red')  \n",
    "    #sc = ax1.plot(setToPlot['seconds'], setToPlot['TravelRelativeTempCorrectedShifted'], color='red')  \n",
    "    #sc = ax1.plot(setToPlot['seconds'], setToPlot['TravelDelta'], color='green')  \n",
    "    #sc = ax1.plot(setToPlot['Pyrometer'], setToPlot['AV Force']*10, color='blue')  \n",
    "    # sc = ax1.plot(setToPlot['seconds'], setToPlot['Heating']) \n",
    "    #sc = plt.scatter(setToPlot['seconds'], setToPlot['Pyrometer'],color='red')  \n",
    "    #sc = plt.scatter(setToPlot['seconds'], setToPlot['Heating'], color='green') \n",
    "    # ax2 = ax1.twinx()\n",
    "    # sc2 = ax2.plot(setToPlot['seconds'], setToPlot['TravelDelta'], color='green')\n",
    "    # Add color bar to show the color scale\n",
    "    # ax2.set_ylim(0, 10)\n",
    "    # ax2.set_ylabel('TravelDelta')\n",
    "    ax1.set_ylabel('seconds, TravelDelta')\n",
    "    # ax1.set_ylim(400, 1000)\n",
    "    # ax1.set_xlim(300, 1400)\n",
    "    # ax2.set_xlim(300, 1400)\n",
    "    ax1.set_title(title)\n",
    "    ax1.set_xlabel('seconds')\n",
    "    ax1.grid(True)\n",
    "    plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "setToPlot = data1000\n",
    "#setToPlot = setToPlot[(setToPlot['seconds'] > 550) & (setToPlot['seconds'] <650)].copy()\n",
    " \n",
    "\n",
    "plt.figure(figsize=(40, 6))\n",
    "#sc = plt.scatter(setToPlot['seconds'], setToPlot['TravelDelta'], c=setToPlot['Pyrometer'], cmap='viridis')  \n",
    "sc = plt.plot(setToPlot['seconds'], setToPlot['TravelDelta'])  \n",
    "\n",
    "# Add color bar to show the color scale\n",
    "#plt.colorbar(sc, label='Temperature')\n",
    "#plt.title('-')\n",
    "plt.xlabel('seconds')\n",
    "plt.ylabel('TravelDelta')\n",
    "plt.grid(True)\n",
    "plt.show()\n",
    "\n",
    "#setToPlot.head(50)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "plot_data_TravelDelta(data900, '900')\n",
    "plot_data_TravelDelta(data1000, '1000')\n",
    "plot_data_TravelDelta(data1200, '1200')\n",
    "plot_data_TravelDelta(dataN1200, 'N1200')\n",
    "plot_data_TravelDelta(data1350, '1350')\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import seaborn as sns\n",
    "#data1000.corr()\n",
    "selected_columns = ['Pyrometer', '', 'column3']\n",
    "new_df = data1000[selected_columns].copy()\n",
    "corr_matrix = new_df.corr()\n",
    "\n",
    "# Побудова теплової карти\n",
    "sns.heatmap(corr_matrix, annot=True, cmap='coolwarm', fmt=\".2f\")\n",
    "plt.title(\"Кореляційна матриця\")\n",
    "plt.show()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.gaussian_process import GaussianProcessRegressor\n",
    "from sklearn.gaussian_process.kernels import RBF, Matern, RationalQuadratic, ExpSineSquared, DotProduct, ConstantKernel as C\n",
    "from sklearn.model_selection import train_test_split\n",
    "from sklearn.metrics import mean_squared_error\n",
    "\n",
    "\n",
    "# Select the relevant columns\n",
    "X = pd.concat( [data900,data1000,data1200], axis=0)\n",
    "y = pd.concat( [data900,data1000,data1200], axis=0)\n",
    "\n",
    "X = X[['seconds','Heating', 'Pyrometer', 'AV Force']]\n",
    "y = y['TravelRelativeCorrected']\n",
    "\n",
    "\n",
    "# Split the data into training and testing sets\n",
    "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)\n",
    "\n",
    "# Define the kernel for the GPR model\n",
    "kernels = [\n",
    "    C(1.0, (1e-4, 1e1)) * RBF(length_scale=1.0),\n",
    "    C(1.0, (1e-4, 1e1)) * Matern(length_scale=1.0, nu=1.5),\n",
    "    C(1.0, (1e-4, 1e1)) * RationalQuadratic(length_scale=1.0, alpha=0.1),\n",
    "    C(1.0, (1e-4, 1e1)) * ExpSineSquared(length_scale=1.0, periodicity=3.0),\n",
    "    C(1.0, (1e-4, 1e1)) * DotProduct(sigma_0=1.0)\n",
    "]\n",
    "kernel = kernels[0]\n",
    "\n",
    "# Create and train the GPR model\n",
    "gpr = GaussianProcessRegressor(kernel=kernel, n_restarts_optimizer=10, alpha=1e-2)\n",
    "gpr.fit(X_train, y_train)\n",
    "\n",
    "# Make predictions\n",
    "y_pred = gpr.predict(X_test)\n",
    "\n",
    "# Evaluate the model\n",
    "mse = mean_squared_error(y_test, y_pred)\n",
    "print(f'Mean Squared Error: {mse}')\n",
    "\n",
    "# Print the kernel parameters\n",
    "print(f'Kernel parameters: {gpr.kernel_}')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.gaussian_process import GaussianProcessRegressor\n",
    "from sklearn.gaussian_process.kernels import RBF, Matern, RationalQuadratic, ExpSineSquared, DotProduct, ConstantKernel as C\n",
    "from sklearn.model_selection import train_test_split\n",
    "from sklearn.metrics import mean_squared_error\n",
    "\n",
    "# data1000 \n",
    "# data900 \n",
    "# data1350 -- bad data\n",
    "# data1200 \n",
    "# dataN1200 -- Different rate?\n",
    "# dataN1100 -- bad data?\n",
    "\n",
    "# data1000 = data1000.sort_values(by=['seconds'])\n",
    "# data900 = data900.sort_values(by=['seconds'])\n",
    "# data1200 = data1200.sort_values(by=['seconds'])\n",
    "# data1350 = data1350.sort_values(by=['seconds'])\n",
    "# dataN1200 = dataN1200.sort_values(by=['seconds'])\n",
    "# dataN1100 = dataN1100.sort_values(by=['seconds'])\n",
    "\n",
    "# Select the relevant columns\n",
    "#D = pd.concat( [data900, data1000, data1200, data1350,dataN1200,dataN1100], axis=0)\n",
    "D = pd.concat( [data900, data1000, data1200,dataN1200], axis=0)\n",
    "#D = pd.concat( [data900, data1000,dataN1200], axis=0)\n",
    "#D = pd.concat( [data900, data1000, data1200], axis=0)\n",
    "\n",
    "#TravelRelativeCorrectedShifted\n",
    "\n",
    "#X_train = X[['seconds','Heating', 'Pyrometer', 'AV Force']]\n",
    "X_train = D[['seconds','TravelRelativeTempCorrected', 'Pyrometer','PyrometerShifted']]\n",
    "#X_train = X[['seconds','Heating', 'Pyrometer']]\n",
    "y_train = D['TravelRelativeTempCorrectedShifted']\n",
    "\n",
    " # Define the kernel for the GPR model\n",
    "kernels = [\n",
    "    C(1.0, (1e-4, 1e9)) * RBF(length_scale=1.0),\n",
    "    C(1.0, (1e-4, 1e9)) * Matern(length_scale=1.0, nu=1.5),\n",
    "    C(1.0, (1e-4, 1e9)) * RationalQuadratic(length_scale=1.0, alpha=0.1),\n",
    "    C(1.0, (1e-4, 1e9)) * ExpSineSquared(length_scale=1.0, periodicity=3.0),\n",
    "    C(1.0, (1e-4, 1e9)) * DotProduct(sigma_0=1.0)\n",
    "]\n",
    "kernel = kernels[4]\n",
    "\n",
    "# Create and train the GPR model\n",
    "gpr = GaussianProcessRegressor(kernel=kernel, n_restarts_optimizer=100, alpha=1e-3)\n",
    "gpr.fit(X_train, y_train)\n",
    "\n",
    "# Make predictions\n",
    "\n",
    "#X_test = data1000[['seconds','Heating', 'Pyrometer', 'AV Force']]\n",
    "X_test = dataN1200[['seconds','TravelRelativeTempCorrected', 'Pyrometer','PyrometerShifted']]\n",
    "#X_test = data1000[['seconds','Heating', 'Pyrometer']]\n",
    "y_test = dataN1200['TravelRelativeTempCorrectedShifted']\n",
    "\n",
    "y_pred = gpr.predict(X_test)\n",
    "\n",
    "\n",
    "# Evaluate the model\n",
    "mse = mean_squared_error(y_test, y_pred)\n",
    "print(f'Mean Squared Error: {mse}')\n",
    "\n",
    "# Print the kernel parameters\n",
    "print(f'Kernel parameters: {gpr.kernel_}')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "plt.figure(figsize=(15, 6))\n",
    "fig, ax1 = plt.subplots( figsize=(15, 6))\n",
    "\n",
    "sc = ax1.plot(data1200['seconds'], data1200['TravelRelativeTempCorrectedShifted'], color='grey') \n",
    "#sc = ax1.plot(data1350['seconds'], data1350['TravelRelativeTempCorrectedShifted'], color='grey') \n",
    "#sc = ax1.plot(data1000['seconds'], data1000['TravelRelativeTempCorrectedShifted'], color='grey') \n",
    "sc = ax1.plot(data900['seconds'], data900['TravelRelativeTempCorrectedShifted'], color='grey') \n",
    "sc = ax1.plot(dataN1200['seconds'], dataN1200['TravelRelativeTempCorrectedShifted'], color='green') \n",
    "sc = ax1.plot(data1000['seconds'], data1000['TravelRelativeTempCorrectedShifted'], color='grey') \n",
    "sc = ax1.plot(X_test['seconds'], y_pred, color='red') \n",
    "#sc = plt.scatter(setToPlot['seconds'], setToPlot['Pyrometer'],color='red')  \n",
    "#sc = plt.scatter(setToPlot['seconds'], setToPlot['Heating'], color='green') \n",
    "# Add color bar to show the color scale\n",
    "#ax1.set_ylabel('Pyrometer, Heating')\n",
    "#ax1.set_ylim(400, 1000)\n",
    "#ax1.set_xlim(300, 1400)\n",
    "ax1.set_title('Поріваняння передбаченого моделлю ходу поршня з реальними даними')\n",
    "ax1.set_xlabel('час, с')\n",
    "ax1.set_ylabel('хід поршня, μм')\n",
    "ax1.grid(True)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "PredictionSet = data1000.head(1)\n",
    "PredictionSet = PredictionSet[['seconds','TravelRelativeTempCorrected', 'Pyrometer','PyrometerShifted']]\n",
    "PredictionSet = PredictionSet.reset_index(drop=True)\n",
    "time = PredictionSet['seconds'].iloc[0]\n",
    "\n",
    "newRegime = PredictionSet.copy()\n",
    "\n",
    "heating = 1\n",
    "\n",
    "print(PredictionSet)\n",
    "while time < 4000 and ( heating == 1 or PredictionSet['PyrometerShifted'].iloc[0] > 1000) :\n",
    "     TravelRelativeTempCorrectedPredicted = gpr.predict(PredictionSet, return_std=True); \n",
    "     #print(TravelRelativeTempCorrectedPredicted[0][0])\n",
    "     if PredictionSet['PyrometerShifted'].iloc[0] > 1200:\n",
    "           heating = 0\n",
    "     time = time + 10\n",
    "     PredictionSet.loc[0,'seconds'] = time\n",
    "     PredictionSet.loc[0,'TravelRelativeTempCorrected'] = TravelRelativeTempCorrectedPredicted[0][0]\n",
    "     PredictionSet.loc[0,'Pyrometer'] = PredictionSet['PyrometerShifted'].iloc[0]\n",
    "     if heating:\n",
    "          PredictionSet.loc[0,'PyrometerShifted'] = PredictionSet['PyrometerShifted'].iloc[0] + 8\n",
    "     else:\n",
    "          PredictionSet.loc[0,'PyrometerShifted'] = PredictionSet['PyrometerShifted'].iloc[0] -30\n",
    "     #print(PredictionSet)\n",
    "     newRegime = pd.concat([newRegime, PredictionSet], ignore_index=True)\n",
    "     newRegime.at[newRegime.index[-1],'STD'] = TravelRelativeTempCorrectedPredicted[1][0]\n",
    "#newRegime.head(100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def calulate_TargetDensificationRateValue(value):\n",
    "    if value < 0.40:\n",
    "        return 1\n",
    "    elif 0.40 <= value < 0.70:\n",
    "        # Лінійне зростання від 0 до 110\n",
    "        return ((value - 0.40) / (0.70 - 0.40) * 110)+1\n",
    "\n",
    "    elif 0.70 <= value < 0.85:\n",
    "        return 50\n",
    "    elif 0.85 <= value < 0.97:\n",
    "        # Лінійне зменшення від 50 до 0\n",
    "        return (0.97 - value) / (0.97 - 0.85) * 50\n",
    "    else:\n",
    "        return 0\n",
    "\n",
    "def calulate_TargetDensificationRate(column):\n",
    "    result = []\n",
    "    for value in column:\n",
    "        result.append(calulate_TargetDensificationRateValue(value))\n",
    "    return pd.Series(result, index=column.index)\n",
    "\n",
    "def find_closest_index(column, target_value):\n",
    "    squared_diff = (column - target_value) ** 2\n",
    "    return squared_diff.idxmin()\n",
    "\n",
    "#calulate_TargetDensificationRate(0.45)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "\n",
    "PredictionSet = data1000.head(1)\n",
    "PredictionSet = PredictionSet[['seconds','TravelRelativeTempCorrected', 'Pyrometer','PyrometerShifted']]\n",
    "PredictionSet = PredictionSet.reset_index(drop=True)\n",
    "time = PredictionSet['seconds'].iloc[0]\n",
    "numberOfOptions = 60\n",
    "newRegime = PredictionSet.copy()\n",
    "for i in range(0, numberOfOptions):\n",
    "     PredictionSet = pd.concat([newRegime]*numberOfOptions, ignore_index=True)\n",
    "heating = 1\n",
    "#print(newRegime)\n",
    "\n",
    "density=0\n",
    "time = time + 10\n",
    "for i in range(0, numberOfOptions):\n",
    "     PredictionSet.loc[i,'seconds'] = time\n",
    "     PredictionSet.loc[i,'PyrometerShifted'] = PredictionSet['PyrometerShifted'].iloc[i] + i-5\n",
    "\n",
    "#print(PredictionSet)\n",
    "while time < 1000 and (density<0.96 ) :\n",
    "     \n",
    "     TravelRelativeTempCorrectedPredicted = gpr.predict(PredictionSet, return_std=True); \n",
    "     #print(TravelRelativeTempCorrectedPredicted[0][0])\n",
    "     #select best prediction\n",
    "     \n",
    "     densificationRate = ( TravelRelativeTempCorrectedPredicted[0]-PredictionSet['TravelRelativeTempCorrected'])/10/1000\n",
    "     density = calulate_density(PredictionSet['TravelRelativeTempCorrected'].iloc[0])\n",
    "     targetRate = calulate_TargetDensificationRateValue(density)\n",
    "     predictedRates = pd.Series(TravelRelativeTempCorrectedPredicted[0]-PredictionSet.loc[0,'TravelRelativeTempCorrected'])\n",
    "     #print(predictedRates)\n",
    "     bestIndex = find_closest_index(predictedRates, targetRate)\n",
    "     #print(targetRate)\n",
    "     #print(bestIndex)\n",
    "     time = time + 10\n",
    "     for i in range(0, numberOfOptions):\n",
    "          PredictionSet.loc[i,'seconds'] = time\n",
    "          PredictionSet.loc[i,'TravelRelativeTempCorrected'] = TravelRelativeTempCorrectedPredicted[0][bestIndex]\n",
    "          PredictionSet.loc[i,'Pyrometer'] = PredictionSet['PyrometerShifted'].iloc[bestIndex]\n",
    "          if heating:\n",
    "               PredictionSet.loc[i,'PyrometerShifted'] = PredictionSet['PyrometerShifted'].iloc[bestIndex] + i-20\n",
    "          else:\n",
    "               PredictionSet.loc[i,'PyrometerShifted'] = PredictionSet['PyrometerShifted'].iloc[bestIndex] -30\n",
    "     #print(PredictionSet)\n",
    "     bestPrediction = PredictionSet.iloc[bestIndex]\n",
    "     bestPrediction = pd.DataFrame([bestPrediction])\n",
    "     #print(bestPrediction)\n",
    "     newRegime = pd.concat([newRegime, bestPrediction], ignore_index=True)\n",
    "     #print(newRegime)\n",
    "     newRegime.at[newRegime.index[-1],'STD'] = TravelRelativeTempCorrectedPredicted[1][bestIndex]\n",
    "newRegime.head(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "plt.figure(figsize=(15, 6))\n",
    "fig, ax1 = plt.subplots( figsize=(15, 6))\n",
    "#heating rate\n",
    "sc = ax1.plot(data1200['seconds'], data1200['PyrometerShifted'] - data1200['Pyrometer'], color='gray') \n",
    "sc = ax1.plot(data900['seconds'], data900['PyrometerShifted'] - data900['Pyrometer'], color='gray') \n",
    "sc = ax1.plot(data1000['seconds'], data1000['PyrometerShifted'] - data1000['Pyrometer'], color='gray') \n",
    "sc = ax1.plot(dataN1200['seconds'], dataN1200['PyrometerShifted'] - dataN1200['Pyrometer'], color='gray') \n",
    "sc = ax1.plot(newRegime['seconds'], newRegime['PyrometerShifted'] - newRegime['Pyrometer'], color='red') \n",
    "ax1.set_title('Швидкість нагріву в віртуальному експерименті в порівнянні з реальним даними')\n",
    "ax1.set_xlabel('час в секундах')\n",
    "ax1.set_ylabel('Швидкість °C/c')\n",
    "ax1.set_ylim(-20, 40 )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "plt.figure(figsize=(15, 6))\n",
    "fig, ax1 = plt.subplots( figsize=(15, 6))\n",
    "\n",
    "#densification rate\n",
    "sc = ax1.plot( calulate_density(data1200['TravelRelativeTempCorrected']), data1200['TravelRelativeTempCorrected'] - data1200['TravelRelativeTempCorrected'].shift(1), color='grey')\n",
    "sc = ax1.plot( calulate_density(data1000['TravelRelativeTempCorrected']), data1000['TravelRelativeTempCorrected'] - data1000['TravelRelativeTempCorrected'].shift(1), color='grey')\n",
    "sc = ax1.plot( calulate_density(data900['TravelRelativeTempCorrected']), data900['TravelRelativeTempCorrected'] - data900['TravelRelativeTempCorrected'].shift(1), color='grey')\n",
    "sc = ax1.plot( calulate_density(dataN1200['TravelRelativeTempCorrected']), dataN1200['TravelRelativeTempCorrected'] - dataN1200['TravelRelativeTempCorrected'].shift(1), color='grey')\n",
    "sc = ax1.plot( calulate_density(newRegime['TravelRelativeTempCorrected']), newRegime['TravelRelativeTempCorrected'] - newRegime['TravelRelativeTempCorrected'].shift(1), color='red')\n",
    "sc = ax1.plot( calulate_density(newRegime['TravelRelativeTempCorrected']), calulate_TargetDensificationRate(calulate_density(newRegime['TravelRelativeTempCorrected'])), color='green')\n",
    "\n",
    "\n",
    "mse = ((newRegime['TravelRelativeTempCorrected'] - newRegime['TravelRelativeTempCorrected'].shift(1) - calulate_TargetDensificationRate(calulate_density(newRegime['TravelRelativeTempCorrected']))) ** 2).mean()\n",
    "rmse = mse ** 0.5\n",
    "print(f'RMSE: {rmse}')\n",
    "meanValue = calulate_TargetDensificationRate(calulate_density(newRegime['TravelRelativeTempCorrected'])).mean()\n",
    "\n",
    "\n",
    "difAbs = ((newRegime['TravelRelativeTempCorrected'] - newRegime['TravelRelativeTempCorrected'].shift(1) - calulate_TargetDensificationRate(calulate_density(newRegime['TravelRelativeTempCorrected']))) ** 2)** 0.5\n",
    "difInPercent = (difAbs / calulate_TargetDensificationRate(calulate_density(newRegime['TravelRelativeTempCorrected']))) * 100\n",
    "print(f'RMSE in percent: {difInPercent.mean()}%')\n",
    "# sc = ax1.plot(data1000['seconds'], data1000['TravelRelativeTempCorrected'], color='grey') \n",
    "# sc = ax1.plot(newRegime['seconds'], newRegime['TravelRelativeTempCorrected'], color='green') \n",
    "#sc = ax1.plot(newRegime['seconds'], newRegime['STD'], color='green') \n",
    "\n",
    "#densification rate\n",
    "#sc = ax1.plot(data1200['seconds'], data1200['TravelRelativeTempCorrectedShifted']-data1200['TravelRelativeTempCorrected'], color='grey') \n",
    "#sc = ax1.plot(data1000['seconds'], data1000['TravelRelativeTempCorrectedShifted']-data1000['TravelRelativeTempCorrected'], color='grey') \n",
    "#sc = ax1.plot(newRegime['seconds'], newRegime['TravelRelativeTempCorrected'] - newRegime['TravelRelativeTempCorrected'].shift(1), color='green') \n",
    "\n",
    "\n",
    "#sc = ax1.plot(data1200['seconds'], data1200['PyrometerShifted'] - data1200['Pyrometer'].shift(1), color='orange') \n",
    "#sc = ax1.plot(data1350['seconds'], data1350['TravelRelativeTempCorrectedShifted'], color='grey') \n",
    "#sc = ax1.plot(data900['seconds'], data900['TravelRelativeTempCorrectedShifted']-data900['TravelRelativeTempCorrected'], color='grey') \n",
    "#sc = ax1.plot(dataN1200['seconds'], dataN1200['TravelRelativeTempCorrectedShifted']-dataN1200['TravelRelativeTempCorrected'], color='grey') \n",
    "#sc = ax1.plot(dataN1100['seconds'], dataN1100['TravelRelativeTempCorrectedShifted'], color='grey') \n",
    "#sc = ax1.plot(data1000['seconds'], data1000['TravelRelativeTempCorrectedShifted']-data1000['TravelRelativeTempCorrected'], color='grey') \n",
    "#sc = ax1.plot(newRegime['seconds'], newRegime['PyrometerShifted'] - newRegime['Pyrometer'].shift(1), color='red') \n",
    "# df['TravelDelta'] = df['TravelRelativeTempCorrected'] - df['TravelRelativeTempCorrected'].shift(1)\n",
    " \n",
    "\n",
    "#ax1.set_title('title')\n",
    "ax1.set_xlabel('Щільність')\n",
    "ax1.set_ylabel('Швидкість ущільнення')\n",
    "ax1.grid(True)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "plt.figure(figsize=(15, 6))\n",
    "fig, ax1 = plt.subplots( figsize=(15, 6))\n",
    "\n",
    "#Temperature\n",
    "sc = ax1.plot(data1200['seconds'], data1200['Pyrometer'], color='grey')\n",
    "sc = ax1.plot(data1000['seconds'], data1000['Pyrometer'], color='grey')\n",
    "sc = ax1.plot(data900['seconds'], data900['Pyrometer'], color='grey')\n",
    "sc = ax1.plot(dataN1200['seconds'], dataN1200['Pyrometer'], color='grey')\n",
    "sc = ax1.plot(newRegime['seconds'], newRegime['Pyrometer'], color='red')\n",
    "\n",
    "ax1.set_title('Порівняння температури з єксперементальними даними')\n",
    "ax1.set_xlabel('Час, с')\n",
    "ax1.set_ylabel('Температура °C')\n",
    "ax1.grid(True)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "plt.figure(figsize=(15, 6))\n",
    "fig, ax1 = plt.subplots( figsize=(15, 6))\n",
    "\n",
    "sc = ax1.plot(data1200['seconds'], data1200['TravelRelativeTempCorrectedShifted'], color='grey') \n",
    "#sc = ax1.plot(data1350['seconds'], data1350['TravelRelativeTempCorrectedShifted'], color='grey') \n",
    "sc = ax1.plot(data1000['seconds'], data1000['TravelRelativeTempCorrectedShifted'], color='grey') \n",
    "sc = ax1.plot(data900['seconds'], data900['TravelRelativeTempCorrectedShifted'], color='grey') \n",
    "sc = ax1.plot(dataN1200['seconds'], dataN1200['TravelRelativeTempCorrectedShifted'], color='grey') \n",
    "#sc = ax1.plot(dataN1100['seconds'], dataN1100['TravelRelativeTempCorrectedShifted'], color='grey') \n",
    "sc = ax1.plot(data1000['seconds'], data1000['TravelRelativeTempCorrectedShifted'], color='grey') \n",
    "sc = ax1.plot(newRegime['seconds'], newRegime['TravelRelativeTempCorrected'], color='red') \n",
    " \n",
    "ax1.set_title('Порівняння ходу поршня з єкспериментальними даними')\n",
    "ax1.set_xlabel('час, с')\n",
    "ax1.set_ylabel('хід поршня, μм')\n",
    "ax1.grid(True)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "plt.figure(figsize=(40, 6))\n",
    "fig, ax1 = plt.subplots( figsize=(40, 6))\n",
    "\n",
    "sc = ax1.plot(data1200['TravelRelativeTempCorrectedShifted'], data1200['Pyrometer'], color='grey') \n",
    "#sc = ax1.plot(data1350['Pyrometer'], data1350['Pyrometer'], color='grey') \n",
    "sc = ax1.plot(data1000['TravelRelativeTempCorrectedShifted'], data1000['Pyrometer'], color='grey') \n",
    "sc = ax1.plot(data900['TravelRelativeTempCorrectedShifted'], data900['Pyrometer'], color='grey') \n",
    "sc = ax1.plot(dataN1200['TravelRelativeTempCorrectedShifted'], dataN1200['Pyrometer'], color='grey') \n",
    "sc = ax1.plot(data1000['TravelRelativeTempCorrectedShifted'], data1000['Pyrometer'], color='grey') \n",
    "sc = ax1.plot(newRegime['TravelRelativeTempCorrected'], newRegime['Pyrometer'], color='red') \n",
    " \n",
    "\n",
    "ax1.set_title('title')\n",
    "ax1.set_xlabel('Microns')\n",
    "ax1.set_ylabel('Pyrometer')\n",
    "ax1.grid(True)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "plt.figure(figsize=(40, 6))\n",
    "fig, ax1 = plt.subplots( figsize=(40, 6))\n",
    "\n",
    "sc = ax1.plot(data1200['seconds'], data1200['Pyrometer'], color='grey') \n",
    "#sc = ax1.plot(data1350['seconds'], data1350['Pyrometer'], color='grey') \n",
    "sc = ax1.plot(data1000['seconds'], data1000['Pyrometer'], color='grey') \n",
    "sc = ax1.plot(data900['seconds'], data900['Pyrometer'], color='grey') \n",
    "sc = ax1.plot(dataN1200['seconds'], dataN1200['Pyrometer'], color='grey') \n",
    "sc = ax1.plot(data1000['seconds'], data1000['Pyrometer'], color='grey') \n",
    "#sc = ax1.plot(dataN1100['seconds'], dataN1100['Pyrometer'], color='grey') \n",
    "sc = ax1.plot(newRegime['seconds'], newRegime['Pyrometer'], color='red') \n",
    " \n",
    "\n",
    "ax1.set_title('title')\n",
    "ax1.set_xlabel('seconds')\n",
    "ax1.set_ylabel('Pyrometer')\n",
    "ax1.grid(True)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "SPS",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.13.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
