Пример #1
0
def draw_12month_cycle_with_map(data, ygrid, xgrid, DataDrawN, cb_min = -2, cb_max = 32, interval = 10, div = 20.0, \
								xlim = [40, 110], ylim = [-20, 30], column = 3, my_color = 1,
								ci = 2.0, linewidth = 1.0, datarange = 40.0, \
								std_length = 0.5, scale = 5.0, intvl = 2, qkeyx = 0.8, qkeyy = 4.6, \
								fsizex = 16, fsizey = 18, clabel = 'clabel', fontsize = 20):
	import matplotlib.pyplot as plt
	parameter = DataDraw[DataDrawN].PickUpParameter(cb_min, cb_max, div, clabel, ci, linewidth, datarange, std_length, scale, intvl, qkeyx, qkeyy)
	parameter_d = DataDraw[DataDrawN].PickUpParameter_for_12months_cycle_figure(std_length, scale, clabel, qkeyx, qkeyy)
	label_flg_if_12months = DataDraw[DataDrawN].Get_label_flg_if_12month()
	if 12 % column != 0:
		raise ValueError('column must be a divisor of 12!')

	row = 12 / column
	months =  [ 'Jan',  'Feb',  'Mar',  'Apr',
				'May',  'Jun',  'Jul',  'Aug',
				'Sep',  'Oct',  'Nov',  'Dec' ]

	fig = plt.figure(figsize = (fsizex, fsizey))
	plt.rcParams['font.size'] = fontsize
	ax = [0] * 12
	for i in range(0, 12):
		ax[i] = fig.add_subplot(row, column, 1 + i)
		m = subroutine.General_map(slat = ylim[0], nlat = ylim[1], wlon = xlim[0], elon = xlim[1])
		if i == 12 - column:
			label = [1, 1]
		elif i > 12 - column:
			label = [1, 0]
		elif i % column == 0:
			label = [0, 1]
		else:
			label = [0, 0]

		m = subroutine.add_lonlat_line_on_map(m, interval = interval, lonlabel = label[0], latlabel = label[1])

		x, y = np.meshgrid(xgrid, ygrid)
		X, Y = m(x, y)
		plt = Cmap[my_color].Set_Cmap(plt)
		data_d = DataDraw[DataDrawN].PickUp_Data_of_a_month(data, i)

		ax[i], CF = DataDraw[DataDrawN].Draw(ax[i], X, Y, data_d, parameter, label_flg = label_flg_if_12months)

		ax[i].set_xlim(xlim)
		ax[i].set_ylim(ylim)
		ax[i].set_title(months[i])

	DataDraw[DataDrawN].Add_Description_to_12MonthsCycleFigure(plt, fig, CF, parameter_d)
	fig.tight_layout()
	return plt
Пример #2
0
	def draw_line(self, plt, xlim = [40, 110], ylim = [ - 20, 30], interval = 10, color = 'red', linetype = '--'):
		import subroutine
		m = subroutine.General_map(slat = ylim[0], nlat = ylim[1], wlon = xlim[0], elon = xlim[1])
		m = subroutine.add_lonlat_line_on_map(m, interval = interval, lonlabel = 1, latlabel = 1)
		for i in range(0, self.band):
			if self.direction == 'NS':
				a = self.lonp + i
				b = self.latp
			elif self.direction == 'EW':
				a = self.lonp
				b = self.latp + i
			else:
				raise ValueError("your direction is not valid!")

			plt.plot(a, b, linetype, color = color)

		return plt
Пример #3
0
	def draw_area(self, plt, xlim = [40, 110], ylim = [ - 20, 30], interval = 10, color = 'red', Map = 0):
		import subroutine
		import numpy as np
		if Map == 0:
			m = subroutine.General_map(slat = ylim[0], nlat = ylim[1], wlon = xlim[0], elon = xlim[1])
			m = subroutine.add_lonlat_line_on_map(m, interval = interval, lonlabel = 1, latlabel = 1)

		M = int(self.nlat - self.slat) + 1
		N = int(self.elon - self.wlon) + 1
		a = np.arange(M) + self.slat
		b1 = np.ones(M) * self.wlon
		b2 = np.ones(M) * self.elon
		c = np.arange(N) + self.wlon
		d1 = np.ones(N) * self.slat
		d2 = np.ones(N) * self.nlat
		plt.plot(b1, a, color = color)
		plt.plot(b2, a, color = color)
		plt.plot(c, d1, color = color)
		plt.plot(c, d2, color = color)
		return plt
Пример #4
0
def draw_with_axis_and_map(data, ygrid, xgrid, cb_min, cb_max, clabel='clabel', fsizex=10, fsizey=4, div=20.0, interval = 10, \
						   xlim = [0, 360], ylim = [ - 90, 90], my_color = 1):
	import matplotlib.pyplot as plt
	from mpl_toolkits.axes_grid1 import make_axes_locatable
	# 参考:http://qiita.com/termoshtt/items/cfb31abc6beabde999c2

	fig, ax = plt.subplots(figsize=(fsizex,fsizey))

	m = subroutine.General_map(slat = ylim[0], nlat = ylim[1], wlon = xlim[0], elon = xlim[1])
	m = subroutine.add_lonlat_line_on_map(m, interval = interval)
	y, x = np.meshgrid(ygrid, xgrid)
	X, Y = m(x, y)
	plt = Cmap[my_color].Set_Cmap(plt)
	plt, _ = DataDraw[0].Draw(plt, X, Y, data.T, [cb_min, cb_max, div, clabel])
	# image = m.contourf(X, Y, data.T, interval_of_cf, latlon = True, extend = 'both')

	# ax.axis('image')
	# divider = make_axes_locatable(ax)
	# ax_cb = divider.new_horizontal(size = "2%", pad = 0.5)
	# fig.add_axes(ax_cb)
	# plt.colorbar(image, cax = ax_cb, label=clabel)
	return plt