#!/usr/bin/env python # coding: utf-8 # I've noticed in some places that the model bathymetry in Boundary Pass doesn't seem to match with reality. # # See these two notebooks: # * http://nbviewer.ipython.org/urls/bitbucket.org/salishsea/analysis/raw/tip/Nancy/strat/comparisons/ONC%20Moorings.ipynb # * http://nbviewer.ipython.org/urls/bitbucket.org/salishsea/analysis/raw/tip/Nancy/strat/comparisons/Fall%202014%20IOS%20data.ipynb # # Is this a consistent error or is it just a discrepancy with the closest model grid point? I will investigate by looking at the bathymetry near the observations points as well. # In[2]: import sys import pandas as pd sys.path.insert(0, './strat/comparisons/') import ONC import ACTDR import comparisons from salishsea_tools import tidetools import netCDF4 as nc import matplotlib.pyplot as plt import datetime get_ipython().run_line_magic('matplotlib', 'inline') # # Model files # In[3]: grid = nc.Dataset('/data/nsoontie/MEOPAR/NEMO-forcing/grid/bathy_meter_SalishSea2.nc') bathy = grid.variables['Bathymetry'][:] lons = grid.variables['nav_lon'][:] lats = grid.variables['nav_lat'][:] # ## ONC Mooring Point # In[4]: csvfilename = ('/ocean/nsoontie/MEOPAR/ONC/BoundaryPass//' 'BoundaryPass_BoundaryPassMooring_CTD_20140411T175025Z_20150408T235058Z-NaN_clean.csv') # In[5]: data, lat, lon, depth = ONC.load_mooring_csv(csvfilename) print(lat,lon, depth) # In[6]: j,i = tidetools.find_closest_model_point(lon,lat,lons, lats, bathy) print(j,i, bathy[j,i]) # At the closest grid point, the model bathymetry is 30m shallower. What about neighbouring points? # In[7]: stp = 3 print(bathy[j-stp:j+stp,i-stp:i+stp]) # In[8]: plt.pcolormesh(lons, lats,bathy,vmin=205,vmax=234) cbar = plt.colorbar() cbar.set_label('Bahtymetry [m]') plt.plot([lons[j-stp,i-stp], lons[j-stp,i+stp]], [lats[j-stp,i-stp], lats[j-stp,i+stp] ] ,'k') plt.plot([lons[j-stp,i-stp], lons[j+stp,i-stp]], [lats[j-stp,i-stp], lats[j+stp,i-stp] ] ,'k') plt.plot([lons[j+stp,i+stp], lons[j-stp,i+stp]], [lats[j+stp,i+stp], lats[j-stp,i+stp] ],'k') plt.plot([lons[j+stp,i+stp], lons[j+stp,i-stp]], [lats[j+stp,i+stp], lats[j+stp,i-stp] ],'k') plt.axis([-123.2,-123, 48.7,48.8]) plt.plot(lon, lat,'r*') # No where in this neighourhood do we get close to 234m depth. Is the depth record in the ONC file accurate? # # IOS Cast # In[9]: ACTDR.load_dat('strat/comparisons/SOG_2000.dat') data = pd.DataFrame(ACTDR.CTD_DAT) # In[10]: lon_min=-123.49 lon_max=-122 lat_min=48.75 lat_max=48.8 data_BP = comparisons.isolate_region(data,lon_min, lon_max, lat_min, lat_max) data_fall_BP = data_BP[(data_BP.Year>=2014) & (data_BP.Month >=10) ] # In[11]: lon = data_fall_BP.Longitude lat = data_fall_BP.Latitude depths = data_fall_BP.Depth print(lon.values[0], lat.values[0], max(depths.values[0])) # In[12]: j,i = tidetools.find_closest_model_point(lon.values[0],lat.values[0],lons, lats, bathy) print(j,i, bathy[j,i]) # The model is 80m shallower! Neighbouring points # In[13]: stp = 3 print(bathy[j-stp:j+stp,i-stp:i+stp]) # In[14]: plt.pcolormesh(lons, lats,bathy,vmin=131,vmax=211) cbar = plt.colorbar() cbar.set_label('Bahtymetry [m]') plt.plot([lons[j-stp,i-stp], lons[j-stp,i+stp]], [lats[j-stp,i-stp], lats[j-stp,i+stp] ] ,'k') plt.plot([lons[j-stp,i-stp], lons[j+stp,i-stp]], [lats[j-stp,i-stp], lats[j+stp,i-stp] ] ,'k') plt.plot([lons[j+stp,i+stp], lons[j-stp,i+stp]], [lats[j+stp,i+stp], lats[j-stp,i+stp] ],'k') plt.plot([lons[j+stp,i+stp], lons[j+stp,i-stp]], [lats[j+stp,i+stp], lats[j+stp,i-stp] ],'k') plt.axis([-123.1,-123, 48.7,48.8]) plt.plot(lon.values[0], lat.values[0],'r*') # The point at find_closest_model_point is too shallow but there are neighouring points at an appropriate depth. # In[ ]: