def setup(self, init_sources=True, overwrite=False, **kwargs):
        """Run pre-processing for each analysis component and
        construct a joint likelihood object.  This function performs
        the following tasks: data selection (gtselect, gtmktime),
        data binning (gtbin), and model generation (gtexpcube2,gtsrcmaps).

        Parameters
        ----------

        init_sources : bool

           Choose whether to compute properties (flux, TS, etc.) for
           individual sources.

        overwrite : bool

           Run all pre-processing steps even if the output file of
           that step is present in the working directory.  By default
           this function will skip any steps for which the output file
           already exists.

        """

        loglevel = kwargs.get('loglevel', self.loglevel)

        self.logger.log(loglevel, 'Running setup.')

        # Make spatial maps for extended sources
        for s in self.roi.sources:
            if s.diffuse:
                continue
            if not s.extended:
                continue
            self.make_template(s)

        # Run setup for each component
        for i, c in enumerate(self.components):
            c.setup(overwrite=overwrite)

        # Create likelihood
        self._create_likelihood()

        # Determine tmin, tmax
        for i, c in enumerate(self._components):
            self._tmin = (c.tmin if self._tmin is None
                          else min(self._tmin, c.tmin))
            self._tmax = (c.tmax if self._tmax is None
                          else min(self._tmax, c.tmax))

        if init_sources:

            self.logger.log(loglevel, 'Initializing source properties')
            for name in self.like.sourceNames():
                self.logger.debug('Initializing source %s', name)
                self._init_source(name)
            self._update_roi()

        self.logger.log(loglevel, 'Finished setup.')
Run pre-processing for each analysis component and
        construct a joint likelihood object.  This function performs
        the following tasks: data selection (gtselect, gtmktime),
        data binning (gtbin), and model generation (gtexpcube2,gtsrcmaps).

        Parameters
        ----------

        init_sources : bool

           Choose whether to compute properties (flux, TS, etc.) for
           individual sources.

        overwrite : bool

           Run all pre-processing steps even if the output file of
           that step is present in the working directory.  By default
           this function will skip any steps for which the output file
           already exists.