def Get_VerticalSection_from_data(self, data, var, product_n):
		import D
		import numpy as np
		import convert
		xgrid, ygrid, zgrid = D.get_grid_value('t', product_n)
		if var == 'u' or var == 'v':
			data = convert.convert_UVgrid_value_to_Sgrid_value_3D(data)

		Ln = self.Pn
		if self.direction == 'EW':
			Data = np.zeros((self.band, Ln, zgrid.size))
			for i in range(0, Ln):
				xn = np.where(xgrid == self.hgrid[i])[0][0]
				for j in range(0, self.band):
					yn = np.where(ygrid == self.latp[i] + j)[0][0]
					Data[j, i, :] = data[yn, xn, :]

		elif self.direction == 'NS':
			Data = np.zeros((Ln, self.band, zgrid.size))
			for j in range(0, Ln):
				yn = np.where(ygrid == self.hgrid[j])[0][0]
				for i in range(0, self.band):
					xn = np.where(xgrid == self.lonp[j] + i)[0][0]
					Data[j, i, :] = data[yn, xn, :]

		else:
			raise ValueError("your direction is not valid!")

		return np.average(Data, axis = self.average_axis), self.hgrid, zgrid
def make_data_of_24sigma_t_depth(year, month, var, product_n = 3):
	_,title_name,_=subroutine.product_n_to_name(product_n)
	sgmt_d = make_24sigma_t_depth(year, month, product_n)
	data = subroutine.get_data(year, month, var, 0, title_name)
	if var == 'u' or var == 'v':
		data = convert.convert_UVgrid_value_to_Sgrid_value_3D(data)

	data_of_sgm_t = make_data_of_24sigma_t_depth_from_data(sgmt_d, data, product_n = product_n)
	return data_of_sgm_t
Example #3
0
	def Get_data_of_area(self, data, var, product_n):
		# 2次元のデータは勿論、3次元のデータもこの関数を使ってtrimmingできます。
		import D
		import numpy as np
		import convert
		xgrid, ygrid, zgrid = D.get_grid_value('t', product_n)
		if var == 'u' or var == 'v':
			if data.ndim == 3:
				data = convert.convert_UVgrid_value_to_Sgrid_value_3D(data)
			elif data.ndim == 2:
				data = convert.convert_UVgrid_value_to_Sgrid_value_2D(data)

		mx = np.where(xgrid == self.wlon)[0][0]
		nx = np.where(xgrid == self.elon)[0][0] + 1
		my = np.where(ygrid == self.slat)[0][0]
		ny = np.where(ygrid == self.nlat)[0][0] + 1
		data = data[my:ny, mx:nx]
		xgrid = xgrid[mx:nx]
		ygrid = ygrid[my:ny]
		return data, xgrid, ygrid
Example #4
0
	def Get_data_of_AreaSection_from_data(self, data, var, product_n):
		# 例えばwlon=10.5, elon=19.5だったとしたら、
		# Data_wは経度10.0度、Data_e=は経度20度に於けるデータを取得することとします。
		import numpy as np
		import D
		import convert
		xgrid, ygrid, zgrid = D.get_grid_value('t', product_n)
		if var == 'u' or var == 'v':
			if data.ndim == 3:
				data = convert.convert_UVgrid_value_to_Sgrid_value_3D(data)
			elif data.ndim == 2:
				data = convert.convert_UVgrid_value_to_Sgrid_value_2D(data)

		mx = np.where(xgrid == self.wlon)[0][0]
		nx = np.where(xgrid == self.elon)[0][0] + 1
		my = np.where(ygrid == self.slat)[0][0]
		ny = np.where(ygrid == self.nlat)[0][0] + 1
		Data_S = 0.5 * (data[my - 1, mx:nx] + data[my, mx:nx])
		Data_N = 0.5 * (data[ny - 1, mx:nx] + data[ny, mx:nx])
		Data_W = 0.5 * (data[my:ny, mx - 1] + data[my:ny, mx])
		Data_E = 0.5 * (data[my:ny, nx - 1] + data[my:ny, nx])
		Data = EACH_SECTION(Data_S, Data_N, Data_W, Data_E)
		return Data