Exemple #1
0
    def plot_spectral_error(self, axes, **kwargs):
        spectral_error_kwargs=dict(color='red',alpha=0.5,zorder=1.8)
        spectral_error_kwargs.update(kwargs)

        sp=SpectrumPlotter(axes=axes)
        sp.plot_error(self.results['spectrum'], self.results['spectrum']['covariance_matrix'],
                      autoscale=False, **spectral_error_kwargs)
Exemple #2
0
    def plot_spectral_fit(self, axes, **kwargs):

        spectral_kwargs = dict(color='red', zorder=1.9)
        spectral_kwargs.update(kwargs)

        sp = SpectrumPlotter(axes=axes)
        sp.plot(self.results['spectrum'], autoscale=False, **spectral_kwargs)
Exemple #3
0
    def plot_spectral_fit(self,axes, **kwargs):

        spectral_kwargs=dict(color='red',zorder=1.9)
        spectral_kwargs.update(kwargs)

        sp=SpectrumPlotter(axes=axes)
        sp.plot(self.results['spectrum'], 
                autoscale=False, **spectral_kwargs)
Exemple #4
0
    def plot_spectral_error(self, axes, **kwargs):
        spectral_error_kwargs = dict(color='red', alpha=0.5, zorder=1.8)
        spectral_error_kwargs.update(kwargs)

        sp = SpectrumPlotter(axes=axes)
        sp.plot_error(self.results['spectrum'],
                      self.results['spectrum']['covariance_matrix'],
                      autoscale=False,
                      **spectral_error_kwargs)
Exemple #5
0
    def plot(
            self,
            filename=None,
            axes=None,
            fignum=None,
            figsize=(5.5, 4.5),
            spectral_kwargs=dict(color='red', zorder=1.9),
            cutoff_kwargs=dict(color='blue', zorder=1.9),
    ):

        if axes is None:
            fig = P.figure(fignum, figsize)
            axes = SpectralAxes(fig=fig,
                                rect=(0.22, 0.15, 0.75, 0.8),
                                flux_units=self.flux_units,
                                energy_units=self.energy_units)
            fig.add_axes(axes)

            axes.set_xlim_units(100 * units.MeV, 10**5.5 * units.MeV)

        # plot sed
        sed = SED(self.sed_4bpd)
        sed.plot_points(axes=axes)

        if self.hypothesis == 'at_pulsar':
            # plot power-law limits
            ul = UpperLimit(self.powerlaw_limit)
            ul.plot(axes=axes, color='orange', zorder=1.9)

        axes.autoscale(False)

        # plot spectral model
        sp = SpectrumPlotter(axes=axes)
        sp.plot(self.spectral_model, **spectral_kwargs)
        sp.plot_error(self.spectral_model, alpha=0.25, **spectral_kwargs)

        if self.hypothesis != 'extended':
            # plot cutoff model
            sp.plot(self.cutoff_model, **cutoff_kwargs)
            sp.plot_error(self.cutoff_model, alpha=0.25, **cutoff_kwargs)

        if self.hypothesis == 'at_pulsar':
            ul = UpperLimit(self.cutoff_limit)
            ul.plot(axes=axes, color='purple', zorder=1.9)

        #if self.code == 'gtlike':
        #    bf = BandFitter(self.bandfits)
        #    bf.plot(axes=axes,
        #            spectral_kwargs=dict(color='green',zorder=1.9),
        #            spectral_error_kwargs=dict(color='green', alpha=0.25))

        if filename is not None:
            P.savefig(expandvars(filename))
        return axes
    def plot(self, filename=None, axes=None,
            fignum=None, figsize=(5.5,4.5),
            spectral_kwargs=dict(color='red', zorder=1.9),
            cutoff_kwargs=dict(color='blue', zorder=1.9),
            ):

        if axes is None:
            fig = P.figure(fignum,figsize)
            axes = SpectralAxes(fig=fig,
                                rect=(0.22,0.15,0.75,0.8),
                                flux_units=self.flux_units,
                                energy_units=self.energy_units)
            fig.add_axes(axes)

            axes.set_xlim_units(100*units.MeV, 10**5.5*units.MeV)
    
        # plot sed
        sed = SED(self.sed_4bpd)
        sed.plot_points(axes=axes)

        if self.hypothesis == 'at_pulsar':
            # plot power-law limits
            ul=UpperLimit(self.powerlaw_limit)
            ul.plot(axes=axes, color='orange', zorder=1.9)

        axes.autoscale(False)

        # plot spectral model
        sp=SpectrumPlotter(axes=axes)
        sp.plot(self.spectral_model, **spectral_kwargs)
        sp.plot_error(self.spectral_model, alpha=0.25, **spectral_kwargs)

        if self.hypothesis != 'extended':
            # plot cutoff model
            sp.plot(self.cutoff_model, **cutoff_kwargs)
            sp.plot_error(self.cutoff_model, alpha=0.25, **cutoff_kwargs)

        if self.hypothesis == 'at_pulsar':
            ul=UpperLimit(self.cutoff_limit)
            ul.plot(axes=axes, color='purple', zorder=1.9)

        #if self.code == 'gtlike':
        #    bf = BandFitter(self.bandfits)
        #    bf.plot(axes=axes, 
        #            spectral_kwargs=dict(color='green',zorder=1.9), 
        #            spectral_error_kwargs=dict(color='green', alpha=0.25))

        if filename is not None:
            P.savefig(expandvars(filename))
        return axes

for i,pwn in enumerate(cutoff_candidates):
    print i,pwn

    axes=grid[i]


    r = classifier.get_results(pwn)
    spectrum = r['spectrum']
    sed = r['sed_4bpd']

    s = SED(sed)
    s.plot_points(axes=axes, zorder=2.1)

    sp = SpectrumPlotter(axes=axes)
    sp.plot(spectrum, autoscale=False, color='red' if not bw else 'grey', zorder=1.9)

label_axes(grid)

grid[0].set_ylabel('')
grid[4].set_ylabel('')


for i in range(nrows*ncols):
    axes=grid[i]
    #axes.set_xlim_units(10**2*units.MeV,10**5.5*units.MeV)
    axes.set_xlim(0.1,10**2.5)
    #axes.set_ylim_units(1e-13*units.erg/units.cm**2/units.s,1e-9*units.erg/units.cm**2/units.s)
    if i in [0,1,2,3]:
        axes.set_ylim(1e-13,1e-9)