{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {
    "pycharm": {
     "name": "#%% Project Setup\n"
    }
   },
   "outputs": [],
   "source": [
    "\n",
    "import jupyter\n",
    "import pandas as pd\n",
    "import geopandas as gp\n",
    "import numpy as np\n",
    "from mpl_toolkits.axes_grid1.anchored_artists import AnchoredSizeBar, AnchoredDirectionArrows\n",
    "import matplotlib.pyplot as plt\n",
    "import matplotlib.font_manager as fm\n",
    "import cartopy.crs as ccrs\n",
    "import contextily as ctx\n",
    "import cmocean.cm as cmo\n",
    "from shapely.geometry import Point, LineString"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "pycharm": {
     "name": "#%% RBR Import Data\n"
    }
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\arey\\Anaconda3\\envs\\BairdBase\\lib\\site-packages\\openpyxl\\styles\\stylesheet.py:221: UserWarning: Workbook contains no default style, apply openpyxl's default\n",
      "  warn(\"Workbook contains no default style, apply openpyxl's default\")\n"
     ]
    }
   ],
   "source": [
    "# RBR\n",
    "RBR_1230 = pd.read_excel('C:/Users/arey/files/Projects/Mustique/065654_20210915_1230.xlsx',\n",
    "                         sheet_name='Data', skiprows=0, header=1)\n",
    "RBR_1552 = pd.read_excel('C:/Users/arey/files/Projects/Mustique/065654_20210917_1552.xlsx',\n",
    "                         sheet_name='Data', skiprows=0, header=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "pycharm": {
     "name": "#%% JFE Import Data\n"
    }
   },
   "outputs": [],
   "source": [
    "JFE_4612 = pd.read_csv('C:/Users/arey/files/Projects/Mustique/20210915_0900_ACLW-USB_0283_084612_A.csv',\n",
    "                          skiprows=30)\n",
    "JFE_5412 = pd.read_csv('C:/Users/arey/files/Projects/Mustique/20210915_1300_ACLW-USB_0283_125412_A.csv',\n",
    "                          skiprows=30)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "pycharm": {
     "name": "#%% GPS Import Data\n"
    }
   },
   "outputs": [],
   "source": [
    "GPS = pd.read_csv('C:/Users/arey/files/Projects/Mustique/export_2002-01-30 08-40.csv',\n",
    "                          header=None, names=['Index', 'Date1', 'Time1', 'Date2', 'Time2', 'Northing', 'North', 'Easting', 'East', 'Var1', 'Var2'])\n",
    "#convert GPS data to geodataframe\n",
    "GPS_gdf = gp.GeoDataFrame(GPS, geometry=gp.points_from_xy(-GPS.Easting, GPS.Northing, crs=\"EPSG:4326\"))\n",
    "\n",
    "GPS_gdf['DateTime'] = pd.to_datetime(GPS_gdf['Date1'].astype(str) + ' ' + GPS_gdf['Time1'].astype(str))\n",
    "\n",
    "# Adjust date to match data\n",
    "GPS_gdf['DateTimeADJ']  =  GPS_gdf['DateTime'] + pd.offsets.DateOffset(years=19, days=-15, months=8, hours=-4)\n",
    "GPS_gdf.set_index('DateTimeADJ', inplace=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "pycharm": {
     "name": "#%% GPS Import Other Tracks\n"
    }
   },
   "outputs": [],
   "source": [
    "GPSswim = pd.read_csv('C:/Users/arey/files/Projects/Mustique/GPS Tracks/Logger_1_KevinSwim.csv',\n",
    "                          header=None, names=['Index', 'Date1', 'Time1', 'Date2', 'Time2', 'Northing', 'North', 'Easting', 'East', 'Var1', 'Var2'])\n",
    "\n",
    "#convert GPS data to geodataframe\n",
    "GPSswim_gdf = gp.GeoDataFrame(GPSswim, geometry=gp.points_from_xy(-GPSswim.Easting, GPSswim.Northing, crs=\"EPSG:4326\"))\n",
    "\n",
    "GPSswim_gdf['DateTime'] = pd.to_datetime(GPSswim_gdf['Date1'].astype(str) + ' ' + GPSswim_gdf['Time1'].astype(str))\n",
    "GPSswim_gdf.geometry = GPSswim_gdf.geometry.to_crs(\"EPSG:32620\")\n",
    "\n",
    "# Adjust date to match data\n",
    "GPSswim_gdf['DateTimeADJ']  =  GPSswim_gdf['DateTime'] + pd.offsets.DateOffset(years=19, days=-15, months=8, hours=-4)\n",
    "GPSswim_gdf.set_index('DateTimeADJ', inplace=True)\n",
    "\n",
    "\n",
    "# Swimming\n",
    "GPSpictures = pd.read_csv('C:/Users/arey/files/Projects/Mustique/GPS Tracks/Logger_1_ReefPictures.csv',\n",
    "                          header=None, names=['Index', 'Date1', 'Time1', 'Date2', 'Time2', 'Northing', 'North', 'Easting', 'East', 'Var1', 'Var2'])\n",
    "\n",
    "#convert GPS data to geodataframe\n",
    "GPSpictures_gdf = gp.GeoDataFrame(GPSpictures, geometry=gp.points_from_xy(-GPSpictures.Easting, GPSpictures.Northing, crs=\"EPSG:4326\"))\n",
    "GPSpictures_gdf.geometry = GPSpictures_gdf.geometry.to_crs(\"EPSG:32620\")\n",
    "\n",
    "GPSpictures_gdf['DateTime'] = pd.to_datetime(GPSpictures_gdf['Date1'].astype(str) + ' ' + GPSpictures_gdf['Time1'].astype(str))\n",
    "\n",
    "# Adjust date to match data\n",
    "GPSpictures_gdf['DateTimeADJ']  =  GPSpictures_gdf['DateTime'] + pd.offsets.DateOffset(years=19, days=-15, months=8, hours=-4)\n",
    "GPSpictures_gdf.set_index('DateTimeADJ', inplace=True)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "pycharm": {
     "name": "#%% Merge GPS to RBR\n"
    }
   },
   "outputs": [],
   "source": [
    "# Process RBR into datetime\n",
    "RBR_1230['DateTime'] = pd.to_datetime(RBR_1230['Time'])\n",
    "RBR_1230.set_index('DateTime', inplace=True)\n",
    "\n",
    "RBR_1230_geo = pd.merge_asof(RBR_1230, GPS_gdf,\n",
    "                             left_index=True, right_index=True,  direction='nearest', tolerance=pd.Timedelta('60s'))\n",
    "RBR_1230_geo = gp.GeoDataFrame(RBR_1230_geo, geometry=RBR_1230_geo.geometry, crs=\"EPSG:4326\")\n",
    "# Convert to UTM\n",
    "RBR_1230_geo.geometry = RBR_1230_geo.geometry.to_crs(\"EPSG:32620\")\n",
    "\n",
    "RBR_1552['DateTime'] = pd.to_datetime(RBR_1552['Time'])\n",
    "RBR_1552.set_index('DateTime', inplace=True)\n",
    "\n",
    "RBR_1552_geo = pd.merge_asof(RBR_1552, GPSswim_gdf,\n",
    "                             left_index=True, right_index=True,  direction='nearest', tolerance=pd.Timedelta('60s'))\n",
    "RBR_1552_geo = gp.GeoDataFrame(RBR_1552_geo, geometry=RBR_1552_geo.geometry, crs=\"EPSG:4326\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "pycharm": {
     "name": "#%% Merge GPS to JFE\n"
    }
   },
   "outputs": [],
   "source": [
    "# Process JFE into datetime\n",
    "JFE_4612['DateTime'] = pd.to_datetime(JFE_4612['Date'])\n",
    "JFE_4612.set_index('DateTime', inplace=True)\n",
    "\n",
    "JFE_4612_geo = pd.merge_asof(JFE_4612, GPS_gdf, left_index=True, right_index=True,  direction='nearest', tolerance=pd.Timedelta('60s'))\n",
    "JFE_4612_geo = gp.GeoDataFrame(JFE_4612_geo, geometry=JFE_4612_geo.geometry, crs=\"EPSG:4326\")\n",
    "JFE_4612_geo.geometry = JFE_4612_geo.geometry.to_crs(\"EPSG:32620\")\n",
    "\n",
    "JFE_5412['DateTime'] = pd.to_datetime(JFE_5412['Date'])\n",
    "JFE_5412.set_index('DateTime', inplace=True)\n",
    "\n",
    "JFE_5412_geo = pd.merge_asof(JFE_5412, GPSswim_gdf, left_index=True, right_index=True,  direction='nearest', tolerance=pd.Timedelta('60s'))\n",
    "JFE_5412_geo = gp.GeoDataFrame(JFE_5412_geo, geometry=JFE_5412_geo.geometry, crs=\"EPSG:4326\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {
    "pycharm": {
     "name": "#%% Plot Points\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": "<Figure size 720x432 with 8 Axes>",
      "image/png": "[encoded data, 202436 characters]\n"
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "mapbox = 'https://api.mapbox.com/styles/v1/alexander0042/ckemxgtk51fgp19nybfmdcb1e/tiles/256/{z}/{x}/{y}@2x?access_token=pk.eyJ1IjoiYWxleGFuZGVyMDA0MiIsImEiOiJjazVmdG4zbncwMHY4M2VrcThwZGUzZDFhIn0.w6oDHoo1eCeRlSBpwzwVtw'\n",
    "mapbox = 'https://api.mapbox.com/styles/v1/alexander0042/ckekcw3pn08am19qmqbhtq8sb/tiles/256/{z}/{x}/{y}@2x?access_token=pk.eyJ1IjoiYWxleGFuZGVyMDA0MiIsImEiOiJjazVmdG4zbncwMHY4M2VrcThwZGUzZDFhIn0.w6oDHoo1eCeRlSBpwzwVtw'\n",
    "\n",
    "fig, axes = plt.subplots(nrows=2, ncols=2, figsize=(10, 6))\n",
    "fig.patch.set_facecolor('white')\n",
    "fig.tight_layout(pad=4)\n",
    "\n",
    "axXlim = (RBR_1230_geo.loc['2021-09-15 09:41:00':'2021-09-15 11:24:00'].geometry.x.min()-100,\n",
    "                 RBR_1230_geo.loc['2021-09-15 09:41:00':'2021-09-15 11:24:00'].geometry.x.max()+100)\n",
    "axYlim = (RBR_1230_geo.loc['2021-09-15 09:41:00':'2021-09-15 11:24:00'].geometry.y.min()-100,\n",
    "                 RBR_1230_geo.loc['2021-09-15 09:41:00':'2021-09-15 11:24:00'].geometry.y.max()+100)\n",
    "\n",
    "fontprops = fm.FontProperties(size=9)\n",
    "x, y, arrow_length = 0.95, 0.93, 0.20\n",
    "\n",
    "plt.setp(axes, xlim=axXlim, ylim=axYlim)\n",
    "\n",
    "# Salinity\n",
    "ctx.add_basemap(axes[0, 0], source=mapbox, crs='EPSG:32620')\n",
    "RBR_1230_geo.loc['2021-09-15 09:41:00':'2021-09-15 11:24:00'].plot(\n",
    "                            column='Salinity ', ax=axes[0, 0], vmin=33.5, vmax=34,\n",
    "                            legend=True, legend_kwds={'label': \"Salinity [PSU]\"},\n",
    "                            cmap='cividis', markersize=6) # Note the space in the col name\n",
    "axes[0, 0].set_title('Salinity')\n",
    "axes[0, 0].set_ylabel('UTM 20N [m]')\n",
    "axes[0, 0].set_xlabel('UTM 20N [m]')\n",
    "#Add scale-bar\n",
    "scalebar = AnchoredSizeBar(axes[0, 0].transData,\n",
    "                           100, '100 m', 'lower right', pad=0.5, size_vertical=10, fontproperties=fontprops)\n",
    "axes[0, 0].add_artist(scalebar)\n",
    "axes[0, 0].annotate('N', xy=(x, y), xytext=(x, y-arrow_length),\n",
    "            arrowprops=dict(facecolor='black', width=2, headwidth=6),\n",
    "            ha='center', va='center', fontsize=13,\n",
    "            xycoords=axes[0, 0].transAxes)\n",
    "\n",
    "# Temperature\n",
    "ctx.add_basemap(axes[0, 1], source=mapbox, crs='EPSG:32620')\n",
    "RBR_1230_geo.loc['2021-09-15 09:41:00':'2021-09-15 11:24:00'].plot(\n",
    "                            column='Temperature ', ax=axes[0, 1], vmin=29.5, vmax=30.5,\n",
    "                            legend=True, legend_kwds={'label': \"Temperature [degC]\"},\n",
    "                            cmap=cmo.thermal, markersize=6) # Note the space in the col name\n",
    "axes[0, 1].set_title('Temperature')\n",
    "axes[0, 1].set_ylabel('UTM 20N [m]')\n",
    "axes[0, 1].set_xlabel('UTM 20N [m]')\n",
    "#Add scale-bar\n",
    "scalebar = AnchoredSizeBar(axes[0, 1].transData,\n",
    "                           100, '100 m', 'lower right', pad=0.5, size_vertical=10, fontproperties=fontprops)\n",
    "axes[0, 1].add_artist(scalebar)\n",
    "axes[0, 1].annotate('N', xy=(x, y), xytext=(x, y-arrow_length),\n",
    "            arrowprops=dict(facecolor='black', width=2, headwidth=6),\n",
    "            ha='center', va='center', fontsize=13,\n",
    "            xycoords=axes[0, 1].transAxes)\n",
    "\n",
    "# Dissolved O₂ saturation\n",
    "ctx.add_basemap(axes[1, 0], source=mapbox, crs='EPSG:32620')\n",
    "RBR_1230_geo.loc['2021-09-15 09:41:00':'2021-09-15 11:24:00'].plot(\n",
    "                            column='Dissolved O₂ saturation ', ax=axes[1, 0], vmin=33, vmax=33.5,\n",
    "                            legend=True, legend_kwds={'label': \"Dissolved O₂ saturation [%]\"},\n",
    "                            cmap=cmo.dense, markersize=6) # Note the space in the col name\n",
    "axes[1, 0].set_title('Dissolved O₂ saturation')\n",
    "axes[1, 0].set_ylabel('UTM 20N [m]')\n",
    "axes[1, 0].set_xlabel('UTM 20N [m]')\n",
    "#Add scale-bar\n",
    "scalebar = AnchoredSizeBar(axes[1, 0].transData,\n",
    "                           100, '100 m', 'lower right', pad=0.5, size_vertical=10, fontproperties=fontprops)\n",
    "axes[1, 0].add_artist(scalebar)\n",
    "axes[1, 0].annotate('N', xy=(x, y), xytext=(x, y-arrow_length),\n",
    "            arrowprops=dict(facecolor='black', width=2, headwidth=6),\n",
    "            ha='center', va='center', fontsize=13,\n",
    "            xycoords=axes[1, 0].transAxes)\n",
    "\n",
    "# Depth\n",
    "ctx.add_basemap(axes[1, 1], source=mapbox, crs='EPSG:32620')\n",
    "RBR_1230_geo.loc['2021-09-15 09:41:00':'2021-09-15 11:24:00'].plot(\n",
    "                            column='Depth ', ax=axes[1, 1], vmin=0, vmax=4,\n",
    "                            legend=True, legend_kwds={'label': \"Depth [m]\"},\n",
    "                            cmap=cmo.deep, markersize=6) # Note the space in the col name\n",
    "axes[1, 1].set_title('Depth')\n",
    "axes[1, 1].set_ylabel('UTM 20N [m]')\n",
    "axes[1, 1].set_xlabel('UTM 20N [m]')\n",
    "#Add scale-bar\n",
    "scalebar = AnchoredSizeBar(axes[1, 1].transData,\n",
    "                           100, '100 m', 'lower right', pad=0.5, size_vertical=10, fontproperties=fontprops)\n",
    "axes[1, 1].add_artist(scalebar)\n",
    "axes[1, 1].annotate('N', xy=(x, y), xytext=(x, y-arrow_length),\n",
    "            arrowprops=dict(facecolor='black', width=2, headwidth=6),\n",
    "            ha='center', va='center', fontsize=13,\n",
    "            xycoords=axes[1, 1].transAxes)\n",
    "\n",
    "plt.show()\n",
    "fig.savefig('C:/Users/arey/files/Projects/Mustique/Figures/RBR_Map.pdf',\n",
    "             bbox_inches='tight')\n",
    "\n",
    "fig.savefig('C:/Users/arey/files/Projects/Mustique/Figures/RBR_Map.png',\n",
    "             bbox_inches='tight', dpi=500)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {
    "pycharm": {
     "name": "#%% Plot JFE Points\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": "<Figure size 720x432 with 8 Axes>",
      "image/png": "[encoded data, 201060 characters]\n"
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "mapbox = 'https://api.mapbox.com/styles/v1/alexander0042/ckemxgtk51fgp19nybfmdcb1e/tiles/256/{z}/{x}/{y}@2x?access_token=pk.eyJ1IjoiYWxleGFuZGVyMDA0MiIsImEiOiJjazVmdG4zbncwMHY4M2VrcThwZGUzZDFhIn0.w6oDHoo1eCeRlSBpwzwVtw'\n",
    "mapbox = 'https://api.mapbox.com/styles/v1/alexander0042/ckekcw3pn08am19qmqbhtq8sb/tiles/256/{z}/{x}/{y}@2x?access_token=pk.eyJ1IjoiYWxleGFuZGVyMDA0MiIsImEiOiJjazVmdG4zbncwMHY4M2VrcThwZGUzZDFhIn0.w6oDHoo1eCeRlSBpwzwVtw'\n",
    "\n",
    "fig, axes = plt.subplots(nrows=2, ncols=2, figsize=(10, 6))\n",
    "fig.patch.set_facecolor('white')\n",
    "fig.tight_layout(pad=4)\n",
    "\n",
    "axXlim = (JFE_4612_geo.loc['2021-09-15 09:41:00':'2021-09-15 11:24:00'].geometry.x.min()-100,\n",
    "                 JFE_4612_geo.loc['2021-09-15 09:41:00':'2021-09-15 11:24:00'].geometry.x.max()+100)\n",
    "axYlim = (JFE_4612_geo.loc['2021-09-15 09:41:00':'2021-09-15 11:24:00'].geometry.y.min()-100,\n",
    "                 JFE_4612_geo.loc['2021-09-15 09:41:00':'2021-09-15 11:24:00'].geometry.y.max()+100)\n",
    "\n",
    "fontprops = fm.FontProperties(size=9)\n",
    "x, y, arrow_length = 0.95, 0.93, 0.20\n",
    "\n",
    "plt.setp(axes, xlim=axXlim, ylim=axYlim)\n",
    "\n",
    "\n",
    "# # Salinity\n",
    "# ctx.add_basemap(axes[0, 0], source=mapbox, crs='EPSG:32620')\n",
    "# JFE_4612_geo.loc['2021-09-15 09:41:00':'2021-09-15 11:24:00'].plot(\n",
    "#                             column='Salinity ', ax=axes[0, 0], vmin=33.5, vmax=34,\n",
    "#                             legend=True, legend_kwds={'label': \"Salinity [PSU]\"},\n",
    "#                             cmap='cividis') # Note the space in the col name\n",
    "# axes[0, 0].set_title('Conductivity')\n",
    "# Chl-a\n",
    "ctx.add_basemap(axes[0, 0], source=mapbox, crs='EPSG:32620')\n",
    "JFE_4612_geo.loc['2021-09-15 09:41:00':'2021-09-15 11:24:00'].plot(\n",
    "                            column='Chl-a[ug/l]', ax=axes[0, 0], vmin=0, vmax=1,\n",
    "                            legend=True, legend_kwds={'label': \"Chl-a[ug/l]\"},\n",
    "                            cmap=cmo.algae, markersize=6)# Note the space in the col name\n",
    "axes[0, 0].set_title('Chl-a')\n",
    "axes[0, 0].set_ylabel('UTM 20N [m]')\n",
    "axes[0, 0].set_xlabel('UTM 20N [m]')\n",
    "#Add scale-bar\n",
    "scalebar = AnchoredSizeBar(axes[0, 0].transData,\n",
    "                           100, '100 m', 'lower right', pad=0.5, size_vertical=10, fontproperties=fontprops)\n",
    "axes[0, 0].add_artist(scalebar)\n",
    "axes[0, 0].annotate('N', xy=(x, y), xytext=(x, y-arrow_length),\n",
    "            arrowprops=dict(facecolor='black', width=2, headwidth=6),\n",
    "            ha='center', va='center', fontsize=13,\n",
    "            xycoords=axes[0, 0].transAxes)\n",
    "\n",
    "# Temperature\n",
    "ctx.add_basemap(axes[0, 1], source=mapbox, crs='EPSG:32620')\n",
    "JFE_4612_geo.loc['2021-09-15 09:41:00':'2021-09-15 11:24:00'].plot(\n",
    "                            column='Temp.[deg C]', ax=axes[0, 1], vmin=29.5, vmax=30.5,\n",
    "                            legend=True, legend_kwds={'label': \"Temperature [degC]\"},\n",
    "                            cmap=cmo.thermal, markersize=6) # Note the space in the col name\n",
    "axes[0, 1].set_title('Temperature')\n",
    "axes[0, 1].set_ylabel('UTM 20N [m]')\n",
    "axes[0, 1].set_xlabel('UTM 20N [m]')\n",
    "#Add scale-bar\n",
    "scalebar = AnchoredSizeBar(axes[0, 1].transData,\n",
    "                           100, '100 m', 'lower right', pad=0.5, size_vertical=10, fontproperties=fontprops)\n",
    "axes[0, 1].add_artist(scalebar)\n",
    "axes[0, 1].annotate('N', xy=(x, y), xytext=(x, y-arrow_length),\n",
    "            arrowprops=dict(facecolor='black', width=2, headwidth=6),\n",
    "            ha='center', va='center', fontsize=13,\n",
    "            xycoords=axes[0, 1].transAxes)\n",
    "\n",
    "# Chl-Flu\n",
    "ctx.add_basemap(axes[1, 0], source=mapbox, crs='EPSG:32620')\n",
    "JFE_4612_geo.loc['2021-09-15 09:41:00':'2021-09-15 11:24:00'].plot(\n",
    "                            column='Chl-Flu.[ppb]', ax=axes[1, 0], vmin=0, vmax=1,\n",
    "                            legend=True, legend_kwds={'label': \"Chl-Flu.[ppb]\"},\n",
    "                            cmap=cmo.algae, markersize=6)# Note the space in the col name\n",
    "axes[1, 0].set_title('Chl-Flu')\n",
    "axes[1, 0].set_ylabel('UTM 20N [m]')\n",
    "axes[1, 0].set_xlabel('UTM 20N [m]')\n",
    "#Add scale-bar\n",
    "scalebar = AnchoredSizeBar(axes[1, 0].transData,\n",
    "                           100, '100 m', 'lower right', pad=0.5, size_vertical=10, fontproperties=fontprops)\n",
    "axes[1, 0].add_artist(scalebar)\n",
    "axes[1, 0].annotate('N', xy=(x, y), xytext=(x, y-arrow_length),\n",
    "            arrowprops=dict(facecolor='black', width=2, headwidth=6),\n",
    "            ha='center', va='center', fontsize=13,\n",
    "            xycoords=axes[1, 0].transAxes)\n",
    "\n",
    "# Turb\n",
    "ctx.add_basemap(axes[1, 1], source=mapbox, crs='EPSG:32620')\n",
    "JFE_4612_geo.loc['2021-09-15 09:41:00':'2021-09-15 11:24:00'].plot(\n",
    "                            column='Turb. -M[FTU]', ax=axes[1, 1], vmin=0, vmax=1,\n",
    "                            legend=True, legend_kwds={'label': \"Turb. -M[FTU]\"},\n",
    "                            cmap=cmo.turbid, markersize=6) # Note the space in the col name\n",
    "axes[1, 1].set_title('Turbidity')\n",
    "axes[1, 1].set_ylabel('UTM 20N [m]')\n",
    "axes[1, 1].set_xlabel('UTM 20N [m]')\n",
    "#Add scale-bar\n",
    "scalebar = AnchoredSizeBar(axes[1, 1].transData,\n",
    "                           100, '100 m', 'lower right', pad=0.5, size_vertical=10, fontproperties=fontprops)\n",
    "axes[1, 1].add_artist(scalebar)\n",
    "axes[1, 1].annotate('N', xy=(x, y), xytext=(x, y-arrow_length),\n",
    "            arrowprops=dict(facecolor='black', width=2, headwidth=6),\n",
    "            ha='center', va='center', fontsize=13,\n",
    "            xycoords=axes[1, 1].transAxes)\n",
    "\n",
    "\n",
    "plt.show()\n",
    "fig.savefig('C:/Users/arey/files/Projects/Mustique/Figures/JFE_Map.pdf',\n",
    "            bbox_inches='tight')\n",
    "\n",
    "fig.savefig('C:/Users/arey/files/Projects/Mustique/Figures/JFE_Map.png',\n",
    "             bbox_inches='tight', dpi=500)\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "outputs": [
    {
     "data": {
      "text/plain": "<Figure size 720x432 with 8 Axes>",
      "image/png": "[encoded data, 112296 characters]\n"
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "mapbox = 'https://api.mapbox.com/styles/v1/alexander0042/ckemxgtk51fgp19nybfmdcb1e/tiles/256/{z}/{x}/{y}@2x?access_token=pk.eyJ1IjoiYWxleGFuZGVyMDA0MiIsImEiOiJjazVmdG4zbncwMHY4M2VrcThwZGUzZDFhIn0.w6oDHoo1eCeRlSBpwzwVtw'\n",
    "mapbox = 'https://api.mapbox.com/styles/v1/alexander0042/ckekcw3pn08am19qmqbhtq8sb/tiles/256/{z}/{x}/{y}@2x?access_token=pk.eyJ1IjoiYWxleGFuZGVyMDA0MiIsImEiOiJjazVmdG4zbncwMHY4M2VrcThwZGUzZDFhIn0.w6oDHoo1eCeRlSBpwzwVtw'\n",
    "\n",
    "fig, axes = plt.subplots(nrows=2, ncols=2, figsize=(10, 6))\n",
    "fig.patch.set_facecolor('white')\n",
    "fig.tight_layout(pad=4.5)\n",
    "\n",
    "axXlim = (RBR_1552_geo.loc['2021-09-15 14:20:00':'2021-09-15 14:26:00'].geometry.x.min()-50,\n",
    "                 RBR_1552_geo.loc['2021-09-15 14:20:00':'2021-09-15 14:26:00'].geometry.x.max()+50)\n",
    "axYlim = (RBR_1552_geo.loc['2021-09-15 14:20:00':'2021-09-15 14:26:00'].geometry.y.min()-50,\n",
    "                 RBR_1552_geo.loc['2021-09-15 14:20:00':'2021-09-15 14:26:00'].geometry.y.max()+50)\n",
    "\n",
    "fontprops = fm.FontProperties(size=9)\n",
    "x, y, arrow_length = 0.95, 0.93, 0.20\n",
    "\n",
    "plt.setp(axes, xlim=axXlim, ylim=axYlim)\n",
    "\n",
    "\n",
    "# Salinity\n",
    "ctx.add_basemap(axes[0, 0], source=mapbox, crs='EPSG:32620')\n",
    "RBR_1552_geo.loc['2021-09-15 14:20:00':'2021-09-15 14:26:00'].plot(\n",
    "                            column='Salinity ', ax=axes[0, 0], vmin=33.5, vmax=34.5,\n",
    "                            legend=True, legend_kwds={'label': \"Salinity [PSU]\"},\n",
    "                            cmap='cividis', markersize=6, aspect=1) # Note the space in the col name\n",
    "axes[0, 0].set_title('Salinity\\n')\n",
    "axes[0, 0].set_ylabel('UTM 20N [m]')\n",
    "axes[0, 0].set_xlabel('UTM 20N [m]')\n",
    "#Add scale-bar\n",
    "scalebar = AnchoredSizeBar(axes[0, 0].transData,\n",
    "                           100, '100 m', 'lower right', pad=0.5, size_vertical=10, fontproperties=fontprops)\n",
    "axes[0, 0].add_artist(scalebar)\n",
    "axes[0, 0].annotate('N', xy=(x, y), xytext=(x, y-arrow_length),\n",
    "            arrowprops=dict(facecolor='black', width=2, headwidth=6),\n",
    "            ha='center', va='center', fontsize=13,\n",
    "            xycoords=axes[0, 0].transAxes)\n",
    "\n",
    "# Temperature\n",
    "ctx.add_basemap(axes[0, 1], source=mapbox, crs='EPSG:32620')\n",
    "RBR_1552_geo.loc['2021-09-15 14:20:00':'2021-09-15 14:26:00'].plot(\n",
    "                            column='Temperature ', ax=axes[0, 1], vmin=29.5, vmax=30.5,\n",
    "                            legend=True, legend_kwds={'label': \"Temperature [degC]\"},\n",
    "                            cmap=cmo.thermal, markersize=6, aspect=1) # Note the space in the col name\n",
    "axes[0, 1].set_title('Temperature\\n')\n",
    "axes[0, 1].set_ylabel('UTM 20N [m]')\n",
    "axes[0, 1].set_xlabel('UTM 20N [m]')\n",
    "#Add scale-bar\n",
    "scalebar = AnchoredSizeBar(axes[0, 1].transData,\n",
    "                           100, '100 m', 'lower right', pad=0.5, size_vertical=10, fontproperties=fontprops)\n",
    "axes[0, 1].add_artist(scalebar)\n",
    "axes[0, 1].annotate('N', xy=(x, y), xytext=(x, y-arrow_length),\n",
    "            arrowprops=dict(facecolor='black', width=2, headwidth=6),\n",
    "            ha='center', va='center', fontsize=13,\n",
    "            xycoords=axes[0, 1].transAxes)\n",
    "\n",
    "# Dissolved O₂ saturation\n",
    "ctx.add_basemap(axes[1, 0], source=mapbox, crs='EPSG:32620')\n",
    "RBR_1552_geo.loc['2021-09-15 14:20:00':'2021-09-15 14:26:00'].plot(\n",
    "                            column='Dissolved O₂ saturation ', ax=axes[1, 0], vmin=33, vmax=33.5,\n",
    "                            legend=True, legend_kwds={'label': \"Dissolved O₂ saturation [%]\"},\n",
    "                            cmap=cmo.dense, markersize=6, aspect=1) # Note the space in the col name\n",
    "axes[1, 0].set_title('Dissolved O₂ saturation\\n')\n",
    "axes[1, 0].set_ylabel('UTM 20N [m]')\n",
    "axes[1, 0].set_xlabel('UTM 20N [m]')\n",
    "#Add scale-bar\n",
    "scalebar = AnchoredSizeBar(axes[1, 0].transData,\n",
    "                           100, '100 m', 'lower right', pad=0.5, size_vertical=10, fontproperties=fontprops)\n",
    "axes[1, 0].add_artist(scalebar)\n",
    "axes[1, 0].annotate('N', xy=(x, y), xytext=(x, y-arrow_length),\n",
    "            arrowprops=dict(facecolor='black', width=2, headwidth=6),\n",
    "            ha='center', va='center', fontsize=13,\n",
    "            xycoords=axes[1, 0].transAxes)\n",
    "\n",
    "# Depth\n",
    "ctx.add_basemap(axes[1, 1], source=mapbox, crs='EPSG:32620')\n",
    "RBR_1552_geo.loc['2021-09-15 14:20:00':'2021-09-15 14:26:00'].plot(\n",
    "                            column='Depth ', ax=axes[1, 1], vmin=0, vmax=4,\n",
    "                            legend=True, legend_kwds={'label': \"Depth [m]\"},\n",
    "                            cmap=cmo.deep, markersize=6, aspect=1) # Note the space in the col name\n",
    "axes[1, 1].set_title('Depth\\n')\n",
    "axes[1, 1].set_ylabel('UTM 20N [m]')\n",
    "axes[1, 1].set_xlabel('UTM 20N [m]')\n",
    "#Add scale-bar\n",
    "scalebar = AnchoredSizeBar(axes[1, 1].transData,\n",
    "                           100, '100 m', 'lower right', pad=0.5, size_vertical=10, fontproperties=fontprops)\n",
    "axes[1, 1].add_artist(scalebar)\n",
    "axes[1, 1].annotate('N', xy=(x, y), xytext=(x, y-arrow_length),\n",
    "            arrowprops=dict(facecolor='black', width=2, headwidth=6),\n",
    "            ha='center', va='center', fontsize=13,\n",
    "            xycoords=axes[1, 1].transAxes)\n",
    "\n",
    "plt.show()\n",
    "fig.savefig('C:/Users/arey/files/Projects/Mustique/Figures/RBR_Baseline_Map.pdf',\n",
    "             bbox_inches='tight')\n",
    "\n",
    "fig.savefig('C:/Users/arey/files/Projects/Mustique/Figures/RBR_Baseline_Map.png',\n",
    "             bbox_inches='tight', dpi=500)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% Plot RBR Kevin Swim Points\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "outputs": [
    {
     "data": {
      "text/plain": "<Figure size 720x432 with 8 Axes>",
      "image/png": "[encoded data, 107700 characters]\n"
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "mapbox = 'https://api.mapbox.com/styles/v1/alexander0042/ckemxgtk51fgp19nybfmdcb1e/tiles/256/{z}/{x}/{y}@2x?access_token=pk.eyJ1IjoiYWxleGFuZGVyMDA0MiIsImEiOiJjazVmdG4zbncwMHY4M2VrcThwZGUzZDFhIn0.w6oDHoo1eCeRlSBpwzwVtw'\n",
    "mapbox = 'https://api.mapbox.com/styles/v1/alexander0042/ckekcw3pn08am19qmqbhtq8sb/tiles/256/{z}/{x}/{y}@2x?access_token=pk.eyJ1IjoiYWxleGFuZGVyMDA0MiIsImEiOiJjazVmdG4zbncwMHY4M2VrcThwZGUzZDFhIn0.w6oDHoo1eCeRlSBpwzwVtw'\n",
    "\n",
    "fig, axes = plt.subplots(nrows=2, ncols=2, figsize=(10, 6))\n",
    "fig.patch.set_facecolor('white')\n",
    "fig.tight_layout(pad=4.5)\n",
    "\n",
    "axXlim = (RBR_1552_geo.loc['2021-09-15 14:20:00':'2021-09-15 14:26:00'].geometry.x.min()-50,\n",
    "                 RBR_1552_geo.loc['2021-09-15 14:20:00':'2021-09-15 14:26:00'].geometry.x.max()+50)\n",
    "axYlim = (RBR_1552_geo.loc['2021-09-15 14:20:00':'2021-09-15 14:26:00'].geometry.y.min()-50,\n",
    "                 RBR_1552_geo.loc['2021-09-15 14:20:00':'2021-09-15 14:26:00'].geometry.y.max()+50)\n",
    "\n",
    "fontprops = fm.FontProperties(size=9)\n",
    "x, y, arrow_length = 0.95, 0.93, 0.20\n",
    "\n",
    "plt.setp(axes, xlim=axXlim, ylim=axYlim)\n",
    "\n",
    "\n",
    "# # Salinity\n",
    "# ctx.add_basemap(axes[0, 0], source=mapbox, crs='EPSG:32620')\n",
    "# JFE_4612_geo.loc['2021-09-15 09:41:00':'2021-09-15 11:24:00'].plot(\n",
    "#                             column='Salinity ', ax=axes[0, 0], vmin=33.5, vmax=34,\n",
    "#                             legend=True, legend_kwds={'label': \"Salinity [PSU]\"},\n",
    "#                             cmap='cividis') # Note the space in the col name\n",
    "# axes[0, 0].set_title('Conductivity')\n",
    "# Chl-a\n",
    "ctx.add_basemap(axes[0, 0], source=mapbox, crs='EPSG:32620')\n",
    "JFE_5412_geo.loc['2021-09-15 14:20:00':'2021-09-15 14:26:00'].plot(\n",
    "                            column='Chl-a[ug/l]', ax=axes[0, 0], vmin=0, vmax=1,\n",
    "                            legend=True, legend_kwds={'label': \"Chl-a[ug/l]\"},\n",
    "                            cmap=cmo.algae, markersize=6, aspect=1)# Note the space in the col name\n",
    "axes[0, 0].set_title('Chl-a\\n')\n",
    "axes[0, 0].set_ylabel('UTM 20N [m]')\n",
    "axes[0, 0].set_xlabel('UTM 20N [m]')\n",
    "#Add scale-bar\n",
    "scalebar = AnchoredSizeBar(axes[0, 0].transData,\n",
    "                           100, '100 m', 'lower right', pad=0.5, size_vertical=10, fontproperties=fontprops)\n",
    "axes[0, 0].add_artist(scalebar)\n",
    "axes[0, 0].annotate('N', xy=(x, y), xytext=(x, y-arrow_length),\n",
    "            arrowprops=dict(facecolor='black', width=2, headwidth=6),\n",
    "            ha='center', va='center', fontsize=13,\n",
    "            xycoords=axes[0, 0].transAxes)\n",
    "\n",
    "# Temperature\n",
    "ctx.add_basemap(axes[0, 1], source=mapbox, crs='EPSG:32620')\n",
    "JFE_5412_geo.loc['2021-09-15 14:20:00':'2021-09-15 14:26:00'].plot(\n",
    "                            column='Temp.[deg C]', ax=axes[0, 1], vmin=29.5, vmax=30.5,\n",
    "                            legend=True, legend_kwds={'label': \"Temperature [degC]\"},\n",
    "                            cmap=cmo.thermal, markersize=6, aspect=1) # Note the space in the col name\n",
    "axes[0, 1].set_title('Temperature\\n')\n",
    "axes[0, 1].set_ylabel('UTM 20N [m]')\n",
    "axes[0, 1].set_xlabel('UTM 20N [m]')\n",
    "#Add scale-bar\n",
    "scalebar = AnchoredSizeBar(axes[0, 1].transData,\n",
    "                           100, '100 m', 'lower right', pad=0.5, size_vertical=10, fontproperties=fontprops)\n",
    "axes[0, 1].add_artist(scalebar)\n",
    "axes[0, 1].annotate('N', xy=(x, y), xytext=(x, y-arrow_length),\n",
    "            arrowprops=dict(facecolor='black', width=2, headwidth=6),\n",
    "            ha='center', va='center', fontsize=13,\n",
    "            xycoords=axes[0, 1].transAxes)\n",
    "\n",
    "# Chl-Flu\n",
    "ctx.add_basemap(axes[1, 0], source=mapbox, crs='EPSG:32620')\n",
    "JFE_5412_geo.loc['2021-09-15 14:20:00':'2021-09-15 14:26:00'].plot(\n",
    "                            column='Chl-Flu.[ppb]', ax=axes[1, 0], vmin=0, vmax=1,\n",
    "                            legend=True, legend_kwds={'label': \"Chl-Flu.[ppb]\"},\n",
    "                            cmap=cmo.algae, markersize=6, aspect=1)# Note the space in the col name\n",
    "axes[1, 0].set_title('Chl-Flu\\n')\n",
    "axes[1, 0].set_ylabel('UTM 20N [m]')\n",
    "axes[1, 0].set_xlabel('UTM 20N [m]')\n",
    "#Add scale-bar\n",
    "scalebar = AnchoredSizeBar(axes[1, 0].transData,\n",
    "                           100, '100 m', 'lower right', pad=0.5, size_vertical=10, fontproperties=fontprops)\n",
    "axes[1, 0].add_artist(scalebar)\n",
    "axes[1, 0].annotate('N', xy=(x, y), xytext=(x, y-arrow_length),\n",
    "            arrowprops=dict(facecolor='black', width=2, headwidth=6),\n",
    "            ha='center', va='center', fontsize=13,\n",
    "            xycoords=axes[1, 0].transAxes)\n",
    "\n",
    "# Turb\n",
    "ctx.add_basemap(axes[1, 1], source=mapbox, crs='EPSG:32620')\n",
    "JFE_5412_geo.loc['2021-09-15 14:20:00':'2021-09-15 14:26:00'].plot(\n",
    "                            column='Turb. -M[FTU]', ax=axes[1, 1], vmin=0, vmax=1,\n",
    "                            legend=True, legend_kwds={'label': \"Turb. -M[FTU]\"},\n",
    "                            cmap=cmo.turbid, markersize=6, aspect=1) # Note the space in the col name\n",
    "axes[1, 1].set_title('Turbidity\\n')\n",
    "axes[1, 1].set_ylabel('UTM 20N [m]')\n",
    "axes[1, 1].set_xlabel('UTM 20N [m]')\n",
    "#Add scale-bar\n",
    "scalebar = AnchoredSizeBar(axes[1, 1].transData,\n",
    "                           100, '100 m', 'lower right', pad=0.5, size_vertical=10, fontproperties=fontprops)\n",
    "axes[1, 1].add_artist(scalebar)\n",
    "axes[1, 1].annotate('N', xy=(x, y), xytext=(x, y-arrow_length),\n",
    "            arrowprops=dict(facecolor='black', width=2, headwidth=6),\n",
    "            ha='center', va='center', fontsize=13,\n",
    "            xycoords=axes[1, 1].transAxes)\n",
    "\n",
    "\n",
    "plt.show()\n",
    "fig.savefig('C:/Users/arey/files/Projects/Mustique/Figures/JFE_Baseline_Map.pdf',\n",
    "            bbox_inches='tight')\n",
    "\n",
    "fig.savefig('C:/Users/arey/files/Projects/Mustique/Figures/JFE_Baseline_Map.png',\n",
    "             bbox_inches='tight', dpi=500)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% Plot JFE Kevin Swim Points\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {
    "pycharm": {
     "name": "#%% Plot Swimming Points\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": "<Figure size 720x432 with 2 Axes>",
      "image/png": "[encoded data, 213000 characters]\n"
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# mapbox = 'https://api.mapbox.com/styles/v1/alexander0042/ckemxgtk51fgp19nybfmdcb1e/tiles/256/{z}/{x}/{y}@2x?access_token=pk.eyJ1IjoiYWxleGFuZGVyMDA0MiIsImEiOiJjazVmdG4zbncwMHY4M2VrcThwZGUzZDFhIn0.w6oDHoo1eCeRlSBpwzwVtw'\n",
    "mapbox = 'https://api.mapbox.com/styles/v1/alexander0042/ckekcw3pn08am19qmqbhtq8sb/tiles/256/{z}/{x}/{y}@2x?access_token=pk.eyJ1IjoiYWxleGFuZGVyMDA0MiIsImEiOiJjazVmdG4zbncwMHY4M2VrcThwZGUzZDFhIn0.w6oDHoo1eCeRlSBpwzwVtw'\n",
    "\n",
    "fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(10, 6))\n",
    "fig.patch.set_facecolor('white')\n",
    "fig.tight_layout(pad=4)\n",
    "\n",
    "axXlim2 = (JFE_4612_geo.loc['2021-09-15 09:41:00':'2021-09-15 11:24:00'].geometry.x.min()-100,\n",
    "                 JFE_4612_geo.loc['2021-09-15 09:41:00':'2021-09-15 11:24:00'].geometry.x.max()+100)\n",
    "axYlim2 = (JFE_4612_geo.loc['2021-09-15 09:41:00':'2021-09-15 11:24:00'].geometry.y.min()-100,\n",
    "                 JFE_4612_geo.loc['2021-09-15 09:41:00':'2021-09-15 11:24:00'].geometry.y.max()+100)\n",
    "axXlim1 = (JFE_4612_geo.loc['2021-09-14 09:41:00':'2021-09-15 11:24:00'].geometry.x.min()-600,\n",
    "                 JFE_4612_geo.loc['2021-09-14 09:41:00':'2021-09-15 11:24:00'].geometry.x.max()+300)\n",
    "axYlim1 = (JFE_4612_geo.loc['2021-09-14 09:41:00':'2021-09-15 11:24:00'].geometry.y.min()-200,\n",
    "                 JFE_4612_geo.loc['2021-09-14 09:41:00':'2021-09-15 11:24:00'].geometry.y.max()+500)\n",
    "\n",
    "fontprops = fm.FontProperties(size=9)\n",
    "\n",
    "plt.setp(axes, xlim=axXlim, ylim=axYlim)\n",
    "\n",
    "lineStringObj = LineString( [[a.x, a.y] for a in GPSswim_gdf.geometry.values] )\n",
    "line_df = pd.DataFrame()\n",
    "line_df['Attrib'] = [1,]\n",
    "line_gdf = gp.GeoDataFrame(line_df, geometry=[lineStringObj,])\n",
    "\n",
    "ctx.add_basemap(axes[0], source=mapbox, crs='EPSG:32620')\n",
    "line_gdf.plot(ax=axes[0], markersize=6)# Note the space in the col name\n",
    "axes[0].set_title('Swimming Route')\n",
    "axes[0].set_ylabel('UTM 20N [m]')\n",
    "axes[0].set_xlabel('UTM 20N [m]')\n",
    "axes[0].set_ylim(axYlim1)\n",
    "axes[0].set_xlim(axXlim1)\n",
    "\n",
    "\n",
    "#Add scale-bar\n",
    "scalebar = AnchoredSizeBar(axes[0].transData, 100, '100 m', 'lower right', pad=0.5, size_vertical=10, fontproperties=fontprops)\n",
    "axes[0].add_artist(scalebar)\n",
    "axes[0].annotate('N', xy=(x, y), xytext=(x, y-arrow_length),\n",
    "            arrowprops=dict(facecolor='black', width=2, headwidth=6),\n",
    "            ha='center', va='center', fontsize=13,\n",
    "            xycoords=axes[0].transAxes)\n",
    "\n",
    "axes[0].locator_params(axis='x', nbins=6)\n",
    "\n",
    "# Swimming points\n",
    "lineStringObj = LineString( [[a.x, a.y] for a in GPSpictures_gdf.geometry.values] )\n",
    "line_df = pd.DataFrame()\n",
    "line_df['Attrib'] = [1,]\n",
    "line_gdf = gp.GeoDataFrame(line_df, geometry=[lineStringObj,])\n",
    "\n",
    "ctx.add_basemap(axes[1], source=mapbox, crs='EPSG:32620')\n",
    "line_gdf.plot(ax=axes[1], markersize=6)# Note the space in the col name\n",
    "axes[1].set_title('Photos Route')\n",
    "axes[1].set_ylabel('UTM 20N [m]')\n",
    "axes[1].set_xlabel('UTM 20N [m]')\n",
    "axes[1].set_ylim(axYlim2)\n",
    "axes[1].set_xlim(axXlim2)\n",
    "\n",
    "#Add scale-bar\n",
    "scalebar = AnchoredSizeBar(axes[1].transData, 100, '100 m', 'lower right', pad=0.5, size_vertical=10, fontproperties=fontprops)\n",
    "axes[1].add_artist(scalebar)\n",
    "axes[1].annotate('N', xy=(x, y), xytext=(x, y-arrow_length),\n",
    "            arrowprops=dict(facecolor='black', width=2, headwidth=6),\n",
    "            ha='center', va='center', fontsize=13,\n",
    "            xycoords=axes[1].transAxes)\n",
    "\n",
    "axes[1].locator_params(axis='x', nbins=6)\n",
    "\n",
    "plt.show()\n",
    "\n",
    "fig.savefig('C:/Users/arey/files/Projects/Mustique/Figures/GPS_Map.pdf',\n",
    "            bbox_inches='tight')\n",
    "\n",
    "fig.savefig('C:/Users/arey/files/Projects/Mustique/Figures/GPS_Map.png',\n",
    "             bbox_inches='tight', dpi=500)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "metadata": {
    "pycharm": {
     "name": "#%% Plot time series for Geo data\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": "<Figure size 864x1080 with 7 Axes>",
      "image/png": "[encoded data, 235696 characters]\n"
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig, axes = plt.subplots(nrows=7, ncols=1, figsize=(12, 15))\n",
    "fig.patch.set_facecolor('white')\n",
    "fig.tight_layout(pad=3)\n",
    "\n",
    "RBRparam = ['Depth ', 'Salinity ', 'Dissolved O₂ saturation ', 'Temperature ']\n",
    "RBRparamName = ['Depth [m]', 'Salinity [PSU]', 'Dissolved O₂ saturation [%]', 'Temperature [degC]']\n",
    "dataTable = np.zeros([7, 4])\n",
    "\n",
    "for paramIDX, param in enumerate(RBRparam):\n",
    "    RBR_1230.loc['2021-09-15 09:44:00':'2021-09-15 11:24:00', param].plot(\n",
    "                    ax=axes[paramIDX], label='1 Second Observations') # Note the space in the col name\n",
    "    RBR_1230.loc['2021-09-15 09:44:00':'2021-09-15 11:24:00', param].rolling(\n",
    "            '900s').mean().plot(\n",
    "            ax=axes[paramIDX], label='15 Minute Average') # Note the space in the col name\n",
    "\n",
    "    dataTable[paramIDX, 0] = RBR_1230.loc['2021-09-15 09:44:00':'2021-09-15 11:24:00', param].mean(skipna=True)\n",
    "    dataTable[paramIDX, 1] = RBR_1230.loc['2021-09-15 09:44:00':'2021-09-15 11:24:00', param].std(skipna=True)\n",
    "    dataTable[paramIDX, 2] = RBR_1230.loc['2021-09-15 09:44:00':'2021-09-15 11:24:00', param].min(skipna=True)\n",
    "    dataTable[paramIDX, 3] = RBR_1230.loc['2021-09-15 09:44:00':'2021-09-15 11:24:00', param].max(skipna=True)\n",
    "\n",
    "    axes[paramIDX].set_ylabel(RBRparamName[paramIDX])\n",
    "    axes[paramIDX].set_title('RBR: ' + RBRparamName[paramIDX])\n",
    "    axes[paramIDX].set_xlabel('')\n",
    "    axes[paramIDX].legend(loc='upper right')\n",
    "\n",
    "JFEparam     = ['Temp.[deg C]', 'Chl-Flu.[ppb]', 'Turb. -M[FTU]']\n",
    "JFEparamName = ['Temperature [degC]', 'Chl-Flu. [ppb]', 'Turbidity [FTU]']\n",
    "\n",
    "for paramIDX, param in enumerate(JFEparam):\n",
    "    JFE_4612.loc['2021-09-15 09:44:00':'2021-09-15 11:24:00', param].plot(\n",
    "                    ax=axes[paramIDX+4], label='15 Second Observations') # Note the space in the col name\n",
    "    JFE_4612.loc['2021-09-15 09:44:00':'2021-09-15 11:24:00', param].rolling(\n",
    "                '900s').mean().plot(\n",
    "                ax=axes[paramIDX+4], label='15 Minute Average') # Note the space in the col name\n",
    "\n",
    "    dataTable[paramIDX+4, 0] = JFE_4612.loc['2021-09-15 09:44:00':'2021-09-15 11:24:00', param].mean(skipna=True)\n",
    "    dataTable[paramIDX+4, 1] = JFE_4612.loc['2021-09-15 09:44:00':'2021-09-15 11:24:00', param].std(skipna=True)\n",
    "    dataTable[paramIDX+4, 2] = JFE_4612.loc['2021-09-15 09:44:00':'2021-09-15 11:24:00', param].min(skipna=True)\n",
    "    dataTable[paramIDX+4, 3] = JFE_4612.loc['2021-09-15 09:44:00':'2021-09-15 11:24:00', param].max(skipna=True)\n",
    "\n",
    "    axes[paramIDX+4].set_ylabel(JFEparamName[paramIDX])\n",
    "    axes[paramIDX+4].set_title('JFE: ' + JFEparamName[paramIDX])\n",
    "    axes[paramIDX+4].set_xlabel('')\n",
    "    axes[paramIDX+4].legend(loc='upper right')\n",
    "    \n",
    "axes[paramIDX+4].set_xlabel('September 15, 2021')\n",
    "\n",
    "\n",
    "plt.show()\n",
    "#fig.savefig('C:/Users/arey/files/Projects/Mustique/Figures/Deployment1TS.pdf',\n",
    "#            bbox_inches='tight')\n",
    "#fig.savefig('C:/Users/arey/files/Projects/Mustique/Figures/Deployment1TS.png',\n",
    "#             bbox_inches='tight', dpi=500)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {
    "pycharm": {
     "name": "#%% Plot time series for Other data\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": "<Figure size 864x1080 with 7 Axes>",
      "image/png": "[encoded data, 225352 characters]\n"
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig, axes = plt.subplots(nrows=7, ncols=1, figsize=(12, 15))\n",
    "fig.patch.set_facecolor('white')\n",
    "fig.tight_layout(pad=3)\n",
    "\n",
    "RBRparam = ['Depth ', 'Salinity ', 'Dissolved O₂ saturation ', 'Temperature ']\n",
    "RBRparamName = ['Depth [m]', 'Salinity [PSU]', 'Dissolved O₂ saturation [%]', 'Temperature [degC]']\n",
    "\n",
    "minTime = '2021-09-16 12:00:00'\n",
    "maxTime = '2021-09-17 12:00:00'\n",
    "# minTime = '2021-09-15 14:21:00'\n",
    "# maxTime = '2021-09-15 14:26:00'\n",
    "\n",
    "# axXlim   = (pd.to_datetime('2021-09-15 16:00:00'),\n",
    "#             pd.to_datetime('2021-09-15 16:15:00'))\n",
    "axXlim   = (pd.to_datetime(minTime),\n",
    "            pd.to_datetime(maxTime))\n",
    "\n",
    "dataTable = np.zeros([7, 4])\n",
    "\n",
    "for paramIDX, param in enumerate(RBRparam):\n",
    "    RBR_1552.loc[minTime:maxTime, param].plot(\n",
    "                    ax=axes[paramIDX], label='1 Second Observations') # Note the space in the col name\n",
    "    # RBR_1552.loc['2021-09-15 14:21:00':'2021-09-15 14:26:00', param].rolling(\n",
    "    #         '900s').mean().plot(\n",
    "    #         ax=axes[paramIDX], label='15 Minute Average') # Note the space in the col name\n",
    "\n",
    "    dataTable[paramIDX, 0] = RBR_1552.loc[minTime:maxTime, param].mean(skipna=True)\n",
    "    dataTable[paramIDX, 1] = RBR_1552.loc[minTime:maxTime, param].std(skipna=True)\n",
    "    dataTable[paramIDX, 2] = RBR_1552.loc[minTime:maxTime, param].min(skipna=True)\n",
    "    dataTable[paramIDX, 3] = RBR_1552.loc[minTime:maxTime, param].max(skipna=True)\n",
    "\n",
    "    axes[paramIDX].set_ylabel(RBRparamName[paramIDX])\n",
    "    axes[paramIDX].set_title('RBR: ' + RBRparamName[paramIDX])\n",
    "    axes[paramIDX].set_xlabel('')\n",
    "    axes[paramIDX].legend(loc='upper right')\n",
    "\n",
    "JFEparam     = ['Temp.[deg C]', 'Chl-Flu.[ppb]', 'Turb. -M[FTU]']\n",
    "JFEparamName = ['Temperature [degC]', 'Chl-Flu. [ppb]', 'Turbidity [FTU]']\n",
    "\n",
    "for paramIDX, param in enumerate(JFEparam):\n",
    "    if paramIDX == 2:\n",
    "        JFE_5412.loc[minTime:maxTime, param].plot(\n",
    "            ax=axes[paramIDX+4]) # Note the space in the col name\n",
    "        # JFE_5412.loc['2021-09-15 14:21:00':'2021-09-15 14:26:00', param].rolling(\n",
    "        #     '900s').mean().plot(\n",
    "        #     ax=axes[paramIDX+4], ylim=[0, 30]) # Note the space in the col name\n",
    "#         JFE_5412.loc['2021-09-15 14:57:00':'2021-09-17 14:06:00', param].plot(\n",
    "#             ax=axes[paramIDX+4], label='1 Minute Observations') # Note the space in the col name\n",
    "#         JFE_5412.loc['2021-09-15 14:57:00':'2021-09-17 14:06:00', param].rolling(\n",
    "#             '900s').mean().plot(\n",
    "#             ax=axes[paramIDX+4], label='15 Minute Average') # Note the space in the col name\n",
    "\n",
    "    else:\n",
    "        JFE_5412.loc[minTime:maxTime, param].plot(\n",
    "                    ax=axes[paramIDX+4], label='1 Minute Observations') # Note the space in the col name\n",
    "        # JFE_5412.loc['2021-09-15 14:21:00':'2021-09-15 14:26:00', param].rolling(\n",
    "        #     '900s').mean().plot(\n",
    "        #     ax=axes[paramIDX+4], label='15 Minute Average') # Note the space in the col name\n",
    "\n",
    "    dataTable[paramIDX+4, 0] = JFE_5412.loc[minTime:maxTime, param].mean(skipna=True)\n",
    "    dataTable[paramIDX+4, 1] = JFE_5412.loc[minTime:maxTime, param].std(skipna=True)\n",
    "    dataTable[paramIDX+4, 2] = JFE_5412.loc[minTime:maxTime, param].min(skipna=True)\n",
    "    dataTable[paramIDX+4, 3] = JFE_5412.loc[minTime:maxTime, param].max(skipna=True)\n",
    "\n",
    "    axes[paramIDX+4].set_ylabel(JFEparamName[paramIDX])\n",
    "    axes[paramIDX+4].set_title('JFE: ' + JFEparamName[paramIDX])\n",
    "    axes[paramIDX+4].set_xlabel('')\n",
    "    axes[paramIDX+4].legend(loc='upper right')\n",
    "\n",
    "axes[paramIDX+4].set_xlabel('Date')\n",
    "\n",
    "plt.setp(axes, xlim=axXlim)\n",
    "\n",
    "\n",
    "plt.show()\n",
    "# fig.savefig('C:/Users/arey/files/Projects/Mustique/Figures/Deployment2TS_RevA.pdf',\n",
    "#             bbox_inches='tight')\n",
    "# fig.savefig('C:/Users/arey/files/Projects/Mustique/Figures/Deployment2TS_RevA.png',\n",
    "#              bbox_inches='tight', dpi=500)\n",
    "\n",
    "# fig.savefig('C:/Users/arey/files/Projects/Mustique/Figures/Deployment2TS_RevB.pdf',\n",
    "#             bbox_inches='tight')\n",
    "# fig.savefig('C:/Users/arey/files/Projects/Mustique/Figures/Deployment2TS_RevB.png',\n",
    "#              bbox_inches='tight', dpi=500)\n",
    "\n",
    "# fig.savefig('C:/Users/arey/files/Projects/Mustique/Figures/Deployment2TS_Tight.pdf',\n",
    "#             bbox_inches='tight')\n",
    "# fig.savefig('C:/Users/arey/files/Projects/Mustique/Figures/Deployment2TS_Tight.png',\n",
    "#              bbox_inches='tight', dpi=500)\n",
    "\n",
    "# fig.savefig('C:/Users/arey/files/Projects/Mustique/Figures/BaselineTS.pdf',\n",
    "#             bbox_inches='tight')\n",
    "# fig.savefig('C:/Users/arey/files/Projects/Mustique/Figures/BaselineTS.png',\n",
    "#              bbox_inches='tight', dpi=500)\n",
    "\n",
    "fig.savefig('C:/Users/arey/files/Projects/Mustique/Figures/24HourTS.pdf',\n",
    "            bbox_inches='tight')\n",
    "fig.savefig('C:/Users/arey/files/Projects/Mustique/Figures/24HourTS.png',\n",
    "             bbox_inches='tight', dpi=500)\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "PyCharm (Mustique)",
   "language": "python",
   "name": "pycharm-78fc648f"
  },
  "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.8.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}