Created
July 3, 2015 21:12
-
-
Save meredith-durbin/a9f97110cb233f767980 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
# In[1]: | |
get_ipython().magic(u'matplotlib inline') | |
get_ipython().magic(u"config InlineBackend.figure_format='retina'") | |
import numpy as np | |
from matplotlib import pyplot as plt | |
from matplotlib import rc | |
from reddening_laws import * | |
import prettyplotlib as ppl | |
rc('font', **{'family': 'serif', 'serif': ['Computer Modern Roman'], 'size':14}) | |
rc('text', usetex=True) | |
# In[2]: | |
f = open('final_data_files/distances_samestars_m4') | |
distances = np.loadtxt(f) | |
f.close() | |
dist_ab = distances[distances[:,3] == 0.] | |
dist_c = distances[distances[:,3] == 1.] | |
len_all = float(len(distances)) | |
# In[3]: | |
dist_mean = (dist_ab[:,1] * len(dist_ab)/len_all) + (dist_c[:,1] * len(dist_c)/len_all) | |
err_mean = np.sqrt((dist_ab[:,2] * len(dist_ab)/len_all)**2 + | |
(dist_c[:,2] * len(dist_c)/len_all)**2)/np.sqrt(len_all) | |
# In[4]: | |
dist_mean_all = np.concatenate(([0,0,0,0], dist_mean)) | |
err_mean_all = np.concatenate(([0,0,0,0], err_mean)) | |
# In[5]: | |
reddening_stuff = fit_reddening(*dist_mean_all) | |
print reddening_stuff | |
tru_dist = reddening_stuff[0] | |
tru_dist_stdev = reddening_stuff[2] | |
# In[7]: | |
nearir_x = np.linspace(1.22,1.5,50) | |
midir_x = np.linspace(1.5,4.5,100) | |
Rv = 3.1 | |
Ak = ccm_nearir(2.164,Rv) | |
nearir_y = ccm_nearir(nearir_x,Rv) | |
midir_y = indebetouw_ir(midir_x) * Ak | |
# In[10]: | |
fig = plt.figure(figsize=(6,5)) | |
ax = fig.add_subplot(1,1,1) | |
ax2 = ax.twiny() | |
x = np.linspace(0.15,0.95,10) | |
y = x * 0 + tru_dist | |
ppl.errorbar(ax, 1/dist_ab[:,0], dist_mean, yerr=err_mean, | |
color='k', mfc='k', fmt='o', label=r'$\mu$ (uncorrected)', zorder=10) | |
ppl.plot(ax, x, y, 'k-', lw=2, label=r'$\mu_0 = {:.3f}$'.format(tru_dist)) | |
ppl.plot(ax, x, y + tru_dist_stdev, 'k--', label=r'$\pm 1\sigma,\ \sigma = {:.3f}$'.format(tru_dist_stdev)) | |
ppl.plot(ax, x, y - tru_dist_stdev, 'k--') | |
ppl.plot(ax, 1/nearir_x, nearir_y + tru_dist, 'k-', label='Reddening law') | |
ppl.plot(ax, 1/midir_x, midir_y + tru_dist, 'k-') | |
ppl.legend(ax, loc=4, prop={'size':14}, numpoints=1, handlelength=1.5) | |
ax.set_xlim(0.15,0.95) | |
ax2.set_xlim(ax.get_xlim()[0], ax.get_xlim()[1]) | |
ax2.xaxis.set_ticks_position('none') | |
ax2.set_xticks(1/dist_ab[:,0]) | |
ax2.set_xticklabels(['$J$', '$H$', '$K$', '[3.6]', '[4.5]']) | |
ax.set_ylim(13.58,14.12) | |
ax.set_xlabel(r'$1/\lambda\ (\mu\mathrm{m}^{-1})$') | |
ax.set_ylabel(r'$\mu$') | |
fig.tight_layout() | |
#fig.savefig('final_plots/multiwavelength_distance_samestars_m4.pdf', dpi=300) | |
# In[ ]: | |
# In[ ]: | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment