Пример #1
0
def addImage(col, row, grid, xrange):
	filename = mp1_data.getDataFilename(row, 2, snapshots[col])

	ax = grid.grid[col][row]
	cbar_ax = grid.cgrid[col][row]

	data = torch.CFD_Data(filename, axial=True)

	vs = data.get_var(torch.VarType("tem", True))
	vsi = data.interpolate(vs, "linear")
	vsmin = vs.min()
	vsmax = vs.max()

	im = torch.image(data.x[0], data.x[1],
						 vsi, vsmin, vsmax, "linear", cmap,
						 ax)

	#cb = cbar_ax.colorbar(im, format=ticker.FuncFormatter(fmt))
	formatter = ticker.ScalarFormatter(useOffset=True, useMathText=True)
	formatter.set_powerlimits((0, 1))

	cb = grid.fig.colorbar(im, cax=cbar_ax, format=ticker.FuncFormatter(fmt), orientation='horizontal')
	#cb.ax.xaxis.set_ticks(np.arange(0, 1.01, 0.5))
	#labels = cb.ax.get_xticklabels()
	#labels[0] = ""
	#labels[2] = ""
	#cb.ax.set_xticklabels(labels)

	if grid.is_visible(col, row):
		zcentre = (110.0 / 200.0) * data.dx * data.ny

		zmin = zcentre - xrange[col][row]/2.0
		zmax = zcentre + xrange[col][row]/2.0

		ax.set_xlim([-xrange[col][row]/2.0, xrange[col][row]/2.0])
		ax.set_ylim([zmin, zmax])
		ax.xaxis.set_ticks(np.arange(-xrange[col][row]/2.0, (xrange[col][row]/2.0) + 0.0001, xrange[col][row]/4.0))
		ax.yaxis.set_ticks(np.arange(zmin, zmax + 0.0001, xrange[col][row]/4.0))

		ax.xaxis.get_major_ticks()[0].label1.set_visible(False)
		ax.xaxis.get_major_ticks()[2].label1.set_visible(False)
		ax.xaxis.get_major_ticks()[-1].label1.set_visible(False)

		ax.yaxis.get_major_ticks()[0].label1.set_visible(False)
		ax.yaxis.get_major_ticks()[2].label1.set_visible(False)
		ax.yaxis.get_major_ticks()[-1].label1.set_visible(False)

	# Add column and row labels

	if col == 0:
		ax.text(-0.15, 0.5, fmt.latexify("M = " + fmt.fmt_mass(mp1_data.masses[row]) + "\ \\mathrm{M_\\odot}"),
				fontsize=10, horizontalalignment='right', verticalalignment='center',
				rotation='vertical', transform=ax.transAxes)
	if row == 0:
		ax.text(0.5, 2.4, fmt.latexify("t = " + fmt.fmt_nolatex(mp1_data.times[col], 0) + "\ \\mathrm{yrs}"),
				fontsize=10, horizontalalignment='center', verticalalignment='bottom',
				rotation='horizontal', transform=ax.transAxes)
Пример #2
0
	nyt = nyticks[irow]

	grid[2 * irow + 0].set_ylim([0, ymax])
	grid[2 * irow + 1].set_ylim([0, ymax])

	if irow == 4:
		for icol in range(2):
			grid[2 * irow + icol].set_yticks(np.arange(0, ymax +  (ymax - 1.0e-8)/ float(nyt), ymax / float(nyt)))
	else:
		for icol in range(2):
			grid[2 * irow + icol].set_yticks(np.arange(ymax / float(nyt), ymax +  (ymax - 1.0e-8)/ float(nyt), ymax / float(nyt)))

	kx1 = dict(linewidth=1.5, label="CORNISH", color='b')
	kx2 = dict(linewidth=1.5, label="Simulated", color='r', linestyle='--')

	grid[2 * irow + 0].text(0.04, 0.94, fmt.latexify("n_\\star = " + fmt.fmt_power(mp1_data.densities[irow], '{:3.1f}', 4) + "\ \\mathrm{cm^{-3}}"),
				fontsize=fontsize, horizontalalignment='left', verticalalignment='top',
				rotation='horizontal', transform=grid[2 * irow + 0].transAxes)

	bins0 = np.arange(0, 24, 1)
	bins1 = np.arange(0, 1, 0.04)

	bincentres0 = 0.5 * (bins0[:-1] + bins0[1:])
	bincentres1 = 0.5 * (bins1[:-1] + bins1[1:])

	plotter.histstep(grid[2* irow + 0], cornish_survey[:,11], bins0, errorcentres=bincentres0, normed=normed, **kx1)
	plotter.histstep(grid[2* irow + 0], simulated_survey[:,7], bins0, normed=normed, **kx2)
	plotter.histstep(grid[2* irow + 1], cornish_phy_sizes, bins1, errorcentres=bincentres1, normed=normed, **kx1)
	plotter.histstep(grid[2* irow + 1], phy_sizes, bins1, normed=normed, **kx2)

### Legend
Пример #3
0
def addImage(col, row, grid, xrange):
	filename = mp1_data.getRadioDirname(row, 2, snapshots[col], 45, 5) + "/emeasure_ff.fits"

	ax = grid.grid[col][row]
	cbar_ax = grid.cgrid[col][row]

	hdu_list = fits.open(filename)
	image_data = hdu_list[0].data

	sig = 5
	FWHM = sig*hdu_list[0].header['PIXAS']*2.335
	image_data = ndimage.gaussian_filter(image_data, sigma=(sig, sig), order=0)

	nx = hdu_list[0].header['NAXIS1']
	ny = hdu_list[0].header['NAXIS2']

	dx = -hdu_list[0].header['CDELT1']*60.0*60.0
	dy = hdu_list[0].header['CDELT2']*60.0*60.0

	xmax = 0.5 * nx * dx
	xmin = -0.5 * nx * dx
	ymax = 0.5 * ny * dy
	ymin = -0.5 * ny * dy

	x = np.arange(xmin + (dx/2.0), xmax, dx)
	y = np.arange(ymin + (dy/2.0), ymax, dy)
	X, Y = np.meshgrid(x, y)
	max = hdu_list[0].header['MPIX']

	nlevels = 7
	levels = []

	for ilev in range(nlevels):
		levels.append(max/(math.sqrt(2.0)**(nlevels - ilev)))
	im = ax.imshow(image_data, extent=[xmin,xmax,ymin,ymax], origin='lower', cmap='gray_r')

	#cb = cbar_ax.colorbar(im, format=ticker.FuncFormatter(fmt))
	formatter = ticker.ScalarFormatter(useOffset=True, useMathText=True)
	formatter.set_powerlimits((0, 1))

	cb = grid.fig.colorbar(im, cax=cbar_ax, format=ticker.FuncFormatter(fmt), orientation='horizontal')
	#cb.ax.xaxis.set_ticks_position('top')
	xmax = cb.ax.get_xlim()[1]
	cb.ax.xaxis.set_ticks(np.arange(0, xmax, xmax/4.0))
	labels = cb.ax.get_xticklabels()
	labels[0] = ""
	labels[2] = ""
	cb.ax.set_xticklabels(labels)

	ax.contour(X, Y, image_data, levels, colors='black', linewidths=0.5)

	ax.set_xlim([-xrange[col][row]/2.0, xrange[col][row]/2.0])
	ax.set_ylim([-xrange[col][row]/2.0, xrange[col][row]/2.0])
	ax.xaxis.set_ticks(np.arange(-xrange[col][row]/2.0, (xrange[col][row]/2.0) + 0.0001, xrange[col][row]/4.0))
	ax.yaxis.set_ticks(np.arange(-(xrange[col][row]/2.0), (xrange[col][row]/2.0) + 0.0001, xrange[col][row]/4.0))

	ax.xaxis.get_major_ticks()[0].label1.set_visible(False)
	ax.xaxis.get_major_ticks()[2].label1.set_visible(False)
	ax.xaxis.get_major_ticks()[-1].label1.set_visible(False)

	ax.yaxis.get_major_ticks()[0].label1.set_visible(False)
	ax.yaxis.get_major_ticks()[2].label1.set_visible(False)
	ax.yaxis.get_major_ticks()[-1].label1.set_visible(False)

	# Pixel angular size in upper left corner.
	ax.text(0.02, 0.96, '{:.2f}'.format(hdu_list[0].header['PIXAS']) + "''",
			fontsize=6, horizontalalignment='left', verticalalignment='top',
			rotation='horizontal', transform=ax.transAxes)

	# FWHM of guassian blur kernal in lower left corner.
	ax.text(0.02, 0.04, "FWHM=" + '{:.1f}'.format(FWHM) + "''",
			fontsize=6, horizontalalignment='left', verticalalignment='bottom',
			rotation='horizontal', transform=ax.transAxes)

	# FWHM diameter line to show scale
	ax.plot([(0.90)*xrange[col][row]/2.0 - FWHM, (0.90)*xrange[col][row]/2.0], [-(0.90)*xrange[col][row]/2.0, -(0.90)*xrange[col][row]/2.0])

	# Peak brightness in mJy/beam in upper right
	rbeam_rad = 0.5 * hdu_list[0].header['BMAJ'] * math.pi / 180.0
	pix_rad = abs(hdu_list[0].header['CDELT1']) * math.pi / 180.0

	intensity_filename = mp1_data.getRadioDirname(row, 2, snapshots[col], 45, 5) + "/intensity_pixel_ff.fits"
	hdu_list2 = fits.open(intensity_filename)

	peak = hdu_list2[0].header['MPIX'] * math.pi * rbeam_rad * rbeam_rad / (pix_rad * pix_rad)

	ax.text(0.98, 0.96, '{:.2f}'.format(peak) + "mJy/b",
			fontsize=6, horizontalalignment='right', verticalalignment='top',
			rotation='horizontal', transform=ax.transAxes)

	# Add column and row labels
	def fmt_mass(x):
		a = '{:.0f}'.format(x)
		return '{}'.format(a)

	if col == 0:
		ax.text(-0.22, 0.5, fmt.latexify("M = " + fmt.fmt_mass(mp1_data.masses[row]) + "\ \\mathrm{M_\\odot}"),
				fontsize=10, horizontalalignment='right', verticalalignment='center',
				rotation='vertical', transform=ax.transAxes)
	if row == 0:
		ax.text(0.5, 1.24, fmt.latexify("t = " + fmt.fmt_nolatex(mp1_data.times[col], 0) + "\ \\mathrm{yrs}"),
				fontsize=10, horizontalalignment='center', verticalalignment='bottom',
				rotation='horizontal', transform=ax.transAxes)
Пример #4
0
def addImage(col, row, grid, xrange):
	if row % 2 == 1 or col % 2 == 1:
		return

	filename = mp1_data.getRadioDirname(row, 2, snapshots[col], 45, 5) + "/emeasure_ff.fits"

	col /= 2
	row /= 2

	ax = grid.grid[col][row]
	cbar_ax = grid.cgrid[col][row]

	hdu_list = fits.open(filename)
	image_data = hdu_list[0].data

	sig = 5
	FWHM = sig*hdu_list[0].header['PIXAS']*2.335
	image_data = ndimage.gaussian_filter(image_data, sigma=(sig, sig), order=0)

	nx = hdu_list[0].header['NAXIS1']
	ny = hdu_list[0].header['NAXIS2']

	dx = -hdu_list[0].header['CDELT1']*60.0*60.0
	dy = hdu_list[0].header['CDELT2']*60.0*60.0

	xmax = 0.5 * nx * dx
	xmin = -0.5 * nx * dx
	ymax = 0.5 * ny * dy
	ymin = -0.5 * ny * dy

	x = np.arange(xmin + (dx/2.0), xmax, dx)
	y = np.arange(ymin + (dy/2.0), ymax, dy)
	X, Y = np.meshgrid(x, y)
	max = hdu_list[0].header['MPIX']

	nlevels = 7
	levels = []

	for ilev in range(nlevels):
		levels.append(max/(math.sqrt(2.0)**(nlevels - ilev)))
	im = ax.imshow(image_data, extent=[xmin,xmax,ymin,ymax], origin='lower', cmap='gray_r', zorder=0)

	#cb = cbar_ax.colorbar(im, format=ticker.FuncFormatter(fmt))
	formatter = ticker.ScalarFormatter(useOffset=True, useMathText=True)
	formatter.set_powerlimits((0, 1))

	cb = grid.fig.colorbar(im, cax=cbar_ax, format=ticker.FuncFormatter(fmt.fmt), orientation='horizontal')
	#cb.ax.xaxis.set_ticks_position('top')
	xmax = cb.ax.get_xlim()[1]
	cb.ax.xaxis.set_ticks(np.arange(0, xmax, xmax/4.0))
	labels = cb.ax.get_xticklabels()
	labels[0] = ""
	labels[2] = ""
	cb.ax.set_xticklabels(labels)

	ax.contour(X, Y, image_data, levels, colors='black', linewidths=0.5, zorder=1)

	param_filename = mp1_data.getParamFilename(row, col, 25)
	filestring = open(param_filename, 'r').read()

	table = lua.eval("{" + filestring + "}")

	physical_dx = table["Parameters"]["Grid"]["side_length"] / float(table["Parameters"]["Grid"]["no_cells_x"])
	side_length_y = table["Parameters"]["Grid"]["no_cells_y"] * physical_dx
	star_vert_phy = table["Parameters"]["Star"]["cell_position_y"] * physical_dx - 0.5 * side_length_y
	star_vert_ang = math.degrees(star_vert_phy / (1.5 * 1000 * 3.09e18)) * 60 * 60
	star_y = star_vert_ang / math.sqrt(2)
	cloud_vert_ang = star_vert_ang + math.degrees(0.35 / 1500.0) * 60 * 60
	cloud_y = cloud_vert_ang / math.sqrt(2)

	ax.scatter([0], [star_y], c='w', marker='*', linewidths=[0.4], zorder=2)
	ax.scatter([0], [cloud_y], c='w', marker='D', linewidths=[0.4], zorder=2)

	ax.set_xlim([-xrange[col][row]/2.0, xrange[col][row]/2.0])
	ax.set_ylim([-xrange[col][row]/2.0, xrange[col][row]/2.0])
	ax.xaxis.set_ticks(np.arange(-xrange[col][row]/2.0, (xrange[col][row]/2.0) + 0.0001, xrange[col][row]/4.0))
	ax.yaxis.set_ticks(np.arange(-(xrange[col][row]/2.0), (xrange[col][row]/2.0) + 0.0001, xrange[col][row]/4.0))

	ax.xaxis.get_major_ticks()[0].label1.set_visible(False)
	ax.xaxis.get_major_ticks()[2].label1.set_visible(False)
	ax.xaxis.get_major_ticks()[-1].label1.set_visible(False)

	ax.yaxis.get_major_ticks()[0].label1.set_visible(False)
	ax.yaxis.get_major_ticks()[2].label1.set_visible(False)
	ax.yaxis.get_major_ticks()[-1].label1.set_visible(False)

	if False:
		# Pixel angular size in upper left corner.
		ax.text(0.02, 0.96, '{:.2f}'.format(hdu_list[0].header['PIXAS']) + "''",
				fontsize=5, horizontalalignment='left', verticalalignment='top',
				rotation='horizontal', transform=ax.transAxes)

		# FWHM of guassian blur kernal in lower left corner.
		ax.text(0.02, 0.04, "FWHM=" + '{:.1f}'.format(FWHM) + "''",
				fontsize=5, horizontalalignment='left', verticalalignment='bottom',
				rotation='horizontal', transform=ax.transAxes)

		# FWHM diameter line to show scale
		ax.plot([(0.90)*xrange[col][row]/2.0 - FWHM, (0.90)*xrange[col][row]/2.0], [-(0.90)*xrange[col][row]/2.0, -(0.90)*xrange[col][row]/2.0])

		# Peak brightness in mJy/beam in upper right
		rbeam_rad = 0.5 * hdu_list[0].header['BMAJ'] * math.pi / 180.0
		pix_rad = abs(hdu_list[0].header['CDELT1']) * math.pi / 180.0

		intensity_filename = mp1_data.getRadioDirname(row, col, 25, 45) + "/intensity_pixel_ff.fits"
		hdu_list2 = fits.open(intensity_filename)

		peak = hdu_list2[0].header['MPIX'] * math.pi * rbeam_rad * rbeam_rad / (pix_rad * pix_rad)

		ax.text(0.98, 0.96, '{:.2f}'.format(peak) + "mJy/b",
					fontsize=5, horizontalalignment='right', verticalalignment='top',
					rotation='horizontal', transform=ax.transAxes)

	# Add column and row labels
	def fmt_mass(x):
		a = '{:.0f}'.format(x)
		return '{}'.format(a)

	if col == 0:
		text_str = fmt.latexify("M = " + fmt.fmt_mass(mp1_data.masses[2 * row]) + "\ \\mathrm{M_\\odot}")
		ax.text(-0.3, 0.5, text_str,
				fontsize=8, horizontalalignment='right', verticalalignment='center',
				rotation='vertical', transform=ax.transAxes)
	if row == 0:
		text_str = fmt.latexify("t = " + fmt.fmt_power(int(mp1_data.times[2 * col] / 1000.0), '{:3.0f}', 0) + "\ \\mathrm{kyr}")
		ax.text(0.5, 1.3, text_str,
				fontsize=8, horizontalalignment='center', verticalalignment='bottom',
				rotation='horizontal', transform=ax.transAxes)
Пример #5
0
def addImage(index, grid, xrange):
	col = index
	row = 0

	filename = mp1_data.getRadioDirname(5, 2, 25, angles[index], 5) + "/emeasure_ff.fits"

	print filename

	ax = grid.grid[col][row]
	cbar_ax = grid.cgrid[col][row]

	hdu_list = fits.open(filename)
	image_data = hdu_list[0].data

	sig = 5
	FWHM = sig*hdu_list[0].header['PIXAS']*2.335
	image_data = ndimage.gaussian_filter(image_data, sigma=(sig, sig), order=0)

	nx = hdu_list[0].header['NAXIS1']
	ny = hdu_list[0].header['NAXIS2']

	dx = -hdu_list[0].header['CDELT1']*60.0*60.0
	dy = hdu_list[0].header['CDELT2']*60.0*60.0

	xmax = 0.5 * nx * dx
	xmin = -0.5 * nx * dx
	ymax = 0.5 * ny * dy
	ymin = -0.5 * ny * dy

	x = np.arange(xmin + (dx/2.0), xmax, dx)
	y = np.arange(ymin + (dy/2.0), ymax, dy)
	X, Y = np.meshgrid(x, y)
	max = hdu_list[0].header['MPIX']

	nlevels = 7
	levels = []

	for ilev in range(nlevels):
		levels.append(max/(math.sqrt(2.0)**(nlevels - ilev)))
	im = ax.imshow(image_data, extent=[xmin,xmax,ymin,ymax], origin='lower', cmap='gray_r')

	#cb = cbar_ax.colorbar(im, format=ticker.FuncFormatter(fmt))
	formatter = ticker.ScalarFormatter(useOffset=True, useMathText=True)
	formatter.set_powerlimits((0, 1))

	cb = grid.fig.colorbar(im, cax=cbar_ax, format=ticker.FuncFormatter(fmt.fmt), orientation='horizontal')
	#cb.ax.xaxis.set_ticks_position('top')
	xmax = cb.ax.get_xlim()[1]
	cb.ax.xaxis.set_ticks(np.arange(0, xmax, xmax/4.0))
	labels = cb.ax.get_xticklabels()
	labels[0] = ""
	labels[2] = ""
	cb.ax.set_xticklabels(labels)

	ax.contour(X, Y, image_data, levels, colors='black', linewidths=0.5)

	ax.set_xlim([-xrange[col][row]/2.0, xrange[col][row]/2.0])
	ax.set_ylim([-xrange[col][row]/2.0, xrange[col][row]/2.0])
	ax.xaxis.set_ticks(np.arange(-xrange[col][row]/2.0, (xrange[col][row]/2.0) + 0.0001, xrange[col][row]/4.0))
	ax.yaxis.set_ticks(np.arange(-(xrange[col][row]/2.0), (xrange[col][row]/2.0) + 0.0001, xrange[col][row]/4.0))

	ax.xaxis.get_major_ticks()[0].label1.set_visible(False)
	ax.xaxis.get_major_ticks()[2].label1.set_visible(False)
	ax.xaxis.get_major_ticks()[-1].label1.set_visible(False)

	ax.yaxis.get_major_ticks()[0].label1.set_visible(False)
	ax.yaxis.get_major_ticks()[2].label1.set_visible(False)
	ax.yaxis.get_major_ticks()[-1].label1.set_visible(False)

	if col != 0:
		ax.tick_params(labelleft='off')

	# Add column and row labels
	if row == 0:
		ax.text(0.5, 1.24, fmt.latexify("\\theta_\\mathrm{i} = " + str(angles[col]) + "^\\circ"),
				fontsize=10, horizontalalignment='center', verticalalignment='bottom',
				rotation='horizontal', transform=ax.transAxes)