コード例 #1
0
 def __init__(self, n, model, rmf):
     self.n = n
     RMFModelNoPHA.__init__(self, rmf=rmf, model=model)
     self.elo = numpy.arange(n)
     self.ehi = numpy.arange(n)
     self.lo = numpy.arange(n)
     self.hi = numpy.arange(n)
     self.xlo = numpy.arange(n)
     self.xhi = numpy.arange(n)
コード例 #2
0
ファイル: pca.py プロジェクト: JohannesBuchner/BXA
	def __init__(self, n, model, rmf):
		self.n = n
		RMFModelNoPHA.__init__(self, rmf=rmf, model=model)
		self.elo = numpy.arange(n)
		self.ehi = numpy.arange(n)
		self.lo = numpy.arange(n)
		self.hi = numpy.arange(n)
		self.xlo = numpy.arange(n)
		self.xhi = numpy.arange(n)
コード例 #3
0
def test_rmfmodelnopha_matrix_call():
    "What happens calling an rmf (matrix) with no pha?"

    rdata = create_non_delta_rmf()

    # Do not use a flat model as it is not as useful a check
    # that the RMF is doing its job.
    #
    constant = 2.3
    slope = -0.1
    mdl = Polynom1D('mdl')
    mdl.c0 = constant
    mdl.c1 = slope

    wrapped = RMFModelNoPHA(rdata, mdl)

    # Calculate the model analytically.
    #
    modvals = mdl(rdata.energ_lo, rdata.energ_hi)
    matrix = get_non_delta_matrix()
    expected = np.matmul(modvals, matrix)

    out = wrapped([4, 5])
    assert_allclose(out, expected)

    # the RMF convolution shouldn't lose flux, although
    # given the previous check it's not clear if this really
    # adds any extra confidence.
    #
    assert out.sum() == pytest.approx(modvals.sum())
コード例 #4
0
def test_rmfmodelnopha_delta_call():
    "What happens calling an rmf (delta function) with no pha?"

    egrid = np.arange(0.01, 0.06, 0.01)
    rdata = create_delta_rmf(egrid[:-1], egrid[1:])

    constant = 2.3
    mdl = Const1D('flat')
    mdl.c0 = constant

    wrapped = RMFModelNoPHA(rdata, mdl)

    # The model is evaluated on the RMF grid, not whatever
    # is sent in. It is also integrated across the bins,
    # which is why there is a multiplication by the
    # grid width (for this constant model).
    #
    de = egrid[1:] - egrid[:-1]
    expected = constant * de
    out = wrapped([4, 5])
    assert_allclose(out, expected)