示例#1
0
def plt_v_vs_u(V, U, Vnbins, Unbins, Vrange, Urange , Vname='', Uname=''):
    c = hst.Canvas(1, 2)
    hst.hist2d(U, V, (Unbins, Vnbins), (Urange, Vrange), canvas=c(1), xylabels=(Uname, Vname));
    xs, ys, eys = fitf.profileX(U, V, Unbins, xrange=Urange)
    hst.errorbar(xs, ys, yerr=eys, fmt='*', canvas=c(1), c='black')
    ymean = np.mean(ys)
    hst.hist(100.*ys/ymean, 20, canvas=c(2), xylabels=(' deviation ratio (%)', ''));
    return c
示例#2
0
def var(tab, names, nbins=100):

    n = int(len(names) / 2) + 1
    c = hst.Canvas(n, 2)
    for i, name in enumerate(names):
        hst.hist(getattr(tab, name),
                 nbins,
                 canvas=c(i + 1),
                 xylabels=(name, ''))
    return
示例#3
0
def df(df):
    cols = df.columns
    ncols = len(cols)
    c = hst.Canvas(ncols, 1)
    for i, col in enumerate(cols):
        colname = str(col)
        hst.hist(df[colname], 100, canvas=c(i + 1))
        plt.xlabel(colname)
        plt.grid()
    plt.tight_layout()
    return
示例#4
0
def plt_xymap(x, y, xymap, mask, vbins, vrange, label = ''):
    """ plot the xymap, the histogram of the values and the xymap
    """
    ok = mask
    c = hst.Canvas(1, 2)
    hst.hist(xymap[ok].flatten(), vbins, vrange, canvas=c(1), xylabels=(label, ''))
    hst.display_matrix(x, y, xymap, canvas=c(2),
                       cmin = vrange[0], cmax = vrange[1], cmap=cmap_default,
                       xylabels = ('x (mm)', 'y (mm)', label))
    plt.clim(*vrange)
    plt.tight_layout()
    return c
示例#5
0
def ratio(tab, pair_names, nbins=100):
    n = len(pair_names)
    c = hst.Canvas(n, 2)
    for i, pair_name in enumerate(pair_names):
        n1, n2 = pair_name
        v1, v2 = getattr(tab, n1), getattr(tab, n2)
        c(2 * i + 1)
        plt.scatter(v1, v2)
        tsel = abs(v1) > 0
        hst.hist(v2[tsel] / v1[tsel],
                 nbins,
                 canvas=c(2 * i + 2),
                 xylabels=(n2 + '/' + n1, ''))
    return
示例#6
0
def plt_var_xymap_wslice(V, X, Y, W, Vnbins, Vrange, XYnbins, XYrange, Wnbins, Wrange, label = ''):
    """ plot the XY map of a variable V in slices of second W variable. Vrange fix the range of the xymap
    """
    vmin, vmax = Vrange
    c = hst.Canvas(Vnbins/2, Vnbins/2)
    zzs = np.linspace(Wrange[0], Wrange[1], Wnbins+1)
    for ii in range(len(zzs)-1):
        sel = in_range(W, zzs[ii], zzs[ii+1])
        x, y, z, uz = fitf.profileXY(X[sel], Y[sel], V[sel], XYnbins, XYnbins,
                                     xrange=XYrange, yrange=XYrange)
        hst.display_matrix(x, y, z, cmap = default_cmap, canvas=c(ii+1), vmin = vmin, vmax=vmax,
                           xylabels=('x (mm)', 'y (mm)', label+ ' in ['+str(zzs[ii])+', '+str(zzs[ii+1])+']') );
        plt.tight_layout()
    return c
示例#7
0
def plt_lt_vs_t_vs_v(fs, Vbins, Tcenters, Vname):
    """ plot the lt vs t and a different variable V (i.e Radius)
    It takes fs that are the restuls of the fit in Time bins
    """
    c = hst.Canvas(1, 2)
    for i, fi in enumerate(fs):
        label = Vname + ' [' + str(Vbins[i]) + ', ' + str(Vbins[i+1]) + ']'
        lts  = [fij[1].value       for fij in fi]
        ults = [fij[1].uncertainty for fij in fi]
        e0s, ue0s = [fij[1].value for fij in fi], [fij[0].uncertainty for fij in fi]
        hst.errorbar(Tcenters, lts, ults, canvas = c(1), label = label, xylabels = ('time (h)', 'lt ($\mu$s)'))
        plt.gca().legend()
        hst.errorbar(Tcenters, e0s, ue0s, canvas = c(2), label = label, xylabels = ('time (h)', 'e0 (pes)'))
        plt.gca().legend()
    plt.tight_layout()
    return
示例#8
0
def plt_entries_xymap_wslice(X, Y, W, XYnbins, XYrange, Wnbins, Wrange, Crange, vname = ''):
    """ plot the number of entries in a XY map in slices of W variable,
    Crange fix the range of events of the xymap
    """
    wmin, wmax = Wrange
    c = hst.Canvas(Wnbins/2, Wnbins/2)
    zzs = np.linspace(wmin, wmax, Wnbins+1)
    for ii in range(len(zzs)-1):
        sel = in_range(W, zzs[ii], zzs[ii+1])
        hst.hist2d(X[sel], Y[sel], (XYnbins, XYnbins), (XYrange, XYrange),
                    cmap = cmap_default, canvas = c(ii+1),
                    xylabels = ('x (mm)', 'y (mm)',
                               'evts '+vname+' in ['+str(zzs[ii])+', '+str(zzs[ii+1])+']') );
        plt.colorbar().set_label("Number of events")
        plt.clim(*Crange)
        plt.tight_layout()
    return c
示例#9
0
def graph_event(x, y, z, ene, scale=0.1, comment=''):
    c = hst.Canvas(2, 2)
    from mpl_toolkits.mplot3d import Axes3D
    fig = plt.gcf()
    ax3D = fig.add_subplot(221, projection='3d')
    p3d = ax3D.scatter(z, x, y, s=scale * ene, c=ene, alpha=0.4, marker='o')
    ax3D.set_xlabel('z (mm)')
    ax3D.set_ylabel('x (mm)')
    ax3D.set_zlabel('y (mm)')
    plt.title(comment)
    hst.scatter(x,
                z,
                c=ene,
                s=scale * ene,
                alpha=0.2,
                canvas=c(2),
                cmap='jet',
                xylabels=('x (mm)', 'z (mm)'))
    plt.colorbar()
    hst.scatter(z,
                y,
                c=ene,
                s=scale * ene,
                alpha=0.2,
                canvas=c(3),
                cmap='jet',
                xylabels=('z (mm)', 'y (mm)'))
    plt.colorbar()
    hst.scatter(x,
                y,
                c=ene,
                s=scale * ene,
                alpha=0.2,
                canvas=c(4),
                cmap='jet',
                xylabels=('x (mm)', 'y (mm)'))
    plt.colorbar()
    plt.tight_layout()
    return