def cal_GeostrophicCurrent_from_SSH(ssh, product_n = 3): ns_dist = subroutine.dist_on_sphere([0.0, - 0.5], [0.0, 0.5]) xgrid, ygrid, zgrid = D.get_grid_value('ht', product_n) yn = ygrid.size xn = xgrid.size Ug = np.zeros((yn, xn)) Vg = np.zeros((yn, xn)) xgrid_new = np.zeros(xn) ygrid_new = np.zeros(yn) for j in range(0, yn): if j == yn - 1: ygrid_new[j] = 0.5 * (ygrid[j] + ygrid[j] + 1) Ug[j, :] = np.nan Vg[j, :] = np.nan else: y0 = j y1 = j + 1 ygrid_new[j] = 0.5 * (ygrid[y0] + ygrid[y1]) if abs(ygrid_new[j]) <= 2.0: # 赤道付近においては地衡流は計算しない Ug[j, :] = np.nan Vg[j, :] = np.nan else: ew_dist = subroutine.dist_on_sphere([0.0, ygrid_new[j]], [1.0, ygrid_new[j]]) f = subroutine.f0(ygrid_new[j]) for i in range(0, xn): x0 = i if i == xn - 1: x1 = 0 lon = 0.5 * (xgrid[i] + xgrid[i] + 1.0) else: x1 = i + 1 lon = 0.5 * (xgrid[x0] + xgrid[x1]) if j == 1: xgrid_new[i] = lon ssh00 = ssh[y0, x0] ssh01 = ssh[y1, x0] ssh10 = ssh[y0, x1] ssh11 = ssh[y1, x1] a = Using_jit.average_of_2data(ssh01, ssh11) b = Using_jit.average_of_2data(ssh00, ssh10) c = Using_jit.average_of_2data(ssh10, ssh11) d = Using_jit.average_of_2data(ssh00, ssh01) Ug[j, i] = -g / f * (a - b) / ns_dist Vg[j, i] = g / f * (c - d) / ew_dist return Ug, Vg, xgrid_new, ygrid_new
def cal_EkmanCurrent_from_tau(taux, tauy, ygrid, nu): zgrid = - np.arange(N) - 0.5 xn = taux.shape[1] yn = taux.shape[0] zn = zgrid.size Ue = np.zeros((yn, xn, zn)) Ve = np.zeros((yn, xn, zn)) Ue_new = np.zeros((yn, xn, M)) Ve_new = np.zeros((yn, xn, M)) for j in range(0, yn): if abs(ygrid[j]) <= 2.0: Ue[j, :, :] = np.nan Ve[j, :, :] = np.nan else: f = subroutine.f0(ygrid[j]) r = np.sqrt(np.abs(f) / (2.0 * nu)) for i in range(0, xn): if ygrid[j] > 0.0: T = ( - taux[j, i] + tauy[j, i]) / (taux[j, i] + tauy[j, i]) Au = (taux[j, i] + tauy[j, i]) / (np.sqrt(2.0) * r * nu * rho0) Av = Au else: T = ( - taux[j, i] - tauy[j, i]) / (taux[j, i] - tauy[j, i]) Au = (taux[j, i] - tauy[j, i]) / (np.sqrt(2.0) * r * nu * rho0) Av = -Au Ue[j, i, :] = Au * np.exp( r * zgrid[:]) * (np.cos(r * zgrid[:]) - T * np.sin(r * zgrid[:])) Ve[j, i, :] = Av * np.exp( r * zgrid[:]) * (np.sin(r * zgrid[:]) + T * np.cos(r * zgrid[:])) for m in range(0, M): Ue_new[:, :, m] = np.average(Ue[:, :, L*m:L*(m + 1)], axis = 2) Ve_new[:, :, m] = np.average(Ve[:, :, L*m:L*(m + 1)], axis = 2) return Ue_new, Ve_new