Ejemplo n.º 1
0
    def __init__(self, like, name, *args, **kwargs):
        keyword_options.process(self, kwargs)

        self.like = like
        self.name = name

        if self.ul_algorithm not in BaseGtlikeSED.ul_choices:
            raise Exception("Upper Limit Algorithm %s not in %s" % (self.ul_algorithm,str(BaseGtlikeSED.ul_choices)))

        if self.bin_edges is not None:
            if not BaseGtlikeSED.good_binning(like, self.bin_edges):
                raise Exception("bin_edges is not commensurate with the underlying energy binning of pyLikelihood.")
            
            self.bin_edges = np.asarray(self.bin_edges)
            energy = np.sqrt(self.bin_edges[1:]*self.bin_edges[:-1])
        else:
            # These energies are always in MeV
            self.bin_edges = like.energies
            energy = like.e_vals

        self.lower=self.bin_edges[:-1]
        self.upper=self.bin_edges[1:]

        source=self.like.logLike.getSource(name) 
        self.init_spectrum=source.spectrum()
        self.init_model=build_pointlike_model(self.init_spectrum)

        self.results = dict(
            Name=name,
            spectrum=name_to_spectral_dict(like,name, errors=True, covariance_matrix=True),
        )
        self._calculate(like)

        super(GtlikeSED,self).__init__(self.results, **keyword_options.defaults_to_kwargs(self, SED))
Ejemplo n.º 2
0
    def __init__(self, roi, name, **kwargs):
        keyword_options.process(self, kwargs)
        self.roi = roi
        self.name = name
        
        bf = BandFlux(self.roi, which=self.name, merge=self.merge, scale_factor=1)
        results = PointlikeSED.pointlike_sed_to_dict(bf, flux_units=self.flux_units, energy_units=self.energy_units)

        results['spectrum'] = name_to_spectral_dict(roi, name, errors=True, covariance_matrix=True)

        super(PointlikeSED,self).__init__(results, **keyword_options.defaults_to_kwargs(self, SED))
Ejemplo n.º 3
0
    def __init__(self, like, name, *args, **kwargs):
        keyword_options.process(self, kwargs)

        self.like = like
        self.name = name

        if self.ul_algorithm not in BaseGtlikeSED.ul_choices:
            raise Exception("Upper Limit Algorithm %s not in %s" %
                            (self.ul_algorithm, str(BaseGtlikeSED.ul_choices)))

        if self.bin_edges is not None:
            if not BaseGtlikeSED.good_binning(like, self.bin_edges):
                raise Exception(
                    "bin_edges is not commensurate with the underlying energy binning of pyLikelihood."
                )

            self.bin_edges = np.asarray(self.bin_edges)
            energy = np.sqrt(self.bin_edges[1:] * self.bin_edges[:-1])
        else:
            # These energies are always in MeV
            self.bin_edges = like.energies
            energy = like.e_vals

        self.lower = self.bin_edges[:-1]
        self.upper = self.bin_edges[1:]

        source = self.like.logLike.getSource(name)
        self.init_spectrum = source.spectrum()
        self.init_model = build_pointlike_model(self.init_spectrum)

        self.results = dict(
            Name=name,
            spectrum=name_to_spectral_dict(like,
                                           name,
                                           errors=True,
                                           covariance_matrix=True),
        )
        self._calculate(like)

        super(GtlikeSED,
              self).__init__(self.results,
                             **keyword_options.defaults_to_kwargs(self, SED))
Ejemplo n.º 4
0
    def __init__(self, roi, name, **kwargs):
        keyword_options.process(self, kwargs)
        self.roi = roi
        self.name = name

        bf = BandFlux(self.roi,
                      which=self.name,
                      merge=self.merge,
                      scale_factor=1)
        results = PointlikeSED.pointlike_sed_to_dict(
            bf, flux_units=self.flux_units, energy_units=self.energy_units)

        results['spectrum'] = name_to_spectral_dict(roi,
                                                    name,
                                                    errors=True,
                                                    covariance_matrix=True)

        super(PointlikeSED,
              self).__init__(results,
                             **keyword_options.defaults_to_kwargs(self, SED))