Test LiveOcean BC's for new tidally average single time files
import matplotlib.pyplot as plt
import netCDF4 as nc
import os
from salishsea_tools.LiveOcean_BCs import create_LiveOcean_TS_BCs
%matplotlib inline
# choose a date
ymd = '2018-06-20'
date = ymd.replace("-", "")
# make yourself a test directory
bc_dir = '/home/sallen/MEOPAR/test_dir/'
os.mkdir(bc_dir)
ourdatas = create_LiveOcean_TS_BCs(ymd, bc_dir=bc_dir)
ourdata = nc.Dataset(ourdatas)
print(ourdata)
<class 'netCDF4._netCDF4.Dataset'> root group (NETCDF4 data model, file format HDF5): acknowledgements: Live Ocean http://faculty.washington.edu/pmacc/LO/LiveOcean.html creator_email: sallen@eoas.ubc.ca creator_name: SalishSeaCast Project Contributors creator_url: https://salishsea-meopar-docs.readthedocs.org/ institution: UBC EOAS institution_fullname: Earth, Ocean & Atmospheric Sciences, University of British Columbia summary: Temperature, Salinity, Nitrate, Oxygen, DIC and TALKfrom the Live Ocean model interpolated in space onto the SalishSeaCast NEMO model western open boundary. Silicon from Nitrate. source: http://nbviewer.org/urls/bitbucket.org/salishsea/.../LiveOceanNew history: [2018-07-14] File creation. dimensions(sizes): t(0), i(0), m(0), e(0), _(0), c(0), o(0), u(0), n(0), r(0), time_counter(1), deptht(40), yb(1), xbT(950) variables(dimensions): int64 time_counter(time_counter), float64 deptht(deptht), int64 yb(yb), int64 xbT(xbT), float64 vosaline(time_counter,deptht,yb,xbT), float64 votemper(time_counter,deptht,yb,xbT), float64 NO3(time_counter,deptht,yb,xbT), float64 Si(time_counter,deptht,yb,xbT), float64 OXY(time_counter,deptht,yb,xbT), float64 DIC(time_counter,deptht,yb,xbT), float64 TA(time_counter,deptht,yb,xbT) groups:
print(ourdata.variables['time_counter'])
print(ourdata.variables['time_counter'][:])
<class 'netCDF4._netCDF4.Variable'> int64 time_counter(time_counter) units: minutes since 1970-01-01 calendar: proleptic_gregorian unlimited dimensions: time_counter current shape = (1,) filling on, default _FillValue of -9223372036854775806 used [25491600]
fig, ax = plt.subplots(1, 2, figsize=(10, 5))
ax[0].pcolormesh(ourdata.variables['vosaline'][0, :, 0, :], cmap='plasma', vmax=34, vmin=31.5)
ds = ourdata.variables['vosaline'][0, 1:, :, :] - ourdata.variables['vosaline'][0, :-1, :, :]
ax[1].pcolormesh(ds[:, 0], cmap='bwr', vmax=0.01, vmin=-0.01)
<matplotlib.collections.QuadMesh at 0x7f422f31d2b0>
livedata = nc.Dataset(os.path.join('/results/forcing/LiveOcean/downloaded',date,'low_passed_UBC.nc'))
print(livedata)
<class 'netCDF4._netCDF4.Dataset'> root group (NETCDF4 data model, file format HDF5): file: /pmr1/parker/LiveOcean_roms/output/cascadia1_base_lobio5/f2018.06.19/ocean_his_0002.nc format: netCDF-3 64bit offset file Conventions: CF-1.4, SGRID-0.3 type: ROMS/TOMS history file title: First LiveOcean input file var_info: /pmr1/parker/LiveOcean_roms/LO_ROMS/ROMS/External/varinfo.dat rst_file: /pmr1/parker/LiveOcean_roms/output/cascadia1_base_lobio5/f2018.06.19/ocean_rst.nc his_base: /pmr1/parker/LiveOcean_roms/output/cascadia1_base_lobio5/f2018.06.19/ocean_his grd_file: /fjdata1/parker/LiveOcean_data/grids/cascadia1/grid.nc ini_file: /pmr1/parker/LiveOcean_roms/output/cascadia1_base_lobio5/f2018.06.18/ocean_his_0025.nc frc_file_01: /fjdata1/parker/LiveOcean_output/cascadia1_base/f2018.06.19/tide/tides.nc frc_file_02: /fjdata1/parker/LiveOcean_output/cascadia1_base/f2018.06.19/atm/lwrad_down.nc frc_file_03: /fjdata1/parker/LiveOcean_output/cascadia1_base/f2018.06.19/atm/Pair.nc frc_file_04: /fjdata1/parker/LiveOcean_output/cascadia1_base/f2018.06.19/atm/Qair.nc frc_file_05: /fjdata1/parker/LiveOcean_output/cascadia1_base/f2018.06.19/atm/rain.nc frc_file_06: /fjdata1/parker/LiveOcean_output/cascadia1_base/f2018.06.19/atm/swrad.nc frc_file_07: /fjdata1/parker/LiveOcean_output/cascadia1_base/f2018.06.19/atm/Tair.nc frc_file_08: /fjdata1/parker/LiveOcean_output/cascadia1_base/f2018.06.19/atm/Uwind.nc frc_file_09: /fjdata1/parker/LiveOcean_output/cascadia1_base/f2018.06.19/atm/Vwind.nc bry_file: /fjdata1/parker/LiveOcean_output/cascadia1_base/f2018.06.19/ocn1/ocean_bry_bio.nc clm_file: /fjdata1/parker/LiveOcean_output/cascadia1_base/f2018.06.19/ocn1/ocean_clm_bio.nc nud_file: /fjdata1/parker/LiveOcean_data/grids/cascadia1/nudgcoef.nc script_file: bpar_file: /pmr1/parker/LiveOcean_roms/output/cascadia1_base_lobio5/f2018.06.19/npzd2o_Banas.in NLM_LBC: EDGE: WEST SOUTH EAST NORTH zeta: Cha Cha Clo Clo ubar: Fla Fla Clo Clo vbar: Fla Fla Clo Clo u: RadNud RadNud Clo Clo v: RadNud RadNud Clo Clo temp: RadNud RadNud Clo Clo salt: RadNud RadNud Clo Clo NO3: RadNud RadNud Clo Clo phytoplankton: RadNud RadNud Clo Clo zooplankton: RadNud RadNud Clo Clo detritus: RadNud RadNud Clo Clo Ldetritus: RadNud RadNud Clo Clo oxygen: RadNud RadNud Clo Clo TIC: RadNud RadNud Clo Clo alkalinity: RadNud RadNud Clo Clo CaCO3: Gra Gra Clo Clo tke: RadNud RadNud Clo Clo svn_url: https://www.myroms.org/svn/src/trunk svn_rev: code_dir: /pmr1/parker/LiveOcean_roms/LO_ROMS header_dir: /pmr1/parker/LiveOcean_roms/makefiles/lobio5 header_file: lobio5.h os: Linux cpu: x86_64 compiler_system: ifort compiler_command: /cm/shared/local/openmpi-ifort/bin/mpif90 compiler_flags: -heap-arrays -fp-model precise -ip -O3 -free -free -free tiling: 008x018 history: ROMS/TOMS, Version 3.7, Tuesday - June 19, 2018 - 4:00:36 AM ana_file: ROMS/Functionals/ana_btflux.h, ROMS/Functionals/ana_stflux.h bio_file: ROMS/Nonlinear/Biology/npzd2o_banas.h CPP_options: LOBIO5, ADD_FSOBC, ADD_M2OBC, ANA_BPFLUX, ANA_BSFLUX, ANA_BTFLUX, ANA_SPFLUX, ANA_SSFLUX, ASSUMED_SHAPE, BULK_FLUXES, CANUTO_A DJ_GRADPS, DOUBLE_PRECISION, GLS_MIXING, LONGWAVE_OUT, MASKING, MIX_GEO_TS, MPI, NONLINEAR, NONLIN_EOS, N2S2_HORAVG, POWER_LAW, PROFILE, K_GSCHEME, RADIATION_2D, RI_SPLINES, !RST_SINGLE, SALINITY, SOLAR_SOURCE, SOLVE3D, SPHERICAL, SSH_TIDES, TS_MPDATA, TS_DIF2, UV_ADV, UV_COR, UV_U3HADVECTION, UV_C4VADVECTION, UV_QDRAG, UV_TIDES, VAR_RHO_2D dimensions(sizes): xi_rho(26), eta_rho(31), N(40), s_rho(40), ocean_time(1), xi_u(25), eta_u(31), xi_v(26), eta_v(30) variables(dimensions): float32 salt(ocean_time,s_rho,eta_rho,xi_rho), float32 temp(ocean_time,s_rho,eta_rho,xi_rho), float64 h(eta_rho,xi_rho), float64 lon_rho(eta_rho,xi_rho), float64 lat_rho(eta_rho,xi_rho), float64 mask_rho(eta_rho,xi_rho), float64 pn(eta_rho,xi_rho), float64 pm(eta_rho,xi_rho), float64 s_rho(s_rho), float64 hc(), float64 Cs_r(s_rho), int32 Vtransform(), float32 zeta(ocean_time,eta_rho,xi_rho), float64 ocean_time(ocean_time), float64 lon_u(eta_,xi_), float64 lat_u(eta_,xi_), float64 mask_u(eta_,xi_), float32 u(ocean_time,s_rho,eta_,xi_), float64 lon_v(eta_v,xi_v), float64 lat_v(eta_v,xi_v), float64 mask_v(eta_v,xi_v), float32 v(ocean_time,s_rho,eta_v,xi_v), float32 NO3(ocean_time,s_rho,eta_rho,xi_rho), float32 phytoplankton(ocean_time,s_rho,eta_rho,xi_rho), float32 zooplankton(ocean_time,s_rho,eta_rho,xi_rho), float32 detritus(ocean_time,s_rho,eta_rho,xi_rho), float32 Ldetritus(ocean_time,s_rho,eta_rho,xi_rho), float32 oxygen(ocean_time,s_rho,eta_rho,xi_rho), float32 TIC(ocean_time,s_rho,eta_rho,xi_rho), float32 alkalinity(ocean_time,s_rho,eta_rho,xi_rho), float32 CaCO3(ocean_time,s_rho,eta_rho,xi_rho), float32 rho(ocean_time,s_rho,eta_rho,xi_rho) groups:
fig, axs = plt.subplots(1, 3, figsize=(16, 4))
for ix, var in enumerate(['DIC', 'TA', 'OXY']):
mesh = axs[ix].pcolormesh(ourdata[var][0, :, 0])
fig.colorbar(mesh, ax=axs[ix])
axs[ix].invert_yaxis()
axs[ix].set_title(var)
fig, axs = plt.subplots(1, 3, figsize=(16, 4))
for ix, var in enumerate(['votemper', 'NO3', 'Si']):
mesh = axs[ix].pcolormesh(ourdata[var][0, :, 0])
fig.colorbar(mesh, ax=axs[ix])
axs[ix].invert_yaxis()
axs[ix].set_title(var)
fig, ax = plt.subplots(1, 1)
ax.plot(ourdata.variables['vosaline'][0, :, 0] * 35 / 35.16504, ourdata.variables['TA'][0, :, 0], 'ok');
Don't forget to remove your test files and directory