In [1]:
import emcee
from scipy.interpolate import interp1d
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline

In [163]:
more_info = np.genfromtxt("/Users/adrian/projects/triand-rrlyrae/data/mdm-targets.txt", 
                          names=True, dtype=None)
more_info


Out[163]:
array([ ('TriAndRRL1', 35.804598, 31.551122, 0.6297892, 55889.67436, 0.724, 17.902, 112, 0.181, 18.131),
       ('TriAndRRl2', 30.59351, 33.377335, 0.6043698, 55763.907589, 0.515, 16.902, 105, 0.208, 16.965),
       ('TriAndRRl3', 28.380832, 30.584897, 0.5817013, 55899.726836, 0.966, 17.151, 116, 0.14, 17.597),
       ('TriAndRRl4', 24.505426, 32.027878, 0.5610494, 55892.613891, 0.68, 17.373, 107, 0.149, 17.595),
       ('TriAndRRl5', 22.322702, 32.72186, 0.5129024, 55853.589624, 0.7, 16.891, 116, 0.148, 17.177),
       ('TriAndRRl6', 12.488351, 42.598328, 0.6189352, 55820.651431, 0.357, 16.523, 101, 0.222, 16.486),
       ('TriAndRRl7', 11.310251, 42.705384, 0.5819742, 55757.857652, 0.499, 16.482, 104, 0.219, 16.524),
       ('TriAndRRl8', 17.992175, 35.466819, 0.6438835, 56272.808192, 0.347, 17.201, 101, 0.151, 17.23),
       ('TriAndRRl9', 11.491072, 40.199252, 0.5191218, 55774.793032, 0.775, 16.636, 116, 0.18, 16.934),
       ('TriAndRRl10', 16.841753, 32.235145, 0.4767494, 56258.826942, 0.973, 16.217, 116, 0.167, 16.64),
       ('TriAndRRl11', 9.262168, 38.824378, 0.6286307, 55899.583961, 0.367, 16.68, 103, 0.151, 16.727),
       ('TriAndRRl12', 12.887871, 34.28071, 0.5708534, 56231.918816, 0.831, 17.026, 118, 0.279, 17.237),
       ('TriAndRRl13', 8.323077, 37.502618, 0.605721, 56265.64237, 0.433, 18.191, 100, 0.168, 18.235),
       ('TriAndRRl14', 7.316877, 37.832822, 0.5361401, 56233.871843, 0.776, 17.176, 112, 0.161, 17.453),
       ('TriAndRRl15', 8.828356, 36.304111, 0.5994482, 56237.939283, 0.798, 16.461, 110, 0.168, 16.725),
       ('TriAndRRl16', 10.495088, 33.834552, 0.5099844, 56258.839841, 0.834, 16.439, 112, 0.244, 16.663),
       ('TriAndRRl17', 11.420589, 31.895553, 0.5194712, 56203.614781, 0.771, 16.282, 112, 0.236, 16.481),
       ('TriAndRRl18', 9.956522, 32.429326, 0.5740692, 56272.769061, 0.752, 16.876, 119, 0.223, 17.113),
       ('TriAndRRl19', 351.051857, 32.899191, 0.4542834, 55046.805814, 1.067, 17.296, 119, 0.375, 17.559),
       ('TriAndRRl20', 5.576572, 36.203326, 0.6826233, 56229.917435, 0.537, 16.545, 105, 0.186, 16.641),
       ('TriAndRRl21', 352.155077, 33.73084, 0.5913201, 56239.726193, 0.548, 17.362, 110, 0.297, 17.367),
       ('TriAndRRl22', 353.523696, 34.806522, 0.634024, 56226.528309, 0.686, 17.01, 107, 0.281, 17.104),
       ('TriAndRRl23', 352.977933, 34.21691, 0.6201623, 56197.71663, 0.469, 17.138, 104, 0.315, 17.07),
       ('TriAndRRl24', 353.000072, 33.44693, 0.5104113, 55782.967115, 0.934, 16.293, 114, 0.247, 16.581),
       ('TriAndRRl25', 353.576571, 33.945158, 0.5268401, 55519.664379, 0.73, 16.881, 106, 0.236, 17.049),
       ('TriAndRRl26', 351.509509, 30.571749, 0.5281412, 56232.636689, 0.75, 17.395, 116, 0.539, 17.319),
       ('TriAndRRl27', 355.466314, 33.808053, 0.5673953, 55813.943244, 0.768, 16.994, 112, 0.199, 17.229),
       ('TriAndRRl28', 2.822702, 34.243251, 0.5633701, 55514.634149, 0.69, 16.391, 116, 0.131, 16.688),
       ('TriAndRRl29', 0.350222, 36.141364, 0.5029317, 56207.678085, 1.135, 17.276, 106, 0.309, 17.574),
       ('TriAndRRl30', 1.605007, 34.567764, 0.6251911, 56204.766799, 0.453, 18.159, 106, 0.156, 18.26),
       ('TriAndRRl31', 354.620544, 30.140181, 0.558377, 56234.646836, 0.73, 17.402, 116, 0.258, 17.596),
       ('TriAndRRl32', 356.154789, 30.168917, 0.5399409, 56234.597284, 0.798, 17.194, 109, 0.364, 17.27),
       ('TriAndRRl33', 1.014094, 32.019259, 0.6935978, 56239.834007, 0.597, 16.898, 104, 0.135, 17.073),
       ('TriAndRRl34', 359.193996, 31.672904, 0.5732184, 55771.935045, 0.581, 17.05, 113, 0.141, 17.254)], 
      dtype=[('name', 'S11'), ('ra', '<f8'), ('dec', '<f8'), ('period', '<f8'), ('hjd0', '<f8'), ('amp', '<f8'), ('mag0', '<f8'), ('template', '<i8'), ('rExt', '<f8'), ('Vmag', '<f8')])

In [2]:
_phase,_vtemplate = np.loadtxt("/Users/adrian/projects/triand-rrlyrae/data/RVtemplates/Halpha.txt").T
template = interp1d(_phase, _vtemplate) # define an interpolator to get template value at arbitrary phases

In [3]:
# observed parameters
a = 35.6 # ± 2.5
b = 78.2 # ± 2.4

In [4]:
def model(phase, vsys, a, b, AV):
    Arv_Ha = a*AV + b
    return Arv_Ha*template(phase) + vsys

def ln_likelihood(p, phase, v, sigma, a, a_err, b, b_err, AV):
    (vsys,) = p
    var = (sigma**2 + template(phase)**2 * (AV**2*a_err**2 + b_err**2))
    lnB = -0.5 * var / (sigma*a_err*b_err)
    lnL = -0.5 * (v - model(phase, vsys, a, b, AV))**2 / var
    return lnB + lnL

def ln_posterior(p, phase, v, sigma, a, a_err, b, b_err, AV):
    return ln_likelihood(p, phase, v, sigma, a, a_err, b, b_err, AV).sum()

Test for RRL14 -- from Ally's fit:

$$v_\gamma = -228. \pm 25.$$

rv phase:

  • -256.0 0.19
  • -210.0 0.26
$$ A_R=0.453 $$

In [5]:
phase = np.array([0.19, 0.26])
rv = np.array([-256., -210.])
rv_err = np.array([15., 18.])
AV = 1.21*0.453

lls = []
vsyss = np.linspace(-250,-150,100)
for vsys in vsyss:
    lls.append(ln_likelihood([vsys], phase, rv, rv_err, a, 2.5, b, 2.4, AV).sum())

plt.plot(vsyss, lls)


Out[5]:
[<matplotlib.lines.Line2D at 0x109ce1cd0>]

In [30]:
sampler = emcee.EnsembleSampler(nwalkers=32, dim=1, lnpostfn=ln_posterior, 
                                args=(phase, rv, rv_err, a, 2.5, b, 2.4, AV))

In [31]:
p0 = np.random.normal(-200, 10., size=(sampler.k,1))

In [54]:
pos,prob,state = sampler.run_mcmc(p0, 100)
sampler.reset()
pos,prob,state = sampler.run_mcmc(pos, 256)

In [64]:
vhel = model(0.27, sampler.flatchain[:,0], a, b, AV)
v = np.median(vhel)
verr = np.sqrt((a*AV + b + 3.4)**2 * (0.06**2 + (0.1*1.47)**2))
v, verr


Out[64]:
(-230.52609847811124, 16.054125122225098)

Fit all velocities


In [15]:
ally_d = np.genfromtxt("/Users/adrian/projects/triand-rrlyrae/data/TriAnd_RRL_26mar15.csv", 
                     skiprows=0, dtype=None, names=True, delimiter=',')

In [6]:
d = np.genfromtxt("/Users/adrian/projects/triand-rrlyrae/data/TriAnd_RRL_RV_intermediate.csv", 
                  delimiter=',', names=True, dtype=None)
d.dtype.names


Out[6]:
('oname', 'name', 'RV_hel', 'Phase', 'Err', 'A_R')

In [26]:
def fit_v(phase, rv, rv_err, A_R):
    sampler = emcee.EnsembleSampler(nwalkers=32, dim=1, lnpostfn=ln_posterior, 
                                    args=(phase, rv, rv_err, a, 2.5, b, 2.4, AV))
    p0 = np.random.normal(-200, 10., size=(sampler.k,1))
    
    pos,prob,state = sampler.run_mcmc(p0, 100)
    sampler.reset()
    pos,prob,state = sampler.run_mcmc(pos, 256)
        
    extra = np.sqrt(np.sum((-(phase-0.5)**2/3 + 0.06)**2))
    
    vsys = sampler.flatchain[:,0]
    vhel = model(0.27, vsys, a, b, AV)
    v = np.median(vhel)
    verr = np.sqrt((a*AV + b + 3.4)**2 * (extra**2 + (0.1*1.47)**2))
    return vsys, v, verr

In [61]:
ally_d


Out[61]:
array([('RRL2', 'TriAndRRl26', 351.509509, 30.571749, 0.75, -199, 20, 22.07),
       ('RRL3', 'TriAndRRl21', 352.155077, 33.73084, 0.548, -269, 16, 22.56),
       ('RRL4', 'TriAndRRl23', 352.977933, 34.21691, 0.469, -84, 23, 19.68),
       ('RRL5', 'TriAndRRl24', 353.000072, 33.44693, 0.934, -305, 25, 15.71),
       ('RRL8', 'TriAndRRl31', 354.620544, 30.140181, 0.73, -318, 24, 25.07),
       ('RRL9', 'TriAndRRl27', 355.466314, 33.808053, 0.768, -231, 18, 21.17),
       ('RRL10', 'TriAndRRl32', 356.154789, 30.168917, 0.798, -176, 25, 21.57),
       ('RRL13', 'TriAndRRl33', 1.014094, 32.019259, 0.597, -89, 20, 19.71),
       ('RRL14', 'TriAndRRl30', 1.605007, 34.567764, 0.453, -228, 25, 34.04),
       ('RRL16', 'TriAndRRl20', 5.576572, 36.203326, 0.537, -129, 25, 16.15),
       ('RRL19', 'TriAndRRl15', 8.828356, 36.304111, 0.798, -88, 16, 16.79),
       ('RRL20', 'TriAndRRl11', 9.262168, 38.824378, 0.367, -133, 22, 16.8),
       ('RRL22', 'TriAndRRl16', 10.495088, 33.834552, 0.834, -194, 25, 16.32),
       ('RRL25', 'TriAndRRl9', 11.491072, 40.199252, 0.775, -157, 18, 18.48),
       ('RRL27', 'TriAndRRl12', 12.887871, 34.28071, 0.831, -25, 22, 21.25),
       ('RRL28', 'TriAndRRl10', 16.841753, 32.235145, 0.973, -287, 18, 16.14),
       ('RRL29', 'TriAndRRl8', 17.992175, 35.466819, 0.347, -128, 19, 21.18),
       ('RRL30', 'TriAndRRl5', 22.322702, 32.72186, 0.7, -212, 20, 20.67),
       ('RRL33', 'TriAndRRl2', 30.59351, 33.377335, 0.515, -245, 19, 18.75),
       ('RRL34', 'TriAndRRL1', 35.804598, 31.551122, 0.724, -159, 22, 32.08)], 
      dtype=[('oname', 'S5'), ('name', 'S11'), ('ra', '<f8'), ('dec', '<f8'), ('amp', '<f8'), ('Vsys', '<i8'), ('Err', '<i8'), ('dist', '<f8')])

In [33]:
ally_dd.dtype.names


Out[33]:
('oname', 'name', 'ra', 'dec', 'amp', 'Vsys', 'Err', 'dist')

In [190]:
rows = []
for name in np.unique(d['name']):
    dd = d[d['name'] == name]
    ally_dd = ally_d[ally_d['name'] == name]
    info = more_info[more_info['name'] == name]
    
    print("---------------\n{0}:".format(name))
    AV = 1.21 * dd['A_R'][0]
    
    # data to fit
    phase = (dd['Phase'] + 0.5/info['period']) % 1.
    print("Phase shift: {0}".format((phase - dd['Phase'])[0]))
    
    # phase = dd['phase']
    ix = (phase > 0.05) & (phase < 0.85)
    if ix.sum() == 0:
        continue
        
    phase = phase[ix]
    RV_hel = dd['RV_hel'][ix]
    RV_err = dd['Err'][ix]

    print("\t Phases: {0}".format(phase))
    print("{0} measurements initially, {1} with good phase".format(len(dd), len(phase)))
    vsys,v,verr = fit_v(phase, RV_hel, RV_err, AV)
    
    plt.figure()
    plt.title(name)
    plt.errorbar(phase, RV_hel, RV_err, marker='o', ecolor='#666666', linestyle='none')
    
    phase = np.linspace(0.,0.94,100)
    for i in range(128):
        plt.plot(phase, model(phase, vsys[np.random.randint(len(vsys))], a, b, AV), 
                 marker=None, color='k', alpha=0.05)
    
    rows.append((name, v, verr, ally_dd['Vsys'], ally_dd['Err'], ally_dd['ra'], ally_dd['dec'], ally_dd['dist']))
    
apw = np.array(rows, dtype=[('name','S12'),('v_apw','f8'),('verr_apw','f8'),('v_ally','f8'),('verr_ally','f8'),
                            ('ra','f8'), ('dec','f8'), ('dist','f8')])


---------------
TriAndRRL1:
Phase shift: -0.206083559388
	 Phases: [ 0.26391644  0.48391644  0.22391644]
3 measurements initially, 3 with good phase
---------------
TriAndRRl10:
Phase shift: 0.048769017853
	 Phases: [ 0.49876902  0.26876902]
2 measurements initially, 2 with good phase
---------------
TriAndRRl11:
Phase shift: -0.204620455221
	 Phases: [ 0.06537954  0.30537954]
2 measurements initially, 2 with good phase
---------------
TriAndRRl12:
Phase shift: -0.124118381357
	 Phases: [ 0.56588162  0.21588162]
2 measurements initially, 2 with good phase
---------------
TriAndRRl15:
Phase shift: -0.165899572307
	 Phases: [ 0.39410043  0.59410043]
2 measurements initially, 2 with good phase
---------------
TriAndRRl16:
Phase shift: -0.019577853754
	 Phases: [ 0.67042215]
1 measurements initially, 1 with good phase
---------------
TriAndRRl2:
Phase shift: -0.172691951186
	 Phases: [ 0.07730805  0.48730805]
2 measurements initially, 2 with good phase
---------------
TriAndRRl20:
Phase shift: -0.267531594658
	 Phases: [ 0.35246841]
2 measurements initially, 1 with good phase
---------------
TriAndRRl21:
Phase shift: -0.154434290328
	 Phases: [ 0.42556571]
2 measurements initially, 1 with good phase
---------------
TriAndRRl23:
Phase shift: -0.193759440069
	 Phases: [ 0.30624056]
1 measurements initially, 1 with good phase
---------------
TriAndRRl24:
Phase shift: -0.0203978634486
	 Phases: [ 0.30960214  0.76960214]
2 measurements initially, 2 with good phase
---------------
TriAndRRl26:
Phase shift: -0.053283477979
	 Phases: [ 0.43671652  0.55671652]
2 measurements initially, 2 with good phase
---------------
TriAndRRl27:
Phase shift: -0.118780152039
	 Phases: [ 0.41121985]
2 measurements initially, 1 with good phase
---------------
TriAndRRl30:
Phase shift: 0.799755466768
	 Phases: [ 0.05975547]
2 measurements initially, 1 with good phase
---------------
TriAndRRl31:
Phase shift: -0.104547644333
	 Phases: [ 0.21545236]
1 measurements initially, 1 with good phase
---------------
TriAndRRl32:
Phase shift: -0.0739727255335
	 Phases: [ 0.24602727]
1 measurements initially, 1 with good phase
---------------
TriAndRRl33:
Phase shift: -0.279121127547
	 Phases: [ 0.34087887  0.09087887]
2 measurements initially, 2 with good phase
---------------
TriAndRRl5:
Phase shift: -0.0251556631437
	 Phases: [ 0.48484434  0.18484434]
2 measurements initially, 2 with good phase
---------------
TriAndRRl8:
Phase shift: -0.223462008267
	 Phases: [ 0.43653799]
2 measurements initially, 1 with good phase
---------------
TriAndRRl9:
Phase shift: -0.0368349007882
	 Phases: [ 0.0531651  0.5031651]
2 measurements initially, 2 with good phase

In [191]:
apw.dtype.names


Out[191]:
('name', 'v_apw', 'verr_apw', 'v_ally', 'verr_ally', 'ra', 'dec', 'dist')

In [192]:
plt.figure(figsize=(6,6))
plt.plot(apw['v_apw'], apw['v_ally'], linestyle='none')
plt.plot(np.linspace(apw['v_apw'].min(),apw['v_apw'].max(),100),
         np.linspace(apw['v_apw'].min(),apw['v_apw'].max(),100), marker=None)
plt.xlabel('Adrian')
plt.ylabel('Ally')
plt.title("Best-fit velocity")


Out[192]:
<matplotlib.text.Text at 0x1119a4490>

In [193]:
plt.figure(figsize=(6,6))
plt.plot(apw['verr_apw'], apw['verr_ally'], linestyle='none')
plt.plot(np.linspace(13,27,100), np.linspace(13,27,100), marker=None)
plt.xlim(13,27)
plt.ylim(13,27)
plt.xlabel('Adrian')
plt.ylabel('Ally')
plt.title("Velocity uncertainty")


Out[193]:
<matplotlib.text.Text at 0x111012150>

In [194]:
from astropy.table import Table

In [195]:
tbl = Table(apw)
tbl.rename_column('v_apw', 'Vsys')
tbl.rename_column('verr_apw', 'Err')

In [196]:
tbl.write("/Users/adrian/projects/triand-rrlyrae/data/apw_velocities.csv", format='ascii', delimiter=',')

In [197]:
!cat /Users/adrian/projects/triand-rrlyrae/data/apw_velocities.csv


name,Vsys,Err,v_ally,verr_ally,ra,dec,dist
TriAndRRL1,-130.85487474138452,18.910268086849097,-159.0,22.0,35.804598,31.551122,32.08
TriAndRRl10,-293.2393952686294,20.290690174660256,-287.0,18.0,16.841753,32.235145,16.14
TriAndRRl11,-110.21222346621133,15.047109038479922,-133.0,22.0,9.262168,38.824378,16.8
TriAndRRl12,-7.622035501769265,18.97776114397998,-25.0,22.0,12.887871,34.28071,21.25
TriAndRRl15,-62.70110044420859,19.416283601942077,-88.0,16.0,8.828356,36.304111,16.79
TriAndRRl16,-191.91409384280064,18.2603504887519,-194.0,25.0,10.495088,33.834552,16.32
TriAndRRl2,-223.04871707478003,16.476122497928984,-245.0,19.0,30.59351,33.377335,18.75
TriAndRRl20,-110.24892867804371,16.35661959775641,-129.0,25.0,5.576572,36.203326,16.15
TriAndRRl21,-242.96579819932728,16.63140990128772,-269.0,16.0,352.155077,33.73084,22.56
TriAndRRl23,-59.41835657984708,15.726415435825837,-84.0,23.0,352.977933,34.21691,19.68
TriAndRRl24,-303.27771404734347,19.334464121414793,-305.0,25.0,353.000072,33.44693,15.71
TriAndRRl26,-193.88573572816819,19.237495987409744,-199.0,20.0,351.509509,30.571749,22.07
TriAndRRl27,-214.18498593649738,18.096799949460543,-231.0,18.0,355.466314,33.808053,21.17
TriAndRRl30,-188.04085683291544,14.870965634886057,-228.0,25.0,1.605007,34.567764,34.04
TriAndRRl31,-304.0424444147709,17.031538022552102,-318.0,24.0,354.620544,30.140181,25.07
TriAndRRl32,-165.41084709322047,17.62326074451958,-176.0,25.0,356.154789,30.168917,21.57
TriAndRRl33,-52.06527512875746,16.723852802894605,-89.0,20.0,1.014094,32.019259,19.71
TriAndRRl5,-212.661111197825,17.992964178273137,-212.0,20.0,22.322702,32.72186,20.67
TriAndRRl8,-104.03853233446037,15.28064781440207,-128.0,19.0,17.992175,35.466819,21.18
TriAndRRl9,-152.12563066664936,18.27178895174345,-157.0,18.0,11.491072,40.199252,18.48

Table to go with publication


In [202]:
pub_tbl = Table(apw)

# fix names
pub_tbl['name'] = np.array([name.replace('l','L') for name in pub_tbl['name']])
pub_tbl['sort_name'] = np.array([int(name[9:]) for name in pub_tbl['name']])

pub_tbl.rename_column('v_apw', 'vgsr')
pub_tbl.rename_column('verr_apw', 'verr')

pub_tbl.remove_column('v_ally')
pub_tbl.remove_column('verr_ally')

pub_tbl.sort('sort_name')
pub_tbl.remove_column('sort_name')

pub_tbl


Out[202]:
<Table masked=False length=20>
namevgsrverrradecdist
string96float64float64float64float64float64
TriAndRRL1-130.85487474118.910268086835.80459831.55112232.08
TriAndRRL2-223.04871707516.476122497930.5935133.37733518.75
TriAndRRL5-212.66111119817.992964178322.32270232.7218620.67
TriAndRRL8-104.03853233415.280647814417.99217535.46681921.18
TriAndRRL9-152.12563066718.271788951711.49107240.19925218.48
TriAndRRL10-293.23939526920.290690174716.84175332.23514516.14
TriAndRRL11-110.21222346615.04710903859.26216838.82437816.8
TriAndRRL12-7.6220355017718.97776114412.88787134.2807121.25
TriAndRRL15-62.701100444219.41628360198.82835636.30411116.79
TriAndRRL16-191.91409384318.260350488810.49508833.83455216.32
TriAndRRL20-110.24892867816.35661959785.57657236.20332616.15
TriAndRRL21-242.96579819916.6314099013352.15507733.7308422.56
TriAndRRL23-59.418356579815.7264154358352.97793334.2169119.68
TriAndRRL24-303.27771404719.3344641214353.00007233.4469315.71
TriAndRRL26-193.88573572819.2374959874351.50950930.57174922.07
TriAndRRL27-214.18498593618.0967999495355.46631433.80805321.17
TriAndRRL30-188.04085683314.87096563491.60500734.56776434.04
TriAndRRL31-304.04244441517.0315380226354.62054430.14018125.07
TriAndRRL32-165.41084709317.6232607445356.15478930.16891721.57
TriAndRRL33-52.065275128816.72385280291.01409432.01925919.71

In [204]:
pub_tbl.write("/Users/adrian/projects/triand-rrlyrae/data/publication_data.csv", format='ascii', delimiter=',')

Figure 1


In [187]:
# _cache = dict()

In [189]:
fig,axes = plt.subplots(2, 2, figsize=(10,8), sharex=True)

for i,name in enumerate(['TriAndRRl2','TriAndRRl26']):
    dd = d[d['name'] == name]
    info = more_info[more_info['name'] == name]
    print("{0}: {1} measurements".format(name, len(dd)))
    print(info['period'])
    print(info['hjd0'])
    AV = 1.21 * dd['A_R'][0]
    phase = np.linspace(0.,0.94,100)
    
    if name not in _cache:
        vsys,v,verr = fit_v(dd['Phase'], dd['RV_hel'], dd['Err'], AV)
        lines = np.array([model(phase, vsys[np.random.randint(len(vsys))], a, b, AV) for j in range(1000)])
        _cache[name] = dict(vsys=vsys, v=v, verr=verr, lines=lines)
    else:
        vsys = _cache[name]['vsys']
        v = _cache[name]['v']
        verr = _cache[name]['verr']
        lines = _cache[name]['lines']
    
    # fit to RV curve
    col = axes[:,i]
    col[0].set_title(name.replace('l','L'))
    
    quantiles = np.percentile(lines, [16, 84, 50], axis=0)
    col[0].fill_between(phase, quantiles[0], quantiles[1], color='#dddddd')
    
    col[0].plot(phase, quantiles[2], marker=None, lw=2., color='k')
    col[0].errorbar(dd['Phase'], dd['RV_hel'], dd['Err'], marker='o', ecolor='#666666', linestyle='none')

    # light curve
    path = "/Users/adrian/projects/triand-rrlyrae/data/lc_{0}.dat".format(name.replace('l','L'))
    lc = np.genfromtxt(path, names=True, dtype=None, skiprows=20)
    lc = lc[(lc['filterID'] == 2) & (lc['sextractorFlags'] == 0) & (lc['magerr'] < 0.15)]
    
    col[1].set_xlabel('Phase')

    phase = ((lc['epoch'] - info['hjd0'] + 0.5) % info['period']) / info['period']
#     if '10' in name:
#         phase = ((lc['epoch'] - info['hjd0'] + 0.08) % info['period']) / info['period']
    col[1].errorbar(phase, lc['mag'], lc['magerr'], linestyle='none', 
                    ecolor='#666666', marker='o', alpha=0.75, ms=4)

    axes[1,1].set_xlim(-0.02, 1.02)
axes[0,0].set_ylabel(r'$v_r$ [${\rm km~s}^{-1}$]')
axes[1,0].set_ylabel(r'$R$ [${\rm mag}$]')

# left column, top
axes[0,0].set_ylim(-300, -150)
axes[0,0].set_yticks([-160, -200, -240, -280])

# left column, bottom
axes[1,0].set_ylim(17.65, 16.75)
axes[1,0].set_yticks([17.5, 17.3, 17.1, 16.9])

# right column, top
axes[0,1].set_ylim(-275, -90)
# axes[0,1].set_yticks([-200, -240, -280, -320])

axes[1,1].set_ylim(18.4, 17.2)
axes[1,1].set_yticks([18.2, 17.9, 17.6, 17.3])

fig.tight_layout()
fig.subplots_adjust(hspace=0.)

fig.savefig("/Users/adrian/projects/triand-rrlyrae/plots/rv_lc.pdf")


TriAndRRl2: 2 measurements
[ 0.6043698]
[ 55763.907589]
TriAndRRl26: 2 measurements
[ 0.5281412]
[ 56232.636689]

In [ ]: