Esempio n. 1
0
def draw_some_timeserieses(plt, Timeseries, fy, ly, draw_fy, draw_ly, llabel, Month_of_RM = 13, fsizex = 20, fsizey = 6):
	months, label = subroutine.get_months_and_label(fy, ly)
	N = Timeseries.shape[0]
	plt.rcParams['lines.linewidth'] =  2
	plt.rcParams['font.size'] = 16
	for i in range(0, 3):
		plt.figure(figsize = (20, 6))
		for j in range(0, N):
			if i == 0:
				plt.plot(months, Timeseries[j, :], label = llabel[j])
				plt.title('Raw Timeseries')
			elif i == 1:
				a = ts.RawData_minus_mean_annual_cycle(Timeseries[j, :])
				plt.plot(months, a, label = llabel[j])
				plt.title('Interannual variation')
			elif i == 2:
				a = ts.running_mean(ts.RawData_minus_mean_annual_cycle(Timeseries[j, :]), Month_of_RM)
				plt.plot(months, a, label = llabel[j])
				plt.title(str(Month_of_RM) + ' month running mean')
			else:
				raise ValueError('i is out of range!')

		plt = trim_Monthly_Timeseries_Figure(plt, fy, ly, fy)
		plt = add_vline_at_Jan(plt, months)
		plt.plot(months, np.zeros(months.size), linewidth = 0.5, color = 'k')
		plt.xticks(months, label)
		plt.legend(bbox_to_anchor = (1.05,  1),  loc = 2,  borderaxespad = 0.)
		plt.show()
Esempio n. 2
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
Esempio n. 3
0
	def timeseries_of_area_averaged_value(self, fy, ly, var, depth, product_n = 3):
		import numpy as np
		import D
		import subroutine
		Yn = ly - fy + 1
		Timeseries = np.zeros(12 * Yn)
		months, label = subroutine.get_months_and_label(fy, ly)
		for year in range(fy, ly + 1):
			for month in range(1, 13):
				i = month - 1 + (year - fy) * 12
				Data = D.get_data(year, month, var, depth, product_n)
				tmp, _, _ = self.Get_data_of_area(Data, var, product_n)
				Timeseries[i] = np.average(tmp[np.where(np.isnan(tmp) == False)])

		return Timeseries, months, label
Esempio n. 4
0
	def Get_Hofmuller_of_D2Data(self, fy, ly, D2N, var, product_n = 3):
		import D2
		import numpy as np
		import subroutine
		Yn = ly - fy + 1
		Timeseries = np.zeros((12 * Yn, self.Pn))
		months, label = subroutine.get_months_and_label(fy, ly)
		a = D2.D2Data[D2N]
		for year in range(fy, ly + 1):
			for month in range(1, 13):
				i = month - 1 + (year - fy) * 12
				Data = a.load_data_of_npz(year, month, product_n)
				Data, hgrid = self.Get_VerticalSection_from_2Ddata(Data, var, product_n)
				Timeseries[i, :] = Data[:]

		return Timeseries, months, label
Esempio n. 5
0
	def Get_Hofmuller(self, fy, ly, var, depth, product_n = 3):
		import D
		import Var
		import numpy as np
		import subroutine
		Yn = ly - fy + 1
		Timeseries = np.zeros((12 * Yn, self.Pn))
		months, label = subroutine.get_months_and_label(fy, ly)

		for year in range(fy, ly + 1):
			for month in range(1, 13):
				i = month - 1 + (year - fy) * 12
				Data, hgrid, zgrid = self.Get_VerticalSection(year, month, var, product_n)
				Timeseries[i, :] = Data[:, depth - 1]

		return Timeseries, months, label
Esempio n. 6
0
	def timeseries_of_area_averaged_D2(self, fy, ly, D2_id, product_n = 3):
		import numpy as np
		import D2
		import subroutine
		D2D = D2.D2Data[D2_id]
		Yn = ly - fy + 1
		Timeseries = np.zeros(12 * Yn)
		months, label = subroutine.get_months_and_label(fy, ly)
		for year in range(fy, ly + 1):
			for month in range(1, 13):
				i = month - 1 + (year - fy) * 12
				Data = D2D.load_data_of_npz(year, month, product_n)
				tmp, _, _ = self.Get_data_of_area(Data, 's', product_n)
				tmp[np.where(np.abs(tmp) == np.inf)] = np.nan
				Timeseries[i] = np.average(tmp[np.where(np.isnan(tmp) == False)])

		return Timeseries, months, label
Esempio n. 7
0
	def load_data_of_npz(self, 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!')

		Timeseries = subroutine.load_npz(self.AreaName + '_of_' + fname_RA + '_at_' + str(zgrid[depthn - 1]) + \
										 'm_Year' + str(fy) + '-' + str(ly) + '_' + title_name)
		months, label = subroutine.get_months_and_label(fy, ly)
		return Timeseries, months, label