コード例 #1
0
                    chi2_minimum=cw.get_min_reference(filename)
                    if chi2_minimum==1e9:
                        chi2_minimum=layer_options.get('chi2_minimum',numpy.min(plot))
                    plot=plot-chi2_minimum
                #for the contours, set 'empty' points to chi2=100
                plot[entries_plot==-1]=100
                #we want control over the segments, 
                #so we delete the contours for the plot and plot the segments individually
                cs=axes.contour(X,Y,plot,levels=levels)
                allsegs=cs.allsegs
                for level, color, alpha, linewidth in zip(allsegs, colors, 
                        alphas, linewidths):
                    for segment in level:
                        if len(segment)>layer_options.get('min_segment_length',0):
                            linestyle=layer_options.get('contour_linestyle')
                            axes.plot(segment[:,0],segment[:,1], c=color, 
                                    linewidth=linewidth, linestyle=linestyle, alpha=alpha)
                for coll in cs.collections:
                    coll.remove()
            if layer_options.get('plot_chi2_minimum',False):
                fill_color=layer_options.get('chi2_minimum_fill_color')
                edge_color=layer_options.get('chi2_minimum_edge_color')
                alpha=layer_options.get('chi2_minimum_alpha', 1.0)
#                rowid = cw.get_min_reference_rowid(filename)
#                if rowid==-1:
#                    id=numpy.where((plot==numpy.min(plot)) & (entries_plot!=-1))
#                else:
#                    id=numpy.where(entries_plot==rowid)
                chi2_overflow_edges = cw.get_2d_overflow_edges(filename,
                        chi2_plotname, nxbins,nybins)
                chi2_plot_min = numpy.min(chi2_plot)
                minimum_is_in_plot = True
コード例 #2
0
 filenames, plotnames, layers_options = layers_details
 for filename, plotname, layer_options in zip(filenames, plotnames, layers_options):
     plot=cw.get_1d_hist(filename,plotname,nxbins)
     entries_plotname='{}_entries'.format(xaxis_details['name'])
     entries_plot=cw.get_1d_hist(filename,entries_plotname,nxbins)
     if layer_options.get('dchi2_mode',False):
         #chi2_minimum=cw.get_min_reference(filename)
         chi2_minimum = cw.get_1d_minimum(filename,plotname,nxbins)
         if chi2_minimum==1e9:
             chi2_minimum=layer_options.get('chi2_minimum',numpy.min(plot))
         plot=plot-chi2_minimum
     color=layer_options.get('color')
     linestyle=layer_options.get('linestyle')
     linewidth=layer_options.get('linewidth',2)
     label = layer_options.get('label')
     axes.plot(bin_centres,plot,linewidth=linewidth,c=color,
             linestyle=linestyle)
     #FIXME: maybe ylim shouldn't be a property of the layer
     axes.set_ylim([layer_options.get('ymin',0),layer_options.get('ymax',9)])
     axes.set_ylabel(layer_options.get('ylabel',''),fontsize=20)
     #FIXME: this is an ugly way to get the 95% CL lower limit out
     if figure_options.get('chi2_eq_4_limit'):
         f=scipy.interpolate.interp1d(bin_centres,plot)
         xnew=numpy.linspace(bin_centres[0],bin_centres[-1],1000)
         ynew=f(xnew)
         try:
             for i in range(999):
                 if ynew[i]>4 and ynew[i+1]<4:
                     print('{}:{}'.format(xaxis_details['name'],int(xnew[i+1])))
             axes.plot(xnew[i+1],ynew[i+1],'o')
         except IndexError:
             print('limit not found for {}'.format(xaxis_details['name']))