import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import datetime as dt
from salishsea_tools import evaltools as et, viz_tools
import os
import datetime as dt
import gsw
import matplotlib.gridspec as gridspec
import matplotlib as mpl
import matplotlib.dates as mdates
import cmocean as cmo
import scipy.interpolate as sinterp
import cmocean
import json
import f90nml
from collections import OrderedDict
fs=16
mpl.rc('xtick', labelsize=fs)
mpl.rc('ytick', labelsize=fs)
mpl.rc('legend', fontsize=fs)
mpl.rc('axes', titlesize=fs)
mpl.rc('axes', labelsize=fs)
mpl.rc('figure', titlesize=fs)
mpl.rc('font', size=fs)
mpl.rc('font', family='sans-serif', weight='normal', style='normal')
import warnings
#warnings.filterwarnings('ignore')
from IPython.display import Markdown, display
%matplotlib inline
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')
df
BugSampleID | Project | Sample Code | Sampling Group | Station | Site Name | Basin | Sub Basin | Latitude | Longitude | ... | Ind Carbon (ug) | Density (#/m3) | Final Carbon (mg/m3) | Species Size Category Aggregation | Size Category Aggregation | Collection Confidence | Carbon Regression EQ | C to DW multipier | DW Regression Equation | C/DW Source | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 93945 | SSMSP | 060817HCB004V1454 | HCSEG | HCB004V | Sisters Point | Hood Canal | S Hood Canal | 47.35620 | -123.0249 | ... | 122.333000 | 5.169013 | 3.185477 | Amphipod | Amphipod | High | C(ug)=(0.0049*([Length(mm)])^2.957)*1000)*37% | C = DW * 37% | DW(ug)=0.0049*([Length(mm)])^2.957)*1000 | Ikeda & Shiga, 1999 |
1 | 93946 | SSMSP | 060817HCB004V1454 | HCSEG | HCB004V | Sisters Point | Hood Canal | S Hood Canal | 47.35620 | -123.0249 | ... | 107.303200 | 0.068013 | 0.010533 | Amphipod | Amphipod | High | C(ug)=(0.0049*([Length(mm)])^2.957)*1000)*37% | C = DW * 37% | DW(ug)=0.0049*([Length(mm)])^2.957)*1000 | Ikeda & Shiga, 1999 |
2 | 93962 | SSMSP | 060817HCB004V1454 | HCSEG | HCB004V | Sisters Point | Hood Canal | S Hood Canal | 47.35620 | -123.0249 | ... | 17.764660 | 21.764267 | 0.397324 | Amphipod | Amphipod | High | C(ug)=(0.0049*([Length(mm)])^2.957)*1000)*37% | C = DW * 37% | DW(ug)=0.0049*([Length(mm)])^2.957)*1000 | Ikeda & Shiga, 1999 |
3 | 94018 | SSMSP | 030917HCB003V1218 | HCSEG | HCB003V | Eldon | Hood Canal | S Hood Canal | 47.53787 | -123.0096 | ... | 343.152100 | 1.730036 | 0.564992 | Amphipod | Amphipod | High | C(ug)=((0.02 * [Length (mm)]^2.1)*1000)*37% | C = DW * 37% | DW(μg) = (0.02 * [Length(mm)]^2.1)*1000 | Kafanov & Fedotov, 1982 |
4 | 94030 | SSMSP | 030917HCB003V1218 | HCSEG | HCB003V | Eldon | Hood Canal | S Hood Canal | 47.53787 | -123.0096 | ... | 17.764660 | 0.812593 | 0.090677 | Amphipod | Amphipod | High | C(ug)=(0.0049*([Length(mm)])^2.957)*1000)*37% | C = DW * 37% | DW(ug)=0.0049*([Length(mm)])^2.957)*1000 | Ikeda & Shiga, 1999 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
81582 | 31509 | SSMSP | 050615MUKV1200 | TUL | MUKV | Mukilteo | Whidbey Basin | S Whidbey Basin | 47.97166 | -122.3222 | ... | 7.450710 | 98.804469 | 0.252324 | Unknown Egg | Unknown Egg | Moderate | C (ug) = 8.0935*[Length (mm)]-1.0883 | C (ug) = 8.0935*[Length (mm)]-1.0883 | NONE | Keister Lab estimate, 2016 |
81583 | 38434 | SSMSP | 081315MUKV1121 | TUL | MUKV | Mukilteo | Whidbey Basin | S Whidbey Basin | 47.97166 | -122.3222 | ... | 7.450710 | 8.634707 | 0.011568 | Unknown Egg | Unknown Egg | Moderate | C (ug) = 8.0935*[Length (mm)]-1.0883 | C (ug) = 8.0935*[Length (mm)]-1.0883 | NONE | Keister Lab estimate, 2016 |
81584 | 38675 | SSMSP | 082615MUKV1116 | TUL | MUKV | Mukilteo | Whidbey Basin | S Whidbey Basin | 47.97166 | -122.3222 | ... | 2.868051 | 27.045302 | 0.077567 | Unknown Egg | Unknown Egg | Moderate | C (ug) = 8.0935*[Length (mm)]-1.0883 | C (ug) = 8.0935*[Length (mm)]-1.0883 | NONE | Keister Lab estimate, 2016 |
81585 | 39535 | SSMSP | 050615CAMV1305 | TUL | CAMV | Camano Head | Whidbey Basin | S Whidbey Basin | 48.05901 | -122.3873 | ... | 7.450710 | 43.628610 | 0.325064 | Unknown Egg | Unknown Egg | Moderate | C (ug) = 8.0935*[Length (mm)]-1.0883 | C (ug) = 8.0935*[Length (mm)]-1.0883 | NONE | Keister Lab estimate, 2016 |
81586 | 104254 | SSMSP | 080318HCB004V1114 | HCSEG | HCB004V | Sisters Point | Hood Canal | S Hood Canal | 47.35620 | -123.0249 | ... | 0.200000 | 4.105091 | 0.004105 | Unknown Nauplius | Unknown Nauplius | High | NONE | NONE | NONE | Keister Lab estimate, 2016 |
81587 rows × 38 columns
df.keys()
Index(['BugSampleID', 'Project', 'Sample Code', 'Sampling Group', 'Station', 'Site Name', 'Basin', 'Sub Basin', 'Latitude', 'Longitude', 'Date Category', 'Sample Date', 'Sample Year', 'Sample Month', 'Sample Time', 'Tow Type', 'Mesh Size', 'Diameter (cm)', 'Station Depth (m)', 'Max Tow Depth (m)', 'Min Tow Depth (m)', 'Vol Filtered (m3)', 'Broad Group', 'Mid-Level Group', '1st Word Taxa', 'Genus species', 'Life History Stage', 'Total Ct', 'Ind Carbon (ug)', 'Density (#/m3)', 'Final Carbon (mg/m3)', 'Species Size Category Aggregation', 'Size Category Aggregation', 'Collection Confidence', 'Carbon Regression EQ', 'C to DW multipier', 'DW Regression Equation', 'C/DW Source'], dtype='object')
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'
],inplace=True)
df
Sample Code | Station | Site Name | Basin | Sub Basin | Latitude | Longitude | Sample Date | Sample Year | Sample Month | ... | Broad Group | Mid-Level Group | 1st Word Taxa | Genus species | Life History Stage | Total Ct | Ind Carbon (ug) | Density (#/m3) | Final Carbon (mg/m3) | Size Category Aggregation | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 060817HCB004V1454 | HCB004V | Sisters Point | Hood Canal | S Hood Canal | 47.35620 | -123.0249 | 2017-06-08 | 2017 | JUN | ... | Amphipod | Amphipoda-Hyperiidea | HYPEROCHE | HYPEROCHE | Unknown | 76.0 | 122.333000 | 5.169013 | 3.185477 | Amphipod |
1 | 060817HCB004V1454 | HCB004V | Sisters Point | Hood Canal | S Hood Canal | 47.35620 | -123.0249 | 2017-06-08 | 2017 | JUN | ... | Amphipod | Amphipoda-Hyperiidea | HYPERIA | HYPERIA | Unknown | 1.0 | 107.303200 | 0.068013 | 0.010533 | Amphipod |
2 | 060817HCB004V1454 | HCB004V | Sisters Point | Hood Canal | S Hood Canal | 47.35620 | -123.0249 | 2017-06-08 | 2017 | JUN | ... | Amphipod | Amphipoda-Hyperiidea | THEMISTO | THEMISTO PACIFICA | Unknown | 320.0 | 17.764660 | 21.764267 | 0.397324 | Amphipod |
3 | 030917HCB003V1218 | HCB003V | Eldon | Hood Canal | S Hood Canal | 47.53787 | -123.0096 | 2017-03-09 | 2017 | MAR | ... | Amphipod | Amphipoda-Cyphocarididae | CYPHOCARIS | CYPHOCARIS CHALLENGERI | Unknown | 66.0 | 343.152100 | 1.730036 | 0.564992 | Amphipod |
4 | 030917HCB003V1218 | HCB003V | Eldon | Hood Canal | S Hood Canal | 47.53787 | -123.0096 | 2017-03-09 | 2017 | MAR | ... | Amphipod | Amphipoda-Hyperiidea | THEMISTO | THEMISTO PACIFICA | Unknown | 31.0 | 17.764660 | 0.812593 | 0.090677 | Amphipod |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
81582 | 050615MUKV1200 | MUKV | Mukilteo | Whidbey Basin | S Whidbey Basin | 47.97166 | -122.3222 | 2015-05-06 | 2015 | MAY | ... | Unknown Egg | Unknown | UNKNOWN | UNKNOWN | EGG Lg | 4500.0 | 7.450710 | 98.804469 | 0.252324 | Unknown Egg |
81583 | 081315MUKV1121 | MUKV | Mukilteo | Whidbey Basin | S Whidbey Basin | 47.97166 | -122.3222 | 2015-08-13 | 2015 | AUG | ... | Unknown Egg | Unknown | UNKNOWN | UNKNOWN | EGG Lg | 385.0 | 7.450710 | 8.634707 | 0.011568 | Unknown Egg |
81584 | 082615MUKV1116 | MUKV | Mukilteo | Whidbey Basin | S Whidbey Basin | 47.97166 | -122.3222 | 2015-08-26 | 2015 | SEP | ... | Unknown Egg | Unknown | UNKNOWN | UNKNOWN | EGG Med | 1000.0 | 2.868051 | 27.045302 | 0.077567 | Unknown Egg |
81585 | 050615CAMV1305 | CAMV | Camano Head | Whidbey Basin | S Whidbey Basin | 48.05901 | -122.3873 | 2015-05-06 | 2015 | MAY | ... | Unknown Egg | Unknown | UNKNOWN | UNKNOWN | EGG Lg | 2025.0 | 7.450710 | 43.628610 | 0.325064 | Unknown Egg |
81586 | 080318HCB004V1114 | HCB004V | Sisters Point | Hood Canal | S Hood Canal | 47.35620 | -123.0249 | 2018-08-03 | 2018 | AUG | ... | Unknown Nauplius | Unknown | UNKNOWN | UNKNOWN | Nauplius | 50.0 | 0.200000 | 4.105091 | 0.004105 | Unknown Nauplius |
81587 rows × 27 columns
df.keys()
Index(['Sample Code', 'Station', 'Site Name', 'Basin', 'Sub Basin', 'Latitude', 'Longitude', 'Sample Date', 'Sample Year', 'Sample Month', 'Sample Time', 'Mesh Size', 'Diameter (cm)', 'Station Depth (m)', 'Max Tow Depth (m)', 'Min Tow Depth (m)', 'Vol Filtered (m3)', 'Broad Group', 'Mid-Level Group', '1st Word Taxa', 'Genus species', 'Life History Stage', 'Total Ct', 'Ind Carbon (ug)', 'Density (#/m3)', 'Final Carbon (mg/m3)', 'Size Category Aggregation'], dtype='object')
df['Broad Group'].unique()
array(['Amphipod', 'Amphipod Egg', 'Anthozoan', 'Arachnida', 'Barnacles', 'Bivalve', 'Bryozoan', 'Cephalopod', 'Chaetognath', 'Chaetognath Egg', 'Cladocera', 'Copepod', 'Copepod Egg', 'Copepod Nauplius', 'Crabs', 'Ctenophore', 'Cumacea', 'Dinoflagellate', 'Echinoderm', 'Fish', 'Fish Egg', 'Gastropod', 'Hydrozoan', 'Insect', 'Isopod', 'Krill Egg', 'Krill Nauplius', 'Krill-Adult Juvenile', 'Krill-Calyptopis', 'Krill-Furcilia', 'Larvacea', 'Mollusk Egg', 'Mysid', 'Mysid Egg', 'Nematode', 'Nemertea', 'Nudibranch', 'Ostracod', 'Phoronid', 'Platyhelminthes', 'Polychaete', 'Pycnogonida', 'Scyphozoan', 'Shrimp', 'Siphonophore', 'Siphonophore Gonophore', 'Tunicate', 'Tunicate Egg', 'Unknown', 'Unknown Egg', 'Unknown Nauplius'], dtype=object)
colListBroad=('Amphipoda', 'Crabs','Krill-Adult Juvenile','Krill-Calyptopis','Krill-Furcilia','Copepod', 'Larvacea',)
colListGenus=('METRIDIA PACIFICA','NEOCALANUS PLUMCHRUS','CALANOIDA','EUCALANUS BUNGII','CALANUS PACIFICUS','CALANUS MARSHALLAE','NEOCALANUS CRISTATUS','EUCALANUS CALIFORNICUS','EUCALANUS','METRIDIIDAE','NEOCALANUS')
#l1=set(df['order'].values)
#l2=set(df['genus species'].values)
#l3=l1|l2
df['Genus species'].unique()
array(['HYPEROCHE', 'HYPERIA', 'THEMISTO PACIFICA', 'CYPHOCARIS CHALLENGERI', 'PRIMNO MACROPA', 'CALLIOPIUS PACIFICUS', 'HYPERIIDEA', 'GAMMARIDEA', 'AMPHIPODA', 'COROPHIUM', 'CAPRELLIDAE', 'CALLIOPIUS CARINATUS', 'PARAPHRONIMA CRASSIPES', 'Anthozoa', 'PEACHIA', 'MITES', 'Arachnidae', 'BARNACLES', 'BIVALVIA', 'BRYOZOA', 'OCTOPODA', 'Teuthida', 'CHAETOGNATHA', 'Chaet/Euphaus Egg', 'EVADNE', 'PODON', 'Evadne', 'CLADOCERA', 'ACARTIA HUDSONICA', 'ACARTIA LONGIREMIS', 'AETIDEUS', 'CENTROPAGES ABDOMINALIS', 'DITRICHOCORYCAEUS ANGLICUS', 'METRIDIA PACIFICA', 'MICROCALANUS', 'OITHONA SIMILIS', 'PARACALANUS', 'PSEUDOCALANUS', 'SCOLECITHRICELLA MINOR', 'PARAEUCHAETA ELONGATA', 'CANDACIA COLUMBIAE', 'CHIRIDIUS GRACILIS', 'OITHONA ATLANTICA', 'PSEUDOCALANUS NEWMANI', 'PSEUDOCALANUS MOULTONI', 'PSEUDOCALANUS Sm', 'THARYBIS FULTONI', 'TRICONIA MINUTA', 'Monstrilloida', 'HARPACTICOIDA', 'GAETANUS PUNGENS', 'NEOCALANUS PLUMCHRUS', 'CALANOIDA', 'TRICONIA CONIFERA', 'EUCALANUS BUNGII', 'TRICONIA BOREALIS', 'OITHONA', 'CALANUS PACIFICUS', 'CALANUS MARSHALLAE', 'TORTANUS DISCAUDATUS', 'PSEUDOCALANUS MIMUS', 'ACARTIA TONSA', 'ONCAEA SUBTILIS', 'Siphonostomatoida', 'ONCAEIDAE', 'BRADYIDIUS SAANICHI', 'PSEUDOCALANUS Lg', 'TRICONIA CANADENSIS', 'NEOCALANUS CRISTATUS', 'PSEUDOCALANUS MINUTUS', 'RACOVITZANUS ANTARCTICUS', 'ACARTIA', 'HEMICYCLOPS', 'ONCAEA PROLATA', 'EPILABIDOCERA AMPHITRITES', 'CTENOCALANUS VANUS', 'SCOLECITHRICELLA OVATA', 'HETERORHABDUS', 'EUCALANUS CALIFORNICUS', 'CYCLOPOIDA', 'TRICONIA SIMILIS', 'SCOLECITHRICELLA Minor', 'Chiridius gracilis', 'GAETANUS SIMPLEX', 'CANDACIA BIPINNATA', 'CANDACIA', 'EUCHIRELLA PULCHRA', 'AETIDEUS ARMATUS', 'TRICONIA', 'GAETANUS MINUTUS', 'EURYTEMORA', 'MESOCALANUS TENUICORNIS', 'EUCALANUS', 'CLAUSOCALANUS', 'SCOLECITHRICELLA DENTATA', 'SCOLECITHRICELLA', 'PLEUROMAMMA ABDOMINALIS', 'Poecilostomatoida', 'EUCHIRELLA PSEUDOPULCHRA', 'EUCHAETIDAE', 'SCAPHOCALANUS BREVICORNIS', 'METRIDIIDAE', 'COPEPODA', 'NEOCALANUS', 'PLEUROMAMMA', 'GAETANUS MILES', 'TRICONIA (tiny)', 'AETIDEUS DIVERGENS', 'CALIGIDAE', 'FARRANULA', 'TORTANUS', 'Tortanus', 'METACARCINUS MAGISTER', 'GLEBOCARCINUS OREGONENSIS', 'METACARCINUS GRACILIS', 'PINNIXA', 'PAGURUS', 'HEMIGRAPSUS', 'GALATHEIDAE', 'PUGETTIA', 'LOPHOPANOPEUS BELLUS', 'CANCER PRODUCTUS', 'FABIA SUBQUADRATA', 'LITHODIDAE', 'OREGONIA GRACILIS', 'PINNOTHERES', 'BRACHYURA', 'Galatheidae', 'Cancridae Sm', 'PINNOTHERIDAE', 'CANCRIDAE', 'Telmessus cheiragonus', 'XANTHOIDEA', 'PACHYCHELES', 'PETROLISTHES', 'Cancridae Lg', 'MAJOIDEA', 'LOPHOLITHODES', 'CHIONOECETES', 'PORCELLANIDAE', 'PAGURIDAE', 'RHINOLITHODES', 'GRAPSIDAE', 'CRYPTOLITHODES', 'DIOGENIDAE', 'ANOMURA', 'PLEUROBRACHIA BACHEI', 'CTENOPHORA', 'Pleurobrachia bachei', 'BEROE', 'CUMACEA', 'NOCTILUCA', 'ECHINODERMATA', 'HOLOTHUROIDEA', 'OPHIUROIDEA', 'FISH', 'Forage FISH', 'Syngnathidae', 'Fish', 'LIMACINA HELICINA', 'CLIONE LIMACINA', 'GASTROPODA', 'GASTROPTERON PACIFICUM', 'Limacina helicina', 'AEQUOREA VICTORIA', 'Mitrocoma cellularia', 'AGLANTHA DIGITALE', 'PANDEIDAE', 'EUPHYSA', 'PROBOSCIDACTYLA FLAVICIRRATA', 'HALITHOLUS', 'RATHKEA', 'OBELIA', 'EUTONINA INDICANS', 'CLYTIA GREGARIA', 'SARSIA', 'LEPTOTHECATA', 'LEUCKARTIARA', 'ANTHOATHECATA', 'HYDROMEDUSA', 'Clytia gregaria', 'Aglantha digitale', 'HYDROID', 'Geomackiea zephyrolata', 'AMPHINEMA', 'AEGINA CITREA', 'STOMOTOCA ATRA', 'BOUGAINVILLIA', 'Euphysa', 'SOLMISSUS', 'HYBOCODON', 'NARCOMEDUSIDA', 'MITROCOMELLA', 'TIAROPSIS', 'HYDROZOA', 'Insecta', 'ISOPODA', 'EUPHAUSIIDAE', 'EUPHAUSIA PACIFICA', 'THYSANOESSA', 'THYSANOESSA RASCHII', 'NEMATOSCELIS DIFFICILIS', 'THYSANOESSA SPINIFERA', 'THYSANOESSA LONGIPES', 'FRITILLARIA', 'OIKOPLEURA', 'LARVACEA', 'LITTORINA', 'ALIENACANTHOMYSIS MACROPSIS', 'METERYTHROPS ROBUSTUS', 'PACIFACANTHOMYSIS NEPHROPHTHALMA', 'MYSIDELLA AMERICANA', 'MYSIDACEA', 'XENACANTHOMYSIS PSEUDOMACROPSIS', 'NEOMYSIS', 'Exacanthomysis davisi', 'PSEUDOMMA', 'NEOMYSIS MERCEDIS', 'NEMATODA', 'Nemertea', 'NUDIBRANCHIA', 'OSTRACODA', 'PHORONIDA', 'PLATYHELMINTHES', 'POLYCHAETA', 'RHYNCHONEREELLA ANGELINI', 'OWENIA', 'TOMOPTERIS', 'PYCNOGONIDA', 'SCYPHOMEDUSA', 'HIPPOLYTIDAE', 'NEOTRYPAEA CALIFORNIENSIS', 'CRANGONIDAE', 'PANDALUS STENOLEPIS', 'PASIPHAEA PACIFICA', 'CALLIANASSIDAE', 'PANDALIDAE', 'CARIDEA', 'UPOGEBIIDAE', 'Caridea', 'SERGESTES SIMILIS', 'DECAPODA', 'MUGGIAEA ATLANTICA', 'Nanomia bijuga', 'Muggiaea atlantica', 'Physonect', 'DIMOPHYES', 'CALYCOPHORAE', 'SIPHONOPHORA', 'ASCIDIACEA', 'SALPA', 'UNKNOWN', 'Unknown'], dtype=object)
df['Sample Date'][0],df['Sample Time'][0]
(Timestamp('2017-06-08 00:00:00'), datetime.time(14, 54))
df['Sample Date'][1000:1020]
1000 2015-08-04 1001 2015-08-04 1002 2015-08-04 1003 2015-08-04 1004 2015-08-17 1005 2015-08-17 1006 2015-08-17 1007 2015-08-18 1008 2015-08-18 1009 2015-08-18 1010 2015-08-18 1011 2015-08-18 1012 2015-07-20 1013 2015-07-20 1014 2015-07-20 1015 2015-08-03 1016 2015-08-03 1017 2015-08-03 1018 2015-07-06 1019 2015-07-06 Name: Sample Date, dtype: datetime64[ns]
df['dtPac']=[dt.datetime.combine(idate, itime) for idate, itime \
in zip(df['Sample Date'],df['Sample Time'])]
df['dtUTC']=[et.pac_to_utc(ii) for ii in df['dtPac']]
df['dtUTC']
0 2017-06-08 21:54:00 1 2017-06-08 21:54:00 2 2017-06-08 21:54:00 3 2017-03-09 20:18:00 4 2017-03-09 20:18:00 ... 81582 2015-05-06 19:00:00 81583 2015-08-13 18:21:00 81584 2015-08-26 18:16:00 81585 2015-05-06 20:05:00 81586 2018-08-03 18:14:00 Name: dtUTC, Length: 81587, dtype: datetime64[ns]
df.rename(columns={'Sample Code':'Key','Latitude':'Lat','Longitude':'Lon'},inplace=True)
df.loc[0]
Key 060817HCB004V1454 Station HCB004V Site Name Sisters Point Basin Hood Canal Sub Basin S Hood Canal Lat 47.3562 Lon -123.025 Sample Date 2017-06-08 00:00:00 Sample Year 2017 Sample Month JUN Sample Time 14:54:00 Mesh Size 200 Diameter (cm) 60 Station Depth (m) 52 Max Tow Depth (m) 47 Min Tow Depth (m) 0 Vol Filtered (m3) 14.703 Broad Group Amphipod Mid-Level Group Amphipoda-Hyperiidea 1st Word Taxa HYPEROCHE Genus species HYPEROCHE Life History Stage Unknown Total Ct 76 Ind Carbon (ug) 122.333 Density (#/m3) 5.16901 Final Carbon (mg/m3) 3.18548 Size Category Aggregation Amphipod dtPac 2017-06-08 14:54:00 dtUTC 2017-06-08 21:54:00 Name: 0, dtype: object
towIDlist=['Key','Station', 'Site Name', 'Basin', 'Sub Basin', 'Lat',
'Lon', 'Sample Date', 'Sample Year', 'Sample Month',
'Sample Time', 'Mesh Size', 'Diameter (cm)', 'Station Depth (m)',
'Max Tow Depth (m)', 'Min Tow Depth (m)','dtUTC']
towIDlist2=['Key', 'Station', 'Sample Date','Sample Time','dtUTC']
len(np.unique(df['Key']))
1159
len(df.groupby(towIDlist)),len(df.groupby(towIDlist2)),len(df.groupby(['Key']))
(2168, 1159, 1159)
biomassDF=df.groupby(towIDlist2,as_index=False).first()\
.loc[:,towIDlist].copy(deep=True)
biomassDF.keys()
Index(['Key', 'Station', 'Site Name', 'Basin', 'Sub Basin', 'Lat', 'Lon', 'Sample Date', 'Sample Year', 'Sample Month', 'Sample Time', 'Mesh Size', 'Diameter (cm)', 'Station Depth (m)', 'Max Tow Depth (m)', 'Min Tow Depth (m)', 'dtUTC'], dtype='object')
biomassDF
Key | Station | Site Name | Basin | Sub Basin | Lat | Lon | Sample Date | Sample Year | Sample Month | Sample Time | Mesh Size | Diameter (cm) | Station Depth (m) | Max Tow Depth (m) | Min Tow Depth (m) | dtUTC | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 010218ELIV1151 | ELIV | Eliza Island | Bellingham Bay | Bellingham Bay | 48.63795 | -122.5694 | 2018-01-02 | 2018 | JAN | 11:51:00 | 200 | 60.0 | 120.700 | 110.0 | 0 | 2018-01-02 19:51:00 |
1 | 010818SKETV1058 | SKETV | South Ketron/Solo Point | South Sound | South Sound | 47.15243 | -122.6586 | 2018-01-08 | 2018 | JAN | 10:58:00 | 200 | 60.0 | 132.000 | 122.0 | 0 | 2018-01-08 18:58:00 |
2 | 011119ELIV1052 | ELIV | Eliza Island | Bellingham Bay | Bellingham Bay | 48.63795 | -122.5694 | 2019-01-11 | 2019 | JAN | 10:52:00 | 200 | 60.0 | 124.054 | 114.0 | 0 | 2019-01-11 18:52:00 |
3 | 011315CAMV1330 | CAMV | Camano Head | Whidbey Basin | S Whidbey Basin | 48.05901 | -122.3873 | 2015-01-13 | 2015 | JAN | 13:30:00 | 200 | 60.0 | 175.000 | 170.0 | 0 | 2015-01-13 21:30:00 |
4 | 011315MUKV1415 | MUKV | Mukilteo | Whidbey Basin | S Whidbey Basin | 47.97166 | -122.3222 | 2015-01-13 | 2015 | JAN | 14:15:00 | 200 | 60.0 | 200.000 | 190.0 | 0 | 2015-01-13 22:15:00 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
1154 | 121917LSNT01V1000 | LSNT01V | Point Williams | Central Basin | N Central Basin | 47.53333 | -122.4333 | 2017-12-19 | 2017 | DEC | 10:00:00 | 200 | 60.0 | 210.000 | 200.0 | 0 | 2017-12-19 18:00:00 |
1155 | 121917NSEX01V1224 | NSEX01V | East Passage | Central Basin | S Central Basin | 47.35862 | -122.3871 | 2017-12-19 | 2017 | DEC | 12:24:00 | 200 | 60.0 | 180.000 | 170.0 | 0 | 2017-12-19 20:24:00 |
1156 | 121918TDBV1327 | TDBV | Thorndyke Bay | Hood Canal | N Hood Canal | 47.78297 | -122.7330 | 2018-12-19 | 2018 | DEC | 13:27:00 | 200 | 60.0 | 112.000 | 109.0 | 0 | 2018-12-19 21:27:00 |
1157 | 122116LSNT01V1057 | LSNT01V | Point Williams | Central Basin | N Central Basin | 47.53333 | -122.4333 | 2016-12-21 | 2016 | DEC | 10:57:00 | 200 | 60.0 | 210.000 | 200.0 | 0 | 2016-12-21 18:57:00 |
1158 | 122116NSEX01V1237 | NSEX01V | East Passage | Central Basin | S Central Basin | 47.35862 | -122.3871 | 2016-12-21 | 2016 | DEC | 12:37:00 | 200 | 60.0 | 180.000 | 170.0 | 0 | 2016-12-21 20:37:00 |
1159 rows × 17 columns
biomassDF2=biomassDF.loc[biomassDF['Sample Year']==2015].copy(deep=True)
df2=df.loc[df['Sample Year']==2015].copy(deep=True)
def getbiomass(colname,key,origdf,matchcol):
biomassArray=origdf.loc[(origdf.Key==key)&(origdf[matchcol]==colname),
['Final Carbon (mg/m3)']]
biomass=np.nansum(biomassArray)
return biomass
for icol in colListBroad:
biomassDF[icol]=[getbiomass(icol,ikey,df,'Broad Group') for ikey in biomassDF['Key']]
colListGenus
('METRIDIA PACIFICA', 'NEOCALANUS PLUMCHRUS', 'CALANOIDA', 'EUCALANUS BUNGII', 'CALANUS PACIFICUS', 'CALANUS MARSHALLAE', 'NEOCALANUS CRISTATUS', 'EUCALANUS CALIFORNICUS', 'EUCALANUS', 'METRIDIIDAE', 'NEOCALANUS')
for icol in colListGenus:
biomassDF[icol]=[getbiomass(icol,ikey,df,'Genus species') for ikey in biomassDF['Key']]
biomassDF
Key | Station | Site Name | Basin | Sub Basin | Lat | Lon | Sample Date | Sample Year | Sample Month | ... | NEOCALANUS PLUMCHRUS | CALANOIDA | EUCALANUS BUNGII | CALANUS PACIFICUS | CALANUS MARSHALLAE | NEOCALANUS CRISTATUS | EUCALANUS CALIFORNICUS | EUCALANUS | METRIDIIDAE | NEOCALANUS | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 010218ELIV1151 | ELIV | Eliza Island | Bellingham Bay | Bellingham Bay | 48.63795 | -122.5694 | 2018-01-02 | 2018 | JAN | ... | 0.000000 | 0.000000 | 0.000000 | 0.107332 | 0.000000 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
1 | 010818SKETV1058 | SKETV | South Ketron/Solo Point | South Sound | South Sound | 47.15243 | -122.6586 | 2018-01-08 | 2018 | JAN | ... | 0.000000 | 0.000000 | 0.000000 | 0.146470 | 0.001061 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
2 | 011119ELIV1052 | ELIV | Eliza Island | Bellingham Bay | Bellingham Bay | 48.63795 | -122.5694 | 2019-01-11 | 2019 | JAN | ... | 0.251016 | 0.030672 | 0.018811 | 0.372864 | 0.034060 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
3 | 011315CAMV1330 | CAMV | Camano Head | Whidbey Basin | S Whidbey Basin | 48.05901 | -122.3873 | 2015-01-13 | 2015 | JAN | ... | 0.000000 | 0.000000 | 0.000000 | 1.702296 | 0.036034 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
4 | 011315MUKV1415 | MUKV | Mukilteo | Whidbey Basin | S Whidbey Basin | 47.97166 | -122.3222 | 2015-01-13 | 2015 | JAN | ... | 0.000000 | 0.000000 | 0.000000 | 1.012093 | 0.000000 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
1154 | 121917LSNT01V1000 | LSNT01V | Point Williams | Central Basin | N Central Basin | 47.53333 | -122.4333 | 2017-12-19 | 2017 | DEC | ... | 0.000000 | 0.000000 | 0.000000 | 0.395991 | 0.000000 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
1155 | 121917NSEX01V1224 | NSEX01V | East Passage | Central Basin | S Central Basin | 47.35862 | -122.3871 | 2017-12-19 | 2017 | DEC | ... | 0.000000 | 0.000000 | 0.000000 | 0.491356 | 0.000000 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
1156 | 121918TDBV1327 | TDBV | Thorndyke Bay | Hood Canal | N Hood Canal | 47.78297 | -122.7330 | 2018-12-19 | 2018 | DEC | ... | 0.000000 | 0.000000 | 0.000000 | 0.232957 | 0.000000 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
1157 | 122116LSNT01V1057 | LSNT01V | Point Williams | Central Basin | N Central Basin | 47.53333 | -122.4333 | 2016-12-21 | 2016 | DEC | ... | 0.000000 | 0.000000 | 0.000000 | 0.749717 | 0.202440 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
1158 | 122116NSEX01V1237 | NSEX01V | East Passage | Central Basin | S Central Basin | 47.35862 | -122.3871 | 2016-12-21 | 2016 | DEC | ... | 0.000000 | 0.000000 | 0.000000 | 0.645485 | 0.011819 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
1159 rows × 35 columns
biomassDF.keys()
import netCDF4 as nc
#ftemp=nc.Dataset('/data/eolson/results/MEOPAR/NEMO-forcing-new/grid/mesh_mask201702.nc')
#ftemp.variables.keys()
#ftemp.variables['e3t_0']
#ftemp.variables['e3t_1d'][:]
fdict={'ptrc_T':1,'grid_T':1}
start_date = dt.datetime(2015,1,1)
end_date = dt.datetime(2016,12,31)
flen=1 # number of days per model output file. always 1 for 201905 and 201812 model runs
namfmt='nowcast' # for 201905 and 201812 model runs, this should always be 'nowcast'
# filemap is dictionary of the form variableName: fileType, where variableName is the name
# of the variable you want to extract and fileType designates the type of
# model output file it can be found in (usually ptrc_T for biology, grid_T for temperature and
# salinity)
filemap={'microzooplankton':'ptrc_T','mesozooplankton':'ptrc_T'}
# fdict is a dictionary mappy file type to its time resolution. Here, 1 means hourly output
# (1h file) and 24 means daily output (1d file). In certain runs, multiple time resolutions
# are available
fdict={'ptrc_T':1,'grid_T':1}
PATH= '/results2/SalishSea/nowcast-green.201905/'
biomassDF.keys()
biomassDF.rename(columns={'Max Tow Depth (m)':'Z_lower','Min Tow Depth (m)':'Z_upper','Station Depth (m)':'Z'},inplace=True)
# define log transform function with slight shift to accommodate zero values
def logt(x):
return np.log10(x+.001)
biomassDF['Year']=[ii.year for ii in biomassDF['dtUTC']]
biomassDF['YD']=et.datetimeToYD(biomassDF['dtUTC'])
biomassDF
biomassDF.keys()
data=et.matchData(biomassDF,filemap,fdict,start_date,end_date,'nowcast',PATH,1,quiet=False,method='vertNet');
data
data.keys()
data['L10Amphipoda']=logt(data['Amphipoda'])
data['L10Crabs']=logt(data['Crabs'])
data['L10Krill-Adult Juvenile']=logt(data['Krill-Adult Juvenile'])
data['L10Krill-Calyptopis']=logt(data['Krill-Calyptopis'])
data['L10Krill-Furcilia']=logt(data['Krill-Furcilia'])
data['L10Copepod']=logt(data['Copepod'])
data['L10Larvacea']=logt(data['Larvacea'])
data['L10mod_microzooplankton']=logt(data['mod_microzooplankton'])
data['L10mod_mesozooplankton']=logt(data['mod_mesozooplankton'])
cm1=cmocean.cm.thermal
with nc.Dataset('/data/eolson/results/MEOPAR/NEMO-forcing-new/grid/bathymetry_201702.nc') as bathy:
bathylon=np.copy(bathy.variables['nav_lon'][:,:])
bathylat=np.copy(bathy.variables['nav_lat'][:,:])
bathyZ=np.copy(bathy.variables['Bathymetry'][:,:])
fig, ax = plt.subplots(1,1,figsize = (6,6))
with nc.Dataset('/ocean/ksuchy/MOAD/NEMO-forcing/grid/bathymetry_201702.nc') as grid:
viz_tools.plot_coastline(ax, grid, coords = 'map',isobath=.1)
colors=('teal','green','firebrick','darkorange','darkviolet','fuchsia',
'royalblue','darkgoldenrod','mediumspringgreen','deepskyblue')
datreg=dict()
for ind, iregion in enumerate(data.Basin.unique()):
datreg[iregion] = data.loc[data.Basin==iregion]
ax.plot(datreg[iregion]['Lon'], datreg[iregion]['Lat'],'.',
color = colors[ind], label=iregion)
ax.set_ylim(47,51)
ax.legend(bbox_to_anchor=[1,.6,0,0])
ax.set_xlim(-126, -120);
ax.set_title('Observation Locations');
ax.legend(bbox_to_anchor=(1.1, 1.05))
data.keys()
def byRegion(ax,obsvar,modvar,lims):
PS=[]
for ind, iregion in enumerate(data.Basin.unique()):
#ax.plot(datreg[iregion]['Lon'], datreg[iregion]['Lat'],'.',
#color = colors[ind], label=iregion)
PS0=et.varvarPlot(ax,datreg[iregion],obsvar,modvar,
cols=(colors[ind],),lname=iregion)
PS.append(PS0)
l=ax.legend(handles=[ip[0][0] for ip in PS])
ax.set_xlabel('Obs')
ax.set_ylabel('Model')
ax.plot(lims,lims,'k-',alpha=.5)
ax.set_xlim(lims)
ax.set_ylim(lims)
ax.set_aspect(1)
return PS,l
data['Month']=[ii.month for ii in data['dtUTC']]
JF=data.loc[(data.Month==1)|(data.Month==2)]
MAM=data.loc[(data.Month==3)|(data.Month==4)|(data.Month==5)]
JJA=data.loc[(data.Month==6)|(data.Month==7)|(data.Month==8)]
SOND=data.loc[(data.Month==9)|(data.Month==10)|(data.Month==11)|(data.Month==12)]
def bySeason(ax,obsvar,modvar,lims):
for axi in ax:
axi.plot(lims,lims,'k-')
axi.set_xlim(lims)
axi.set_ylim(lims)
axi.set_aspect(1)
axi.set_xlabel('Obs')
axi.set_ylabel('Model')
PS=et.varvarPlot(ax[0],JF,obsvar,modvar,cols=('crimson','darkturquoise','navy'))
ax[0].set_title('Winter')
PS=et.varvarPlot(ax[1],MAM,obsvar,modvar,cols=('crimson','darkturquoise','navy'))
ax[1].set_title('Spring')
PS=et.varvarPlot(ax[2],JJA,obsvar,modvar,cols=('crimson','darkturquoise','navy'))
ax[2].set_title('Summer')
PS=et.varvarPlot(ax[3],SOND,obsvar,modvar,cols=('crimson','darkturquoise','navy'))
ax[3].set_title('Autumn')
return
fig, ax = plt.subplots(1,1,figsize = (16,7))
PS,l=byRegion(ax,'L10Crabs','L10mod_mesozooplankton',(-2,2))
ax.set_title('Crabs ($\mu$M) By Region')
ax.legend(bbox_to_anchor=(1.1, 1.05))
fig, ax = plt.subplots(1,4,figsize = (16,3.3))
bySeason(ax,'L10Crabs','L10mod_mesozooplankton',(-2,2))
fig, ax = plt.subplots(1,1,figsize = (16,7))
PS,l=byRegion(ax,'L10Krill-Adult Juvenile','L10mod_mesozooplankton',(-3,3))
ax.set_title('L10Krill-Adult Juveniles ($\mu$M) By Region')
ax.legend(bbox_to_anchor=(1.1, 1.05))
fig, ax = plt.subplots(1,4,figsize = (16,3.3))
bySeason(ax,'L10Krill-Adult Juvenile','L10mod_mesozooplankton',(-3,3))
fig, ax = plt.subplots(1,1,figsize = (16,7))
PS,l=byRegion(ax,'L10Copepod','L10mod_mesozooplankton',(-1.5,1.5))
ax.set_title('L10Copepod($\mu$M) By Region')
ax.legend(bbox_to_anchor=(1.1, 1.05))
fig, ax = plt.subplots(1,4,figsize = (16,3.3))
bySeason(ax,'L10Copepod','L10mod_mesozooplankton',(-1.5,1.5))
fig, ax = plt.subplots(1,1,figsize = (16,7))
PS,l=byRegion(ax,'L10Larvacea','L10mod_mesozooplankton',(-1.5,1.5))
ax.set_title('L10Larvaceans ($\mu$M) By Region')
ax.legend(bbox_to_anchor=(1.1, 1.05))
fig, ax = plt.subplots(1,4,figsize = (16,3.3))
bySeason(ax,'L10Larvacea','L10mod_mesozooplankton',(-1.5,1.5))
fig,ax=plt.subplots(2,4,figsize=(15,7))
fig.subplots_adjust(wspace=.4)
fig.subplots_adjust(hspace=.6)
ax=ax.flatten()
chplc=('Amphipoda', 'Crabs','Krill-Adult Juvenile', 'Krill-Calyptopis', 'Krill-Furcilia','Copepod','Larvacea')
mvar1=data['mod_microzooplankton']
mvar2=data['mod_mesozooplankton']
for ii in range(0,len(chplc)):
ax[ii].plot(logt(data.loc[:,[chplc[ii]]].values),logt(mvar1),'.',ms=1,color='blue',label='Microzoop')
ax[ii].plot(logt(data.loc[:,[chplc[ii]]].values),logt(mvar2),'.',ms=1,color='red',label='Mesozoop')
ax[ii].set_ylabel('Model Class')
ax[ii].set_xlabel(chplc[ii])
ax[ii].set_title('log10[$\mu$M +.001]')
ax[ii].plot((-3,1.5),(-3,1.5),'k-',alpha=.2)
ax[ii].set_xlim((-3,1.5))
ax[ii].set_ylim((-3,1.5))
ax[ii].set_aspect(1)
ax[0].legend(loc=2, fontsize = 'small')