def make_residmap_plots(self, maps, roi=None, **kwargs):
        """Make plots from the output of
        `~fermipy.gtanalysis.GTAnalysis.residmap`.

        Parameters
        ----------
        maps : dict
            Output dictionary of
            `~fermipy.gtanalysis.GTAnalysis.residmap`.

        roi : `~fermipy.roi_model.ROIModel`
            ROI Model object.  Generate markers at the positions of
            the sources in this ROI.

        zoom : float
            Crop the image by this factor.  If None then no crop is
            applied.

        """

        fmt = kwargs.get('format', self.config['format'])
        figsize = kwargs.get('figsize', self.config['figsize'])
        workdir = kwargs.pop('workdir', self.config['fileio']['workdir'])
        use_weights = kwargs.pop('use_weights', False)
        # FIXME, how to set this:
        no_contour = False
        zoom = kwargs.get('zoom', None)

        kwargs.setdefault('graticule_radii', self.config['graticule_radii'])
        kwargs.setdefault('label_ts_threshold',
                          self.config['label_ts_threshold'])
        cmap = kwargs.setdefault('cmap', self.config['cmap'])
        cmap_resid = kwargs.pop('cmap_resid', self.config['cmap_resid'])
        kwargs.setdefault('catalogs', self.config['catalogs'])
        if no_contour:
            sigma_levels = None
        else:
            sigma_levels = [-5, -3, 3, 5, 7] + list(np.logspace(1, 3, 17))

        load_bluered_cmap()

        prefix = maps['name']
        mask = maps['mask']
        if use_weights:
            sigma_hist_data = maps['sigma'].data[maps['mask'].data.astype(
                bool)]
            maps['sigma'].data *= maps['mask'].data
            maps['data'].data *= maps['mask'].data
            maps['model'].data *= maps['mask'].data
            maps['excess'].data *= maps['mask'].data
        else:
            sigma_hist_data = maps['sigma'].data

        fig = plt.figure(figsize=figsize)
        p = ROIPlotter(maps['sigma'], roi=roi, **kwargs)
        p.plot(vmin=-5, vmax=5, levels=sigma_levels,
               cb_label='Significance [$\sigma$]', interpolation='bicubic',
               cmap=cmap_resid, zoom=zoom)
        plt.savefig(utils.format_filename(workdir,
                                          'residmap_sigma',
                                          prefix=[prefix],
                                          extension=fmt))
        plt.close(fig)

        # make and draw histogram
        fig, ax = plt.subplots(figsize=figsize)
        nBins = np.linspace(-6, 6, 121)
        data = np.nan_to_num(sigma_hist_data)
        # find best fit parameters
        mu, sigma = norm.fit(data.flatten())
        # make and draw the histogram
        data[data > 6.0] = 6.0
        data[data < -6.0] = -6.0

        n, bins, patches = ax.hist(data.flatten(), nBins, density=True,
                                   histtype='stepfilled',
                                   facecolor='green', alpha=0.75)
        # make and draw best fit line
        y = norm.pdf(bins, mu, sigma)
        ax.plot(bins, y, 'r--', linewidth=2)
        y = norm.pdf(bins, 0.0, 1.0)
        ax.plot(bins, y, 'k', linewidth=1)

        # labels and such
        ax.set_xlabel(r'Significance ($\sigma$)')
        ax.set_ylabel('Probability')
        paramtext = 'Gaussian fit:\n'
        paramtext += '$\\mu=%.2f$\n' % mu
        paramtext += '$\\sigma=%.2f$' % sigma
        ax.text(0.05, 0.95, paramtext, verticalalignment='top',
                horizontalalignment='left', transform=ax.transAxes)

        plt.savefig(utils.format_filename(workdir,
                                          'residmap_sigma_hist',
                                          prefix=[prefix],
                                          extension=fmt))
        plt.close(fig)

        vmax = max(np.max(maps['data'].data), np.max(maps['model'].data))
        vmin = min(np.min(maps['data'].data), np.min(maps['model'].data))

        fig = plt.figure(figsize=figsize)
        p = ROIPlotter(maps['data'], roi=roi, **kwargs)
        p.plot(cb_label='Counts', interpolation='bicubic',
               cmap=cmap, zscale='sqrt', vmin=vmin, vmax=vmax)
        plt.savefig(utils.format_filename(workdir,
                                          'residmap_data',
                                          prefix=[prefix],
                                          extension=fmt))
        plt.close(fig)

        fig = plt.figure(figsize=figsize)
        p = ROIPlotter(maps['model'], roi=roi, **kwargs)
        p.plot(cb_label='Counts', interpolation='bicubic',
               cmap=cmap, zscale='sqrt', vmin=vmin, vmax=vmax)
        plt.savefig(utils.format_filename(workdir,
                                          'residmap_model',
                                          prefix=[prefix],
                                          extension=fmt))
        plt.close(fig)

        fig = plt.figure(figsize=figsize)
        p = ROIPlotter(maps['excess'], roi=roi, **kwargs)
        p.plot(cb_label='Counts', interpolation='bicubic',
               cmap=cmap_resid)
        plt.savefig(utils.format_filename(workdir,
                                          'residmap_excess',
                                          prefix=[prefix],
                                          extension=fmt))
        plt.close(fig)
def make_residmap_plots ( self , maps , roi = None , ** kwargs ) : fmt = kwargs . get ( 'format' , self . config [ 'format' ] ) figsize = kwargs . get ( 'figsize' , self . config [ 'figsize' ] ) workdir = kwargs . pop ( 'workdir' , self . config [ 'fileio' ] [ 'workdir' ] ) use_weights = kwargs . pop ( 'use_weights' , False ) no_contour = False zoom = kwargs . get ( 'zoom' , None ) kwargs . setdefault ( 'graticule_radii' , self . config [ 'graticule_radii' ] ) kwargs . setdefault ( 'label_ts_threshold' , self . config [ 'label_ts_threshold' ] ) cmap = kwargs . setdefault ( 'cmap' , self . config [ 'cmap' ] ) cmap_resid = kwargs . pop ( 'cmap_resid' , self . config [ 'cmap_resid' ] ) kwargs . setdefault ( 'catalogs' , self . config [ 'catalogs' ] ) if no_contour : sigma_levels = None else : sigma_levels = [ - 5 , - 3 , 3 , 5 , 7 ] + list ( np . logspace ( 1 , 3 , 17 ) ) load_bluered_cmap ( ) prefix = maps [ 'name' ] mask = maps [ 'mask' ] if use_weights : sigma_hist_data = maps [ 'sigma' ] . data [ maps [ 'mask' ] . data . astype ( bool ) ] maps [ 'sigma' ] . data *= maps [ 'mask' ] . data maps [ 'data' ] . data *= maps [ 'mask' ] . data maps [ 'model' ] . data *= maps [ 'mask' ] . data maps [ 'excess' ] . data *= maps [ 'mask' ] . data else : sigma_hist_data = maps [ 'sigma' ] . data fig = plt . figure ( figsize = figsize ) p = ROIPlotter ( maps [ 'sigma' ] , roi = roi , ** kwargs ) p . plot ( vmin = - 5 , vmax = 5 , levels = sigma_levels , cb_label = 'Significance [$\sigma$]' , interpolation = 'bicubic' , cmap = cmap_resid , zoom = zoom ) plt . savefig ( utils . format_filename ( workdir , 'residmap_sigma' , prefix = [ prefix ] , extension = fmt ) ) plt . close ( fig ) fig , ax = plt . subplots ( figsize = figsize ) nBins = np . linspace ( - 6 , 6 , 121 ) data = np . nan_to_num ( sigma_hist_data ) mu , sigma = norm . fit ( data . flatten ( ) ) data [ data > 6.0 ] = 6.0 data [ data < - 6.0 ] = - 6.0 n , bins , patches = ax . hist ( data . flatten ( ) , nBins , density = True , histtype = 'stepfilled' , facecolor = 'green' , alpha = 0.75 ) y = norm . pdf ( bins , mu , sigma ) ax . plot ( bins , y , 'r--' , linewidth = 2 ) y = norm . pdf ( bins , 0.0 , 1.0 ) ax . plot ( bins , y , 'k' , linewidth = 1 ) ax . set_xlabel ( r'Significance ($\sigma$)' ) ax . set_ylabel ( 'Probability' ) paramtext = 'Gaussian fit:\n' paramtext += '$\\mu=%.2f$\n' % mu paramtext += '$\\sigma=%.2f$' % sigma ax . text ( 0.05 , 0.95 , paramtext , verticalalignment = 'top' , horizontalalignment = 'left' , transform = ax . transAxes ) plt . savefig ( utils . format_filename ( workdir , 'residmap_sigma_hist' , prefix = [ prefix ] , extension = fmt ) ) plt . close ( fig ) vmax = max ( np . max ( maps [ 'data' ] . data ) , np . max ( maps [ 'model' ] . data ) ) vmin = min ( np . min ( maps [ 'data' ] . data ) , np . min ( maps [ 'model' ] . data ) ) fig = plt . figure ( figsize = figsize ) p = ROIPlotter ( maps [ 'data' ] , roi = roi , ** kwargs ) p . plot ( cb_label = 'Counts' , interpolation = 'bicubic' , cmap = cmap , zscale = 'sqrt' , vmin = vmin , vmax = vmax ) plt . savefig ( utils . format_filename ( workdir , 'residmap_data' , prefix = [ prefix ] , extension = fmt ) ) plt . close ( fig ) fig = plt . figure ( figsize = figsize ) p = ROIPlotter ( maps [ 'model' ] , roi = roi , ** kwargs ) p . plot ( cb_label = 'Counts' , interpolation = 'bicubic' , cmap = cmap , zscale = 'sqrt' , vmin = vmin , vmax = vmax ) plt . savefig ( utils . format_filename ( workdir , 'residmap_model' , prefix = [ prefix ] , extension = fmt ) ) plt . close ( fig ) fig = plt . figure ( figsize = figsize ) p = ROIPlotter ( maps [ 'excess' ] , roi = roi , ** kwargs ) p . plot ( cb_label = 'Counts' , interpolation = 'bicubic' , cmap = cmap_resid ) plt . savefig ( utils . format_filename ( workdir , 'residmap_excess' , prefix = [ prefix ] , extension = fmt ) ) plt . close ( fig )
Make plots from the output of
        `~fermipy.gtanalysis.GTAnalysis.residmap`.

        Parameters
        ----------
        maps : dict
            Output dictionary of
            `~fermipy.gtanalysis.GTAnalysis.residmap`.

        roi : `~fermipy.roi_model.ROIModel`
            ROI Model object.  Generate markers at the positions of
            the sources in this ROI.

        zoom : float
            Crop the image by this factor.  If None then no crop is
            applied.