Waveform analysis - final ranks

In [1]:
import pandas as pd
import matplotlib.pyplot as plt

loglist = ['log_'+nome+'.csv' for nome in ['valerio','alessiaS', 'edoardo', 'Silvia', 'Magda', 'Damiano', 'Andrea', 'Martino', 'Maria1', 'Maria2'] ]


dflist=[]
for file in loglist :
    dftemp = pd.read_csv(file, 
                         names = ['name','filename', 'nsim', 'nfound', 'dcor', 'cor', 'invcor', 'eff98', 'eff5ns'],
                         header=None)
    dflist.append(dftemp)
    
df = pd.concat(dflist, ignore_index=True)
df['type'] = df.filename.apply(lambda x : x.split('/')[-1].split('_')[0][:-3])
df['tau'] = df.filename.apply(lambda x : int(x.split('/')[-1].split('_')[0][-3:]))
df['shortname'] = df.name + '-' +df.type + '-' + df.tau.astype(str)
In [2]:
df
Out[2]:
name filename nsim nfound dcor cor invcor eff98 eff5ns type tau shortname
0 valerio output_from_course/valerio/expo100_out.npz 1000 865 0.480 0.625 0.768 23.0 89.3 expo 100 valerio-expo-100
1 valerio output_from_course/valerio/expo300_out.npz 1000 938 0.707 0.799 0.885 14.0 95.4 expo 300 valerio-expo-300
2 valerio output_from_course/valerio/expo500_out.npz 1000 955 0.819 0.868 0.943 7.0 97.9 expo 500 valerio-expo-500
3 valerio output_from_course/valerio/expo700_out.npz 1000 970 0.827 0.888 0.932 6.0 98.0 expo 700 valerio-expo-700
4 valerio output_from_course/valerio/expo900_out.npz 1000 967 0.804 0.875 0.919 8.0 97.3 expo 900 valerio-expo-900
... ... ... ... ... ... ... ... ... ... ... ... ...
145 Maria2 output_from_course/Maria2/poiss100_out.npz 1000 992 0.938 0.965 0.972 4.0 99.2 poiss 100 Maria2-poiss-100
146 Maria2 output_from_course/Maria2/poiss300_out.npz 1000 948 0.864 0.883 0.978 4.0 99.8 poiss 300 Maria2-poiss-300
147 Maria2 output_from_course/Maria2/poiss500_out.npz 1000 954 0.888 0.908 0.978 4.0 99.7 poiss 500 Maria2-poiss-500
148 Maria2 output_from_course/Maria2/poiss700_out.npz 1000 954 0.860 0.880 0.977 4.0 99.6 poiss 700 Maria2-poiss-700
149 Maria2 output_from_course/Maria2/poiss900_out.npz 1000 957 0.895 0.914 0.978 4.0 99.9 poiss 900 Maria2-poiss-900

150 rows × 12 columns

In [3]:
# color dictionary for the bar plot

colordict = {'valerio'    : 'deepskyblue',
             'alessiaS'   : 'gold',
             'edoardo'    : 'mediumpurple', 
             'Silvia'     : 'aquamarine',
             'Magda'      : 'mediumseagreen',
             'Damiano'    : 'lightsteelblue',
             'Andrea'     : 'orangered',
             'Martino'    : 'dodgerblue',
             'Maria1'     : 'yellowgreen',
             'Maria2'     : 'olivedrab'
            }
In [4]:
def dobarplot(a, param='dcor', asc=True, select='poiss') :
    subdf = df[df['type']==select]
    labels = subdf.sort_values([param], ascending=asc).shortname.values
    idx = range(len(labels))
    values = subdf.sort_values([param], ascending=asc)[param].values
    colorlist = [colordict.get(l.split('-')[0], 'grey')  for l in labels]
    a.set_title(param+' '+select, fontsize=16)
    a.barh(idx,values, tick_label=labels, color=colorlist)
    maxw = 0
    for b in a.patches:
        if b.get_width() > maxw :
            maxw = b.get_width()
       
    for i,bar in enumerate(a.patches):
        a.text(max(bar.get_width()-0.01, maxw*0.15),bar.get_y()+0.01,f'{values[i]:.3f}', fontsize=9, ha='right', va='bottom')
In [5]:
fig, ax = plt.subplots(1,3,figsize=(20,12))
plt.subplots_adjust(wspace = 0.4)

dobarplot(ax[0], 'dcor', select='poiss')
dobarplot(ax[1], 'dcor', select='flat')
dobarplot(ax[2], 'dcor', select='expo')
plt.show()
fig.savefig('finalbars.pdf')