{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "260ffca4-7cd5-442a-8966-81b344a6930e",
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "from matplotlib.font_manager import FontProperties\n",
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "794bcf06-5c3a-4a6a-ac54-01a0ba20dbfd",
   "metadata": {},
   "source": [
    "# Importing data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "7d107961-afd1-4a4c-8770-313a538ca30e",
   "metadata": {},
   "outputs": [],
   "source": [
    "med = pd.read_csv('med.csv')\n",
    "med_discri = pd.read_csv('med_discri.csv')\n",
    "data_plot= pd.read_csv('data_plot.csv')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b04bd56f-dc7b-407f-b68a-c744f40b2796",
   "metadata": {},
   "source": [
    "# Filtering data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "e6cbc55a-9bb7-4908-9c9f-5b259bb80cb4",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 24 Hrs light intensity\n",
    "luxes = med.iloc[0:288,0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "53d26ad9-ac4e-4072-b885-cb64c9af2b0b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 23420 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(luxes,'.k')\n",
    "plt.xlabel('Sample Number')\n",
    "plt.ylabel('[Lx]', rotation=90)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "27096899-6340-4d63-8ff3-5fccccda21ac",
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "#Filtering data\n",
    "def FilteringData(b,e):\n",
    "    filtered_med = med[(med['hh'] >= b ) & (med['hh'] <= e)]\n",
    "    #Saving luxes, temp, hum and power data\n",
    "    luxesf = filtered_med.iloc[:,0].tolist()\n",
    "    tempf  = filtered_med.iloc[:,1].tolist()\n",
    "    humf   = filtered_med.iloc[:,2].tolist()\n",
    "    powf   = filtered_med.iloc[:,5].tolist()\n",
    "\n",
    "    return luxesf, tempf, humf, powf"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2fd90fdf-61c3-4630-853f-99918cb6a0ad",
   "metadata": {},
   "source": [
    "# Plotting data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "4257e945-efd5-4bec-91ec-2a5b5cf5ed22",
   "metadata": {},
   "outputs": [],
   "source": [
    "#Graph\n",
    "# 0,0 - 0,3\n",
    "def GenGraph(luxesf, tempf, humf, powf):\n",
    "    figure, axis = plt.subplots(4,4, figsize=(8,6))\n",
    "    luxlim=(2055,48000)\n",
    "    templim=(13,50)\n",
    "    humlim=(12,88)\n",
    "    powlim=(0.68,11.61)\n",
    "    #Text fontsize\n",
    "    fontsize=16\n",
    "    Tfont = FontProperties(family='serif', style='normal',size=16)\n",
    "    #Tiles fontsize, family font\n",
    "    font = FontProperties(family='serif',style='italic',size=10)\n",
    "    #Pos x,y Titles\n",
    "    Tx=1.15\n",
    "    Ty=0.36\n",
    "    \n",
    "    axis[0,0].text(0.5,0.5,'Lux', verticalalignment='center', horizontalalignment='center',font = Tfont)\n",
    "    for spine in axis[0,0].spines.values():\n",
    "        spine.set_visible(False)\n",
    "    \n",
    "    axis[0,1].scatter(luxesf,tempf, s=5, c='none', marker='.', facecolors='none', edgecolors='black', alpha=1)\n",
    "    axis[0,1].set(xlim=luxlim,ylim=templim)\n",
    "    axis[0,1].set_title('a)',y=Ty, x=Tx)\n",
    "    \n",
    "    axis[0,2].scatter(luxesf,humf, s=5, c='none', marker='.', facecolors='none', edgecolors='black', alpha=1)\n",
    "    axis[0,2].set(xlim=luxlim,ylim=humlim)\n",
    "    axis[0,2].set_title('b)',y=Ty, x=Tx)\n",
    "    \n",
    "    axis[0,3].scatter(luxesf,powf, s=5, c='none', marker='.', facecolors='none', edgecolors='black', alpha=1)\n",
    "    axis[0,3].set(xlim=luxlim,ylim=powlim)\n",
    "    axis[0,3].set_title('c)',y=Ty, x=Tx)\n",
    "    \n",
    "    # 1,0 - 1,3\n",
    "    axis[1,0].scatter(tempf,luxesf, s=5, c='none', marker='o', facecolors='none', edgecolors='black', alpha=0.3)\n",
    "    axis[1,0].set_title('d)',y=Ty, x=Tx)\n",
    "    axis[1,0].set(xlim=templim,ylim=luxlim)\n",
    "    axis[1,0].set_ylim(luxlim)\n",
    "    \n",
    "    \n",
    "    axis[1,1].text(0.5,0.5,'Temp', fontsize=fontsize, verticalalignment='center', horizontalalignment='center', font = Tfont)\n",
    "    for spine in axis[1,1].spines.values():\n",
    "        spine.set_visible(False)\n",
    "    \n",
    "    axis[1,2].scatter(tempf,humf, s=5, c='none', marker='.', facecolors='none', edgecolors='black', alpha=1)\n",
    "    axis[1,2].set_title('e)',y=Ty, x=Tx)\n",
    "    axis[1,2].set(xlim=templim,ylim=humlim)\n",
    "    \n",
    "    axis[1,3].scatter(tempf,powf, s=5, c='none', marker='.', facecolors='none', edgecolors='black', alpha=1)\n",
    "    axis[1,3].set_title('f)',y=Ty, x=Tx)\n",
    "    axis[1,3].set(xlim=templim,ylim=powlim)\n",
    "    # 2,0 - 2,3\n",
    "    axis[2,0].scatter(humf,luxesf, s=5, c='none', marker='o', facecolors='none', edgecolors='black', alpha=0.3)\n",
    "    axis[2,0].set_title('g)',y=Ty, x=Tx)\n",
    "    axis[2,0].set(xlim=humlim,ylim=luxlim)\n",
    "    \n",
    "    axis[2,1].scatter(humf,tempf, s=5, c='none', marker='o', facecolors='none', edgecolors='black', alpha=0.3)\n",
    "    axis[2,1].set_title('h)',y=Ty, x=Tx)\n",
    "    axis[2,1].set(xlim=humlim,ylim=templim)\n",
    "    \n",
    "    axis[2,2].text(0.5,0.5,'Hum', fontsize=fontsize, verticalalignment='center', horizontalalignment='center', font = Tfont)\n",
    "    for spine in axis[2,2].spines.values():\n",
    "        spine.set_visible(False)\n",
    "    \n",
    "    axis[2,3].scatter(humf,powf, s=5, c='none', marker='.', facecolors='none', edgecolors='black', alpha=1)\n",
    "    axis[2,3].set_title('i)',y=Ty, x=Tx)\n",
    "    axis[2,3].set(xlim=humlim,ylim=powlim)\n",
    "    \n",
    "    # 3,0 - 3,3\n",
    "    axis[3,0].scatter(powf,luxesf, s=5, c='none', marker='o', facecolors='none', edgecolors='black', alpha=0.3)\n",
    "    axis[3,0].set_title('j)',y=Ty, x=Tx)\n",
    "    axis[3,0].set(xlim=powlim,ylim=luxlim)\n",
    "    \n",
    "    axis[3,1].scatter(powf,tempf, s=5, c='none', marker='o', facecolors='none', edgecolors='black', alpha=0.3)\n",
    "    axis[3,1].set_title('k)',y=Ty, x=Tx)\n",
    "    axis[3,1].set(xlim=powlim,ylim=templim)\n",
    "    \n",
    "    axis[3,2].scatter(powf,humf, s=5, c='none', marker='o', facecolors='none', edgecolors='black', alpha=0.3)\n",
    "    axis[3,2].set_title('l)',y=Ty, x=Tx)\n",
    "    axis[3,2].set(xlim=powlim,ylim=humlim)\n",
    "    \n",
    "    axis[3,3].text(0.5,0.5,'Pow', fontsize=fontsize, verticalalignment='center', horizontalalignment='center', font = Tfont)\n",
    "    for spine in axis[3,3].spines.values():\n",
    "        spine.set_visible(False)\n",
    "    \n",
    "    for ax in axis.flat:\n",
    "        ax.set_xticklabels([])\n",
    "        ax.set_xticks([])\n",
    "        ax.set_yticklabels([])\n",
    "        ax.set_yticks([])\n",
    "        for text in [ax.title]:\n",
    "            text.set_font_properties(font)\n",
    "    plt.subplots_adjust(wspace=0.4,hspace=0.06)\n",
    "    plt.savefig(\"Graph.png\")\n",
    "    plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "698d5c2f-9006-407d-b8f8-aab86dac1bfb",
   "metadata": {},
   "source": [
    "# Own filtered data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "625b4e71-b5dc-49c0-acd5-331363ddf3da",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 215020 characters]",
      "text/plain": [
       "<Figure size 800x600 with 16 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "luxesf, tempf, humf, powf = FilteringData(9,19)\n",
    "GenGraph(luxesf,tempf,humf,powf)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3e735482-e2b5-4d07-9c9b-5588139be694",
   "metadata": {},
   "source": [
    "# Data_plot data base"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "9d456520-ca2f-4197-9207-6bff22962a8c",
   "metadata": {},
   "outputs": [],
   "source": [
    "luxesplt = data_plot.iloc[:,0].tolist()\n",
    "tempplt  = data_plot.iloc[:,1].tolist()\n",
    "humplt   = data_plot.iloc[:,2].tolist()\n",
    "powplt   = data_plot.iloc[:,3].tolist()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "f7645ada-820e-4fb0-ae46-e42e6a405348",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 188652 characters]",
      "text/plain": [
       "<Figure size 800x600 with 16 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "GenGraph(luxesplt,tempplt,humplt,powplt)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "17ed2d8f-4b6b-409b-ba3a-ae20b0eb5435",
   "metadata": {},
   "source": [
    "# med data base"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "99642d65-ce00-490b-bead-e77272da9eb5",
   "metadata": {},
   "outputs": [],
   "source": [
    "luxesm = med.iloc[:,0].tolist()\n",
    "tempm  = med.iloc[:,1].tolist()\n",
    "humm   = med.iloc[:,2].tolist()\n",
    "powm   = med.iloc[:,5].tolist()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "f6e7d952-0019-4a9d-9aa4-600426a5c8ea",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 217648 characters]",
      "text/plain": [
       "<Figure size 800x600 with 16 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "GenGraph(luxesm,tempm,humm,powm)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1f02dd77-50b2-4924-80ad-be51300dca87",
   "metadata": {},
   "source": [
    "# med_discri data base"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "6b9d86cc-46da-4748-b54d-81395beb2207",
   "metadata": {},
   "outputs": [],
   "source": [
    "luxesdi = med_discri.iloc[:,0].tolist()\n",
    "tempdi  = med_discri.iloc[:,1].tolist()\n",
    "humdi   = med_discri.iloc[:,2].tolist()\n",
    "powdi   = med_discri.iloc[:,5].tolist()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "e5a7e622-3f2b-4992-8309-2e0f10097409",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 215016 characters]",
      "text/plain": [
       "<Figure size 800x600 with 16 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "GenGraph(luxesdi,tempdi,humdi,powdi)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "b911498a-1453-4a4d-b9b0-425bb43287de",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "def GenGraphTemp(x,y,xlim,ylim,xtitle,ytitle,temp):\n",
    "\n",
    "    fig, ax = plt.subplots(figsize=(7,6))\n",
    "    scatter = ax.scatter(x,y, c=temp, cmap='gray', s=50, edgecolors='none', linewidths=1.5, vmin=0, vmax=70)\n",
    "    ax.set(xlim=xlim,ylim=ylim, xlabel=xtitle, ylabel=ytitle)\n",
    "    ax.grid(True, linestyle='--', linewidth=0.5,alpha=0.7)\n",
    "    ax.tick_params(axis='both', direction='in',length=5,width=1, top=True, right=True)\n",
    "    ColorBar = fig.colorbar(scatter,ax=ax,label='Temp[°C]')\n",
    "    plt.savefig(f\"{xtitle} vs {ytitle}\",\".png\")\n",
    "    plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "9f9501e0-8b41-4586-92b0-627d7d93d620",
   "metadata": {},
   "outputs": [],
   "source": [
    "xlim=(2055,51000)\n",
    "ylim=(1,12)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "95b917cf-2623-4d65-830d-2d2c7c0718cd",
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'luxesdi' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "Cell \u001b[0;32mIn[3], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m GenGraphTemp(\u001b[43mluxesdi\u001b[49m,powdi,xlim,ylim,\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mLuxes[lx]\u001b[39m\u001b[38;5;124m'\u001b[39m,\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mPV\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124ms Power[W]\u001b[39m\u001b[38;5;124m\"\u001b[39m,tempdi)\n",
      "\u001b[0;31mNameError\u001b[0m: name 'luxesdi' is not defined"
     ]
    }
   ],
   "source": [
    "GenGraphTemp(luxesdi,powdi,xlim,ylim,'Luxes[lx]',\"PV's Power[W]\",tempdi)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "b291669c-47df-4fa6-a45c-f52ad6839eb3",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 84244 characters]",
      "text/plain": [
       "<Figure size 700x600 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "GenGraphTemp(luxesm,powm,xlim,ylim,'Luxes[lx]',\"PV's Power[W]\",tempm)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "7b9585cd-7f2a-4f45-af81-0b554d8c0e9d",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 80920 characters]",
      "text/plain": [
       "<Figure size 700x600 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "GenGraphTemp(luxesf,powf,xlim,ylim,'Luxes[lx]',\"PV's Power[W]\",tempf)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "fe35a72d-9627-4d20-80a3-5654953c6105",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 73128 characters]",
      "text/plain": [
       "<Figure size 700x600 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "GenGraphTemp(luxesplt,powplt,xlim,ylim,'Luxes[lx]',\"PV's Power[W]\",tempplt)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "7af23993-2bcd-4e52-b674-25a815b5e895",
   "metadata": {},
   "outputs": [],
   "source": [
    "xlim2=(15,100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "3f0c9295-be3a-478b-82c0-a94fa5035994",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 157636 characters]",
      "text/plain": [
       "<Figure size 700x600 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "GenGraphTemp(humdi,powdi,xlim2,ylim,'Humidity[%]',\"PV's Power[W]\",tempdi)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "e80f6226-c70f-4396-a8ff-e981935f87fc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 157996 characters]",
      "text/plain": [
       "<Figure size 700x600 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "GenGraphTemp(humm,powm,xlim2,ylim,'Humidity[%]',\"PV's Power[W]\",tempm)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "655b9e57-f46a-4617-9902-4561694475f1",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 147532 characters]",
      "text/plain": [
       "<Figure size 700x600 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "GenGraphTemp(humf,powf,xlim2,ylim,'Humidity[%]',\"PV's Power[W]\",tempf)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "96ea2e5b-7c50-4a3e-bcd1-1606f0f38231",
   "metadata": {},
   "outputs": [],
   "source": [
    "GenGraphTemp(humplt,powplt,xlim2,ylim,'Humidity[%]',\"PV's Power[W]\",tempplt)"
   ]
  }
 ],
 "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.10.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
