<jupyter_start><jupyter_text>low summer values also have low nitrate and are associated with higher temperatures; likely biological drawdown rivers north of domain have even higher Si<jupyter_code>obsdirF='/ocean/eolson/MEOPAR/obs/ECRivers/Flow'

Fraser=pd.read_csv(os.path.join(obsdirF,'FraserHopeDaily__Apr-12-2018_11_07_27PM.csv'),skiprows=1)
flow=dict()
#Alouette=pd.read_csv(os.path.join(obsdirF,'AlouetteDaily__Sep-1-2018_12_00_54AM.csv'),skiprows=1)
Sumas=pd.read_csv(os.path.join(obsdirF,'SumasHuntingdonDaily__Apr-12-2018_11_04_56PM.csv'),skiprows=1)
Cheakamus=pd.read_csv(os.path.join(obsdirF,'CheakamusDaily__Aug-31-2018_11_30_09PM.csv'),skiprows=1)
Cowichan=pd.read_csv(os.path.join(obsdirF,'CowichanDaily__Aug-31-2018_11_42_02PM.csv'),skiprows=1)
Englishman=pd.read_csv(os.path.join(obsdirF,'EnglishmanDaily__Aug-31-2018_11_47_05PM.csv'),skiprows=1)
Quinsam=pd.read_csv(os.path.join(obsdirF,'QuinsamDaily__Aug-31-2018_11_52_15PM.csv'),skiprows=1)
Tsolum=pd.read_csv(os.path.join(obsdirF,'TsolumDaily__Aug-31-2018_11_44_58PM.csv'),skiprows=1)
Puntledge=pd.read_csv(os.path.join(obsdirF,'PuntledgeDaily__Sep-4-2018_07_10_42PM.csv'),skiprows=1)
Goldstream=pd.read_csv(os.path.join(obsdirF,'Goldstream_08HA039_Daily__Sep-27-2018_12_47_45AM.csv'),skiprows=1)
Qualicum=pd.read_csv(os.path.join(obsdirF,'QualicumDaily__Sep-4-2018_07_22_26PM.csv'),skiprows=1)
Nanaimo=pd.read_csv(os.path.join(obsdirF,'NanaimoDaily__Sep-4-2018_07_17_25PM.csv'),skiprows=1)
Campbell=pd.read_csv(os.path.join(obsdirF,'Campbell_08HD003_Daily__Sep-27-2018_12_41_44AM.csv'),skiprows=1)
Oyster=pd.read_csv(os.path.join(obsdirF,'Oyster_08HD011_Daily__Sep-27-2018_12_38_53AM.csv'),skiprows=1)
Squamish=pd.read_csv(os.path.join(obsdirF,'Squamish_08GA022_Daily__Sep-27-2018_12_25_48AM.csv'),skiprows=1)
# PARAM=1 is daily discharge in m3/s
flow=dict()
#flow['Alouette']=np.mean(Alouette.loc[Alouette.PARAM==1,['Value']].values)
flow['Sumas']=np.nanmean(Sumas.loc[Sumas.PARAM==1,['Value']].values)
flow['Cheakamus']=np.mean(Cheakamus.loc[Cheakamus.PARAM==1,['Value']].values)
flow['Cowichan']=np.mean(Cowichan.loc[Cowichan.PARAM==1,['Value']].values)
flow['Englishman']=np.mean(Englishman.loc[Englishman.PARAM==1,['Value']].values)
flow['Quinsam']=np.mean(Quinsam.loc[Quinsam.PARAM==1,['Value']].values)
flow['Tsolum']=np.mean(Tsolum.loc[Tsolum.PARAM==1,['Value']].values)
flow['Puntledge']=np.mean(Puntledge.loc[Puntledge.PARAM==1,['Value']].values)
flow['Goldstream']=np.mean(Goldstream.loc[Goldstream.PARAM==1,['Value']].values)
flow['Qualicum']=np.mean(Qualicum.loc[Qualicum.PARAM==1,['Value']].values)
flow['Nanaimo']=np.mean(Nanaimo.loc[Nanaimo.PARAM==1,['Value']].values)
flow['Campbell']=np.mean(Campbell.loc[Campbell.PARAM==1,['Value']].values)
flow['Oyster']=np.mean(Oyster.loc[Oyster.PARAM==1,['Value']].values)
flow['Squamish']=np.mean(Squamish.loc[Squamish.PARAM==1,['Value']].values)
flow['Okeover']=np.nan
#flow['Theodesia']=np.nan
flow['Trent river']=np.nan
flow['Tsable']=np.nan
flow['Rosewall']=np.nan
print('Fraser',np.mean(Fraser.loc[Fraser.PARAM==1,['Value']].values))
for ikey in flow.keys():
    print(ikey, flow[ikey])
np.unique(file1S.river)
np.unique(file2S.river)
np.unique(file3S.river)
np.unique(file4S.River)
siList=dict()
Ns=dict()
#siList['Alouette']=
#siList['Cheakamus']=
siList['Sumas']=list()
Ns['Sumas']=0
for el in df0['Sumas']['Silica Dissolved [Lab: 36] [VMV: 103469]'].values:
    if not np.isnan(el):
        siList['Sumas'].append(el/mwSiO2*1000.0)
        Ns['Sumas']=Ns['Sumas']+1
#for el in df0['Sumas']['Silicon Dissolved [Lab: -54] [VMV: 1175]'].values:
#    if not np.isnan(el):
#        siList['Sumas'].append(el/mwSiO2*1000.0)
#        Ns['Sumas']=Ns['Sumas']+1

siList['Cowichan']=list()
Ns['Cowichan']=0
#for el in df0['Cowichan']['Silicon Dissolved [Lab: -54] [VMV: 108166]'].values:
#    if not np.isnan(el):
#        siList['Cowichan'].append(el/mwSiO2*1000.0)
#        Ns['Cowichan']=Ns['Cowichan']+1
for el in file1S.loc[file1S.river=='Cowichan',['Si_uM']].values:
    if not np.isnan(el):
        siList['Cowichan'].append(el)
        Ns['Cowichan']=Ns['Cowichan']+1
for el in file2S.loc[file2S.river=='Cowichan',['Si_uM']].values:
    if not np.isnan(el):
        siList['Cowichan'].append(el)
        Ns['Cowichan']=Ns['Cowichan']+1
for el in file3S.loc[file3S.river=='Cowichan',['Si']].values:
    if not np.isnan(el):
        siList['Cowichan'].append(el)
        Ns['Cowichan']=Ns['Cowichan']+1
for el in file4S.loc[file4S.River=='Cowichan',['Silicate (uM)']].values:
    if not np.isnan(el):
        siList['Cowichan'].append(el)
        Ns['Cowichan']=Ns['Cowichan']+1

siList['Englishman']=list()
Ns['Englishman']=0
#for el in df0['Englishman']['Silicon Dissolved [Lab: -54] [VMV: 108166]'].values:
#    if not np.isnan(el):
#        siList['Englishman'].append(el/mwSiO2*1000.0)
#        Ns['Englishman']=Ns['Englishman']+1
for el in file2S.loc[file2S.river=='Englishman',['Si_uM']].values:
    if not np.isnan(el):
        siList['Englishman'].append(el)
        Ns['Englishman']=Ns['Englishman']+1
for el in file3S.loc[file3S.river=='Englishman',['Si']].values:
    if not np.isnan(el):
        siList['Englishman'].append(el)
        Ns['Englishman']=Ns['Englishman']+1
for el in file4S.loc[file4S.River=='Englishman',['Silicate (uM)']].values:
    if not np.isnan(el):
        siList['Englishman'].append(el)
        Ns['Englishman']=Ns['Englishman']+1

siList['Quinsam']=list()
Ns['Quinsam']=0
for el in df0['Quinsam']['Silica Dissolved [Lab: 36] [VMV: 103469]'].values:
    if not np.isnan(el):
        siList['Quinsam'].append(el/mwSiO2*1000.0)
        Ns['Quinsam']=Ns['Quinsam']+1

#siList['Tsolum']=list()
#Ns['Tsolum']=0
#for el in df0['Tsolum']['Silicon Dissolved [Lab: -54] [VMV: 108166]'].values:
#    if not np.isnan(el):
#        siList['Tsolum'].append(el/mwSiO2*1000.0)
#        Ns['Tsolum']=Ns['Tsolum']+1

siList['Puntledge']=list()
Ns['Puntledge']=0
for el in file1S.loc[file1S.river=='Puntledge',['Si_uM']].values:
    if not np.isnan(el):
        siList['Puntledge'].append(el)
        Ns['Puntledge']=Ns['Puntledge']+1
for el in file2S.loc[file2S.river=='Puntledge',['Si_uM']].values:
    if not np.isnan(el):
        siList['Puntledge'].append(el)
        Ns['Puntledge']=Ns['Puntledge']+1
for el in file3S.loc[file3S.river=='Puntledge',['Si']].values:
    if not np.isnan(el):
        siList['Puntledge'].append(el)
        Ns['Puntledge']=Ns['Puntledge']+1
for el in file4S.loc[file4S.River=='Puntledge',['Silicate (uM)']].values:
    if not np.isnan(el):
        siList['Puntledge'].append(el)
        Ns['Puntledge']=Ns['Puntledge']+1
    
siList['Goldstream']=list()
Ns['Goldstream']=0
for el in file2S.loc[file2S.river=='Goldstream',['Si_uM']].values:
    if not np.isnan(el):
        siList['Goldstream'].append(el)
        Ns['Goldstream']=Ns['Goldstream']+1
for el in file4S.loc[file4S.River=='Goldstream',['Silicate (uM)']].values:
    if not np.isnan(el):
        siList['Goldstream'].append(el)
        Ns['Goldstream']=Ns['Goldstream']+1
    
siList['Qualicum']=list()
Ns['Qualicum']=0
for el in file2S.loc[file2S.river=='Qualicum',['Si_uM']].values:
    if not np.isnan(el):
        siList['Qualicum'].append(el)
        Ns['Qualicum']=Ns['Qualicum']+1
for el in file3S.loc[file3S.river=='Big Qualicum',['Si']].values:
    if not np.isnan(el):
        siList['Qualicum'].append(el)
        Ns['Qualicum']=Ns['Qualicum']+1
for el in file4S.loc[file4S.River=='Qualicum',['Silicate (uM)']].values:
    if not np.isnan(el):
        siList['Qualicum'].append(el)
        Ns['Qualicum']=Ns['Qualicum']+1
    
siList['Nanaimo']=list()
Ns['Nanaimo']=0
for el in file2S.loc[file2S.river=='Nanaimo',['Si_uM']].values:
    if not np.isnan(el):
        siList['Nanaimo'].append(el)
        Ns['Nanaimo']=Ns['Nanaimo']+1
for el in file3S.loc[file3S.river=='Nanaimo',['Si']].values:
    if not np.isnan(el):
        siList['Nanaimo'].append(el)
        Ns['Nanaimo']=Ns['Nanaimo']+1
for el in file4S.loc[file4S.River=='Nanaimo',['Silicate (uM)']].values:
    if not np.isnan(el):
        siList['Nanaimo'].append(el)
        Ns['Nanaimo']=Ns['Nanaimo']+1

siList['Okeover']=list()
Ns['Okeover']=0
for el in file1S.loc[file1S.river=='Cowichan',['Si_uM']].values:
    if not np.isnan(el):
        siList['Okeover'].append(el)
        Ns['Okeover']=Ns['Okeover']+1
for el in file2S.loc[file2S.river=='YvesCreek',['Si_uM']].values:
    if not np.isnan(el):
        siList['Okeover'].append(el)
        Ns['Okeover']=Ns['Okeover']+1
        
siList['Campbell']=list()
Ns['Campbell']=0
for el in file3S.loc[file3S.river=='Campbell',['Si']].values:
    if not np.isnan(el):
        siList['Campbell'].append(el)
        Ns['Campbell']=Ns['Campbell']+1
for el in file4S.loc[file4S.River=='Campbell',['Silicate (uM)']].values:
    if not np.isnan(el):
        siList['Campbell'].append(el)
        Ns['Campbell']=Ns['Campbell']+1
        
siList['Oyster']=list()
Ns['Oyster']=0
for el in file3S.loc[file3S.river=='Oyster',['Si']].values:
    if not np.isnan(el):
        siList['Oyster'].append(el)
        Ns['Oyster']=Ns['Oyster']+1
for el in file4S.loc[file4S.River=='Oyster',['Silicate (uM)']].values:
    if not np.isnan(el):
        siList['Oyster'].append(el)
        Ns['Oyster']=Ns['Oyster']+1
        
siList['Rosewall']=list()
Ns['Rosewall']=0
for el in file4S.loc[file4S.River=='Rosewall',['Silicate (uM)']].values:
    if not np.isnan(el):
        siList['Rosewall'].append(el)
        Ns['Rosewall']=Ns['Rosewall']+1
        
siList['Squamish']=list()
Ns['Squamish']=0
for el in file4S.loc[file4S.River=='Squamish',['Silicate (uM)']].values:
    if not np.isnan(el):
        siList['Squamish'].append(el)
        Ns['Squamish']=Ns['Squamish']+1
        
siList['Trent river']=list()
Ns['Trent river']=0
for el in file3S.loc[file3S.river=='Trent river',['Si']].values:
    if not np.isnan(el):
        siList['Trent river'].append(el)
        Ns['Trent river']=Ns['Trent river']+1
        
siList['Tsable']=list()
Ns['Tsable']=0
for el in file3S.loc[file3S.river=='Tsable',['Si']].values:
    if not np.isnan(el):
        siList['Tsable'].append(el)
        Ns['Tsable']=Ns['Tsable']+1
dflist=list()
silistAll=list()
silistNoSumas=list()
for ikey in Ns.keys():
    dflist.append((ikey,np.mean(siList[ikey]),Ns[ikey],flow[ikey]))
    for el in siList[ikey]:
        #print(ikey,el)
        silistAll.append(el)
    if not ikey=='Sumas':
        for el in siList[ikey]:
            silistNoSumas.append(el)
dflist
np.mean(np.array(silistAll)),np.mean(np.array(silistNoSumas))
dflist
dfs=pd.DataFrame(columns=['river','si','n','flow'],data=dflist)
dfs
num=0
den=0
for i,row in dfs.iterrows():
    fl=row['flow'] if not np.isnan(row['flow']) else 1
    num=num+row['si']*fl
    den=den+fl
print(num/den)
np.mean([dfs['si']])
plt.plot(dfs['flow'],dfs['si'],'k*')<jupyter_output><empty_output><jupyter_text>Nitrate<jupyter_code>llNO3=list()
llNH=list()
for ff in df0.keys():
    llNO3=llNO3+[(ff,i) for i in df0[ff].keys() if ((re.search('[Nn]itrate',i) is not None and re.search('[Nn]itrite',i) is None and re.search('[Dd]is',i) is not None))]
    llNH=llNH+[(ff,i) for i in df0[ff].keys() if ((re.search('[Aa]mm',i) is not None) and (re.search('[Dd]is',i) is not None))]
print('NO3')
for (ff,i) in llNO3:
    print(ff,i,np.min(df0[ff]['TS'][df0[ff][i]>=0]),np.max(df0[ff]['TS'][df0[ff][i]>=0]))
print('NH4')
for (ff,i) in llNH:
    print(ff,i)
l=np.arange(1975,2018,1)
for (ff,i) in llNO3:
    fig,ax=plt.subplots(1,1,figsize=(16,1))
    yy=[x['TS'].year for i0,x in df0[ff].iterrows() if x[i]>=0]
    ax.hist(yy,l)
    ax.set_title(ff)
    ax.set_xticks(np.arange(1975,2018,3))
plt.plot(df0['Quinsam'].TS,df0['Quinsam']['Nitrite and Nitrate (as N) [Lab: 33] [VMV: 2233]'],'r.')
plt.plot(df0['Quinsam'].TS,df0['Quinsam']['Nitrogen Dissolved Nitrate [Lab: 1] [VMV: 7315]'],'b.')
plt.plot(df0['Quinsam'].TS,df0['Quinsam']['Nitrogen Dissolved Nitrate [Lab: 36] [VMV: 7315]'],'c.')
plt.plot(df0['Quinsam'].TS,df0['Quinsam']['Nitrogen Dissolved Nitrate [Lab: -54] [VMV: 1115]'],'g.')
plt.plot(df0['Quinsam'].TS,df0['Quinsam']['Nitrogen Total Nitrate [Lab: 33] [VMV: 1971]'],'y.')
plt.plot(df0['Quinsam'].TS,df0['Quinsam']['Nitrite and Nitrate (as N) [Lab: 33] [VMV: 2233]']/mwN*1000,'r.')
plt.plot(df0['Quinsam'].TS,df0['Quinsam']['Nitrogen Dissolved Nitrate [Lab: 1] [VMV: 7315]']/mwN*1000,'b.')
plt.plot(df0['Quinsam'].TS,df0['Quinsam']['Nitrogen Dissolved Nitrate [Lab: 36] [VMV: 7315]']/mwN*1000,'c.')
plt.plot(df0['Quinsam'].TS,df0['Quinsam']['Nitrogen Dissolved Nitrate [Lab: -54] [VMV: 1115]']/mwN*1000,'g.')
plt.plot(df0['Quinsam'].TS,df0['Quinsam']['Nitrogen Total Nitrate [Lab: 33] [VMV: 1971]']/mwN*1000,'y.')
plt.ylim(0,20)
rname='Englishman'
plt.plot(df0[rname].TS,df0[rname]['Nitrite and Nitrate (as N) [Lab: 33] [VMV: 2233]']/mwN*1000,'r.')
plt.plot(df0[rname].TS,df0[rname]['Nitrogen Dissolved Nitrate [Lab: 31] [VMV: 1115]']/mwN*1000,'b.')
plt.plot(df0[rname].TS,df0[rname]['Nitrogen Dissolved Nitrate [Lab: -54] [VMV: 1115]']/mwN*1000,'g.')
plt.plot(df0[rname].TS,df0[rname]['Nitrogen Total Nitrate [Lab: 33] [VMV: 1971]']/mwN*1000,'y.')
plt.ylim(0,20)
fig=plt.figure(figsize=(6,6))
gs1 = gridspec.GridSpec(2,1,left=.12,right=.55,bottom=.18,top=.9,hspace=.4)
#gs0=gridspec.GridSpecFromSubplotSpec(1,2,subplot_spec=gs1[0],width_ratios=[10,1],wspace=.1)
#gs1=gridspec.GridSpecFromSubplotSpec(5,1,subplot_spec=gs1[1:],height_ratios=[.3,1,.3,1,.3],wspace=.3)
ax0=fig.add_subplot(gs1[0])
ax1=fig.add_subplot(gs1[1])

ax=ax0
ps=list()
labels=list()
for (ff,ii) in llNO3:
    p,=ax.plot(df0[ff]['YD'],df0[ff][ii]/mwN*1000.0,'.',label='EC '+ff,markersize=ms1,color=cols[ff])
    if not ('EC '+ff in labels):
        ps.append(p)
        labels.append('EC '+ff)
ax.set_xlim(0,366)
ax.set_xlabel('Year Day')
ax.set_ylabel('Nitrate ($\mu$M)')
labeled=set()
for ff in file1S['river'].values:
    ff2=ff if not (ff in tr.keys()) else tr[ff]
    if (ff2 in labeled):
        ax.plot(file1S.loc[file1S.river==ff,['YD']],file1S.loc[file1S.river==ff,['NO3']],'*',color=cols[ff2],
                label='Ianson '+ff,markersize=ms2)
    else:
        p,=ax.plot(file1S.loc[file1S.river==ff,['YD']],file1S.loc[file1S.river==ff,['NO3']],'*',color=cols[ff2],
                   label='Ianson '+ff,markersize=ms2)
        ps.append(p)
        labels.append('Ianson '+ff2)
        labeled.add(ff2)
for ff in file2S['river'].values:
    ff2=ff if not (ff in tr.keys()) else tr[ff]
    if (ff2 in labeled):
        ax.plot(file2S.loc[file2S.river==ff,['YD']],file2S.loc[file2S.river==ff,['NO3']],'*',color=cols[ff2],
                label='Ianson '+ff,markersize=ms2)
    else:
        p,=ax.plot(file2S.loc[file2S.river==ff,['YD']],file2S.loc[file2S.river==ff,['NO3']],'*',color=cols[ff2],
                   label='Ianson '+ff,markersize=ms2)
        ps.append(p)
        labels.append('Ianson '+ff2)
        labeled.add(ff2)
for ff in file3S['river'].values:
    ff2=ff if not (ff in tr.keys()) else tr[ff]
    if (ff2 in labeled):
        ax.plot(file3S.loc[file3S.river==ff,['YD']],file3S.loc[file3S.river==ff,['N']],'*',color=cols[ff2],
                label='Ianson '+ff,markersize=ms2)
    else:
        p,=ax.plot(file3S.loc[file3S.river==ff,['YD']],file3S.loc[file3S.river==ff,['N']],'*',color=cols[ff2],
                   label='Ianson '+ff,markersize=ms2)
        ps.append(p)
        labels.append('Ianson '+ff2)
        labeled.add(ff2)
for ff in file4S['River'].values:
    ff2=ff if not (ff in tr.keys()) else tr[ff]
    if (ff2 in labeled):
        ax.plot(file4S.loc[file4S.River==ff,['YD']],file4S.loc[file4S.River==ff,['Nitrate_plus_Nitrite (uM)']],'*',color=cols[ff2],
                label='Ianson '+ff,markersize=ms2)
    else:
        p,=ax.plot(file4S.loc[file4S.River==ff,['YD']],file4S.loc[file4S.River==ff,['Nitrate_plus_Nitrite (uM)']],'*',color=cols[ff2],
                   label='Ianson '+ff,markersize=ms2)
        ps.append(p)
        labels.append('Ianson '+ff2)
        labeled.add(ff2)
ax.plot((dt.datetime(2017,11,1)-dt.datetime(2016,12,31)).days,67,'*',color=cols['Fraser'],markersize=ms2) # add my Fraser data point
ax.legend(ps,labels,bbox_to_anchor=(1., 1.05),fontsize=10)

ax=ax1
ps=list()
labels=list()
for (ff,ii) in llNO3:
    p,=ax.plot(df0[ff]['YD'],df0[ff][ii]/mwN*1000.0,'.',label='EC '+ff,markersize=ms1,color=cols[ff])
    if not ('EC '+ff in labels):
        ps.append(p)
        labels.append('EC '+ff)
ax.set_xlim(0,366)
ax.set_xlabel('Year Day')
ax.set_ylabel('Nitrate ($\mu$M)')
labeled=set()
for ff in file1S['river'].values:
    ff2=ff if not (ff in tr.keys()) else tr[ff]
    if (ff2 in labeled):
        ax.plot(file1S.loc[file1S.river==ff,['YD']],file1S.loc[file1S.river==ff,['NO3']],'*',color=cols[ff2],
                label='Ianson '+ff,markersize=ms2)
    else:
        p,=ax.plot(file1S.loc[file1S.river==ff,['YD']],file1S.loc[file1S.river==ff,['NO3']],'*',color=cols[ff2],
                   label='Ianson '+ff,markersize=ms2)
        ps.append(p)
        labels.append('Ianson '+ff2)
        labeled.add(ff2)
for ff in file2S['river'].values:
    ff2=ff if not (ff in tr.keys()) else tr[ff]
    if (ff2 in labeled):
        ax.plot(file2S.loc[file2S.river==ff,['YD']],file2S.loc[file2S.river==ff,['NO3']],'*',color=cols[ff2],
                label='Ianson '+ff,markersize=ms2)
    else:
        p,=ax.plot(file2S.loc[file2S.river==ff,['YD']],file2S.loc[file2S.river==ff,['NO3']],'*',color=cols[ff2],
                   label='Ianson '+ff,markersize=ms2)
        ps.append(p)
        labels.append('Ianson '+ff2)
        labeled.add(ff2)
for ff in file3S['river'].values:
    ff2=ff if not (ff in tr.keys()) else tr[ff]
    if (ff2 in labeled):
        ax.plot(file3S.loc[file3S.river==ff,['YD']],file3S.loc[file3S.river==ff,['N']],'*',color=cols[ff2],
                label='Ianson '+ff,markersize=ms2)
    else:
        p,=ax.plot(file3S.loc[file3S.river==ff,['YD']],file3S.loc[file3S.river==ff,['N']],'*',color=cols[ff2],
                   label='Ianson '+ff,markersize=ms2)
        ps.append(p)
        labels.append('Ianson '+ff2)
        labeled.add(ff2)
for ff in file4S['River'].values:
    ff2=ff if not (ff in tr.keys()) else tr[ff]
    if (ff2 in labeled):
        ax.plot(file4S.loc[file4S.River==ff,['YD']],file4S.loc[file4S.River==ff,['Nitrate_plus_Nitrite (uM)']],'*',color=cols[ff2],
                label='Ianson '+ff,markersize=ms2)
    else:
        p,=ax.plot(file4S.loc[file4S.River==ff,['YD']],file4S.loc[file4S.River==ff,['Nitrate_plus_Nitrite (uM)']],'*',color=cols[ff2],
                   label='Ianson '+ff,markersize=ms2)
        ps.append(p)
        labels.append('Ianson '+ff2)
        labeled.add(ff2)
ax.plot((dt.datetime(2017,11,1)-dt.datetime(2016,12,31)).days,67,'*',color=cols['Fraser'],markersize=ms2) # add my Fraser data point
#ax.legend(ps,labels,bbox_to_anchor=(1.3, 1.1))
ax.set_ylim(0,75)
#fig.savefig('/data/eolson/results/MEOPAR/biomodelevalpaper/figsMod/riverForcing/rivNO3.png',dpi=400,transparent=True)

##fig.savefig('/data/eolson/results/MEOPAR/biomodelevalpaper/figsMod/rivNO3Hi.png',dpi=400,transparent=True)
fig,ax=plt.subplots(1,1,figsize=(6,6))
ps=list()
labels=list()
for (ff,ii) in llNO3:
    p,=ax.plot(df0[ff]['YD'],df0[ff][ii]/mwN*1000.0,'.',label='EC '+ff,markersize=ms1,color=cols[ff])
    if not ('EC '+ff in labels):
        ps.append(p)
        labels.append('EC '+ff)
ax.set_xlim(0,366)
ax.set_xlabel('Year Day')
ax.set_ylabel('Nitrate ($\mu$M)')
labeled=set()
for ff in file1S['river'].values:
    ff2=ff if not (ff in tr.keys()) else tr[ff]
    if (ff2 in labeled):
        ax.plot(file1S.loc[file1S.river==ff,['YD']],file1S.loc[file1S.river==ff,['NO3']],'*',color=cols[ff2],
                label='Ianson '+ff,markersize=ms2)
    else:
        p,=ax.plot(file1S.loc[file1S.river==ff,['YD']],file1S.loc[file1S.river==ff,['NO3']],'*',color=cols[ff2],
                   label='Ianson '+ff,markersize=ms2)
        ps.append(p)
        labels.append('Ianson '+ff2)
        labeled.add(ff2)
for ff in file2S['river'].values:
    ff2=ff if not (ff in tr.keys()) else tr[ff]
    if (ff2 in labeled):
        ax.plot(file2S.loc[file2S.river==ff,['YD']],file2S.loc[file2S.river==ff,['NO3']],'*',color=cols[ff2],
                label='Ianson '+ff,markersize=ms2)
    else:
        p,=ax.plot(file2S.loc[file2S.river==ff,['YD']],file2S.loc[file2S.river==ff,['NO3']],'*',color=cols[ff2],
                   label='Ianson '+ff,markersize=ms2)
        ps.append(p)
        labels.append('Ianson '+ff2)
        labeled.add(ff2)
for ff in file3S['river'].values:
    ff2=ff if not (ff in tr.keys()) else tr[ff]
    if (ff2 in labeled):
        ax.plot(file3S.loc[file3S.river==ff,['YD']],file3S.loc[file3S.river==ff,['N']],'*',color=cols[ff2],
                label='Ianson '+ff,markersize=ms2)
    else:
        p,=ax.plot(file3S.loc[file3S.river==ff,['YD']],file3S.loc[file3S.river==ff,['N']],'*',color=cols[ff2],
                   label='Ianson '+ff,markersize=ms2)
        ps.append(p)
        labels.append('Ianson '+ff2)
        labeled.add(ff2)
for ff in file4S['River'].values:
    ff2=ff if not (ff in tr.keys()) else tr[ff]
    if (ff2 in labeled):
        ax.plot(file4S.loc[file4S.River==ff,['YD']],file4S.loc[file4S.River==ff,['Nitrate_plus_Nitrite (uM)']],'*',color=cols[ff2],
                label='Ianson '+ff,markersize=ms2)
    else:
        p,=ax.plot(file4S.loc[file4S.River==ff,['YD']],file4S.loc[file4S.River==ff,['Nitrate_plus_Nitrite (uM)']],'*',color=cols[ff2],
                   label='Ianson '+ff,markersize=ms2)
        ps.append(p)
        labels.append('Ianson '+ff2)
        labeled.add(ff2)
ax.plot((dt.datetime(2017,11,1)-dt.datetime(2016,12,31)).days,67,'*',color=cols['Fraser'],markersize=ms2) # add my Fraser data point
ax.legend(ps,labels,bbox_to_anchor=(1.3, 1.0),fontsize=10)
ax.set_ylim(0,80)
#fig.savefig('/data/eolson/results/MEOPAR/biomodelevalpaper/figsMod/riverForcing/rivNO3Lo.png',dpi=400,transparent=True)
def gsmooth(YD,Amm,L):
    allt=np.arange(1,367)
    fil=np.empty(np.size(allt))
    s=L/2.355
    sdict={}
    for t in allt:
        diff=[min(abs(x-t),abs(x-t+365), abs(x-t-365)) for x in YD]
        weight=[np.exp(-.5*x**2/s**2) if x <= 3*L else 0.0 for x in diff]
        #weight=[np.exp(-.5*x**2/s**2) for x in diff]
        fil[t-1]=np.sum(weight*Amm)/np.sum(weight)
        sdict[t]=fil[t-1]
    plt.plot(allt,fil,'k-')
    plt.plot(allt+365,fil,'k-')
    diff_ex=[min(abs(x-t),abs(x-t+365), abs(x-t-365)) for x in allt]
    weight_ex=[np.exp(-.5*x**2/s**2) if x <= 3*L else 0.0 for x in diff_ex]
    plt.plot(allt,weight_ex/np.sum(weight_ex)*np.max(2.0*Amm),'k:')
    plt.plot(allt+365,weight_ex/np.sum(weight_ex)*np.max(2.0*Amm),'k:')
    return(sdict)
    #plt.plot(YD,weight,'*')
fig,ax=plt.subplots(1,1,figsize=(12,10))
alldata=list()
allyd=list()
for (ff,ii) in llNO3:
    ax.plot(df0[ff]['YD'],df0[ff][ii]/mwN*1000.0,'.',label=ff,markersize=6,color=cols[ff])
    for i,row in df0[ff].iterrows():
        if ((not np.isnan(row[ii])) and (ff!='Sumas') and (not ff.startswith('Fraser'))):
            alldata.append(row[ii]/mwN*1000.0)
            allyd.append(row['YD'])
#ax.legend(bbox_to_anchor=(1.2, 1.0))
ax.set_xlim(0,366)
ax.set_xlabel('Sampling Year Day')
ax.set_ylabel('NO3 ($\mu$M)')
plt.ylim(0,80)
print('Mean of EC NO3 excluding Sumas and Fraser:', str(np.mean(alldata)))
s=gsmooth(np.array(allyd),np.array(alldata),30)
ax.plot(file1S.YD,file1S.NO3,'*',color='black',markeredgewidth=0.0,markersize=10)
ax.plot(file2S.YD,file2S.NO3,'*',color='gray',markeredgewidth=0.0,markersize=10)
plt.plot(allyd,alldata,'r.')
rlist1=['Quinsam','Cowichan','Englishman','Tsolum']
rlist2=['Cheakamus','Fraser-Hope','Fraser-Gravesend','Alouette']
fig,ax=plt.subplots(1,1,figsize=(12,10))
for (ff,ii) in llNO3:
    if ff in rlist1:
        ax.plot(df0[ff]['YD'],df0[ff][ii]/mwN*1000.0,'.',label=ff,markersize=7,color=cols[ff])
ax.legend(bbox_to_anchor=(1.2, 1.0))
ax.set_xlim(0,366)
ax.set_xlabel('Sampling Year Day')
ax.set_ylabel('NO3 ($\mu$M)')
plt.ylim(0,80)
plt.title('Island Rivers')

alldata=list()
allyd=list()
for (ff,ii) in llNO3:
    if ff in rlist1:
        for i,row in df0[ff].iterrows():
            if (not np.isnan(row[ii])):
                alldata.append(row[ii]/mwN*1000.0)
                allyd.append(row['YD'])
s=gsmooth(np.array(allyd),np.array(alldata),30)
fig,ax=plt.subplots(1,1,figsize=(12,10))
for (ff,ii) in llNO3:
    if ff in rlist2:
        ax.plot(df0[ff]['YD'],df0[ff][ii]/mwN*1000.0,'.',label=ff,markersize=7,color=cols[ff])
ax.legend(bbox_to_anchor=(1.2, 1.0))
ax.set_xlim(0,366)
ax.set_xlabel('Sampling Year Day')
ax.set_ylabel('NO3 ($\mu$M)')
plt.ylim(0,40)
plt.title('Mainland Rivers')
alldata=list()
allyd=list()
for (ff,ii) in llNO3:
    if ff in rlist2:
        for i,row in df0[ff].iterrows():
            if (not np.isnan(row[ii])):
                alldata.append(row[ii]/mwN*1000.0)
                allyd.append(row['YD'])
s=gsmooth(np.array(allyd),np.array(alldata),30)
llNO3
NOlist=dict()
Ns=dict()
#NOlist['Alouette']=
#NOlist['Cheakamus']=
for rname in ('Sumas','Cowichan','Englishman','Quinsam','Tsolum','Qualicum','Nanaimo','Okeover','Cheakamus','Alouette','Puntledge'):
    NOlist[rname]=list()
    Ns[rname]=0

for riv, fname in llNO3:
    if not riv.startswith('Fraser'):
        for el in df0[riv][fname]:
            if not np.isnan(el):
                NOlist[riv].append(el/mwN*1000.0)
                Ns[riv]=Ns[riv]+1


for el in file1S.loc[file1S.river=='Cowichan',['NO3']].values:
    if not np.isnan(el):
        NOlist['Cowichan'].append(el)
        Ns['Cowichan']=Ns['Cowichan']+1
for el in file2S.loc[file2S.river=='Cowichan',['NO3']].values:
    if not np.isnan(el):
        NOlist['Cowichan'].append(el)
        Ns['Cowichan']=Ns['Cowichan']+1
for el in file3S.loc[file3S.river=='Cowichan',['N']].values:
    if not np.isnan(el):
        NOlist['Cowichan'].append(el)
        Ns['Cowichan']=Ns['Cowichan']+1
for el in file4S.loc[file4S.River=='Cowichan',['Nitrate_plus_Nitrite (uM)']].values:
    if not np.isnan(el):
        NOlist['Cowichan'].append(el)
        Ns['Cowichan']=Ns['Cowichan']+1


for el in file2S.loc[file2S.river=='Englishman',['NO3']].values:
    if not np.isnan(el):
        NOlist['Englishman'].append(el)
        Ns['Englishman']=Ns['Englishman']+1
for el in file3S.loc[file3S.river=='Englishman',['N']].values:
    if not np.isnan(el):
        NOlist['Englishman'].append(el)
        Ns['Englishman']=Ns['Englishman']+1
for el in file4S.loc[file4S.River=='Englishman',['Nitrate_plus_Nitrite (uM)']].values:
    if not np.isnan(el):
        NOlist['Englishman'].append(el)
        Ns['Englishman']=Ns['Englishman']+1


for el in file1S.loc[file1S.river=='Puntledge',['NO3']].values:
    if not np.isnan(el):
        NOlist['Puntledge'].append(el)
        Ns['Puntledge']=Ns['Puntledge']+1
for el in file2S.loc[file2S.river=='Puntledge',['NO3']].values:
    if not np.isnan(el):
        NOlist['Puntledge'].append(el)
        Ns['Puntledge']=Ns['Puntledge']+1
for el in file3S.loc[file3S.river=='Puntledge',['N']].values:
    if not np.isnan(el):
        NOlist['Puntledge'].append(el)
        Ns['Puntledge']=Ns['Puntledge']+1
for el in file4S.loc[file4S.River=='Puntledge',['Nitrate_plus_Nitrite (uM)']].values:
    if not np.isnan(el):
        NOlist['Puntledge'].append(el)
        Ns['Puntledge']=Ns['Puntledge']+1
    
NOlist['Goldstream']=list()
Ns['Goldstream']=0
for el in file2S.loc[file2S.river=='Goldstream',['NO3']].values:
    if not np.isnan(el):
        NOlist['Goldstream'].append(el)
        Ns['Goldstream']=Ns['Goldstream']+1
for el in file4S.loc[file4S.River=='Goldstream',['Nitrate_plus_Nitrite (uM)']].values:
    if not np.isnan(el):
        NOlist['Goldstream'].append(el)
        Ns['Goldstream']=Ns['Goldstream']+1
    

for el in file2S.loc[file2S.river=='Qualicum',['NO3']].values:
    if not np.isnan(el):
        NOlist['Qualicum'].append(el)
        Ns['Qualicum']=Ns['Qualicum']+1
for el in file3S.loc[file3S.river=='Big Qualicum',['N']].values:
    if not np.isnan(el):
        NOlist['Qualicum'].append(el)
        Ns['Qualicum']=Ns['Qualicum']+1
for el in file4S.loc[file4S.River=='Qualicum',['Nitrate_plus_Nitrite (uM)']].values:
    if not np.isnan(el):
        siList['Qualicum'].append(el)
        Ns['Qualicum']=Ns['Qualicum']+1
    
for el in file2S.loc[file2S.river=='Nanaimo',['NO3']].values:
    if not np.isnan(el):
        NOlist['Nanaimo'].append(el)
        Ns['Nanaimo']=Ns['Nanaimo']+1
for el in file3S.loc[file3S.river=='Nanaimo',['N']].values:
    if not np.isnan(el):
        NOlist['Nanaimo'].append(el)
        Ns['Nanaimo']=Ns['Nanaimo']+1
for el in file4S.loc[file4S.River=='Nanaimo',['Nitrate_plus_Nitrite (uM)']].values:
    if not np.isnan(el):
        NOlist['Nanaimo'].append(el)
        Ns['Nanaimo']=Ns['Nanaimo']+1

for el in file1S.loc[file1S.river=='Cowichan',['NO3']].values:
    if not np.isnan(el):
        NOlist['Okeover'].append(el)
        Ns['Okeover']=Ns['Okeover']+1
for el in file2S.loc[file2S.river=='YvesCreek',['NO3']].values:
    if not np.isnan(el):
        NOlist['Okeover'].append(el)
        Ns['Okeover']=Ns['Okeover']+1
        
NOlist['Campbell']=list()
Ns['Campbell']=0
for el in file3S.loc[file3S.river=='Campbell',['N']].values:
    if not np.isnan(el):
        NOlist['Campbell'].append(el)
        Ns['Campbell']=Ns['Campbell']+1
for el in file4S.loc[file4S.River=='Campbell',['Nitrate_plus_Nitrite (uM)']].values:
    if not np.isnan(el):
        NOlist['Campbell'].append(el)
        Ns['Campbell']=Ns['Campbell']+1
        
NOlist['Oyster']=list()
Ns['Oyster']=0
for el in file3S.loc[file3S.river=='Oyster',['N']].values:
    if not np.isnan(el):
        NOlist['Oyster'].append(el)
        Ns['Oyster']=Ns['Oyster']+1
for el in file4S.loc[file4S.River=='Oyster',['Nitrate_plus_Nitrite (uM)']].values:
    if not np.isnan(el):
        NOlist['Oyster'].append(el)
        Ns['Oyster']=Ns['Oyster']+1
        
NOlist['Rosewall']=list()
Ns['Rosewall']=0
for el in file4S.loc[file4S.River=='Rosewall',['Nitrate_plus_Nitrite (uM)']].values:
    if not np.isnan(el):
        NOlist['Rosewall'].append(el)
        Ns['Rosewall']=Ns['Rosewall']+1
        
NOlist['Squamish']=list()
Ns['Squamish']=0
for el in file4S.loc[file4S.River=='Squamish',['Nitrate_plus_Nitrite (uM)']].values:
    if not np.isnan(el):
        NOlist['Squamish'].append(el)
        Ns['Squamish']=Ns['Squamish']+1
        
NOlist['Trent river']=list()
Ns['Trent river']=0
for el in file3S.loc[file3S.river=='Trent river',['N']].values:
    if not np.isnan(el):
        NOlist['Trent river'].append(el)
        Ns['Trent river']=Ns['Trent river']+1
        
NOlist['Tsable']=list()
Ns['Tsable']=0
for el in file3S.loc[file3S.river=='Tsable',['N']].values:
    if not np.isnan(el):
        NOlist['Tsable'].append(el)
        Ns['Tsable']=Ns['Tsable']+1
dNO=list()
dNOAll=list()
dNONoSumas=list()
for ikey in NOlist.keys():
    dNO.append((ikey,np.mean(NOlist[ikey]),Ns[ikey]))
    for el in NOlist[ikey]:
        #print(ikey,el)
        dNOAll.append(el)
    if not ikey=='Sumas':
        for el in NOlist[ikey]:
            dNONoSumas.append(el)<jupyter_output><empty_output><jupyter_text>dNO=list()for ik in NOlist.keys():    dNO.append((ik,np.mean(NOlist[ik]),Ns[ik]))<jupyter_code>dNO
dfno=pd.DataFrame(columns=['river','no3','n'],data=dNO)
dfno
np.mean(dfno['no3'])
np.mean(dfno.loc[dfno.river!='Sumas',['no3']])
np.mean(np.array(dNOAll)),np.mean(np.array(dNONoSumas))<jupyter_output><empty_output><jupyter_text>Ammonia<jupyter_code>llNH
fig=plt.figure(figsize=(6,3))
gs1 = gridspec.GridSpec(1,1,left=.12,right=.6,bottom=.18,top=.9)
ax=fig.add_subplot(gs1[0])
ps=list()
labels=list()
alldata=list()
dataNoSumas=list()
allyd=list()
for (ff,ii) in llNH:
    p,=ax.plot(df0[ff]['YD'],df0[ff][ii]/mwN*1000.0,'.',label='EC '+ff,markersize=ms1,color=cols[ff])
    if not ('EC '+ff in labels):
        ps.append(p)
        labels.append('EC '+ff)
    for i,row in df0[ff].iterrows():
        if ((not np.isnan(row[ii])) and (row[ii]/mwN*1000.0>0)):
            alldata.append(row[ii]/mwN*1000.0)
            allyd.append(row['YD'])
            if not ff.startswith('Sumas'): #(ff.startswith('Fraser') or
                dataNoSumas.append(row[ii]/mwN*1000.0)
ax.set_xlim(0,366)
ax.set_ylim(-0,50)
ax.set_xlabel('Year Day')
ax.set_ylabel('Ammonia ($\mu$M)')
p1,=ax.plot((1,366),(4.43,4.43),'k--')
p2,=ax.plot((1,366),(4.09,4.09),'k-')
ps.append(p1);ps.append(p2);
labels.append('Fraser Forcing')
labels.append('Other Rivers Forcing')
ax.legend(ps,labels,bbox_to_anchor=(1., 1),fontsize=10)
fig.savefig('/data/eolson/results/MEOPAR/biomodelevalpaper/figsMod/riverForcing/rivNH.png',dpi=400,transparent=True)

print('Mean of NH:', str(np.mean(alldata)))
print('Mean of NH, no Sumas:', str(np.mean(dataNoSumas)))
NHlist=dict()
NHs=dict()
allriv=list()
for riv, fname in llNH:
    if not riv.startswith('Fraser'):
        allriv.append(riv)
allriv=np.unique(allriv)
for rname in allriv:
    NHlist[rname]=list()
    NHs[rname]=0

for riv, fname in llNH:
    if not riv.startswith('Fraser'):
        for el in df0[riv][fname]:
            if ((not np.isnan(el)) and (el>0)):
                NHlist[riv].append(el/mwN*1000.0)
                NHs[riv]=NHs[riv]+1
dNH=list()
for ik in NHlist.keys():
    dNH.append((ik,np.mean(NHlist[ik]),NHs[ik]))
dfnh=pd.DataFrame(columns=['river','nh','n'],data=dNH)
dfnh
np.mean(dfnh['nh'])
np.mean(dfnh.loc[dfnh.river!='Sumas',['nh']])<jupyter_output><empty_output><jupyter_text>Load old and new model forcing and compare<jupyter_code># this is the file the HC201812 was run with:
constsOld=nc.Dataset('/data/eolson/MEOPAR/NEMO-forcing-new/rivers-climatology/bio/R201812_bioConst.nc')
constsNew=nc.Dataset('/data/eolson/MEOPAR/NEMO-forcing-new/rivers-climatology/bio/R201906_bioConst.nc')
for ikey in ('nh4',): # nh4 is only nonzero nutrient taken from this file
    print('old',ikey, np.min(constsOld.variables[ikey]),np.max(constsOld.variables[ikey]))
    print('new',ikey, np.min(constsNew.variables[ikey]),np.max(constsNew.variables[ikey]))
(4.23-4.09)/4.09*100,(4.3-4.43)/4.43*100
fnameO='/data/eolson/MEOPAR/NEMO-forcing-new/rivers-climatology/bio/R201809_2_bioClim_'
fnameN='/data/eolson/MEOPAR/NEMO-forcing-new/rivers-climatology/bio/R201906_bioClim_'
listFraserOldN=list()
listFraserNewN=list()
listFraserOldSi=list()
listFraserNewSi=list()
year=2016
for yearday in range(1,367):
    t2=dt.date(year, 1, 1) + dt.timedelta(days = yearday - 1)
    #datestr='y'+t2.strftime('%Y')+'m'+t2.strftime('%m')+'d'+t2.strftime('%d')
    datestr='m'+t2.strftime('%m')+'d'+t2.strftime('%d')
    new=nc.Dataset(fnameN+datestr+'.nc')
    old=nc.Dataset(fnameO+datestr+'.nc')
    if yearday==1:
        print('old consts:','no3',old.variables['no3'][0,200,200],'sil:',old.variables['sil'][0,200,200])
        print('new consts:','no3',new.variables['no3'][0,200,200],'sil:',new.variables['sil'][0,200,200])
    listFraserNewN.append((new.variables['no3'][0,450,382]))
    listFraserOldN.append((old.variables['no3'][0,450,382]))
    listFraserNewSi.append((new.variables['sil'][0,450,382]))
    listFraserOldSi.append((old.variables['sil'][0,450,382]))
    new.close()
    old.close()
(6.18-6.26)/6.26*100,(59.57-55.69)/55.69*100
fraclist=list()
for ii in range(0,366):
    print(ii,listFraserNewN[ii],listFraserOldN[ii],(listFraserNewN[ii]-listFraserOldN[ii])/listFraserOldN[ii]*100)
    fraclist.append((listFraserNewN[ii]-listFraserOldN[ii])/listFraserOldN[ii]*100)
print(np.min(np.array(fraclist)),np.max(np.array(fraclist)))
fraclist=list()
for ii in range(0,366):
    print(ii,listFraserNewSi[ii],listFraserOldSi[ii],(listFraserNewSi[ii]-listFraserOldSi[ii])/listFraserOldSi[ii]*100)
    fraclist.append((listFraserNewSi[ii]-listFraserOldSi[ii])/listFraserOldSi[ii]*100)
print(np.min(np.array(fraclist)),np.max(np.array(fraclist)))
# now add climatology to Si and N plots
fig=plt.figure(figsize=(6,4.7))
gs1 = gridspec.GridSpec(1,1,left=.12,right=.65,bottom=.15,top=.9)
#gs0=gridspec.GridSpecFromSubplotSpec(1,2,subplot_spec=gs1[0],width_ratios=[10,1],wspace=.1)
#gs1=gridspec.GridSpecFromSubplotSpec(5,1,subplot_spec=gs1[1:],height_ratios=[.3,1,.3,1,.3],wspace=.3)
ax=fig.add_subplot(gs1[0])

ps=list()
labels=list()
for (ff,ii) in ll:
    p,=ax.plot(df0[ff]['YD'],df0[ff][ii]/mwSiO2*1000.0,'.',label='EC '+ff,markersize=ms1,color=cols[ff])
    if not ('EC '+ff in labels):
        ps.append(p)
        labels.append('EC '+ff)
ax.set_xlim(0,366)
ax.set_xlabel('Year Day')
ax.set_ylabel('Dissolved Si ($\mu$M)')
file1S=file1.loc[file1.S<.5]
file2S=file2.loc[file2.S<.5]
file3S=file3.loc[file3.salt<.5]
file4S=file4.loc[file4.Salinity<.5]
labeled=set()
for ff in file1S['river'].values:
    ff2=ff if not (ff in tr.keys()) else tr[ff]
    if (ff2 in labeled):
        ax.plot(file1S.loc[file1S.river==ff,['YD']],file1S.loc[file1S.river==ff,['Si_uM']],'*',color=cols[ff2],
                label='Ianson '+ff,markersize=ms2)
    else:
        p,=ax.plot(file1S.loc[file1S.river==ff,['YD']],file1S.loc[file1S.river==ff,['Si_uM']],'*',color=cols[ff2],
                   label='Ianson '+ff,markersize=ms2)
        ps.append(p)
        labels.append('Ianson '+ff2)
        labeled.add(ff2)
for ff in file2S['river'].values:
    ff2=ff if not (ff in tr.keys()) else tr[ff]
    if (ff2 in labeled):
        ax.plot(file2S.loc[file2S.river==ff,['YD']],file2S.loc[file2S.river==ff,['Si_uM']],'*',color=cols[ff2],
                label='Ianson '+ff,markersize=ms2)
    else:
        p,=ax.plot(file2S.loc[file2S.river==ff,['YD']],file2S.loc[file2S.river==ff,['Si_uM']],'*',color=cols[ff2],
                   label='Ianson '+ff,markersize=ms2)
        ps.append(p)
        labels.append('Ianson '+ff2)
        labeled.add(ff2)
for ff in file3S['river'].values:
    ff2=ff if not (ff in tr.keys()) else tr[ff]
    if (ff2 in labeled):
        ax.plot(file3S.loc[file3S.river==ff,['YD']],file3S.loc[file3S.river==ff,['Si']],'*',color=cols[ff2],
                label='Ianson '+ff,markersize=ms2)
    else:
        p,=ax.plot(file3S.loc[file3S.river==ff,['YD']],file3S.loc[file3S.river==ff,['Si']],'*',color=cols[ff2],
                   label='Ianson '+ff,markersize=ms2)
        ps.append(p)
        labels.append('Ianson '+ff2)
        labeled.add(ff2)
for ff in file4S['River'].values:
    ff2=ff if not (ff in tr.keys()) else tr[ff]
    if (ff2 in labeled):
        ax.plot(file4S.loc[file4S.River==ff,['YD']],file4S.loc[file4S.River==ff,['Silicate (uM)']],'*',color=cols[ff2],
                label='Ianson '+ff,markersize=ms2)
    else:
        p,=ax.plot(file4S.loc[file4S.River==ff,['YD']],file4S.loc[file4S.River==ff,['Silicate (uM)']],'*',color=cols[ff2],
                   label='Ianson '+ff,markersize=ms2)
        ps.append(p)
        labels.append('Ianson '+ff2)
        labeled.add(ff2)
ax.plot((dt.datetime(2017,11,1)-dt.datetime(2016,12,31)).days,67,'*',color=cols['Fraser'],markersize=10) # add my Fraser data point
p1,=ax.plot(np.arange(1,367),listFraserOldSi,'k--')# add forcing climatology for Fraser
p2,=ax.plot((1,367),(55.69,55.69),'k-')# add forcing climatology for Fraser
ps.append(p1);ps.append(p2);
labels.append('Fraser Forcing')
labels.append('Other Rivers Forcing')
ax.legend(ps,labels,bbox_to_anchor=(1., 1.025),fontsize=10)
ax.set_ylim(0,250)
#plt.tight_layout()
fig.savefig('/data/eolson/results/MEOPAR/biomodelevalpaper/figsMod/riverForcing/rivSi.png',dpi=400,transparent=True)
fig=plt.figure(figsize=(6,7))
gs1 = gridspec.GridSpec(2,1,left=.12,right=.55,bottom=.18,top=.9,hspace=.4)
#gs0=gridspec.GridSpecFromSubplotSpec(1,2,subplot_spec=gs1[0],width_ratios=[10,1],wspace=.1)
#gs1=gridspec.GridSpecFromSubplotSpec(5,1,subplot_spec=gs1[1:],height_ratios=[.3,1,.3,1,.3],wspace=.3)
ax0=fig.add_subplot(gs1[0])
ax1=fig.add_subplot(gs1[1])

ax=ax0
ps=list()
labels=list()
for (ff,ii) in llNO3:
    p,=ax.plot(df0[ff]['YD'],df0[ff][ii]/mwN*1000.0,'.',label='EC '+ff,markersize=ms1,color=cols[ff])
    if not ('EC '+ff in labels):
        ps.append(p)
        labels.append('EC '+ff)
ax.set_xlim(0,366)
ax.set_xlabel('Year Day')
ax.set_ylabel('Nitrate ($\mu$M)')
labeled=set()
for ff in file1S['river'].values:
    ff2=ff if not (ff in tr.keys()) else tr[ff]
    if (ff2 in labeled):
        ax.plot(file1S.loc[file1S.river==ff,['YD']],file1S.loc[file1S.river==ff,['NO3']],'*',color=cols[ff2],
                label='Ianson '+ff,markersize=ms2)
    else:
        p,=ax.plot(file1S.loc[file1S.river==ff,['YD']],file1S.loc[file1S.river==ff,['NO3']],'*',color=cols[ff2],
                   label='Ianson '+ff,markersize=ms2)
        ps.append(p)
        labels.append('Ianson '+ff2)
        labeled.add(ff2)
for ff in file2S['river'].values:
    ff2=ff if not (ff in tr.keys()) else tr[ff]
    if (ff2 in labeled):
        ax.plot(file2S.loc[file2S.river==ff,['YD']],file2S.loc[file2S.river==ff,['NO3']],'*',color=cols[ff2],
                label='Ianson '+ff,markersize=ms2)
    else:
        p,=ax.plot(file2S.loc[file2S.river==ff,['YD']],file2S.loc[file2S.river==ff,['NO3']],'*',color=cols[ff2],
                   label='Ianson '+ff,markersize=ms2)
        ps.append(p)
        labels.append('Ianson '+ff2)
        labeled.add(ff2)
for ff in file3S['river'].values:
    ff2=ff if not (ff in tr.keys()) else tr[ff]
    if (ff2 in labeled):
        ax.plot(file3S.loc[file3S.river==ff,['YD']],file3S.loc[file3S.river==ff,['N']],'*',color=cols[ff2],
                label='Ianson '+ff,markersize=ms2)
    else:
        p,=ax.plot(file3S.loc[file3S.river==ff,['YD']],file3S.loc[file3S.river==ff,['N']],'*',color=cols[ff2],
                   label='Ianson '+ff,markersize=ms2)
        ps.append(p)
        labels.append('Ianson '+ff2)
        labeled.add(ff2)
for ff in file4S['River'].values:
    ff2=ff if not (ff in tr.keys()) else tr[ff]
    if (ff2 in labeled):
        ax.plot(file4S.loc[file4S.River==ff,['YD']],file4S.loc[file4S.River==ff,['Nitrate_plus_Nitrite (uM)']],'*',color=cols[ff2],
                label='Ianson '+ff,markersize=ms2)
    else:
        p,=ax.plot(file4S.loc[file4S.River==ff,['YD']],file4S.loc[file4S.River==ff,['Nitrate_plus_Nitrite (uM)']],'*',color=cols[ff2],
                   label='Ianson '+ff,markersize=ms2)
        ps.append(p)
        labels.append('Ianson '+ff2)
        labeled.add(ff2)
ax.plot((dt.datetime(2017,11,1)-dt.datetime(2016,12,31)).days,67,'*',color=cols['Fraser'],markersize=ms2) # add my Fraser data point
p1,=ax.plot(-1*np.arange(1,367),listFraserOldN,'k--')# add forcing climatology for Fraser
p2,=ax.plot((-1,-367),(6.26,6.26),'k-')# add forcing climatology for Fraser
ps.append(p1);ps.append(p2);
labels.append('Fraser Forcing')
labels.append('Other Rivers Forcing')
ax.legend(ps,labels,bbox_to_anchor=(1., 1.05),fontsize=10)
ax.set_xlim(0,367)

ax=ax1
ps=list()
labels=list()
for (ff,ii) in llNO3:
    p,=ax.plot(df0[ff]['YD'],df0[ff][ii]/mwN*1000.0,'.',label='EC '+ff,markersize=ms1,color=cols[ff])
    if not ('EC '+ff in labels):
        ps.append(p)
        labels.append('EC '+ff)
ax.set_xlim(0,366)
ax.set_xlabel('Year Day')
ax.set_ylabel('Nitrate ($\mu$M)')
labeled=set()
for ff in file1S['river'].values:
    ff2=ff if not (ff in tr.keys()) else tr[ff]
    if (ff2 in labeled):
        ax.plot(file1S.loc[file1S.river==ff,['YD']],file1S.loc[file1S.river==ff,['NO3']],'*',color=cols[ff2],
                label='Ianson '+ff,markersize=ms2)
    else:
        p,=ax.plot(file1S.loc[file1S.river==ff,['YD']],file1S.loc[file1S.river==ff,['NO3']],'*',color=cols[ff2],
                   label='Ianson '+ff,markersize=ms2)
        ps.append(p)
        labels.append('Ianson '+ff2)
        labeled.add(ff2)
for ff in file2S['river'].values:
    ff2=ff if not (ff in tr.keys()) else tr[ff]
    if (ff2 in labeled):
        ax.plot(file2S.loc[file2S.river==ff,['YD']],file2S.loc[file2S.river==ff,['NO3']],'*',color=cols[ff2],
                label='Ianson '+ff,markersize=ms2)
    else:
        p,=ax.plot(file2S.loc[file2S.river==ff,['YD']],file2S.loc[file2S.river==ff,['NO3']],'*',color=cols[ff2],
                   label='Ianson '+ff,markersize=ms2)
        ps.append(p)
        labels.append('Ianson '+ff2)
        labeled.add(ff2)
for ff in file3S['river'].values:
    ff2=ff if not (ff in tr.keys()) else tr[ff]
    if (ff2 in labeled):
        ax.plot(file3S.loc[file3S.river==ff,['YD']],file3S.loc[file3S.river==ff,['N']],'*',color=cols[ff2],
                label='Ianson '+ff,markersize=ms2)
    else:
        p,=ax.plot(file3S.loc[file3S.river==ff,['YD']],file3S.loc[file3S.river==ff,['N']],'*',color=cols[ff2],
                   label='Ianson '+ff,markersize=ms2)
        ps.append(p)
        labels.append('Ianson '+ff2)
        labeled.add(ff2)
for ff in file4S['River'].values:
    ff2=ff if not (ff in tr.keys()) else tr[ff]
    if (ff2 in labeled):
        ax.plot(file4S.loc[file4S.River==ff,['YD']],file4S.loc[file4S.River==ff,['Nitrate_plus_Nitrite (uM)']],'*',color=cols[ff2],
                label='Ianson '+ff,markersize=ms2)
    else:
        p,=ax.plot(file4S.loc[file4S.River==ff,['YD']],file4S.loc[file4S.River==ff,['Nitrate_plus_Nitrite (uM)']],'*',color=cols[ff2],
                   label='Ianson '+ff,markersize=ms2)
        ps.append(p)
        labels.append('Ianson '+ff2)
        labeled.add(ff2)
ax.plot((dt.datetime(2017,11,1)-dt.datetime(2016,12,31)).days,67,'*',color=cols['Fraser'],markersize=ms2) # add my Fraser data point
p1,=ax.plot(np.arange(1,367),listFraserOldN,'k--')# add forcing climatology for Fraser
p2,=ax.plot((1,367),(6.26,6.26),'k-')# add forcing climatology for Fraser
ps.append(p1);ps.append(p2);
labels.append('Fraser Forcing')
labels.append('Other Rivers Forcing')
#ax.legend(ps,labels,bbox_to_anchor=(1.3, 1.1))
ax.set_ylim(0,75)
fig.savefig('/data/eolson/results/MEOPAR/biomodelevalpaper/figsMod/riverForcing/rivNO3.png',dpi=400,transparent=True)

#fig.savefig('/data/eolson/results/MEOPAR/biomodelevalpaper/figsMod/rivNO3Hi.png',dpi=400,transparent=True)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.21712917618892152, 'fraction_numerical': 0.04501033844814452, 'mean_word_length': 4.491335006573443, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '483919', 'license': 'Apache-2.0', 'n_tokens_mistral': 20810, 'n_tokens_neox': 19569, 'n_words': 2380, 'path': 'notebooks/methods/calcOtherRiversMean-MoreData-recDataInfo-ReviseMacDonaldMWsOnlyDissolvedSiO2OnlyDissolvedNO3NH.ipynb', 'repo_name': 'e-olson/NSOGNO3', 'size': '45945'}