import numpy as np
import numpy.ma as ma
import netCDF4 as nc
import matplotlib.pyplot as plt
from salishsea_tools import viz_tools
import matplotlib.patches as patches
%matplotlib inline
coarse = nc.Dataset('/home/mdunphy/MEOPAR/SalishSea/WorkingAGRIF/multi-26jun15/SalishSea_1h_20150626_20150630_grid_T_20150629-20150629.nc')
HS1 = nc.Dataset('/home/mdunphy/MEOPAR/SalishSea/WorkingAGRIF/multi-26jun15/1_SalishSea_1h_20150626_20150630_grid_T.nc')
BS2 = nc.Dataset('/home/mdunphy/MEOPAR/SalishSea/WorkingAGRIF/multi-26jun15/2_SalishSea_1h_20150626_20150630_grid_T_20150629-20150629.nc')
mesh_mask = nc.Dataset('/home/mdunphy/MEOPAR/SalishSea/WorkingAGRIF/multi-26jun15/mesh_mask.nc')
HS1mask = nc.Dataset('/home/mdunphy/MEOPAR/SalishSea/WorkingAGRIF/multi-26jun15/1_mesh_mask.nc')
BS2mask = nc.Dataset('/home/mdunphy/MEOPAR/SalishSea/WorkingAGRIF/multi-26jun15/2_mesh_mask.nc')
fig,(ax1,ax2) = plt.subplots(1,2, figsize=(16,12))
mesh1 = ax1.pcolormesh(mesh_mask.variables['glamt'][0,:,:],
mesh_mask.variables['gphit'][0,:,:],
np.ma.masked_array(coarse.variables['vosaline'][-1,0,:,:], 1-mesh_mask.variables['tmask'][0,0,:,:])
, vmin=3, vmax=30)
x1, y1 = [-123.2, -122.2], [48.08, 48.46]
x2, y2 = [-122.2, -122.8], [48.46,49.19]
x3,y3 = [-122.8,-123.8], [49.19,48.79]
x4, y4 = [-123.8,-123.2], [48.79,48.08]
ax1.plot(x1,y1,'r-',x2,y2,'r-',x3,y3,'r-', x4, y4, 'r-')
ax2.pcolormesh(mesh_mask.variables['glamt'][0,:,:],
mesh_mask.variables['gphit'][0,:,:],
np.ma.masked_array(coarse.variables['vosaline'][-1,0,:,:], 1-mesh_mask.variables['tmask'][0,0,:,:]),
vmin=3, vmax=30)
mesh2=ax2.pcolormesh(HS1mask.variables['glamt'][0,:,:],
HS1mask.variables['gphit'][0,:,:],
np.ma.masked_array(HS1.variables['vosaline'][-1,0,:,:], 1-HS1mask.variables['tmask'][0,0,:,:]),
vmin=3, vmax=30)
ax2.plot(x1,y1,'r-',x2,y2,'r-',x3,y3,'r-', x4, y4, 'r-')
ax1.set_ylim((48,49.5))
ax2.set_ylim((48,49.5))
ax1.set_xlim((-124, -122))
ax2.set_xlim((-124,-122))
ax1.set_title('Coarse Grid', fontsize=16)
ax1.tick_params(labelsize=12)
ticks = np.arange(-124, -122, 0.5)
ax1.xaxis.set_ticks(ticks)
ax2.xaxis.set_ticks(ticks)
ax2.tick_params(labelsize=12)
ax1.set_xlabel('Longitude', fontsize=14)
ax2.set_xlabel('Longitude', fontsize=14)
ax1.set_ylabel('Latitude', fontsize=14)
ax2.set_ylabel('Latitude', fontsize=14)
fig.colorbar(mesh1,ax=ax1, label='Salinity (g/kg)')
ax2.set_title('Fine Grid', fontsize=16)
fig.colorbar(mesh2,ax=ax2, label='Salinity (g/kg)')
#viz_tools.set_aspect(ax1)
#viz_tools.set_aspect(ax2)
plt.savefig('SalinityHS.png', bbox_inches='tight')
fig,(ax1,ax2) = plt.subplots(1,2, figsize=(16,12))
mesh1 = ax1.pcolormesh(mesh_mask.variables['glamt'][0,:,:],
mesh_mask.variables['gphit'][0,:,:],
np.ma.masked_array(coarse.variables['votemper'][-1,0,:,:], 1-mesh_mask.variables['tmask'][0,0,:,:]),
vmin=10,vmax=26, cmap='jet')
x1, y1 = [-123.2, -122.2], [48.08, 48.46]
x2, y2 = [-122.2, -122.8], [48.46,49.19]
x3,y3 = [-122.8,-123.8], [49.19,48.79]
x4, y4 = [-123.8,-123.2], [48.79,48.08]
ax1.plot(x1,y1,'r-',x2,y2,'r-',x3,y3,'r-', x4, y4, 'r-')
ax2.pcolormesh(mesh_mask.variables['glamt'][0,:,:],
mesh_mask.variables['gphit'][0,:,:],
np.ma.masked_array(coarse.variables['votemper'][-1,0,:,:], 1-mesh_mask.variables['tmask'][0,0,:,:]),
vmin=10,vmax=26, cmap='jet')
mesh2 = ax2.pcolormesh(HS1mask.variables['glamt'][0,:,:],
HS1mask.variables['gphit'][0,:,:],
np.ma.masked_array(HS1.variables['votemper'][-1,0,:,:], 1-HS1mask.variables['tmask'][0,0,:,:]),
vmin=10,vmax=26, cmap='jet')
ax2.plot(x1,y1,'r-',x2,y2,'r-',x3,y3,'r-', x4, y4, 'r-')
ax1.set_ylim((48,49.5))
ax2.set_ylim((48,49.5))
ax1.set_xlim((-124, -122))
ax2.set_xlim((-124,-122))
ax1.set_title('Coarse Grid', fontsize=16)
ax1.tick_params(labelsize=12)
ticks = np.arange(-124, -122, 0.5)
ax1.xaxis.set_ticks(ticks)
ax2.xaxis.set_ticks(ticks)
ax2.tick_params(labelsize=12)
ax1.set_xlabel('Longitude', fontsize=14)
ax2.set_xlabel('Longitude', fontsize=14)
ax1.set_ylabel('Latitude', fontsize=14)
ax2.set_ylabel('Latitude', fontsize=14)
fig.colorbar(mesh1,ax=ax1, label='Temperature (C)')
ax2.set_title('Fine Grid', fontsize=16)
fig.colorbar(mesh2,ax=ax2, label='Temperature (C)')
plt.savefig('TemperatureHS.png', bbox_inches='tight')
fig,(ax1,ax2) = plt.subplots(1,2 , figsize=(16,12)
)
mesh1=ax1.pcolormesh(mesh_mask.variables['glamt'][0,:,:],
mesh_mask.variables['gphit'][0,:,:],
np.ma.masked_array(coarse.variables['vosaline'][-1,0,:,:], 1-mesh_mask.variables['tmask'][0,0,:,:]),
vmin = 23, vmax=27)
x1, y1 = [-124.7, -124.45], [49.28, 49.38]
x2, y2 = [-124.45, -124.9], [49.38,49.88]
x3,y3 = [-124.9,-125.1], [49.88,49.79]
x4, y4 = [-125.1,-124.7], [49.79,49.28]
ax1.plot(x1,y1,'r-'
,x2,y2,'r-'
,x3,y3,'r-', x4, y4, 'r-'
)
ax2.pcolormesh(mesh_mask.variables['glamt'][0,:,:],
mesh_mask.variables['gphit'][0,:,:],
np.ma.masked_array(coarse.variables['vosaline'][-1,0,:,:], 1-mesh_mask.variables['tmask'][0,0,:,:]),
vmin = 23, vmax=27)
mesh2=ax2.pcolormesh(BS2mask.variables['glamt'][0,:,:],
BS2mask.variables['gphit'][0,:,:],
np.ma.masked_array(BS2.variables['vosaline'][-1,0,:,:], 1-BS2mask.variables['tmask'][0,0,:,:]),
vmin = 23, vmax=27)
ax2.plot(x1,y1,'r-',x2,y2,'r-',x3,y3,'r-', x4, y4, 'r-')
ax1.set_ylim((49.3,49.9))
ax2.set_ylim((49.3,49.9))
ax1.set_xlim((-125.1, -124.4))
ax2.set_xlim((-125.1,-124.4))
ax1.set_title('Coarse Grid', fontsize=16)
ax1.tick_params(labelsize=12)
ticks = np.arange(-125.1, -124.4, 0.2)
ax1.xaxis.set_ticks(ticks)
ax2.xaxis.set_ticks(ticks)
ax2.tick_params(labelsize=12)
ax1.set_xlabel('Longitude', fontsize=14)
ax2.set_xlabel('Longitude', fontsize=14)
ax1.set_ylabel('Latitude', fontsize=14)
ax2.set_ylabel('Latitude', fontsize=14)
fig.colorbar(mesh1,ax=ax1, label='Salinity (g/kg)')
ax2.set_title('Fine Grid', fontsize=16)
fig.colorbar(mesh2,ax=ax2, label='Salinity (g/kg)')
plt.savefig('SalinityBS.png', bbox_inches='tight')
fig,(ax1,ax2) = plt.subplots(1,2, figsize=(16,12))
ax1.pcolormesh(mesh_mask.variables['glamt'][0,:,:],
mesh_mask.variables['gphit'][0,:,:],
np.ma.masked_array(coarse.variables['votemper'][-1,0,:,:], 1-mesh_mask.variables['tmask'][0,0,:,:]),
vmin = 16, vmax=20
)
x1, y1 = [-124.7, -124.4], [49.28, 49.38]
x2, y2 = [-124.4, -124.9], [49.38,49.88]
x3,y3 = [-124.9,-125.1], [49.88,49.79]
x4, y4 = [-125.1,-124.7], [49.79,49.28]
ax1.plot(x1,y1,'r-'
,x2,y2,'r-'
,x3,y3,'r-', x4, y4, 'r-'
)
ax2.pcolormesh(mesh_mask.variables['glamt'][0,:,:],
mesh_mask.variables['gphit'][0,:,:],
np.ma.masked_array(coarse.variables['votemper'][-1,0,:,:], 1-mesh_mask.variables['tmask'][0,0,:,:]),
vmin = 16, vmax=20
)
ax2.pcolormesh(BS2mask.variables['glamt'][0,:,:],
BS2mask.variables['gphit'][0,:,:],
np.ma.masked_array(BS2.variables['votemper'][-1,0,:,:], 1-BS2mask.variables['tmask'][0,0,:,:]),
vmin = 16, vmax=20
)
ax2.plot(x1,y1,'r-',x2,y2,'r-',x3,y3,'r-', x4, y4, 'r-')
ax1.set_ylim((49.3,49.9))
ax2.set_ylim((49.3,49.9))
ax1.set_xlim((-125.1, -124.4))
ax2.set_xlim((-125.1,-124.4))
ax1.set_title('Coarse Grid')
ax2.set_title('Fine Grid')
viz_tools.set_aspect(ax1)
viz_tools.set_aspect(ax2)
#plt.savefig('TemperatureBS.png', bbox_inches='tight')
np.max(BS2mask.variables['glamt'][0,...])
-124.44407
np.max(BS2mask.variables['gphit'][0,...])
49.882534
fig,(ax1,ax2) = plt.subplots(1,2, figsize=(16,12))
mesh1 = ax1.pcolormesh(mesh_mask.variables['glamt'][0,:,:],
mesh_mask.variables['gphit'][0,:,:],
np.ma.masked_array(coarse.variables['votemper'][-1,0,:,:], 1-mesh_mask.variables['tmask'][0,0,:,:]),
vmin = 17, vmax=20, cmap='jet'
)
x1, y1 = [-124.7, -124.45], [49.28, 49.38]
x2, y2 = [-124.45, -124.9], [49.38,49.8825]
x3,y3 = [-124.9,-125.1], [49.8825,49.79]
x4, y4 = [-125.1,-124.7], [49.79,49.28]
ax1.plot(x1,y1,'b-'
,x2,y2,'b-'
,x3,y3,'b-', x4, y4, 'b-'
)
ax2.pcolormesh(mesh_mask.variables['glamt'][0,:,:],
mesh_mask.variables['gphit'][0,:,:],
np.ma.masked_array(coarse.variables['votemper'][-1,0,:,:], 1-mesh_mask.variables['tmask'][0,0,:,:]),
vmin = 17, vmax=20, cmap='jet'
)
mesh2 = ax2.pcolormesh(BS2mask.variables['glamt'][0,:,:],
BS2mask.variables['gphit'][0,:,:],
np.ma.masked_array(BS2.variables['votemper'][-1,0,:,:], 1-BS2mask.variables['tmask'][0,0,:,:]),
vmin = 17, vmax=20, cmap='jet'
)
ax2.plot(x1,y1,'b-',x2,y2,'b-',x3,y3,'b-', x4, y4, 'b-')
ax1.set_ylim((49.3,49.9))
ax2.set_ylim((49.3,49.9))
ax1.set_xlim((-125.1, -124.4))
ax2.set_xlim((-125.1,-124.4))
ax1.set_title('Coarse Grid', fontsize=16)
ax1.tick_params(labelsize=12)
ticks = np.arange(-125.1, -124.4, 0.2)
ax1.xaxis.set_ticks(ticks)
ax2.xaxis.set_ticks(ticks)
ax2.tick_params(labelsize=12)
ax1.set_xlabel('Longitude', fontsize=14)
ax2.set_xlabel('Longitude', fontsize=14)
ax1.set_ylabel('Latitude', fontsize=14)
ax2.set_ylabel('Latitude', fontsize=14)
fig.colorbar(mesh1,ax=ax1, label='Temperature (C)')
ax2.set_title('Fine Grid', fontsize=16)
fig.colorbar(mesh2,ax=ax2, label='Temperature (C)')
plt.savefig('TemperatureBS.png', bbox_inches='tight')