<jupyter_start><jupyter_text>Make Data Tables for the Paper<jupyter_code>res = pd.read_csv('results_40percent.csv')
res_tsquared = pd.read_csv('results_40_tsquared.csv')
# Table with uninformative results
for tab in ['full', 'just15']:
    if tab == 'full':
        last_row = len(res)
        filename = 'uninformative_FULL.tex'
    elif tab == 'just15':
        last_row = 15
        filename = 'uninformative.tex'

    with open('../paper/tables/' + filename, 'w') as fw:
        print(r'\begin{deluxetable*}{lllccccccccccccccccc}', file=fw)
        print(r'\tabletypesize{\scriptsize}', file=fw)
        print(r'\tablewidth{0pt}', file=fw)
        print(r'\tablecaption{Ninety Percent Credible Regions for Marginalized Model Parameters (Uninformative Prior)\label{tab:uninformative}}', file=fw)
        print(r'\tablehead{', file=fw)
        print(r'\colhead{}', file=fw)
        print(r'& \colhead{}', file=fw)
        print(r'& \colhead{}', file=fw)
        print(r'& \multicolumn{3}{c}{$t_\mathrm{rise}$\,(d)}', file=fw)
        print(r'& \colhead{}', file=fw)
        print(r'& \multicolumn{3}{c}{$\alpha_g$}', file=fw)
        print(r'& \colhead{}', file=fw)
        print(r'& \multicolumn{3}{c}{$\alpha_r$}', file=fw)
        print(r'& \colhead{}', file=fw)
        print(r'& \multicolumn{3}{c}{$\alpha_r - \alpha_g$}', file=fw)
        print(r'& \colhead{}', file=fw)
        print(r'& \colhead{} \\', file=fw)
        # top line
        print(r'\cline{4-6}', file=fw)
        print(r'\cline{8-10}', file=fw)
        print(r'\cline{12-14}', file=fw)
        print(r'\cline{16-18}', file=fw)
        # center lines
        
        
        print(r'\colhead{ZTF Name}', file=fw)
        print(r'& \colhead{TNS Name}', file=fw)
        print(r'& \colhead{$z$\tablenotemark{\scriptsize{a}}}', file=fw)
        print(r'& \colhead{5}', file=fw)
        print(r'& \colhead{50}', file=fw)
        print(r'& \colhead{95}', file=fw)
        print(r'& \colhead{}', file=fw)
        print(r'& \colhead{5}', file=fw)
        print(r'& \colhead{50}', file=fw)
        print(r'& \colhead{95}', file=fw)
        print(r'& \colhead{}', file=fw)
        print(r'& \colhead{5}', file=fw)
        print(r'& \colhead{50}', file=fw)
        print(r'& \colhead{95}', file=fw)
        print(r'& \colhead{}', file=fw)
        print(r'& \colhead{5}', file=fw)
        print(r'& \colhead{50}', file=fw)
        print(r'& \colhead{95}', file=fw)
        print(r'& \colhead{Reliable\tablenotemark{\scriptsize{b}}}', file=fw)
        print(r'& \colhead{Normal\tablenotemark{\scriptsize{c}}}', file=fw)
    # 
#         print('\colhead{Name}', file=fw)
#         print('& \colhead{(J2000.0)}', file=fw)
#         print('& \colhead{(J2000.0)}', file=fw)
#         print('& \colhead{Name}', file=fw)
#         print('& \colhead{Name}', file=fw)
#         print('& \colhead{by}', file=fw)
#         print('& \colhead{(mag)}', file=fw)
#         print('& \colhead{Type}', file=fw)
#         print('& \colhead{}', file=fw)
#         print(r'& \colhead{(JD$^\prime$)\tablenotemark{d}}', file=fw)
#         print('& \colhead{(mag)}', file=fw)
#         print('& \colhead{(mag)}', file=fw)
#         print(r'& \colhead{(JD$^\prime$)\tablenotemark{d}}', file=fw)
#         print('& \colhead{(mag)}', file=fw)
#         print('& \colhead{(mag)}', file=fw)
        print('}', file=fw)
    #     print('\decimalcolnumbers', file=fw)
        print('\startdata', file=fw)
        for index, row in res.sort_values('ztf_name').iloc[0:last_row].iterrows():
            dat_string = ''
            ztf_name = str(row.ztf_name)[2:-1]
            dat_string += '{} & '.format(ztf_name)
            this_sn = np.where(salt_df.name == ztf_name)
            tns_name = salt_df['TNS name'].iloc[this_sn].values[0]
            dat_string += '{} & '.format(tns_name[0:2]+'\,'+tns_name[2:])
            if salt_df.z_source.iloc[this_sn].values[0] == 'Msl':
                dat_string += '{:.3f} & '.format(salt_df.z_adopt.iloc[this_sn].values[0])
            else:
                dat_string += '{:.4f} & '.format(salt_df.z_adopt.iloc[this_sn].values[0])
            dat_string += '{:.2f} & '.format(row.t_rise_05)
            dat_string += '{:.2f} & '.format(row.t_rise_50)
            dat_string += '{:.2f} & '.format(row.t_rise_95)
            dat_string += ' & '
            dat_string += '{:.2f} & '.format(row.flat_alpha_g_95)
            dat_string += '{:.2f} & '.format(row.flat_alpha_g_50)
            dat_string += '{:.2f} & '.format(row.flat_alpha_g_05)
            dat_string += ' & '
            dat_string += '{:.2f} & '.format(row.flat_alpha_r_95)
            dat_string += '{:.2f} & '.format(row.flat_alpha_r_50)
            dat_string += '{:.2f} & '.format(row.flat_alpha_r_05)
            dat_string += ' & '
            dat_string += '{:.2f} & '.format(row.flat_delta_95)
            dat_string += '{:.2f} & '.format(row.flat_delta_50)
            dat_string += '{:.2f} & '.format(row.flat_delta_05)
            if row.final_selection == 1:
                dat_string += r'y &'
            elif row.final_selection == 0:
                dat_string += r'n &'
            if (salt_df['Ia subtype'].iloc[this_sn].values[0] == 'normal' or
                salt_df['Ia subtype'].iloc[this_sn].values[0] == 'normal*' or
                salt_df['Ia subtype'].iloc[this_sn].values[0] == '99aa-like' or
                salt_df['Ia subtype'].iloc[this_sn].values[0] == '99aa-like*' or
                salt_df['Ia subtype'].iloc[this_sn].values[0] == '91T-like' or
                salt_df['Ia subtype'].iloc[this_sn].values[0] == '91T-like*'
               ):
                dat_string += r'y \\'
            else:
                dat_string += r'n \\'
                

            print(dat_string, file=fw)
        print(r'\enddata', file=fw)
        print(r'\tablecomments{', file=fw)

        print(r'''The table includes the $5^\mathrm{th}$, $50^\mathrm{th}$, 
and $95^\mathrm{th}$ percentiles for the four parameters of interest: 
$t_\mathrm{rise}$, $\alpha_g$, $\alpha_r$, $\alpha_r - \alpha_g$. 
The 90\% credible regions are obtained by subtracting the $5^\mathrm{th}$ percentile 
from the $95^\mathrm{th}$ percentile. Estimates for $t_\mathrm{rise}$ come from 
$t_\mathrm{fl}$ while accounting for the uncertainties on $t_{B,\mathrm{max}}$, 
while estimates for the $\alpha$ parameters have been corrected to a flat prior
(see text for further details).}
''', file=fw)
        print(r'''\tablenotetext{a}{Redshifts are reported to four decimal places, 
if the SN host galaxy redshift ($z_\mathrm{host}$) is known. 
Otherwise, the SN redshift ($z_\mathrm{SN}$) is reported to three decimal places; 
see \citet{Yao19} for further details.}''', file=fw)
        print(r'''\tablenotetext{b}{Flag for SNe with reliable model parameters (see \ref{sec:qa}):  
y = reliable group, and n = unreliable group (see text).}''', file=fw)
        print(r'''\tablenotetext{c}{Flag for normal SNe\,Ia:
y = normal, and n = peculiar (the seven peculiar SNe Ia in our sample are discussed in \ref{sec:rare}; their rise times are measured relative to $T_{g,\mathrm{max}}$).}''', file=fw)
        print(r'''(This table is available in its entirety in a machine-readable 
form in the online journal.)''', file=fw)

        
        
#         print(r'\tablenotetext{c}{Determined from \texttt{SNID} (see text).}', file=fw)
#         print(r'\tablenotetext{d}{JD$^\prime$ = JD $-$ 2,458,000.}', file=fw)
        print(r'\end{deluxetable*}', file=fw)
# Table with alpha=2 results
for tab in ['full', 'just15']:
    if tab == 'full':
        last_row = len(res)
        filename = 'alpha2_FULL.tex'
    elif tab == 'just15':
        last_row = 15
        filename = 'alpha2.tex'

    with open('../paper/tables/' + filename, 'w') as fw:
        print(r'\begin{deluxetable}{llcccc}', file=fw)
        print(r'\tabletypesize{\scriptsize}', file=fw)
        print(r'\tablewidth{0pt}', file=fw)
        print(r'\tablecaption{Ninety Percent Credible Region for $t_\mathrm{rise}$ ($\alpha = 2$ Prior)\label{tab:alpha2_rise}}', file=fw)
        print(r'\tablehead{', file=fw)
        print(r'\colhead{}', file=fw)
        print(r'& \colhead{}', file=fw)
        print(r'& \multicolumn{3}{c}{$t_\mathrm{rise}$\,(d)}', file=fw)
        print(r'& \colhead{} \\', file=fw)
        # top line
        print(r'\cline{3-5}', file=fw)
        # center lines
        
        
        print(r'\colhead{ZTF Name}', file=fw)
        print(r'& \colhead{TNS Name}', file=fw)
        print(r'& \colhead{5}', file=fw)
        print(r'& \colhead{50}', file=fw)
        print(r'& \colhead{95}', file=fw)
        print(r'& \colhead{Reliable\tablenotemark{\scriptsize{a}}}', file=fw)
        print('}', file=fw)
        print('\startdata', file=fw)
        for index, row in res_tsquared.sort_values('ztf_name').iloc[0:last_row].iterrows():
            dat_string = ''
            ztf_name = str(row.ztf_name)[2:-1]
            dat_string += '{} & '.format(ztf_name)
            this_sn = np.where(salt_df.name == ztf_name)
            tns_name = salt_df['TNS name'].iloc[this_sn].values[0]
            dat_string += '{} & '.format(tns_name[0:2]+'\,'+tns_name[2:])
            dat_string += '{:.2f} & '.format(row.t_rise_05)
            dat_string += '{:.2f} & '.format(row.t_rise_50)
            dat_string += '{:.2f} & '.format(row.t_rise_95)
            if row.final_selection == 1:
                dat_string += r'y \\'
            elif row.final_selection == 0:
                dat_string += r'n \\'
                

            print(dat_string, file=fw)
        print(r'\enddata', file=fw)
        print(r'\tablecomments{', file=fw)

        print(r'''The table includes the $5^\mathrm{th}$, $50^\mathrm{th}$, 
and $95^\mathrm{th}$ percentiles for  
$t_\mathrm{rise}$ after adopting the $\alpha = 2$ prior (see text for further details).}
''', file=fw)
        print(r'''\tablenotetext{a}{Flag for SNe with reliable model parameters.
Note that the $\alpha = 2$ prior definition of reliable differs from that in 
\ref{sec:qa} (see text).}''', file=fw)
        print(r'''(This table is available in its entirety in a machine-readable 
form in the online journal.)''', file=fw)
#         print(r'\tablenotetext{c}{Determined from \texttt{SNID} (see text).}', file=fw)
#         print(r'\tablenotetext{d}{JD$^\prime$ = JD $-$ 2,458,000.}', file=fw)
        print(r'\end{deluxetable}', file=fw)
with open('../paper/tables/mean_parameters.tex', 'w') as fw:
    print(r'\begin{deluxetable*}{lrcccccccccrcc}', file=fw)
    print(r'\tabletypesize{\scriptsize}', file=fw)
    print(r'\tablewidth{0pt}', file=fw)
    print(r'\tablecaption{Population Mean and Scatter For $t_\mathrm{rise}$ and $\alpha$\label{tab:mean_params}}', file=fw)
    print(r'\tablehead{', file=fw)
    print(r'\colhead{}', file=fw)
    print(r'& \colhead{}', file=fw)
    print(r'& \multicolumn{8}{c}{Uninformative Prior}', file=fw)
    print(r'& \colhead{}', file=fw)
    print(r'& \multicolumn{3}{c}{$\alpha = 2$ Prior} \\', file=fw)
    # top line
    print(r'\cline{2-10}', file=fw)
    print(r'\cline{12-14}', file=fw)
    # center lines
    print(r'\colhead{}', file=fw)
    print(r'& \colhead{}', file=fw)
    print(r'& \colhead{$t_\mathrm{rise}$}', file=fw)
    print(r'& \colhead{$\sigma_{t_\mathrm{rise}}$}', file=fw)
    print(r'& \colhead{}', file=fw)
    print(r'& \colhead{}', file=fw)
    print(r'& \colhead{}', file=fw)
    print(r'& \colhead{}', file=fw)
    print(r'& \colhead{}', file=fw)
    print(r'& \colhead{}', file=fw)
    print(r'& \colhead{}', file=fw)
    print(r'& \colhead{}', file=fw)
    print(r'& \colhead{$t_\mathrm{rise}$}', file=fw)
    print(r'& \colhead{$\sigma_{t_\mathrm{rise}}$} \\', file=fw)

    
    
    
    print(r'\colhead{Subset}', file=fw)
    print(r'& \colhead{N}', file=fw)
    print(r'& \colhead{(d)}', file=fw)
    print(r'& \colhead{(d)}', file=fw)
    print(r'& \colhead{$\alpha_g$}', file=fw)
    print(r'& \colhead{$\sigma_{\alpha_g}$}', file=fw)
    print(r'& \colhead{$\alpha_r$}', file=fw)
    print(r'& \colhead{$\sigma_{\alpha_r}$}', file=fw)
    print(r'& \colhead{$\alpha_r - \alpha_g$}', file=fw)
    print(r'& \colhead{$\sigma_{\alpha_r - \alpha_g}$}', file=fw)
    print(r'& \colhead{}', file=fw)
    print(r'& \colhead{N}', file=fw)
    print(r'& \colhead{(d)}', file=fw)
    print(r'& \colhead{(d)}', file=fw)
    print('}', file=fw)
    print('\startdata', file=fw)
    print(r'Normal &                    120 & $ 17.92\pm0.04 $ & 1.81 & $ 1.89\pm0.02 $ & 0.75 & $ 1.73\pm0.02 $ & 0.80 & $ -0.18\pm0.01 $ & 0.73 && 120 & $ 21.59\pm0.02 $ & 1.89 \\', file=fw)
    print(r'Reliable &                   47 & $ 18.53\pm0.05 $ & 1.62 & $ 2.05\pm0.02 $ & 0.53 & $ 1.89\pm0.02 $ & 0.50 & $ -0.17\pm0.01 $ & 0.23 && 115 & $ 21.59\pm0.02 $ & 1.90 \\', file=fw)
    print(r'Reliable-$z_\mathrm{host}$ & 25 & $ 18.73\pm0.05 $ & 1.85 & $ 2.12\pm0.02 $ & 0.59 & $ 1.99\pm0.03 $ & 0.54 & $ -0.18\pm0.02 $ & 0.17 &&  58 & $ 21.54\pm0.02 $ & 2.09 \\', file=fw)
    print('\hline',file=fw)
    print(r'\multicolumn{14}{c}{Volume-limited ($z < 0.06$) subset} \\',file=fw)
    print('\hline',file=fw)
    print(r'Normal &                     28 & $ 18.61\pm0.05 $ & 2.26 & $ 2.05\pm0.03 $ & 0.76 & $ 1.95\pm0.03 $ & 0.67 & $ -0.21\pm0.01 $ & 0.86 && 28 & $ 21.68\pm0.02 $ & 1.53 \\', file=fw)
    print(r'Reliable &                   16 & $ 18.91\pm0.05 $ & 1.75 & $ 2.13\pm0.03 $ & 0.54 & $ 2.01\pm0.03 $ & 0.52 & $ -0.18\pm0.02 $ & 0.08 && 27 & $ 21.68\pm0.02 $ & 1.51 \\', file=fw)
    print(r'Reliable-$z_\mathrm{host}$ & 15 & $ 18.95\pm0.05 $ & 1.71 & $ 2.14\pm0.03 $ & 0.51 & $ 2.02\pm0.03 $ & 0.50 & $ -0.18\pm0.02 $ & 0.09 && 24 & $ 21.67\pm0.02 $ & 1.56 \\', file=fw)
    print(r'DIC preferred &  & $ \ldots $ & $ \ldots $ & $ \ldots $ & $ \ldots $ & $ \ldots $ & $ \ldots $ & $ \ldots $ & $ \ldots $              && 28 & $ 19.87\pm0.03 $ & 1.46 \\', file=fw)
    print(r'DIC--uninformative &          9 & $ 19.20\pm0.06 $ & 1.38 & $ 2.14\pm0.03 $ & 0.55 & $ 2.02\pm0.03 $ & 0.52 & $ -0.19\pm0.02 $ & 0.08 && $ \ldots $ & $ \ldots $ & $ \ldots $ \\', file=fw)
    print(r'\enddata', file=fw)
    print(r'\tablecomments{', file=fw)

    print(r'''Table includes the weighted mean (see text), plus standard uncertainty in the weighted mean, 
as well as the scatter (the sample standard deviation), for the four parameters of interest, 
$t_\mathrm{rise}$, $\alpha_g$, $\alpha_r$, $\alpha_r - \alpha_g$, for the uninformative 
and $\alpha = 2$ priors. $N$ is the number of SNe in each subset of the data, which are defined as follows 
(see text for more detailed definitions):
normal -- normal SNe\,Ia; 
reliable -- SNe with reliable model parameters; 
reliable-$z_\mathrm{host}$ -- reliable SNe with known host galaxy redshifts; 
DIC preferred -- results from the $\alpha = 2$ prior, 
\textit{unless the DIC prefers the uninformative prior} (see \S\ref{sec:dic}; only applies to $t_\mathrm{rise}$);
DIC--uninformative -- only SNe where the DIC prefers the uninformative prior 
(see \S\ref{sec:dic}; excludes the $\alpha = 2$ prior by construction).
The volume-limited subset includes only SNe with $z < 0.06$ (see \S\ref{sec:volume_limited}).
Note that the  definition of reliable differs for the uninformative and $\alpha = 2$ priors; 
see \ref{sec:qa} and \S\ref{sec:strong_priors}, respectively.
}
''', file=fw)
#     print(r'''\tablenotetext{a}{Flag for SNe with reliable model parameters.
# Note that the $\alpha = 2$ prior definition of reliable differs from that in 
# \ref{sec:qa} (see text).}''', file=fw)
#         print(r'\tablenotetext{c}{Determined from \texttt{SNID} (see text).}', file=fw)
#         print(r'\tablenotetext{d}{JD$^\prime$ = JD $-$ 2,458,000.}', file=fw)
    print(r'\end{deluxetable*}', file=fw)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.20375759109311742, 'fraction_numerical': 0.03688006072874494, 'mean_word_length': 2.7066822977725673, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '310772', 'license': 'MIT', 'n_tokens_mistral': 6255, 'n_tokens_neox': 5910, 'n_words': 1156, 'path': 'playground/MakeTables.ipynb', 'repo_name': 'adamamiller/ztf_early_Ia_2018', 'size': '15808'}