import sqlalchemy
from sqlalchemy import (create_engine, Column, String, Integer, Float, MetaData,
Table, type_coerce, ForeignKey, case)
from sqlalchemy.orm import mapper, create_session, relationship, aliased, Session
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import case
import numpy as np
from sqlalchemy.ext.automap import automap_base
import matplotlib.pyplot as plt
import sqlalchemy.types as types
from sqlalchemy.sql import and_, or_, not_, func
from sqlalchemy.sql import select
import os
from os.path import isfile
import pandas as pd
import netCDF4 as nc
import datetime as dt
from salishsea_tools import evaltools as et, viz_tools
import datetime
import glob
import gsw
import matplotlib as mpl
mpl.rc('xtick', labelsize=16)
mpl.rc('ytick', labelsize=16)
mpl.rc('legend', fontsize=16)
mpl.rc('axes', titlesize=16)
mpl.rc('axes', labelsize=16)
mpl.rc('figure', titlesize=16)
mpl.rc('font', size=16)
mpl.rc('text', usetex=True)
mpl.rc('text.latex', preamble = ','.join(r'''
\usepackage{txfonts}
\usepackage{lmodern}
'''.split()))
mpl.rc('font', family='sans-serif', weight='normal', style='normal')
%matplotlib inline
PATH= '/data/eolson/MEOPAR/SS36runs/linkHC201812/'
start_date = datetime.datetime(2015,1,1)
end_date = datetime.datetime(2018,12,31)
flen=1
namfmt='nowcast'
#varmap={'N':'nitrate','Si':'silicon','Ammonium':'ammonium'}
filemap={'nitrate':'ptrc_T','silicon':'ptrc_T','ammonium':'ptrc_T','diatoms':'ptrc_T','ciliates':'ptrc_T','flagellates':'ptrc_T','vosaline':'grid_T','votemper':'grid_T'}
#gridmap={'nitrate':'tmask','silicon':'tmask','ammonium':'tmask'}
fdict={'ptrc_T':1,'grid_T':1}
df1=et.loadDFO()
df1.head()
Year | Month | Day | Hour | Lat | Lon | Pressure | Depth | Ammonium | Ammonium_units | Chlorophyll_Extracted | Chlorophyll_Extracted_units | N | Si | Silicate_units | AbsSal | ConsT | Z | dtUTC | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1982.0 | 7.0 | 16.0 | 1.35 | 49.25 | -123.943 | NaN | 12.0 | NaN | None | 5.28 | mg/m^3 | 6.6 | 13.6 | umol/L | NaN | NaN | 12.0 | 1982-07-16 01:21:00 |
1 | 1982.0 | 7.0 | 16.0 | 1.35 | 49.25 | -123.943 | NaN | 21.5 | NaN | None | 0.61 | mg/m^3 | 21.2 | 45.0 | umol/L | NaN | NaN | 21.5 | 1982-07-16 01:21:00 |
2 | 1982.0 | 7.0 | 16.0 | 1.35 | 49.25 | -123.943 | NaN | 30.5 | NaN | None | NaN | mg/m^3 | 23.5 | 47.4 | umol/L | NaN | NaN | 30.5 | 1982-07-16 01:21:00 |
3 | 1982.0 | 7.0 | 16.0 | 1.35 | 49.25 | -123.943 | NaN | 52.3 | NaN | None | NaN | mg/m^3 | 28.0 | 50.2 | umol/L | NaN | NaN | 52.3 | 1982-07-16 01:21:00 |
4 | 1982.0 | 7.0 | 16.0 | 1.35 | 49.25 | -123.943 | NaN | 75.4 | NaN | None | NaN | mg/m^3 | 26.5 | 49.1 | umol/L | NaN | NaN | 75.4 | 1982-07-16 01:21:00 |
data=et.matchData(df1,filemap, fdict, start_date, end_date, namfmt, PATH, flen)
(Lat,Lon)= 49.29933333333334 -122.983 not matched to domain (Lat,Lon)= 49.304833333333335 -122.94116666666666 not matched to domain (Lat,Lon)= 50.4882 -126.3484 not matched to domain (Lat,Lon)= 50.6318 -126.4979 not matched to domain (Lat,Lon)= 50.8046 -126.5291 not matched to domain (Lat,Lon)= 50.8762 -126.6183 not matched to domain (Lat,Lon)= 50.9086 -126.5451 not matched to domain progress: 0.0% progress: 97.48488984207448%
fig, ax = plt.subplots(figsize = (6,6))
viz_tools.set_aspect(ax, coords = 'map')
ax.plot(data['Lon'], data['Lat'], 'ro',label='data')
ax.plot(data.loc[(data.Lon < -123.5) & (data.Lat < 48.6),['Lon']],
data.loc[(data.Lon < -123.5) & (data.Lat < 48.6),['Lat']],
'bo', label = 'Juan de Fuca')
ax.plot(data.loc[data.Si>75,['Lon']],data.loc[data.Si>75,['Lat']],'*',color='y',label='high Si')
grid = nc.Dataset('/data/vdo/MEOPAR/NEMO-forcing/grid/bathymetry_201702.nc')
viz_tools.plot_coastline(ax, grid, coords = 'map')
ax.set_ylim(48, 50.5)
ax.legend()
ax.set_xlim(-125.7, -122.5);
N_s, modmean_s, obsmean_s, bias_s, RMSE_s, WSS_s = et.stats(data.loc[data.Z<15,['N']],data.loc[data.Z<15,['mod_nitrate']])
N_i, modmean_i, obsmean_i, bias_i, RMSE_i, WSS_i = et.stats(data.loc[(data.Z>=15)&(data.Z<22),['N']],data.loc[(data.Z>=15)&(data.Z<22),['mod_nitrate']])
N_d, modmean_d, obsmean_d, bias_d, RMSE_d, WSS_d = et.stats(data.loc[data.Z>=22,['N']],data.loc[data.Z>=22,['mod_nitrate']])
N, modmean, obsmean, bias, RMSE, WSS = et.stats(data.loc[:,['N']],data.loc[:,['mod_nitrate']])
print('Nitrate')
print('z<15 m:')
print(' N: {}\n bias: {}\n RMSE: {}\n WSS: {}'.format(N_s,bias_s,RMSE_s,WSS_s))
print('15 m<=z<22 m:')
print(' N: {}\n bias: {}\n RMSE: {}\n WSS: {}'.format(N_i,bias_i,RMSE_i,WSS_i))
print('z>=22 m:')
print(' N: {}\n bias: {}\n RMSE: {}\n WSS: {}'.format(N_d,bias_d,RMSE_d,WSS_d))
print('all:')
print(' N: {}\n bias: {}\n RMSE: {}\n WSS: {}'.format(N,bias,RMSE,WSS))
Nitrate z<15 m: N: 1336 bias: -3.2785366864106606 RMSE: 5.807895579534486 WSS: 0.8817466255506349 15 m<=z<22 m: N: 376 bias: -2.211073728064271 RMSE: 4.371477738722917 WSS: 0.792189747118878 z>=22 m: N: 2834 bias: -0.97561779832537 RMSE: 2.539267744330473 WSS: 0.9064397326172332 all: N: 4546 bias: -1.7545951551365846 RMSE: 3.9387096905675083 WSS: 0.9465988006783927
import importlib
importlib.reload(et)
<module 'salishsea_tools.evaltools' from '/data/eolson/MEOPAR/tools/SalishSeaTools/salishsea_tools/evaltools.py'>
fig, ax = plt.subplots(figsize = (8,8))
ps=et.varvarPlot(ax,data,'N','mod_nitrate','Z',(15,22),'z','m',('mediumseagreen','darkturquoise','navy'))
ax.legend(handles=ps)
ax.set_xlabel('Obs')
ax.set_ylabel('Model')
ax.set_title('NO3 ')
<matplotlib.text.Text at 0x7ff95df7e080>
fig, ax = plt.subplots(1,4,figsize = (24,6))
for axi in ax:
axi.plot(np.arange(0,30),np.arange(0,30),'k-')
ps=et.varvarPlot(ax[0],data.loc[(data.Z<15)&(data.dtUTC<=dt.datetime(2015,4,1)),:],'N','mod_nitrate',cols=('crimson','darkturquoise','navy'))
ax[0].set_title('Feb-Mar')
ii1=(data.Z < 15)&(data.dtUTC<=dt.datetime(2015,5,1))&(data.dtUTC>dt.datetime(2015,4,1))
ps=et.varvarPlot(ax[1],data.loc[ii1,:],'N','mod_nitrate',cols=('crimson','darkturquoise','navy'))
ax[1].set_title('April')
ii2=(data.Z < 15)&(data.dtUTC<=dt.datetime(2015,9,1))&(data.dtUTC>dt.datetime(2015,5,1))
ps=et.varvarPlot(ax[2],data.loc[ii2,:],'N','mod_nitrate',cols=('crimson','darkturquoise','navy'))
ax[2].set_title('May-Jun')
ii3=(data.Z < 15)&(data.dtUTC<=dt.datetime(2015,12,1))&(data.dtUTC>dt.datetime(2015,9,1))
ps=et.varvarPlot(ax[3],data.loc[ii3,:],'N','mod_nitrate',cols=('crimson','darkturquoise','navy'))
ax[3].set_title('Sep-Oct')
#ii4=(data.Z < 15)&(data.dtUTC<=dt.datetime(2016,4,1))&(data.dtUTC>dt.datetime(2016,2,1))
#ps=et.varvarPlot(ax[0],data.loc[ii4,:],obsvar,modvar,cols=('darkturquoise','navy'))
#ii5=(data.Z < 15)&(data.dtUTC<=dt.datetime(2016,5,1))&(data.dtUTC>dt.datetime(2016,4,1))
#ps=et.varvarPlot(ax[1],data.loc[ii5,:],obsvar,modvar,cols=('darkturquoise','navy'))
print('Nitrate, z<15')
print('Feb-Mar:')
et.printstats(data.loc[(data.Z<15)&(data.dtUTC<=dt.datetime(2015,4,1)),:],'N','mod_nitrate')
print('April:')
et.printstats(data.loc[ii1,:],'N','mod_nitrate')
print('May-Jun:')
et.printstats(data.loc[ii2,:],'N','mod_nitrate')
print('Sep-Oct:')
et.printstats(data.loc[ii3,:],'N','mod_nitrate')
fig,ax=plt.subplots(1,1,figsize=(24,1))
plt.plot(data.dtUTC,np.ones(np.shape(data.dtUTC)),'k.')
Nitrate, z<15 Feb-Mar: N: 8 bias: -1.804167585372923 RMSE: 3.3866433502512043 WSS: 0.7581138103454419 April: N: 70 bias: -5.239810629882989 RMSE: 6.896408558235642 WSS: 0.7131106355609722 May-Jun: N: 32 bias: -2.5642608180444224 RMSE: 5.0773242557384375 WSS: 0.7471119544375593 Sep-Oct: N: 26 bias: -2.166149588731617 RMSE: 3.6753659396988327 WSS: 0.9228187762302941
[<matplotlib.lines.Line2D at 0x7ff95bf7f198>]
fig, ax = plt.subplots(figsize = (8,8))
viz_tools.set_aspect(ax, coords = 'map')
ax.plot(data['Lon'], data['Lat'], 'ro',label='data')
dJDF=data.loc[(data.Lon<-123.6)&(data.Lat<48.6)]
ax.plot(dJDF['Lon'],dJDF['Lat'],'b.',label='JDF')
dSJGI=data.loc[(data.Lon>=-123.6)&(data.Lat<48.9)]
ax.plot(dSJGI['Lon'],dSJGI['Lat'],'c.',label='SJGI')
dSOG=data.loc[(data.Lat>=48.9)&(data.Lon>-124.0)]
ax.plot(dSOG['Lon'],dSOG['Lat'],'y.',label='SOG')
dNSOG=data.loc[(data.Lat>=48.9)&(data.Lon<=-124.0)]
ax.plot(dNSOG['Lon'],dNSOG['Lat'],'m.',label='NSOG')
grid = nc.Dataset('/data/vdo/MEOPAR/NEMO-forcing/grid/bathymetry_201702.nc')
viz_tools.plot_coastline(ax, grid, coords = 'map')
ax.set_ylim(48, 50.5)
ax.legend()
ax.set_xlim(-125.7, -122.5);
fig, ax = plt.subplots(figsize = (8,8))
ps1=et.varvarPlot(ax,dJDF,'N','mod_nitrate',cols=('b','darkturquoise','navy'),lname='SJDF')
ps2=et.varvarPlot(ax,dSJGI,'N','mod_nitrate',cols=('c','darkturquoise','navy'),lname='SJGI')
ps3=et.varvarPlot(ax,dSOG,'N','mod_nitrate',cols=('y','darkturquoise','navy'),lname='SOG')
ps4=et.varvarPlot(ax,dNSOG,'N','mod_nitrate',cols=('m','darkturquoise','navy'),lname='NSOGF')
ax.legend(handles=[ps1[0][0],ps2[0][0],ps3[0][0],ps4[0][0]])
ax.set_xlabel('Obs')
ax.set_ylabel('Model')
ax.set_title('NO$_3$ ($\mu$M)')
ax.plot((0,40),(0,40),'-',color='gray',alpha=.5)
[<matplotlib.lines.Line2D at 0x7ff95452cbe0>]
fig, ax = plt.subplots(1,2,figsize = (17,8))
cols=('crimson','red','orangered','darkorange','gold','chartreuse','green','lightseagreen','cyan','darkturquoise','royalblue',
'lightskyblue','blue','darkblue','mediumslateblue','blueviolet','darkmagenta','fuchsia','deeppink','pink')
ii0=start_date
for ii in range(1,13):
iii=(data.Month==ii)
ax[0].plot(data.loc[iii,['mod_nitrate']].values-data.loc[iii,['N']].values, data.loc[iii,['Z']].values,
'.', color = cols[ii],label=str(ii))
ax[1].plot(data.loc[iii,['mod_silicon']].values-data.loc[iii,['Si']].values, data.loc[iii,['Z']].values,
'.', color = cols[ii],label=str(ii))
for axi in (ax[0],ax[1]):
axi.legend(loc=4)
axi.set_ylim(400,0)
axi.set_ylabel('depth (m)')
ax[0].set_xlabel('model - obs N')
ax[1].set_xlabel('model - obs Si')
ax[1].set_xlim(-40,20)
(-40, 20)
fig, ax = plt.subplots(1,1,figsize = (4.5,5))
ax.set_position((.15,.12,.62,.85))
cols=('crimson','fuchsia','orangered','darkorange','gold','chartreuse','green','lightseagreen','cyan','darkturquoise','royalblue',
'navy','purple')#,'darkblue','navy','purple','darkmagenta','fuchsia','deeppink','pink')
ii0=start_date
for ii in range(1,13):
iii=(data.Month==ii)
ax.plot(data.loc[iii,['mod_silicon']].values-data.loc[iii,['Si']].values, data.loc[iii,['Z']].values,
'.', color = cols[ii],label=str(ii))
for axi in (ax,):
axi.legend(loc=4,bbox_to_anchor=[1.24,0.0,.1,.1],frameon=False)
axi.set_ylim(400,0)
axi.set_ylabel('Depth (m)')
ax.set_xlabel('Model - Observed Si ($\muup$M)')
ax.set_xlim(-50,50)
fig.text(0.8, 0.93, 'Month', fontsize=16)
fig.savefig('/home/eolson/pyCode/notebooks/figs/modObsSiVDepth.png',dpi=300,transparent=True)
print('Nitrate')
print('z<15 m:')
et.printstats(data.loc[data.Z<15,:],'Si','mod_silicon')
print('15 m<=z<22 m:')
et.printstats(data.loc[(data.Z>=15)&(data.Z<22),:],'Si','mod_silicon')
print('z>=22 m:')
et.printstats(data.loc[data.Z>=22,:],'Si','mod_silicon')
print('all:')
et.printstats(data,'Si','mod_silicon')
print('obs Si < 50:')
et.printstats(data.loc[data.Si<50,:],'Si','mod_silicon')
Nitrate z<15 m: N: 1336 bias: 2.5958287732472662 RMSE: 9.306181296044691 WSS: 0.8680583725463291 15 m<=z<22 m: N: 376 bias: 0.9253949220129769 RMSE: 6.951009171353076 WSS: 0.8184827174511083 z>=22 m: N: 2833 bias: -1.3971534333664977 RMSE: 7.325894727246283 WSS: 0.7407212300631146 all: N: 4545 bias: -0.03127831572982842 RMSE: 7.931428213123399 WSS: 0.884649289073829 obs Si < 50: N: 2823 bias: 3.6993376116967127 RMSE: 7.433617202918384 WSS: 0.8792006617324462
fig, ax = plt.subplots(figsize = (8,8))
ps=et.varvarPlot(ax,data,'Si','mod_silicon','Z',(15,22),'z','m',('mediumseagreen','darkturquoise','navy'))
ax.legend(handles=ps)
ax.set_xlabel('Obs')
ax.set_ylabel('Model')
ax.set_title('dSi ($\mu$M)')
<matplotlib.text.Text at 0x7ff95e637828>
obsvar='Si'; modvar='mod_silicon'
fig, ax = plt.subplots(1,4,figsize = (24,6))
for axi in ax:
axi.plot(np.arange(0,70),np.arange(0,70),'k-')
ps=et.varvarPlot(ax[0],data.loc[(data.Z<15)&(data.dtUTC<=dt.datetime(2015,4,1)),:],obsvar,modvar,cols=('crimson','darkturquoise','navy'))
ax[0].set_title('Feb-Mar')
ii1=(data.Z < 15)&(data.dtUTC<=dt.datetime(2015,5,1))&(data.dtUTC>dt.datetime(2015,4,1))
ps=et.varvarPlot(ax[1],data.loc[ii1,:],obsvar,modvar,cols=('crimson','darkturquoise','navy'))
ax[1].set_title('April')
ii2=(data.Z < 15)&(data.dtUTC<=dt.datetime(2015,9,1))&(data.dtUTC>dt.datetime(2015,5,1))
ps=et.varvarPlot(ax[2],data.loc[ii2,:],obsvar,modvar,cols=('crimson','darkturquoise','navy'))
ax[2].set_title('May-Jun')
ii3=(data.Z < 15)&(data.dtUTC<=dt.datetime(2015,12,1))&(data.dtUTC>dt.datetime(2015,9,1))
ps=et.varvarPlot(ax[3],data.loc[ii3,:],obsvar,modvar,cols=('crimson','darkturquoise','navy'))
ax[3].set_title('Sep-Oct')
ii4=(data.Z < 15)&(data.dtUTC<=dt.datetime(2016,4,1))&(data.dtUTC>dt.datetime(2016,2,1))
ps=et.varvarPlot(ax[0],data.loc[ii4,:],obsvar,modvar,cols=('darkturquoise','navy'))
ii5=(data.Z < 15)&(data.dtUTC<=dt.datetime(2016,5,1))&(data.dtUTC>dt.datetime(2016,4,1))
ps=et.varvarPlot(ax[1],data.loc[ii5,:],obsvar,modvar,cols=('darkturquoise','navy'))
print('Silicate, z<15')
print('Feb-Mar:')
et.printstats(data.loc[(data.Z<15)&(data.dtUTC<=dt.datetime(2015,4,1)),:],obsvar,modvar)
print('April:')
et.printstats(data.loc[ii1,:],obsvar,modvar)
print('May-Jun:')
et.printstats(data.loc[ii2,:],obsvar,modvar)
print('Sep-Oct:')
et.printstats(data.loc[ii3,:],obsvar,modvar)
fig,ax=plt.subplots(1,1,figsize=(24,1))
plt.plot(data.dtUTC,np.ones(np.shape(data.dtUTC)),'k.')
Silicate, z<15 Feb-Mar: N: 8 bias: -1.7856989097595246 RMSE: 4.185801731596523 WSS: 0.8571304665432427 April: N: 70 bias: 2.354278733934674 RMSE: 8.080153080744388 WSS: 0.8225875253432602 May-Jun: N: 32 bias: 7.123919839859006 RMSE: 10.541828402072646 WSS: 0.59595942287343 Sep-Oct: N: 26 bias: 5.138510131835943 RMSE: 6.004303266758209 WSS: 0.6997888359382411
[<matplotlib.lines.Line2D at 0x7ff9542b6550>]
fig, ax = plt.subplots(figsize = (8,8))
ps1=et.varvarPlot(ax,dJDF,obsvar,modvar,cols=('b','darkturquoise','navy'),lname='SJDF')
ps2=et.varvarPlot(ax,dSJGI,obsvar,modvar,cols=('c','darkturquoise','navy'),lname='SJGI')
ps3=et.varvarPlot(ax,dSOG,obsvar,modvar,cols=('y','darkturquoise','navy'),lname='SOG')
ps4=et.varvarPlot(ax,dNSOG,obsvar,modvar,cols=('m','darkturquoise','navy'),lname='NSOGF')
ax.legend(handles=[ps1[0][0],ps2[0][0],ps3[0][0],ps4[0][0]])
ax.set_xlabel('Obs')
ax.set_ylabel('Model')
ax.set_title('Si ($\mu$M)')
ax.plot((0,80),(0,80),'-',color='gray',alpha=.5)
[<matplotlib.lines.Line2D at 0x7ff954137198>]
fig,ax=plt.subplots(1,2,figsize=(16,7))
p1=ax[0].plot(dJDF['N'],dJDF['Si'],'b.',label='SJDF')
p2=ax[0].plot(dSJGI['N'],dSJGI['Si'],'c.',label='SJGI')
p3=ax[0].plot(dSOG['N'],dSOG['Si'],'y.',label='SOG')
p4=ax[0].plot(dNSOG['N'],dNSOG['Si'],'m.',label='NSOG')
ax[0].set_title('Observed')
ax[0].set_xlabel('N')
ax[0].set_ylabel('Si')
ax[0].set_xlim(0,40)
ax[0].set_ylim(0,85)
ax[0].legend()
p5=ax[1].plot(dJDF['mod_nitrate'],dJDF['mod_silicon'],'b.',label='SJDF')
p6=ax[1].plot(dSJGI['mod_nitrate'],dSJGI['mod_silicon'],'c.',label='SJGI')
p7=ax[1].plot(dSOG['mod_nitrate'],dSOG['mod_silicon'],'y.',label='SOG')
p8=ax[1].plot(dNSOG['mod_nitrate'],dNSOG['mod_silicon'],'m.',label='NSOG')
ax[1].set_title('Model')
ax[1].set_xlabel('N')
ax[1].set_ylabel('Si')
ax[1].set_xlim(0,40)
ax[1].set_ylim(0,85)
ax[1].legend()
ax[0].plot(np.arange(0,35),1.3*np.arange(0,35),'k-')
ax[1].plot(np.arange(0,35),1.3*np.arange(0,35),'k-')
[<matplotlib.lines.Line2D at 0x7ff95bd37160>]
fig,ax=plt.subplots(1,2,figsize=(16,7))
ps=et.varvarPlot(ax[0],data,'N','Si','Month',np.arange(3,12),'Month','',('darkred','red','darkorange','gold','lime','mediumseagreen','darkturquoise','blue','navy','indigo','orchid','fucshia'))
#p1=ax[0].plot(dJDF['N'],dJDF['Si'],'b.',label='SJDF')
#p2=ax[0].plot(dSJGI['N'],dSJGI['Si'],'c.',label='SJGI')
#p3=ax[0].plot(dSOG['N'],dSOG['Si'],'y.',label='SOG')
#p4=ax[0].plot(dNSOG['N'],dNSOG['Si'],'m.',label='NSOG')
#ax[0].set_title('Observed')
#ax[0].set_xlabel('N')
#ax[0].set_ylabel('Si')
ax[0].set_xlim(0,40)
ax[0].set_ylim(0,85)
ax[0].legend()
ps1=et.varvarPlot(ax[1],data,'mod_nitrate','mod_silicon','Month',np.arange(3,12),'Month','',('darkred','red','darkorange','gold','lime','mediumseagreen','darkturquoise','blue','navy','indigo','orchid','fucshia'))
ax[1].set_xlim(0,40)
ax[1].set_ylim(0,85)
ax[1].legend()
ax[0].plot(np.arange(0,35),1.3*np.arange(0,35),'k-')
ax[1].plot(np.arange(0,35),1.3*np.arange(0,35),'k-')
[<matplotlib.lines.Line2D at 0x7ff95be78518>]
fig,ax=plt.subplots(1,2,figsize=(16,7))
p1=ax[0].plot(dJDF['AbsSal'], dJDF['Si']-1.3*dJDF['N'],'b.',label='SJDF')
p2=ax[0].plot(dSJGI['AbsSal'],dSJGI['Si']-1.3*dSJGI['N'],'c.',label='SJGI')
p3=ax[0].plot(dSOG['AbsSal'],dSOG['Si']-1.3*dSOG['N'],'y.',label='SOG')
p4=ax[0].plot(dNSOG['AbsSal'],dNSOG['Si']-1.3*dNSOG['N'],'m.',label='NSOG')
ax[0].set_title('Observed')
ax[0].set_xlabel('S')
ax[0].set_ylabel('Si-1.3N')
ax[0].set_xlim(10,35)
ax[0].set_ylim(0,45)
ax[0].legend()
p5=ax[1].plot(dJDF['mod_vosaline'],dJDF['mod_silicon']-1.3*dJDF['mod_nitrate'],'b.',label='SJDF')
p6=ax[1].plot(dSJGI['mod_vosaline'],dSJGI['mod_silicon']-1.3*dSJGI['mod_nitrate'],'c.',label='SJGI')
p7=ax[1].plot(dSOG['mod_vosaline'],dSOG['mod_silicon']-1.3*dSOG['mod_nitrate'],'y.',label='SOG')
p8=ax[1].plot(dNSOG['mod_vosaline'],dNSOG['mod_silicon']-1.3*dNSOG['mod_nitrate'],'m.',label='NSOG')
ax[1].set_title('Model')
ax[1].set_xlabel('S')
ax[1].set_ylabel('Si-1.3N')
ax[1].set_xlim(10,35)
ax[1].set_ylim(0,45)
ax[1].legend()
<matplotlib.legend.Legend at 0x7ff9540b8b00>
data.loc[data.Si>65,['Month','Lat','Lon','Z','Si']]
Month | Lat | Lon | Z | Si | |
---|---|---|---|---|---|
220 | 4.0 | 49.029667 | -123.436500 | 248.620295 | 67.85 |
221 | 4.0 | 49.029667 | -123.436500 | 298.724014 | 73.00 |
222 | 4.0 | 49.029667 | -123.436500 | 312.485544 | 74.76 |
236 | 4.0 | 49.163333 | -123.551500 | 249.310468 | 68.35 |
237 | 4.0 | 49.163333 | -123.551500 | 297.928316 | 69.99 |
238 | 4.0 | 49.163333 | -123.551500 | 348.217366 | 76.12 |
255 | 4.0 | 49.318833 | -123.799667 | 299.211146 | 66.73 |
256 | 4.0 | 49.318833 | -123.799667 | 346.826687 | 70.58 |
270 | 4.0 | 49.401833 | -124.156000 | 248.710873 | 65.86 |
271 | 4.0 | 49.401833 | -124.156000 | 269.604692 | 70.17 |
285 | 4.0 | 49.443333 | -124.337167 | 248.808959 | 68.77 |
286 | 4.0 | 49.443333 | -124.337167 | 298.712730 | 70.83 |
287 | 4.0 | 49.443333 | -124.337167 | 314.651658 | 77.02 |
320 | 4.0 | 49.591667 | -124.637833 | 162.832911 | 70.41 |
333 | 4.0 | 49.726500 | -124.680333 | 198.887917 | 65.16 |
334 | 4.0 | 49.726500 | -124.680333 | 248.703513 | 69.50 |
335 | 4.0 | 49.726500 | -124.680333 | 298.012014 | 73.43 |
336 | 4.0 | 49.726500 | -124.680333 | 348.298456 | 80.74 |
350 | 4.0 | 49.882500 | -124.993833 | 249.096075 | 75.41 |
351 | 4.0 | 49.882500 | -124.993833 | 309.392440 | 80.29 |
361 | 4.0 | 49.962500 | -125.147167 | 124.882272 | 66.16 |
362 | 4.0 | 49.962500 | -125.147167 | 152.920744 | 68.27 |
385 | 6.0 | 48.652167 | -123.510167 | 99.031907 | 65.58 |
600 | 3.0 | 49.250500 | -123.749000 | 385.230269 | 71.41 |
607 | 3.0 | 49.055500 | -123.372000 | 1.388115 | 68.21 |
620 | 3.0 | 49.505833 | -124.099500 | 413.720144 | 70.46 |
624 | 3.0 | 49.466833 | -124.499333 | 297.425045 | 66.30 |
633 | 3.0 | 49.670333 | -124.272667 | 297.716534 | 78.25 |
642 | 4.0 | 48.651833 | -123.511000 | 99.230124 | 69.23 |
784 | 4.0 | 49.030667 | -123.436833 | 248.620272 | 67.93 |
... | ... | ... | ... | ... | ... |
4357 | 10.0 | 49.591833 | -124.637500 | 164.400000 | 73.88 |
4373 | 10.0 | 49.726667 | -124.680167 | 344.200000 | 65.81 |
4412 | 2.0 | 48.654667 | -123.513167 | 99.600000 | 80.68 |
4539 | 2.0 | 49.443667 | -124.336833 | 314.700000 | 66.00 |
4546 | 2.0 | 49.483333 | -124.766500 | 49.400000 | 67.12 |
4547 | 2.0 | 49.483333 | -124.766500 | 58.300000 | 68.59 |
4589 | 2.0 | 49.726333 | -124.678833 | 347.000000 | 68.11 |
4603 | 2.0 | 49.883500 | -124.993333 | 247.400000 | 65.04 |
4604 | 2.0 | 49.883500 | -124.993333 | 307.700000 | 65.14 |
4718 | 3.0 | 49.029667 | -123.438500 | 297.400000 | 65.37 |
4719 | 3.0 | 49.029667 | -123.438500 | 311.800000 | 65.58 |
4751 | 3.0 | 49.251000 | -123.750500 | 347.000000 | 65.79 |
4752 | 3.0 | 49.251000 | -123.750500 | 394.300000 | 68.71 |
4775 | 4.0 | 48.653333 | -123.510667 | 99.200000 | 80.63 |
4877 | 4.0 | 49.029333 | -123.436333 | 297.700000 | 68.36 |
4878 | 4.0 | 49.029333 | -123.436333 | 311.600000 | 69.25 |
4894 | 4.0 | 49.163667 | -123.549833 | 346.900000 | 67.76 |
4895 | 4.0 | 49.163667 | -123.549833 | 365.500000 | 69.40 |
4914 | 4.0 | 49.318167 | -123.800667 | 341.200000 | 71.17 |
4932 | 4.0 | 49.401833 | -124.156500 | 270.900000 | 66.78 |
4964 | 4.0 | 49.883000 | -124.992500 | 304.700000 | 65.99 |
4979 | 4.0 | 49.726667 | -124.679833 | 297.900000 | 67.59 |
4980 | 4.0 | 49.726667 | -124.679833 | 346.700000 | 72.87 |
4992 | 4.0 | 49.591500 | -124.638333 | 163.700000 | 66.54 |
5020 | 4.0 | 49.444000 | -124.337667 | 297.500000 | 67.55 |
5021 | 4.0 | 49.444000 | -124.337667 | 315.400000 | 69.92 |
5080 | 5.0 | 49.724500 | -124.678833 | 339.500000 | 75.91 |
5099 | 5.0 | 49.673333 | -124.270833 | 199.700000 | 67.32 |
5100 | 5.0 | 49.673333 | -124.270833 | 342.700000 | 73.57 |
5114 | 5.0 | 49.250667 | -123.749833 | 386.800000 | 72.96 |
200 rows × 5 columns
data['l10_obsChl']=np.log10(data['Chlorophyll_Extracted']+0.01)
data['l10_modChl']=np.log10(2*(data['mod_diatoms']+data['mod_ciliates']+data['mod_flagellates'])+0.01)
data['mod_Chl']=2*(data['mod_diatoms']+data['mod_ciliates']+data['mod_flagellates'])
print('log10[Chl+0.01]')
print('z<15 m:')
et.printstats(data.loc[data.Z<15,:],'l10_obsChl','l10_modChl')
print('z>=15 m:')
et.printstats(data.loc[data.Z>=15,:],'l10_obsChl','l10_modChl')
print('all:')
et.printstats(data,'l10_obsChl','l10_modChl')
print('\n')
print('Chl')
print('z<15 m:')
et.printstats(data.loc[data.Z<15,:],'Chlorophyll_Extracted','mod_Chl')
print('z>=15 m:')
et.printstats(data.loc[data.Z>=15,:],'Chlorophyll_Extracted','mod_Chl')
print('all:')
et.printstats(data,'Chlorophyll_Extracted','mod_Chl')
log10[Chl+0.01] z<15 m: N: 818 bias: 0.20696113104649166 RMSE: 0.4695189243442345 WSS: 0.6277932129443751 z>=15 m: N: 357 bias: 0.2929584167254081 RMSE: 0.48617426045658313 WSS: 0.5896734164402759 all: N: 1175 bias: 0.23308966805702203 RMSE: 0.4746411253810355 WSS: 0.6684961459467691 Chl z<15 m: N: 818 bias: 0.6806347093995728 RMSE: 4.417664762830422 WSS: 0.5692166559830008 z>=15 m: N: 357 bias: 0.5246366105754323 RMSE: 1.812982703595353 WSS: 0.5111085535634803 all: N: 1175 bias: 0.6332378402249197 RMSE: 3.8190250314062966 WSS: 0.6150486638588972
fig, ax = plt.subplots(1,2,figsize = (14,6))
ax[0].plot(np.arange(-.6,1.6,.1),np.arange(-.6,1.6,.1),'k-')
ps=et.varvarPlot(ax[0],data,'l10_obsChl','l10_modChl','Z',(5,10,15,20,25),'z','m',('crimson','darkorange','lime','mediumseagreen','darkturquoise','navy'))
ax[0].legend(handles=ps)
ax[0].set_xlabel('Obs')
ax[0].set_ylabel('Model')
ax[0].set_title('log10[Chl ($\mu$g/L)+0.01]')
ax[1].plot(np.arange(0,35),np.arange(0,35),'k-')
ps=et.varvarPlot(ax[1],data,'Chlorophyll_Extracted','mod_Chl','Z',(5,10,15,20,25),'z','m',('crimson','darkorange','lime','mediumseagreen','darkturquoise','navy'))
ax[1].legend(handles=ps)
ax[1].set_xlabel('Obs')
ax[1].set_ylabel('Model')
ax[1].set_title('Chl ($\mu$g/L)')
<matplotlib.text.Text at 0x7ff9306fa518>