Notebook to explore Live Ocean results from Parker MacCready and group (http://faculty.washington.edu/pmacc/LO/LiveOcean.html). Goal is to determine a region for extracting boundary conditions.
import netCDF4 as nc
import matplotlib.pyplot as plt
import UBC_subdomain
from salishsea_tools import viz_tools
%matplotlib inline
f = nc.Dataset('/ocean/nsoontie/MEOPAR/LiveOcean/20160608/ocean_his_0025.nc')
f.variables
OrderedDict([('ntimes', <class 'netCDF4._netCDF4.Variable'> int32 ntimes() long_name: number of long time-steps unlimited dimensions: current shape = () filling off), ('ndtfast', <class 'netCDF4._netCDF4.Variable'> int32 ndtfast() long_name: number of short time-steps unlimited dimensions: current shape = () filling off), ('dt', <class 'netCDF4._netCDF4.Variable'> float64 dt() long_name: size of long time-steps units: second unlimited dimensions: current shape = () filling off), ('dtfast', <class 'netCDF4._netCDF4.Variable'> float64 dtfast() long_name: size of short time-steps units: second unlimited dimensions: current shape = () filling off), ('dstart', <class 'netCDF4._netCDF4.Variable'> float64 dstart() long_name: time stamp assigned to model initilization units: days since 1970-01-01 00:00:00 unlimited dimensions: current shape = () filling off), ('nHIS', <class 'netCDF4._netCDF4.Variable'> int32 nHIS() long_name: number of time-steps between history records unlimited dimensions: current shape = () filling off), ('ndefHIS', <class 'netCDF4._netCDF4.Variable'> int32 ndefHIS() long_name: number of time-steps between the creation of history files unlimited dimensions: current shape = () filling off), ('nRST', <class 'netCDF4._netCDF4.Variable'> int32 nRST() long_name: number of time-steps between restart records cycle: only latest two records are maintained unlimited dimensions: current shape = () filling off), ('Falpha', <class 'netCDF4._netCDF4.Variable'> float64 Falpha() long_name: Power-law shape barotropic filter parameter unlimited dimensions: current shape = () filling off), ('Fbeta', <class 'netCDF4._netCDF4.Variable'> float64 Fbeta() long_name: Power-law shape barotropic filter parameter unlimited dimensions: current shape = () filling off), ('Fgamma', <class 'netCDF4._netCDF4.Variable'> float64 Fgamma() long_name: Power-law shape barotropic filter parameter unlimited dimensions: current shape = () filling off), ('nl_tnu2', <class 'netCDF4._netCDF4.Variable'> float64 nl_tnu2(tracer) long_name: nonlinear model Laplacian mixing coefficient for tracers units: meter2 second-1 unlimited dimensions: current shape = (2,) filling off), ('LtracerSponge', <class 'netCDF4._netCDF4.Variable'> int32 LtracerSponge(tracer) long_name: horizontal diffusivity sponge activation switch flag_values: [0 1] flag_meanings: .FALSE. .TRUE. unlimited dimensions: current shape = (2,) filling off), ('Akt_bak', <class 'netCDF4._netCDF4.Variable'> float64 Akt_bak(tracer) long_name: background vertical mixing coefficient for tracers units: meter2 second-1 unlimited dimensions: current shape = (2,) filling off), ('Akv_bak', <class 'netCDF4._netCDF4.Variable'> float64 Akv_bak() long_name: background vertical mixing coefficient for momentum units: meter2 second-1 unlimited dimensions: current shape = () filling off), ('Akk_bak', <class 'netCDF4._netCDF4.Variable'> float64 Akk_bak() long_name: background vertical mixing coefficient for turbulent energy units: meter2 second-1 unlimited dimensions: current shape = () filling off), ('Akp_bak', <class 'netCDF4._netCDF4.Variable'> float64 Akp_bak() long_name: background vertical mixing coefficient for length scale units: meter2 second-1 unlimited dimensions: current shape = () filling off), ('rdrg', <class 'netCDF4._netCDF4.Variable'> float64 rdrg() long_name: linear drag coefficient units: meter second-1 unlimited dimensions: current shape = () filling off), ('rdrg2', <class 'netCDF4._netCDF4.Variable'> float64 rdrg2() long_name: quadratic drag coefficient unlimited dimensions: current shape = () filling off), ('Zob', <class 'netCDF4._netCDF4.Variable'> float64 Zob() long_name: bottom roughness units: meter unlimited dimensions: current shape = () filling off), ('Zos', <class 'netCDF4._netCDF4.Variable'> float64 Zos() long_name: surface roughness units: meter unlimited dimensions: current shape = () filling off), ('gls_p', <class 'netCDF4._netCDF4.Variable'> float64 gls_p() long_name: stability exponent unlimited dimensions: current shape = () filling off), ('gls_m', <class 'netCDF4._netCDF4.Variable'> float64 gls_m() long_name: turbulent kinetic energy exponent unlimited dimensions: current shape = () filling off), ('gls_n', <class 'netCDF4._netCDF4.Variable'> float64 gls_n() long_name: turbulent length scale exponent unlimited dimensions: current shape = () filling off), ('gls_cmu0', <class 'netCDF4._netCDF4.Variable'> float64 gls_cmu0() long_name: stability coefficient unlimited dimensions: current shape = () filling off), ('gls_c1', <class 'netCDF4._netCDF4.Variable'> float64 gls_c1() long_name: shear production coefficient unlimited dimensions: current shape = () filling off), ('gls_c2', <class 'netCDF4._netCDF4.Variable'> float64 gls_c2() long_name: dissipation coefficient unlimited dimensions: current shape = () filling off), ('gls_c3m', <class 'netCDF4._netCDF4.Variable'> float64 gls_c3m() long_name: buoyancy production coefficient (minus) unlimited dimensions: current shape = () filling off), ('gls_c3p', <class 'netCDF4._netCDF4.Variable'> float64 gls_c3p() long_name: buoyancy production coefficient (plus) unlimited dimensions: current shape = () filling off), ('gls_sigk', <class 'netCDF4._netCDF4.Variable'> float64 gls_sigk() long_name: constant Schmidt number for TKE unlimited dimensions: current shape = () filling off), ('gls_sigp', <class 'netCDF4._netCDF4.Variable'> float64 gls_sigp() long_name: constant Schmidt number for PSI unlimited dimensions: current shape = () filling off), ('gls_Kmin', <class 'netCDF4._netCDF4.Variable'> float64 gls_Kmin() long_name: minimum value of specific turbulent kinetic energy unlimited dimensions: current shape = () filling off), ('gls_Pmin', <class 'netCDF4._netCDF4.Variable'> float64 gls_Pmin() long_name: minimum Value of dissipation unlimited dimensions: current shape = () filling off), ('Charnok_alpha', <class 'netCDF4._netCDF4.Variable'> float64 Charnok_alpha() long_name: Charnok factor for surface roughness unlimited dimensions: current shape = () filling off), ('Zos_hsig_alpha', <class 'netCDF4._netCDF4.Variable'> float64 Zos_hsig_alpha() long_name: wave amplitude factor for surface roughness unlimited dimensions: current shape = () filling off), ('sz_alpha', <class 'netCDF4._netCDF4.Variable'> float64 sz_alpha() long_name: surface flux from wave dissipation unlimited dimensions: current shape = () filling off), ('CrgBan_cw', <class 'netCDF4._netCDF4.Variable'> float64 CrgBan_cw() long_name: surface flux due to Craig and Banner wave breaking unlimited dimensions: current shape = () filling off), ('Znudg', <class 'netCDF4._netCDF4.Variable'> float64 Znudg() long_name: free-surface nudging/relaxation inverse time scale units: day-1 unlimited dimensions: current shape = () filling off), ('M2nudg', <class 'netCDF4._netCDF4.Variable'> float64 M2nudg() long_name: 2D momentum nudging/relaxation inverse time scale units: day-1 unlimited dimensions: current shape = () filling off), ('M3nudg', <class 'netCDF4._netCDF4.Variable'> float64 M3nudg() long_name: 3D momentum nudging/relaxation inverse time scale units: day-1 unlimited dimensions: current shape = () filling off), ('Tnudg', <class 'netCDF4._netCDF4.Variable'> float64 Tnudg(tracer) long_name: Tracers nudging/relaxation inverse time scale units: day-1 unlimited dimensions: current shape = (2,) filling off), ('FSobc_in', <class 'netCDF4._netCDF4.Variable'> float64 FSobc_in(boundary) long_name: free-surface inflow, nudging inverse time scale units: second-1 unlimited dimensions: current shape = (4,) filling off), ('FSobc_out', <class 'netCDF4._netCDF4.Variable'> float64 FSobc_out(boundary) long_name: free-surface outflow, nudging inverse time scale units: second-1 unlimited dimensions: current shape = (4,) filling off), ('M2obc_in', <class 'netCDF4._netCDF4.Variable'> float64 M2obc_in(boundary) long_name: 2D momentum inflow, nudging inverse time scale units: second-1 unlimited dimensions: current shape = (4,) filling off), ('M2obc_out', <class 'netCDF4._netCDF4.Variable'> float64 M2obc_out(boundary) long_name: 2D momentum outflow, nudging inverse time scale units: second-1 unlimited dimensions: current shape = (4,) filling off), ('Tobc_in', <class 'netCDF4._netCDF4.Variable'> float64 Tobc_in(boundary, tracer) long_name: tracers inflow, nudging inverse time scale units: second-1 unlimited dimensions: current shape = (4, 2) filling off), ('Tobc_out', <class 'netCDF4._netCDF4.Variable'> float64 Tobc_out(boundary, tracer) long_name: tracers outflow, nudging inverse time scale units: second-1 unlimited dimensions: current shape = (4, 2) filling off), ('M3obc_in', <class 'netCDF4._netCDF4.Variable'> float64 M3obc_in(boundary) long_name: 3D momentum inflow, nudging inverse time scale units: second-1 unlimited dimensions: current shape = (4,) filling off), ('M3obc_out', <class 'netCDF4._netCDF4.Variable'> float64 M3obc_out(boundary) long_name: 3D momentum outflow, nudging inverse time scale units: second-1 unlimited dimensions: current shape = (4,) filling off), ('rho0', <class 'netCDF4._netCDF4.Variable'> float64 rho0() long_name: mean density used in Boussinesq approximation units: kilogram meter-3 unlimited dimensions: current shape = () filling off), ('gamma2', <class 'netCDF4._netCDF4.Variable'> float64 gamma2() long_name: slipperiness parameter unlimited dimensions: current shape = () filling off), ('LuvSrc', <class 'netCDF4._netCDF4.Variable'> int32 LuvSrc() long_name: momentum point sources and sink activation switch flag_values: [0 1] flag_meanings: .FALSE. .TRUE. unlimited dimensions: current shape = () filling off), ('LwSrc', <class 'netCDF4._netCDF4.Variable'> int32 LwSrc() long_name: mass point sources and sink activation switch flag_values: [0 1] flag_meanings: .FALSE. .TRUE. unlimited dimensions: current shape = () filling off), ('LtracerSrc', <class 'netCDF4._netCDF4.Variable'> int32 LtracerSrc(tracer) long_name: tracer point sources and sink activation switch flag_values: [0 1] flag_meanings: .FALSE. .TRUE. unlimited dimensions: current shape = (2,) filling off), ('LsshCLM', <class 'netCDF4._netCDF4.Variable'> int32 LsshCLM() long_name: sea surface height climatology processing switch flag_values: [0 1] flag_meanings: .FALSE. .TRUE. unlimited dimensions: current shape = () filling off), ('Lm2CLM', <class 'netCDF4._netCDF4.Variable'> int32 Lm2CLM() long_name: 2D momentum climatology processing switch flag_values: [0 1] flag_meanings: .FALSE. .TRUE. unlimited dimensions: current shape = () filling off), ('Lm3CLM', <class 'netCDF4._netCDF4.Variable'> int32 Lm3CLM() long_name: 3D momentum climatology processing switch flag_values: [0 1] flag_meanings: .FALSE. .TRUE. unlimited dimensions: current shape = () filling off), ('LtracerCLM', <class 'netCDF4._netCDF4.Variable'> int32 LtracerCLM(tracer) long_name: tracer climatology processing switch flag_values: [0 1] flag_meanings: .FALSE. .TRUE. unlimited dimensions: current shape = (2,) filling off), ('LnudgeM2CLM', <class 'netCDF4._netCDF4.Variable'> int32 LnudgeM2CLM() long_name: 2D momentum climatology nudging activation switch flag_values: [0 1] flag_meanings: .FALSE. .TRUE. unlimited dimensions: current shape = () filling off), ('LnudgeM3CLM', <class 'netCDF4._netCDF4.Variable'> int32 LnudgeM3CLM() long_name: 3D momentum climatology nudging activation switch flag_values: [0 1] flag_meanings: .FALSE. .TRUE. unlimited dimensions: current shape = () filling off), ('LnudgeTCLM', <class 'netCDF4._netCDF4.Variable'> int32 LnudgeTCLM(tracer) long_name: tracer climatology nudging activation switch flag_values: [0 1] flag_meanings: .FALSE. .TRUE. unlimited dimensions: current shape = (2,) filling off), ('spherical', <class 'netCDF4._netCDF4.Variable'> int32 spherical() long_name: grid type logical switch flag_values: [0 1] flag_meanings: Cartesian spherical unlimited dimensions: current shape = () filling off), ('xl', <class 'netCDF4._netCDF4.Variable'> float64 xl() long_name: domain length in the XI-direction units: meter unlimited dimensions: current shape = () filling off), ('el', <class 'netCDF4._netCDF4.Variable'> float64 el() long_name: domain length in the ETA-direction units: meter unlimited dimensions: current shape = () filling off), ('Vtransform', <class 'netCDF4._netCDF4.Variable'> int32 Vtransform() long_name: vertical terrain-following transformation equation unlimited dimensions: current shape = () filling off), ('Vstretching', <class 'netCDF4._netCDF4.Variable'> int32 Vstretching() long_name: vertical terrain-following stretching function unlimited dimensions: current shape = () filling off), ('theta_s', <class 'netCDF4._netCDF4.Variable'> float64 theta_s() long_name: S-coordinate surface control parameter unlimited dimensions: current shape = () filling off), ('theta_b', <class 'netCDF4._netCDF4.Variable'> float64 theta_b() long_name: S-coordinate bottom control parameter unlimited dimensions: current shape = () filling off), ('Tcline', <class 'netCDF4._netCDF4.Variable'> float64 Tcline() long_name: S-coordinate surface/bottom layer width units: meter unlimited dimensions: current shape = () filling off), ('hc', <class 'netCDF4._netCDF4.Variable'> float64 hc() long_name: S-coordinate parameter, critical depth units: meter unlimited dimensions: current shape = () filling off), ('s_rho', <class 'netCDF4._netCDF4.Variable'> float64 s_rho(s_rho) long_name: S-coordinate at RHO-points valid_min: -1.0 valid_max: 0.0 positive: up standard_name: ocean_s_coordinate_g1 formula_terms: s: s_rho C: Cs_r eta: zeta depth: h depth_c: hc field: s_rho, scalar unlimited dimensions: current shape = (40,) filling off), ('s_w', <class 'netCDF4._netCDF4.Variable'> float64 s_w(s_w) long_name: S-coordinate at W-points valid_min: -1.0 valid_max: 0.0 positive: up standard_name: ocean_s_coordinate_g1 formula_terms: s: s_w C: Cs_w eta: zeta depth: h depth_c: hc field: s_w, scalar unlimited dimensions: current shape = (41,) filling off), ('Cs_r', <class 'netCDF4._netCDF4.Variable'> float64 Cs_r(s_rho) long_name: S-coordinate stretching curves at RHO-points valid_min: -1.0 valid_max: 0.0 field: Cs_r, scalar unlimited dimensions: current shape = (40,) filling off), ('Cs_w', <class 'netCDF4._netCDF4.Variable'> float64 Cs_w(s_w) long_name: S-coordinate stretching curves at W-points valid_min: -1.0 valid_max: 0.0 field: Cs_w, scalar unlimited dimensions: current shape = (41,) filling off), ('h', <class 'netCDF4._netCDF4.Variable'> float64 h(eta_rho, xi_rho) long_name: bathymetry at RHO-points units: meter coordinates: lon_rho lat_rho field: bath, scalar unlimited dimensions: current shape = (381, 174) filling off), ('f', <class 'netCDF4._netCDF4.Variable'> float64 f(eta_rho, xi_rho) long_name: Coriolis parameter at RHO-points units: second-1 coordinates: lon_rho lat_rho field: coriolis, scalar unlimited dimensions: current shape = (381, 174) filling off), ('pm', <class 'netCDF4._netCDF4.Variable'> float64 pm(eta_rho, xi_rho) long_name: curvilinear coordinate metric in XI units: meter-1 coordinates: lon_rho lat_rho field: pm, scalar unlimited dimensions: current shape = (381, 174) filling off), ('pn', <class 'netCDF4._netCDF4.Variable'> float64 pn(eta_rho, xi_rho) long_name: curvilinear coordinate metric in ETA units: meter-1 coordinates: lon_rho lat_rho field: pn, scalar unlimited dimensions: current shape = (381, 174) filling off), ('lon_rho', <class 'netCDF4._netCDF4.Variable'> float64 lon_rho(eta_rho, xi_rho) long_name: longitude of RHO-points units: degree_east standard_name: longitude field: lon_rho, scalar unlimited dimensions: current shape = (381, 174) filling off), ('lat_rho', <class 'netCDF4._netCDF4.Variable'> float64 lat_rho(eta_rho, xi_rho) long_name: latitude of RHO-points units: degree_north standard_name: latitude field: lat_rho, scalar unlimited dimensions: current shape = (381, 174) filling off), ('lon_u', <class 'netCDF4._netCDF4.Variable'> float64 lon_u(eta_u, xi_u) long_name: longitude of U-points units: degree_east standard_name: longitude field: lon_u, scalar unlimited dimensions: current shape = (381, 173) filling off), ('lat_u', <class 'netCDF4._netCDF4.Variable'> float64 lat_u(eta_u, xi_u) long_name: latitude of U-points units: degree_north standard_name: latitude field: lat_u, scalar unlimited dimensions: current shape = (381, 173) filling off), ('lon_v', <class 'netCDF4._netCDF4.Variable'> float64 lon_v(eta_v, xi_v) long_name: longitude of V-points units: degree_east standard_name: longitude field: lon_v, scalar unlimited dimensions: current shape = (380, 174) filling off), ('lat_v', <class 'netCDF4._netCDF4.Variable'> float64 lat_v(eta_v, xi_v) long_name: latitude of V-points units: degree_north standard_name: latitude field: lat_v, scalar unlimited dimensions: current shape = (380, 174) filling off), ('lon_psi', <class 'netCDF4._netCDF4.Variable'> float64 lon_psi(eta_psi, xi_psi) long_name: longitude of PSI-points units: degree_east standard_name: longitude field: lon_psi, scalar unlimited dimensions: current shape = (380, 173) filling off), ('lat_psi', <class 'netCDF4._netCDF4.Variable'> float64 lat_psi(eta_psi, xi_psi) long_name: latitude of PSI-points units: degree_north standard_name: latitude field: lat_psi, scalar unlimited dimensions: current shape = (380, 173) filling off), ('mask_rho', <class 'netCDF4._netCDF4.Variable'> float64 mask_rho(eta_rho, xi_rho) long_name: mask on RHO-points flag_values: [ 0. 1.] flag_meanings: land water coordinates: lon_rho lat_rho unlimited dimensions: current shape = (381, 174) filling off), ('mask_u', <class 'netCDF4._netCDF4.Variable'> float64 mask_u(eta_u, xi_u) long_name: mask on U-points flag_values: [ 0. 1.] flag_meanings: land water coordinates: lon_u lat_u unlimited dimensions: current shape = (381, 173) filling off), ('mask_v', <class 'netCDF4._netCDF4.Variable'> float64 mask_v(eta_v, xi_v) long_name: mask on V-points flag_values: [ 0. 1.] flag_meanings: land water coordinates: lon_v lat_v unlimited dimensions: current shape = (380, 174) filling off), ('mask_psi', <class 'netCDF4._netCDF4.Variable'> float64 mask_psi(eta_psi, xi_psi) long_name: mask on psi-points flag_values: [ 0. 1.] flag_meanings: land water coordinates: lon_psi lat_psi unlimited dimensions: current shape = (380, 173) filling off), ('ocean_time', <class 'netCDF4._netCDF4.Variable'> float64 ocean_time(ocean_time) long_name: time since initialization units: seconds since 1970-01-01 00:00:00 calendar: gregorian field: time, scalar, series unlimited dimensions: ocean_time current shape = (1,) filling off), ('zeta', <class 'netCDF4._netCDF4.Variable'> float32 zeta(ocean_time, eta_rho, xi_rho) long_name: free-surface units: meter time: ocean_time coordinates: lon_rho lat_rho ocean_time field: free-surface, scalar, series _FillValue: 1e+37 unlimited dimensions: ocean_time current shape = (1, 381, 174) filling off), ('ubar', <class 'netCDF4._netCDF4.Variable'> float32 ubar(ocean_time, eta_u, xi_u) long_name: vertically integrated u-momentum component units: meter second-1 time: ocean_time coordinates: lon_u lat_u ocean_time field: ubar-velocity, scalar, series _FillValue: 1e+37 unlimited dimensions: ocean_time current shape = (1, 381, 173) filling off), ('vbar', <class 'netCDF4._netCDF4.Variable'> float32 vbar(ocean_time, eta_v, xi_v) long_name: vertically integrated v-momentum component units: meter second-1 time: ocean_time coordinates: lon_v lat_v ocean_time field: vbar-velocity, scalar, series _FillValue: 1e+37 unlimited dimensions: ocean_time current shape = (1, 380, 174) filling off), ('u', <class 'netCDF4._netCDF4.Variable'> float32 u(ocean_time, s_rho, eta_u, xi_u) long_name: u-momentum component units: meter second-1 time: ocean_time coordinates: lon_u lat_u s_rho ocean_time field: u-velocity, scalar, series _FillValue: 1e+37 unlimited dimensions: ocean_time current shape = (1, 40, 381, 173) filling off), ('v', <class 'netCDF4._netCDF4.Variable'> float32 v(ocean_time, s_rho, eta_v, xi_v) long_name: v-momentum component units: meter second-1 time: ocean_time coordinates: lon_v lat_v s_rho ocean_time field: v-velocity, scalar, series _FillValue: 1e+37 unlimited dimensions: ocean_time current shape = (1, 40, 380, 174) filling off), ('w', <class 'netCDF4._netCDF4.Variable'> float32 w(ocean_time, s_w, eta_rho, xi_rho) long_name: vertical momentum component units: meter second-1 time: ocean_time coordinates: lon_rho lat_rho s_w ocean_time field: w-velocity, scalar, series _FillValue: 1e+37 unlimited dimensions: ocean_time current shape = (1, 41, 381, 174) filling off), ('temp', <class 'netCDF4._netCDF4.Variable'> float32 temp(ocean_time, s_rho, eta_rho, xi_rho) long_name: potential temperature units: Celsius time: ocean_time coordinates: lon_rho lat_rho s_rho ocean_time field: temperature, scalar, series _FillValue: 1e+37 unlimited dimensions: ocean_time current shape = (1, 40, 381, 174) filling off), ('salt', <class 'netCDF4._netCDF4.Variable'> float32 salt(ocean_time, s_rho, eta_rho, xi_rho) long_name: salinity time: ocean_time coordinates: lon_rho lat_rho s_rho ocean_time field: salinity, scalar, series _FillValue: 1e+37 unlimited dimensions: ocean_time current shape = (1, 40, 381, 174) filling off), ('rho', <class 'netCDF4._netCDF4.Variable'> float32 rho(ocean_time, s_rho, eta_rho, xi_rho) long_name: density anomaly units: kilogram meter-3 time: ocean_time coordinates: lon_rho lat_rho s_rho ocean_time field: density, scalar, series _FillValue: 1e+37 unlimited dimensions: ocean_time current shape = (1, 40, 381, 174) filling off), ('AKv', <class 'netCDF4._netCDF4.Variable'> float32 AKv(ocean_time, s_w, eta_rho, xi_rho) long_name: vertical viscosity coefficient units: meter2 second-1 time: ocean_time coordinates: lon_rho lat_rho s_w ocean_time field: AKv, scalar, series unlimited dimensions: ocean_time current shape = (1, 41, 381, 174) filling off), ('AKs', <class 'netCDF4._netCDF4.Variable'> float32 AKs(ocean_time, s_w, eta_rho, xi_rho) long_name: salinity vertical diffusion coefficient units: meter2 second-1 time: ocean_time coordinates: lon_rho lat_rho s_w ocean_time field: AKs, scalar, series unlimited dimensions: ocean_time current shape = (1, 41, 381, 174) filling off), ('Uwind', <class 'netCDF4._netCDF4.Variable'> float32 Uwind(ocean_time, eta_rho, xi_rho) long_name: surface u-wind component units: meter second-1 time: ocean_time coordinates: lon_rho lat_rho ocean_time field: u-wind, scalar, series _FillValue: 1e+37 unlimited dimensions: ocean_time current shape = (1, 381, 174) filling off), ('Vwind', <class 'netCDF4._netCDF4.Variable'> float32 Vwind(ocean_time, eta_rho, xi_rho) long_name: surface v-wind component units: meter second-1 time: ocean_time coordinates: lon_rho lat_rho ocean_time field: v-wind, scalar, series _FillValue: 1e+37 unlimited dimensions: ocean_time current shape = (1, 381, 174) filling off), ('shflux', <class 'netCDF4._netCDF4.Variable'> float32 shflux(ocean_time, eta_rho, xi_rho) long_name: surface net heat flux units: watt meter-2 negative_value: upward flux, cooling positive_value: downward flux, heating time: ocean_time coordinates: lon_rho lat_rho ocean_time field: surface heat flux, scalar, series _FillValue: 1e+37 unlimited dimensions: ocean_time current shape = (1, 381, 174) filling off), ('latent', <class 'netCDF4._netCDF4.Variable'> float32 latent(ocean_time, eta_rho, xi_rho) long_name: net latent heat flux units: watt meter-2 negative_value: upward flux, cooling positive_value: downward flux, heating time: ocean_time coordinates: lon_rho lat_rho ocean_time field: latent heat flux, scalar, series _FillValue: 1e+37 unlimited dimensions: ocean_time current shape = (1, 381, 174) filling off), ('sensible', <class 'netCDF4._netCDF4.Variable'> float32 sensible(ocean_time, eta_rho, xi_rho) long_name: net sensible heat flux units: watt meter-2 negative_value: upward flux, cooling positive_value: downward flux, heating time: ocean_time coordinates: lon_rho lat_rho ocean_time field: sensible heat flux, scalar, series _FillValue: 1e+37 unlimited dimensions: ocean_time current shape = (1, 381, 174) filling off), ('lwrad', <class 'netCDF4._netCDF4.Variable'> float32 lwrad(ocean_time, eta_rho, xi_rho) long_name: net longwave radiation flux units: watt meter-2 negative_value: upward flux, cooling positive_value: downward flux, heating time: ocean_time coordinates: lon_rho lat_rho ocean_time field: longwave radiation, scalar, series _FillValue: 1e+37 unlimited dimensions: ocean_time current shape = (1, 381, 174) filling off), ('swrad', <class 'netCDF4._netCDF4.Variable'> float32 swrad(ocean_time, eta_rho, xi_rho) long_name: solar shortwave radiation flux units: watt meter-2 negative_value: upward flux, cooling positive_value: downward flux, heating time: ocean_time coordinates: lon_rho lat_rho ocean_time field: shortwave radiation, scalar, series _FillValue: 1e+37 unlimited dimensions: ocean_time current shape = (1, 381, 174) filling off), ('sustr', <class 'netCDF4._netCDF4.Variable'> float32 sustr(ocean_time, eta_u, xi_u) long_name: surface u-momentum stress units: newton meter-2 time: ocean_time coordinates: lon_u lat_u ocean_time field: surface u-momentum stress, scalar, series _FillValue: 1e+37 unlimited dimensions: ocean_time current shape = (1, 381, 173) filling off), ('svstr', <class 'netCDF4._netCDF4.Variable'> float32 svstr(ocean_time, eta_v, xi_v) long_name: surface v-momentum stress units: newton meter-2 time: ocean_time coordinates: lon_v lat_v ocean_time field: surface v-momentum stress, scalar, series _FillValue: 1e+37 unlimited dimensions: ocean_time current shape = (1, 380, 174) filling off), ('bustr', <class 'netCDF4._netCDF4.Variable'> float32 bustr(ocean_time, eta_u, xi_u) long_name: bottom u-momentum stress units: newton meter-2 time: ocean_time coordinates: lon_u lat_u ocean_time field: bottom u-momentum stress, scalar, series _FillValue: 1e+37 unlimited dimensions: ocean_time current shape = (1, 381, 173) filling off), ('bvstr', <class 'netCDF4._netCDF4.Variable'> float32 bvstr(ocean_time, eta_v, xi_v) long_name: bottom v-momentum stress units: newton meter-2 time: ocean_time coordinates: lon_v lat_v ocean_time field: bottom v-momentum stress, scalar, series _FillValue: 1e+37 unlimited dimensions: ocean_time current shape = (1, 380, 174) filling off)])
Lots of output! I am interested in:
Anything else?
dt = f.variables['dt']
ntimes = f.variables['ntimes']
ntimes[:]*dt[:]/86400
3.0
It appears as if this file was part of a three day simulation.
ocean_time = f.variables['ocean_time']
ocean_time[:]
array([ 1.46543040e+09])
ocean_time
<class 'netCDF4._netCDF4.Variable'> float64 ocean_time(ocean_time) long_name: time since initialization units: seconds since 1970-01-01 00:00:00 calendar: gregorian field: time, scalar, series unlimited dimensions: ocean_time current shape = (1,) filling off
time = nc.num2date(ocean_time[:], ocean_time.units)
time
array([datetime.datetime(2016, 6, 9, 0, 0)], dtype=object)
It is fairly easy to grab the snap shot time using ocean_time and the nc.num2date method.
sal = f.variables['salt']
lon_rho = f.variables['lon_rho']
lat_rho = f.variables['lat_rho']
s_rho = f.variables['s_rho']
sal
<class 'netCDF4._netCDF4.Variable'> float32 salt(ocean_time, s_rho, eta_rho, xi_rho) long_name: salinity time: ocean_time coordinates: lon_rho lat_rho s_rho ocean_time field: salinity, scalar, series _FillValue: 1e+37 unlimited dimensions: ocean_time current shape = (1, 40, 381, 174) filling off
b = nc.Dataset('/data/nsoontie/MEOPAR/NEMO-forcing/grid/bathy_meter_SalishSea2.nc')
X = b.variables['nav_lon']
Y = b.variables['nav_lat']
fig,ax=plt.subplots(1,1)
mesh=ax.pcolormesh(lon_rho, lat_rho, sal[0,0,:,:])
cbar=plt.colorbar(mesh,ax=ax)
cbar.set_label('salinity')
viz_tools.plot_coastline(ax,b,coords='map')
iss = 55
iee = 80
jss = 295
jee = 325
ax.plot([lon_rho[jss,iss], lon_rho[jss,iee]],
[lat_rho[jss,iss], lat_rho[jss,iee]], '-k')
ax.plot([lon_rho[jss,iss], lon_rho[jee,iss]],
[lat_rho[jss,iss], lat_rho[jee,iss]], '-k')
ax.plot([lon_rho[jee,iss], lon_rho[jee,iee]],
[lat_rho[jee,iss], lat_rho[jee,iee]], '-k')
ax.plot([lon_rho[jee,iee], lon_rho[jss,iee]],
[lat_rho[jee,iee], lat_rho[jss,iee]], '-k')
[<matplotlib.lines.Line2D at 0x7fbbce8a5470>]
fig,ax=plt.subplots(1,1)
mesh=ax.pcolormesh(lon_rho[jss:jee,iss:iee],
lat_rho[jss:jee,iss:iee],
sal[0,0,jss:jee,iss:iee])
cbar=plt.colorbar(mesh,ax=ax)
cbar.set_label('salinity')
viz_tools.plot_coastline(ax,b,coords='map')
ax.set_xlim([-125.1,-124.4])
ax.set_ylim([48.3,48.9])
ax.plot(X[:,10], Y[:,10],'g-')
[<matplotlib.lines.Line2D at 0x7fbbce3f1f28>]
lon_u = f.variables['lon_u']
lat_u = f.variables['lat_u']
lon_v = f.variables['lon_v']
lat_v = f.variables['lat_v']
print('Bottom left')
print('U', lon_u[0,0], lat_u[0,0])
print('V', lon_v[0,0], lat_v[0,0])
print('sal', lon_rho[0,0], lat_rho[0,0])
Bottom left U -127.370613735 43.0 V -127.4 43.0134983458 sal -127.4 43.0
print('Top left')
print('U', lon_u[-1,0], lat_u[-1,0])
print('V', lon_v[-1,0], lat_v[-1,0])
print('sal', lon_rho[-1,0], lat_rho[-1,0])
Top left U -127.370613735 50.0224161638 V -127.4 50.0089467306 sal -127.4 50.0224161638
print('Bottom right')
print('U', lon_u[0,-1], lat_u[0,-1])
print('V', lon_v[0,-1], lat_v[0,-1])
print('sal', lon_rho[0,-1], lat_rho[0,-1])
Bottom right U -121.986028612 43.0 V -121.966436234 43.0134983458 sal -121.966436234 43.0
print('Top right')
print('U', lon_u[-1,-1], lat_u[-1,-1])
print('V', lon_v[-1,-1], lat_v[-1,-1])
print('sal', lon_rho[-1,-1], lat_rho[-1,-1])
Top right U -121.986028612 50.0224161638 V -121.966436234 50.0089467306 sal -121.966436234 50.0224161638
h = f.variables['h']
h
<class 'netCDF4._netCDF4.Variable'> float64 h(eta_rho, xi_rho) long_name: bathymetry at RHO-points units: meter coordinates: lon_rho lat_rho field: bath, scalar unlimited dimensions: current shape = (381, 174) filling off
fig,ax=plt.subplots(1,1)
mesh=ax.pcolormesh(lon_rho, lat_rho, h,vmin=0,vmax=300)
cbar=plt.colorbar(mesh,ax=ax)
cbar.set_label('bathy [m]')
viz_tools.plot_coastline(ax,b,coords='map')
ax.plot([lon_rho[jss,iss], lon_rho[jss,iee]],
[lat_rho[jss,iss], lat_rho[jss,iee]], '-w')
ax.plot([lon_rho[jss,iss], lon_rho[jee,iss]],
[lat_rho[jss,iss], lat_rho[jee,iss]], '-w')
ax.plot([lon_rho[jee,iss], lon_rho[jee,iee]],
[lat_rho[jee,iss], lat_rho[jee,iee]], '-w')
ax.plot([lon_rho[jee,iee], lon_rho[jss,iee]],
[lat_rho[jee,iee], lat_rho[jss,iee]], '-w')
[<matplotlib.lines.Line2D at 0x7fbbce2fca58>]
fig,ax=plt.subplots(1,1)
mesh=ax.pcolormesh(lon_rho[jss:jee,iss:iee],
lat_rho[jss:jee,iss:iee],
h[jss:jee,iss:iee])
cbar=plt.colorbar(mesh,ax=ax)
cbar.set_label('bathy [m]')
viz_tools.plot_coastline(ax,b,coords='map')
ax.set_xlim([-125.1,-124.4])
ax.set_ylim([48.3,48.9])
ax.plot(X[:,10], Y[:,10],'g-')
[<matplotlib.lines.Line2D at 0x7fbbce299e10>]
This region looks reasonable. I need to go in the mouth a little bit because our BCs cover the first 10 grid points.
f2 = nc.Dataset('/ocean/nsoontie/MEOPAR/LiveOcean/20160608/ocean_his_0002_UBC.nc')
f2.variables
OrderedDict([('salt', <class 'netCDF4._netCDF4.Variable'> float32 salt(ocean_time, s_rho, eta_rho, xi_rho) _FillValue: 1e+37 long_name: salinity coordinates: lon_rho lat_rho s_rho ocean_time time: ocean_time field: salinity, scalar, series unlimited dimensions: ocean_time current shape = (1, 40, 31, 26) filling on), ('temp', <class 'netCDF4._netCDF4.Variable'> float32 temp(ocean_time, s_rho, eta_rho, xi_rho) _FillValue: 1e+37 long_name: potential temperature coordinates: lon_rho lat_rho s_rho ocean_time time: ocean_time units: Celsius field: temperature, scalar, series unlimited dimensions: ocean_time current shape = (1, 40, 31, 26) filling on), ('h', <class 'netCDF4._netCDF4.Variable'> float64 h(eta_rho, xi_rho) long_name: bathymetry at RHO-points coordinates: lon_rho lat_rho field: bath, scalar units: meter unlimited dimensions: current shape = (31, 26) filling on, default _FillValue of 9.969209968386869e+36 used), ('lon_rho', <class 'netCDF4._netCDF4.Variable'> float64 lon_rho(eta_rho, xi_rho) standard_name: longitude long_name: longitude of RHO-points field: lon_rho, scalar units: degree_east unlimited dimensions: current shape = (31, 26) filling on, default _FillValue of 9.969209968386869e+36 used), ('lat_rho', <class 'netCDF4._netCDF4.Variable'> float64 lat_rho(eta_rho, xi_rho) standard_name: latitude long_name: latitude of RHO-points field: lat_rho, scalar units: degree_north unlimited dimensions: current shape = (31, 26) filling on, default _FillValue of 9.969209968386869e+36 used), ('mask_rho', <class 'netCDF4._netCDF4.Variable'> float64 mask_rho(eta_rho, xi_rho) flag_values: [ 0. 1.] long_name: mask on RHO-points coordinates: lon_rho lat_rho flag_meanings: land water unlimited dimensions: current shape = (31, 26) filling on, default _FillValue of 9.969209968386869e+36 used), ('pn', <class 'netCDF4._netCDF4.Variable'> float64 pn(eta_rho, xi_rho) long_name: curvilinear coordinate metric in ETA coordinates: lon_rho lat_rho field: pn, scalar units: meter-1 unlimited dimensions: current shape = (31, 26) filling on, default _FillValue of 9.969209968386869e+36 used), ('pm', <class 'netCDF4._netCDF4.Variable'> float64 pm(eta_rho, xi_rho) long_name: curvilinear coordinate metric in XI coordinates: lon_rho lat_rho field: pm, scalar units: meter-1 unlimited dimensions: current shape = (31, 26) filling on, default _FillValue of 9.969209968386869e+36 used), ('s_rho', <class 'netCDF4._netCDF4.Variable'> float64 s_rho(s_rho) long_name: S-coordinate at RHO-points positive: up valid_min: -1.0 standard_name: ocean_s_coordinate_g1 field: s_rho, scalar valid_max: 0.0 formula_terms: s: s_rho C: Cs_r eta: zeta depth: h depth_c: hc unlimited dimensions: current shape = (40,) filling on, default _FillValue of 9.969209968386869e+36 used), ('hc', <class 'netCDF4._netCDF4.Variable'> float64 hc() long_name: S-coordinate parameter, critical depth units: meter unlimited dimensions: current shape = () filling on, default _FillValue of 9.969209968386869e+36 used), ('Cs_r', <class 'netCDF4._netCDF4.Variable'> float64 Cs_r(s_rho) long_name: S-coordinate stretching curves at RHO-points field: Cs_r, scalar valid_max: 0.0 valid_min: -1.0 unlimited dimensions: current shape = (40,) filling on, default _FillValue of 9.969209968386869e+36 used), ('Vtransform', <class 'netCDF4._netCDF4.Variable'> int32 Vtransform() long_name: vertical terrain-following transformation equation unlimited dimensions: current shape = () filling on, default _FillValue of -2147483647 used), ('zeta', <class 'netCDF4._netCDF4.Variable'> float32 zeta(ocean_time, eta_rho, xi_rho) _FillValue: 1e+37 long_name: free-surface coordinates: lon_rho lat_rho ocean_time time: ocean_time units: meter field: free-surface, scalar, series unlimited dimensions: ocean_time current shape = (1, 31, 26) filling on), ('ocean_time', <class 'netCDF4._netCDF4.Variable'> float64 ocean_time(ocean_time) long_name: time since initialization calendar: gregorian field: time, scalar, series units: seconds since 1970-01-01 00:00:00 unlimited dimensions: ocean_time current shape = (1,) filling on, default _FillValue of 9.969209968386869e+36 used), ('lon_u', <class 'netCDF4._netCDF4.Variable'> float64 lon_u(eta_u, xi_u) standard_name: longitude long_name: longitude of U-points field: lon_u, scalar units: degree_east unlimited dimensions: current shape = (31, 25) filling on, default _FillValue of 9.969209968386869e+36 used), ('lat_u', <class 'netCDF4._netCDF4.Variable'> float64 lat_u(eta_u, xi_u) standard_name: latitude long_name: latitude of U-points field: lat_u, scalar units: degree_north unlimited dimensions: current shape = (31, 25) filling on, default _FillValue of 9.969209968386869e+36 used), ('mask_u', <class 'netCDF4._netCDF4.Variable'> float64 mask_u(eta_u, xi_u) flag_values: [ 0. 1.] long_name: mask on U-points coordinates: lon_u lat_u flag_meanings: land water unlimited dimensions: current shape = (31, 25) filling on, default _FillValue of 9.969209968386869e+36 used), ('u', <class 'netCDF4._netCDF4.Variable'> float32 u(ocean_time, s_rho, eta_u, xi_u) _FillValue: 1e+37 long_name: u-momentum component coordinates: lon_u lat_u s_rho ocean_time time: ocean_time units: meter second-1 field: u-velocity, scalar, series unlimited dimensions: ocean_time current shape = (1, 40, 31, 25) filling on), ('lon_v', <class 'netCDF4._netCDF4.Variable'> float64 lon_v(eta_v, xi_v) standard_name: longitude long_name: longitude of V-points field: lon_v, scalar units: degree_east unlimited dimensions: current shape = (30, 26) filling on, default _FillValue of 9.969209968386869e+36 used), ('lat_v', <class 'netCDF4._netCDF4.Variable'> float64 lat_v(eta_v, xi_v) standard_name: latitude long_name: latitude of V-points field: lat_v, scalar units: degree_north unlimited dimensions: current shape = (30, 26) filling on, default _FillValue of 9.969209968386869e+36 used), ('mask_v', <class 'netCDF4._netCDF4.Variable'> float64 mask_v(eta_v, xi_v) flag_values: [ 0. 1.] long_name: mask on V-points coordinates: lon_v lat_v flag_meanings: land water unlimited dimensions: current shape = (30, 26) filling on, default _FillValue of 9.969209968386869e+36 used), ('v', <class 'netCDF4._netCDF4.Variable'> float32 v(ocean_time, s_rho, eta_v, xi_v) _FillValue: 1e+37 long_name: v-momentum component coordinates: lon_v lat_v s_rho ocean_time time: ocean_time units: meter second-1 field: v-velocity, scalar, series unlimited dimensions: ocean_time current shape = (1, 40, 30, 26) filling on)])
ocean_time2 = f2.variables['ocean_time']
time2 = nc.num2date(ocean_time2[:], ocean_time2.units)
time2
array([datetime.datetime(2016, 6, 8, 1, 0)], dtype=object)
sal2 = f2.variables['salt']
lon_rho2 = f2.variables['lon_rho']
lat_rho2 = f2.variables['lat_rho']
s_rho2 = f2.variables['s_rho']
sal2
<class 'netCDF4._netCDF4.Variable'> float32 salt(ocean_time, s_rho, eta_rho, xi_rho) _FillValue: 1e+37 long_name: salinity coordinates: lon_rho lat_rho s_rho ocean_time time: ocean_time field: salinity, scalar, series unlimited dimensions: ocean_time current shape = (1, 40, 31, 26) filling on
sal
<class 'netCDF4._netCDF4.Variable'> float32 salt(ocean_time, s_rho, eta_rho, xi_rho) long_name: salinity time: ocean_time coordinates: lon_rho lat_rho s_rho ocean_time field: salinity, scalar, series _FillValue: 1e+37 unlimited dimensions: ocean_time current shape = (1, 40, 381, 174) filling off
fig,ax=plt.subplots(1,1)
mesh=ax.pcolormesh(lon_rho2, lat_rho2, sal2[0,0,:,:])
cbar=plt.colorbar(mesh,ax=ax)
cbar.set_label('salinity')
viz_tools.plot_coastline(ax,b,coords='map')
ax.set_xlim([-125,-124.4])
ax.set_ylim([48.3,48.9])
ax.plot(X[:,10], Y[:,10],'g-')
[<matplotlib.lines.Line2D at 0x7fbbce15fc88>]
f.close()
UBC_subdomain.get_UBC_subdomain(['/ocean/nsoontie/MEOPAR/LiveOcean/20160608/ocean_his_0025.nc'])