data_file = 'results/usALEX-5samples-PR-raw-dir_ex_aa-fit-AexAem.csv'

"""
Explanation: Executed: Mon Mar 27 11:38:35 2017
Duration: 3 seconds.
Direct ecitation coefficient fit

This notebook estracts the direct excitation coefficient from the set of 5 us-ALEX smFRET measurements.

What it does?
This notebook performs a weighted average of direct excitation coefficient fitted from each measurement.
Dependencies
This notebooks reads the file:
End of explanation
"""


from __future__ import division
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
%config InlineBackend.figure_format='retina'  # for hi-dpi displays

sns.set_style('whitegrid')
palette = ('Paired', 10)
sns.palplot(sns.color_palette(*palette))
sns.set_palette(*palette)

data = pd.read_csv(data_file).set_index('sample')
data

data.columns

d = data[[c for c in data.columns if c.startswith('dir')]]
d.plot(kind='line', lw=3, title='Direct Excitation Coefficient')
plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0., frameon=False);

dir_ex_aa = np.average(data.dir_ex_S_kde_w5, weights=data.n_bursts_aa)
'%.5f' % dir_ex_aa

"""
Explanation: The data has been generated by running the template notebook
usALEX-5samples-PR-raw-dir_ex_aa-fit-AexAem
for each sample.
To recompute the PR data used by this notebook run the 
8-spots paper analysis notebook.
Computation
End of explanation
"""


with open('results/usALEX - direct excitation coefficient dir_ex_aa.csv', 'w') as f:
    f.write('%.5f' % dir_ex_aa)

"""
Explanation: Save coefficient to disk
End of explanation
"""


