To consistently measure the RVs of my target stars, I need to align them with the telluric lines. That is because I took no effort to make sure they are consistent by e.g. observing an RV standard or something. I have a decent amount of code already written for the IGRINS pipeline, so lets just re-use that.
In [27]:
import sys
import os
import numpy as np
import matplotlib.pyplot as plt
import HelperFunctions
import telfit
from scipy.interpolate import InterpolatedUnivariateSpline as spline
import FittingUtilities
from scipy.optimize import minimize
from functools import partial
import Telluric_Wavecal
import logging
logger = logging.getLogger()
logger.setLevel(logging.INFO)
home = os.environ['HOME']
#sys.path.append('{}/School/Research/IGRINS_data/plp/recipes/'.format(home))
#import recipe_tell_wvsol
%matplotlib inline
In [2]:
with open('../starlist_20151013', 'r') as f:
fnames = ['../{}'.format(fn).strip() for fn in f.readlines()]
In [28]:
fname = fnames[-1]
reload(Telluric_Wavecal)
o2_fitter = Telluric_Wavecal.VelocityFitter(fname, tell_orders=(690, ))
h2o_fitter = Telluric_Wavecal.VelocityFitter(fname, tell_orders=(700., 715., 730.))
print('O2 Fit:\n================')
o2_rv, o2_rv_err = o2_fitter.fit()
print('\n\nH2O Fit:\n===============')
h2o_rv, h2o_rv_err = h2o_fitter.fit()
In [29]:
print(o2_rv, o2_rv_err)
print(h2o_rv, h2o_rv_err)
In [30]:
import telfit
modeler = telfit.Modeler()
full_model = modeler.MakeModel(highfreq=1e7/680.0, lowfreq=1e7/780.0)
plt.plot(full_model.x, full_model.y)
Out[30]:
In [32]:
with open('telluric_wavecal_summary.csv', 'w') as f:
f.write('filename,o2_rv,o2_rv_err,h2o_rv,h2o_rv_err\n')
for i, fname in enumerate(fnames):
print('File {}/{}: {}'.format(i+1, len(fnames), fname))
o2_fitter = Telluric_Wavecal.VelocityFitter(fname, tell_orders=(690.), telluric_model=full_model)
h2o_fitter = Telluric_Wavecal.VelocityFitter(fname, tell_orders=(700., 715., 730.), telluric_model=full_model)
print('O2 Fit:\n================')
o2_rv, o2_rv_err = o2_fitter.fit()
print('\n\nH2O Fit:\n===============')
h2o_rv, h2o_rv_err = h2o_fitter.fit()
with open('telluric_wavecal_summary.csv', 'a') as f:
f.write('{},{},{},{},{}\n'.format(fname, o2_rv, o2_rv_err, h2o_rv, h2o_rv_err))
In [15]:
import pandas as pd
df = pd.read_csv('telluric_wavecal_summary.csv')
df.o2_rv.hist(bins=30)
Out[15]:
In [17]:
df.h2o_rv.hist(bins=20)
Out[17]:
In [25]:
import scipy.stats
values = df.h2o_rv
loc, scale = scipy.stats.norm.fit(data=values[~np.isnan(values)])
df.h2o_rv.hist(bins=10, normed=True, alpha=0.4)
x = np.arange(-0.2, 0.3, 0.01)
y = scipy.stats.norm.pdf(x, loc=loc, scale=scale)
plt.plot(x, y, 'r-', lw=2)
Out[25]:
In [26]:
orders = HelperFunctions.ReadExtensionFits('../20140110/KG13385-0.fits')
print(len(orders))
%matplotlib inline
fig = plt.figure(figsize=(15,7))
ordernums = HelperFunctions.FindOrderNums(orders, (690., 700., 715., 730.))
for order in orders:
plt.plot(order.x, order.y/order.cont, 'k-', alpha=0.5)
for order in [orders[n] for n in ordernums]:
plt.plot(order.x, order.y/order.cont, 'r-', alpha=0.5)
print(order.x[0], order.x[-1])
In [ ]: