def test_add_charges(): chargeres = ChargeResolutionCalculator(None, None) true_charge = np.arange(100) measured_charge = np.arange(100) chargeres.add_charges(true_charge, measured_charge) variation_hist = chargeres.variation_hist assert (variation_hist[0][0] == 1)
def setup(self): kwargs = dict(config=self.config, tool=self) self.dl0 = CameraDL0Reducer(**kwargs) self.dl1 = CameraDL1Calibrator(**kwargs) self.cal = CameraCalibrator(r1_product=self.calibrator) self.calculator = ChargeResolutionCalculator(**kwargs)
def test_get_binned_charge_resolution(): chargeres = ChargeResolutionCalculator(None, None) true_charge = np.arange(100) measured_charge = np.arange(100) chargeres.add_charges(true_charge, measured_charge) true_charge, chargeres, chargeres_error, \ scaled_chargeres, scaled_chargeres_error = \ chargeres.get_charge_resolution() assert (true_charge[0] == 1) assert (chargeres[0] == 1) assert (round(chargeres_error[0], 7) == 0.7071068) assert (round(scaled_chargeres[0], 7) == 0.5550272) assert (round(scaled_chargeres_error[0], 7) == 0.3924635)
def setup(self): self.log_format = "%(levelname)s: %(message)s [%(name)s.%(funcName)s]" kwargs = dict(config=self.config, tool=self) self.eventsource = SimTelEventSource(**kwargs) extractor = ChargeExtractorFactory.produce(**kwargs) self.r1 = HESSIOR1Calibrator(**kwargs) self.dl0 = CameraDL0Reducer(**kwargs) self.dl1 = CameraDL1Calibrator(extractor=extractor, **kwargs) self.calculator = ChargeResolutionCalculator(**kwargs)
def setup(self): self.log_format = "%(levelname)s: %(message)s [%(name)s.%(funcName)s]" kwargs = dict(config=self.config, tool=self) self.file_reader = HessioFileReader(**kwargs) extractor_factory = ChargeExtractorFactory(**kwargs) extractor_class = extractor_factory.get_class() extractor = extractor_class(**kwargs) r1_factory = CameraR1CalibratorFactory(origin=self.file_reader.origin, **kwargs) r1_class = r1_factory.get_class() self.r1 = r1_class(**kwargs) self.dl0 = CameraDL0Reducer(**kwargs) self.dl1 = CameraDL1Calibrator(extractor=extractor, **kwargs) self.calculator = ChargeResolutionCalculator(**kwargs)
def setup(self): self.log_format = "%(levelname)s: %(message)s [%(name)s.%(funcName)s]" kwargs = dict(config=self.config, tool=self) self.calculator = ChargeResolutionCalculator(**kwargs) self.plotter = ChargeResolutionPlotter(**kwargs)
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()