{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "2022-09-27 Leo Micklem\n",
    "This script is designed to carry out the following tasks: \n",
    "\n",
    "1. Load the Meta Deta File from Testing \n",
    "2. Create a class of test case that reads in all the test data and tare data \n",
    "3. Subtract the means from the force data\n",
    "4. Carry out an FFT on the data \n",
    "5. Filter the raw force data \n",
    "6. Project the filtered data to lift and thrust axis\n",
    "7. Create a dictionary of all test cases and run each method\n",
    "8. Cycle average corresponding trials"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "import mat73\n",
    "from scipy.signal import butter,filtfilt\n",
    "import math\n",
    "from scipy.signal import find_peaks\n",
    "from scipy.io import loadmat\n",
    "import matplotlib.patches as patches\n",
    "from matplotlib.lines import Line2D\n",
    "import scipy.fftpack\n",
    "import matplotlib.gridspec as gridspec\n",
    "from scipy import signal\n",
    "import matplotlib.image as mpimg\n",
    "from matplotlib.offsetbox import TextArea, DrawingArea, OffsetImage, AnnotationBbox\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "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>Ms</th>\n",
       "      <th>Mpt</th>\n",
       "      <th>Pressure</th>\n",
       "      <th>Frequency</th>\n",
       "      <th>Amplitude</th>\n",
       "      <th>Cycles</th>\n",
       "      <th>AoA</th>\n",
       "      <th>U inf</th>\n",
       "      <th>~St</th>\n",
       "      <th>Re</th>\n",
       "      <th>Date</th>\n",
       "      <th>Comment</th>\n",
       "      <th>LoadCell Drift</th>\n",
       "      <th>Unnamed: 13</th>\n",
       "      <th>Imaged Angle</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>001</td>\n",
       "      <td>001</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.6</td>\n",
       "      <td>12</td>\n",
       "      <td>120</td>\n",
       "      <td>0</td>\n",
       "      <td>0.2</td>\n",
       "      <td>0.15</td>\n",
       "      <td>38867.849312</td>\n",
       "      <td>2022-05-30</td>\n",
       "      <td>amplitude images taken</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>001</td>\n",
       "      <td>002</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.6</td>\n",
       "      <td>12</td>\n",
       "      <td>120</td>\n",
       "      <td>0</td>\n",
       "      <td>0.2</td>\n",
       "      <td>0.15</td>\n",
       "      <td>38867.849312</td>\n",
       "      <td>2022-05-30</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>001</td>\n",
       "      <td>003</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.6</td>\n",
       "      <td>12</td>\n",
       "      <td>120</td>\n",
       "      <td>0</td>\n",
       "      <td>0.2</td>\n",
       "      <td>0.15</td>\n",
       "      <td>38867.849312</td>\n",
       "      <td>2022-05-30</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>001</td>\n",
       "      <td>004</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.6</td>\n",
       "      <td>12</td>\n",
       "      <td>120</td>\n",
       "      <td>0</td>\n",
       "      <td>0.2</td>\n",
       "      <td>0.15</td>\n",
       "      <td>38867.849312</td>\n",
       "      <td>2022-05-30</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>001</td>\n",
       "      <td>005</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.6</td>\n",
       "      <td>12</td>\n",
       "      <td>120</td>\n",
       "      <td>0</td>\n",
       "      <td>0.2</td>\n",
       "      <td>0.15</td>\n",
       "      <td>38867.849312</td>\n",
       "      <td>2022-05-30</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</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",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>471</th>\n",
       "      <td>038</td>\n",
       "      <td>004</td>\n",
       "      <td>0.2</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>200</td>\n",
       "      <td>0</td>\n",
       "      <td>0.2</td>\n",
       "      <td>NaN</td>\n",
       "      <td>38867.849312</td>\n",
       "      <td>2022-12-18</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>472</th>\n",
       "      <td>039</td>\n",
       "      <td>001</td>\n",
       "      <td>0.5</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>200</td>\n",
       "      <td>-15</td>\n",
       "      <td>0.2</td>\n",
       "      <td>NaN</td>\n",
       "      <td>38867.849312</td>\n",
       "      <td>2022-12-18</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>473</th>\n",
       "      <td>039</td>\n",
       "      <td>002</td>\n",
       "      <td>0.5</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>200</td>\n",
       "      <td>-10</td>\n",
       "      <td>0.2</td>\n",
       "      <td>NaN</td>\n",
       "      <td>38867.849312</td>\n",
       "      <td>2022-12-18</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>474</th>\n",
       "      <td>039</td>\n",
       "      <td>003</td>\n",
       "      <td>0.5</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>200</td>\n",
       "      <td>-5</td>\n",
       "      <td>0.2</td>\n",
       "      <td>NaN</td>\n",
       "      <td>38867.849312</td>\n",
       "      <td>2022-12-18</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>475</th>\n",
       "      <td>039</td>\n",
       "      <td>004</td>\n",
       "      <td>0.5</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>200</td>\n",
       "      <td>0</td>\n",
       "      <td>0.2</td>\n",
       "      <td>NaN</td>\n",
       "      <td>38867.849312</td>\n",
       "      <td>2022-12-18</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>476 rows × 15 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      Ms  Mpt  Pressure  Frequency  Amplitude  Cycles  AoA  U inf   ~St  \\\n",
       "0    001  001       0.0        0.6         12     120    0    0.2  0.15   \n",
       "1    001  002       0.0        0.6         12     120    0    0.2  0.15   \n",
       "2    001  003       0.0        0.6         12     120    0    0.2  0.15   \n",
       "3    001  004       0.0        0.6         12     120    0    0.2  0.15   \n",
       "4    001  005       0.0        0.6         12     120    0    0.2  0.15   \n",
       "..   ...  ...       ...        ...        ...     ...  ...    ...   ...   \n",
       "471  038  004       0.2        0.0          0     200    0    0.2   NaN   \n",
       "472  039  001       0.5        0.0          0     200  -15    0.2   NaN   \n",
       "473  039  002       0.5        0.0          0     200  -10    0.2   NaN   \n",
       "474  039  003       0.5        0.0          0     200   -5    0.2   NaN   \n",
       "475  039  004       0.5        0.0          0     200    0    0.2   NaN   \n",
       "\n",
       "               Re       Date                 Comment LoadCell Drift  \\\n",
       "0    38867.849312 2022-05-30  amplitude images taken            NaN   \n",
       "1    38867.849312 2022-05-30                     NaN            NaN   \n",
       "2    38867.849312 2022-05-30                     NaN            NaN   \n",
       "3    38867.849312 2022-05-30                     NaN            NaN   \n",
       "4    38867.849312 2022-05-30                     NaN            NaN   \n",
       "..            ...        ...                     ...            ...   \n",
       "471  38867.849312 2022-12-18                     NaN            NaN   \n",
       "472  38867.849312 2022-12-18                     NaN            NaN   \n",
       "473  38867.849312 2022-12-18                     NaN            NaN   \n",
       "474  38867.849312 2022-12-18                     NaN            NaN   \n",
       "475  38867.849312 2022-12-18                     NaN            NaN   \n",
       "\n",
       "     Unnamed: 13  Imaged Angle  \n",
       "0            NaN           NaN  \n",
       "1            NaN           NaN  \n",
       "2            NaN           NaN  \n",
       "3            NaN           NaN  \n",
       "4            NaN           NaN  \n",
       "..           ...           ...  \n",
       "471          NaN           NaN  \n",
       "472          NaN           NaN  \n",
       "473          NaN           NaN  \n",
       "474          NaN           NaN  \n",
       "475          NaN           NaN  \n",
       "\n",
       "[476 rows x 15 columns]"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "meta_data_filepath = r'2022-05-30 Force Testing Matrix.xlsx'\n",
    "meta_data = pd.read_excel(meta_data_filepath, header =0, converters={'Ms':str})\n",
    "meta_data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "class TestCase: \n",
    "    def __init__(self, Ms, Mpt, Pressure, Cycles, AoA, U_inf, foldername, load_cell_drift):\n",
    "        self.Ms = Ms\n",
    "        self.Mpt= Mpt\n",
    "        self.Pressure = Pressure\n",
    "        self.Cycles = Cycles\n",
    "        self.AoA = AoA\n",
    "        self.foldername = foldername\n",
    "        self.U_inf = U_inf\n",
    "        self.load_cell_drift = load_cell_drift\n",
    "        #self.imaged_angle = imaged_angle\n",
    "                \n",
    "        data_filename = f\"./{self.foldername}/ms{Ms}mpt{Mpt}.mat\"\n",
    "        tare_filename = f\"./{self.foldername}/ms{Ms}_tareData.mat\"\n",
    "        \n",
    "        self.data_filename = data_filename\n",
    "        self.tare_filename = tare_filename\n",
    "        \n",
    "    def read_matlab_data(self):\n",
    "        \n",
    "        self.Data = mat73.loadmat(self.data_filename)\n",
    "        \n",
    "        self.rawForces = self.Data[\"expData\"][\"rawData\"]\n",
    "        self.samplingRate = self.Data[\"expData\"][\"samplingRate\"]\n",
    "        self.alpha = self.Data[\"expData\"][\"alpha\"]\n",
    "        bar = self.Data[\"expData\"]['encDeg']\n",
    "        self.encoder_alpha = max(bar, key=lambda x: abs(x))\n",
    "        #self.encoder_alpha = max(abs(self.Data[\"expData\"]['encDeg']))\n",
    "        \n",
    "    def read_matlab_tare(self):\n",
    "        \n",
    "        self.tareData = mat73.loadmat(self.tare_filename)\n",
    "\n",
    "        self.tare_mean_x = np.mean(self.tareData['tareData'][:,0])\n",
    "        self.tare_mean_y = np.mean(self.tareData['tareData'][:,1])\n",
    "        self.tare_mean_z = np.mean(self.tareData['tareData'][:,2])\n",
    "        self.tare_mean_tx = np.mean(self.tareData['tareData'][:,3])\n",
    "        self.tare_mean_ty = np.mean(self.tareData['tareData'][:,4])\n",
    "        self.tare_mean_tz = np.mean(self.tareData['tareData'][:,5])\n",
    "\n",
    "        self.tare_x = self.tareData['tareData'][:,0]\n",
    "        self.tare_y = self.tareData['tareData'][:,1]\n",
    "        self.tare_z = self.tareData['tareData'][:,2]\n",
    "        self.tare_tx = self.tareData['tareData'][:,3]\n",
    "        self.tare_ty = self.tareData['tareData'][:,4]\n",
    "        self.tare_tz = self.tareData['tareData'][:,5]\n",
    "        \n",
    "        if self.load_cell_drift == 'Yes':\n",
    "            drift_factors = {15:0.003, 10:0.0015, 5:0.00075, 0:0.0007, -5:0, -10:0, -15:0}\n",
    "            self.tare_mean_x -= self.tare_mean_x*drift_factors[self.AoA]\n",
    "            self.tare_mean_y -= self.tare_mean_y*drift_factors[self.AoA]\n",
    "        \n",
    "    def adjust_raw_forces(self):  #subtract mean offset value \n",
    "        \n",
    "        self.fx_raw = self.rawForces[10000:,0] - self.tare_mean_x\n",
    "        self.fy_raw = self.rawForces[10000:,1] - self.tare_mean_y\n",
    "        self.fz_raw = self.rawForces[10000:,2] - self.tare_mean_z\n",
    "        self.tx_raw = self.rawForces[10000:,3] - self.tare_mean_tx\n",
    "        self.ty_raw = self.rawForces[10000:,4] - self.tare_mean_ty\n",
    "        self.tz_raw = self.rawForces[10000:,5] - self.tare_mean_tz\n",
    "        \n",
    "        \n",
    "    def find_oscillatory_signal(self): #subtract mean of data from data \n",
    "        \n",
    "        self.fx_raw_oscil = self.fx_raw - np.mean(self.fx_raw)\n",
    "        self.fy_raw_oscil = self.fy_raw - np.mean(self.fy_raw)\n",
    "        self.fz_raw_oscil = self.fz_raw - np.mean(self.fz_raw)\n",
    "        self.tx_raw_oscil = self.tx_raw - np.mean(self.tx_raw)\n",
    "        self.ty_raw_oscil = self.ty_raw - np.mean(self.ty_raw)\n",
    "        self.tz_raw_oscil = self.tz_raw - np.mean(self.tz_raw)\n",
    "        \n",
    "    def project_forces_to_axis(self):\n",
    "        \n",
    "        rho = 1000\n",
    "        v = 0.2\n",
    "        A = 0.195 * 0.12\n",
    "        \n",
    "        alpha_rad = self.encoder_alpha * np.pi / 180 #convert AoA value to radians\n",
    "        # Multiply forces by rotation matrix\n",
    "        self.lift = self.fy_raw * np.cos(alpha_rad) + self.fx_raw * np.sin(alpha_rad)\n",
    "        self.thrust = self.fy_raw * np.sin(alpha_rad) - self.fx_raw * np.cos(alpha_rad) \n",
    "        self.Cl = self.lift/ (0.5 * rho * v**2 * A)\n",
    "        self.Cd = -self.thrust/ (0.5 * rho * v**2 * A)\n",
    "        \n",
    "    def calculate_std(self):\n",
    "        \n",
    "        self.lift_std = np.std(self.lift)\n",
    "        self.thrust_std = np.std(self.thrust)\n",
    "        self.Cl_std = np.std(self.Cl)\n",
    "        \n",
    "    def spectral_density(self):\n",
    "        \n",
    "        self.f_y, self.Pxx_den_y = signal.welch(self.fy_raw_oscil, 1000, nperseg=1024)\n",
    "        self.f_x, self.Pxx_den_x = signal.welch(self.fx_raw_oscil, 1000, nperseg=1024)\n",
    "        self.Pxx_en_y = self.Pxx_den_y * self.f_y\n",
    "        self.Pxx_en_x = self.Pxx_den_x * self.f_x\n",
    "        self.f_reduced_y = self.f_y * 0.195 * np.sin(np.deg2rad(abs(self.AoA)))/self.U_inf\n",
    "        self.f_reduced_x = self.f_x * 0.195 * np.sin(np.deg2rad(abs(self.AoA)))/self.U_inf\n",
    "        \n",
    "        self.Cl_f, self.Pxx_den_Cl = signal.welch(self.Cl, 1000)#, nperseg=1024)\n",
    "        self.Pxx_en_Cl = self.Pxx_den_Cl * self.Cl_f\n",
    "        self.f_reduced_Cl = self.Cl_f * 0.195 * np.sin(np.deg2rad(abs(self.AoA)))/self.U_inf\n",
    "\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "035 001\n",
      "-15.0 14.832\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 19588 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "i=447\n",
    "sample_test= TestCase(meta_data['Ms'][i],\n",
    "                      meta_data['Mpt'][i],\n",
    "                      meta_data['Pressure'][i],\n",
    "                      meta_data['Cycles'][i],\n",
    "                      meta_data['AoA'][i],\n",
    "                      meta_data['U inf'][i],\n",
    "                      \"2022-12-17 Force Testing\",\n",
    "                     meta_data['LoadCell Drift'][i])\n",
    "# , meta_data['Imaged Angle'][336]\n",
    "\n",
    "\n",
    "sample_test.read_matlab_data()\n",
    "sample_test.read_matlab_tare()\n",
    "sample_test.adjust_raw_forces()\n",
    "sample_test.find_oscillatory_signal()\n",
    "sample_test.project_forces_to_axis()\n",
    "sample_test.calculate_std()\n",
    "\n",
    "\n",
    "print(meta_data['Ms'][i],meta_data['Mpt'][i])\n",
    "#print(sample_test.load_cell_drift)\n",
    "#print(np.mean(sample_test.lift))\n",
    "\n",
    "plt.plot(sample_test.rawForces[10000:,3])\n",
    "print(sample_test.alpha, sample_test.encoder_alpha)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "-0.10530356916768897 -0.1278905997917214\n",
      "./2022-12-17 Force Testing/ms035mpt004.mat\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 19916 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "#Debugging\n",
    "\n",
    "#plt.plot(sample_test.lift)\n",
    "plt.plot(sample_test.thrust)\n",
    "print(np.mean(sample_test.lift), np.mean(sample_test.thrust))\n",
    "print(sample_test.data_filename)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "all_test_cases={}\n",
    "\n",
    "for i in range(419, 476):\n",
    "    all_test_cases[f\"ms{meta_data['Ms'][i]}mpt{meta_data['Mpt'][i]}\"] = TestCase(meta_data['Ms'][i],\n",
    "                      meta_data['Mpt'][i],\n",
    "                      meta_data['Pressure'][i],\n",
    "                      meta_data['Cycles'][i],\n",
    "                      meta_data['AoA'][i],\n",
    "                      meta_data['U inf'][i],\n",
    "                      \"2022-12-17 Force Testing\",\n",
    "                      meta_data['LoadCell Drift'][i])\n",
    "    \n",
    "for case in all_test_cases.items():\n",
    "    case[1].read_matlab_tare()\n",
    "    case[1].read_matlab_data()\n",
    "    case[1].adjust_raw_forces()\n",
    "    case[1].find_oscillatory_signal()\n",
    "    case[1].project_forces_to_axis()\n",
    "    case[1].calculate_std()\n",
    "    case[1].spectral_density()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 37272 characters]\n",
      "text/plain": [
       "<Figure size 1000x1000 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig=plt.figure(figsize= (10,10), dpi =100)\n",
    "ax=plt.gca()\n",
    "plt.xticks(fontsize=16)\n",
    "plt.yticks(fontsize=16)\n",
    "plt.ylabel('$Lift~(N)$', fontsize=16)\n",
    "plt.xlabel('$AoA~(Deg)$',fontsize=16)\n",
    "plt.axhline(color = 'k')\n",
    "\n",
    "for case in all_test_cases.items():\n",
    "    if case[1].Pressure == 0.0:                    \n",
    "        plt.scatter(case[1].encoder_alpha, np.mean(case[1].lift), color = 'b')\n",
    "    if case[1].Pressure == 0.2:\n",
    "        plt.scatter(case[1].encoder_alpha, np.mean(case[1].lift), color = 'orange')\n",
    "    if case[1].Pressure == 0.5:\n",
    "        plt.scatter(case[1].encoder_alpha, np.mean(case[1].lift), color = 'r')\n",
    "    if case[1].Pressure == 0.7:\n",
    "        plt.scatter(case[1].encoder_alpha, np.mean(case[1].lift), color = 'k')\n",
    "        \n",
    "        \n",
    "legend_elements = [Line2D([0], [0], color='w', marker = 'o', label='0 Bar',\n",
    "                         markerfacecolor='b', markersize=10),\n",
    "                   Line2D([0], [0], color='w', marker = 'o', label='0.2 Bar',\n",
    "                         markerfacecolor='orange', markersize=10),\n",
    "                   Line2D([0], [0], color='w', marker = 'o', label='0.5 Bar',\n",
    "                         markerfacecolor='r', markersize=10),\n",
    "                   Line2D([0], [0], color='w', marker = 'o', label='0.7 Bar',\n",
    "                         markerfacecolor='k', markersize=10)]\n",
    "                  \n",
    "\n",
    "plt.legend(handles=legend_elements);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 41400 characters]\n",
      "text/plain": [
       "<Figure size 1000x1000 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig=plt.figure(figsize= (10,10), dpi =100)\n",
    "ax=plt.gca()\n",
    "plt.xticks(fontsize=16)\n",
    "plt.yticks(fontsize=16)\n",
    "plt.ylabel('$Cd$', fontsize=16)\n",
    "plt.xlabel('$AoA~(Deg)$',fontsize=16)\n",
    "plt.axhline(color = 'k')\n",
    "\n",
    "for case in all_test_cases.items():\n",
    "    if case[1].Pressure == 0.0:                    \n",
    "        plt.scatter(case[1].encoder_alpha, np.mean(case[1].Cd), color = 'b')\n",
    "    if case[1].Pressure == 0.2:\n",
    "        plt.scatter(case[1].encoder_alpha, np.mean(case[1].Cd), color = 'orange')\n",
    "    if case[1].Pressure == 0.5:\n",
    "        plt.scatter(case[1].encoder_alpha, np.mean(case[1].Cd), color = 'r')\n",
    "    if case[1].Pressure == 0.7:\n",
    "        plt.scatter(case[1].encoder_alpha, np.mean(case[1].Cd), color = 'k')\n",
    "        \n",
    "        \n",
    "legend_elements = [Line2D([0], [0], color='w', marker = 'o', label='0 Bar',\n",
    "                         markerfacecolor='b', markersize=10),\n",
    "                   Line2D([0], [0], color='w', marker = 'o', label='0.2 Bar',\n",
    "                         markerfacecolor='orange', markersize=10),\n",
    "                   Line2D([0], [0], color='w', marker = 'o', label='0.5 Bar',\n",
    "                         markerfacecolor='r', markersize=10),\n",
    "                   Line2D([0], [0], color='w', marker = 'o', label='0.7 Bar',\n",
    "                         markerfacecolor='k', markersize=10)]\n",
    "                  \n",
    "\n",
    "plt.legend(handles=legend_elements);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 34400 characters]\n",
      "text/plain": [
       "<Figure size 1000x1000 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig=plt.figure(figsize= (10,10), dpi =100)\n",
    "ax=plt.gca()\n",
    "plt.xticks(fontsize=16)\n",
    "plt.yticks(fontsize=16)\n",
    "plt.ylabel('$Cl$', fontsize=16)\n",
    "plt.xlabel('$Cd$',fontsize=16)\n",
    "plt.axhline(color = 'k')\n",
    "\n",
    "for case in all_test_cases.items():\n",
    "    if case[1].Pressure == 0.0:                    \n",
    "        plt.scatter(np.mean(case[1].Cd), -np.mean(case[1].Cl), color = 'b')\n",
    "    if case[1].Pressure == 0.2:\n",
    "        plt.scatter(np.mean(case[1].Cd), -np.mean(case[1].Cl), color = 'orange')\n",
    "    if case[1].Pressure == 0.5:\n",
    "        plt.scatter(np.mean(case[1].Cd), -np.mean(case[1].Cl), color = 'r')\n",
    "    if case[1].Pressure == 0.7:\n",
    "        plt.scatter(np.mean(case[1].Cd), -np.mean(case[1].Cl), color = 'k')\n",
    "        \n",
    "        \n",
    "legend_elements = [Line2D([0], [0], color='w', marker = 'o', label='0 Bar',\n",
    "                         markerfacecolor='b', markersize=10),\n",
    "                   Line2D([0], [0], color='w', marker = 'o', label='0.2 Bar',\n",
    "                         markerfacecolor='orange', markersize=10),\n",
    "                   Line2D([0], [0], color='w', marker = 'o', label='0.5 Bar',\n",
    "                         markerfacecolor='r', markersize=10),\n",
    "                   Line2D([0], [0], color='w', marker = 'o', label='0.7 Bar',\n",
    "                         markerfacecolor='k', markersize=10)]\n",
    "                  \n",
    "\n",
    "plt.legend(handles=legend_elements);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 41284 characters]\n",
      "text/plain": [
       "<Figure size 1000x1000 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig=plt.figure(figsize= (10,10), dpi =100)\n",
    "ax=plt.gca()\n",
    "plt.xticks(fontsize=16)\n",
    "plt.yticks(fontsize=16)\n",
    "plt.ylabel('$Fx~Raw~(N)$', fontsize=16)\n",
    "plt.xlabel('$AoA~(Deg)$',fontsize=16)\n",
    "plt.axhline(color = 'k')\n",
    "\n",
    "for case in all_test_cases.items():\n",
    "    if case[1].Pressure == 0.0:                    \n",
    "        plt.scatter(case[1].AoA, np.mean(case[1].fx_raw), color = 'b')\n",
    "    if case[1].Pressure == 0.2:\n",
    "        plt.scatter(case[1].AoA, np.mean(case[1].fx_raw), color = 'orange')\n",
    "    if case[1].Pressure == 0.5:\n",
    "        plt.scatter(case[1].AoA, np.mean(case[1].fx_raw), color = 'r')\n",
    "    if case[1].Pressure == 0.7:\n",
    "        plt.scatter(case[1].AoA, np.mean(case[1].fx_raw), color = 'k')\n",
    "        \n",
    "        \n",
    "legend_elements = [Line2D([0], [0], color='w', marker = 'o', label='0 Bar',\n",
    "                         markerfacecolor='b', markersize=10),\n",
    "                   Line2D([0], [0], color='w', marker = 'o', label='0.2 Bar',\n",
    "                         markerfacecolor='orange', markersize=10),\n",
    "                   Line2D([0], [0], color='w', marker = 'o', label='0.5 Bar',\n",
    "                         markerfacecolor='r', markersize=10),\n",
    "                   Line2D([0], [0], color='w', marker = 'o', label='0.7 Bar',\n",
    "                         markerfacecolor='k', markersize=10)]\n",
    "                  \n",
    "\n",
    "plt.legend(handles=legend_elements);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 51280 characters]\n",
      "text/plain": [
       "<Figure size 1000x1000 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "#Lift Std\n",
    "\n",
    "fig=plt.figure(figsize= (10,10), dpi =100)\n",
    "ax=plt.gca()\n",
    "plt.xticks(fontsize=16)\n",
    "plt.yticks(fontsize=16)\n",
    "plt.ylabel('$Standard~Deviation~(N)$', fontsize=16)\n",
    "plt.xlabel('$AoA~(Deg)$',fontsize=16)\n",
    "#plt.axhline(color = 'k')\n",
    "\n",
    "for case in all_test_cases.items():\n",
    "    if case[1].Pressure == 0.0:                    \n",
    "        plt.scatter(case[1].AoA, case[1].lift_std, color = 'b')\n",
    "    if case[1].Pressure == 0.2:\n",
    "        plt.scatter(case[1].AoA, case[1].lift_std, color = 'orange')\n",
    "    if case[1].Pressure == 0.5:\n",
    "        plt.scatter(case[1].AoA, case[1].lift_std, color = 'r')\n",
    "    if case[1].Pressure == 0.7:\n",
    "        plt.scatter(case[1].AoA, case[1].lift_std, color = 'k')\n",
    "        \n",
    "        \n",
    "legend_elements = [Line2D([0], [0], color='w', marker = 'o', label='0 Bar',\n",
    "                         markerfacecolor='b', markersize=10),\n",
    "                   Line2D([0], [0], color='w', marker = 'o', label='0.2 Bar',\n",
    "                         markerfacecolor='orange', markersize=10),\n",
    "                   Line2D([0], [0], color='w', marker = 'o', label='0.5 Bar',\n",
    "                         markerfacecolor='r', markersize=10),\n",
    "                   Line2D([0], [0], color='w', marker = 'o', label='0.7 Bar',\n",
    "                         markerfacecolor='k', markersize=10)]\n",
    "                  \n",
    "\n",
    "plt.legend(handles=legend_elements);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 38024 characters]\n",
      "text/plain": [
       "<Figure size 1000x1000 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "## Plotting with Cl\n",
    "\n",
    "fig=plt.figure(figsize= (10,10), dpi =100)\n",
    "ax=plt.gca()\n",
    "plt.xticks(fontsize=16)\n",
    "plt.yticks(fontsize=16)\n",
    "plt.ylabel('$Cl$', fontsize=16)\n",
    "plt.xlabel('$AoA~(Deg)$',fontsize=16)\n",
    "plt.axhline(color = 'k')\n",
    "\n",
    "Cl_alphas_export = []\n",
    "Cls_export = []\n",
    "Cls_pressure_export =[]\n",
    "\n",
    "for case in all_test_cases.items():\n",
    "    if case[1].Pressure == 0.0:                    \n",
    "        plt.scatter(case[1].encoder_alpha, -np.mean(case[1].Cl), color = 'b')\n",
    "    if case[1].Pressure == 0.2:\n",
    "        plt.scatter(case[1].encoder_alpha, -np.mean(case[1].Cl), color = 'orange')\n",
    "    if case[1].Pressure == 0.5:\n",
    "        plt.scatter(case[1].encoder_alpha, -np.mean(case[1].Cl), color = 'r')\n",
    "    if case[1].Pressure == 0.7:\n",
    "        plt.scatter(case[1].encoder_alpha, -np.mean(case[1].Cl), color = 'k')\n",
    "    if case[1].Pressure in [0.0,0.7] and case[1].encoder_alpha >= 0:\n",
    "        Cl_alphas_export.append(case[1].encoder_alpha)\n",
    "        Cls_export.append(-np.mean(case[1].Cl))\n",
    "        Cls_pressure_export.append(case[1].Pressure)\n",
    "    Cl_alphas_export = [round(i) for i in Cl_alphas_export]\n",
    "\n",
    "        \n",
    "legend_elements = [Line2D([0], [0], color='w', marker = 'o', label='0 Bar',\n",
    "                         markerfacecolor='b', markersize=10),\n",
    "                   Line2D([0], [0], color='w', marker = 'o', label='0.2 Bar',\n",
    "                         markerfacecolor='orange', markersize=10),\n",
    "                   Line2D([0], [0], color='w', marker = 'o', label='0.5 Bar',\n",
    "                         markerfacecolor='r', markersize=10),\n",
    "                   Line2D([0], [0], color='w', marker = 'o', label='0.7 Bar',\n",
    "                         markerfacecolor='k', markersize=10)]\n",
    "                  \n",
    "\n",
    "plt.legend(handles=legend_elements);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [],
   "source": [
    "data = pd.DataFrame({'Pressure':Cls_pressure_export, 'alphas':Cl_alphas_export, 'Cl': Cls_export})\n",
    "#data.to_csv('Steady Lift Data.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 43816 characters]\n",
      "text/plain": [
       "<Figure size 1000x1000 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "## Plotting Cl STD\n",
    "\n",
    "fig=plt.figure(figsize= (10,10), dpi =100)\n",
    "ax=plt.gca()\n",
    "plt.xticks(fontsize=16)\n",
    "plt.yticks(fontsize=16)\n",
    "plt.ylabel('$Cl~Std$', fontsize=16)\n",
    "plt.xlabel('$AoA~(Deg)$',fontsize=16)\n",
    "\n",
    "\n",
    "for case in all_test_cases.items():\n",
    "    if case[1].Pressure == 0.0:                    \n",
    "        plt.scatter(case[1].AoA, case[1].Cl_std, color = 'b')\n",
    "    if case[1].Pressure == 0.2:\n",
    "        plt.scatter(case[1].AoA, case[1].Cl_std, color = 'orange')\n",
    "    if case[1].Pressure == 0.5:\n",
    "        plt.scatter(case[1].AoA, case[1].Cl_std, color = 'r')\n",
    "    if case[1].Pressure == 0.7:\n",
    "        plt.scatter(case[1].AoA, case[1].Cl_std, color = 'k')\n",
    "        \n",
    "        \n",
    "legend_elements = [Line2D([0], [0], color='w', marker = 'o', label='0 Bar',\n",
    "                         markerfacecolor='b', markersize=10),\n",
    "                   Line2D([0], [0], color='w', marker = 'o', label='0.2 Bar',\n",
    "                         markerfacecolor='orange', markersize=10),\n",
    "                   Line2D([0], [0], color='w', marker = 'o', label='0.5 Bar',\n",
    "                         markerfacecolor='r', markersize=10),\n",
    "                   Line2D([0], [0], color='w', marker = 'o', label='0.7 Bar',\n",
    "                         markerfacecolor='k', markersize=10)]\n",
    "                  \n",
    "\n",
    "plt.legend(handles=legend_elements);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 42492 characters]\n",
      "text/plain": [
       "<Figure size 1000x1000 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "## Plotting Cl with Std\n",
    "\n",
    "fig=plt.figure(figsize= (10,10), dpi =100)\n",
    "ax=plt.gca()\n",
    "plt.xticks(fontsize=16)\n",
    "plt.yticks(fontsize=16)\n",
    "plt.ylabel('$Cl$', fontsize=16)\n",
    "plt.xlabel('$AoA~(Deg)$',fontsize=16)\n",
    "plt.axhline(color = 'k')\n",
    "\n",
    "for case in all_test_cases.items():\n",
    "    if case[1].Pressure == 0.0:                    \n",
    "        plt.errorbar(case[1].AoA, np.mean(case[1].Cl), fmt = 'o', yerr = case[1].Cl_std/np.sqrt(len(case[1].Cl)), capsize = 4, elinewidth = 0.5, color = 'b')\n",
    "    if case[1].Pressure == 0.2:\n",
    "        plt.errorbar(case[1].AoA, np.mean(case[1].Cl), fmt = 'o', yerr = case[1].Cl_std/np.sqrt(len(case[1].Cl)), capsize = 4, elinewidth = 0.5, color = 'orange')\n",
    "    if case[1].Pressure == 0.5:\n",
    "        plt.errorbar(case[1].AoA, np.mean(case[1].Cl), fmt = 'o', yerr = case[1].Cl_std/np.sqrt(len(case[1].Cl)), capsize = 4, elinewidth = 0.5, color = 'r')\n",
    "    if case[1].Pressure == 0.7:\n",
    "        plt.errorbar(case[1].AoA, np.mean(case[1].Cl), fmt = 'o', yerr = case[1].Cl_std/np.sqrt(len(case[1].Cl)), capsize = 4, elinewidth = 0.5, color = 'k')\n",
    "        \n",
    "        \n",
    "legend_elements = [Line2D([0], [0], color='w', marker = 'o', label='0 Bar',\n",
    "                         markerfacecolor='b', markersize=10),\n",
    "                   Line2D([0], [0], color='w', marker = 'o', label='0.2 Bar',\n",
    "                         markerfacecolor='orange', markersize=10),\n",
    "                   Line2D([0], [0], color='w', marker = 'o', label='0.5 Bar',\n",
    "                         markerfacecolor='r', markersize=10),\n",
    "                   Line2D([0], [0], color='w', marker = 'o', label='0.7 Bar',\n",
    "                         markerfacecolor='k', markersize=10),\n",
    "                  Line2D([0], [0], color = 'w', marker = '|', label = r'Error = $\\frac{\\sigma}{\\sqrt{N}}$', \n",
    "                        markerfacecolor = 'k', markersize = 10)]\n",
    "                  \n",
    "\n",
    "plt.legend(handles=legend_elements);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 264764 characters]",
      "text/plain": [
       "<Figure size 1000x1000 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "## Plotting with Cl + adding images\n",
    "\n",
    "fig=plt.figure(figsize= (10,10), dpi =100)\n",
    "ax=plt.gca()\n",
    "plt.xticks(fontsize=16)\n",
    "plt.yticks(fontsize=16)\n",
    "plt.ylabel('$Cl$', fontsize=16)\n",
    "plt.xlabel('$AoA~(Deg)$',fontsize=16)\n",
    "plt.axhline(color = 'k')\n",
    "plt.ylim(-1.4, 0.6)\n",
    "\n",
    "for case in all_test_cases.items():\n",
    "    if case[1].Pressure == 0.0:                    \n",
    "        plt.errorbar(case[1].AoA, np.mean(case[1].Cl), fmt = 'o', yerr = case[1].Cl_std/np.sqrt(len(case[1].Cl)), capsize = 4, elinewidth = 0.5, color = 'b')\n",
    "    if case[1].Pressure == 0.2:\n",
    "        plt.errorbar(case[1].AoA, np.mean(case[1].Cl), fmt = 'o', yerr = case[1].Cl_std/np.sqrt(len(case[1].Cl)), capsize = 4, elinewidth = 0.5, color = 'orange')\n",
    "    if case[1].Pressure == 0.5:\n",
    "        plt.errorbar(case[1].AoA, np.mean(case[1].Cl), fmt = 'o', yerr = case[1].Cl_std/np.sqrt(len(case[1].Cl)), capsize = 4, elinewidth = 0.5, color = 'r')\n",
    "    if case[1].Pressure == 0.7:\n",
    "        plt.errorbar(case[1].AoA, np.mean(case[1].Cl), fmt = 'o', yerr = case[1].Cl_std/np.sqrt(len(case[1].Cl)), capsize = 4, elinewidth = 0.5, color = 'k')\n",
    "        \n",
    "        \n",
    "legend_elements = [Line2D([0], [0], color='w', marker = 'o', label='0 Bar',\n",
    "                         markerfacecolor='b', markersize=10),\n",
    "                   Line2D([0], [0], color='w', marker = 'o', label='0.2 Bar',\n",
    "                         markerfacecolor='orange', markersize=10),\n",
    "                   Line2D([0], [0], color='w', marker = 'o', label='0.5 Bar',\n",
    "                         markerfacecolor='r', markersize=10),\n",
    "                   Line2D([0], [0], color='w', marker = 'o', label='0.7 Bar',\n",
    "                         markerfacecolor='k', markersize=10),\n",
    "                  Line2D([0], [0], color = 'w', marker = '|', label = r'Error = $\\frac{\\sigma}{\\sqrt{N}}$', \n",
    "                        markerfacecolor = 'k', markersize = 10)]\n",
    "                  \n",
    "    \n",
    "arr_0b0d = mpimg.imread('./2022-12-17 Force Testing/Images/GOPR6850.JPG')\n",
    "arr_0b0d = arr_0b0d[1200:1800, 1950:2350, :]\n",
    "image_0b0d = OffsetImage(arr_0b0d, zoom = 0.2,zorder = 0)\n",
    "ab_0b0d = AnnotationBbox(image_0b0d, (0, 0.2),frameon=False)\n",
    "ax.add_artist(ab_0b0d)\n",
    "\n",
    "arr_0bn15d = mpimg.imread('./2022-12-17 Force Testing/Images/GOPR6851.JPG')\n",
    "arr_0bn15d = arr_0bn15d[1200:1800, 1950:2350, :]\n",
    "image_0bn15d = OffsetImage(arr_0bn15d, zoom = 0.2,zorder = 0)\n",
    "ab_0bn15d = AnnotationBbox(image_0bn15d, (-14, -0.4),frameon=False)\n",
    "ax.add_artist(ab_0bn15d)\n",
    "\n",
    "arr_07b0d = mpimg.imread('./2022-12-17 Force Testing/Images/GOPR6866.JPG')\n",
    "arr_07b0d = arr_07b0d[1200:1800, 1950:2350, :]\n",
    "image_07b0d = OffsetImage(arr_07b0d, zoom = 0.2,zorder = 0)\n",
    "ab_07b0d = AnnotationBbox(image_07b0d, (0, -0.7),frameon=False)\n",
    "ax.add_artist(ab_07b0d)\n",
    "\n",
    "arr_07bn15d = mpimg.imread('./2022-12-17 Force Testing/Images/GOPR6867.JPG')\n",
    "arr_07bn15d = arr_07bn15d[1200:1800, 1950:2350, :]\n",
    "image_07bn15d = OffsetImage(arr_07bn15d, zoom = 0.2,zorder = 0)\n",
    "ab_07bn15d = AnnotationBbox(image_07bn15d, (-12.4, -1.2),frameon=False)\n",
    "ax.add_artist(ab_07bn15d)\n",
    "\n",
    "plt.legend(handles=legend_elements);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 264424 characters]",
      "text/plain": [
       "<Figure size 1000x1000 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "## Plotting with Cl + adding images\n",
    "\n",
    "fig=plt.figure(figsize= (10,10), dpi =100)\n",
    "ax=plt.gca()\n",
    "plt.xticks(fontsize=16)\n",
    "plt.yticks(fontsize=16)\n",
    "plt.ylabel('$Cl$', fontsize=16)\n",
    "plt.xlabel('$AoA~(Deg)$',fontsize=16)\n",
    "plt.axhline(color = 'k')\n",
    "plt.ylim(-0.6, 1.4)\n",
    "\n",
    "for case in all_test_cases.items():\n",
    "    if case[1].Pressure == 0.0:                    \n",
    "        plt.errorbar(case[1].AoA, -np.mean(case[1].Cl), fmt = 'o', yerr = case[1].Cl_std/np.sqrt(len(case[1].Cl)), capsize = 4, elinewidth = 0.5, color = 'b')\n",
    "    if case[1].Pressure == 0.2:\n",
    "        plt.errorbar(case[1].AoA, -np.mean(case[1].Cl), fmt = 'o', yerr = case[1].Cl_std/np.sqrt(len(case[1].Cl)), capsize = 4, elinewidth = 0.5, color = 'orange')\n",
    "    if case[1].Pressure == 0.5:\n",
    "        plt.errorbar(case[1].AoA, -np.mean(case[1].Cl), fmt = 'o', yerr = case[1].Cl_std/np.sqrt(len(case[1].Cl)), capsize = 4, elinewidth = 0.5, color = 'r')\n",
    "    if case[1].Pressure == 0.7:\n",
    "        plt.errorbar(case[1].AoA, -np.mean(case[1].Cl), fmt = 'o', yerr = case[1].Cl_std/np.sqrt(len(case[1].Cl)), capsize = 4, elinewidth = 0.5, color = 'k')\n",
    "        \n",
    "        \n",
    "legend_elements = [Line2D([0], [0], color='w', marker = 'o', label='0 Bar',\n",
    "                         markerfacecolor='b', markersize=10),\n",
    "                   Line2D([0], [0], color='w', marker = 'o', label='0.2 Bar',\n",
    "                         markerfacecolor='orange', markersize=10),\n",
    "                   Line2D([0], [0], color='w', marker = 'o', label='0.5 Bar',\n",
    "                         markerfacecolor='r', markersize=10),\n",
    "                   Line2D([0], [0], color='w', marker = 'o', label='0.7 Bar',\n",
    "                         markerfacecolor='k', markersize=10),\n",
    "                  Line2D([0], [0], color = 'w', marker = '|', label = r'Error = $\\frac{\\sigma}{\\sqrt{N}}$', \n",
    "                        markerfacecolor = 'k', markersize = 10)]\n",
    "                  \n",
    "    \n",
    "arr_0b0d = mpimg.imread('./2022-12-17 Force Testing/Images/GOPR6850.JPG')\n",
    "arr_0b0d = arr_0b0d[1200:1800, 1950:2350, :]\n",
    "image_0b0d = OffsetImage(arr_0b0d, zoom = 0.2,zorder = 0)\n",
    "ab_0b0d = AnnotationBbox(image_0b0d, (0, -0.2),frameon=False)\n",
    "ax.add_artist(ab_0b0d)\n",
    "\n",
    "arr_0bn15d = mpimg.imread('./2022-12-17 Force Testing/Images/GOPR6851.JPG')\n",
    "arr_0bn15d = arr_0bn15d[1200:1800, 1950:2350, :]\n",
    "image_0bn15d = OffsetImage(arr_0bn15d, zoom = 0.2,zorder = 0)\n",
    "ab_0bn15d = AnnotationBbox(image_0bn15d, (-14, 0.4),frameon=False)\n",
    "ax.add_artist(ab_0bn15d)\n",
    "\n",
    "arr_07b0d = mpimg.imread('./2022-12-17 Force Testing/Images/GOPR6866.JPG')\n",
    "arr_07b0d = arr_07b0d[1200:1800, 1950:2350, :]\n",
    "image_07b0d = OffsetImage(arr_07b0d, zoom = 0.2,zorder = 0)\n",
    "ab_07b0d = AnnotationBbox(image_07b0d, (0, 0.7),frameon=False)\n",
    "ax.add_artist(ab_07b0d)\n",
    "\n",
    "arr_07bn15d = mpimg.imread('./2022-12-17 Force Testing/Images/GOPR6867.JPG')\n",
    "arr_07bn15d = arr_07bn15d[1200:1800, 1950:2350, :]\n",
    "image_07bn15d = OffsetImage(arr_07bn15d, zoom = 0.2,zorder = 0)\n",
    "ab_07bn15d = AnnotationBbox(image_07bn15d, (-12, 1.15),frameon=False)\n",
    "ax.add_artist(ab_07bn15d)\n",
    "\n",
    "plt.legend(handles=legend_elements);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 430988 characters]",
      "text/plain": [
       "<Figure size 1000x1400 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "## Plotting with Cl + adding images\n",
    "\n",
    "fig=plt.figure(figsize= (10,14), dpi =100)\n",
    "ax=plt.gca()\n",
    "plt.xticks(fontsize=20)\n",
    "plt.yticks(fontsize=20)\n",
    "plt.ylabel('$Lift~Coefficient$', fontsize=20)\n",
    "plt.xlabel(r'$Attack~Angle~(\\degree)$',fontsize=20)\n",
    "plt.axhline(color = 'k')\n",
    "plt.ylim(-0.6, 1.4)\n",
    "\n",
    "### Get just one point per pressure/angle\n",
    "\n",
    "angle_0 = []\n",
    "angle_02 = []\n",
    "angle_05 = []\n",
    "angle_07 = []\n",
    "\n",
    "for case in all_test_cases.items():\n",
    "    if case[1].Pressure == 0.0 and case[1].AoA not in angle_0:                    \n",
    "        plt.errorbar(-case[1].AoA, -np.mean(case[1].Cl), fmt = 'H', yerr = case[1].Cl_std/np.sqrt(len(case[1].Cl)),\n",
    "                     capsize = 10, elinewidth = 0.5, color = 'r', alpha = 1, markersize = 10)\n",
    "        angle_0.append(case[1].AoA)\n",
    "    if case[1].Pressure == 0.2 and case[1].AoA not in angle_02:\n",
    "        plt.errorbar(-case[1].AoA, -np.mean(case[1].Cl), fmt = '*', yerr = case[1].Cl_std/np.sqrt(len(case[1].Cl)),\n",
    "                     capsize = 10, elinewidth = 0.5, color = 'r', alpha = 1, markersize = 14)\n",
    "        angle_02.append(case[1].AoA)\n",
    "    if case[1].Pressure == 0.5 and case[1].AoA not in angle_05:\n",
    "        plt.errorbar(-case[1].AoA, -np.mean(case[1].Cl), fmt = 'o', yerr = case[1].Cl_std/np.sqrt(len(case[1].Cl)),\n",
    "                     capsize = 10, elinewidth = 0.5, color = 'r', alpha = 1, markersize = 13)\n",
    "        angle_05.append(case[1].AoA)\n",
    "    if case[1].Pressure == 0.7 and case[1].AoA not in angle_07:\n",
    "        plt.errorbar(-case[1].AoA, -np.mean(case[1].Cl), fmt = 'P', yerr = case[1].Cl_std/np.sqrt(len(case[1].Cl)),\n",
    "                     capsize = 10, elinewidth = 0.5, color = 'r', alpha = 1, markersize = 16)\n",
    "        angle_07.append(case[1].AoA)\n",
    "        \n",
    "legend_elements = [Line2D([0], [0], color='w', marker = 'P', label='6.5% Camber',\n",
    "                         markerfacecolor='r', markersize=18),\n",
    "                   Line2D([0], [0], color='w', marker = 'o', label='5% Camber',\n",
    "                         markerfacecolor='r', markersize=18),\n",
    "                   Line2D([0], [0], color='w', marker = '*', label='3.5% Camber',\n",
    "                         markerfacecolor='r', markersize=22),\n",
    "                   Line2D([0], [0], color='w', marker = 'H', label='3% Camber',\n",
    "                         markerfacecolor='r', markersize=18),\n",
    "                  Line2D([0], [0], color = 'w', marker = '|', label = r'Error = $\\frac{\\sigma}{\\sqrt{N}}$', \n",
    "                        markerfacecolor = 'k', markersize = 10)]\n",
    "                  \n",
    "    \n",
    "xy = [0, 0.1]    \n",
    "arr_0b0d = mpimg.imread('./2022-12-17 Force Testing/Images/GOPR6850.JPG')\n",
    "arr_0b0d = arr_0b0d[1200:1800, 1950:2350, :]\n",
    "image_0b0d = OffsetImage(arr_0b0d, zoom = 0.26,zorder = 0)\n",
    "ab_0b0d = AnnotationBbox(image_0b0d, xy, (0, -0.29),frameon=True,\n",
    "                         arrowprops=dict(arrowstyle=\"->\", color = 'r', lw = 2),\n",
    "                            bboxprops=dict(boxstyle=\"square\", color = 'r', linestyle = '-', lw = 1))\n",
    "ax.add_artist(ab_0b0d)\n",
    "\n",
    "xy = [15, 0.63]  \n",
    "arr_0bn15d = mpimg.imread('./2022-12-17 Force Testing/Images/GOPR6851.JPG')\n",
    "arr_0bn15d = arr_0bn15d[1200:1800, 1950:2350, :]\n",
    "image_0bn15d = OffsetImage(arr_0bn15d, zoom = 0.26,zorder = 0)\n",
    "ab_0bn15d = AnnotationBbox(image_0bn15d, xy, (13, 0.1),frameon=True,\n",
    "                         arrowprops=dict(arrowstyle=\"->\", color = 'r', lw = 2), \n",
    "                            bboxprops=dict(boxstyle=\"square\", color = 'r', linestyle = '-', lw = 1))\n",
    "ax.add_artist(ab_0bn15d)\n",
    "\n",
    "xy =  [0, 0.4]\n",
    "arr_07b0d = mpimg.imread('./2022-12-17 Force Testing/Images/GOPR6866.JPG')\n",
    "arr_07b0d = arr_07b0d[1200:1800, 1950:2350, :]\n",
    "image_07b0d = OffsetImage(arr_07b0d, zoom = 0.26,zorder = 0)\n",
    "ab_07b0d = AnnotationBbox(image_07b0d, xy, (-5, 0.7),frameon=True,\n",
    "                         arrowprops=dict(arrowstyle=\"->\", color = 'r', lw = 2), \n",
    "                            bboxprops=dict(boxstyle=\"square\", color = 'r', linestyle = '-', lw = 1))\n",
    "ax.add_artist(ab_07b0d)\n",
    "\n",
    "xy =   [14.5, 0.97] \n",
    "arr_07bn15d = mpimg.imread('./2022-12-17 Force Testing/Images/GOPR6867.JPG')\n",
    "arr_07bn15d = arr_07bn15d[1200:1800, 1950:2350, :]\n",
    "image_07bn15d = OffsetImage(arr_07bn15d, zoom = 0.26,zorder = 0)\n",
    "ab_07bn15d = AnnotationBbox(image_07bn15d, xy, (10, 1.1),frameon=True,\n",
    "                         arrowprops=dict(arrowstyle=\"->\", color = 'r', lw = 2), \n",
    "                            bboxprops=dict(boxstyle=\"square\", color = 'r', linestyle = '-', lw = 1))\n",
    "ax.add_artist(ab_07bn15d)\n",
    "\n",
    "frameon=True,\n",
    "                                   \n",
    "\n",
    "plt.legend(handles=legend_elements, loc = 2, fontsize = 20);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 107,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 39928 characters]\n",
      "text/plain": [
       "<Figure size 1000x1000 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig=plt.figure(figsize= (10,10), dpi =100)\n",
    "ax=plt.gca()\n",
    "plt.xticks(fontsize=16)\n",
    "plt.yticks(fontsize=16)\n",
    "plt.ylabel('$Thrust~(N)$', fontsize=16)\n",
    "plt.xlabel('$AoA~(Deg)$',fontsize=16)\n",
    "plt.axhline(color = 'k')\n",
    "\n",
    "for case in all_test_cases.items():\n",
    "    if case[1].Pressure == 0.0:\n",
    "        plt.scatter(case[1].AoA, np.mean(case[1].thrust), color = 'b')\n",
    "    if case[1].Pressure == 0.2:\n",
    "        plt.scatter(case[1].AoA, np.mean(case[1].thrust), color = 'orange')\n",
    "    if case[1].Pressure == 0.5:\n",
    "        plt.scatter(case[1].AoA, np.mean(case[1].thrust), color = 'r')\n",
    "    if case[1].Pressure == 0.7:\n",
    "        plt.scatter(case[1].AoA, np.mean(case[1].thrust), color = 'k')\n",
    "\n",
    "legend_elements = [Line2D([0], [0], color='w', marker = 'o', label='0 Bar',\n",
    "                         markerfacecolor='b', markersize=10),\n",
    "                   Line2D([0], [0], color='w', marker = 'o', label='0.2 Bar',\n",
    "                         markerfacecolor='orange', markersize=10),\n",
    "                   Line2D([0], [0], color='w', marker = 'o', label='0.5 Bar',\n",
    "                         markerfacecolor='r', markersize=10),\n",
    "                   Line2D([0], [0], color='w', marker = 'o', label='0.7 Bar',\n",
    "                         markerfacecolor='k', markersize=10)]\n",
    "                  \n",
    "\n",
    "plt.legend(handles=legend_elements);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "-0.2859751325482988 -0.1481230274949704\n",
      "./2022-06-01 Force Testing/ms017mpf002.mat\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 24864 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(all_test_cases['ms017mpt002'].lift, label='lift')\n",
    "plt.plot(all_test_cases['ms017mpt002'].thrust, label ='thrust')\n",
    "print(np.mean(all_test_cases['ms017mpt002'].lift), np.mean(all_test_cases['ms017mpt002'].thrust))\n",
    "print(all_test_cases['ms017mpt002'].data_filename)\n",
    "plt.legend();"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "6.268712060750187\n",
      "6.268461220337955\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "Text(0.5, 1.0, '0.2 Bar Tare y. Mean = 6.2687')"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 19936 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(all_test_cases['ms018mpt001'].tare_y)\n",
    "print(np.mean(all_test_cases['ms018mpt001'].tare_y))\n",
    "print(np.mean(all_test_cases['ms018mpt001'].tare_y[15000:]))\n",
    "plt.title('0.2 Bar Tare y. Mean = 6.2687')\n",
    "\n",
    "\n",
    "# print(np.mean(all_test_cases['ms017mpt001'].tare_x))\n",
    "# print(np.mean(all_test_cases['ms018mpt001'].tare_x))\n",
    "# print(np.mean(all_test_cases['ms019mpt001'].tare_x))\n",
    "# print(np.mean(all_test_cases['ms020mpt001'].tare_x))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 30624 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "f, Pxx_den = signal.welch(all_test_cases['ms020mpt001'].fy_raw_oscil, 1000, nperseg=1024)\n",
    "Pxx_den = Pxx_den * f\n",
    "f = f * 0.195 * np.sin(np.deg2rad(12))/0.2\n",
    "plt.semilogy(f, Pxx_den)\n",
    "plt.xlabel('Reduced Frequency: Fcsin(alpha)/U')\n",
    "plt.ylabel('PSD*frequency')\n",
    "plt.title('0.7 Bar, alpha=-12, PSD Fy Data')\n",
    "plt.xlim(0,40)\n",
    "plt.grid()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Text(0.5, 1.0, '0.7 Bar, alpha=-9, Fluctuating Fy Data')"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 23224 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(all_test_cases['ms019mpt009'].fy_raw_oscil)\n",
    "plt.title('0.7 Bar, alpha=-9, Fluctuating Fy Data')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.lines.Line2D at 0x28980e19d90>"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 25692 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "input_angle =[-12,-9,-6,-3,0,3,6,9,12]\n",
    "measured_angle = [-13, -12, -9, -7, -4, -1, 0, 3, 6]\n",
    "\n",
    "plt.plot(input_angle, label= 'Desired AoA')\n",
    "plt.plot(measured_angle, label = 'Measured AoA')\n",
    "plt.legend()\n",
    "plt.title('Plot of Desired AoA and Measured AoA for one test case')\n",
    "plt.ylabel('AoA (deg)')\n",
    "plt.xlabel('Test Case Number ')\n",
    "plt.grid()\n",
    "plt.axhline(0, color='k')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "<ipython-input-19-87669007e9c9>:13: UserWarning: Data has no positive values, and therefore cannot be log-scaled.\n",
      "  plt.semilogy(case[1].f_reduced_y,case[1].Pxx_en_y, label = case[1].Pressure)\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 157576 characters]\n",
      "text/plain": [
       "<Figure size 1000x1000 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "##Plotting Spectral Density\n",
    "\n",
    "fig=plt.figure(figsize= (10,10), dpi =100)\n",
    "ax=plt.gca()\n",
    "plt.xticks(fontsize=16)\n",
    "plt.yticks(fontsize=16)\n",
    "plt.xlabel('$Reduced~Frequency:~Fcsin(alpha)/U$', fontsize=16)\n",
    "plt.ylabel('$PSD*frequency$',fontsize=16)\n",
    "plt.axhline(color = 'k')\n",
    "\n",
    "for case in all_test_cases.items():\n",
    "    if case[1].AoA == 5:\n",
    "        plt.semilogy(case[1].f_reduced_y,case[1].Pxx_en_y, label = case[1].Pressure)\n",
    "#     if case[1].Pressure == 0.2:\n",
    "#         plt.scatter(case[1].AoA, np.mean(case[1].thrust), color = 'orange')\n",
    "#     if case[1].Pressure == 0.5:\n",
    "#         plt.scatter(case[1].AoA, np.mean(case[1].thrust), color = 'r')\n",
    "#     if case[1].Pressure == 0.7:\n",
    "#         plt.scatter(case[1].AoA, np.mean(case[1].thrust), color = 'k')\n",
    "\n",
    "# legend_elements = [Line2D([0], [0], color='w', marker = 'o', label='0 Bar',\n",
    "#                          markerfacecolor='b', markersize=10),\n",
    "#                    Line2D([0], [0], color='w', marker = 'o', label='0.2 Bar',\n",
    "#                          markerfacecolor='orange', markersize=10),\n",
    "#                    Line2D([0], [0], color='w', marker = 'o', label='0.5 Bar',\n",
    "#                          markerfacecolor='r', markersize=10),\n",
    "#                    Line2D([0], [0], color='w', marker = 'o', label='0.7 Bar',\n",
    "#                          markerfacecolor='k', markersize=10)]\n",
    "plt.title('Total Spectral Energy (y direction) at Reduced Frequency for Alpha=6')            \n",
    "plt.xlim(0,40)\n",
    "plt.grid()\n",
    "#plt.legend(handles=legend_elements);\n",
    "plt.legend();"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 70072 characters]\n",
      "text/plain": [
       "<Figure size 1000x1000 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "## Plotting Raw Cl @ 15 deg\n",
    "\n",
    "fig=plt.figure(figsize= (10,10), dpi =100)\n",
    "ax=plt.gca()\n",
    "plt.xticks(fontsize=16)\n",
    "plt.yticks(fontsize=16)\n",
    "plt.ylabel('$Cl$', fontsize=16)\n",
    "plt.xlabel('$Measurement Number$',fontsize=16)\n",
    "#plt.axhline(color = 'k')\n",
    "# plt.ylim(0,0.8)\n",
    "\n",
    "for case in all_test_cases.items():\n",
    "    if case[1].AoA == -5:                    \n",
    "        plt.scatter(case[1].AoA, case[1].Cl_std, label = f'Pressure={case[1].Pressure}bar. Ms={case[1].Ms}')\n",
    "#     if case[1].Pressure == 0.2:\n",
    "#         plt.scatter(case[1].AoA, np.mean(case[1].Cl), color = 'orange')\n",
    "#     if case[1].Pressure == 0.5:\n",
    "#         plt.scatter(case[1].AoA, np.mean(case[1].Cl), color = 'r')\n",
    "#     if case[1].Pressure == 0.7:\n",
    "#         plt.scatter(case[1].AoA, np.mean(case[1].Cl), color = 'k')\n",
    "        \n",
    "        \n",
    "legend_elements = [Line2D([0], [0], color='w', marker = 'o', label='0 Bar',\n",
    "                         markerfacecolor='b', markersize=10),\n",
    "                   Line2D([0], [0], color='w', marker = 'o', label='0.2 Bar',\n",
    "                         markerfacecolor='orange', markersize=10),\n",
    "                   Line2D([0], [0], color='w', marker = 'o', label='0.5 Bar',\n",
    "                         markerfacecolor='r', markersize=10),\n",
    "                   Line2D([0], [0], color='w', marker = 'o', label='0.7 Bar',\n",
    "                         markerfacecolor='k', markersize=10)]\n",
    "\n",
    "# plt.plot(all_test_cases['ms033mpt007'].Cl, label = f'Pressure=0.0bar. Ms=33')\n",
    "                  \n",
    "\n",
    "plt.legend();"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "129\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 86236 characters]\n",
      "text/plain": [
       "<Figure size 1000x1000 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "## Plotting Raw Cl @ 15 deg\n",
    "\n",
    "fig=plt.figure(figsize= (10,10), dpi =100)\n",
    "ax=plt.gca()\n",
    "plt.xticks(fontsize=16)\n",
    "plt.yticks(fontsize=16)\n",
    "plt.ylabel('$Cl~PSD*frequency$', fontsize=16)\n",
    "plt.xlabel('$Frequency$',fontsize=16)\n",
    "#plt.axhline(color = 'k')\n",
    "plt.xlim(0,10)\n",
    "plt.ylim(0,0.025)\n",
    "\n",
    "plt.plot(all_test_cases['ms037mpt001'].Cl_f, all_test_cases['ms037mpt001'].Pxx_en_Cl, label = f'Pressure=0.7bar. Ms=37', color = 'k')\n",
    "plt.plot(all_test_cases['ms036mpt001'].Cl_f, all_test_cases['ms036mpt001'].Pxx_en_Cl, label = f'Pressure=0.0bar. Ms=36', color = 'b')\n",
    "plt.plot(all_test_cases['ms031mpt001'].Cl_f, all_test_cases['ms031mpt001'].Pxx_en_Cl, label = f'Pressure=0.0bar. Ms=31', color = 'b')\n",
    "plt.plot(all_test_cases['ms038mpt001'].Cl_f, all_test_cases['ms038mpt001'].Pxx_en_Cl, label = f'Pressure=0.0bar. Ms=38', color = 'orange')\n",
    "plt.plot(all_test_cases['ms039mpt001'].Cl_f, all_test_cases['ms039mpt001'].Pxx_en_Cl, label = f'Pressure=0.0bar. Ms=39', color = 'r')\n",
    "\n",
    "# plt.plot(all_test_cases['ms034mpt001'].Cl_f, all_test_cases['ms034mpt001'].Pxx_en_Cl, label = f'Pressure=0.7bar. Ms=34', color = 'k')\n",
    "# plt.plot(all_test_cases['ms033mpt001'].Cl_f, all_test_cases['ms033mpt001'].Pxx_en_Cl, label = f'Pressure=0.7bar. Ms=33', color = 'k')\n",
    "# plt.plot(all_test_cases['ms032mpt001'].Cl_f, all_test_cases['ms032mpt001'].Pxx_en_Cl, label = f'Pressure=0.0bar. Ms=32', color = 'b')\n",
    "\n",
    "plt.legend();\n",
    "\n",
    "print(len(all_test_cases['ms037mpt001'].Pxx_en_Cl))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 177860 characters]\n",
      "text/plain": [
       "<Figure size 1000x1000 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "## Plotting Raw Cl @ 15 deg\n",
    "\n",
    "fig=plt.figure(figsize= (10,10), dpi =100)\n",
    "ax=plt.gca()\n",
    "plt.xticks(fontsize=16)\n",
    "plt.yticks(fontsize=16)\n",
    "plt.ylabel('$Cl~PSD*frequency$', fontsize=16)\n",
    "plt.xlabel('$Frequency$',fontsize=16)\n",
    "#plt.axhline(color = 'k')\n",
    "plt.xlim(0,50)\n",
    "# plt.ylim(0,0.009)\n",
    "\n",
    "for case in all_test_cases.items():\n",
    "    if case[1].Ms == '032' :                    \n",
    "        plt.plot(case[1].Cl_f, case[1].Pxx_en_Cl, color = 'b')\n",
    "    if case[1].Ms == '033':\n",
    "        plt.plot(case[1].Cl_f, case[1].Pxx_en_Cl, color = 'k')\n",
    "    if case[1].Ms == '034':\n",
    "        plt.plot(case[1].Cl_f, case[1].Pxx_en_Cl, color = 'k')\n",
    "#     if case[1].Pressure == 0.7:\n",
    "#         plt.scatter(case[1].AoA, np.mean(case[1].Cl), color = 'k')\n",
    "        \n",
    "        \n",
    "# legend_elements = [Line2D([0], [0], color='w', marker = 'o', label='0 Bar',\n",
    "#                          markerfacecolor='b', markersize=10),\n",
    "#                    Line2D([0], [0], color='w', marker = 'o', label='0.2 Bar',\n",
    "#                          markerfacecolor='orange', markersize=10),\n",
    "#                    Line2D([0], [0], color='w', marker = 'o', label='0.5 Bar',\n",
    "#                          markerfacecolor='r', markersize=10),\n",
    "#                    Line2D([0], [0], color='w', marker = 'o', label='0.7 Bar',\n",
    "#                          markerfacecolor='k', markersize=10)]\n",
    "\n",
    "# plt.plot(all_test_cases['ms037mpt007'].Cl_f, all_test_cases['ms037mpt007'].Pxx_en_Cl, label = f'Pressure=0.7bar. Ms=37', color = 'k')\n",
    "# plt.plot(all_test_cases['ms036mpt007'].Cl_f, all_test_cases['ms036mpt007'].Pxx_en_Cl, label = f'Pressure=0.0bar. Ms=36', color = 'b')\n",
    "# plt.plot(all_test_cases['ms031mpt007'].Cl_f, all_test_cases['ms031mpt007'].Pxx_en_Cl, label = f'Pressure=0.0bar. Ms=31', color = 'b')\n",
    "                  \n",
    "# plt.plot(all_test_cases['ms034mpt007'].Cl_f, all_test_cases['ms034mpt007'].Pxx_en_Cl, label = f'Pressure=0.7bar. Ms=34', color = 'k')\n",
    "# plt.plot(all_test_cases['ms033mpt007'].Cl_f, all_test_cases['ms033mpt007'].Pxx_en_Cl, label = f'Pressure=0.7bar. Ms=33', color = 'k')\n",
    "# plt.plot(all_test_cases['ms032mpt007'].Cl_f, all_test_cases['ms032mpt007'].Pxx_en_Cl, label = f'Pressure=0.0bar. Ms=32', color = 'b')\n",
    "\n",
    "# plt.legend();"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 58232 characters]\n",
      "text/plain": [
       "<Figure size 1000x1000 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "## Plotting Cl STD\n",
    "\n",
    "fig=plt.figure(figsize= (10,10), dpi =100)\n",
    "ax=plt.gca()\n",
    "plt.xticks(fontsize=16)\n",
    "plt.yticks(fontsize=16)\n",
    "plt.ylabel('$Cl~PSD*frequency~(First~peak~Magnitude)$', fontsize=16)\n",
    "plt.xlabel('$AoA~(Deg)$',fontsize=16)\n",
    "\n",
    "\n",
    "for case in all_test_cases.items():\n",
    "    if case[1].Pressure == 0.0:                    \n",
    "        plt.scatter(case[1].AoA, max(case[1].Pxx_en_Cl[0:10]), color = 'b')\n",
    "    if case[1].Pressure == 0.2:\n",
    "        plt.scatter(case[1].AoA, max(case[1].Pxx_en_Cl[0:10]), color = 'orange')\n",
    "    if case[1].Pressure == 0.5:\n",
    "        plt.scatter(case[1].AoA, max(case[1].Pxx_en_Cl[0:10]), color = 'r')\n",
    "    if case[1].Pressure == 0.7:\n",
    "        plt.scatter(case[1].AoA, max(case[1].Pxx_en_Cl[0:10]), color = 'k')\n",
    "        \n",
    "        \n",
    "legend_elements = [Line2D([0], [0], color='w', marker = 'o', label='0 Bar',\n",
    "                         markerfacecolor='b', markersize=10),\n",
    "                   Line2D([0], [0], color='w', marker = 'o', label='0.2 Bar',\n",
    "                         markerfacecolor='orange', markersize=10),\n",
    "                   Line2D([0], [0], color='w', marker = 'o', label='0.5 Bar',\n",
    "                         markerfacecolor='r', markersize=10),\n",
    "                   Line2D([0], [0], color='w', marker = 'o', label='0.7 Bar',\n",
    "                         markerfacecolor='k', markersize=10)]\n",
    "                  \n",
    "\n",
    "plt.legend(handles=legend_elements);"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "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.11.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
