Some Nitrate-Diatom plots for Deep Bay
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
import glob
from salishsea_tools import nc_tools
import netCDF4 as nc
Jan = sorted(glob.glob('/results/SalishSea/hindcast/*jan16/*1h*ptrc_T*'))
Feb = sorted(glob.glob('/results/SalishSea/hindcast/*feb16/*1h*ptrc_T*'))
Mar = sorted(glob.glob('/results/SalishSea/hindcast/*mar16/*1h*ptrc_T*'))
Apr = sorted(glob.glob('/results/SalishSea/hindcast/*apr16/*1h*ptrc_T*'))
May = sorted(glob.glob('/results/SalishSea/hindcast/*may16/*1h*ptrc_T*'))
Jun = sorted(glob.glob('/results/SalishSea/hindcast/*jun16/*1h*ptrc_T*'))
Jul = sorted(glob.glob('/results/SalishSea/hindcast/*jul16/*1h*ptrc_T*'))
Aug = sorted(glob.glob('/results/SalishSea/hindcast/*aug16/*1h*ptrc_T*'))
Sep = sorted(glob.glob('/results/SalishSea/hindcast/*sep16/*1h*ptrc_T*'))
Oct = sorted(glob.glob('/results/SalishSea/hindcast/*sep16/*1h*ptrc_T*'))
Nov = sorted(glob.glob('/results/SalishSea/hindcast/*nov16/*1h*ptrc_T*'))
Dec = sorted(glob.glob('/results/SalishSea/hindcast/*dec16/*1h*ptrc_T*'))
def make_ND_plot(files,start_time, end_time, depth, lon, lat):
with nc_tools.scDataset(files) as f:
t = f.variables['nitrate'][start_time:end_time, :depth, lon, lat]
s = f.variables['diatoms'][start_time:end_time, :depth, lon, lat]
fig,(ax1,ax2) = plt.subplots(1,2,figsize=(12,12))
ax1.plot(t[0,0],s[0,0],'y*', markersize = 20)
ax1.plot(t[:,0],s[:,0])
ax1.grid('on')
ax1.set_ylabel('Diatoms')
ax1.set_xlabel('Nitrate')
ax1.set_title(' depth= 0')
ax2.plot(t[0,-1],s[0,-1],'y*', markersize = 20)
ax2.plot(t[:,-1],s[:,-1])
ax2.grid('on')
ax2.set_ylabel('Diatoms')
ax2.set_xlabel('Nitrate')
ax2.set_title('depth layer ' + str(depth))
fig.suptitle('Nitrate-Diatom plot at lon=' + str(lon) + ', lat=' + str(lat) + ',from hour=' + str(start_time)
+ ' to hour= ' + str(end_time -1), fontsize = 20)
make_ND_plot(Jan, 0, -1, 6, 599, 125)
make_ND_plot(Feb, 0, -1, 6, 599, 125)
make_ND_plot(Mar, 0, -1, 6, 599, 125)
make_ND_plot(Apr, 0, -1, 6, 599, 125)
make_ND_plot(May, 0, -1, 6, 599, 125)
make_ND_plot(Jun, 0, -1, 6, 599, 125)
make_ND_plot(Jul, 0, -1, 6, 599, 125)
make_ND_plot(Aug, 0, -1, 6, 599, 125)
make_ND_plot(Sep, 0, -1, 6, 599, 125)
make_ND_plot(Oct, 0, -1, 6, 599, 125)
make_ND_plot(Nov, 0, -1, 6, 599, 125)
make_ND_plot(Dec, 0, -1, 6, 599, 125)
lon=599
lat=125
with nc_tools.scDataset(Jun) as f:
t = f.variables['nitrate'][:168, :7, 599, 125]
s = f.variables['diatoms'][:168, :7, 599, 125]
fig,(ax1,ax2) = plt.subplots(1,2,figsize=(12,12))
ax1.plot(t[0,0],s[0,0],'y*', markersize = 20)
ax1.plot(t[:,0],s[:,0])
ax1.grid('on')
ax1.set_ylabel('Diatoms')
ax1.set_xlabel('Nitrate')
ax1.set_title(' depth= 0')
ax2.plot(t[0,-1],s[0,-1],'y*', markersize = 20)
ax2.plot(t[:,-1],s[:,-1])
ax2.grid('on')
ax2.set_ylabel('Diatoms')
ax2.set_xlabel('Nitrate')
ax2.set_title('depth layer 6')
fig.suptitle('Nitrate-Diatom plot at lon=' + str(lon) + ', lat=' + str(lat), fontsize = 20)
plt.savefig('Nitrate-Diatoms-Jun.png', bbox_inches='tight')
168/24
7.0