<jupyter_start><jupyter_text>Dipping toes into Brink code (again)<jupyter_code>import numpy as np
import netCDF4 as nc
import os
import scipy.io as sio
from scipy import interpolate
import matplotlib
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import cmocean as cmo
from salishsea_tools.nc_tools import scDataset
import sys
from matplotlib import colors
sys.path.append('/ocean/imachuca/Canyons/analysis_mackenzie_canyon/notebooks/general_circulation/')
import general_functions
sys.path.append('/ocean/imachuca/Canyons/analysis_mackenzie_canyon/notebooks/upwelling_depth/')
import upwelling_functions
%matplotlib inline
from IPython.display import Image
import warnings
warnings.filterwarnings("ignore")

# From Idalia's email

# dispersion curve
output = np.loadtxt('/ocean/imachuca/CTW_Brink/output/dispc_J.dat')
disp_k = output[:, 0] #rad/cm
disp_f = output[:, 1] #rad/sec

# Brink mode
file = sio.loadmat('/ocean/imachuca/CTW_Brink/output/figures_J1.mat')
z, xpl, xxx, zzz = file['z'][0,:], file['xpl'][0,:], file['xxx'][0,:], file['zzz'][0,:]
k, f = file['wavenumber'][0][0], file['frequency'][0][0]
# (u is cross-shore and v is alongshore in Brink. so, I'm flipping them back right here)
p0, v0, u0, w0, r0 = file['p_profile'], file['u_profile'], file['v_profile'], file['w_profile'], file['r_profile']
R = file['ratio_for_wave'][0][0]


print('ratio', R)


w = w0 * 0.01 * scale # cms-1 to ms-1 and normalization
u = u0 * 0.01 * scale # cms-1 to ms-1 and normalization 
v = v0 * 0.01 * scale # cms-1 to ms-1 and normalization 
r = r0 * 1.0 * scale # mg/cm³ to kg/m³ and normalization
p = p0 * 0.1 * scale # dyn/cm² to 0.1 Pa (or kg m-1 s-2) and normalization


ax.plot(disp_k, disp_f, c='k', lw=3, zorder=1)
ax.scatter(k, f, s=350, c='forestgreen', zorder=2, marker='o')


p3 = ax3.contourf(xpl, z, w, levels=levels, cmap=cmap, vmin=-1*vm, vmax=vm, zorder=1)
ax3.contour(xpl, z, w, levels=[0], linewidths=3, linestyles='-', colors='k', zorder=2)
ax3.fill_between(xxx, zzz.min(), zzz, facecolor=landc, zorder=3)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15414444983034417, 'fraction_numerical': 0.030538051381483276, 'mean_word_length': 5.470219435736677, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '219326', 'license': 'Apache-2.0', 'n_tokens_mistral': 853, 'n_tokens_neox': 823, 'n_words': 206, 'path': 'forPaper2/shelfWaves/01_dippingToes.ipynb', 'repo_name': 'UBC-MOAD/outputanalysisnotebooks', 'size': '2063'}