#!/usr/bin/env python # coding: utf-8 # In[1]: import numpy as np import netCDF4 as nc import matplotlib.pyplot as plt from salishsea_tools import viz_tools, places,geo_tools get_ipython().run_line_magic('matplotlib', 'inline') # In[3]: mesh=nc.Dataset('/data/eolson/results/MEOPAR/NEMO-forcing-new/grid/mesh_mask201702.nc') # In[4]: bathy=nc.Dataset('/data/eolson/results/MEOPAR/NEMO-forcing-new/grid/bathymetry_201702.nc') # In[6]: mesh.variables.keys() # In[7]: bathy.variables.keys() # In[16]: latQU39=50.0307 lonQU39=-125.0992 # In[17]: fig,ax=plt.subplots(1,1,figsize=(8,5)) ax.pcolormesh(bathy['nav_lon'],bathy['nav_lat'],bathy['Bathymetry']) ax.set_xlim(-125.5,-124) ax.set_ylim(49.5,50.3) ax.plot(lonQU39,latQU39,'r*') viz_tools.set_aspect(ax,coords='map') # In[14]: places.PLACES # In[21]: # NEMO grid j,i=geo_tools.find_closest_model_point(lonQU39,latQU39,mesh.variables['nav_lon'][:,:],mesh.variables['nav_lat'][:,:]) print(j,i) # In[22]: # ops grid ops=nc.Dataset('/results/forcing/atmospheric/GEM2.5/operational/ops_y2015m08d16.nc') ops.variables.keys() # In[30]: jo,io=geo_tools.find_closest_model_point(lonQU39,latQU39,ops.variables['nav_lon'][:,:]-360,ops.variables['nav_lat'][:,:],grid='GEM2.5',) print(jo,io) # In[ ]: