def testDistanceAVG(self): R = numpy.linspace(5, 6, 1100) kappa = [ 2. / 3 ] * 1100 weights = [ 1. ] * 1100 tm = DistanceAVGKappaTransferMatrix(20, 11, 5, self.constant5000Burstgen, 5.475, R, kappa, weights) tm.generateMatrix() self.assertEqual(tm.getMatrix().shape, (20, 11)) self.assertEqual(tm.RRange[0], 5) self.assertEqual(tm.RRange[1], 6) self.assertEqual(tm.getMatrix()[9][5], 1.)
def testSamplesOutsideRange(self): R = numpy.linspace(4.95, 6.05, 22) kappa = [ 2. / 3 ] * 22 weights = [ 1. ] * 22 tm = DistanceAVGKappaTransferMatrix(20, 11, 200, self.constant5000Burstgen, 5.475, R, kappa, weights, RRange = (5., 6)) tm.generateMatrix() self.assertEqual(tm.RRange[0], 5) self.assertEqual(tm.RRange[1], 6) self.assertAlmostEqual(tm.getMatrix()[9][5], 1., delta = 0.01) tmref = GlobalAVGKappaTransferMatrix(20, 11, 200, self.constant5000Burstgen, 5.475, (5, 6)) self.assertMatrixAlmostEqual(tm.getMatrix() , tmref.getMatrix(), delta = 0.15)
def testDistanceAVGLocalKappavsGlobal(self): R = numpy.linspace(5.05, 5.95, 20) kappa = [ 2. / 3 ] * 20 weights = [ 1. ] * 20 tm = DistanceAVGKappaTransferMatrix(20, 11, 5000, self.constant5000Burstgen, 5.475, R, kappa, weights, RRange = (5, 6)) tm.generateMatrix() self.assertEqual(tm.RRange[0], 5) self.assertEqual(tm.RRange[1], 6) self.assertAlmostEqual(tm.getMatrix()[9][5], 1., delta = 0.01) tmref = GlobalAVGKappaTransferMatrix(20, 11, 5000, self.constant5000Burstgen, 5.475, [5, 6]) self.assertMatrixAlmostEqual(tm.getMatrix(), tmref.getMatrix(), delta = 0.05)
def testDistanceAVGAlteredKappa(self): R = numpy.linspace(5, 6, 1100) kappa = [ 2. / 3 ] * 200 + [ 1. / 3 ] * 400 + [ 2. / 3 ] * 500 weights = [ 1. ] * 1100 tm = DistanceAVGKappaTransferMatrix(20, 11, 5, self.constant5000Burstgen, 5.475, R, kappa, weights) tm.generateMatrix() self.assertEqual(tm.getMatrix().shape, (20, 11)) self.assertEqual(tm.RRange[0], 5) self.assertEqual(tm.RRange[1], 6) R0neu = modifyR0(5.475, 1. / 3) print "New R0 is %f" % R0neu eff = rToEff(5.475, R0 = R0neu) effndx = int(eff * 11) self.assertAlmostEqual(tm.getMatrix()[9][effndx], 1, delta = 0.01)