| 1 |
"""Plot extinction functions for comparison""" |
| 2 |
|
| 3 |
from collections import OrderedDict |
| 4 |
|
| 5 |
import numpy as np |
| 6 |
import matplotlib.pyplot as plt |
| 7 |
from matplotlib import rcParams |
| 8 |
from mpl_toolkits.axes_grid1 import make_axes_locatable |
| 9 |
|
| 10 |
import extinction |
| 11 |
|
| 12 |
rcParams['font.family'] = 'serif' |
| 13 |
|
| 14 |
|
| 15 |
def extinction_figure(wave, a_lambda, residual_from, residual_lims=(-0.1, 0.4), title_text='$R_V = 3.1$'): |
| 16 |
|
| 17 |
names = list(a_lambda.keys()) |
| 18 |
fig = plt.figure(figsize=(8.5, 6.)) |
| 19 |
|
| 20 |
ax = plt.axes() |
| 21 |
for name in names: |
| 22 |
plt.plot(wave, a_lambda[name], label=name) |
| 23 |
plt.axvline(x=2700., ls=':', c='k') |
| 24 |
plt.axvline(x=3030.3030, ls=':', c='k') |
| 25 |
plt.axvline(x=9090.9091, ls=':', c='k') |
| 26 |
plt.axvspan(wave[0], 1150., fc='0.8', ec='none', zorder=-1000) |
| 27 |
plt.axvspan(1150., 1250., fc='0.9', ec='none', zorder=-1000) |
| 28 |
plt.text(0.65, 0.95, title_text, transform=ax.transAxes, va='top', |
| 29 |
ha='right', size='x-large') |
| 30 |
plt.ylabel('Extinction ($A(\lambda)$ / $A_V$)') |
| 31 |
plt.legend() |
| 32 |
plt.setp(ax.get_xticklabels(), visible=False) |
| 33 |
|
| 34 |
divider = make_axes_locatable(ax) |
| 35 |
axresid = divider.append_axes("bottom", size=2.0, pad=0.2, sharex=ax) |
| 36 |
for name in names: |
| 37 |
plt.plot(wave, a_lambda[name] - a_lambda[residual_from]) |
| 38 |
plt.axvline(x=2700., ls=':', c='k') |
| 39 |
plt.axvline(x=3030.3030, ls=':', c='k') |
| 40 |
plt.axvline(x=9090.9091, ls=':', c='k') |
| 41 |
plt.axvspan(wave[0], 1150., fc='0.8', ec='none', zorder=-1000) |
| 42 |
plt.axvspan(1150., 1250., fc='0.9', ec='none', zorder=-1000) |
| 43 |
plt.xlim(wave[0], wave[-1]) |
| 44 |
plt.ylim(ymin=residual_lims[0], ymax=residual_lims[1]) |
| 45 |
plt.ylabel('residual from ' + residual_from) |
| 46 |
plt.xlabel(r'Wavelength ($\mathrm{\AA}$)') |
| 47 |
|
| 48 |
ax.set_xscale('log') |
| 49 |
axresid.set_xscale('log') |
| 50 |
plt.tight_layout() |
| 51 |
|
| 52 |
return fig |