Beispiel #1
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
Beispiel #2
0
    def plot(
            self,
            filename=None,
            axes=None,
            title=None,
            fignum=None,
            figsize=(4, 4),
            rect=(0.22, 0.15, 0.75, 0.8),
            plot_spectral_fit=True,
            plot_spectral_error=True,
            data_kwargs=dict(),
            spectral_kwargs=dict(),
            spectral_error_kwargs=dict(),
    ):

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

            edict = self.results['Energy']
            file_energy_units = units.fromstring(edict['Units'])

            if 'Lower' in edict and 'Upper' in edict:
                axes.set_xlim_units(edict['Lower'][0] * file_energy_units,
                                    edict['Upper'][-1] * file_energy_units)
            else:
                axes.set_xlim_units(edict['Energy'][0] * file_energy_units,
                                    edict['Energy'][-1] * file_energy_units)

        self.plot_points(axes=axes, **data_kwargs)

        if plot_spectral_fit:
            self.plot_spectral_fit(axes=axes, **spectral_kwargs)
        if plot_spectral_error:
            self.plot_spectral_error(axes=axes, **spectral_error_kwargs)

        if title is not None: axes.set_title(title)
        if filename is not None:
            P.savefig(expandvars(filename))
        return axes
Beispiel #3
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
Beispiel #4
0
    def plot(self, filename=None, axes=None, title=None,
             fignum=None, figsize=(4,4),
             rect=(0.22,0.15,0.75,0.8),
             plot_spectral_fit=True,
             plot_spectral_error=True,
             data_kwargs=dict(),
             spectral_kwargs=dict(),
             spectral_error_kwargs=dict(),
            ):

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

            edict = self.results['Energy']
            file_energy_units = units.fromstring(edict['Units'])

            if 'Lower' in edict and 'Upper' in edict:
                axes.set_xlim_units(edict['Lower'][0]*file_energy_units, edict['Upper'][-1]*file_energy_units)
            else:
                axes.set_xlim_units(edict['Energy'][0]*file_energy_units, edict['Energy'][-1]*file_energy_units)

        self.plot_points(axes=axes, **data_kwargs)

        if plot_spectral_fit:
            self.plot_spectral_fit(axes=axes, **spectral_kwargs)
        if plot_spectral_error:
            self.plot_spectral_error(axes=axes, **spectral_error_kwargs)

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