{ "cells": [ { "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 datetime as dt\n", "from salishsea_tools import evaltools as et, viz_tools\n", "import os\n", "import datetime as dt\n", "import gsw\n", "import matplotlib.gridspec as gridspec\n", "import matplotlib as mpl\n", "import matplotlib.dates as mdates\n", "import cmocean as cmo\n", "import scipy.interpolate as sinterp\n", "import cmocean\n", "import json\n", "import f90nml\n", "from collections import OrderedDict\n", "\n", "fs=16\n", "mpl.rc('xtick', labelsize=fs)\n", "mpl.rc('ytick', labelsize=fs)\n", "mpl.rc('legend', fontsize=fs)\n", "mpl.rc('axes', titlesize=fs)\n", "mpl.rc('axes', labelsize=fs)\n", "mpl.rc('figure', titlesize=fs)\n", "mpl.rc('font', size=fs)\n", "mpl.rc('font', family='sans-serif', weight='normal', style='normal')\n", "\n", "import warnings\n", "#warnings.filterwarnings('ignore')\n", "from IPython.display import Markdown, display\n", "\n", "%matplotlib inline\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Import Puget Sound data and create dataframe" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "df=pd.read_excel('/ocean/ksuchy/MOAD/observe/SSMSP_TransBoundary_Extract_2014-2019_Verticals_Keister_Lab.xlsx',engine='openpyxl',sheet_name='SSMSP 2014-2019 Density&Biomass')" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
BugSampleIDProjectSample CodeSampling GroupStationSite NameBasinSub BasinLatitudeLongitude...Ind Carbon (ug)Density (#/m3)Final Carbon (mg/m3)Species Size Category AggregationSize Category AggregationCollection ConfidenceCarbon Regression EQC to DW multipierDW Regression EquationC/DW Source
093945SSMSP060817HCB004V1454HCSEGHCB004VSisters PointHood CanalS Hood Canal47.35620-123.0249...122.3330005.1690133.185477AmphipodAmphipodHighC(ug)=(0.0049*([Length(mm)])^2.957)*1000)*37%C = DW * 37%DW(ug)=0.0049*([Length(mm)])^2.957)*1000Ikeda & Shiga, 1999
193946SSMSP060817HCB004V1454HCSEGHCB004VSisters PointHood CanalS Hood Canal47.35620-123.0249...107.3032000.0680130.010533AmphipodAmphipodHighC(ug)=(0.0049*([Length(mm)])^2.957)*1000)*37%C = DW * 37%DW(ug)=0.0049*([Length(mm)])^2.957)*1000Ikeda & Shiga, 1999
293962SSMSP060817HCB004V1454HCSEGHCB004VSisters PointHood CanalS Hood Canal47.35620-123.0249...17.76466021.7642670.397324AmphipodAmphipodHighC(ug)=(0.0049*([Length(mm)])^2.957)*1000)*37%C = DW * 37%DW(ug)=0.0049*([Length(mm)])^2.957)*1000Ikeda & Shiga, 1999
394018SSMSP030917HCB003V1218HCSEGHCB003VEldonHood CanalS Hood Canal47.53787-123.0096...343.1521001.7300360.564992AmphipodAmphipodHighC(ug)=((0.02 * [Length (mm)]^2.1)*1000)*37%C = DW * 37%DW(μg) = (0.02 * [Length(mm)]^2.1)*1000Kafanov & Fedotov, 1982
494030SSMSP030917HCB003V1218HCSEGHCB003VEldonHood CanalS Hood Canal47.53787-123.0096...17.7646600.8125930.090677AmphipodAmphipodHighC(ug)=(0.0049*([Length(mm)])^2.957)*1000)*37%C = DW * 37%DW(ug)=0.0049*([Length(mm)])^2.957)*1000Ikeda & Shiga, 1999
..................................................................
8158231509SSMSP050615MUKV1200TULMUKVMukilteoWhidbey BasinS Whidbey Basin47.97166-122.3222...7.45071098.8044690.252324Unknown EggUnknown EggModerateC (ug) = 8.0935*[Length (mm)]-1.0883C (ug) = 8.0935*[Length (mm)]-1.0883NONEKeister Lab estimate, 2016
8158338434SSMSP081315MUKV1121TULMUKVMukilteoWhidbey BasinS Whidbey Basin47.97166-122.3222...7.4507108.6347070.011568Unknown EggUnknown EggModerateC (ug) = 8.0935*[Length (mm)]-1.0883C (ug) = 8.0935*[Length (mm)]-1.0883NONEKeister Lab estimate, 2016
8158438675SSMSP082615MUKV1116TULMUKVMukilteoWhidbey BasinS Whidbey Basin47.97166-122.3222...2.86805127.0453020.077567Unknown EggUnknown EggModerateC (ug) = 8.0935*[Length (mm)]-1.0883C (ug) = 8.0935*[Length (mm)]-1.0883NONEKeister Lab estimate, 2016
8158539535SSMSP050615CAMV1305TULCAMVCamano HeadWhidbey BasinS Whidbey Basin48.05901-122.3873...7.45071043.6286100.325064Unknown EggUnknown EggModerateC (ug) = 8.0935*[Length (mm)]-1.0883C (ug) = 8.0935*[Length (mm)]-1.0883NONEKeister Lab estimate, 2016
81586104254SSMSP080318HCB004V1114HCSEGHCB004VSisters PointHood CanalS Hood Canal47.35620-123.0249...0.2000004.1050910.004105Unknown NaupliusUnknown NaupliusHighNONENONENONEKeister Lab estimate, 2016
\n", "

81587 rows × 38 columns

\n", "
" ], "text/plain": [ " BugSampleID Project Sample Code Sampling Group Station \\\n", "0 93945 SSMSP 060817HCB004V1454 HCSEG HCB004V \n", "1 93946 SSMSP 060817HCB004V1454 HCSEG HCB004V \n", "2 93962 SSMSP 060817HCB004V1454 HCSEG HCB004V \n", "3 94018 SSMSP 030917HCB003V1218 HCSEG HCB003V \n", "4 94030 SSMSP 030917HCB003V1218 HCSEG HCB003V \n", "... ... ... ... ... ... \n", "81582 31509 SSMSP 050615MUKV1200 TUL MUKV \n", "81583 38434 SSMSP 081315MUKV1121 TUL MUKV \n", "81584 38675 SSMSP 082615MUKV1116 TUL MUKV \n", "81585 39535 SSMSP 050615CAMV1305 TUL CAMV \n", "81586 104254 SSMSP 080318HCB004V1114 HCSEG HCB004V \n", "\n", " Site Name Basin Sub Basin Latitude Longitude \\\n", "0 Sisters Point Hood Canal S Hood Canal 47.35620 -123.0249 \n", "1 Sisters Point Hood Canal S Hood Canal 47.35620 -123.0249 \n", "2 Sisters Point Hood Canal S Hood Canal 47.35620 -123.0249 \n", "3 Eldon Hood Canal S Hood Canal 47.53787 -123.0096 \n", "4 Eldon Hood Canal S Hood Canal 47.53787 -123.0096 \n", "... ... ... ... ... ... \n", "81582 Mukilteo Whidbey Basin S Whidbey Basin 47.97166 -122.3222 \n", "81583 Mukilteo Whidbey Basin S Whidbey Basin 47.97166 -122.3222 \n", "81584 Mukilteo Whidbey Basin S Whidbey Basin 47.97166 -122.3222 \n", "81585 Camano Head Whidbey Basin S Whidbey Basin 48.05901 -122.3873 \n", "81586 Sisters Point Hood Canal S Hood Canal 47.35620 -123.0249 \n", "\n", " ... Ind Carbon (ug) Density (#/m3) Final Carbon (mg/m3) \\\n", "0 ... 122.333000 5.169013 3.185477 \n", "1 ... 107.303200 0.068013 0.010533 \n", "2 ... 17.764660 21.764267 0.397324 \n", "3 ... 343.152100 1.730036 0.564992 \n", "4 ... 17.764660 0.812593 0.090677 \n", "... ... ... ... ... \n", "81582 ... 7.450710 98.804469 0.252324 \n", "81583 ... 7.450710 8.634707 0.011568 \n", "81584 ... 2.868051 27.045302 0.077567 \n", "81585 ... 7.450710 43.628610 0.325064 \n", "81586 ... 0.200000 4.105091 0.004105 \n", "\n", " Species Size Category Aggregation Size Category Aggregation \\\n", "0 Amphipod Amphipod \n", "1 Amphipod Amphipod \n", "2 Amphipod Amphipod \n", "3 Amphipod Amphipod \n", "4 Amphipod Amphipod \n", "... ... ... \n", "81582 Unknown Egg Unknown Egg \n", "81583 Unknown Egg Unknown Egg \n", "81584 Unknown Egg Unknown Egg \n", "81585 Unknown Egg Unknown Egg \n", "81586 Unknown Nauplius Unknown Nauplius \n", "\n", " Collection Confidence Carbon Regression EQ \\\n", "0 High C(ug)=(0.0049*([Length(mm)])^2.957)*1000)*37% \n", "1 High C(ug)=(0.0049*([Length(mm)])^2.957)*1000)*37% \n", "2 High C(ug)=(0.0049*([Length(mm)])^2.957)*1000)*37% \n", "3 High C(ug)=((0.02 * [Length (mm)]^2.1)*1000)*37% \n", "4 High C(ug)=(0.0049*([Length(mm)])^2.957)*1000)*37% \n", "... ... ... \n", "81582 Moderate C (ug) = 8.0935*[Length (mm)]-1.0883 \n", "81583 Moderate C (ug) = 8.0935*[Length (mm)]-1.0883 \n", "81584 Moderate C (ug) = 8.0935*[Length (mm)]-1.0883 \n", "81585 Moderate C (ug) = 8.0935*[Length (mm)]-1.0883 \n", "81586 High NONE \n", "\n", " C to DW multipier \\\n", "0 C = DW * 37% \n", "1 C = DW * 37% \n", "2 C = DW * 37% \n", "3 C = DW * 37% \n", "4 C = DW * 37% \n", "... ... \n", "81582 C (ug) = 8.0935*[Length (mm)]-1.0883 \n", "81583 C (ug) = 8.0935*[Length (mm)]-1.0883 \n", "81584 C (ug) = 8.0935*[Length (mm)]-1.0883 \n", "81585 C (ug) = 8.0935*[Length (mm)]-1.0883 \n", "81586 NONE \n", "\n", " DW Regression Equation C/DW Source \n", "0 DW(ug)=0.0049*([Length(mm)])^2.957)*1000 Ikeda & Shiga, 1999 \n", "1 DW(ug)=0.0049*([Length(mm)])^2.957)*1000 Ikeda & Shiga, 1999 \n", "2 DW(ug)=0.0049*([Length(mm)])^2.957)*1000 Ikeda & Shiga, 1999 \n", "3 DW(μg) = (0.02 * [Length(mm)]^2.1)*1000 Kafanov & Fedotov, 1982 \n", "4 DW(ug)=0.0049*([Length(mm)])^2.957)*1000 Ikeda & Shiga, 1999 \n", "... ... ... \n", "81582 NONE Keister Lab estimate, 2016 \n", "81583 NONE Keister Lab estimate, 2016 \n", "81584 NONE Keister Lab estimate, 2016 \n", "81585 NONE Keister Lab estimate, 2016 \n", "81586 NONE Keister Lab estimate, 2016 \n", "\n", "[81587 rows x 38 columns]" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Index(['BugSampleID', 'Project', 'Sample Code', 'Sampling Group', 'Station',\n", " 'Site Name', 'Basin', 'Sub Basin', 'Latitude', 'Longitude',\n", " 'Date Category', 'Sample Date', 'Sample Year', 'Sample Month',\n", " 'Sample Time', 'Tow Type', 'Mesh Size', 'Diameter (cm)',\n", " 'Station Depth (m)', 'Max Tow Depth (m)', 'Min Tow Depth (m)',\n", " 'Vol Filtered (m3)', 'Broad Group', 'Mid-Level Group', '1st Word Taxa',\n", " 'Genus species', 'Life History Stage', 'Total Ct', 'Ind Carbon (ug)',\n", " 'Density (#/m3)', 'Final Carbon (mg/m3)',\n", " 'Species Size Category Aggregation', 'Size Category Aggregation',\n", " 'Collection Confidence', 'Carbon Regression EQ', 'C to DW multipier',\n", " 'DW Regression Equation', 'C/DW Source'],\n", " dtype='object')" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.keys()" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "df.drop(columns=['BugSampleID','Project','Sampling Group','Date Category','Tow Type','Species Size Category Aggregation','Collection Confidence','Carbon Regression EQ','C to DW multipier','DW Regression Equation','C/DW Source'\n", " ],inplace=True)" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Sample CodeStationSite NameBasinSub BasinLatitudeLongitudeSample DateSample YearSample Month...Broad GroupMid-Level Group1st Word TaxaGenus speciesLife History StageTotal CtInd Carbon (ug)Density (#/m3)Final Carbon (mg/m3)Size Category Aggregation
0060817HCB004V1454HCB004VSisters PointHood CanalS Hood Canal47.35620-123.02492017-06-082017JUN...AmphipodAmphipoda-HyperiideaHYPEROCHEHYPEROCHEUnknown76.0122.3330005.1690133.185477Amphipod
1060817HCB004V1454HCB004VSisters PointHood CanalS Hood Canal47.35620-123.02492017-06-082017JUN...AmphipodAmphipoda-HyperiideaHYPERIAHYPERIAUnknown1.0107.3032000.0680130.010533Amphipod
2060817HCB004V1454HCB004VSisters PointHood CanalS Hood Canal47.35620-123.02492017-06-082017JUN...AmphipodAmphipoda-HyperiideaTHEMISTOTHEMISTO PACIFICAUnknown320.017.76466021.7642670.397324Amphipod
3030917HCB003V1218HCB003VEldonHood CanalS Hood Canal47.53787-123.00962017-03-092017MAR...AmphipodAmphipoda-CyphocarididaeCYPHOCARISCYPHOCARIS CHALLENGERIUnknown66.0343.1521001.7300360.564992Amphipod
4030917HCB003V1218HCB003VEldonHood CanalS Hood Canal47.53787-123.00962017-03-092017MAR...AmphipodAmphipoda-HyperiideaTHEMISTOTHEMISTO PACIFICAUnknown31.017.7646600.8125930.090677Amphipod
..................................................................
81582050615MUKV1200MUKVMukilteoWhidbey BasinS Whidbey Basin47.97166-122.32222015-05-062015MAY...Unknown EggUnknownUNKNOWNUNKNOWNEGG Lg4500.07.45071098.8044690.252324Unknown Egg
81583081315MUKV1121MUKVMukilteoWhidbey BasinS Whidbey Basin47.97166-122.32222015-08-132015AUG...Unknown EggUnknownUNKNOWNUNKNOWNEGG Lg385.07.4507108.6347070.011568Unknown Egg
81584082615MUKV1116MUKVMukilteoWhidbey BasinS Whidbey Basin47.97166-122.32222015-08-262015SEP...Unknown EggUnknownUNKNOWNUNKNOWNEGG Med1000.02.86805127.0453020.077567Unknown Egg
81585050615CAMV1305CAMVCamano HeadWhidbey BasinS Whidbey Basin48.05901-122.38732015-05-062015MAY...Unknown EggUnknownUNKNOWNUNKNOWNEGG Lg2025.07.45071043.6286100.325064Unknown Egg
81586080318HCB004V1114HCB004VSisters PointHood CanalS Hood Canal47.35620-123.02492018-08-032018AUG...Unknown NaupliusUnknownUNKNOWNUNKNOWNNauplius50.00.2000004.1050910.004105Unknown Nauplius
\n", "

81587 rows × 27 columns

\n", "
" ], "text/plain": [ " Sample Code Station Site Name Basin \\\n", "0 060817HCB004V1454 HCB004V Sisters Point Hood Canal \n", "1 060817HCB004V1454 HCB004V Sisters Point Hood Canal \n", "2 060817HCB004V1454 HCB004V Sisters Point Hood Canal \n", "3 030917HCB003V1218 HCB003V Eldon Hood Canal \n", "4 030917HCB003V1218 HCB003V Eldon Hood Canal \n", "... ... ... ... ... \n", "81582 050615MUKV1200 MUKV Mukilteo Whidbey Basin \n", "81583 081315MUKV1121 MUKV Mukilteo Whidbey Basin \n", "81584 082615MUKV1116 MUKV Mukilteo Whidbey Basin \n", "81585 050615CAMV1305 CAMV Camano Head Whidbey Basin \n", "81586 080318HCB004V1114 HCB004V Sisters Point Hood Canal \n", "\n", " Sub Basin Latitude Longitude Sample Date Sample Year \\\n", "0 S Hood Canal 47.35620 -123.0249 2017-06-08 2017 \n", "1 S Hood Canal 47.35620 -123.0249 2017-06-08 2017 \n", "2 S Hood Canal 47.35620 -123.0249 2017-06-08 2017 \n", "3 S Hood Canal 47.53787 -123.0096 2017-03-09 2017 \n", "4 S Hood Canal 47.53787 -123.0096 2017-03-09 2017 \n", "... ... ... ... ... ... \n", "81582 S Whidbey Basin 47.97166 -122.3222 2015-05-06 2015 \n", "81583 S Whidbey Basin 47.97166 -122.3222 2015-08-13 2015 \n", "81584 S Whidbey Basin 47.97166 -122.3222 2015-08-26 2015 \n", "81585 S Whidbey Basin 48.05901 -122.3873 2015-05-06 2015 \n", "81586 S Hood Canal 47.35620 -123.0249 2018-08-03 2018 \n", "\n", " Sample Month ... Broad Group Mid-Level Group \\\n", "0 JUN ... Amphipod Amphipoda-Hyperiidea \n", "1 JUN ... Amphipod Amphipoda-Hyperiidea \n", "2 JUN ... Amphipod Amphipoda-Hyperiidea \n", "3 MAR ... Amphipod Amphipoda-Cyphocarididae \n", "4 MAR ... Amphipod Amphipoda-Hyperiidea \n", "... ... ... ... ... \n", "81582 MAY ... Unknown Egg Unknown \n", "81583 AUG ... Unknown Egg Unknown \n", "81584 SEP ... Unknown Egg Unknown \n", "81585 MAY ... Unknown Egg Unknown \n", "81586 AUG ... Unknown Nauplius Unknown \n", "\n", " 1st Word Taxa Genus species Life History Stage Total Ct \\\n", "0 HYPEROCHE HYPEROCHE Unknown 76.0 \n", "1 HYPERIA HYPERIA Unknown 1.0 \n", "2 THEMISTO THEMISTO PACIFICA Unknown 320.0 \n", "3 CYPHOCARIS CYPHOCARIS CHALLENGERI Unknown 66.0 \n", "4 THEMISTO THEMISTO PACIFICA Unknown 31.0 \n", "... ... ... ... ... \n", "81582 UNKNOWN UNKNOWN EGG Lg 4500.0 \n", "81583 UNKNOWN UNKNOWN EGG Lg 385.0 \n", "81584 UNKNOWN UNKNOWN EGG Med 1000.0 \n", "81585 UNKNOWN UNKNOWN EGG Lg 2025.0 \n", "81586 UNKNOWN UNKNOWN Nauplius 50.0 \n", "\n", " Ind Carbon (ug) Density (#/m3) Final Carbon (mg/m3) \\\n", "0 122.333000 5.169013 3.185477 \n", "1 107.303200 0.068013 0.010533 \n", "2 17.764660 21.764267 0.397324 \n", "3 343.152100 1.730036 0.564992 \n", "4 17.764660 0.812593 0.090677 \n", "... ... ... ... \n", "81582 7.450710 98.804469 0.252324 \n", "81583 7.450710 8.634707 0.011568 \n", "81584 2.868051 27.045302 0.077567 \n", "81585 7.450710 43.628610 0.325064 \n", "81586 0.200000 4.105091 0.004105 \n", "\n", " Size Category Aggregation \n", "0 Amphipod \n", "1 Amphipod \n", "2 Amphipod \n", "3 Amphipod \n", "4 Amphipod \n", "... ... \n", "81582 Unknown Egg \n", "81583 Unknown Egg \n", "81584 Unknown Egg \n", "81585 Unknown Egg \n", "81586 Unknown Nauplius \n", "\n", "[81587 rows x 27 columns]" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Index(['Sample Code', 'Station', 'Site Name', 'Basin', 'Sub Basin', 'Latitude',\n", " 'Longitude', 'Sample Date', 'Sample Year', 'Sample Month',\n", " 'Sample Time', 'Mesh Size', 'Diameter (cm)', 'Station Depth (m)',\n", " 'Max Tow Depth (m)', 'Min Tow Depth (m)', 'Vol Filtered (m3)',\n", " 'Broad Group', 'Mid-Level Group', '1st Word Taxa', 'Genus species',\n", " 'Life History Stage', 'Total Ct', 'Ind Carbon (ug)', 'Density (#/m3)',\n", " 'Final Carbon (mg/m3)', 'Size Category Aggregation'],\n", " dtype='object')" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.keys()" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array(['Amphipod', 'Amphipod Egg', 'Anthozoan', 'Arachnida', 'Barnacles',\n", " 'Bivalve', 'Bryozoan', 'Cephalopod', 'Chaetognath',\n", " 'Chaetognath Egg', 'Cladocera', 'Copepod', 'Copepod Egg',\n", " 'Copepod Nauplius', 'Crabs', 'Ctenophore', 'Cumacea',\n", " 'Dinoflagellate', 'Echinoderm', 'Fish', 'Fish Egg', 'Gastropod',\n", " 'Hydrozoan', 'Insect', 'Isopod', 'Krill Egg', 'Krill Nauplius',\n", " 'Krill-Adult Juvenile', 'Krill-Calyptopis', 'Krill-Furcilia',\n", " 'Larvacea', 'Mollusk Egg', 'Mysid', 'Mysid Egg', 'Nematode',\n", " 'Nemertea', 'Nudibranch', 'Ostracod', 'Phoronid',\n", " 'Platyhelminthes', 'Polychaete', 'Pycnogonida', 'Scyphozoan',\n", " 'Shrimp', 'Siphonophore', 'Siphonophore Gonophore', 'Tunicate',\n", " 'Tunicate Egg', 'Unknown', 'Unknown Egg', 'Unknown Nauplius'],\n", " dtype=object)" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df['Broad Group'].unique()" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "colListBroad=('Amphipoda', 'Crabs','Krill-Adult Juvenile','Krill-Calyptopis','Krill-Furcilia','Copepod', 'Larvacea',)" ] }, { "cell_type": "code", "execution_count": 39, "metadata": {}, "outputs": [], "source": [ "colListGenus=('METRIDIA PACIFICA','NEOCALANUS PLUMCHRUS','CALANOIDA','EUCALANUS BUNGII','CALANUS PACIFICUS','CALANUS MARSHALLAE','NEOCALANUS CRISTATUS','EUCALANUS CALIFORNICUS','EUCALANUS','METRIDIIDAE','NEOCALANUS')" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [], "source": [ "#l1=set(df['order'].values)\n", "#l2=set(df['genus species'].values)\n", "#l3=l1|l2" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array(['HYPEROCHE', 'HYPERIA', 'THEMISTO PACIFICA',\n", " 'CYPHOCARIS CHALLENGERI', 'PRIMNO MACROPA', 'CALLIOPIUS PACIFICUS',\n", " 'HYPERIIDEA', 'GAMMARIDEA', 'AMPHIPODA', 'COROPHIUM',\n", " 'CAPRELLIDAE', 'CALLIOPIUS CARINATUS', 'PARAPHRONIMA CRASSIPES',\n", " 'Anthozoa', 'PEACHIA', 'MITES', 'Arachnidae', 'BARNACLES',\n", " 'BIVALVIA', 'BRYOZOA', 'OCTOPODA', 'Teuthida', 'CHAETOGNATHA',\n", " 'Chaet/Euphaus Egg', 'EVADNE', 'PODON', 'Evadne', 'CLADOCERA',\n", " 'ACARTIA HUDSONICA', 'ACARTIA LONGIREMIS', 'AETIDEUS',\n", " 'CENTROPAGES ABDOMINALIS', 'DITRICHOCORYCAEUS ANGLICUS',\n", " 'METRIDIA PACIFICA', 'MICROCALANUS', 'OITHONA SIMILIS',\n", " 'PARACALANUS', 'PSEUDOCALANUS', 'SCOLECITHRICELLA MINOR',\n", " 'PARAEUCHAETA ELONGATA', 'CANDACIA COLUMBIAE',\n", " 'CHIRIDIUS GRACILIS', 'OITHONA ATLANTICA', 'PSEUDOCALANUS NEWMANI',\n", " 'PSEUDOCALANUS MOULTONI', 'PSEUDOCALANUS Sm', 'THARYBIS FULTONI',\n", " 'TRICONIA MINUTA', 'Monstrilloida', 'HARPACTICOIDA',\n", " 'GAETANUS PUNGENS', 'NEOCALANUS PLUMCHRUS', 'CALANOIDA',\n", " 'TRICONIA CONIFERA', 'EUCALANUS BUNGII', 'TRICONIA BOREALIS',\n", " 'OITHONA', 'CALANUS PACIFICUS', 'CALANUS MARSHALLAE',\n", " 'TORTANUS DISCAUDATUS', 'PSEUDOCALANUS MIMUS', 'ACARTIA TONSA',\n", " 'ONCAEA SUBTILIS', 'Siphonostomatoida', 'ONCAEIDAE',\n", " 'BRADYIDIUS SAANICHI', 'PSEUDOCALANUS Lg', 'TRICONIA CANADENSIS',\n", " 'NEOCALANUS CRISTATUS', 'PSEUDOCALANUS MINUTUS',\n", " 'RACOVITZANUS ANTARCTICUS', 'ACARTIA', 'HEMICYCLOPS',\n", " 'ONCAEA PROLATA', 'EPILABIDOCERA AMPHITRITES',\n", " 'CTENOCALANUS VANUS', 'SCOLECITHRICELLA OVATA', 'HETERORHABDUS',\n", " 'EUCALANUS CALIFORNICUS', 'CYCLOPOIDA', 'TRICONIA SIMILIS',\n", " 'SCOLECITHRICELLA Minor', 'Chiridius gracilis', 'GAETANUS SIMPLEX',\n", " 'CANDACIA BIPINNATA', 'CANDACIA', 'EUCHIRELLA PULCHRA',\n", " 'AETIDEUS ARMATUS', 'TRICONIA', 'GAETANUS MINUTUS', 'EURYTEMORA',\n", " 'MESOCALANUS TENUICORNIS', 'EUCALANUS', 'CLAUSOCALANUS',\n", " 'SCOLECITHRICELLA DENTATA', 'SCOLECITHRICELLA',\n", " 'PLEUROMAMMA ABDOMINALIS', 'Poecilostomatoida',\n", " 'EUCHIRELLA PSEUDOPULCHRA', 'EUCHAETIDAE',\n", " 'SCAPHOCALANUS BREVICORNIS', 'METRIDIIDAE', 'COPEPODA',\n", " 'NEOCALANUS', 'PLEUROMAMMA', 'GAETANUS MILES', 'TRICONIA (tiny)',\n", " 'AETIDEUS DIVERGENS', 'CALIGIDAE', 'FARRANULA', 'TORTANUS',\n", " 'Tortanus', 'METACARCINUS MAGISTER', 'GLEBOCARCINUS OREGONENSIS',\n", " 'METACARCINUS GRACILIS', 'PINNIXA', 'PAGURUS', 'HEMIGRAPSUS',\n", " 'GALATHEIDAE', 'PUGETTIA', 'LOPHOPANOPEUS BELLUS',\n", " 'CANCER PRODUCTUS', 'FABIA SUBQUADRATA', 'LITHODIDAE',\n", " 'OREGONIA GRACILIS', 'PINNOTHERES', 'BRACHYURA', 'Galatheidae',\n", " 'Cancridae Sm', 'PINNOTHERIDAE', 'CANCRIDAE',\n", " 'Telmessus cheiragonus', 'XANTHOIDEA', 'PACHYCHELES',\n", " 'PETROLISTHES', 'Cancridae Lg', 'MAJOIDEA', 'LOPHOLITHODES',\n", " 'CHIONOECETES', 'PORCELLANIDAE', 'PAGURIDAE', 'RHINOLITHODES',\n", " 'GRAPSIDAE', 'CRYPTOLITHODES', 'DIOGENIDAE', 'ANOMURA',\n", " 'PLEUROBRACHIA BACHEI', 'CTENOPHORA', 'Pleurobrachia bachei',\n", " 'BEROE', 'CUMACEA', 'NOCTILUCA', 'ECHINODERMATA', 'HOLOTHUROIDEA',\n", " 'OPHIUROIDEA', 'FISH', 'Forage FISH', 'Syngnathidae', 'Fish',\n", " 'LIMACINA HELICINA', 'CLIONE LIMACINA', 'GASTROPODA',\n", " 'GASTROPTERON PACIFICUM', 'Limacina helicina', 'AEQUOREA VICTORIA',\n", " 'Mitrocoma cellularia', 'AGLANTHA DIGITALE', 'PANDEIDAE',\n", " 'EUPHYSA', 'PROBOSCIDACTYLA FLAVICIRRATA', 'HALITHOLUS', 'RATHKEA',\n", " 'OBELIA', 'EUTONINA INDICANS', 'CLYTIA GREGARIA', 'SARSIA',\n", " 'LEPTOTHECATA', 'LEUCKARTIARA', 'ANTHOATHECATA', 'HYDROMEDUSA',\n", " 'Clytia gregaria', 'Aglantha digitale', 'HYDROID',\n", " 'Geomackiea zephyrolata', 'AMPHINEMA', 'AEGINA CITREA',\n", " 'STOMOTOCA ATRA', 'BOUGAINVILLIA', 'Euphysa', 'SOLMISSUS',\n", " 'HYBOCODON', 'NARCOMEDUSIDA', 'MITROCOMELLA', 'TIAROPSIS',\n", " 'HYDROZOA', 'Insecta', 'ISOPODA', 'EUPHAUSIIDAE',\n", " 'EUPHAUSIA PACIFICA', 'THYSANOESSA', 'THYSANOESSA RASCHII',\n", " 'NEMATOSCELIS DIFFICILIS', 'THYSANOESSA SPINIFERA',\n", " 'THYSANOESSA LONGIPES', 'FRITILLARIA', 'OIKOPLEURA', 'LARVACEA',\n", " 'LITTORINA', 'ALIENACANTHOMYSIS MACROPSIS',\n", " 'METERYTHROPS ROBUSTUS', 'PACIFACANTHOMYSIS NEPHROPHTHALMA',\n", " 'MYSIDELLA AMERICANA', 'MYSIDACEA',\n", " 'XENACANTHOMYSIS PSEUDOMACROPSIS', 'NEOMYSIS',\n", " 'Exacanthomysis davisi', 'PSEUDOMMA', 'NEOMYSIS MERCEDIS',\n", " 'NEMATODA', 'Nemertea', 'NUDIBRANCHIA', 'OSTRACODA', 'PHORONIDA',\n", " 'PLATYHELMINTHES', 'POLYCHAETA', 'RHYNCHONEREELLA ANGELINI',\n", " 'OWENIA', 'TOMOPTERIS', 'PYCNOGONIDA', 'SCYPHOMEDUSA',\n", " 'HIPPOLYTIDAE', 'NEOTRYPAEA CALIFORNIENSIS', 'CRANGONIDAE',\n", " 'PANDALUS STENOLEPIS', 'PASIPHAEA PACIFICA', 'CALLIANASSIDAE',\n", " 'PANDALIDAE', 'CARIDEA', 'UPOGEBIIDAE', 'Caridea',\n", " 'SERGESTES SIMILIS', 'DECAPODA', 'MUGGIAEA ATLANTICA',\n", " 'Nanomia bijuga', 'Muggiaea atlantica', 'Physonect', 'DIMOPHYES',\n", " 'CALYCOPHORAE', 'SIPHONOPHORA', 'ASCIDIACEA', 'SALPA', 'UNKNOWN',\n", " 'Unknown'], dtype=object)" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df['Genus species'].unique()" ] }, { "cell_type": "raw", "metadata": {}, "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Convert date to proper format" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(Timestamp('2017-06-08 00:00:00'), datetime.time(14, 54))" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df['Sample Date'][0],df['Sample Time'][0]" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "1000 2015-08-04\n", "1001 2015-08-04\n", "1002 2015-08-04\n", "1003 2015-08-04\n", "1004 2015-08-17\n", "1005 2015-08-17\n", "1006 2015-08-17\n", "1007 2015-08-18\n", "1008 2015-08-18\n", "1009 2015-08-18\n", "1010 2015-08-18\n", "1011 2015-08-18\n", "1012 2015-07-20\n", "1013 2015-07-20\n", "1014 2015-07-20\n", "1015 2015-08-03\n", "1016 2015-08-03\n", "1017 2015-08-03\n", "1018 2015-07-06\n", "1019 2015-07-06\n", "Name: Sample Date, dtype: datetime64[ns]" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df['Sample Date'][1000:1020]" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [], "source": [ "df['dtPac']=[dt.datetime.combine(idate, itime) for idate, itime \\\n", " in zip(df['Sample Date'],df['Sample Time'])]" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [], "source": [ "df['dtUTC']=[et.pac_to_utc(ii) for ii in df['dtPac']]" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0 2017-06-08 21:54:00\n", "1 2017-06-08 21:54:00\n", "2 2017-06-08 21:54:00\n", "3 2017-03-09 20:18:00\n", "4 2017-03-09 20:18:00\n", " ... \n", "81582 2015-05-06 19:00:00\n", "81583 2015-08-13 18:21:00\n", "81584 2015-08-26 18:16:00\n", "81585 2015-05-06 20:05:00\n", "81586 2018-08-03 18:14:00\n", "Name: dtUTC, Length: 81587, dtype: datetime64[ns]" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df['dtUTC']" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [], "source": [ "df.rename(columns={'Sample Code':'Key','Latitude':'Lat','Longitude':'Lon'},inplace=True)" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Key 060817HCB004V1454\n", "Station HCB004V\n", "Site Name Sisters Point\n", "Basin Hood Canal\n", "Sub Basin S Hood Canal\n", "Lat 47.3562\n", "Lon -123.025\n", "Sample Date 2017-06-08 00:00:00\n", "Sample Year 2017\n", "Sample Month JUN\n", "Sample Time 14:54:00\n", "Mesh Size 200\n", "Diameter (cm) 60\n", "Station Depth (m) 52\n", "Max Tow Depth (m) 47\n", "Min Tow Depth (m) 0\n", "Vol Filtered (m3) 14.703\n", "Broad Group Amphipod\n", "Mid-Level Group Amphipoda-Hyperiidea\n", "1st Word Taxa HYPEROCHE\n", "Genus species HYPEROCHE\n", "Life History Stage Unknown\n", "Total Ct 76\n", "Ind Carbon (ug) 122.333\n", "Density (#/m3) 5.16901\n", "Final Carbon (mg/m3) 3.18548\n", "Size Category Aggregation Amphipod\n", "dtPac 2017-06-08 14:54:00\n", "dtUTC 2017-06-08 21:54:00\n", "Name: 0, dtype: object" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.loc[0]" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [], "source": [ "towIDlist=['Key','Station', 'Site Name', 'Basin', 'Sub Basin', 'Lat',\n", " 'Lon', 'Sample Date', 'Sample Year', 'Sample Month',\n", " 'Sample Time', 'Mesh Size', 'Diameter (cm)', 'Station Depth (m)',\n", " 'Max Tow Depth (m)', 'Min Tow Depth (m)','dtUTC']" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [], "source": [ "towIDlist2=['Key', 'Station', 'Sample Date','Sample Time','dtUTC']" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "1159" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "len(np.unique(df['Key']))" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(2168, 1159, 1159)" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "len(df.groupby(towIDlist)),len(df.groupby(towIDlist2)),len(df.groupby(['Key']))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Create a biomass dataframe" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [], "source": [ "biomassDF=df.groupby(towIDlist2,as_index=False).first()\\\n", " .loc[:,towIDlist].copy(deep=True)" ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Index(['Key', 'Station', 'Site Name', 'Basin', 'Sub Basin', 'Lat', 'Lon',\n", " 'Sample Date', 'Sample Year', 'Sample Month', 'Sample Time',\n", " 'Mesh Size', 'Diameter (cm)', 'Station Depth (m)', 'Max Tow Depth (m)',\n", " 'Min Tow Depth (m)', 'dtUTC'],\n", " dtype='object')" ] }, "execution_count": 26, "metadata": {}, "output_type": "execute_result" } ], "source": [ "biomassDF.keys()" ] }, { "cell_type": "code", "execution_count": 27, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
KeyStationSite NameBasinSub BasinLatLonSample DateSample YearSample MonthSample TimeMesh SizeDiameter (cm)Station Depth (m)Max Tow Depth (m)Min Tow Depth (m)dtUTC
0010218ELIV1151ELIVEliza IslandBellingham BayBellingham Bay48.63795-122.56942018-01-022018JAN11:51:0020060.0120.700110.002018-01-02 19:51:00
1010818SKETV1058SKETVSouth Ketron/Solo PointSouth SoundSouth Sound47.15243-122.65862018-01-082018JAN10:58:0020060.0132.000122.002018-01-08 18:58:00
2011119ELIV1052ELIVEliza IslandBellingham BayBellingham Bay48.63795-122.56942019-01-112019JAN10:52:0020060.0124.054114.002019-01-11 18:52:00
3011315CAMV1330CAMVCamano HeadWhidbey BasinS Whidbey Basin48.05901-122.38732015-01-132015JAN13:30:0020060.0175.000170.002015-01-13 21:30:00
4011315MUKV1415MUKVMukilteoWhidbey BasinS Whidbey Basin47.97166-122.32222015-01-132015JAN14:15:0020060.0200.000190.002015-01-13 22:15:00
......................................................
1154121917LSNT01V1000LSNT01VPoint WilliamsCentral BasinN Central Basin47.53333-122.43332017-12-192017DEC10:00:0020060.0210.000200.002017-12-19 18:00:00
1155121917NSEX01V1224NSEX01VEast PassageCentral BasinS Central Basin47.35862-122.38712017-12-192017DEC12:24:0020060.0180.000170.002017-12-19 20:24:00
1156121918TDBV1327TDBVThorndyke BayHood CanalN Hood Canal47.78297-122.73302018-12-192018DEC13:27:0020060.0112.000109.002018-12-19 21:27:00
1157122116LSNT01V1057LSNT01VPoint WilliamsCentral BasinN Central Basin47.53333-122.43332016-12-212016DEC10:57:0020060.0210.000200.002016-12-21 18:57:00
1158122116NSEX01V1237NSEX01VEast PassageCentral BasinS Central Basin47.35862-122.38712016-12-212016DEC12:37:0020060.0180.000170.002016-12-21 20:37:00
\n", "

1159 rows × 17 columns

\n", "
" ], "text/plain": [ " Key Station Site Name Basin \\\n", "0 010218ELIV1151 ELIV Eliza Island Bellingham Bay \n", "1 010818SKETV1058 SKETV South Ketron/Solo Point South Sound \n", "2 011119ELIV1052 ELIV Eliza Island Bellingham Bay \n", "3 011315CAMV1330 CAMV Camano Head Whidbey Basin \n", "4 011315MUKV1415 MUKV Mukilteo Whidbey Basin \n", "... ... ... ... ... \n", "1154 121917LSNT01V1000 LSNT01V Point Williams Central Basin \n", "1155 121917NSEX01V1224 NSEX01V East Passage Central Basin \n", "1156 121918TDBV1327 TDBV Thorndyke Bay Hood Canal \n", "1157 122116LSNT01V1057 LSNT01V Point Williams Central Basin \n", "1158 122116NSEX01V1237 NSEX01V East Passage Central Basin \n", "\n", " Sub Basin Lat Lon Sample Date Sample Year \\\n", "0 Bellingham Bay 48.63795 -122.5694 2018-01-02 2018 \n", "1 South Sound 47.15243 -122.6586 2018-01-08 2018 \n", "2 Bellingham Bay 48.63795 -122.5694 2019-01-11 2019 \n", "3 S Whidbey Basin 48.05901 -122.3873 2015-01-13 2015 \n", "4 S Whidbey Basin 47.97166 -122.3222 2015-01-13 2015 \n", "... ... ... ... ... ... \n", "1154 N Central Basin 47.53333 -122.4333 2017-12-19 2017 \n", "1155 S Central Basin 47.35862 -122.3871 2017-12-19 2017 \n", "1156 N Hood Canal 47.78297 -122.7330 2018-12-19 2018 \n", "1157 N Central Basin 47.53333 -122.4333 2016-12-21 2016 \n", "1158 S Central Basin 47.35862 -122.3871 2016-12-21 2016 \n", "\n", " Sample Month Sample Time Mesh Size Diameter (cm) Station Depth (m) \\\n", "0 JAN 11:51:00 200 60.0 120.700 \n", "1 JAN 10:58:00 200 60.0 132.000 \n", "2 JAN 10:52:00 200 60.0 124.054 \n", "3 JAN 13:30:00 200 60.0 175.000 \n", "4 JAN 14:15:00 200 60.0 200.000 \n", "... ... ... ... ... ... \n", "1154 DEC 10:00:00 200 60.0 210.000 \n", "1155 DEC 12:24:00 200 60.0 180.000 \n", "1156 DEC 13:27:00 200 60.0 112.000 \n", "1157 DEC 10:57:00 200 60.0 210.000 \n", "1158 DEC 12:37:00 200 60.0 180.000 \n", "\n", " Max Tow Depth (m) Min Tow Depth (m) dtUTC \n", "0 110.0 0 2018-01-02 19:51:00 \n", "1 122.0 0 2018-01-08 18:58:00 \n", "2 114.0 0 2019-01-11 18:52:00 \n", "3 170.0 0 2015-01-13 21:30:00 \n", "4 190.0 0 2015-01-13 22:15:00 \n", "... ... ... ... \n", "1154 200.0 0 2017-12-19 18:00:00 \n", "1155 170.0 0 2017-12-19 20:24:00 \n", "1156 109.0 0 2018-12-19 21:27:00 \n", "1157 200.0 0 2016-12-21 18:57:00 \n", "1158 170.0 0 2016-12-21 20:37:00 \n", "\n", "[1159 rows x 17 columns]" ] }, "execution_count": 27, "metadata": {}, "output_type": "execute_result" } ], "source": [ "biomassDF" ] }, { "cell_type": "code", "execution_count": 30, "metadata": {}, "outputs": [], "source": [ "biomassDF2=biomassDF.loc[biomassDF['Sample Year']==2015].copy(deep=True)" ] }, { "cell_type": "code", "execution_count": 31, "metadata": {}, "outputs": [], "source": [ "df2=df.loc[df['Sample Year']==2015].copy(deep=True)" ] }, { "cell_type": "code", "execution_count": 35, "metadata": {}, "outputs": [], "source": [ "def getbiomass(colname,key,origdf,matchcol): \n", " biomassArray=origdf.loc[(origdf.Key==key)&(origdf[matchcol]==colname),\n", " ['Final Carbon (mg/m3)']]\n", " biomass=np.nansum(biomassArray)\n", " \n", " return biomass" ] }, { "cell_type": "code", "execution_count": 37, "metadata": {}, "outputs": [], "source": [ "for icol in colListBroad:\n", " biomassDF[icol]=[getbiomass(icol,ikey,df,'Broad Group') for ikey in biomassDF['Key']]\n", " " ] }, { "cell_type": "code", "execution_count": 41, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "('METRIDIA PACIFICA',\n", " 'NEOCALANUS PLUMCHRUS',\n", " 'CALANOIDA',\n", " 'EUCALANUS BUNGII',\n", " 'CALANUS PACIFICUS',\n", " 'CALANUS MARSHALLAE',\n", " 'NEOCALANUS CRISTATUS',\n", " 'EUCALANUS CALIFORNICUS',\n", " 'EUCALANUS',\n", " 'METRIDIIDAE',\n", " 'NEOCALANUS')" ] }, "execution_count": 41, "metadata": {}, "output_type": "execute_result" } ], "source": [ "colListGenus" ] }, { "cell_type": "code", "execution_count": 42, "metadata": {}, "outputs": [], "source": [ "for icol in colListGenus:\n", " biomassDF[icol]=[getbiomass(icol,ikey,df,'Genus species') for ikey in biomassDF['Key']]" ] }, { "cell_type": "code", "execution_count": 43, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
KeyStationSite NameBasinSub BasinLatLonSample DateSample YearSample Month...NEOCALANUS PLUMCHRUSCALANOIDAEUCALANUS BUNGIICALANUS PACIFICUSCALANUS MARSHALLAENEOCALANUS CRISTATUSEUCALANUS CALIFORNICUSEUCALANUSMETRIDIIDAENEOCALANUS
0010218ELIV1151ELIVEliza IslandBellingham BayBellingham Bay48.63795-122.56942018-01-022018JAN...0.0000000.0000000.0000000.1073320.0000000.00.00.00.00.0
1010818SKETV1058SKETVSouth Ketron/Solo PointSouth SoundSouth Sound47.15243-122.65862018-01-082018JAN...0.0000000.0000000.0000000.1464700.0010610.00.00.00.00.0
2011119ELIV1052ELIVEliza IslandBellingham BayBellingham Bay48.63795-122.56942019-01-112019JAN...0.2510160.0306720.0188110.3728640.0340600.00.00.00.00.0
3011315CAMV1330CAMVCamano HeadWhidbey BasinS Whidbey Basin48.05901-122.38732015-01-132015JAN...0.0000000.0000000.0000001.7022960.0360340.00.00.00.00.0
4011315MUKV1415MUKVMukilteoWhidbey BasinS Whidbey Basin47.97166-122.32222015-01-132015JAN...0.0000000.0000000.0000001.0120930.0000000.00.00.00.00.0
..................................................................
1154121917LSNT01V1000LSNT01VPoint WilliamsCentral BasinN Central Basin47.53333-122.43332017-12-192017DEC...0.0000000.0000000.0000000.3959910.0000000.00.00.00.00.0
1155121917NSEX01V1224NSEX01VEast PassageCentral BasinS Central Basin47.35862-122.38712017-12-192017DEC...0.0000000.0000000.0000000.4913560.0000000.00.00.00.00.0
1156121918TDBV1327TDBVThorndyke BayHood CanalN Hood Canal47.78297-122.73302018-12-192018DEC...0.0000000.0000000.0000000.2329570.0000000.00.00.00.00.0
1157122116LSNT01V1057LSNT01VPoint WilliamsCentral BasinN Central Basin47.53333-122.43332016-12-212016DEC...0.0000000.0000000.0000000.7497170.2024400.00.00.00.00.0
1158122116NSEX01V1237NSEX01VEast PassageCentral BasinS Central Basin47.35862-122.38712016-12-212016DEC...0.0000000.0000000.0000000.6454850.0118190.00.00.00.00.0
\n", "

1159 rows × 35 columns

\n", "
" ], "text/plain": [ " Key Station Site Name Basin \\\n", "0 010218ELIV1151 ELIV Eliza Island Bellingham Bay \n", "1 010818SKETV1058 SKETV South Ketron/Solo Point South Sound \n", "2 011119ELIV1052 ELIV Eliza Island Bellingham Bay \n", "3 011315CAMV1330 CAMV Camano Head Whidbey Basin \n", "4 011315MUKV1415 MUKV Mukilteo Whidbey Basin \n", "... ... ... ... ... \n", "1154 121917LSNT01V1000 LSNT01V Point Williams Central Basin \n", "1155 121917NSEX01V1224 NSEX01V East Passage Central Basin \n", "1156 121918TDBV1327 TDBV Thorndyke Bay Hood Canal \n", "1157 122116LSNT01V1057 LSNT01V Point Williams Central Basin \n", "1158 122116NSEX01V1237 NSEX01V East Passage Central Basin \n", "\n", " Sub Basin Lat Lon Sample Date Sample Year \\\n", "0 Bellingham Bay 48.63795 -122.5694 2018-01-02 2018 \n", "1 South Sound 47.15243 -122.6586 2018-01-08 2018 \n", "2 Bellingham Bay 48.63795 -122.5694 2019-01-11 2019 \n", "3 S Whidbey Basin 48.05901 -122.3873 2015-01-13 2015 \n", "4 S Whidbey Basin 47.97166 -122.3222 2015-01-13 2015 \n", "... ... ... ... ... ... \n", "1154 N Central Basin 47.53333 -122.4333 2017-12-19 2017 \n", "1155 S Central Basin 47.35862 -122.3871 2017-12-19 2017 \n", "1156 N Hood Canal 47.78297 -122.7330 2018-12-19 2018 \n", "1157 N Central Basin 47.53333 -122.4333 2016-12-21 2016 \n", "1158 S Central Basin 47.35862 -122.3871 2016-12-21 2016 \n", "\n", " Sample Month ... NEOCALANUS PLUMCHRUS CALANOIDA EUCALANUS BUNGII \\\n", "0 JAN ... 0.000000 0.000000 0.000000 \n", "1 JAN ... 0.000000 0.000000 0.000000 \n", "2 JAN ... 0.251016 0.030672 0.018811 \n", "3 JAN ... 0.000000 0.000000 0.000000 \n", "4 JAN ... 0.000000 0.000000 0.000000 \n", "... ... ... ... ... ... \n", "1154 DEC ... 0.000000 0.000000 0.000000 \n", "1155 DEC ... 0.000000 0.000000 0.000000 \n", "1156 DEC ... 0.000000 0.000000 0.000000 \n", "1157 DEC ... 0.000000 0.000000 0.000000 \n", "1158 DEC ... 0.000000 0.000000 0.000000 \n", "\n", " CALANUS PACIFICUS CALANUS MARSHALLAE NEOCALANUS CRISTATUS \\\n", "0 0.107332 0.000000 0.0 \n", "1 0.146470 0.001061 0.0 \n", "2 0.372864 0.034060 0.0 \n", "3 1.702296 0.036034 0.0 \n", "4 1.012093 0.000000 0.0 \n", "... ... ... ... \n", "1154 0.395991 0.000000 0.0 \n", "1155 0.491356 0.000000 0.0 \n", "1156 0.232957 0.000000 0.0 \n", "1157 0.749717 0.202440 0.0 \n", "1158 0.645485 0.011819 0.0 \n", "\n", " EUCALANUS CALIFORNICUS EUCALANUS METRIDIIDAE NEOCALANUS \n", "0 0.0 0.0 0.0 0.0 \n", "1 0.0 0.0 0.0 0.0 \n", "2 0.0 0.0 0.0 0.0 \n", "3 0.0 0.0 0.0 0.0 \n", "4 0.0 0.0 0.0 0.0 \n", "... ... ... ... ... \n", "1154 0.0 0.0 0.0 0.0 \n", "1155 0.0 0.0 0.0 0.0 \n", "1156 0.0 0.0 0.0 0.0 \n", "1157 0.0 0.0 0.0 0.0 \n", "1158 0.0 0.0 0.0 0.0 \n", "\n", "[1159 rows x 35 columns]" ] }, "execution_count": 43, "metadata": {}, "output_type": "execute_result" } ], "source": [ "biomassDF" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "biomassDF.keys()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import netCDF4 as nc" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#ftemp=nc.Dataset('/data/eolson/results/MEOPAR/NEMO-forcing-new/grid/mesh_mask201702.nc')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#ftemp.variables.keys()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#ftemp.variables['e3t_0']" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#ftemp.variables['e3t_1d'][:]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fdict={'ptrc_T':1,'grid_T':1}\n", "start_date = dt.datetime(2015,1,1)\n", "end_date = dt.datetime(2016,12,31)\n", "flen=1 # number of days per model output file. always 1 for 201905 and 201812 model runs\n", "namfmt='nowcast' # for 201905 and 201812 model runs, this should always be 'nowcast'\n", "# filemap is dictionary of the form variableName: fileType, where variableName is the name\n", "# of the variable you want to extract and fileType designates the type of \n", "# model output file it can be found in (usually ptrc_T for biology, grid_T for temperature and \n", "# salinity)\n", "filemap={'microzooplankton':'ptrc_T','mesozooplankton':'ptrc_T'}\n", "# fdict is a dictionary mappy file type to its time resolution. Here, 1 means hourly output\n", "# (1h file) and 24 means daily output (1d file). In certain runs, multiple time resolutions \n", "# are available\n", "fdict={'ptrc_T':1,'grid_T':1}" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "PATH= '/results2/SalishSea/nowcast-green.201905/'" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "biomassDF.keys()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "biomassDF.rename(columns={'Max Tow Depth (m)':'Z_lower','Min Tow Depth (m)':'Z_upper','Station Depth (m)':'Z'},inplace=True)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# define log transform function with slight shift to accommodate zero values\n", "def logt(x):\n", " return np.log10(x+.001)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "biomassDF['Year']=[ii.year for ii in biomassDF['dtUTC']]\n", "biomassDF['YD']=et.datetimeToYD(biomassDF['dtUTC'])" ] }, { "cell_type": "raw", "metadata": {}, "source": [ "biomassDF['Amphipoda']=biomassDF['Amphipoda']/8.5\n", "biomassDF['Crabs']=biomassDF['Crabs']/8.5\n", "biomassDF['Krill-Adult Juvenile']=biomassDF['Krill-Adult Juvenile']/8.5\n", "biomassDF['Krill-Calyptopis']=biomassDF['Krill-Calyptopis']/8.5\n", "biomassDF['Krill-Furcilia']=biomassDF['Krill-Furcilia']/8.5\n", "biomassDF['Copepod']=biomassDF['Copepod']/8.5\n", "biomassDF['Larvacea']=biomassDF['Larvacea']/8.5\n", "\n", "\n", "#biomassDF['METRIDIA PACIFICA']=biomassDF['METRIDIA PACIFICA']/8.5\n", "#biomassDF['NEOCALANUS PLUMCHRUS']=biomassDF['NEOCALANUS PLUMCHRUS']/8.5\n", "#biomassDF['CALANOIDA']=biomassDF['CALANOIDA']/8.5\n", "#biomassDF['EUCALANUS BUNGII']=biomassDF['EUCALANUS BUNGII']/8.5\n", "#biomassDF['CALANUS PACIFICUS']=biomassDF['CALANUS PACIFICUS']/8.5\n", "#biomassDF['CALANUS MARSHALLAE']=biomassDF['CALANUS MARSHALLAE']/8.5\n", "#biomassDF['NEOCALANUS CRISTATUS']=biomassDF['NEOCALANUS CRISTATUS']/8.5\n", "#biomassDF['EUCALANUS CALIFORNICUS']=biomassDF['EUCALANUS CALIFORNICUS']/8.5\n", "#biomassDF['EUCALANUS']=biomassDF['EUCALANUS']/8.5\n", "#biomassDF['METRIDIIDAE']=biomassDF['METRIDIIDAE']/8.5\n", "#biomassDF['NEOCALANUS']=biomassDF['NEOCALANUS']/8.5\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "biomassDF" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "biomassDF.keys()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "data=et.matchData(biomassDF,filemap,fdict,start_date,end_date,'nowcast',PATH,1,quiet=False,method='vertNet');" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "data" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "data.keys()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "data['L10Amphipoda']=logt(data['Amphipoda'])\n", "data['L10Crabs']=logt(data['Crabs'])\n", "data['L10Krill-Adult Juvenile']=logt(data['Krill-Adult Juvenile'])\n", "data['L10Krill-Calyptopis']=logt(data['Krill-Calyptopis'])\n", "data['L10Krill-Furcilia']=logt(data['Krill-Furcilia'])\n", "data['L10Copepod']=logt(data['Copepod'])\n", "data['L10Larvacea']=logt(data['Larvacea'])\n", "data['L10mod_microzooplankton']=logt(data['mod_microzooplankton'])\n", "data['L10mod_mesozooplankton']=logt(data['mod_mesozooplankton'])" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "cm1=cmocean.cm.thermal\n", "with nc.Dataset('/data/eolson/results/MEOPAR/NEMO-forcing-new/grid/bathymetry_201702.nc') as bathy:\n", " bathylon=np.copy(bathy.variables['nav_lon'][:,:])\n", " bathylat=np.copy(bathy.variables['nav_lat'][:,:])\n", " bathyZ=np.copy(bathy.variables['Bathymetry'][:,:])" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fig, ax = plt.subplots(1,1,figsize = (6,6))\n", "with nc.Dataset('/ocean/ksuchy/MOAD/NEMO-forcing/grid/bathymetry_201702.nc') as grid:\n", " viz_tools.plot_coastline(ax, grid, coords = 'map',isobath=.1)\n", "colors=('teal','green','firebrick','darkorange','darkviolet','fuchsia',\n", " 'royalblue','darkgoldenrod','mediumspringgreen','deepskyblue')\n", "datreg=dict()\n", "for ind, iregion in enumerate(data.Basin.unique()):\n", " datreg[iregion] = data.loc[data.Basin==iregion]\n", " ax.plot(datreg[iregion]['Lon'], datreg[iregion]['Lat'],'.',\n", " color = colors[ind], label=iregion)\n", "ax.set_ylim(47,51)\n", "ax.legend(bbox_to_anchor=[1,.6,0,0])\n", "ax.set_xlim(-126, -120);\n", "ax.set_title('Observation Locations');\n", "ax.legend(bbox_to_anchor=(1.1, 1.05))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "data.keys()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "def byRegion(ax,obsvar,modvar,lims):\n", " PS=[]\n", " for ind, iregion in enumerate(data.Basin.unique()):\n", " #ax.plot(datreg[iregion]['Lon'], datreg[iregion]['Lat'],'.',\n", " #color = colors[ind], label=iregion)\n", " PS0=et.varvarPlot(ax,datreg[iregion],obsvar,modvar,\n", " cols=(colors[ind],),lname=iregion)\n", " PS.append(PS0)\n", " l=ax.legend(handles=[ip[0][0] for ip in PS])\n", " ax.set_xlabel('Obs')\n", " ax.set_ylabel('Model')\n", " ax.plot(lims,lims,'k-',alpha=.5)\n", " ax.set_xlim(lims)\n", " ax.set_ylim(lims)\n", " ax.set_aspect(1)\n", " return PS,l" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "data['Month']=[ii.month for ii in data['dtUTC']]\n", "JF=data.loc[(data.Month==1)|(data.Month==2)]\n", "MAM=data.loc[(data.Month==3)|(data.Month==4)|(data.Month==5)]\n", "JJA=data.loc[(data.Month==6)|(data.Month==7)|(data.Month==8)]\n", "SOND=data.loc[(data.Month==9)|(data.Month==10)|(data.Month==11)|(data.Month==12)]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "def bySeason(ax,obsvar,modvar,lims):\n", " for axi in ax:\n", " axi.plot(lims,lims,'k-')\n", " axi.set_xlim(lims)\n", " axi.set_ylim(lims)\n", " axi.set_aspect(1)\n", " axi.set_xlabel('Obs')\n", " axi.set_ylabel('Model')\n", " PS=et.varvarPlot(ax[0],JF,obsvar,modvar,cols=('crimson','darkturquoise','navy'))\n", " ax[0].set_title('Winter')\n", " PS=et.varvarPlot(ax[1],MAM,obsvar,modvar,cols=('crimson','darkturquoise','navy'))\n", " ax[1].set_title('Spring')\n", " PS=et.varvarPlot(ax[2],JJA,obsvar,modvar,cols=('crimson','darkturquoise','navy'))\n", " ax[2].set_title('Summer')\n", " PS=et.varvarPlot(ax[3],SOND,obsvar,modvar,cols=('crimson','darkturquoise','navy'))\n", " ax[3].set_title('Autumn')\n", " return " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fig, ax = plt.subplots(1,1,figsize = (16,7)) \n", "PS,l=byRegion(ax,'L10Crabs','L10mod_mesozooplankton',(-2,2))\n", "ax.set_title('Crabs ($\\mu$M) By Region')\n", "ax.legend(bbox_to_anchor=(1.1, 1.05))\n", "\n", "fig, ax = plt.subplots(1,4,figsize = (16,3.3))\n", "bySeason(ax,'L10Crabs','L10mod_mesozooplankton',(-2,2))\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fig, ax = plt.subplots(1,1,figsize = (16,7)) \n", "PS,l=byRegion(ax,'L10Krill-Adult Juvenile','L10mod_mesozooplankton',(-3,3))\n", "ax.set_title('L10Krill-Adult Juveniles ($\\mu$M) By Region')\n", "ax.legend(bbox_to_anchor=(1.1, 1.05))\n", "\n", "fig, ax = plt.subplots(1,4,figsize = (16,3.3))\n", "bySeason(ax,'L10Krill-Adult Juvenile','L10mod_mesozooplankton',(-3,3))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fig, ax = plt.subplots(1,1,figsize = (16,7)) \n", "PS,l=byRegion(ax,'L10Copepod','L10mod_mesozooplankton',(-1.5,1.5))\n", "ax.set_title('L10Copepod($\\mu$M) By Region')\n", "ax.legend(bbox_to_anchor=(1.1, 1.05))\n", "\n", "fig, ax = plt.subplots(1,4,figsize = (16,3.3))\n", "bySeason(ax,'L10Copepod','L10mod_mesozooplankton',(-1.5,1.5))\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fig, ax = plt.subplots(1,1,figsize = (16,7)) \n", "PS,l=byRegion(ax,'L10Larvacea','L10mod_mesozooplankton',(-1.5,1.5))\n", "ax.set_title('L10Larvaceans ($\\mu$M) By Region')\n", "ax.legend(bbox_to_anchor=(1.1, 1.05))\n", "\n", "fig, ax = plt.subplots(1,4,figsize = (16,3.3))\n", "bySeason(ax,'L10Larvacea','L10mod_mesozooplankton',(-1.5,1.5))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fig,ax=plt.subplots(2,4,figsize=(15,7))\n", "fig.subplots_adjust(wspace=.4)\n", "fig.subplots_adjust(hspace=.6)\n", "ax=ax.flatten()\n", "\n", "chplc=('Amphipoda', 'Crabs','Krill-Adult Juvenile', 'Krill-Calyptopis', 'Krill-Furcilia','Copepod','Larvacea')\n", "\n", "mvar1=data['mod_microzooplankton']\n", "mvar2=data['mod_mesozooplankton']\n", "\n", "for ii in range(0,len(chplc)):\n", " ax[ii].plot(logt(data.loc[:,[chplc[ii]]].values),logt(mvar1),'.',ms=1,color='blue',label='Microzoop')\n", " ax[ii].plot(logt(data.loc[:,[chplc[ii]]].values),logt(mvar2),'.',ms=1,color='red',label='Mesozoop')\n", " ax[ii].set_ylabel('Model Class')\n", " ax[ii].set_xlabel(chplc[ii])\n", " ax[ii].set_title('log10[$\\mu$M +.001]')\n", " ax[ii].plot((-3,1.5),(-3,1.5),'k-',alpha=.2)\n", " ax[ii].set_xlim((-3,1.5))\n", " ax[ii].set_ylim((-3,1.5))\n", " ax[ii].set_aspect(1)\n", "ax[0].legend(loc=2, fontsize = 'small')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python (py39)", "language": "python", "name": "py39" }, "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.9.1" } }, "nbformat": 4, "nbformat_minor": 4 }