def extension(self, name, **kwargs):
        """Test this source for spatial extension with the likelihood
        ratio method (TS_ext).  This method will substitute an
        extended spatial model for the given source and perform a
        one-dimensional scan of the spatial extension parameter over
        the range specified with the width parameters.  The 1-D
        profile likelihood is then used to compute the best-fit value,
        upper limit, and TS for extension.  The nuisance parameters
        that will be simultaneously fit when performing the spatial
        scan can be controlled with the ``fix_shape``,
        ``free_background``, and ``free_radius`` options.  By default
        the position of the source will be fixed to its current
        position.  A simultaneous fit to position and extension can be
        performed by setting ``fit_position`` to True.

        Parameters
        ----------
        name : str
            Source name.

        {options}

        optimizer : dict
            Dictionary that overrides the default optimizer settings.

        Returns
        -------
        extension : dict
            Dictionary containing results of the extension analysis.  The same
            dictionary is also saved to the dictionary of this source under
            'extension'.
        """
        timer = Timer.create(start=True)
        name = self.roi.get_source_by_name(name).name

        schema = ConfigSchema(self.defaults['extension'],
                              optimizer=self.defaults['optimizer'])
        schema.add_option('prefix', '')
        schema.add_option('outfile', None, '', str)
        config = utils.create_dict(self.config['extension'],
                                   optimizer=self.config['optimizer'])
        config = schema.create_config(config, **kwargs)

        self.logger.info('Running extension fit for %s', name)

        free_state = FreeParameterState(self)
        ext = self._extension(name, **config)
        free_state.restore()

        self.logger.info('Finished extension fit.')

        if config['make_plots']:
            self._plotter.make_extension_plots(ext, self.roi,
                                               prefix=config['prefix'])

        outfile = config.get('outfile', None)
        if outfile is None:
            outfile = utils.format_filename(self.workdir, 'ext',
                                            prefix=[config['prefix'],
                                                    name.lower().replace(' ', '_')])
        else:
            outfile = os.path.join(self.workdir,
                                   os.path.splitext(outfile)[0])

        if config['write_fits']:
            self._make_extension_fits(ext, outfile + '.fits')

        if config['write_npy']:
            np.save(outfile + '.npy', dict(ext))

        self.logger.info('Execution time: %.2f s', timer.elapsed_time)
        return ext
def extension ( self , name , ** kwargs ) : timer = Timer . create ( start = True ) name = self . roi . get_source_by_name ( name ) . name schema = ConfigSchema ( self . defaults [ 'extension' ] , optimizer = self . defaults [ 'optimizer' ] ) schema . add_option ( 'prefix' , '' ) schema . add_option ( 'outfile' , None , '' , str ) config = utils . create_dict ( self . config [ 'extension' ] , optimizer = self . config [ 'optimizer' ] ) config = schema . create_config ( config , ** kwargs ) self . logger . info ( 'Running extension fit for %s' , name ) free_state = FreeParameterState ( self ) ext = self . _extension ( name , ** config ) free_state . restore ( ) self . logger . info ( 'Finished extension fit.' ) if config [ 'make_plots' ] : self . _plotter . make_extension_plots ( ext , self . roi , prefix = config [ 'prefix' ] ) outfile = config . get ( 'outfile' , None ) if outfile is None : outfile = utils . format_filename ( self . workdir , 'ext' , prefix = [ config [ 'prefix' ] , name . lower ( ) . replace ( ' ' , '_' ) ] ) else : outfile = os . path . join ( self . workdir , os . path . splitext ( outfile ) [ 0 ] ) if config [ 'write_fits' ] : self . _make_extension_fits ( ext , outfile + '.fits' ) if config [ 'write_npy' ] : np . save ( outfile + '.npy' , dict ( ext ) ) self . logger . info ( 'Execution time: %.2f s' , timer . elapsed_time ) return ext
Test this source for spatial extension with the likelihood
        ratio method (TS_ext).  This method will substitute an
        extended spatial model for the given source and perform a
        one-dimensional scan of the spatial extension parameter over
        the range specified with the width parameters.  The 1-D
        profile likelihood is then used to compute the best-fit value,
        upper limit, and TS for extension.  The nuisance parameters
        that will be simultaneously fit when performing the spatial
        scan can be controlled with the ``fix_shape``,
        ``free_background``, and ``free_radius`` options.  By default
        the position of the source will be fixed to its current
        position.  A simultaneous fit to position and extension can be
        performed by setting ``fit_position`` to True.

        Parameters
        ----------
        name : str
            Source name.

        {options}

        optimizer : dict
            Dictionary that overrides the default optimizer settings.

        Returns
        -------
        extension : dict
            Dictionary containing results of the extension analysis.  The same
            dictionary is also saved to the dictionary of this source under
            'extension'.