Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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())
Ejemplo n.º 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))
Ejemplo n.º 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())
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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, ))
Ejemplo n.º 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,))
Ejemplo n.º 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()
Ejemplo n.º 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)
Ejemplo n.º 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()
Ejemplo n.º 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()
Ejemplo n.º 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()
Ejemplo n.º 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,))
Ejemplo n.º 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, ))
Ejemplo n.º 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))
Ejemplo n.º 22
0
 def startup(self):
     self.model.startup()
     CompositeModel.startup(self)
Ejemplo n.º 23
0
 def teardown(self):
     self.model.teardown()
     CompositeModel.teardown(self)
Ejemplo n.º 24
0
 def startup(self):
     self.model.startup()
     CompositeModel.startup(self)
Ejemplo n.º 25
0
 def startup(self, cache):
     self.model.startup(cache)
     CompositeModel.startup(self, cache)
Ejemplo n.º 26
0
 def teardown(self):
     self.model.teardown()
     CompositeModel.teardown(self)