Exemplo n.º 1
0
def display_var(hist,
                geom,
                title='Gain [ADC/p.e.]',
                index_var=1,
                limit_min=0.,
                limit_max=10.,
                bin_width=0.2):
    f, ax = plt.subplots(1, 2, figsize=(20, 7))
    plt.subplot(1, 2, 1)
    vis_gain = visualization.CameraDisplay(geom,
                                           title='',
                                           norm='lin',
                                           cmap='viridis')
    vis_gain.add_colorbar()
    vis_gain.colorbar.set_label(title)
    h = np.copy(hist.fit_result[:, index_var, 0])
    h_err = np.copy(hist.fit_result[:, index_var, 1])
    h[np.isnan(h_err)] = limit_min
    h[h < limit_min] = limit_min
    h[h > limit_max] = limit_max
    vis_gain.image = h
    # plt.subplot(1,2,2)
    hh, bin_tmp = np.histogram(h,
                               bins=np.arange(limit_min - bin_width / 2,
                                              limit_max + 1.5 * bin_width,
                                              bin_width))
    hh_hist = histogram(data=hh.reshape(1, hh.shape[0]),
                        bin_centers=np.arange(limit_min, limit_max + bin_width,
                                              bin_width),
                        xlabel=title,
                        ylabel='$\mathrm{N_{pixel}/%.2f}$' % bin_width,
                        label='All pixels')
    hh_hist.show(which_hist=(0, ), axis=ax[1], show_fit=False)
    plt.show()
Exemplo n.º 2
0
parser.add_option("--histo_filename", dest="histo_filename",
                  help="Histogram SPE file name", default="adc_hv_on.npz")

parser.add_option("--output_directory", dest="output_directory",
                  help="directory of histo file", default='/data/datasets/CTA/DarkRun/20161214/')

parser.add_option("--fit_filename", dest="fit_filename",
                  help="name of fit file with SPE", default='adc_hv_on_fit.npz')

# Arrange the options
(options, args) = parser.parse_args()
options.file_list = options.file_list.split(',')

# Define the histograms
adcs = histogram(bin_center_min=0., bin_center_max=4095., bin_width=1., data_shape=(1296,))


# Get the adcs
if not options.use_saved_histo:
    # Fill the adcs hist from data
    adc_hist.run(adcs, options, 'ADC')
else:
    if options.verbose:
        print('--|> Recover data from %s' % (options.output_directory + options.histo_filename))
    file = np.load(options.output_directory + options.histo_filename)
    adcs = histogram(data=np.copy(file['adcs']), bin_centers=np.copy(file['adcs_bin_centers']))

# Recover fit from the HV off
if options.perform_fit:
    print('--|> Compute gain, cross talk sigma_i and sigma_e from ADC distributions with HV OFF')
Exemplo n.º 3
0
if __name__ == '__main__':

    data_path = 'data/20161214/'

    file_list = [
        'adc_hv_off.npz', 'mpe_scan_0_195_5.npz', 'spe_hv_on.npz', 'peaks.npz'
    ]

    for file in file_list:

        data = np.load(data_path + file)

        if file == 'adc_hv_off.npz':  # gaussienne sur baseline (prendre baseline)

            hist_hv_off = histogram(data=data['adcs'],
                                    bin_centers=data['adcs_bin_centers'])

        elif file == 'mpe_scan_0_195_5.npz':  # mpe

            hist_mpe = histogram(data=data['mpes'],
                                 bin_centers=data['mpes_bin_centers'])

        elif file == 'spe_hv_on.npz':  # peak finder sur du dark (prendre gain et sigma_e des fits de ca)

            hist_spe = histogram(data=data['adcs'],
                                 bin_centers=data['adcs_bin_centers'])

        elif file == 'peaks.npz':  #

            hist_peak = histogram(data=data['peaks'],
                                  bin_centers=data['peaks_bin_centers'])
if len(options.scan_level) == 3:
    options.scan_level = np.arange(
        options.scan_level[0], options.scan_level[1] + options.scan_level[2],
        options.scan_level[2])

# Define Geometry
geom = generate_geometry_0()

# Leave the hand
plt.ion()

# Prepare the mpe histograms
mpes = histogram(bin_center_min=1950. * 8,
                 bin_center_max=4095. * 8,
                 bin_width=8.,
                 data_shape=(options.scan_level.shape + (1296, )),
                 xlabel='Integrated ADC',
                 ylabel='$\mathrm{N_{entries}}$',
                 label='MPE')
mpes_peaks = histogram(bin_center_min=1950.,
                       bin_center_max=4095.,
                       bin_width=1.,
                       data_shape=(options.scan_level.shape + (1296, )),
                       xlabel='Peak ADC',
                       ylabel='$\mathrm{N_{entries}}$',
                       label='MPE')

peaks = histogram(bin_center_min=0.5,
                  bin_center_max=51.5,
                  bin_width=1.,
                  data_shape=((1296, )),
Exemplo n.º 5
0
                      111, 127, 182, 219, 195, 124, 77, 79, 65, 66, 86, 119, 129, 148, 107, 108, 87, 59, 42, 59, 62, 91,
                      73, 100, 106,
                      67, 59, 50, 33, 36, 39, 50, 53, 49, 51, 53, 35, 27, 25, 22, 36, 35, 32, 29, 22, 21, 14, 17, 12,
                      16, 12, 21, 18, 22,
                      11, 7, 5, 7, 11, 4, 9, 8, 3, 6, 10, 8, 5, 4, 2, 4, 4, 4, 5, 6, 2, 3, 7, 5, 2, 2, 2, 3, 4, 3, 1, 2,
                      2, 2, 1, 1, 1,
                      1, 1, 1, 1, 0, 1, 0, 1, 0]], dtype='float32')


    bin = np.arange(0, data.shape[1], 1)

    #bin, data = mpe_fit.mpe_distribution(mean_cherenkov_photon=500, normalized=False)

    data = data.reshape((1,data.shape[-1]))

    mpe = histogram(data, bin_centers=np.arange(0, data.shape[1], 1))
    #mpe.predef_fit()

    #fit_function = mpe.fit_function
    #parameters = mpe.fit_result

    #mpe.show(show_fit=True)

    #config = [{'baseline': 20, 'gain': 5.6}]
    config = None

    def reduced_mpe(p,x, config=None):

        new_p = [p[0], p[1], 9.7, 20., 0.09, 0.09, p[2]]

        return utils.pdf.mpe_distribution_general(new_p, x, config=config)
Exemplo n.º 6
0
if len(options.scan_level)==3:
    options.scan_level=np.arange(options.scan_level[0],options.scan_level[1]+options.scan_level[2],options.scan_level[2])

# Define Geometry
sector_to_angle = {1:0.,2:120.,3:240.} #TODO check and put it in cts
cts = cts.CTS('/data/software/CTS/config/cts_config_%d.cfg'%(sector_to_angle[options.cts_sector]),
              '/data/software/CTS/config/camera_config.cfg',
              angle=sector_to_angle[options.cts_sector], connected=False)
#geom,good_pixels = generate_geometry(cts)
geom = generate_geometry_0()

# Leave the hand
plt.ion()

# Prepare the mpe histograms
mpes = histogram(bin_center_min=-100., bin_center_max=3095., bin_width=1., data_shape=(options.scan_level.shape+(1296,)),
                 xlabel='Integrated ADC',ylabel='$\mathrm{N_{entries}}$',label='MPE')
mpes_peaks = histogram(bin_center_min=-100., bin_center_max=3095., bin_width=1., data_shape=(options.scan_level.shape+(1296,)),
                 xlabel='Peak ADC',ylabel='$\mathrm{N_{entries}}$',label='MPE')
peaks = histogram(bin_center_min=-1., bin_center_max=51., bin_width=1., data_shape=(options.scan_level.shape+(1296,)),
                  xlabel='Peak maximum position [4ns]', ylabel='$\mathrm{N_{entries}}$', label='MPE')


# Where do we take the data from
if not options.use_saved_histo:
    # Loop over the files
    mpe_hist.run([mpes,mpes_peaks,peaks], options)
else :
    if options.verbose: print('--|> Recover data from %s' % (options.saved_histo_directory+options.saved_histo_filename))
    file = np.load(options.saved_histo_directory+options.saved_histo_filename)
    mpes = histogram(data=file['mpes'],bin_centers=file['mpes_bin_centers'])
    peaks = histogram(data=file['peaks'],bin_centers=file['peaks_bin_centers'])