def compute_sigma_level(trace1, trace2, nbins=20):
 (L, xbins, ybins) = np.histogram2d(trace1, trace2, nbins)
 L[(L == 0)] = 1e-16
 logL = np.log(L)
 shape = L.shape
 L = L.ravel()
 i_sort = np.argsort(L)[::(-1)]
 i_unsort = np.argsort(i_sort)
 L_cumsum = L[i_sort].cumsum()
 L_cumsum /= L_cumsum[(-1)]
 xbins = (0.5 * (xbins[1:] + xbins[:(-1)]))
 ybins = (0.5 * (ybins[1:] + ybins[:(-1)]))
 return (xbins, ybins, L_cumsum[i_unsort].reshape(shape))

def compute_sigma_level ( trace1 , trace2 , nbins = 20 ) : ( L , xbins , ybins ) = np . histogram2d ( trace1 , trace2 , nbins ) L [ ( L == 0 ) ] = 1e-16 logL = np . log ( L ) shape = L . shape L = L . ravel ( ) i_sort = np . argsort ( L ) [ : : ( - 1 ) ] i_unsort = np . argsort ( i_sort ) L_cumsum = L [ i_sort ] . cumsum ( ) L_cumsum /= L_cumsum [ ( - 1 ) ] xbins = ( 0.5 * ( xbins [ 1 : ] + xbins [ : ( - 1 ) ] ) ) ybins = ( 0.5 * ( ybins [ 1 : ] + ybins [ : ( - 1 ) ] ) ) return ( xbins , ybins , L_cumsum [ i_unsort ] . reshape ( shape ) )
from a set of traces .