def gaia_spitzer_errors(): """ Visualize the observational errors from Gaia and Spitzer, along with dispersion and distance scale of Sgr and Orphan. """ rcparams = {'lines.linestyle' : '-', 'lines.linewidth' : 1., 'lines.color' : 'k', 'lines.marker' : None, 'axes.edgecolor' : '#444444', 'axes.facecolor' : '#ffffff'} sgr_color = '#67A9CF' orp_color = '#EF8A62' with rc_context(rc=rcparams): fig,axes = plt.subplots(1, 2, figsize=(12, 6), sharex=True) # vertical lines for dwarf satellites axes[0].vlines([24,65,80,100], 0.001, 100, color='#888888', linestyles='--', zorder=-1) axes[1].vlines([24,65,80,100], [0.081,0.0465,0.025,0.014], 100, color='#888888', linestyles='--', zorder=-1) # label the vertical lines axes[1].text(17.1, 0.075, 'Sgr -', color='#888888', rotation=0) axes[1].text(29.5, 0.043, 'UMi, Boo -', color='#888888', rotation=0) axes[1].text(58., 0.023, 'Scl -', color='#888888', rotation=0) axes[1].text(69.75, 0.013, 'Car -', color='#888888', rotation=0) # Distance from 1kpc to ~100kpc D = np.logspace(0., 2., 50)*u.kpc # Sample metallicities from: http://arxiv.org/pdf/1211.7073v1.pdf fe_hs = np.random.normal(-1.67, 0.3, size=50) fe_hs = np.append(fe_hs, np.random.normal(-2.33, 0.3, size=len(fe_hs)//5)) for fe_h in fe_hs: # Johnson/Cousins (V - I_C) color for RR Lyrae at *minimum* # Guldenschuh et al. (2005 PASP 117, 721), pg. 725 rrl_V_minus_I = np.random.normal(0.579, 0.006) # Compute the apparent magnitude as a function of distance M_V = rrl_M_V(fe_h=fe_h)[0] m_V = apparent_magnitude(M_V, D) # Distance error dp = parallax_error(m_V, rrl_V_minus_I).arcsecond dD = D.to(u.pc).value**2 * dp * u.pc # Velocity error dpm = proper_motion_error(m_V, rrl_V_minus_I) dVtan = (dpm*D).to(u.km*u.radian/u.s).value # Plot Gaia distance errors axes[0].loglog(D.kiloparsec, (dD/D).decompose(), color='k', alpha=0.1) # Plot tangential velocity errors axes[1].loglog(D.kiloparsec, dVtan, color='k', alpha=0.1) # Add spitzer 2% line to distance plot axes[0].axhline(0.02, linestyle='-', linewidth=3, color='k', alpha=0.75) # Now add rectangles for Sgr, Orphan sgr_d = Rectangle((10., 0.15), 60., 0.15, color=sgr_color, alpha=1., label='Sgr stream range') axes[0].add_patch(sgr_d) # From fig. 3 in http://mnras.oxfordjournals.org/content/389/3/1391.full.pdf+html orp_d = Rectangle((10., 0.03), 35., 0.03, color=orp_color, alpha=1., label='Orp stream range') axes[0].add_patch(orp_d) # Dispersion from Majewski 2004: 10 km/s sgr_v = Rectangle((10., 10), 60., 1., color=sgr_color, alpha=1.) axes[1].add_patch(sgr_v) orp_v = Rectangle((10., 8.), 35., 1., color=orp_color, alpha=1.) axes[1].add_patch(orp_v) axes[0].set_ylim(0.003, 10) axes[0].set_xlim(1, 105) axes[1].set_ylim(0.01, 100) #axes[1].set_xlim(10, 100) axes[0].set_xlabel("Distance [kpc]") axes[0].set_ylabel("Frac. distance error: $\epsilon_D/D$") axes[1].set_ylabel("$v_{tan}$ error: $\epsilon_v$ [km/s]") axes[1].set_xlabel("Distance [kpc]") axes[0].set_xticklabels(["1", "10", "100"]) axes[0].set_yticklabels(["{:g}".format(yt) for yt in axes[0].get_yticks()]) axes[1].set_yticklabels(["{:g}".format(yt) for yt in axes[1].get_yticks()]) # add Gaia and Spitzer text to plots axes[0].text(4., 0.125, 'Gaia', fontsize=16, rotation=45, fontweight='normal') axes[0].text(4., 0.013, 'Spitzer', fontsize=16, color="k", alpha=0.75, fontweight='normal') axes[1].text(4., 0.06, 'Gaia', fontsize=16, rotation=45, fontweight='normal') # add legends axes[0].legend(loc='upper left', fancybox=True) #axes[1].legend(loc='upper left', fancybox=True) axes[0].yaxis.tick_left() axes[1].yaxis.tick_left() fig.subplots_adjust(hspace=0.1, wspace=0.1) plt.tight_layout() plt.savefig(os.path.join(plot_path, "gaia.pdf"))
def fig2(**kwargs): """ Visualize the observational errors from Gaia and Spitzer, along with dispersion and distance scale of Sgr and Orphan. """ rcparams = {'lines.linestyle' : '-', 'lines.linewidth' : 1., 'lines.color' : 'k', 'lines.marker' : None, 'axes.facecolor' : '#ffffff', 'xtick.major.size' : 16, 'xtick.major.width' : 1.5, 'xtick.minor.size' : 0, 'ytick.major.size' : 16, 'ytick.major.width' : 1.5, 'ytick.minor.size' : 0} with rc_context(rc=rcparams): fig,axes = plt.subplots(2, 1, figsize=(8, 10), sharex=True) # Distance from 1kpc to ~100kpc D = np.logspace(0., 2., 50)*u.kpc # Sample metallicities from: http://arxiv.org/pdf/1211.7073v1.pdf fe_h = -1.67 # Johnson/Cousins (V - I_C) color for RR Lyrae at *minimum* # Guldenschuh et al. (2005 PASP 117, 721), pg. 725 rrl_V_minus_I = np.random.normal(0.579, 0.006) # Compute the apparent magnitude as a function of distance M_V = rrl_M_V(fe_h=fe_h)[0] m_V = apparent_magnitude(M_V, D) # Distance error dp = parallax_error(m_V, rrl_V_minus_I).to(u.arcsecond).value dD = D.to(u.pc).value**2 * dp * u.pc # Velocity error dpm = proper_motion_error(m_V, rrl_V_minus_I) dVtan = (dpm*D).to(u.km*u.radian/u.s).value #dVtan = (D*dpm + dD*1.*u.mas/u.yr).to(u.km*u.radian/u.s).value # Plot Gaia distance errors fracDist = (dD/D).decompose().value fracDist[fracDist > 0.1] = 0.1 axes[0].loglog(D.to(u.kpc).value, fracDist, color='#000000', alpha=1., linewidth=4.) # Plot tangential velocity errors axes[1].loglog(D.to(u.kpc).value, dVtan, color='#000000', alpha=1., linewidth=4.) # Add spitzer 2% line to distance plot axes[0].axhline(0.02, linestyle='--', linewidth=3, color='k', alpha=0.75) # Now add rectangles for Sgr, Orphan sgr_d = Rectangle((10., 0.15), 60., 0.15, color=sgr_color, alpha=0.75, label='Sgr stream') axes[0].add_patch(sgr_d) # From fig. 3 in http://mnras.oxfordjournals.org/content/389/3/1391.full.pdf+html orp_d = Rectangle((10., 0.03), 35., 0.03, color=orp_color, alpha=0.75, label='Orp stream') axes[0].add_patch(orp_d) # Dispersion from Majewski 2004: 10 km/s sgr_v = Rectangle((10., 10), 60., 1., alpha=0.75, color=sgr_color) axes[1].add_patch(sgr_v) orp_v = Rectangle((10., 8.), 35., 1., alpha=0.75, color=orp_color) axes[1].add_patch(orp_v) axes[0].set_ylim(0.003, 1.3) axes[0].set_xlim(1, 100) axes[1].set_ylim(0.06, 130) axes[0].set_yticklabels([]) axes[1].set_yticklabels([]) axes[1].set_xticklabels([]) axes[0].yaxis.tick_left() axes[0].xaxis.tick_bottom() axes[1].yaxis.tick_left() axes[1].xaxis.tick_bottom() plt.tight_layout() #fig.subplots_adjust(hspace=0.05) fig.savefig(os.path.join(plot_path, "fig2.pdf"))