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
示例#2
0
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