Beispiel #1
0
def plot_gc(gcstars, gcdata, gcID, cut=5.0, err=0.5,
            modelfn='../data/PScolors.dat', DM=None, Ar=None):
	d = gcstars[gcstars['gcID'] == gcID]
	gc = gcdata[gcdata['ID'] == gcID]
	
	# Filter out stars which are too far from cluster center
	gc_rad = gc['r_h'] / 60.
	if np.isnan(gc_rad):
		gc_rad = gc['r_c'] / 60.
	tp_star = np.array([(90. - d['b'])*np.pi/180., d['l']*np.pi/180.]).T
	tp_gc = np.array([(90. - gc['b'])*np.pi/180., gc['l']*np.pi/180.]).T
	gc_dist = great_circle_dist(tp_gc, tp_star)[0]
	#idx = np.argsort(gc_dist)
	#d = d[idx[:int(cut*len(idx))]]
	idx = (gc_dist < cut * gc_rad * np.pi / 180.)
	d = d[idx]
	print 'Filtered out %.1f pct of stars based on distance.' % (100.*(1. - float(np.sum(idx))/float(len(idx))))
	
	# Determine distance modulus to cluster
	mu = 5. * (2. + np.log10(gc['R_Sun'][0]))
	
	print 'Cluster ID: %s' % gcID
	print 'Radius = %.2f deg' % gc_rad
	print '# of stars = %d' % len(d)
	print '(l, b): %.2f, %.2f' % (gc['l'], gc['b'])
	print 'DM = %.2f' % mu
	print '[Fe/H] = %.2f' % gc['FeH'] 
	print 'E(B-V) = %.2f' % gc['EBV']
	print 'A_r = %.2f' % (gc['EBV'] * 2.271)
	
	# Correct observed magnitudes for extinction
	A_coeff = np.array([3.172, 2.271, 1.682, 1.322, 1.087])
	EBV = gc['EBV'] + 0.15
	if DM != None:
		mu = DM
	if Ar != None:
		EBV = Ar / A_coeff[1]
	m_g = d['g'] - A_coeff[0] * EBV
	m_r = d['r'] - A_coeff[1] * EBV
	m_i = d['i'] - A_coeff[2] * EBV
	m_z = d['z'] - A_coeff[3] * EBV
	m_y = d['y'] - A_coeff[4] * EBV
	
	# Determine model colors
	model = StellarModel(modelfn)
	idx = (d['g'] > 0.) & (d['r'] > 0.)
	idx = idx & (d['g_err'] < 10.*err) & (d['r_err'] < 10.*err)
	Mr = np.linspace(max(np.min(m_r[idx] - mu), -1.), min(np.max(m_r[idx] - mu), 27.), 200)
	FeH = np.empty(200, dtype=np.float32)
	FeH.fill(gc['FeH'])
	model_color = []
	for i in range(3):
		model_color.append(model.color(Mr, FeH + 1.*(i-1.)))
	
	mplib.rc('text', usetex=True)
	
	'''
	# Color - Color
	fig = plt.figure(figsize=(8,8), dpi=100)
	
	# g-r vs r-i
	ax = fig.add_subplot(2,2,2)
	idx = (d['g'] > 0.) & (d['r'] > 0.) & (d['i'] > 0.)
	idx = idx & (d['g_err'] < err) & (d['r_err'] < err) & (d['i_err'] < err)
	if np.any(idx):
		density_scatter(ax, m_g[idx] - m_r[idx], m_r[idx] - m_i[idx],
		                binsize=(0.05,0.05), threshold=8)
		ax.set_xlabel(r'$g - r$', fontsize=16)
		ax.set_ylabel(r'$r - i$', fontsize=16)
		for c,mc in zip(['r','g','c'], model_color):
			ax.plot(mc['gr'], mc['ri'], c, alpha=0.5)
	
	# r-i vs i-z
	ax = fig.add_subplot(2,2,3)
	idx = (d['r'] > 0.) & (d['i'] > 0.) & (d['z'] > 0.)
	idx = idx & (d['r_err'] < err) & (d['i_err'] < err) & (d['z_err'] < err)
	if np.any(idx):
		density_scatter(ax, m_r[idx] - m_i[idx], m_i[idx] - m_z[idx],
		                binsize=(0.05,0.05), threshold=8)
		ax.set_xlabel(r'$r - i', fontsize=16)
		ax.set_ylabel(r'$i - z$', fontsize=16)
		for c,mc in zip(['r','g','c'], model_color):
			ax.plot(mc['ri'], mc['iz'], c, alpha=0.5)
	
	# i-z vs z-y
	ax = fig.add_subplot(2,2,4)
	#for i in range(50):
	#	print d['i'][5*i:5*(i+1)]
	#	print d['i_err'][5*i:5*(i+1)]
	#	print ''
	idx = (d['i'] > 0.) & (d['z'] > 0.) & (d['y'] > 0.)
	idx = idx & (d['i_err'] < err) & (d['z_err'] < err) & (d['y_err'] < err)
	if np.any(idx):
		density_scatter(ax, m_i[idx] - m_z[idx], m_z[idx] - m_y[idx],
		                binsize=(0.05,0.05), threshold=8)
		ax.set_xlabel(r'$i - z$', fontsize=16)
		ax.set_ylabel(r'$z - y$', fontsize=16)
		for c,mc in zip(['r','g','c'], model_color):
			ax.plot(mc['iz'], mc['zy'], c, alpha=0.5)
	'''
	
	
	# Color - Magnitude
	fig = plt.figure(figsize=(8,8), dpi=100)
	
	# g-r vs M_r
	ax = fig.add_subplot(2,2,1)
	idx = (m_g > 0.) & (m_r > 0.)
	idx = idx & (d['g_err'] < err) & (d['r_err'] < err)
	if np.any(idx):
		density_scatter(ax, m_g[idx] - m_r[idx], m_r[idx] - mu,
		                nbins=(500,500), threshold=100)
		ax.set_xlim(-0.5, 0.9)
		ylim = ax.get_ylim()
		ax.set_ylim(ylim[1], ylim[0])
		ax.set_xlabel(r'$g - r$', fontsize=16)
		ax.set_ylabel(r'$M_{r}$', fontsize=16)
		for c,mc in zip(['r','g','c'], model_color):
			ax.plot(mc['gr'], Mr, c, alpha=0.5)
	
	# r-i vs M_r
	ax = fig.add_subplot(2,2,2)
	idx = (m_r > 0.) & (m_i > 0.)
	idx = idx & (d['r_err'] < err) & (d['i_err'] < err)
	if np.any(idx):
		density_scatter(ax, m_r[idx] - m_i[idx], m_r[idx] - mu,
		                nbins=(500,500), threshold=100)
		ax.set_xlim(-0.5, 0.7)
		ylim = ax.get_ylim()
		ax.set_ylim(ylim[1], ylim[0])
		ax.set_xlabel(r'$r - i$', fontsize=16)
		ax.set_ylabel(r'$M_{r}$', fontsize=16)
		for c,mc in zip(['r','g','c'], model_color):
			ax.plot(mc['ri'], Mr, c, alpha=0.5)
	
	# i-z vs M_r
	ax = fig.add_subplot(2,2,3)
	idx = (m_r > 0.) & (m_i > 0.) & (m_z > 0.)
	idx = idx & (d['i_err'] < err) & (d['z_err'] < err)
	if np.any(idx):
		density_scatter(ax, m_i[idx] - m_z[idx], m_r[idx] - mu,
		                nbins=(500,500), threshold=100)
		ax.set_xlim(-0.5, 0.6)
		ylim = ax.get_ylim()
		ax.set_ylim(ylim[1], ylim[0])
		ax.set_xlabel(r'$i - z$', fontsize=16)
		ax.set_ylabel(r'$M_{r}$', fontsize=16)
		for c,mc in zip(['r','g','c'], model_color):
			ax.plot(mc['iz'], Mr, c, alpha=0.5)
	
	# z-y vs M_r
	ax = fig.add_subplot(2,2,4)
	idx = (m_r > 0.) & (m_z > 0.) & (m_y > 0.)
	idx = idx & (d['z_err'] < err) & (d['y_err'] < err)
	if np.any(idx):
		density_scatter(ax, m_z[idx] - m_y[idx], m_r[idx] - mu,
		                nbins=(500,500), threshold=100)
		ax.set_xlim(-0.5, 0.6)
		ylim = ax.get_ylim()
		ax.set_ylim(ylim[1], ylim[0])
		ax.set_xlabel(r'$z - y$', fontsize=16)
		ax.set_ylabel(r'$M_{r}$', fontsize=16)
		for c,mc in zip(['r','g','c'], model_color):
			ax.plot(mc['zy'], Mr, c, alpha=0.5)
	
	
	# Source positions
	fig = plt.figure(figsize=(8,8), dpi=100)
	ax = fig.add_subplot(1,1,1)
	density_scatter(ax, d['l'], d['b'], nbins=(100,100), threshold=20)
	ax.set_xlabel(r'$\ell$', fontsize=16)
	ax.set_ylabel(r'$b$', fontsize=16)
Beispiel #2
0
def plot_colors(d, model):
	# Correct for reddening
	A_coeff = np.array([3.634, 2.241, 1.568, 1.258, 1.074])
	m_g = d['g'] - A_coeff[0] * d['EBV']
	m_r = d['r'] - A_coeff[1] * d['EBV']
	m_i = d['i'] - A_coeff[2] * d['EBV']
	m_z = d['z'] - A_coeff[3] * d['EBV']
	m_y = d['y'] - A_coeff[4] * d['EBV']
	
	sel = (np.abs((m_g - m_r) - 0.715) < 10.02) & (np.abs((m_r - m_i) - 0.318) < 10.02)
	
	fig = plt.figure(figsize=(12,8), dpi=150)
	
	err = 0.02
	
	# Color corrections (by eye)
	iz_corr = Delta_iz()
	model['iz'] += iz_corr(model['ri'])
	zy_corr = Delta_zy()
	model['zy'] += zy_corr(model['ri'])
	
	# Metallicity masks
	msel = np.abs(model['Mr'] + 0.5) < 100.01
	rich = msel & (model['FeH'] == 0.)
	poor = msel & (model['FeH'] == -2.5)
	
	# g-r vs r-i
	ax = fig.add_subplot(2,3,1)
	idx = sel & (m_g > 0.) & (m_r > 0.) & (m_i > 0.)
	idx = idx & (d['g_err'] < err) & (d['r_err'] < err) & (d['i_err'] < err)
	gr = m_g[idx] - m_r[idx]
	ri = m_r[idx] - m_i[idx]
	idx = (gr > - 0.5) & (gr < 2.) & (ri > -0.5) & (ri < 2.)
	density_scatter(ax, gr[idx], ri[idx], nbins=(80,80), threshold=3, s=1.5)
	ax.plot(model['gr'][rich], model['ri'][rich], 'k.', ms=0.3)
	#ax.plot(model['gr'][poor], model['ri'][poor], 'g.', ms=0.2)
	ax.set_xlabel(r'$g - r$', fontsize=16)
	ax.set_ylabel(r'$r - i$', fontsize=16)
	ax.set_xlim(-0.5, 2.)
	ax.set_ylim(-0.5, 2.)
	
	# r-i vs i-z
	ax = fig.add_subplot(2,3,2)
	idx = sel & (m_r > 0.) & (m_i > 0.) & (m_z > 0.)
	idx = idx & (d['r_err'] < err) & (d['i_err'] < err) & (d['z_err'] < err)
	ri = m_r[idx] - m_i[idx]
	iz = m_i[idx] - m_z[idx]
	idx = (ri > -0.5) & (ri < 2.) & (iz > -0.25) & (iz < 1.)
	density_scatter(ax, ri[idx], iz[idx], nbins=(80,80), threshold=3, s=1.5)
	ax.plot(model['ri'][rich], model['iz'][rich], 'k.', ms=0.3)
	#ax.plot(model['ri'][poor], model['iz'][poor]+0.030, 'g.', ms=0.2)
	ax.set_xlabel(r'$r - i', fontsize=16)
	ax.set_ylabel(r'$i - z$', fontsize=16)
	ax.set_xlim(-0.5, 2.)
	ax.set_ylim(-0.25, 1.)
	
	# i-z vs z-y
	ax = fig.add_subplot(2,3,3)
	idx = sel & (m_i > 0.) & (m_z > 0.) & (m_y > 0.)
	idx = idx & (d['i_err'] < err) & (d['z_err'] < err) & (d['y_err'] < err)
	iz = m_i[idx] - m_z[idx]
	zy = m_z[idx] - m_y[idx]
	idx = (iz > -0.25) & (iz < 1.) & (zy > -0.2) & (zy < 0.6)
	density_scatter(ax, iz[idx], zy[idx], nbins=(80,80), threshold=3, s=1.5)
	ax.plot(model['iz'][rich], model['zy'][rich], 'k.', ms=0.3)
	#ax.plot(model['iz'][poor]+0.030, model['zy'][poor]-0.035, 'g.', ms=0.2)
	ax.set_xlabel(r'$i - z$', fontsize=16)
	ax.set_ylabel(r'$z - y$', fontsize=16)
	ax.set_xlim(-0.25, 1.)
	ax.set_ylim(-0.2, 0.6)
	
	# g-r vs z-y
	ax = fig.add_subplot(2,3,4)
	idx = sel & (m_g > 0.) & (m_r > 0.) & (m_z > 0.) & (m_y > 0.)
	idx = idx & (d['g_err'] < err) & (d['r_err'] < err) & (d['z_err'] < err) & (d['y_err'] < err)
	gr = m_g[idx] - m_r[idx]
	zy = m_z[idx] - m_y[idx]
	idx = (gr > - 0.5) & (gr < 2.) & (zy > -0.2) & (zy < 0.6)
	density_scatter(ax, gr[idx], zy[idx], nbins=(80,80), threshold=3, s=1.5)
	ax.plot(model['gr'][rich], model['zy'][rich], 'k.', ms=0.3)
	ax.set_xlabel(r'$g - r$', fontsize=16)
	ax.set_ylabel(r'$z - y$', fontsize=16)
	ax.set_xlim(-0.5, 2.)
	ax.set_ylim(-0.2, 0.6)
	
	# g-r vs i-z
	ax = fig.add_subplot(2,3,5)
	idx = sel & (m_g > 0.) & (m_r > 0.) & (m_i > 0.) & (m_z > 0.)
	idx = idx & (d['g_err'] < err) & (d['r_err'] < err) & (d['i_err'] < err) & (d['z_err'] < err)
	gr = m_g[idx] - m_r[idx]
	iz = m_i[idx] - m_z[idx]
	idx = (gr > - 0.5) & (gr < 2.) & (iz > -0.25) & (iz < 1.)
	density_scatter(ax, gr[idx], iz[idx], nbins=(80,80), threshold=3, s=1.5)
	ax.plot(model['gr'][rich], model['iz'][rich], 'k.', ms=0.3)
	ax.set_xlabel(r'$g - r$', fontsize=16)
	ax.set_ylabel(r'$i - z$', fontsize=16)
	ax.set_xlim(-0.5, 2.)
	ax.set_ylim(-0.25, 1.)
	
	# r-i vs z-y
	ax = fig.add_subplot(2,3,6)
	idx = sel & (m_g > 0.) & (m_r > 0.) & (m_z > 0.) & (m_y > 0.)
	idx = idx & (d['r_err'] < err) & (d['i_err'] < err) & (d['z_err'] < err) & (d['y_err'] < err)
	ri = m_r[idx] - m_i[idx]
	zy = m_z[idx] - m_y[idx]
	idx = (ri > - 0.5) & (ri < 2.) & (zy > -0.2) & (zy < 0.6)
	density_scatter(ax, ri[idx], zy[idx], nbins=(80,80), threshold=3, s=1.5)
	ax.plot(model['ri'][rich], model['zy'][rich], 'k.', ms=0.3)
	ax.set_xlabel(r'$r - i$', fontsize=16)
	ax.set_ylabel(r'$z - y$', fontsize=16)
	ax.set_xlim(-0.5, 2.)
	ax.set_ylim(-0.2, 0.6)
	
	fig.subplots_adjust(left=0.08, right=0.95, bottom=0.1, top=0.9, wspace=0.3)