Ejemplo n.º 1
0
for j, (vov, flen) in enumerate(zip(afterpulse_tile21.AfterPulseTile21.defaultparams, length)):
    ap21 = afterpulse_tile21.AfterPulseTile21(vov)

    fig = plt.figure(num=f'figlaserpos2-{j}0', clear=True, figsize=[4.5, 3.5])

    ap21.sim.hist('mainpos-offset', 'mainnpe==1', fig=fig, selection=False)
    ax, = fig.get_axes()
    textbox.textbox(ax, f'{vov} VoV', fontsize='medium', loc='lower center')
    ax.set_xlabel('Laser peak position [ns]')

    row = [fig]

    fig = plt.figure(num=f'figlaserpos2-{j}1', clear=True, figsize=[4.5, 3.5])

    ap21.sim.hist2d('mainpos-offset', 'mainampl', f'(mainnpe==1)&(length=={flen})', fig=fig, cmap=colormap.uniform(), selection=False)
    ax, _ = fig.get_axes()
    textbox.textbox(ax, f'{vov} VoV', fontsize='medium', loc='lower center')
    textbox.textbox(ax, f'{flen} ns filter', fontsize='medium', loc='upper left')
    ax.set_xlabel('Laser peak position [ns]')
    ax.set_ylabel('Peak height')

    row.append(fig)
    
    figs.append(row)

for row in figs:
    for fig in row:
        fig.tight_layout()
        fig.show()
Ejemplo n.º 2
0
import figlatex
import hist2d
import colormap

commands = [
    '-m 100000 -L 860 -v 860 -l 8900 darksidehd/LF_TILE15_77K_73V_9VoV_1.wav',
    '-m 100000 -L 750 -v 750 -l 8900 darksidehd/nuvhd_lf_3x_tile57_77K_64V_6VoV_1.wav',
    '-m 100000 -L 750 -v 750 -l 8900 darksidehd/nuvhd_lf_3x_tile59_77K_64V_6VoV_1.wav',
]

###########################

figs = []

cmap = colormap.uniform()

for ifile, cmd in enumerate(commands):

    figname = f'fighist2dtile155759-{ifile}'
    fig = plt.figure(num=figname, clear=True, figsize=[9, 4])
    
    save = f'figthesis/{figname}.npz'
    if not os.path.exists(save):
        hist = hist2d.Hist2D(cmd.split())
        print(f'save {save}...')
        hist.save(save, compress=True)
    print(f'load {save}...')
    hist = hist2d.Hist2D.load(save)
    
    hist.hist2d(fig, cmap=cmap)
Ejemplo n.º 3
0
command = '-m 100000 -L 1 -t -l 500 darksidehd/nuvhd_lf_3x_tile57_77K_64V_6VoV_1.wav'

###########################

def naivelinear(colors=['black', '#f55', 'white'], N=256, return_pos=False):
    rgb0 = np.array([_colors.to_rgb(color) for color in colors])
    t0 = np.linspace(0, 1, len(rgb0))
    t = np.linspace(0, 1, N)
    rgb = interpolate.interp1d(t0, rgb0, axis=0)(t)
    rt = _colors.ListedColormap(rgb)
    if return_pos:
        rt = (rt, t0)
    return rt

cmap1 = naivelinear()
cmap2 = colormap.uniform()

figs = []

for ifile, cmap in enumerate([cmap1, cmap2]):

    figname = f'fighist2dtile57-cmap-{ifile}'
    fig = plt.figure(num=figname, clear=True, figsize=[9, 4])
    
    save = f'figthesis/{figname}.npz'
    if not os.path.exists(save):
        hist = hist2d.Hist2D(command.split())
        print(f'save {save}...')
        hist.save(save, compress=True)
    print(f'load {save}...')
    hist = hist2d.Hist2D.load(save)
Ejemplo n.º 4
0
prefix = 'nuvhd_lf_3x_tile57_77K_64V_6VoV_1'

###########################

templ = _template.Template.load('templates/' + prefix + '-template.npz')

signal_loc = np.linspace(0, 1, 3 * 8 + 1)
event_length = templ.template_length // 8 + int(np.max(np.ceil(signal_loc))) + 1
simulated_signal = templ.generate(event_length, signal_loc, randampl=False, aligned='trigger')

fig, ax = plt.subplots(num='figinterptempl', clear=True, figsize=[6.4, 4])

ax.set_xlabel('Sample number @ 125 MSa/s')

colors = colormap.uniform(['black', 'red'], len(signal_loc), (0, 60)).colors

for i in range(len(signal_loc)):
    kw = dict(
        label=f'{signal_loc[i]:.2f}',
        color=colors[i],
    )
    ax.plot(simulated_signal[i], **kw)

ax.legend(loc='upper right', title_fontsize='large', title='Signal start [sample]', ncol=4)

ax.set_xlim(7, 13)
ax.minorticks_on()
ax.grid(True, which='major', linestyle='--')
ax.grid(True, which='minor', linestyle=':')
Ejemplo n.º 5
0
    def snrplot(tau,
                delta_ma,
                delta_exp,
                delta_mf,
                waveform,
                snr,
                fig1=None,
                fig2=None,
                plottemplate=True):
        """
        Plot SNR as a function of tau and delta. Called by snrseries().
    
        Parameters
        ----------
        tau, delta_ma, delta_exp, delta_mf, waveform, snr : arrays
            The output from snrseries().
        fig1, fig2 : matplotlib figure, optional
            The figures where the plot is drawn.
        plottemplate : bool
            If True (default), plot the matched filter template.
    
        Returns
        -------
        fig1, fig2 : matplotlib figure
            The figures with the plots.
        """

        if fig1 is None:
            fig = plt.figure('fingersnr-snrplot', figsize=[10.2, 7.1])
            fig.clf()
        else:
            fig = fig1

        grid = gridspec.GridSpec(2, 2)
        ax0 = fig.add_subplot(grid[0, 0])
        ax1 = fig.add_subplot(grid[0, 1], sharex=ax0, sharey=ax0)
        ax2 = fig.add_subplot(grid[1, :], sharex=ax0, sharey=ax0)
        axs = [ax0, ax1, ax2]

        axs[0].set_title('Moving average')
        axs[1].set_title('Exponential moving average')
        axs[2].set_title('Cross correlation')

        colors = colormap.uniform(['black', 'black'], len(tau),
                                  (0, 100 * (1 - 1 / len(tau)))).colors

        for i, (ax, d) in enumerate(zip(axs, [delta_ma, delta_exp, delta_mf])):
            for j in range(len(tau)):
                label = f'{tau[j]}'
                ax.plot(d[j],
                        snr[i, j],
                        color=colors[j],
                        label=label,
                        zorder=2.5 - 0.01 * j)
            if ax.is_first_col():
                ax.set_ylabel('SNR')
            if ax.is_last_row():
                ax.set_xlabel('Offset from trigger [ns]')
            ax.minorticks_on()
            ax.grid(True, which='major', linestyle='--')
            ax.grid(True, which='minor', linestyle=':')

        axs[2].legend(loc='best', title='Filter length [ns]', ncol=2)

        fig.tight_layout()
        fig.show()

        fig1 = fig

        if plottemplate and fig2 is None:
            fig = plt.figure('fingersnr-snrplot2')
            fig.clf()
        else:
            fig = fig2

        if plottemplate:
            ax = fig.subplots(1, 1)
            ax.set_title('Matched filter template')
            ax.set_xlabel('Sample number [ns]')
            ax.plot(waveform)
            ax.grid()

            fig.tight_layout()
            fig.show()

        fig2 = fig

        return fig1, fig2