#!/usr/bin/env python # coding: utf-8 # # inter-run comparisons of N contained in phytoplankton # - S3 # - Sentry Shoal # - Central Node # - JDF # In[1]: import pandas as pd import xarray as xr import datetime as dt import matplotlib.pyplot as plt import cmocean import numpy as np import os import re import dateutil as dutil from salishsea_tools import viz_tools, places, evaltools as et import glob import pickle import matplotlib.dates as mdates import matplotlib as mpl mpl.rc('xtick', labelsize=14) mpl.rc('ytick', labelsize=16) mpl.rc('legend', fontsize=16) mpl.rc('axes', titlesize=16) mpl.rc('figure', titlesize=16) mpl.rc('axes', labelsize=16) mpl.rc('font', size=16) mpl.rcParams['font.size'] = 16 mpl.rcParams['axes.titlesize'] = 16 mpl.rcParams['legend.numpoints'] = 1 get_ipython().run_line_magic('matplotlib', 'inline') # ### definitions # In[2]: ChlToN=1.8 rundict={'202007H':'/home/sallen/202007/202007H', '202007I':'/home/sallen/202007/202007I', '201812':'/results/SalishSea/nowcast-green.201812/', '201905':'/results2/SalishSea/nowcast-green.201905/'} namfmt={'202007H':'long', '202007I':'long', '201812':'nowcast', '201905':'nowcast'} tres={'202007H':24, '202007I':24, '201812':1, '201905':24} cols={'202007H':'c', '202007I':'g', '201812':'b', '201905':'m'} startdate=dt.datetime(2015,2,1) enddate=dt.datetime(2015,4,30) yearstr='2015' len(rundict) # ### load ferry data # In[3]: df1=pd.read_csv('/ocean/eolson/MEOPAR/obs/ONC/turbidity/nearSurface/search3928586/BritishColumbiaFerries_Tsawwassen-DukePoint_Turbidity-ChlorophyllandFluorescence_20140804T234330Z_20150604T070614Z-clean.csv', skiprows=78,usecols=['TimeUTC','Chlorophyll_ug','ChlQC','Lat','LatQC','Lon','LongQC'],header=None, names=('TimeUTC','CDOM','CDOMQC','Chlorophyll_ug','ChlQC','Turbidity_NTU','TurbQC','Lat','LatQC','Lon','LongQC'), dtype={'TimeUTC':str,'Chlorophyll_ug':str,'ChlQC':int,'Lat':str,'LatQC':int, 'Lon':str,'LongQC':int}) df2=pd.read_csv('/ocean/eolson/MEOPAR/obs/ONC/turbidity/nearSurface/search3928586/BritishColumbiaFerries_Tsawwassen-DukePoint_Turbidity-ChlorophyllandFluorescence_20150604T070624Z_20160307T160206Z-clean.csv', skiprows=78,usecols=['TimeUTC','Chlorophyll_ug','ChlQC','Lat','LatQC','Lon','LongQC'],header=None, names=('TimeUTC','CDOM','CDOMQC','Chlorophyll_ug','ChlQC','Turbidity_NTU','TurbQC','Lat','LatQC','Lon','LongQC'), dtype={'TimeUTC':str,'Chlorophyll_ug':str,'ChlQC':int,'Lat':str,'LatQC':int, 'Lon':str,'LongQC':int}) df=pd.concat([df1.drop(df1[df1.TimeUTC'2016'].index)],ignore_index=True) dts=[dt.datetime(int(r[0:4]),int(r[5:7]),int(r[8:10]),int(r[11:13]),int(r[14:16]),int(r[17:19])) for r in df['TimeUTC']] df=df.assign(dts=dts) df['Lat']=pd.to_numeric(df['Lat'],errors='coerce') df['Lon']=pd.to_numeric(df['Lon'],errors='coerce') df['Chlorophyll_ug']=pd.to_numeric(df['Chlorophyll_ug'],errors='coerce') df.head() # In[4]: ij,ii=places.PLACES['S3']['NEMO grid ji'] llon=places.PLACES['S3']['lon lat'][0]-.01 ulon=places.PLACES['S3']['lon lat'][0]+.01 llat=places.PLACES['S3']['lon lat'][1]-.01 ulat=places.PLACES['S3']['lon lat'][1]+.01 iidfnd=(df.Lon>llon)&(df.Lonllat)&(df.Lat