{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import numpy as np\n", "import pickle\n", "import matplotlib.pyplot as plt\n", "import datetime as dt\n", "from salishsea_tools import evaltools as et" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "# read in stored station info (links station names to locations)\n", "dir0 = '/ocean/eolson/MEOPAR/obs/WADE/ptools_data/ecology/'\n", "sta_df = pd.read_pickle(dir0 + 'sta_df.p')" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "bottle_fn = dir0 + 'raw/ParkerMacCready2019CTDDataFeb2020.xlsx'\n", "sheet_name = '2018-2019NutrientData'\n", "sheet_chl = '2018-2019ChlaLabData'\n", "bot = pd.read_excel(bottle_fn, sheet_name=sheet_name,engine='openpyxl')\n", "chl = pd.read_excel(bottle_fn, sheet_name=sheet_chl, engine='openpyxl')" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "bot.dropna(how='all',inplace=True) # drop rows where all values are NaN\n", "chl.dropna(how='all',inplace=True)\n", "bot.dropna(subset=['Sampling Depth'],inplace=True) # drop rows with NaN sampling depths because nominal depths do not appear reliable\n", "chl.dropna(subset=['Sampling Depth'],inplace=True)\n", "# drop rows with no useful data:\n", "bot.dropna(how='all',subset=['NH4_Lab','NO2_Lab','NO3_Lab','PO4_Lab','SiOH4_Lab'],inplace=True)\n", "chl.dropna(how='all',subset=['Chla_Lab'],inplace=True)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "# drop rows that appear to have misaligned Sampling depths\n", "#Date\tStation\tNiskin\tNomdepth\tSampling Depth\tCTD Cast Rep\tChla_Lab\tChla_QC\t\n", " #2019-02-26\tDNA001\t12.0\t30\t1.136\t1.0\t1.9216\t2.0\t\n", "chl.drop(chl.loc[(chl.Date==dt.datetime(2019,2,26))&(chl.Station=='DNA001')&\\\n", " (chl.Nomdepth==30)&(chl['Sampling Depth']==1.9216)].index,inplace=True)\n", "# also remove from chl: \n", "# 2018-02-01 HCB010 9.0 30 10.545 sample is probably actually 30 m based on nuts\n", "# 2018-03-09 CRR001 9.0 30 101.554 \"\n", "chl.drop(chl.loc[(chl.Date==dt.datetime(2018,2,1))&(chl.Station=='HCB010')&\\\n", " (chl.Nomdepth==30)&(chl['Sampling Depth']==10.545)].index,inplace=True)\n", "chl.drop(chl.loc[(chl.Date==dt.datetime(2018,3,9))&(chl.Station=='CRR001')&\\\n", " (chl.Nomdepth==30)&(chl['Sampling Depth']==101.554)].index,inplace=True)\n", "#remove from chl and nuts:\n", "# Date:2019-10-30 Station: ADM001 all 3 values (Nom depth 0,10,30 but sampling depth all ~126.7)\n", "chl.drop(chl.loc[(chl.Date==dt.datetime(2019,10,30))&(chl.Station=='ADM001')].index,inplace=True)\n", "bot.drop(chl.loc[(chl.Date==dt.datetime(2019,10,30))&(chl.Station=='ADM001')].index,inplace=True)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "# average over rows having identical (Date,Station,Niskin,Sampling Depth) [replicates]\n", "# ignore Nomdepth because it seems to not always be accurate\n", "chl2=pd.DataFrame(chl.groupby(['Date','Station','Niskin','Sampling Depth'],as_index=False).mean())" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | Date | \n", "Station | \n", "Niskin | \n", "Sampling Depth | \n", "CTD Cast Rep | \n", "Chla_Lab | \n", "Chla_QC | \n", "Chla_QA | \n", "Chla_SampleFieldReplicateNumber | \n", "
---|---|---|---|---|---|---|---|---|---|
0 | \n", "2018-01-10 | \n", "PSS019 | \n", "9 | \n", "31.196 | \n", "1.0 | \n", "0.0710 | \n", "2.0 | \n", "3.0 | \n", "1.0 | \n", "
1 | \n", "2018-01-10 | \n", "PSS019 | \n", "11 | \n", "11.404 | \n", "1.0 | \n", "0.1960 | \n", "2.0 | \n", "3.0 | \n", "1.0 | \n", "
2 | \n", "2018-01-10 | \n", "PSS019 | \n", "12 | \n", "1.187 | \n", "1.0 | \n", "0.6673 | \n", "2.0 | \n", "3.0 | \n", "1.0 | \n", "
3 | \n", "2018-01-10 | \n", "SAR003 | \n", "9 | \n", "31.057 | \n", "1.0 | \n", "0.0530 | \n", "2.0 | \n", "3.0 | \n", "1.0 | \n", "
4 | \n", "2018-01-10 | \n", "SAR003 | \n", "11 | \n", "11.146 | \n", "1.0 | \n", "0.2097 | \n", "2.0 | \n", "3.0 | \n", "1.0 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
1787 | \n", "2019-12-19 | \n", "NSQ002 | \n", "9 | \n", "30.676 | \n", "1.0 | \n", "0.3154 | \n", "2.0 | \n", "2.0 | \n", "1.0 | \n", "
1788 | \n", "2019-12-19 | \n", "NSQ002 | \n", "10 | \n", "10.871 | \n", "1.0 | \n", "0.3640 | \n", "2.0 | \n", "2.0 | \n", "1.0 | \n", "
1789 | \n", "2019-12-19 | \n", "NSQ002 | \n", "12 | \n", "1.214 | \n", "1.0 | \n", "0.4397 | \n", "2.0 | \n", "2.0 | \n", "1.0 | \n", "
1790 | \n", "2019-12-19 | \n", "OAK004 | \n", "11 | \n", "11.106 | \n", "1.0 | \n", "0.5765 | \n", "2.0 | \n", "2.0 | \n", "2.0 | \n", "
1791 | \n", "2019-12-19 | \n", "OAK004 | \n", "12 | \n", "1.189 | \n", "1.0 | \n", "0.5765 | \n", "2.0 | \n", "2.0 | \n", "1.0 | \n", "
1792 rows × 9 columns
\n", "\n", " | Station | \n", "Desig | \n", "Descrip | \n", "Basin | \n", "*Max_Depth | \n", "Lat | \n", "Lon | \n", "Date | \n", "Niskin | \n", "Sampling Depth | \n", "... | \n", "SiOH4_QC | \n", "SiOH4_QA | \n", "SiOH4_SampleFieldReplicateNumber | \n", "Unnamed: 36 | \n", "Chla_Lab | \n", "Chla_QC | \n", "Chla_QA | \n", "Chla_SampleFieldReplicateNumber | \n", "dtUTC | \n", "UTCDateTime | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "HCB013 | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "2018-01-10 | \n", "3 | \n", "26.820 | \n", "... | \n", "2.0 | \n", "3.0 | \n", "1.0 | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "
1 | \n", "HCB013 | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "2018-01-10 | \n", "11 | \n", "11.252 | \n", "... | \n", "2.0 | \n", "3.0 | \n", "1.0 | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "
2 | \n", "HCB013 | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "2018-01-10 | \n", "12 | \n", "1.336 | \n", "... | \n", "2.0 | \n", "3.0 | \n", "1.0 | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "
3 | \n", "PSS019 | \n", "C | \n", "Possession Sound - Gedney Island | \n", "Whidbey Basin | \n", "107.0 | \n", "48.010927 | \n", "-122.301250 | \n", "2018-01-10 | \n", "3 | \n", "98.380 | \n", "... | \n", "2.0 | \n", "3.0 | \n", "1.0 | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "2018-01-10 20:34:00 | \n", "
4 | \n", "PSS019 | \n", "C | \n", "Possession Sound - Gedney Island | \n", "Whidbey Basin | \n", "107.0 | \n", "48.010927 | \n", "-122.301250 | \n", "2018-01-10 | \n", "9 | \n", "31.196 | \n", "... | \n", "2.0 | \n", "3.0 | \n", "1.0 | \n", "NaN | \n", "0.0710 | \n", "2.0 | \n", "3.0 | \n", "1.0 | \n", "NaN | \n", "2018-01-10 20:34:00 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
2352 | \n", "SKG003 | \n", "C | \n", "Skagit Bay - Str. Point Red Buoy | \n", "Whidbey Basin | \n", "25.0 | \n", "48.296488 | \n", "-122.489605 | \n", "2018-09-05 | \n", "9 | \n", "10.848 | \n", "... | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "1.2393 | \n", "2.0 | \n", "3.0 | \n", "1.0 | \n", "NaN | \n", "2018-09-05 19:48:00 | \n", "
2353 | \n", "OAK004 | \n", "C | \n", "Oakland Bay - Near Eagle Point | \n", "South Basin | \n", "28.0 | \n", "47.213427 | \n", "-123.077650 | \n", "2018-12-10 | \n", "10 | \n", "0.880 | \n", "... | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "1.0945 | \n", "2.0 | \n", "3.0 | \n", "2.0 | \n", "NaN | \n", "2018-12-10 22:14:00 | \n", "
2354 | \n", "ELB015 | \n", "C | \n", "Elliott Bay - E. of Duwamish Head | \n", "Main Basin | \n", "91.0 | \n", "47.596487 | \n", "-122.369572 | \n", "2019-03-15 | \n", "12 | \n", "0.897 | \n", "... | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "0.8500 | \n", "2.0 | \n", "2.0 | \n", "1.0 | \n", "NaN | \n", "2019-03-15 19:15:00 | \n", "
2355 | \n", "HCB004 | \n", "C | \n", "Hood Canal - Gt. Bend, Sisters Point | \n", "Hood Canal Basin | \n", "53.0 | \n", "47.356205 | \n", "-123.024873 | \n", "2019-08-16 | \n", "4 | \n", "26.098 | \n", "... | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "0.7460 | \n", "2.0 | \n", "2.0 | \n", "1.0 | \n", "NaN | \n", "2019-08-16 20:47:00 | \n", "
2356 | \n", "ADM003 | \n", "C | \n", "Admiralty Inlet (south) | \n", "Admiralty Inlet | \n", "118.0 | \n", "47.878983 | \n", "-122.483195 | \n", "2019-11-14 | \n", "12 | \n", "0.379 | \n", "... | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "0.7404 | \n", "2.0 | \n", "2.0 | \n", "1.0 | \n", "NaN | \n", "2019-11-14 20:06:00 | \n", "
2357 rows × 38 columns
\n", "\n", " | Station | \n", "Desig | \n", "Descrip | \n", "Basin | \n", "*Max_Depth | \n", "Lat | \n", "Lon | \n", "Date | \n", "Niskin | \n", "Z | \n", "... | \n", "SiOH4_QC | \n", "SiOH4_QA | \n", "SiOH4_SampleFieldReplicateNumber | \n", "Unnamed: 36 | \n", "Chla_Lab | \n", "Chla_QC | \n", "Chla_QA | \n", "Chla_SampleFieldReplicateNumber | \n", "dtUTC | \n", "UTCDateTime | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
3 | \n", "PSS019 | \n", "C | \n", "Possession Sound - Gedney Island | \n", "Whidbey Basin | \n", "107.0 | \n", "48.010927 | \n", "-122.301250 | \n", "2018-01-10 | \n", "3 | \n", "98.380 | \n", "... | \n", "2.0 | \n", "3.0 | \n", "1.0 | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "2018-01-10 20:34:00 | \n", "
4 | \n", "PSS019 | \n", "C | \n", "Possession Sound - Gedney Island | \n", "Whidbey Basin | \n", "107.0 | \n", "48.010927 | \n", "-122.301250 | \n", "2018-01-10 | \n", "9 | \n", "31.196 | \n", "... | \n", "2.0 | \n", "3.0 | \n", "1.0 | \n", "NaN | \n", "0.0710 | \n", "2.0 | \n", "3.0 | \n", "1.0 | \n", "NaN | \n", "2018-01-10 20:34:00 | \n", "
5 | \n", "PSS019 | \n", "C | \n", "Possession Sound - Gedney Island | \n", "Whidbey Basin | \n", "107.0 | \n", "48.010927 | \n", "-122.301250 | \n", "2018-01-10 | \n", "11 | \n", "11.404 | \n", "... | \n", "2.0 | \n", "3.0 | \n", "1.0 | \n", "NaN | \n", "0.1960 | \n", "2.0 | \n", "3.0 | \n", "1.0 | \n", "NaN | \n", "2018-01-10 20:34:00 | \n", "
6 | \n", "PSS019 | \n", "C | \n", "Possession Sound - Gedney Island | \n", "Whidbey Basin | \n", "107.0 | \n", "48.010927 | \n", "-122.301250 | \n", "2018-01-10 | \n", "12 | \n", "1.187 | \n", "... | \n", "2.0 | \n", "3.0 | \n", "1.0 | \n", "NaN | \n", "0.6673 | \n", "2.0 | \n", "3.0 | \n", "1.0 | \n", "NaN | \n", "2018-01-10 20:34:00 | \n", "
7 | \n", "SAR003 | \n", "C | \n", "Saratoga Passage - East Point | \n", "Whidbey Basin | \n", "123.0 | \n", "48.107595 | \n", "-122.491542 | \n", "2018-01-10 | \n", "3 | \n", "152.993 | \n", "... | \n", "2.0 | \n", "3.0 | \n", "1.0 | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "2018-01-10 19:41:00 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
2352 | \n", "SKG003 | \n", "C | \n", "Skagit Bay - Str. Point Red Buoy | \n", "Whidbey Basin | \n", "25.0 | \n", "48.296488 | \n", "-122.489605 | \n", "2018-09-05 | \n", "9 | \n", "10.848 | \n", "... | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "1.2393 | \n", "2.0 | \n", "3.0 | \n", "1.0 | \n", "NaN | \n", "2018-09-05 19:48:00 | \n", "
2353 | \n", "OAK004 | \n", "C | \n", "Oakland Bay - Near Eagle Point | \n", "South Basin | \n", "28.0 | \n", "47.213427 | \n", "-123.077650 | \n", "2018-12-10 | \n", "10 | \n", "0.880 | \n", "... | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "1.0945 | \n", "2.0 | \n", "3.0 | \n", "2.0 | \n", "NaN | \n", "2018-12-10 22:14:00 | \n", "
2354 | \n", "ELB015 | \n", "C | \n", "Elliott Bay - E. of Duwamish Head | \n", "Main Basin | \n", "91.0 | \n", "47.596487 | \n", "-122.369572 | \n", "2019-03-15 | \n", "12 | \n", "0.897 | \n", "... | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "0.8500 | \n", "2.0 | \n", "2.0 | \n", "1.0 | \n", "NaN | \n", "2019-03-15 19:15:00 | \n", "
2355 | \n", "HCB004 | \n", "C | \n", "Hood Canal - Gt. Bend, Sisters Point | \n", "Hood Canal Basin | \n", "53.0 | \n", "47.356205 | \n", "-123.024873 | \n", "2019-08-16 | \n", "4 | \n", "26.098 | \n", "... | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "0.7460 | \n", "2.0 | \n", "2.0 | \n", "1.0 | \n", "NaN | \n", "2019-08-16 20:47:00 | \n", "
2356 | \n", "ADM003 | \n", "C | \n", "Admiralty Inlet (south) | \n", "Admiralty Inlet | \n", "118.0 | \n", "47.878983 | \n", "-122.483195 | \n", "2019-11-14 | \n", "12 | \n", "0.379 | \n", "... | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "0.7404 | \n", "2.0 | \n", "2.0 | \n", "1.0 | \n", "NaN | \n", "2019-11-14 20:06:00 | \n", "
2309 rows × 38 columns
\n", "