<jupyter_start><jupyter_text>GTC spectrum plots<jupyter_code>%pylab inline
from scipy.ndimage import median_filter as mf
from itertools import chain
from src.core import *

sb.set_context('paper')
wlt, spt = loadtxt('data/spectra/N1_GTC_spectra_target.txt').T
wlr, spr = loadtxt('data/spectra/N1_GTC_spectra_reference.txt').T

wlt, wlr = 0.1*wlt, 0.1*wlr
with sb.axes_style('ticks'):
    fig, ax = subplots(figsize=(AAOCW, 0.65*AAOCW))
    ax.plot(wlt, N(spt) + 1.3, lw=1)
    ax.plot(wlr, N(spr), lw=1)
    ax.text(950, 1.95, 'WASP-80', color=cp[0])
    ax.text(950, 0.7, 'Comparison', color=cp[1])
setp(ax, ylabel = 'Normalised flux', xlabel='Wavelength [nm]')
sb.despine(fig)
fig.tight_layout()
fig.savefig('plots/pub_spectra.pdf')
with sb.axes_style('ticks'):
    fig, ax = subplots(2, 1, figsize=(AAOCW, 0.85*AAOCW))
    [ax[0].plot(wlt, f(wlt)*N(spt), lw=1, c=c_ob, alpha=0.25) for f in pb_filters_nb]
    [ax[0].fill_between(wlt, f(wlt)*N(spt), lw=1, edgecolor=c_ob, facecolor='w', zorder=100) for f in pb_filters_na]
    ax[0].text(0.05, 0.95, 'Na I', va='top', transform=ax[0].transAxes, bbox=dict(facecolor='w', edgecolor='w'))
    [ax[1].plot(wlt, f(wlt)*N(spt), lw=1, c=c_ob, alpha=0.25) for f in pb_filters_nb]
    [ax[1].fill_between(wlt, f(wlt)*N(spt), lw=1, edgecolor=c_ob, facecolor='w', zorder=100) for f in pb_filters_k]
    ax[1].text(0.05, 0.95, 'K I', va='top', transform=ax[1].transAxes, bbox=dict(facecolor='w', edgecolor='w'))
    [[a.axvline(l, lw=1, c=c_ob, ls='--', alpha=0.5, zorder=101) for l in chain(wlc_k, wlc_na)] for a in ax]
    
setp(ax[0], yticks=[], xlim=(559,621), ylim=(0,1.8))
setp(ax[1], xlabel='Wavelength [nm]', yticks=[], xlim=(735,797))
sb.despine(fig, left=True)
fig.tight_layout()
fig.savefig('plots/pub_pb_na_and_k.pdf')
dfs = [pd.merge(pd.read_hdf('data/aux.h5','night%i'%night),
              pd.read_hdf('results/gtc_light_curves_gc.h5','night%i'%night),
              left_index=True, right_index=True) for night in [1,2]]
cols =  [[c for c in df.columns if 'relative_nb' in c] for df in dfs]
cref = [[c for c in df.columns if 'comparison_nb' in c] for df in dfs]
ctrg = [[c for c in df.columns if 'target_nb' in c] for df in dfs]
with sb.axes_style('ticks'):
    fig, ax = subplots(2, 1, figsize=(AAOCW, 1.5*AAOCW), sharey=True)
    for inight,df in enumerate(dfs):
        time = df.bjd_aux.values - 2456855
        fref = N(df[cref[inight]].mean(1).values)
        mref = (abs(fref-mf(fref, 7)) < 0.001)
        if inight == 0:
            mref &= fref > 0.9855
        ftrg = N(df[ctrg[inight]].mean(1).values)
        mtrg = abs(ftrg-mf(ftrg, 5)) < 0.005
        mtrg= ones(ftrg.size, bool)
        ax[inight].plot(time, where(mref, fref+0.04, nan), '.')
        ax[inight].plot(time, where(mtrg, ftrg, nan), '.')
        ax[inight].plot(time, where(mtrg&mref, ftrg/fref-0.04, nan), '.')
        setp(ax[inight], xlim=time[[0,-1]])
        ax[inight].set_title('Run %i'%(inight+1))
setp(ax, ylim=(0.92,1.065), xlabel='BJD - 2456855')
setp(ax[0], ylabel='Normalised flux')
sb.despine(offset=10)
fig.tight_layout()
fig.savefig('plots/pub_white_lcs.pdf')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.19936305732484078, 'fraction_numerical': 0.048089171974522296, 'mean_word_length': 4.296795952782462, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 6, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '134449', 'license': 'MIT', 'n_tokens_mistral': 1491, 'n_tokens_neox': 1405, 'n_words': 262, 'path': 'notebooks/02_gtc_analysis/03b_publication_plots.ipynb', 'repo_name': 'hpparvi/Parviainen-2017-WASP-80b', 'size': '3140'}