def load_climatology_or_interannual_variation_as_npz(fy, ly, month, var, Ave_or_Std, product_n = 3):
	vid = Var.var_to_id(var)
	formal_name = Var.VAR[vid].Get_formal_name()
	title_name = D.Data[product_n].title_name
	_, strmonth = subroutine.strym(2000, month)
	data =subroutine.load_npz(Ave_or_Std + '_of_' + \
							  formal_name + '_m' + strmonth + '_' + str(fy) + '-' + str(ly) + \
							  '_' + title_name)
	return data
Пример #2
0
	def save_data_as_npz(self, Timeseries, fy, ly, var, depth = 1, product_n = 3):
		import D
		import Var
		import subroutine
		vid = Var.var_to_id(var)
		formal_name = Var.VAR[vid].Get_formal_name()
		title_name = D.Data[product_n].title_name
		xgrid, ygrid, zgrid = D.get_grid_value(var, product_n)
		subroutine.save_npz(Timeseries, self.AreaName + '_Area-Averaged-' + \
							formal_name + '_at_' + str(zgrid[depth - 1]) + \
							'm_Year' + str(fy) + '-' + str(ly) + '_' + title_name)
Пример #3
0
	def load_data_of_npz(self, fy, ly, var, depth = 1, product_n = 3):
		import D
		import Var
		import subroutine
		vid = Var.var_to_id(var)
		formal_name = Var.VAR[vid].Get_formal_name()
		title_name = D.Data[product_n].title_name
		xgrid, ygrid, zgrid = D.get_grid_value(var, product_n)
		Timeseries = subroutine.load_npz(self.AreaName + '_Area-Averaged-' + \
										 formal_name + '_at_' + str(zgrid[depth - 1]) + \
										 'm_Year' + str(fy) + '-' + str(ly) + '_' + title_name)
		months, label = subroutine.get_months_and_label(fy, ly)
		return Timeseries, months, label
Пример #4
0
	def save_Area_Trimmed_variable_as_npz(self, year, month, var, product_n):
		import Var
		import D
		id = Var.var_to_id(var)
		VV = Var.VAR[id]
		if VV.dim == '3D':
			data = D.get_data(year, month, var, 0, product_n)
		elif VV.dim == '2D':
			data = D.get_data(year, month, var, 1, product_n)
		else:
			raise ValueError('your var is not valid!')

		Data, _, _ = self.Get_data_of_area(data, var, product_n)
		self.save_Area_Trimmed_data_as_npz(Data, year, month, VV.dir_name, VV.formal_name, product_n)
Пример #5
0
	def draw_Hofmuller_Diagram(self, Timeseries, months, label, \
							   var = 's', Rawdata_or_Anomaly = 'Rawdata', cb_min = 33, cb_max = 37, \
							   fsizex = 20, my_color = 1):
		import matplotlib.pyplot as plt
		import quick
		import numpy as np
		import Var
		plt.rcParams['font.size'] = 20
		vid = Var.var_to_id(var)
		cb_title = Var.VAR[vid].Get_cb_title()
		if var == 'u' or var == 'v':
			hgrid = self.hgrid[:self.Pn - 1] + 0.5
		else:
			hgrid = self.hgrid

		if Rawdata_or_Anomaly == 'Rawdata':
			clabel = cb_title
		elif Rawdata_or_Anomaly == 'Anomaly':
			clabel = 'Anomaly of ' + cb_title
		else:
			raise ValueError('your Rawdata_or_Anomaly argument is not valid!')


		if self.direction == 'EW':
			plta = quick.draw_with_axis(Timeseries, months, hgrid, cb_min, cb_max, \
										fsizex = fsizex, fsizey = self.fsizey, clabel = clabel, my_color = my_color)
			plta.ylabel('Year', fontsize = 32)
			plta.xlabel('LONGITUDE', fontsize = 32)
			plta.xticks(self.ticks, fontsize = 20)
			plta.yticks(months, label, fontsize = 15)
			plta.ylim(min(months), max(months))
			for i in range(months.size):
				if months[i] % 12 == 1:
					plta.axhline(y = months[i], linestyle = '--')

		elif self.direction == 'NS':
			plta = quick.draw_with_axis(Timeseries.T, hgrid, months, cb_min, cb_max, \
										fsizex = fsizex, fsizey = self.fsizey, clabel = clabel, my_color = my_color)
			plta.xlabel('Year', fontsize = 32)
			plta.ylabel('LATITUDE', fontsize = 32)
			plta.yticks(self.ticks, fontsize = 20)
			plta.xticks(months, label, fontsize = 15)
			plta.xlim(min(months), max(months))
			plta = quick.add_vline_at_Jan(plta, months)

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


		return plta
Пример #6
0
	def draw_line_with_data_map(self, plt, year, month, var, depth, cb_min, cb_max, product_n = 3, xlim = [40, 110], ylim = [ - 20, 30], \
								fsizex = 10, fsizey = 6, div = 20.0, interval = 10, color = 'red', linetype = '--'):
		import D
		import Var
		import quick
		import subroutine
		xgrid, ygrid, zgrid = D.get_grid_value(var, product_n)
		data = D.get_data(year, month, var, depth, product_n)
		stryear, strmonth = subroutine.strym(year, month)
		vid = Var.var_to_id(var)
		formal_name = Var.VAR[vid].Get_formal_name()
		title_name = D.Data[product_n].title_name
		clabel = stryear + '/' + strmonth + ' ' + formal_name + ' ' + ' at ' + str(zgrid[depth - 1]) + 'm '+ title_name
		plta = quick.draw_with_axis_and_map(data, ygrid, xgrid, cb_min, cb_max, xlim = xlim, ylim = ylim, \
											interval = interval, clabel = clabel, fsizex = fsizex, fsizey = fsizey)
		plta = self.draw_line(plta, xlim, ylim, interval = interval, color = color, linetype = linetype)
		return plta
Пример #7
0
	def save_data_as_npz(self, Timeseries, fy, ly, var = 's', depthn = 1, product_n = 3, Rawdata_or_Anomaly = 'Rawdata', fy_of_Anomalydata = 1990, ly_of_Anomalydata = 2011):
		import D
		import subroutine
		import Var
		title_name = D.Data[product_n].title_name
		xgrid, ygrid, zgrid = D.get_grid_value('s', product_n)
		vid = Var.var_to_id(var)
		formal_name = Var.VAR[vid].Get_formal_name()

		if Rawdata_or_Anomaly == 'Rawdata':
			fname_RA = formal_name
		elif Rawdata_or_Anomaly == 'Anomaly':
			fname_RA = '[Anomaly_of_' + formal_name + str(fy_of_Anomalydata) + '-' + str(ly_of_Anomalydata) + ']'
		else:
			raise ValueError('your Rawdata_or_Anomaly argument is not valid!')

		subroutine.save_npz(Timeseries, self.AreaName + '_of_' + fname_RA + '_at_' + str(zgrid[depthn - 1]) + \
							'm_Year' + str(fy) + '-' + str(ly) + '_' + title_name)
Пример #8
0
def masuda_data_read(year,month,var,depth):
	Mt=60*60*24*30				# 1ヶ月の秒数
	Threshold=-1e+30		# Threshold of Missing value
	data_dir=subroutine.dat_dir()+'ESTOCver03/binary/each_data/'
	ID = Var.var_to_id(var)
	dt=np.dtype([("data","<"+str(nx*ny)+"f")])
	stryear,strmonth=subroutine.strym(year,month)
	fd=open(data_dir+"/"+stryear+strmonth+"/"+var+".out","r")
	dim = Var.VAR[ID].Get_dim()
	if dim == '3D':
		count=ik
	else:
		count=1

	if count == 1 and depth != 1:
		raise ValueError('if you choose 2D data, depth must be 1!')

	chunk=np.fromfile(fd,dtype=dt,count=count)
	if depth != 0:
		data=chunk[depth-1]['data']
		data=np.reshape(data,(ny,nx))
	else:
		data=np.ones((ny,nx,ik))
		for k in range(0,ik):
			data[:,:,k]=np.reshape(chunk[k]['data'],(ny,nx))

	data[np.where(data<=Threshold)]=np.nan # 欠損値のところはnanに。


	# 単位に関してはすでに修正済み。
	# taux,tauy:N/m^2
	# u,v,w,sff:m/s
	# q:cal/(m^2 s)

	if var=='sff':# 単位をm/Monthに
		data=data*Mt
	elif var=='ustar' or var=='vstar' or var=='wstar':
		data=data / 100.0 # 単位をm/sに
	elif var=='eq':				# 淡水フラックスと同じ次元で扱えるように
		data=data*-Mt*0.01


	return data
Пример #9
0
	def load_Area_Trimmed_variable_of_npz(self, year, month, var, product_n):
		import Var
		id = Var.var_to_id(var)
		VV = Var.VAR[id]
		Data = self.load_Area_Trimmed_data_of_npz(year, month, VV.dir_name, VV.formal_name, product_n)
		return Data