예제 #1
0
         axes.set_xticks(numpy.arange(low,high*1.001,step))
     if axes_details[1].get('yticks',False) and binnings[1]['type']=='linear':
         low,high,step=binnings[1]['low'],binnings[1]['high'],axes_details[1]['yticks']
         axes.set_yticks(numpy.arange(low,high*1.001,step))
 text_box_options_list = figure_options.get('text_boxes',False)
 if isinstance(text_box_options_list, list):
     for text_box_options in text_box_options_list:
         args=text_box_options.get('args')
         kwargs={'verticalalignment':'top','transform':axes.transAxes,
                 'fontsize':20,'horizontalalignment':'left'}
         kwargs.update(text_box_options.get('kwargs',{}))
         axes.text(*args,**kwargs)
 #FIXME: there might be a better way of zipping an unzipping
 filenames, plotnames, layers_options, layers_zaxis = layers_details
 for filename, plotname, layer_options, layer_zaxis in zip(filenames, plotnames, layers_options, layers_zaxis):
     plot=cw.get_2d_hist(filename,plotname,nxbins,nybins)
     entries_plotname='{}_entries'.format('_'.join([axis['name'] for axis in axes_details]))
     entries_plot=cw.get_2d_hist(filename,entries_plotname,nxbins,nybins)
     chi2_plotname='{}_chi2'.format('_'.join([axis['name'] for axis in axes_details]))
     chi2_plot=cw.get_2d_hist(filename,chi2_plotname,nxbins,nybins)
     if layer_options.get('colz',False):
         #mask where rowid == -1 (not filled)
         plot=ma.masked_where(entries_plot==-1,plot)
         if layer_options.get('mask_dchi2_gt'):
             dchi2_max=layer_options.get('mask_dchi2_gt')
             chi2_minimum=cw.get_min_reference(filename)
             if chi2_minimum==1e9:
                 chi2_minimum=layer_options.get('chi2_minimum',numpy.min(chi2_plot))
             plot=ma.masked_where(chi2_plot>chi2_minimum+dchi2_max,plot)
         if layer_options.get('dchi2_mode',False):
             chi2_minimum=cw.get_min_reference(filename)
예제 #2
0
    entries_plot=cw.get_1d_hist(rootfile,'{}_entries'.format(plotname),nxbins)
    plt.plot(bin_centres[0],chi2_plot,'o')
    plt.ylim([vmin,vmax])
    if args.best_fit:
        chi2_min=numpy.min(chi2_plot)
        rowid=int(entries_plot[chi2_plot==numpy.min(chi2_plot)])
    else:
        [(x,y)]=plt.ginput(1)
        id=numpy.where(bin_edges[0]>x)[0][0]-1
        print('Clicked points: {}: {}  {}: {}'.format(axes[0],x,'chi2',y))
        rowid=int(entries_plot[id])

#get plots
elif len(axes)==2:
    nybins=binnings[0]['nbins']
    chi2_plot=cw.get_2d_hist(rootfile,'{}_chi2'.format(plotname),nxbins,nybins)
    entries_plot=cw.get_2d_hist(rootfile,'{}_entries'.format(plotname),nxbins,nybins)
    chi2_plot=ma.masked_where(entries_plot==-1,chi2_plot)
    ext=[binnings[0]['low'],binnings[0]['high'],binnings[1]['low'],binnings[1]['high']]
    if binnings[1]['type'] == 'log':
        plt.yscale('log')
    plt.imshow(chi2_plot,vmin=vmin,vmax=vmax,origin='lower',interpolation='nearest',extent=ext,aspect='auto')
    plt.colorbar()
    plt.ylabel(axes[1])
    #FIXME: the best fit point shouldn't come from a plane
    if  args.best_fit:
        chi2_min=numpy.min(chi2_plot)
        rowid=int(entries_plot[chi2_plot==numpy.min(chi2_plot)])
    else:
        [(x,y)]=plt.ginput(1)
        print('Clicked points: {}: {}  {}: {}'.format(axes[0],x,axes[1],y))