Esempio n. 1
0
def fig_plot_marginal_2d(x, k1, k2, keys, ax, i, nbins, color):
    a = phsp.fig_get_sub_fig(ax, i)
    index1 = keys.index(k1)
    d1 = x[:, index1]
    index2 = keys.index(k2)
    d2 = x[:, index2]
    label = '{} {}'.format(k1, k2)

    ptype = 'scatter'
    # ptype = 'hist'

    if ptype == 'scatter':
        a.scatter(d1, d2, color=color, alpha=0.25, edgecolor='none', s=1)

    if ptype == 'hist':
        cmap = plt.cm.Greens
        if color == 'r':
            cmap = plt.cm.Reds
        a.hist2d(d1, d2, bins=(nbins, nbins), alpha=0.5, cmap=cmap)

    if ptype == 'density':
        x = d1
        y = d2
        print('kde')
        k = kde.gaussian_kde([x, y])
        xi, yi = np.mgrid[x.min():x.max():nbins * 1j,
                          y.min():y.max():nbins * 1j]
        zi = k(np.vstack([xi.flatten(), yi.flatten()]))
        a.pcolormesh(xi, yi, zi.reshape(xi.shape), alpha=0.5)

    a.set_xlabel(k1)
    a.set_ylabel(k2)
Esempio n. 2
0
def fig_plot_marginal(x, k, keys, ax, i, nb_bins, color, r=''):
    a = phsp.fig_get_sub_fig(ax, i)
    index = keys.index(k)
    if len(x[0]) > 1:
        d = x[:, index]
    else:
        d = x
    label = ' {} $\mu$={:.2f} $\sigma$={:.2f}'.format(k, np.mean(d), np.std(d))
    if r != '':
        a.hist(d,
               nb_bins,
               density=True,
               histtype='stepfilled',
               facecolor=color,
               alpha=0.5,
               range=r,
               label=label)
    else:
        a.hist(d,
               nb_bins,
               density=True,
               histtype='stepfilled',
               facecolor=color,
               alpha=0.5,
               label=label)
    a.set_ylabel('Counts')
    a.legend()
Esempio n. 3
0
def analyse_one_curve(ax, i, folder, previous_folder, filename):
    a = phsp.fig_get_sub_fig(ax, i)
    f = os.path.join(folder, filename)
    plot_edep(f, a)
    if previous_folder:
        previous_filename = os.path.join(previous_folder, filename)
        r = gamma_index(a, f, previous_filename)
        return r
    return True
Esempio n. 4
0
def analyse_one_curve(ax, i, folder, previous_folder, filename, subType):
    a = phsp.fig_get_sub_fig(ax, i)
    filename = filename + '-' + subType + '.mhd'
    f = os.path.join(folder, filename)
    if subType != 'Edep':
        plot_edep(f, a, subType + ' [MeV]')
    else:
        plot_edep(f, a, 'LET ' + subType + ' [keV/um]')
    if previous_folder and (subType != 'Edep'):
        # print('Found previous folder:', previous_folder)
        previous_filename = os.path.join(previous_folder, filename)
        r = gamma_index(a, f, previous_filename)
        return r
    return True
Esempio n. 5
0
def plot_all(output_folders, filename, ax, i, axis1, axis2):
    a = phsp.fig_get_sub_fig(ax,i)
    a.set_title(filename)
    for o in output_folders:
        plot(o, a, filename, axis1, axis2)
    return i+1