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
%matplotlib inline
PATH= '/data/eolson/MEOPAR/SS36runs/CedarRuns/NewLOSOGT2Si/'
start_date = datetime.datetime(2017,1,1)
end_date = datetime.datetime(2017,10,27)
flen=10
namfmt='long'
filemap={'nitrate':'ptrc_T','silicon':'ptrc_T','diatoms':'ptrc_T','ciliates':'ptrc_T',
'flagellates':'ptrc_T'}
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)= 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
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')
iSaa=(data.Lon>-123.7)&(data.Lon<-123.3)&(data.Lat>48.5)&(data.Lat<48.7)
ax.plot(data.loc[iSaa,['Lon']],data.loc[iSaa,['Lat']],'*',color='m',label='Saanich')
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);
data.drop(data.loc[iSaa].index.values,inplace=True)
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: 508 bias: -2.8191344539727297 RMSE: 5.564407121515423 WSS: 0.8705963661296845 15 m<=z<22 m: N: 137 bias: -2.228914300821131 RMSE: 4.007163322236465 WSS: 0.8569396743774275 z>=22 m: N: 945 bias: -0.9146834765641145 RMSE: 2.6725611394876423 WSS: 0.90588260894914 all: N: 1590 bias: -1.6363883315620953 RMSE: 3.9396878629860805 WSS: 0.9444491778202974
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('NO$_3$ ($\mu$M)')
<matplotlib.text.Text at 0x7fa7fd98f748>
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(2017,4,1)),:],'N','mod_nitrate',cols=('crimson','darkturquoise','navy'))
ax[0].set_title('Feb-Mar')
ii1=(data.Z < 15)&(data.dtUTC<=dt.datetime(2017,5,1))&(data.dtUTC>dt.datetime(2017,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(2017,9,1))&(data.dtUTC>dt.datetime(2017,5,1))
ps=et.varvarPlot(ax[2],data.loc[ii2,:],'N','mod_nitrate',cols=('crimson','darkturquoise','navy'))
ax[2].set_title('May-Aug')
ii3=(data.Z < 15)&(data.dtUTC<=dt.datetime(2017,12,1))&(data.dtUTC>dt.datetime(2017,9,1))
ps=et.varvarPlot(ax[3],data.loc[ii3,:],'N','mod_nitrate',cols=('crimson','darkturquoise','navy'))
ax[3].set_title('Sep-Nov')
print('Nitrate, z<15')
print('Feb-Mar:')
et.printstats(data.loc[(data.Z<15)&(data.dtUTC<=dt.datetime(2017,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: 42 bias: -2.6650564620608392 RMSE: 3.748366909975236 WSS: 0.8162290472238456 April: N: 185 bias: -1.1732559626617949 RMSE: 3.8435480038220566 WSS: 0.8910519273652896 May-Jun: N: 184 bias: -3.2686477589834 RMSE: 5.549803054829107 WSS: 0.8373208300221945 Sep-Oct: N: 97 bias: -5.172210210991889 RMSE: 8.33491385631993 WSS: 0.7176466421719732
[<matplotlib.lines.Line2D at 0x7fa7fe91b198>]
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);
dNSOGN=data.loc[(data.Lat>=49.7)&(data.Lon<=-124.0)]
dNSOGS=data.loc[(data.Lat<49.7)&(data.Lat>=49.1)&(data.Lon<=-124.0)]
dNSOGW=data.loc[(data.Lat>=49.1)&(data.Lon<=-124.5)]
dNSOGE=data.loc[(data.Lat>=49.1)&(data.Lon>-124.5)&(data.Lon<=-124.0)]
dBaynes=data.loc[(data.Lat>=49.35)&(data.Lat<49.7)&(data.Lon<-124.65)&(data.Lon>-125.0)]
ax.plot(dNSOGE['Lon'],dNSOGE['Lat'],'go',ms=12,alpha=.03,label='NSOGE')
ax.plot(dNSOGN['Lon'],dNSOGN['Lat'],'kx',ms=8,label='NSOGE')
ax.plot(dBaynes['Lon'],dBaynes['Lat'],'k+',ms=8,label='Baynes')
[<matplotlib.lines.Line2D at 0x7fa7fda48630>]
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.set_xlim(0,35)
ax.set_ylim(0,35)
(0, 35)
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(0,int((end_date-start_date).days/30)):
iii=(data.dtUTC>=(start_date+dt.timedelta(days=ii*30)))&(data.dtUTC<(start_date+dt.timedelta(days=(ii+1)*30)))
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[0].set_xlim(-20,20)
ax[1].set_xlabel('model - obs Si')
ax[1].set_xlim(-40,20)
(-40, 20)
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: 508 bias: -2.3117072311161024 RMSE: 13.74443013329437 WSS: 0.6611649082039461 15 m<=z<22 m: N: 137 bias: -4.115303478937079 RMSE: 9.648512339290395 WSS: 0.7254757669235399 z>=22 m: N: 944 bias: -3.1506108586262798 RMSE: 6.8069636291654465 WSS: 0.8610514240721232 all: N: 1589 bias: -2.9655887354087938 RMSE: 9.795254872673388 WSS: 0.8458561129405198 obs Si < 50: N: 1042 bias: -1.1123510086147377 RMSE: 10.397133576361485 WSS: 0.7123257660386313
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)')
ax.set_xlim(0,80)
ax.set_ylim(0,80)
(0, 80)
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(2017,4,1)),:],obsvar,modvar,cols=('crimson','darkturquoise','navy'))
ax[0].set_title('Feb-Mar')
ii1=(data.Z < 15)&(data.dtUTC<=dt.datetime(2017,5,1))&(data.dtUTC>dt.datetime(2017,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(2017,9,1))&(data.dtUTC>dt.datetime(2017,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(2017,12,1))&(data.dtUTC>dt.datetime(2017,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(2017,4,1))&(data.dtUTC>dt.datetime(2017,2,1))
ps=et.varvarPlot(ax[0],data.loc[ii4,:],obsvar,modvar,cols=('darkturquoise','navy'))
ii5=(data.Z < 15)&(data.dtUTC<=dt.datetime(2017,5,1))&(data.dtUTC>dt.datetime(2017,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(2017,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: 42 bias: -4.227117994399293 RMSE: 5.481165685062623 WSS: 0.9077174119985949 April: N: 185 bias: 7.837566649565826 RMSE: 11.435200749252445 WSS: 0.6732468918721675 May-Jun: N: 184 bias: -3.4961575149453203 RMSE: 11.283975099253079 WSS: 0.6578351671989823 Sep-Oct: N: 97 bias: -18.592424382081965 RMSE: 22.031951020773235 WSS: 0.37504906869013865
[<matplotlib.lines.Line2D at 0x7fa7fe6ea358>]
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='NSOG')
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.set_xlim(0,80)
ax.set_ylim(0,80)
(0, 80)
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 0x7fa7fe426f60>]
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(dNSOGN['N'],dNSOGN['Si'],'r.',label='NSOG_N')
p4=ax[0].plot(dNSOGS['N'],dNSOGS['Si'],'g.',label='NSOG_S')
p4=ax[0].plot(dBaynes['N'],dBaynes['Si'],'.',color='purple',label='Baynes')
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(dNSOGN['mod_nitrate'],dNSOGN['mod_silicon'],'r.',label='NSOG_N')
p8=ax[1].plot(dNSOGS['mod_nitrate'],dNSOGS['mod_silicon'],'g.',label='NSOG_S')
p8=ax[1].plot(dBaynes['mod_nitrate'],dBaynes['mod_silicon'],'.',color='purple',label='Baynes')
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 0x7fa7fd706630>]
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(dNSOGE['N'],dNSOGE['Si'],'r.',label='NSOG_E')
p4=ax[0].plot(dNSOGW['N'],dNSOGW['Si'],'g.',label='NSOG_W')
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(dNSOGE['mod_nitrate'],dNSOGE['mod_silicon'],'r.',label='NSOG_E')
p8=ax[1].plot(dNSOGW['mod_nitrate'],dNSOGW['mod_silicon'],'g.',label='NSOG_W')
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 0x7fa7fec50c18>]
data.loc[data.Si>65,['Month','Lat','Lon','Z','Si']]
Month | Lat | Lon | Z | Si | |
---|---|---|---|---|---|
80 | 2.0 | 49.027667 | -123.437833 | 297.5 | 66.85 |
81 | 2.0 | 49.027667 | -123.437833 | 311.8 | 67.82 |
97 | 2.0 | 49.163167 | -123.551000 | 347.1 | 66.29 |
98 | 2.0 | 49.163167 | -123.551000 | 367.2 | 68.34 |
109 | 2.0 | 49.250833 | -123.749000 | 390.9 | 72.03 |
140 | 2.0 | 49.402000 | -124.155167 | 272.6 | 65.08 |
153 | 2.0 | 49.466500 | -124.499500 | 316.1 | 69.51 |
169 | 2.0 | 49.730000 | -124.685000 | 347.9 | 68.70 |
184 | 2.0 | 49.885333 | -124.995333 | 307.2 | 66.13 |
185 | 2.0 | 49.483667 | -124.766667 | 0.6 | 66.38 |
348 | 4.0 | 49.030000 | -123.437000 | 314.0 | 67.87 |
367 | 4.0 | 49.164167 | -123.549833 | 298.0 | 65.52 |
368 | 4.0 | 49.164167 | -123.549833 | 347.1 | 69.04 |
369 | 4.0 | 49.164167 | -123.549833 | 368.5 | 71.44 |
389 | 4.0 | 49.318333 | -123.799000 | 297.5 | 66.13 |
390 | 4.0 | 49.318333 | -123.799000 | 336.6 | 67.33 |
408 | 4.0 | 49.401833 | -124.155167 | 247.9 | 67.95 |
409 | 4.0 | 49.401833 | -124.155167 | 272.0 | 68.41 |
428 | 4.0 | 49.443333 | -124.337667 | 297.6 | 68.10 |
429 | 4.0 | 49.443333 | -124.337667 | 315.7 | 69.80 |
465 | 4.0 | 49.592000 | -124.637667 | 163.9 | 66.94 |
481 | 4.0 | 49.726333 | -124.680000 | 297.7 | 68.27 |
482 | 4.0 | 49.726333 | -124.680000 | 346.2 | 73.59 |
498 | 4.0 | 49.883667 | -124.993833 | 308.2 | 66.64 |
785 | 6.0 | 49.706833 | -124.724333 | 197.9 | 73.17 |
786 | 6.0 | 49.706833 | -124.724333 | 287.2 | 75.08 |
803 | 6.0 | 49.670667 | -124.272333 | 198.7 | 69.14 |
804 | 6.0 | 49.670667 | -124.272333 | 343.8 | 78.96 |
821 | 6.0 | 49.250833 | -123.751500 | 198.2 | 70.85 |
822 | 6.0 | 49.250833 | -123.751500 | 388.9 | 71.47 |
826 | 6.0 | 49.054667 | -123.373167 | 1.4 | 66.25 |
1072 | 6.0 | 49.029667 | -123.436333 | 247.8 | 69.83 |
1073 | 6.0 | 49.029667 | -123.436333 | 298.1 | 67.66 |
1074 | 6.0 | 49.029667 | -123.436333 | 313.0 | 69.44 |
1090 | 6.0 | 49.163333 | -123.550333 | 297.9 | 69.22 |
1091 | 6.0 | 49.163333 | -123.550333 | 347.1 | 83.94 |
1092 | 6.0 | 49.163333 | -123.550333 | 370.5 | 83.76 |
1117 | 6.0 | 49.318167 | -123.799333 | 297.8 | 69.70 |
1118 | 6.0 | 49.318167 | -123.799333 | 334.5 | 80.44 |
1135 | 6.0 | 49.402000 | -124.154333 | 271.0 | 70.33 |
1153 | 6.0 | 49.443833 | -124.335667 | 247.8 | 70.53 |
1154 | 6.0 | 49.443833 | -124.335667 | 297.5 | 77.42 |
1155 | 6.0 | 49.443833 | -124.335667 | 313.8 | 79.93 |
1189 | 6.0 | 49.591500 | -124.639000 | 149.3 | 71.18 |
1190 | 6.0 | 49.591500 | -124.639000 | 164.3 | 73.79 |
1206 | 6.0 | 49.727000 | -124.680333 | 297.6 | 76.22 |
1207 | 6.0 | 49.727000 | -124.680333 | 348.7 | 82.07 |
1219 | 6.0 | 49.962000 | -125.147333 | 147.9 | 66.55 |
1233 | 6.0 | 49.883167 | -124.993500 | 173.7 | 65.36 |
1234 | 6.0 | 49.883167 | -124.993500 | 198.6 | 66.20 |
1235 | 6.0 | 49.883167 | -124.993500 | 248.1 | 69.74 |
1236 | 6.0 | 49.883167 | -124.993500 | 307.8 | 75.95 |
1513 | 9.0 | 49.705333 | -124.723667 | 284.6 | 67.10 |
1537 | 9.0 | 49.670500 | -124.271833 | 198.7 | 86.13 |
1821 | 10.0 | 49.591833 | -124.637500 | 149.2 | 72.69 |
1822 | 10.0 | 49.591833 | -124.637500 | 164.4 | 73.88 |
1838 | 10.0 | 49.726667 | -124.680167 | 344.2 | 65.81 |
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: 311 bias: -0.005793859848504224 RMSE: 0.5058907823492509 WSS: 0.5728115427783046 z>=15 m: N: 119 bias: 0.04702215063210043 RMSE: 0.46427368577441896 WSS: 0.5788996500906497 all: N: 430 bias: 0.008822663982174739 RMSE: 0.4947239822438732 WSS: 0.6566836678623074 Chl z<15 m: N: 311 bias: -0.9593349216078884 RMSE: 5.223262936623002 WSS: 0.49446424558990476 z>=15 m: N: 119 bias: -0.19475524872255723 RMSE: 1.7164710902242097 WSS: 0.4719567098404429 all: N: 430 bias: -0.7477419423675284 RMSE: 4.532943094392799 WSS: 0.5369111496817489
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 0x7fa7fd73ac18>