import netCDF4 as nc
from matplotlib import pyplot as plt
import numpy as np
import glob
import pickle
from salishsea_tools import evaltools as et
import datetime as dt
import os
import re
import cmocean
%matplotlib inline
f1=nc.Dataset('/data/eolson/results/MEOPAR/SS36runs/GrahamRuns/gyretestOrig/GYRE_1d_00010101_00010206_bioscalar.nc')
f2=nc.Dataset('/data/eolson/results/MEOPAR/SS36runs/GrahamRuns/gyretestOrig/GYRE_1d_00010101_00010206_grid_T.nc')
f3=nc.Dataset('/data/eolson/results/MEOPAR/SS36runs/GrahamRuns/gyretestOrig/GYRE_1d_00010101_00010206_ptrc_T.nc')
f1.variables.keys()
dict_keys(['nav_lat', 'nav_lon', 'time_instant', 'time_instant_bounds', 'time_counter', 'time_counter_bounds', 'time_centered', 'time_centered_bounds', 'tdenit', 'tnfix', 'tcflx', 'tcflxcum', 'tcexp', 'tintpp', 'pno3tot', 'ppo4tot', 'psiltot', 'palktot', 'pfertot'])
print(f1.variables['pno3tot'])
print(np.max(f1.variables['pno3tot']),np.min(f1.variables['pno3tot']))
print(f2.variables['tos'])
<class 'netCDF4._netCDF4.Variable'> float32 pno3tot(time_counter, y, x) long_name: global mean nitrate concentration units: umolN online_operation: average interval_operation: 7200 s interval_write: 1 d cell_methods: time: mean (interval: 7200 s) _FillValue: 1e+20 missing_value: 1e+20 coordinates: time_centered nav_lat nav_lon unlimited dimensions: time_counter current shape = (36, 22, 32) filling on 30.910471 30.91006 <class 'netCDF4._netCDF4.Variable'> float32 tos(time_counter, y, x) standard_name: sea_surface_temperature long_name: sea surface temperature units: degC online_operation: average interval_operation: 7200 s interval_write: 1 d cell_methods: time: mean (interval: 7200 s) _FillValue: 1e+20 missing_value: 1e+20 coordinates: time_centered nav_lat nav_lon unlimited dimensions: time_counter current shape = (36, 22, 32) filling on
plt.pcolormesh(f2.variables['tos'][-1,:,:])
<matplotlib.collections.QuadMesh at 0x7f9f0af962b0>
f3.variables['NO3']
<class 'netCDF4._netCDF4.Variable'> float32 NO3(time_counter, deptht, y, x) long_name: Nitrate Concentration units: mmol/m3 online_operation: average interval_operation: 7200 s interval_write: 1 d cell_methods: time: mean (interval: 7200 s) _FillValue: 1e+20 missing_value: 1e+20 coordinates: time_centered nav_lat nav_lon unlimited dimensions: time_counter current shape = (36, 31, 22, 32) filling on
plt.pcolormesh(f3.variables['NO3'][-1,0,:,:])
<matplotlib.collections.QuadMesh at 0x7f9f0af2bb20>
f=nc.Dataset('/data/eolson/results/MEOPAR/SS36runs/GrahamRuns/gyretest/GYRE_1d_00010101_00010206_ptrc_T.nc')
for el in ('AFILTNO3','SMSNO3A','SMSNO3B'):
print(np.min(f.variables[el]),np.max(f.variables[el]))
-2.4541109e-11 0.0002356125 -2.2278057e-10 4.8211153e-12 0.0 0.0
SMSNO3A=np.copy(f.variables['SMSNO3A'][:,:,:,:]).flatten()
AFILTNO3=np.copy(f.variables['AFILTNO3'][:,:,:,:]).flatten()
fig,ax=plt.subplots(1,1,figsize=(5,5))
ax.plot(SMSNO3A,AFILTNO3,'k.')
ax.set_xlim(-2.5e-10,.5e-10)
ax.set_ylim(-2.5e-11,.5e-11)
x1=np.linspace(-2.5e-10,.5e-10,5)
ax.plot(x1,.11*x1,'r-')
[<matplotlib.lines.Line2D at 0x7f9f3d6eb160>]
fig,ax=plt.subplots(1,1,figsize=(5,5))
ax.plot(f.variables['SMSNO3A'][-1,5,:,:],f.variables['AFILTNO3'][-1,5,:,:],'k.')
ax.set_xlim(-2e-11,1e-11)
ax.set_ylim(-2e-12,1e-12)
x1=np.linspace(-2.5e-11,1e-11,5)
ax.plot(x1,.11*x1,'r-')
[<matplotlib.lines.Line2D at 0x7f9f0aecbcd0>]
ignorelist=('nav_lat','nav_lon', 'bounds_nav_lon', 'bounds_nav_lat', 'area', 'bounds_lon','bounds_lat',
'deptht', 'deptht_bounds', 'time_centered', 'time_centered_bounds',
'time_counter', 'time_counter_bounds','nav_lat_grid_T', 'nav_lon_grid_T',
'bounds_nav_lon_grid_T', 'bounds_nav_lat_grid_T', 'area_grid_T',
'nav_lat_grid_W', 'nav_lon_grid_W', 'bounds_nav_lon_grid_W',
'bounds_nav_lat_grid_W', 'area_grid_W', 'time_centered', 'time_centered_bounds',
'depthu', 'depthu_bounds','depthv', 'depthv_bounds','depthw', 'depthw_bounds',
'layer6m_W', 'layer6m_W_bounds','bounds_lon_grid_T','bounds_lat_grid_T',
'bounds_lon_grid_W','bounds_lat_grid_W','time_instant_bounds','time_instant')
def checkall(ff):
fkeys=ff.variables.keys()
print('fP.variables.keys():',fkeys)
print('Min/Max:')
for var in fkeys:
if var not in ignorelist:
#print(var)
if len(np.shape(ff.variables[var]))==4:
print(var,':',np.min(np.ma.masked_where(tmask[:,:,:]==0,ff.variables[var][-1,:,:,:])),
np.max(np.ma.masked_where(tmask[:,:,:]==0,ff.variables[var][-1,:,:,:])))
elif len(np.shape(ff.variables[var]))==3:
print(var,':',np.min(np.ma.masked_where(tmask[0,:,:]==0,ff.variables[var][-1,:,:])),
np.max(np.ma.masked_where(tmask[0,:,:]==0,ff.variables[var][-1,:,:])))
else:
print('unknown shape: ',var,len(np.shape(ff.variables[var])))
def checkallSlice(ff):
fkeys=ff.variables.keys()
print('fP.variables.keys():',fkeys)
print('Min/Max:')
for var in fkeys:
if var not in ignorelist:
print(var,':',np.min(ff.variables[var][-1,:,:,:]),
np.max(ff.variables[var][-1,:,:,:]))
with nc.Dataset('/ocean/eolson/MEOPAR/NEMO-forcing/grid/mesh_mask201702_noLPE.nc') as mesh:
tmask=mesh.variables['tmask'][0,:,:,:]
e1t=np.expand_dims(mesh.variables['e1t'][:,:,:],1)
e2t=np.expand_dims(mesh.variables['e2t'][:,:,:],1)
z=mesh.variables['gdept_1d'][0,:]
e3t_1d=mesh.variables['e3t_1d'][0,:]
SOGtmaskPath='/ocean/eolson/MEOPAR/northernNO3PaperCalcs/save/SOGtmask.pkl'
(tmaskSOG,_,_,_,_)=pickle.load(open(SOGtmaskPath,'rb'))
idir='/data/sallen/results/MEOPAR/fluxes_elise_2/'
ts=dt.datetime(2015,1,1)
te=dt.datetime(2015,12,31)
ftype='dian_T'
paths=glob.glob(os.path.join(idir,'*','*'+ftype+'*'))
fPlist=et.index_model_files_flex(idir,'dian_T','1d','nowcast',ts,te)
fDlist=et.index_model_files_flex(idir,'dia1_T','1d','nowcast',ts,te)
fD2list=et.index_model_files_flex(idir,'dia2_T','1d','nowcast',ts,te)
fSlist=et.index_model_files_flex(idir,'snp_T','1d','nowcast',ts,te)
fRlist=et.index_model_files_flex(idir,'rad_T','1d','nowcast',ts,te)
fPlist.head()
paths | t_0 | t_n | |
---|---|---|---|
0 | /data/sallen/results/MEOPAR/fluxes_elise_2/01j... | 2015-01-01 | 2015-01-06 |
1 | /data/sallen/results/MEOPAR/fluxes_elise_2/06j... | 2015-01-06 | 2015-01-11 |
2 | /data/sallen/results/MEOPAR/fluxes_elise_2/11j... | 2015-01-11 | 2015-01-16 |
3 | /data/sallen/results/MEOPAR/fluxes_elise_2/16j... | 2015-01-16 | 2015-01-21 |
4 | /data/sallen/results/MEOPAR/fluxes_elise_2/21j... | 2015-01-21 | 2015-01-26 |
fDlist.head()
paths | t_0 | t_n | |
---|---|---|---|
0 | /data/sallen/results/MEOPAR/fluxes_elise_2/01j... | 2015-01-01 | 2015-01-06 |
1 | /data/sallen/results/MEOPAR/fluxes_elise_2/06j... | 2015-01-06 | 2015-01-11 |
2 | /data/sallen/results/MEOPAR/fluxes_elise_2/11j... | 2015-01-11 | 2015-01-16 |
3 | /data/sallen/results/MEOPAR/fluxes_elise_2/16j... | 2015-01-16 | 2015-01-21 |
4 | /data/sallen/results/MEOPAR/fluxes_elise_2/21j... | 2015-01-21 | 2015-01-26 |
fD2list.head()
paths | t_0 | t_n | |
---|---|---|---|
0 | /data/sallen/results/MEOPAR/fluxes_elise_2/01j... | 2015-01-01 | 2015-01-06 |
1 | /data/sallen/results/MEOPAR/fluxes_elise_2/06j... | 2015-01-06 | 2015-01-11 |
2 | /data/sallen/results/MEOPAR/fluxes_elise_2/11j... | 2015-01-11 | 2015-01-16 |
3 | /data/sallen/results/MEOPAR/fluxes_elise_2/16j... | 2015-01-16 | 2015-01-21 |
4 | /data/sallen/results/MEOPAR/fluxes_elise_2/21j... | 2015-01-21 | 2015-01-26 |
fD2list.tail()
paths | t_0 | t_n | |
---|---|---|---|
67 | /data/sallen/results/MEOPAR/fluxes_elise_2/06d... | 2015-12-06 | 2015-12-11 |
68 | /data/sallen/results/MEOPAR/fluxes_elise_2/11d... | 2015-12-11 | 2015-12-16 |
69 | /data/sallen/results/MEOPAR/fluxes_elise_2/16d... | 2015-12-16 | 2015-12-21 |
70 | /data/sallen/results/MEOPAR/fluxes_elise_2/21d... | 2015-12-21 | 2015-12-26 |
71 | /data/sallen/results/MEOPAR/fluxes_elise_2/26d... | 2015-12-26 | 2016-01-01 |
fSlist.head()
paths | t_0 | t_n | |
---|---|---|---|
0 | /data/sallen/results/MEOPAR/fluxes_elise_2/01j... | 2015-01-01 | 2015-01-06 |
1 | /data/sallen/results/MEOPAR/fluxes_elise_2/06j... | 2015-01-06 | 2015-01-11 |
2 | /data/sallen/results/MEOPAR/fluxes_elise_2/11j... | 2015-01-11 | 2015-01-16 |
3 | /data/sallen/results/MEOPAR/fluxes_elise_2/16j... | 2015-01-16 | 2015-01-21 |
4 | /data/sallen/results/MEOPAR/fluxes_elise_2/21j... | 2015-01-21 | 2015-01-26 |
with nc.Dataset(fRlist.paths[0]) as ff:
checkall(ff)
fP.variables.keys(): dict_keys(['nav_lat', 'nav_lon', 'bounds_lon', 'bounds_lat', 'area', 'deptht', 'deptht_bounds', 'RDB_NO3', 'time_centered', 'time_centered_bounds', 'time_counter', 'time_counter_bounds', 'RDB_NH4', 'RDB_DON', 'RDB_PON', 'RDB_LIV', 'RDN_NO3', 'RDN_NH4', 'RDN_DON', 'RDN_PON', 'RDN_LIV']) Min/Max: RDB_NO3 : 0.0 0.0 RDB_NH4 : 0.0 0.0 RDB_DON : 0.0 0.0 RDB_PON : 0.0 0.0 RDB_LIV : 0.0 0.007850944 RDN_NO3 : 0.0 0.0 RDN_NH4 : 0.0 0.0 RDN_DON : 0.0 0.0 RDN_PON : 0.0 0.0 RDN_LIV : 0.0 0.084532455
with nc.Dataset(fPlist.paths[0]) as ff:
checkall(ff)
fP.variables.keys(): dict_keys(['nav_lat', 'nav_lon', 'bounds_lon', 'bounds_lat', 'area', 'deptht', 'deptht_bounds', 'NO3RAD', 'time_centered', 'time_centered_bounds', 'time_counter', 'time_counter_bounds', 'RIV_NO3', 'RIV_NH4', 'REM_NO3', 'REM_PON', 'REM_DON', 'PRD_NO3', 'PRD_NH4', 'REFRN']) Min/Max: NO3RAD : 0.0 0.0 RIV_NO3 : 0.0 4302.5117 RIV_NH4 : 0.0 2210.7188 REM_NO3 : 0.0 1.1682037 REM_PON : -0.77527034 -0.0 REM_DON : -1.1512139 -0.0 PRD_NO3 : -0.5814207 -0.0 PRD_NH4 : -0.22910036 -0.0 REFRN : -1.9300626e-06 2.3530053e-21
radNO3Sum=list(); rivNO3Sum=list(); rivNH4Sum=list(); nitrSum=list(); remONSum=list(); prdNO3Sum=list();
prdNH4Sum=list(); refrNSum=list();
radSum=list();
for i,r in fPlist.iterrows():
with nc.Dataset(r['paths']) as f:
radNO3Sum.append(np.sum(np.sum(np.sum(tmaskSOG*f.variables['NO3RAD'][:,:,:,:],3),2),1))
rivNO3Sum.append(np.sum(np.sum(np.sum(tmaskSOG*f.variables['RIV_NO3'][:,:,:,:],3),2),1))
rivNH4Sum.append(np.sum(np.sum(np.sum(tmaskSOG*f.variables['RIV_NH4'][:,:,:,:],3),2),1))
nitrSum.append(np.sum(np.sum(np.sum(tmaskSOG*f.variables['REM_NO3'][:,:,:,:],3),2),1))
remONSum.append(np.sum(np.sum(np.sum(tmaskSOG*(f.variables['REM_DON'][:,:,:,:]+\
f.variables['REM_PON'][:,:,:,:]),3),2),1))
prdNO3Sum.append(np.sum(np.sum(np.sum(tmaskSOG*f.variables['PRD_NO3'][:,:,:,:],3),2),1))
prdNH4Sum.append(np.sum(np.sum(np.sum(tmaskSOG*f.variables['PRD_NH4'][:,:,:,:],3),2),1))
refrNSum.append(np.sum(np.sum(np.sum(tmaskSOG*f.variables['REFRN'][:,:,:,:],3),2),1))
radNO3Sum=np.concatenate(radNO3Sum,axis=0)
rivNO3Sum=np.concatenate(rivNO3Sum,axis=0)
rivNH4Sum=np.concatenate(rivNH4Sum,axis=0)
nitrSum=np.concatenate(nitrSum,axis=0)
remONSum=np.concatenate(remONSum,axis=0)
prdNO3Sum=np.concatenate(prdNO3Sum,axis=0)
prdNH4Sum=np.concatenate(prdNH4Sum,axis=0)
refrNSum=np.concatenate(refrNSum,axis=0)
rdbNO3Sum=list(); rdbNH4Sum=list(); rdbDONSum=list(); rdbPONSum=list(); rdbLIVSum=list();
rdnNO3Sum=list(); rdnNH4Sum=list(); rdnDONSum=list(); rdnPONSum=list(); rdnLIVSum=list();
for i,r in fRlist.iterrows():
with nc.Dataset(r['paths']) as f:
rdbNO3Sum.append(np.sum(np.sum(np.sum(tmaskSOG*f.variables['RDB_NO3'][:,:,:,:],3),2),1))
rdbNH4Sum.append(np.sum(np.sum(np.sum(tmaskSOG*f.variables['RDB_NH4'][:,:,:,:],3),2),1))
rdbDONSum.append(np.sum(np.sum(np.sum(tmaskSOG*f.variables['RDB_DON'][:,:,:,:],3),2),1))
rdbPONSum.append(np.sum(np.sum(np.sum(tmaskSOG*f.variables['RDB_PON'][:,:,:,:],3),2),1))
rdbLIVSum.append(np.sum(np.sum(np.sum(tmaskSOG*f.variables['RDB_LIV'][:,:,:,:],3),2),1))
rdnNO3Sum.append(np.sum(np.sum(np.sum(tmaskSOG*f.variables['RDN_NO3'][:,:,:,:],3),2),1))
rdnNH4Sum.append(np.sum(np.sum(np.sum(tmaskSOG*f.variables['RDN_NH4'][:,:,:,:],3),2),1))
rdnDONSum.append(np.sum(np.sum(np.sum(tmaskSOG*f.variables['RDN_DON'][:,:,:,:],3),2),1))
rdnPONSum.append(np.sum(np.sum(np.sum(tmaskSOG*f.variables['RDN_PON'][:,:,:,:],3),2),1))
rdnLIVSum.append(np.sum(np.sum(np.sum(tmaskSOG*f.variables['RDN_LIV'][:,:,:,:],3),2),1))
rdbNO3Sum=np.concatenate(rdbNO3Sum,axis=0)
rdbNH4Sum=np.concatenate(rdbNH4Sum,axis=0)
rdbDONSum=np.concatenate(rdbDONSum,axis=0)
rdbPONSum=np.concatenate(rdbPONSum,axis=0)
rdbLIVSum=np.concatenate(rdbLIVSum,axis=0)
rdnNO3Sum=np.concatenate(rdnNO3Sum,axis=0)
rdnNH4Sum=np.concatenate(rdnNH4Sum,axis=0)
rdnDONSum=np.concatenate(rdnDONSum,axis=0)
rdnPONSum=np.concatenate(rdnPONSum,axis=0)
rdnLIVSum=np.concatenate(rdnLIVSum,axis=0)
with nc.Dataset(fDlist.paths[0]) as ff:
checkall(ff)
fP.variables.keys(): dict_keys(['nav_lat_grid_T', 'nav_lon_grid_T', 'bounds_lon_grid_T', 'bounds_lat_grid_T', 'area_grid_T', 'deptht', 'deptht_bounds', 'nav_lat_grid_W', 'nav_lon_grid_W', 'bounds_lon_grid_W', 'bounds_lat_grid_W', 'area_grid_W', 'ATF_NO3', 'time_centered', 'time_centered_bounds', 'time_counter', 'time_counter_bounds', 'ATF_NH4', 'ATF_DON', 'ATF_PON', 'ATF_LIV', 'BFX_PON', 'BFX_DIAT']) Min/Max: ATF_NO3 : -0.24442177 0.40803906 ATF_NH4 : -0.06709565 0.13065556 ATF_DON : -0.055233955 0.02081882 ATF_PON : -0.25654957 0.2159471 ATF_LIV : -0.2947296 0.039652318 BFX_PON : -1.5762753e-05 -0.0 BFX_DIAT : -4.585363e-07 -0.0
ATFNO3Sum=list(); ATFNH4Sum=list(); ATFDONSum=list(); ATFPONSum=list(); ATFLIVSum=list();
BFXPONSum=list(); BFXDIATSum=list();
for i,r in fDlist.iterrows():
with nc.Dataset(r['paths']) as f:
ATFNO3Sum.append(np.sum(np.sum(np.sum(tmaskSOG*f.variables['ATF_NO3'][:,:,:,:],3),2),1))
ATFNH4Sum.append(np.sum(np.sum(np.sum(tmaskSOG*f.variables['ATF_NH4'][:,:,:,:],3),2),1))
ATFDONSum.append(np.sum(np.sum(np.sum(tmaskSOG*f.variables['ATF_DON'][:,:,:,:],3),2),1))
ATFPONSum.append(np.sum(np.sum(np.sum(tmaskSOG*f.variables['ATF_PON'][:,:,:,:],3),2),1))
ATFLIVSum.append(np.sum(np.sum(np.sum(tmaskSOG*f.variables['ATF_LIV'][:,:,:,:],3),2),1))
BFXPONSum.append(np.sum(np.sum(tmaskSOG[:,0,:,:]*e1t[:,0,:,:]*e2t[:,0,:,:]*f.variables['BFX_PON'][:,:,:],2),1))
BFXDIATSum.append(np.sum(np.sum(tmaskSOG[:,0,:,:]*e1t[:,0,:,:]*e2t[:,0,:,:]*f.variables['BFX_DIAT'][:,:,:],2),1))
ATFNO3Sum=np.concatenate(ATFNO3Sum,axis=0)
ATFNH4Sum=np.concatenate(ATFNH4Sum,axis=0)
ATFDONSum=np.concatenate(ATFDONSum,axis=0)
ATFPONSum=np.concatenate(ATFPONSum,axis=0)
ATFLIVSum=np.concatenate(ATFLIVSum,axis=0)
BFXPONSum=np.concatenate(BFXPONSum,axis=0)
BFXDIATSum=np.concatenate(BFXDIATSum,axis=0)
np.shape(e1t)
(1, 1, 898, 398)
with nc.Dataset(fD2list.paths[0]) as ff:
checkall(ff)
fP.variables.keys(): dict_keys(['nav_lat', 'nav_lon', 'bounds_lon', 'bounds_lat', 'area', 'deptht', 'deptht_bounds', 'PHS_NO3', 'time_centered', 'time_centered_bounds', 'time_counter', 'time_counter_bounds', 'PHS_NH4', 'PHS_DON', 'PHS_PON', 'PHS_LIV', 'SMS_NO3', 'SMS_NH4', 'SMS_DON', 'SMS_PON', 'SMS_LIV']) Min/Max: PHS_NO3 : -321.71988 226.96649 PHS_NH4 : -18.812874 17.29121 PHS_DON : -6.5223646 6.215761 PHS_PON : -3.5704317 2.5522447 PHS_LIV : -14.197901 19.155512 SMS_NO3 : -0.5728717 1.1682037 SMS_NH4 : -0.58287334 1.1759585 SMS_DON : -0.497201 0.1873806 SMS_PON : -0.6986264 0.7050382 SMS_LIV : -2.6782591 0.3758299
PHSNO3Sum=list(); PHSNH4Sum=list(); PHSDONSum=list(); PHSPONSum=list(); PHSLIVSum=list();
SMSNO3Sum=list(); SMSNH4Sum=list(); SMSDONSum=list(); SMSPONSum=list(); SMSLIVSum=list();
for i,r in fD2list.iterrows():
with nc.Dataset(r['paths']) as f:
PHSNO3Sum.append(np.sum(np.sum(np.sum(tmaskSOG*f.variables['PHS_NO3'][:,:,:,:],3),2),1))
PHSNH4Sum.append(np.sum(np.sum(np.sum(tmaskSOG*f.variables['PHS_NH4'][:,:,:,:],3),2),1))
PHSDONSum.append(np.sum(np.sum(np.sum(tmaskSOG*f.variables['PHS_DON'][:,:,:,:],3),2),1))
PHSPONSum.append(np.sum(np.sum(np.sum(tmaskSOG*f.variables['PHS_PON'][:,:,:,:],3),2),1))
PHSLIVSum.append(np.sum(np.sum(np.sum(tmaskSOG*f.variables['PHS_LIV'][:,:,:,:],3),2),1))
SMSNO3Sum.append(np.sum(np.sum(np.sum(tmaskSOG*f.variables['SMS_NO3'][:,:,:,:],3),2),1))
SMSNH4Sum.append(np.sum(np.sum(np.sum(tmaskSOG*f.variables['SMS_NH4'][:,:,:,:],3),2),1))
SMSDONSum.append(np.sum(np.sum(np.sum(tmaskSOG*f.variables['SMS_DON'][:,:,:,:],3),2),1))
SMSPONSum.append(np.sum(np.sum(np.sum(tmaskSOG*f.variables['SMS_PON'][:,:,:,:],3),2),1))
SMSLIVSum.append(np.sum(np.sum(np.sum(tmaskSOG*f.variables['SMS_LIV'][:,:,:,:],3),2),1))
PHSNO3Sum=np.concatenate(PHSNO3Sum,axis=0)
PHSNH4Sum=np.concatenate(PHSNH4Sum,axis=0)
PHSDONSum=np.concatenate(PHSDONSum,axis=0)
PHSPONSum=np.concatenate(PHSPONSum,axis=0)
PHSLIVSum=np.concatenate(PHSLIVSum,axis=0)
SMSNO3Sum=np.concatenate(SMSNO3Sum,axis=0)
SMSNH4Sum=np.concatenate(SMSNH4Sum,axis=0)
SMSDONSum=np.concatenate(SMSDONSum,axis=0)
SMSPONSum=np.concatenate(SMSPONSum,axis=0)
SMSLIVSum=np.concatenate(SMSLIVSum,axis=0)
plt.plot(SMSNO3Sum,ATFNO3Sum,'k.',label='ATF trend')
plt.plot(SMSNH4Sum,ATFNH4Sum,'g.',label='ATF trend')
plt.plot(SMSDONSum,ATFDONSum,'b.',label='ATF trend')
plt.plot(SMSNO3Sum,0.1111*SMSNO3Sum,'c-', label='Bio trend * 0.111')
plt.xlabel('Bio Trend')
plt.ylabel('ATF Trend')
from scipy import stats as scst
slope, intercept, r_value, p_value, std_err = scst.linregress(SMSNO3Sum,ATFNO3Sum)
print(slope, intercept, r_value, p_value, std_err)
0.11112161670571052 11.93817220665369 0.9999998578055815 0.0 3.1102948242488117e-06
with nc.Dataset(fSlist.paths[0]) as ff:
checkall(ff)
fP.variables.keys(): dict_keys(['nav_lat', 'nav_lon', 'bounds_lon', 'bounds_lat', 'area', 'deptht', 'deptht_bounds', 'NO3_E3TSNAP', 'time_instant', 'time_instant_bounds', 'time_counter', 'time_counter_bounds', 'NH4_E3TSNAP', 'PON_E3TSNAP', 'DON_E3TSNAP', 'LIV_E3TSNAP']) Min/Max: NO3_E3TSNAP : 0.0 938.17944 NH4_E3TSNAP : 0.0 26.615145 PON_E3TSNAP : 0.0 3.1245656 DON_E3TSNAP : 0.0 5.336901 LIV_E3TSNAP : 0.0 15.088703
NO3Sum=list(); NH4Sum=list(); DONSum=list(); PONSum=list(); LIVSum=list();
for i,r in fSlist.iterrows():
with nc.Dataset(r['paths']) as f:
NO3Sum.append(np.sum(np.sum(np.sum(tmaskSOG*e1t*e2t*f.variables['NO3_E3TSNAP'][:,:,:,:],3),2),1))
NH4Sum.append(np.sum(np.sum(np.sum(tmaskSOG*e1t*e2t*f.variables['NH4_E3TSNAP'][:,:,:,:],3),2),1))
DONSum.append(np.sum(np.sum(np.sum(tmaskSOG*e1t*e2t*f.variables['DON_E3TSNAP'][:,:,:,:],3),2),1))
PONSum.append(np.sum(np.sum(np.sum(tmaskSOG*e1t*e2t*f.variables['PON_E3TSNAP'][:,:,:,:],3),2),1))
LIVSum.append(np.sum(np.sum(np.sum(tmaskSOG*e1t*e2t*f.variables['LIV_E3TSNAP'][:,:,:,:],3),2),1))
NO3Sum=np.concatenate(NO3Sum,axis=0)
NH4Sum=np.concatenate(NH4Sum,axis=0)
DONSum=np.concatenate(DONSum,axis=0)
PONSum=np.concatenate(PONSum,axis=0)
LIVSum=np.concatenate(LIVSum,axis=0)
NO3diff=(NO3Sum[1:]-NO3Sum[:-1])/(24*3600)
NH4diff=(NH4Sum[1:]-NH4Sum[:-1])/(24*3600)
PONdiff=(PONSum[1:]-PONSum[:-1])/(24*3600)
DONdiff=(DONSum[1:]-DONSum[:-1])/(24*3600)
LIVdiff=(LIVSum[1:]-LIVSum[:-1])/(24*3600)
fig,ax=plt.subplots(1,3,figsize=(16,5))
ax[0].plot(range(1,len(NO3diff)+1),NO3diff,'k-',label='no3diff')
ax[0].plot(range(0,len(PHSNO3Sum)),PHSNO3Sum+SMSNO3Sum+ATFNO3Sum,'g--',label='phys+bio+afilt')
ax[0].legend()
ax[0].set_title('NO3')
ax[1].plot(range(1,len(NH4diff)+1),NH4diff,'k-',label='NH4diff')
ax[1].plot(range(0,len(PHSNH4Sum)),PHSNH4Sum+SMSNH4Sum+ATFNH4Sum,'g--',label='phys+bio+afilt')
ax[1].legend()
ax[1].set_title('NH4')
ax[2].plot(range(1,len(DONdiff)+1),DONdiff,'k-',label='no3diff')
ax[2].plot(range(0,len(PHSDONSum)),PHSDONSum+SMSDONSum+ATFDONSum,'g--',label='phys+bio+afilt')
ax[2].legend()
ax[2].set_title('DON')
Text(0.5, 1.0, 'DON')
fig,ax=plt.subplots(1,3,figsize=(16,5))
ax[0].plot(range(1,len(NO3diff)+1),NO3diff,'k-',label='no3diff')
ax[0].plot(range(0,len(PHSNO3Sum)),PHSNO3Sum+SMSNO3Sum+ATFNO3Sum,'g--',label='phys+bio+afilt')
ax[0].legend()
ax[0].set_title('NO3')
ax[0].set_xlim((0,10))
ax[1].plot(range(1,len(NH4diff)+1),NH4diff,'k-',label='NH4diff')
ax[1].plot(range(0,len(PHSNH4Sum)),PHSNH4Sum+SMSNH4Sum+ATFNH4Sum,'g--',label='phys+bio+afilt')
ax[1].legend()
ax[1].set_title('NH4')
ax[2].plot(range(1,len(DONdiff)+1),DONdiff,'k-',label='no3diff')
ax[2].plot(range(0,len(PHSDONSum)),PHSDONSum+SMSDONSum+ATFDONSum,'g--',label='phys+bio+afilt')
ax[2].legend()
ax[2].set_title('DON')
Text(0.5, 1.0, 'DON')
fig,ax=plt.subplots(2,1,figsize=(11,10))
ax[0].plot(range(1,len(PONdiff)+1),PONdiff,'k-',label='PONdiff')
ax[0].plot(range(0,len(PHSPONSum)),PHSPONSum+SMSPONSum+ATFPONSum+BFXPONSum,'g--',label='phys+bio+afilt+sink')
ax[0].legend()
ax[0].set_title('PON')
ax[1].plot(range(1,len(LIVdiff)+1),LIVdiff,'k-',label='LIVdiff')
ax[1].plot(range(0,len(PHSLIVSum)),PHSLIVSum+SMSLIVSum+ATFLIVSum+BFXDIATSum,'g--',label='phys+bio+afilt+sink')
ax[1].legend()
ax[1].set_title('LIV')
ax[1].set_xlim((-.5,40))
(-0.5, 40)
fig,ax=plt.subplots(2,1,figsize=(11,10))
ax[0].plot(range(1,len(PHSPONSum)),PHSPONSum[1:]+SMSPONSum[1:]+ATFPONSum[1:]+BFXPONSum[1:]-PONdiff,'g--',label='difference')
ax[0].legend()
ax[0].set_title('PON')
ax[1].plot(range(1,len(PHSLIVSum)),PHSLIVSum[1:]+SMSLIVSum[1:]+ATFLIVSum[1:]+BFXDIATSum[1:]-LIVdiff,'g--',label='difference')
ax[1].legend()
ax[1].set_title('LIV')
ax[1].set_xlim((-.5,40))
(-0.5, 40)
np.sum(radNO3Sum)
9.330578
np.sum(NO3diff)
-1117917.2736643702
(NO3Sum[-1]-NO3Sum[0])/(24*3600)
-1117917.27366437
# difference between fluxes and change in N content compared to rivers
np.sum(PHSNO3Sum[1:]+SMSNO3Sum[1:]+ATFNO3Sum[1:]),np.sum(NO3diff),\
np.sum(PHSNO3Sum[1:]+SMSNO3Sum[1:]+ATFNO3Sum[1:])-np.sum(NO3diff),np.sum(rivNO3Sum)
(-1115508.0, -1117917.2736643702, 2409.273664370179, 11269719.0)
# percent difference in N based on content versus fluxes (1) and relative to river input (2):
(np.sum(PHSNO3Sum[1:]+SMSNO3Sum[1:]+ATFNO3Sum[1:])-np.sum(NO3diff))/np.sum(NO3diff)*100, (np.sum(PHSNO3Sum[1:]+SMSNO3Sum[1:]+ATFNO3Sum[1:])-np.sum(NO3diff))/np.sum(rivNO3Sum[1:])*100
(-0.21551448583247407, 0.021427022234526576)
varsXr={'ATNO3':'ATX_NO3', 'ATNH4':'ATX_NH4', 'ATPON':'ATX_PON', 'ATDON':'ATX_DON', 'ATLIV':'ATX_LIV',
'DTNO3':'DTX_NO3', 'DTNH4':'DTX_NH4', 'DTPON':'DTX_PON', 'DTDON':'DTX_DON', 'DTLIV':'DTX_LIV'}
varsYr={'ATNO3':'ATY_NO3', 'ATNH4':'ATY_NH4', 'ATPON':'ATY_PON', 'ATDON':'ATY_DON', 'ATLIV':'ATY_LIV',
'DTNO3':'DTY_NO3', 'DTNH4':'DTY_NH4', 'DTPON':'DTY_PON', 'DTDON':'DTY_DON', 'DTLIV':'DTY_LIV'}
varsX = {v: k for k, v in varsXr.items()}
varsY = {v: k for k, v in varsYr.items()}
locs=('mal','har','sjc','ros','dis','sut')
dirs={'mal':-1,'har':1,'sjc':1,'ros':1,'dis':-1,'sut':-1} # in or out of domain
transps=dict();
fnames={'mal':'Malaspina_U','har':'Haro_V','sjc':'SJC_V','ros':'Rosario_V','dis':'Discovery_V','sut':'Sutil_V'}
for iloc in locs:
transps[iloc]=dict()
for ivar, inam in varsX.items():
print(ivar,inam)
ATX_NO3 ATNO3 ATX_NH4 ATNH4 ATX_PON ATPON ATX_DON ATDON ATX_LIV ATLIV DTX_NO3 DTNO3 DTX_NH4 DTNH4 DTX_PON DTPON DTX_DON DTDON DTX_LIV DTLIV
# x-dir
iloc='mal'
flist=et.index_model_files_flex(idir,'Malaspina_U','1d','nowcast',ts,te)
vls=dict()
for inam in varsX.values():
vls[inam]=list()
for i,r in flist.iterrows():
with nc.Dataset(r['paths']) as f:
for ivar, inam in varsX.items():
vls[inam].append(np.sum(np.sum(f.variables[ivar][:,:,:,0],2),1))
for inam in varsX.values():
transps[iloc][inam]=dirs[iloc]*np.concatenate(vls[inam],axis=0)
for iloc in ('har','sjc','ros','dis','sut'): # y-dir
flist=et.index_model_files_flex(idir,fnames[iloc],'1d','nowcast',ts,te)
vls=dict()
for inam in varsY.values():
vls[inam]=list()
for i,r in flist.iterrows():
with nc.Dataset(r['paths']) as f:
for ivar, inam in varsY.items():
vls[inam].append(np.sum(np.sum(f.variables[ivar][:,:,0,:],2),1))
for inam in varsY.values():
transps[iloc][inam]=dirs[iloc]*np.concatenate(vls[inam],axis=0)
transps['HaroDeep50']=dict()
# depth of no motion on average between 44 and58 m; sum index k=24 and deeper
flist=et.index_model_files_flex(idir,fnames['har'],'1d','nowcast',ts,te)
vls=dict()
for inam in varsY.values():
vls[inam]=list()
for i,r in flist.iterrows():
with nc.Dataset(r['paths']) as f:
for ivar, inam in varsY.items():
vls[inam].append(np.sum(np.sum(f.variables[ivar][:,24:,0,:],2),1))
for inam in varsY.values():
transps['HaroDeep50'][inam]=dirs['har']*np.concatenate(vls[inam],axis=0)
transps['HaroZ']=dict()
# depth of no motion on average between 44 and58 m; sum index k=24 and deeper
flist=et.index_model_files_flex(idir,fnames['har'],'1d','nowcast',ts,te)
vls=dict()
for inam in varsY.values():
vls[inam]=list()
for i,r in flist.iterrows():
with nc.Dataset(r['paths']) as f:
for ivar, inam in varsY.items():
vls[inam].append(np.sum(f.variables[ivar][:,:,0,:],2))
for inam in varsY.values():
transps['HaroZ'][inam]=dirs['har']*np.concatenate(vls[inam],axis=0)
plt.plot(np.sum(transps['HaroZ']['ATNO3']/e3t_1d,0),-1*z)
plt.plot(np.sum(transps['HaroZ']['ATNO3']/e3t_1d,0),-1*z,'k*')
plt.ylim(-300,0)
(-300, 0)
fig,ax=plt.subplots(3,1,figsize=(16,15))
advNO3=np.zeros(np.shape(transps['mal']['ATNO3']))
for iloc in locs:
ax[0].plot(range(0,len(transps[iloc]['ATNO3'])),transps[iloc]['ATNO3'],label=iloc)
advNO3=advNO3+transps[iloc]['ATNO3']
ax[0].plot(range(0,len(transps[iloc]['ATNO3'])),advNO3,'k-',label='sum')
ax[0].legend()
ax[0].set_title('Advection NO3')
difNO3=np.zeros(np.shape(transps['mal']['DTNO3']))
for iloc in locs:
ax[1].plot(range(0,len(transps[iloc]['DTNO3'])),transps[iloc]['DTNO3'],label=iloc)
difNO3=difNO3+transps[iloc]['DTNO3']
ax[1].plot(range(0,len(transps[iloc]['DTNO3'])),difNO3,'k-',label='sum')
ax[1].legend()
ax[1].set_title('Diffusion NO3')
ax[2].plot(range(0,len(transps[iloc]['DTNO3'])),PHSNO3Sum,'k-',label='phys')
ax[2].plot(range(0,len(transps[iloc]['DTNO3'])),advNO3+difNO3,'r--',label='lateral')
ax[2].legend()
<matplotlib.legend.Legend at 0x7f583cbf0eb0>
# repeat for all N-containing classes combined
Alist=('ATNO3','ATNH4','ATPON','ATDON','ATLIV')
Dlist=('DTNO3','DTNH4','DTPON','DTDON','DTLIV')
sh=np.shape(transps['mal']['ATNO3'])
for iloc in locs:
transps[iloc]['ATN']=np.zeros(sh)
transps[iloc]['DTN']=np.zeros(sh)
for ivar in Alist:
transps[iloc]['ATN']=transps[iloc]['ATN']+transps[iloc][ivar]
for ivar in Dlist:
transps[iloc]['DTN']=transps[iloc]['DTN']+transps[iloc][ivar]
fig,ax=plt.subplots(3,1,figsize=(16,15))
advN=np.zeros(sh)
for iloc in locs:
ax[0].plot(range(0,len(transps[iloc]['ATN'])),transps[iloc]['ATN'],label=iloc)
advN=advN+transps[iloc]['ATN']
ax[0].plot(range(0,len(transps[iloc]['ATN'])),advN,'k-',label='sum')
ax[0].legend()
ax[0].set_title('Advection N')
difN=np.zeros(sh)
for iloc in locs:
ax[1].plot(range(0,len(transps[iloc]['DTN'])),transps[iloc]['DTN'],label=iloc)
difN=difN+transps[iloc]['DTN']
ax[1].plot(range(0,len(transps[iloc]['DTN'])),difN,'k-',label='sum')
ax[1].legend()
ax[1].set_title('Diffusion N')
ax[2].plot(range(0,len(transps[iloc]['DTN'])),PHSNO3Sum+PHSNH4Sum+PHSDONSum+PHSPONSum+PHSLIVSum,'k-',label='phys')#
ax[2].plot(range(0,len(transps[iloc]['DTN'])),advN+difN,'r--',label='lateral')
ax[2].legend()
<matplotlib.legend.Legend at 0x7f583ca63940>
sums=dict()
print('NO3, Gmol/year')
print('Lateral Transport, Advection:\n', np.sum(advNO3)*24*3600*1e-12)
print('Lateral Transport, Mixing: \n',np.sum(difNO3)*24*3600*1e-12)
print('Rivers:\n',np.sum(rivNO3Sum)*24*3600*1e-12)
print('Primary Production: \n',np.sum(prdNO3Sum)*24*3600*1e-12)
print('Nitrification:\n',np.sum(nitrSum)*24*3600*1e-12)
print('Asselin Filter:\n',np.sum(ATFNO3Sum)*24*3600*1e-12)
print('Net change:\n',(np.sum(advNO3)+np.sum(difNO3)+np.sum(rivNO3Sum)+np.sum(prdNO3Sum)+np.sum(nitrSum)+\
np.sum(ATFNO3Sum))*24*3600*1e-12)
#print('Tansport+Rivers+Phytoplankton+Nitrification+Filter:\n',(np.sum(adv[:-1])+np.sum(dif[:-1])+np.sum(rivSum[:-1])\
# -np.sum(PPSum[:-1])+np.sum(nitrSum[:-1])+np.sum(afiltSum[:-1]))*24*3600*1e-12)
NO3, Gmol/year Lateral Transport, Advection: 10.63075983528164 Lateral Transport, Mixing: 0.006624143644155836 Rivers: 0.9737037216 Primary Production: -26.5755727872 Nitrification: 16.1179656192 Asselin Filter: -1.1616898176 Net change: -0.008209285074204827
print('NO3, Gmol/year, ATF-Corrected version')
print('Lateral Transport, Advection:\n', np.sum(advNO3)*24*3600*1e-12)
print('Lateral Transport, Mixing: \n',np.sum(difNO3)*24*3600*1e-12)
print('Rivers:\n',np.sum(rivNO3Sum)*24*3600*1e-12)
print('NO3-based Primary Production: \n',np.sum(prdNO3Sum)*24*3600*1e-12*1.111)
print('NH4-based Primary Production: \n',np.sum(prdNH4Sum)*24*3600*1e-12*1.111)
print('Nitrification:\n',np.sum(nitrSum)*24*3600*1e-12*1.111)
print('Net change NO3:\n',(np.sum(advNO3)+np.sum(difNO3)+np.sum(rivNO3Sum)+np.sum(prdNO3Sum)*1.111+np.sum(nitrSum)*1.111\
)*24*3600*1e-12)
print('Net change:\n',(NO3Sum[-1]+NH4Sum[-1]+DONSum[-1]+PONSum[-1]+LIVSum[-1]-NO3Sum[0]-NH4Sum[0]-DONSum[0]-PONSum[0]-LIVSum[0])*1e-12)
# save:
sums['Lateral Transport, Advection']=np.sum(advNO3)*24*3600*1e-12
sums['Lateral Transport, Mixing']=np.sum(difNO3)*24*3600*1e-12
sums['Rivers NO3']=np.sum(rivNO3Sum)*24*3600*1e-12
sums['NO3-based Primary Production']=np.sum(prdNO3Sum)*24*3600*1e-12*1.111
sums['NH4-based Primary Production']=np.sum(prdNH4Sum)*24*3600*1e-12*1.111
sums['Nitrification']=np.sum(nitrSum)*24*3600*1e-12*1.111
sums['Net change NO3']=(np.sum(advNO3)+np.sum(difNO3)+np.sum(rivNO3Sum)+np.sum(prdNO3Sum)*1.111+np.sum(nitrSum)*1.111\
)*24*3600*1e-12
sums['Net change']=(NO3Sum[-1]+NH4Sum[-1]+DONSum[-1]+PONSum[-1]+LIVSum[-1]-NO3Sum[0]-NH4Sum[0]-DONSum[0]-PONSum[0]-LIVSum[0])*1e-12
NO3, Gmol/year, ATF-Corrected version Lateral Transport, Advection: 10.63075983528164 Lateral Transport, Mixing: 0.006624143644155836 Rivers: 0.9737037216 NO3-based Primary Production: -29.525461366579197 NH4-based Primary Production: -19.950646271846402 Nitrification: 17.9070598029312 Net change NO3: -0.007313863122201634 Net change: -0.17072711256050263
print('DIN (NH4+NO3) from Rivers:',(np.sum(rivNO3Sum)+np.sum(rivNH4Sum))*24*3600*1e-12)
sums['DIN (NH4+NO3) from Rivers']=(np.sum(rivNO3Sum)+np.sum(rivNH4Sum))*24*3600*1e-12
DIN (NH4+NO3) from Rivers: 1.6409051712
# Haro:
print('Haro Strait NO3:',(np.sum(transps['har']['ATNO3']))*24*3600*1e-12)
print('Haro Strait NH4:',(np.sum(transps['har']['ATNH4']))*24*3600*1e-12)
print('Haro Strait DIN:',(np.sum(transps['har']['ATNO3'])+np.sum(transps['har']['ATNH4']))*24*3600*1e-12)
print('Haro Strait PON:',(np.sum(transps['har']['ATPON']))*24*3600*1e-12)
print('Haro Strait DON:',(np.sum(transps['har']['ATDON']))*24*3600*1e-12)
print('Haro Strait Living:',(np.sum(transps['har']['ATLIV']))*24*3600*1e-12)
sums['Haro Strait NO3']=(np.sum(transps['har']['ATNO3']))*24*3600*1e-12
sums['Haro Strait NH4']=(np.sum(transps['har']['ATNH4']))*24*3600*1e-12
sums['Haro Strait DIN']=(np.sum(transps['har']['ATNO3'])+np.sum(transps['har']['ATNH4']))*24*3600*1e-12
sums['Haro Strait PON']=(np.sum(transps['har']['ATPON']))*24*3600*1e-12
sums['Haro Strait DON']=(np.sum(transps['har']['ATDON']))*24*3600*1e-12
sums['Haro Strait Living']=(np.sum(transps['har']['ATLIV']))*24*3600*1e-12
Haro Strait NO3: 23.5918614528 Haro Strait NH4: 0.4319850528 Haro Strait DIN: 24.0238476288 Haro Strait PON: 0.244069632 Haro Strait DON: -0.7426197504 Haro Strait Living: -1.2506517503999999
# Deep Haro:
print('Deep Haro Strait NO3:',(np.sum(transps['HaroDeep50']['ATNO3']))*24*3600*1e-12)
print('Deep Haro Strait NH4:',(np.sum(transps['HaroDeep50']['ATNH4']))*24*3600*1e-12)
print('Deep Haro Strait DIN:',(np.sum(transps['HaroDeep50']['ATNO3'])+np.sum(transps['HaroDeep50']['ATNH4']))*24*3600*1e-12)
print('Deep Haro Strait PON:',(np.sum(transps['HaroDeep50']['ATPON']))*24*3600*1e-12)
print('Deep Haro Strait DON:',(np.sum(transps['HaroDeep50']['ATDON']))*24*3600*1e-12)
print('Deep Haro Strait Living:',(np.sum(transps['HaroDeep50']['ATLIV']))*24*3600*1e-12)
sums['Deep Haro Strait NO3']=(np.sum(transps['HaroDeep50']['ATNO3']))*24*3600*1e-12
sums['Deep Haro Strait NH4']=(np.sum(transps['HaroDeep50']['ATNH4']))*24*3600*1e-12
sums['Deep Haro Strait DIN']=(np.sum(transps['HaroDeep50']['ATNO3'])+np.sum(transps['har']['ATNH4']))*24*3600*1e-12
sums['Deep Haro Strait PON']=(np.sum(transps['HaroDeep50']['ATPON']))*24*3600*1e-12
sums['Deep Haro Strait DON']=(np.sum(transps['HaroDeep50']['ATDON']))*24*3600*1e-12
sums['Deep Haro Strait Living']=(np.sum(transps['HaroDeep50']['ATLIV']))*24*3600*1e-12
Deep Haro Strait NO3: 57.776943513599996 Deep Haro Strait NH4: 3.1661169408 Deep Haro Strait DIN: 60.9430597632 Deep Haro Strait PON: 0.9571352256 Deep Haro Strait DON: 1.0336510656 Deep Haro Strait Living: 1.7824650048
# Southern Passages:
print('Southern NO3:',(np.sum(transps['har']['ATNO3'])+np.sum(transps['sjc']['ATNO3'])+np.sum(transps['ros']['ATNO3']))*24*3600*1e-12)
print('Southern NH4:',(np.sum(transps['har']['ATNH4'])+np.sum(transps['sjc']['ATNH4'])+np.sum(transps['ros']['ATNH4']))*24*3600*1e-12)
print('Southern DIN:',(np.sum(transps['har']['ATNO3'])+np.sum(transps['sjc']['ATNO3'])+np.sum(transps['ros']['ATNO3'])+\
np.sum(transps['har']['ATNH4'])+np.sum(transps['sjc']['ATNH4'])+np.sum(transps['ros']['ATNH4']))*24*3600*1e-12)
print('Southern PON:',(np.sum(transps['har']['ATPON'])+np.sum(transps['sjc']['ATPON'])+np.sum(transps['ros']['ATPON']))*24*3600*1e-12)
print('Southern DON:',(np.sum(transps['har']['ATDON'])+np.sum(transps['sjc']['ATDON'])+np.sum(transps['ros']['ATDON']))*24*3600*1e-12)
print('Southern Living:',(np.sum(transps['har']['ATLIV'])+np.sum(transps['sjc']['ATLIV'])+np.sum(transps['ros']['ATLIV']))*24*3600*1e-12)
sums['Southern NO3']=(np.sum(transps['har']['ATNO3'])+np.sum(transps['sjc']['ATNO3'])+np.sum(transps['ros']['ATNO3']))*24*3600*1e-12
sums['Southern NH4']=(np.sum(transps['har']['ATNH4'])+np.sum(transps['sjc']['ATNH4'])+np.sum(transps['ros']['ATNH4']))*24*3600*1e-12
sums['Southern DIN']=(np.sum(transps['har']['ATNO3'])+np.sum(transps['sjc']['ATNO3'])+np.sum(transps['ros']['ATNO3'])+\
np.sum(transps['har']['ATNH4'])+np.sum(transps['sjc']['ATNH4'])+np.sum(transps['ros']['ATNH4']))*24*3600*1e-12
sums['Southern PON']=(np.sum(transps['har']['ATPON'])+np.sum(transps['sjc']['ATPON'])+np.sum(transps['ros']['ATPON']))*24*3600*1e-12
sums['Southern DON']=(np.sum(transps['har']['ATDON'])+np.sum(transps['sjc']['ATDON'])+np.sum(transps['ros']['ATDON']))*24*3600*1e-12
sums['Southern Living']=(np.sum(transps['har']['ATLIV'])+np.sum(transps['sjc']['ATLIV'])+np.sum(transps['ros']['ATLIV']))*24*3600*1e-12
Southern NO3: 9.3085175808 Southern NH4: -1.1331983808 Southern DIN: 8.1753186816 Southern PON: -0.2766181104 Southern DON: -2.0263514688 Southern Living: -3.122769024
# Northern Passages:
print('Northern NO3:',(np.sum(transps['dis']['ATNO3'])+np.sum(transps['mal']['ATNO3'])+np.sum(transps['sut']['ATNO3']))*24*3600*1e-12)
print('Northern NH4:',(np.sum(transps['dis']['ATNH4'])+np.sum(transps['mal']['ATNH4'])+np.sum(transps['sut']['ATNH4']))*24*3600*1e-12)
print('Northern DIN:',(np.sum(transps['dis']['ATNO3'])+np.sum(transps['mal']['ATNO3'])+np.sum(transps['sut']['ATNO3'])+\
np.sum(transps['dis']['ATNH4'])+np.sum(transps['mal']['ATNH4'])+np.sum(transps['sut']['ATNH4']))*24*3600*1e-12)
print('Northern PON:',(np.sum(transps['dis']['ATPON'])+np.sum(transps['mal']['ATPON'])+np.sum(transps['sut']['ATPON']))*24*3600*1e-12)
print('Northern DON:',(np.sum(transps['dis']['ATDON'])+np.sum(transps['mal']['ATDON'])+np.sum(transps['sut']['ATDON']))*24*3600*1e-12)
print('Northern Living:',(np.sum(transps['dis']['ATLIV'])+np.sum(transps['mal']['ATLIV'])+np.sum(transps['sut']['ATLIV']))*24*3600*1e-12)
sums['Northern NO3']=(np.sum(transps['dis']['ATNO3'])+np.sum(transps['mal']['ATNO3'])+np.sum(transps['sut']['ATNO3']))*24*3600*1e-12
sums['Northern NH4']=(np.sum(transps['dis']['ATNH4'])+np.sum(transps['mal']['ATNH4'])+np.sum(transps['sut']['ATNH4']))*24*3600*1e-12
sums['Northern DIN']=(np.sum(transps['dis']['ATNO3'])+np.sum(transps['mal']['ATNO3'])+np.sum(transps['sut']['ATNO3'])+\
np.sum(transps['dis']['ATNH4'])+np.sum(transps['mal']['ATNH4'])+np.sum(transps['sut']['ATNH4']))*24*3600*1e-12
sums['Northern PON']=(np.sum(transps['dis']['ATPON'])+np.sum(transps['mal']['ATPON'])+np.sum(transps['sut']['ATPON']))*24*3600*1e-12
sums['Northern DON']=(np.sum(transps['dis']['ATDON'])+np.sum(transps['mal']['ATDON'])+np.sum(transps['sut']['ATDON']))*24*3600*1e-12
sums['Northern Living']=(np.sum(transps['dis']['ATLIV'])+np.sum(transps['mal']['ATLIV'])+np.sum(transps['sut']['ATLIV']))*24*3600*1e-12
Northern NO3: 1.3222417536 Northern NH4: 0.4049241408 Northern DIN: 1.7271658944 Northern PON: 0.1611352872 Northern DON: 0.20055438 Northern Living: 0.45836547839999997
# bio fluxes
print('NO3-based Primary Production: \n',np.sum(prdNO3Sum)*24*3600*1e-12*1.111)
print('NH4-based Primary Production: \n',np.sum(prdNH4Sum)*24*3600*1e-12*1.111)
print('Nitrification:\n',np.sum(nitrSum)*24*3600*1e-12*1.111)
print('PON&DON->NH4:\n',np.sum(remONSum)*24*3600*1e-12*1.111)
print('To Refractory N:\n',np.sum(refrNSum)*24*3600*1e-12*1.111)
sums['NO3-based Primary Production']=np.sum(prdNO3Sum)*24*3600*1e-12*1.111
sums['NH4-based Primary Production']=np.sum(prdNH4Sum)*24*3600*1e-12*1.111
sums['Nitrification']=np.sum(nitrSum)*24*3600*1e-12*1.111
sums['PON&DON->NH4']=np.sum(remONSum)*24*3600*1e-12*1.111
sums['To Refractory N']=np.sum(refrNSum)*24*3600*1e-12*1.111
NO3-based Primary Production: -29.525461366579197 NH4-based Primary Production: -19.950646271846402 Nitrification: 17.9070598029312 PON&DON->NH4: -35.4477772357632 To Refractory N: -0.00014582117033085936
# bottom flux
print('Bottom flux diatoms: \n',np.sum(BFXDIATSum)*24*3600*1e-12*1.111)
print('Bottom flux PON: \n',np.sum(BFXPONSum)*24*3600*1e-12*1.111)
sums['Bottom flux diatoms']=np.sum(BFXDIATSum)*24*3600*1e-12*1.111
sums['Bottom flux PON']=np.sum(BFXPONSum)*24*3600*1e-12*1.111
Bottom flux diatoms: -0.08593979204279813 Bottom flux PON: -6.451666514111936
# RAD
print('rad correction:')
print(' NO3: \n',(np.sum(rdnNO3Sum)+np.sum(rdbNO3Sum))*24*3600*1e-12)
print(' NH4: \n',(np.sum(rdnNH4Sum)+np.sum(rdbNH4Sum))*24*3600*1e-12)
print(' DON: \n',(np.sum(rdnDONSum)+np.sum(rdbDONSum))*24*3600*1e-12)
print(' PON: \n',(np.sum(rdnPONSum)+np.sum(rdbPONSum))*24*3600*1e-12)
print(' Living: \n',(np.sum(rdnLIVSum)+np.sum(rdbLIVSum))*24*3600*1e-12)
rad correction: NO3: 6.4492505859375e-05 NH4: 2.112146026611328e-06 DON: 5.736459814453125e-06 PON: 0.0 Living: 1.463045625e-05
pickle.dump(sums, open( "sums2015.pkl", "wb" ) )
1/1.111111
0.900000090000009
-29.525461366579197-19.950646271846402
-49.4761076384256
-29.54990592-19.9768439808
-49.5267499008
(-49.4761076384256+49.5267499008)/-49.4761076384256*100
-0.10235700581883395
(-49.4761076384256+49.5267499008)/49.5267499008*100
0.10225234338176878
(17.9070598029312-17.9358686208)/17.9070598029312*100
-0.1608796652596439
(-35.4982238208+35.4477772357632)/35.4477772357632*100
-0.14231240706936804
(1.3222417536+9.3085175808-9.3747760128-1.2943034495999999)/(9.3085175808+1.3222417536)*100
-0.3604646365758612
(1.3222417536+9.3085175808-9.3747760128-1.2943034495999999)/(9.3747760128+1.2943034495999999)*100
-0.35916995589963785