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_curl(year, month, product_n = 3): taux = D.get_data(year, month, 'taux', 1, product_n) tauy = D.get_data(year, month, 'tauy', 1, product_n) xgrid, ygrid, zgrid = D.get_grid_value('taux', product_n) xn = xgrid.size yn = ygrid.size curl = np.zeros([yn, xn]) ns_dist = subroutine.dist_on_sphere([0.0, - 0.5], [0.0, 0.5]) for j in range(0, yn): if j == yn - 1: curl[j, :] = np.nan else: y0 = j y1 = j + 1 lat0 = ygrid[y0] lat1 = ygrid[y1] tmpdist = np.average(np.array([lat0, lat1])) ew_dist = subroutine.dist_on_sphere([0.0, tmpdist], [1.0, tmpdist]) for i in range(0, xn): x0 = i lon0 = xgrid[x0] if i == xn - 1: x1 = 0 lon1 = xgrid[x1] else: x1 = i + 1 lon1 = xgrid[x1] taux00 = taux[y0, x0] tauy00 = tauy[y0, x0] taux01 = taux[y1, x0] tauy01 = tauy[y1, x0] taux10 = taux[y0, x1] tauy10 = tauy[y0, x1] taux11 = taux[y1, x1] tauy11 = tauy[y1, x1] a = Using_jit.average_of_2data(tauy10, tauy11) b = Using_jit.average_of_2data(tauy00, tauy01) c = Using_jit.average_of_2data(taux01, taux11) d = Using_jit.average_of_2data(taux00, taux10) if np.isnan(a - b) == False and np.isnan(c - d) == False: curl[j, i] = (a - b) / ew_dist - (c - d) / ns_dist elif np.isnan(a - b) == False: curl[j, i] = (a - b) / ew_dist elif np.isnan(c - d) == False: curl[j, i] = - (c - d) / ns_dist else: curl[j, i] = np.nan return curl
def convert_Sgrid_value_to_UVgrid_value_2D(S): # TSなど、◯.5度を基準に与えられている物理量を、UVなどと同じように、◯.0度を基準に変換してやる。 # 2次元のデータ専用 yn = S.shape[0] xn = S.shape[1] S_dash = np.zeros((yn, xn)) for j in range(yn): if j == yn - 1: S_dash[j, :] = np.nan else: for i in range(xn): if i != xn - 1: S00 = S[j, i] S01 = S[j + 1, i] S10 = S[j, i + 1] S11 = S[j + 1, i + 1] else: S00 = S[j, i] S01 = S[j + 1, i] S10 = S[j, 0] S11 = S[j + 1, 0] S_dash[j, i] = Using_jit.average_of_4data(S00, S01, S10, S11) return S_dash
def convert_Sgrid_value_to_UVgrid_value_3D(S): # TSなど、◯.5度を基準に与えられている物理量を、UVなどと同じように、◯.0度を基準に変換してやる。 yn = S.shape[0] xn = S.shape[1] zn = S.shape[2] S_dash = np.zeros((yn, xn, zn)) for j in range(yn): if j == yn - 1: S_dash[j, :, :] = np.nan else: for i in range(xn): if i != xn - 1: S00 = S[j, i, :] S01 = S[j + 1, i, :] S10 = S[j, i + 1, :] S11 = S[j + 1, i + 1, :] else: S00 = S[j, i, :] S01 = S[j + 1, i, :] S10 = S[j, 0, :] S11 = S[j + 1, 0, :] for k in range(0, zn): S_dash[j, i, k] = Using_jit.average_of_4data(S00[k], S01[k], S10[k], S11[k]) return S_dash
def convert_UVgrid_value_to_Sgrid_value_2D(U): # UVなど、~.0度を基準に与えられている物理量を、UVなどと同じように、~.5度を基準に変換してやる。 yn = U.shape[0] xn = U.shape[1] U_dash = np.zeros((yn, xn)) for j in range(yn): if j == yn - 1: U_dash[j, :] = np.nan else: for i in range(xn): if i != 0: U00 = U[j - 1, i - 1] U01 = U[j, i - 1] U10 = U[j - 1, i] U11 = U[j, i] else: U00 = U[j - 1, xn - 1] U01 = U[j, xn - 1] U10 = U[j - 1, i] U11 = U[j, i] U_dash[j, i] = Using_jit.average_of_4data(U00, U01, U10, U11) return U_dash
def cal_Salinity_Transport_Budget(self, year, month, depth = 10, product_n = 3): # その領域における塩分輸送量収支を計算する。 # 注意! x,y,z軸方向のグリッドの大きさはすべて等しいと仮定して計算しております。 # さらに、領域は南北に長くなく、EWdistで南北両側面の断面積を計算していいこととしております。 import D import D2 import Using_jit import numpy as np import Budget_at_Global_Ocean rho0 = 1024.0 dS = Budget_at_Global_Ocean.cal_dSdt(year, month, product_n)[:, :, :depth] sff = D.get_data(year, month, 'sff', 1, product_n) s = D.get_data(year, month, 's', 0, product_n)[:, :, :depth] u = D.get_data(year, month, 'u', 0, product_n)[:, :, :depth] v = D.get_data(year, month, 'v', 0, product_n)[:, :, :depth] ssh = D2.D2Data[33].load_data_of_npz(year, month, product_n) ssh_Sec = self.Get_data_of_AreaSection_from_data(ssh, 'ht', product_n) ssh_Area, _, _ = self.Get_data_of_area(ssh, 'ht', product_n) s_bottom = s[:, :, depth - 1] s_surface = s[:, :, 0] w = D.get_data(year, month, 'w', depth, product_n) _, _, zgrid = D.get_grid_value('w', product_n) ZonTsp = Using_jit.cal_Salt_Transport(s, u, 0, product_n) MerTsp = Using_jit.cal_Salt_Transport(s, v, 1, product_n) ZonTsp = self.Get_data_of_AreaSection_from_data(ZonTsp, 's', product_n) MerTsp = self.Get_data_of_AreaSection_from_data(MerTsp, 's', product_n) # 海面力学高度の分だけ、各断面の高さに下駄を履かせてやる West = np.sum(ZonTsp.West) * (zgrid[depth - 1] + np.average(ssh_Sec.West)) / zgrid[depth - 1] East = np.sum(ZonTsp.East) * (zgrid[depth - 1] + np.average(ssh_Sec.East)) / zgrid[depth - 1] North = np.sum(MerTsp.North) * (zgrid[depth - 1] + np.average(ssh_Sec.North)) / zgrid[depth - 1] South = np.sum(MerTsp.South) * (zgrid[depth - 1] + np.average(ssh_Sec.South)) / zgrid[depth - 1] w, _, _ = self.Get_data_of_area(w, 'w', product_n) s_bottom, _, _ = self.Get_data_of_area(s_bottom, 's', product_n) Bottom = self.Square * np.average(1e-3 * rho0 * w * s_bottom) sff, _, _ = self.Get_data_of_area(sff, 'sff', product_n) s_surface, _, _ = self.Get_data_of_area(s_surface, 's', product_n) Surface = self.Square * np.average(1e-3 * rho0 * sff * s_surface) / (60 * 60 * 24 * 30.0) # 海面力学高度の分だけ、水柱の高さに下駄を履かせてやる dS, _, _ = self.Get_data_of_area(dS, 's', product_n) Change = 1e-3 * rho0 * np.average(dS) * (zgrid[depth - 1] + np.average(ssh_Area)) * self.Square / (60 * 60 * 24 * 30.0) return South, North, West, East, Bottom, Surface, Change
def make_LD_Averaged_Data(data, LD, product_n): n_LD = (LD / 10.0).astype(np.int64) n_LD[np.where(n_LD <= 0.0)] = 0 Data = Using_jit.cal_XXDepth_Averaged_data(data, n_LD) return Data