Esempio n. 1
0
class ChargeResolutionViewer(Tool):
    name = "ChargeResolutionViewer"
    description = "Plot the charge resolution from " \
                  "ChargeResolutionCalculator objects restored via " \
                  "pickled dictionaries."

    input_files = List(Unicode, None,
                       help='Input pickle files that are produced from '
                            'ChargeResolutionCalculator.save().'
                            '').tag(config=True)

    aliases = Dict(dict(f='ChargeResolutionViewer.input_files',
                        B='ChargeResolutionCalculator.binning',
                        max_pe='ChargeResolutionPlotter.max_pe',
                        O='ChargeResolutionPlotter.output_path',
                        ))
    flags = Dict(dict(L=({'ChargeResolutionCalculator': {'log_bins': False}},
                         'Bin the x axis linearly instead of logarithmic.'),
                      linx=({'ChargeResolutionPlotter': {'linear_x': True}},
                            'Plot the x values on a linear axis, '
                            'instead of log.'),
                      liny=({'ChargeResolutionPlotter': {'linear_y': True}},
                            'Plot the x values on a linear axis, '
                            'instead of log.')
                      ))
    classes = List([ChargeResolutionCalculator,
                    ChargeResolutionPlotter
                    ])

    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.calculator = None
        self.plotter = None

    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 start(self):
        self.plotter.plot_limit_curves()
        for fp in self.input_files:
            self.calculator.load(fp)
            x, res, res_error, scaled_res, scaled_res_error = \
                self.calculator.get_charge_resolution()

            name = basename(fp)
            self.plotter.plot_chargeres(name, x, res, res_error)
            self.plotter.plot_scaled_chargeres(x, scaled_res, scaled_res_error)

    def finish(self):
        self.plotter.save()
Esempio n. 2
0
class ChargeResolutionVariationViewer(Tool):
    name = "ChargeResolutionVariationViewer"
    description = "Plot the charge resolution from " \
                  "ChargeResolutionCalculator objects restored via " \
                  "pickled dictionaries."

    input_path = Unicode(None,
                         allow_none=True,
                         help='Path to the hdf5 file produced from'
                         'ChargeResolutionCalculator.save()'
                         '').tag(config=True)

    aliases = Dict(
        dict(
            f='ChargeResolutionVariationViewer.input_path',
            O='ChargeResolutionVariationPlotter.output_path',
        ))
    classes = List(
        [ChargeResolutionCalculator, ChargeResolutionVariationPlotter])

    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.calculator = None
        self.plotter = None

    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 = ChargeResolutionVariationPlotter(**kwargs)

    def start(self):
        self.calculator.load(self.input_path)

    def finish(self):
        hist = self.calculator.variation_hist
        xedges = self.calculator.variation_xedges
        yedges = self.calculator.variation_yedges
        self.plotter.plot_hist(hist, xedges, yedges)
class ChargeResolutionVariationViewer(Tool):
    name = "ChargeResolutionVariationViewer"
    description = "Plot the charge resolution from " \
                  "ChargeResolutionCalculator objects restored via " \
                  "pickled dictionaries."

    input_path = Unicode(None, allow_none=True,
                         help='Path to the hdf5 file produced from'
                              'ChargeResolutionCalculator.save()'
                              '').tag(config=True)

    aliases = Dict(dict(f='ChargeResolutionVariationViewer.input_path',
                        O='ChargeResolutionVariationPlotter.output_path',
                        ))
    classes = List([ChargeResolutionCalculator,
                    ChargeResolutionVariationPlotter
                    ])

    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.calculator = None
        self.plotter = None

    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 = ChargeResolutionVariationPlotter(**kwargs)

    def start(self):
        self.calculator.load(self.input_path)

    def finish(self):
        hist = self.calculator.variation_hist
        xedges = self.calculator.variation_xedges
        yedges = self.calculator.variation_yedges
        self.plotter.plot_hist(hist, xedges, yedges)