Пример #1
0
 def teardown(self):
     pha = self.pha
     rmf = self.rmf
     self.channel = sao_arange(1, rmf.detchans)
     self.mask = numpy.ones(rmf.detchans, dtype=bool)
     self.model.teardown()
     CompositeModel.teardown(self)
Пример #2
0
 def teardown(self):
     pha = self.pha
     rmf = self.rmf
     self.channel = sao_arange(1, rmf.detchans)
     self.mask = numpy.ones(rmf.detchans, dtype=bool)
     self.model.teardown()
     CompositeModel.teardown(self)
Пример #3
0
 def startup(self, cache):
     pha = self.pha
     pha.notice_response(False)
     self.channel = pha.get_noticed_channels()
     self.mask = pha.get_mask()
     self.model.startup(cache)
     CompositeModel.startup(self, cache)
Пример #4
0
 def startup(self):
     pha = self.pha
     pha.notice_response(False)
     self.channel = pha.get_noticed_channels()
     self.mask = pha.get_mask()
     self.model.startup()
     CompositeModel.startup(self)
Пример #5
0
 def __init__(self, srcdata, bkgmodels):
     self.srcdata = srcdata
     self.bkgmodels = bkgmodels
     scale_factor = self.srcdata.sum_background_data(lambda key, bkg:1)
     bkgnames = [model.name for model in bkgmodels.values()]
     name = '%g * (' % scale_factor + ' + '.join(bkgnames) + ')'
     CompositeModel.__init__(self, name, self.bkgmodels.values())
Пример #6
0
 def __init__(self, model, wrapper):
     self.model = self.wrapobj(model)
     self.wrapper = wrapper
     CompositeModel.__init__(self,
                             "{}({})".format(self.wrapper.name,
                                             self.model.name),
                             (self.wrapper, self.model))
Пример #7
0
 def __init__(self, srcdata, bkgmodels):
     self.srcdata = srcdata
     self.bkgmodels = bkgmodels
     scale_factor = self.srcdata.sum_background_data(lambda key, bkg: 1)
     bkgnames = [model.name for model in bkgmodels.values()]
     name = '%g * (' % scale_factor + ' + '.join(bkgnames) + ')'
     CompositeModel.__init__(self, name, self.bkgmodels.values())
Пример #8
0
 def startup(self):
     pha = self.pha
     if numpy.iterable(pha.mask):
         pha.notice_response(True)
     self.channel = pha.get_noticed_channels()
     self.mask = pha.get_mask()
     self._get_noticed_energy_list()
     CompositeModel.startup(self)
Пример #9
0
 def startup(self, cache):
     pha = self.pha
     if numpy.iterable(pha.mask):
         pha.notice_response(True)
     self.channel = pha.get_noticed_channels()
     self.mask = pha.get_mask()
     self._get_noticed_energy_list()
     CompositeModel.startup(self, cache)
Пример #10
0
 def teardown(self):
     pha = self.pha
     if numpy.iterable(pha.mask):
         pha.notice_response(False)
     self.channel = pha.channel
     self.mask = numpy.ones(len(pha.channel), dtype=bool)
     self.elo = None; self.ehi = None; self.table = None
     self.lo = None; self.hi = None
     CompositeModel.teardown(self)
Пример #11
0
 def teardown(self):
     pha = self.pha
     if numpy.iterable(pha.mask):
         pha.notice_response(False)
     self.channel = pha.channel
     self.mask = numpy.ones(len(pha.channel), dtype=bool)
     self.elo = None
     self.ehi = None
     self.table = None
     self.lo = None
     self.hi = None
     CompositeModel.teardown(self)
Пример #12
0
    def __init__(self, rmf, model, pha=None):
        self.pha = pha
        self.channel = sao_arange(1, rmf.detchans)  # sao_arange is inclusive
        self.mask = numpy.ones(rmf.detchans, dtype=bool)
        self.rmf = rmf

        self.elo, self.ehi = rmf.get_indep()
        self.lo, self.hi = DataPHA._hc / self.ehi, DataPHA._hc / self.elo
        self.model = model
        self.otherargs = None
        self.otherkwargs = None
        self.pars = ()
        CompositeModel.__init__(self,
                                ('%s(%s)' % ('apply_rmf', self.model.name)),
                                (self.model, ))
Пример #13
0
    def __init__(self, rmf, model, pha=None):
        self.pha = pha
        self.channel = sao_arange(1, rmf.detchans)  # sao_arange is inclusive
        self.mask = numpy.ones(rmf.detchans, dtype=bool)
        self.rmf = rmf

        self.elo, self.ehi = rmf.get_indep()
        self.lo, self.hi = DataPHA._hc / self.ehi, DataPHA._hc / self.elo
        self.model = model
        self.otherargs = None
        self.otherkwargs = None
        self.pars = ()
        CompositeModel.__init__(self,
                                ('%s(%s)' % ('apply_rmf', self.model.name)),
                                (self.model,))
Пример #14
0
    def __init__(self, arf, model):
        self.arf = arf
        self.model = model

        self.elo = None; self.ehi = None  # Energy space
        self.lo = None;  self.hi = None   # Wavelength space
        self.xlo = None; self.xhi = None  # Current Spectral coordinates

        # Used to rebin against finer or coarser energy grids
        self.arfargs = ()

        # Logic for ArithmeticModel.__init__
        self.pars = ()

        CompositeModel.__init__(self, 'apply_arf(%s)' % model.name, (model,))
        self.filter()
Пример #15
0
    def teardown(self):

        # Note:
        #
        # The pha variable was declared but not used, so has been commented
        # out. It has been kept as a comment for future review, since it
        # is unclear whether anything should be done to the PHA object
        # during teardown
        #
        # pha = self.pha

        rmf = self.rmf
        self.channel = sao_arange(1, rmf.detchans)
        self.mask = numpy.ones(rmf.detchans, dtype=bool)
        self.model.teardown()
        CompositeModel.teardown(self)
Пример #16
0
    def __init__(self, rmf, model):
        self.rmf = rmf
        self.model = model

        # Logic for ArithmeticModel.__init__
        self.pars = ()
        
        # FIXME: group pairs of coordinates with one attribute

        self.elo = None; self.ehi = None  # Energy space
        self.lo = None;  self.hi = None   # Wavelength space
        self.xlo = None; self.xhi = None  # Current Spectral coordinates

        # Used to rebin against finer or coarser energy grids
        self.rmfargs = ()

        CompositeModel.__init__(self, 'apply_rmf(%s)' % model.name, (model,))
        self.filter()
Пример #17
0
    def __init__(self, arf, model):
        self.arf = arf
        self.model = model

        self.elo = None
        self.ehi = None  # Energy space
        self.lo = None
        self.hi = None  # Wavelength space
        self.xlo = None
        self.xhi = None  # Current Spectral coordinates

        # Used to rebin against finer or coarser energy grids
        self.arfargs = ()

        # Logic for ArithmeticModel.__init__
        self.pars = ()

        CompositeModel.__init__(self, 'apply_arf(%s)' % model.name, (model, ))
        self.filter()
Пример #18
0
    def __init__(self, rmf, model):
        self.rmf = rmf
        self.model = model

        # Logic for ArithmeticModel.__init__
        self.pars = ()

        # FIXME: group pairs of coordinates with one attribute

        self.elo = None
        self.ehi = None  # Energy space
        self.lo = None
        self.hi = None  # Wavelength space
        self.xlo = None
        self.xhi = None  # Current Spectral coordinates

        # Used to rebin against finer or coarser energy grids
        self.rmfargs = ()

        CompositeModel.__init__(self, 'apply_rmf(%s)' % model.name, (model, ))
        self.filter()
Пример #19
0
    def __init__(self, source, pha):
        self.channel = pha.channel
        self.mask = numpy.ones(len(pha.channel), dtype=bool)
        self.pha = pha
        self.source = source
        self.elo = None
        self.ehi = None
        self.lo = None
        self.hi = None
        self.table = None
        self.orders = None

        models = []
        grid = []

        for id in pha.response_ids:
            arf, rmf = pha.get_response(id)

            if arf is None and rmf is None:
                raise DataErr('norsp', pha.name)

            m = ResponseNestedModel(arf, rmf)
            indep = None

            if arf is not None:
                indep = arf.get_indep()

            if rmf is not None:
                indep = rmf.get_indep()

            models.append(m)
            grid.append(indep)

        self.models = models
        self.grid = grid

        name = '%s(%s)' % (type(self).__name__,
                           ','.join(['%s(%s)' % (m.name, source.name)
                                     for m in models]))
        CompositeModel.__init__(self, name, (source,))
Пример #20
0
    def __init__(self, source, pha):
        self.channel = pha.channel
        self.mask = numpy.ones(len(pha.channel), dtype=bool)
        self.pha = pha
        self.source = source
        self.elo = None
        self.ehi = None
        self.lo = None
        self.hi = None
        self.table = None
        self.orders = None

        models = []
        grid = []

        for id in pha.response_ids:
            arf, rmf = pha.get_response(id)

            if arf is None and rmf is None:
                raise DataErr('norsp', pha.name)

            m = ResponseNestedModel(arf, rmf)
            indep = None

            if arf is not None:
                indep = arf.get_indep()

            if rmf is not None:
                indep = rmf.get_indep()

            models.append(m)
            grid.append(indep)

        self.models = models
        self.grid = grid

        name = '%s(%s)' % (type(self).__name__, ','.join(
            ['%s(%s)' % (m.name, source.name) for m in models]))
        CompositeModel.__init__(self, name, (source, ))
Пример #21
0
 def __init__(self, model, wrapper):
     self.model = self.wrapobj(model)
     self.wrapper = wrapper
     CompositeModel.__init__(
         self, "{}({})".format(self.wrapper.name, self.model.name),
         (self.wrapper, self.model))
Пример #22
0
 def startup(self):
     self.model.startup()
     CompositeModel.startup(self)
Пример #23
0
 def teardown(self):
     self.model.teardown()
     CompositeModel.teardown(self)
Пример #24
0
 def startup(self):
     self.model.startup()
     CompositeModel.startup(self)
Пример #25
0
 def startup(self, cache):
     self.model.startup(cache)
     CompositeModel.startup(self, cache)
Пример #26
0
 def teardown(self):
     self.model.teardown()
     CompositeModel.teardown(self)