<jupyter_start><jupyter_text>Welter issue 4 Simple plots of lines Part 1- Br$\gamma$<NAME>-Santiago  Friday, December 4, 2015  Let's look for scientifically interesting emission lines.<jupyter_code>import warnings
warnings.filterwarnings("ignore")
import numpy as np
from astropy.io import fits
import matplotlib.pyplot as plt
% matplotlib inline
% config InlineBackend.figure_format = 'retina'
import seaborn as sns
sns.set_context('notebook')<jupyter_output><empty_output><jupyter_text>Read in all the data.No spot-checking necessary, since we already did that in the previous notebook.  IGRINS data of LkCa4<jupyter_code>import h5py
f = h5py.File("../data/reduced/LkCa4_IGRINS_K.hdf5", "r")
K = {key:np.array(f[key]) for key in f.keys()}
f.close()

f = h5py.File("../data/reduced/LkCa4_IGRINS_H.hdf5", "r")
H = {key:np.array(f[key]) for key in f.keys()}
f.close()
K['wls'].shape<jupyter_output><empty_output><jupyter_text>Telluric absorption<jupyter_code>import pandas as pd
tell = pd.read_csv('~/GitHub/plp/master_calib/TelluricModel.dat', sep=' ', names = ['wls', 'trans'])
tell['wls'] = tell['wls'] * 10.0 #convert to angstroms
tell.head()<jupyter_output><empty_output><jupyter_text>Identify interesting lines Interesting lines:Line|Wavelength-|-Pa$\alpha$|1.87569Br$\gamma$|2.16612CO $\nu =2-0$|2.29353CO $\nu =3-1$|2.32265Na$~$I|2.20624  Meta<jupyter_code>K_orders, H_orders = pd.DataFrame(), pd.DataFrame()
K_orders['wl_start']=[np.floor(min(wl)) for wl in K['wls']]
K_orders['wl_end']=[np.floor(max(wl)) for wl in K['wls']]
K_orders['band']='K'
H_orders['wl_start']=[np.floor(min(wl)) for wl in H['wls']]
H_orders['wl_end']=[np.floor(max(wl)) for wl in H['wls']]
H_orders['band']='H'
orders = H_orders.append(K_orders)
orders.head()<jupyter_output><empty_output><jupyter_text>Plot the favorite lines<jupyter_code>sns.set_context('paper', font_scale=1.4)
sns.set_style('ticks')<jupyter_output><empty_output><jupyter_text>Br$\gamma$<jupyter_code>line = 21661.2
this_order = (orders.wl_start < line) & (orders.wl_end > line)
m = orders.index[this_order].values
print(m)
m = 11
wl = K['wls'][m,:]
fl = K['fls'][m,:]<jupyter_output><empty_output><jupyter_text>Feature indices<jupyter_code>dw = 60
gi = (wl > (line - dw)) & (wl < (line + dw))<jupyter_output><empty_output><jupyter_text>Continuum indices<jupyter_code>N = len(wl)
cib = (wl > 21600) & (wl < 21625)
cir = (wl > 21700) & (wl < 21750)
ci = cib | cir
cont_level = np.nanmedian(fl[ci])
cont = np.ones(N)*cont_level
sig_cont = np.nanstd(fl[ci])/cont_level
print('The relative uncertainty per pixel is {:.2}%'.format(sig_cont))<jupyter_output>The relative uncertainty per pixel is 0.021%<jupyter_text>Calculate the 10% width<jupyter_code>this_wl, this_fl = wl[gi], fl[gi]/cont_level
peak = np.nanmax(this_fl)
tph = (peak-1.0)*0.1
#tpw_r = (this_wl < line) & (this_fl <1)

ymax = 1.5
plt.figure(figsize=(5, 5))

plt.step(this_wl, this_fl, 'k')
plt.plot(this_wl,cont[gi]/cont_level, 'r--' )
plt.plot([min(this_wl), max(this_wl)],[1+tph, 1+tph], 'g:' )
#plt.plot(tell.wls, tell.trans*2.5, 'k-', alpha=0.2)
plt.fill_between(tell.wls, tell.trans*ymax, y2=ymax, alpha=0.2)
plt.plot([line, line],[0, ymax], 'b-.' )
#plt.plot([21655.3, 21655.3],[0, 3])
plt.plot([21637, 21637],[0, ymax], 'b:' )
plt.plot([21702, 21702],[0, ymax], 'b--' )
#plt.plot([21660, 21660],[0, ymax], 'r:' )
plt.ylim(0.8, ymax)
plt.text(21643, 1.35, 'Br$\gamma$', fontsize=20)
plt.xlim(min(this_wl), max(this_wl))
plt.xlabel('$\lambda$ ($\AA$)')
plt.ylabel('$f_\lambda$ (continuum $\equiv$ 1)')
plt.gca().get_xaxis().get_major_formatter().set_useOffset(False);
plt.savefig('../document/figures/Br_gamma_zoom.pdf', bbox_inches='tight')<jupyter_output><empty_output><jupyter_text>Calculate the 10% width and RV Let's convert to velocity units.$$\Delta v = \frac{\Delta \lambda}{\lambda}c $$<jupyter_code>from astropy import constants as const
c = const.c.to('km/s')<jupyter_output><empty_output><jupyter_text>10% width<jupyter_code>del_lam = 21702.0 - 21637.0
del_v = del_lam / line * c
del_v<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18927600691870522, 'fraction_numerical': 0.04595997034840623, 'mean_word_length': 6.7251908396946565, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '11', 'dir': 'jupyter-structured-clean-dedup', 'id': '444907', 'license': 'MIT', 'n_tokens_mistral': 1851, 'n_tokens_neox': 1692, 'n_words': 304, 'path': 'notebooks/welter_issue004-01_Bracket_Gamma.ipynb', 'repo_name': 'BrownDwarf/welter', 'size': '4054'}