Example #1
0
    def plot_limit_curves(self):
        x = np.logspace(log10(0.9), log10(self.max_pe * 1.1), 100)
        requirement = ChargeResolutionCalculator.requirement(x)
        goal = ChargeResolutionCalculator.goal(x)
        poisson = ChargeResolutionCalculator.poisson(x)

        r_p, = self.ax_l.plot(x, requirement, 'r', ls='--')
        g_p, = self.ax_l.plot(x, goal, 'g', ls='--')
        p_p, = self.ax_l.plot(x, poisson, c='0.75', ls='--')
        self.ax_r.plot(x, requirement / goal, 'r')
        self.ax_r.plot(x, np.ones_like(x), 'g')
        self.ax_r.plot(x, poisson / goal, c='0.75', ls='--')

        self.legend_handles.append(r_p)
        self.legend_labels.append("Requirement")
        self.legend_handles.append(g_p)
        self.legend_labels.append("Goal")
        self.legend_handles.append(p_p)
        self.legend_labels.append("Poisson")
    def plot_limit_curves(self):
        x = np.logspace(log10(0.9), log10(self.max_pe * 1.1), 100)
        requirement = ChargeResolutionCalculator.requirement(x)
        goal = ChargeResolutionCalculator.goal(x)
        poisson = ChargeResolutionCalculator.poisson(x)

        r_p, = self.ax_l.plot(x, requirement, 'r', ls='--')
        g_p, = self.ax_l.plot(x, goal, 'g', ls='--')
        p_p, = self.ax_l.plot(x, poisson, c='0.75', ls='--')
        self.ax_r.plot(x, requirement / goal, 'r')
        self.ax_r.plot(x, np.ones_like(x), 'g')
        self.ax_r.plot(x, poisson / goal, c='0.75', ls='--')

        self.legend_handles.append(r_p)
        self.legend_labels.append("Requirement")
        self.legend_handles.append(g_p)
        self.legend_labels.append("Goal")
        self.legend_handles.append(p_p)
        self.legend_labels.append("Poisson")
Example #3
0
    def get_charge(self):
        fig = plt.figure(1)
        ax = fig.add_subplot(111)

        calculator = ChargeResolutionCalculator(config=None, tool=None)
        calculator2 = ChargeResolutionCalculator(config=None, tool=None)

        pevals = [
            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20,
            21, 23, 24, 26, 28, 30, 32, 35, 37, 40, 43, 46, 49, 53, 57, 61, 65,
            70, 75, 81, 86, 93, 100, 107, 114, 123, 132, 141, 151, 162, 174,
            187, 200, 215, 231, 247, 265, 284, 305, 327, 351, 376, 403, 432,
            464, 497, 533, 572, 613, 657, 705, 756, 811, 869, 932, 1000
        ]

        for n, i in enumerate(pevals):
            self.filename = '/Users/armstrongt/Workspace/CTA/MCValidation/data/bypass2_enoise_pe_e%s.simtel.gz' % n
            ntrig = 0
            source = hessio_event_source(self.filename,
                                         allowed_tels=None,
                                         max_events=None)
            for event in source:
                self.calib.calibrate(event)
                true_charge = event.mc.tel[
                    1].photo_electron_image * self.pixel_mask
                measured_charge = event.dl1.tel[1].image[0] * self.pixel_mask
                true_charge2 = np.asarray(
                    [int(i)] * len(measured_charge)) * self.pixel_mask
                calculator.add_charges(true_charge, measured_charge)
                calculator2.add_charges(true_charge2, measured_charge)
                ntrig = ntrig + 1

        x, res, res_error, scaled_res, scaled_res_error = calculator.get_charge_resolution(
        )
        x2, res2, res_error2, scaled_res2, scaled_res_error2 = calculator2.get_charge_resolution(
        )
        ax.errorbar(x,
                    res,
                    yerr=res_error,
                    marker='x',
                    linestyle="None",
                    label='MC Charge Res')
        ax.errorbar(x2,
                    res2,
                    yerr=res_error2,
                    marker='x',
                    color='C1',
                    linestyle="None",
                    label='\'Lab\' Charge Res')
        x = np.logspace(np.log10(0.9), np.log10(1000 * 1.1), 100)
        requirement = ChargeResolutionCalculator.requirement(x)
        goal = ChargeResolutionCalculator.goal(x)
        poisson = ChargeResolutionCalculator.poisson(x)
        r_p = ax.plot(x, requirement, 'r', ls='--', label='Requirement')
        g_p = ax.plot(x, goal, 'g', ls='--', label='Goal')
        p_p = ax.plot(x, poisson, c='0.75', ls='--', label='Poisson')
        plt.legend()
        plt.yscale('log')
        plt.xscale('log')
        plt.xlabel('true charge')
        plt.ylabel('charge resolution')
        plt.show()