def test_lineWidth_sf(self): from nPYc.utilities._lineWidth import lineWidth sf = (1000 - 200) * numpy.random.random_sample() + 200 trueLineWidth = 2 trueLineWidth = trueLineWidth / sf x = L(self.y, 0, trueLineWidth) calculatedLW = lineWidth(x, self.y, sf, [-5, 5], multiplicity='singlet') numpy.testing.assert_allclose(calculatedLW, trueLineWidth * sf, atol=0.001)
def test_lineWidth_doublet(self): from nPYc.utilities._lineWidth import lineWidth # Aproximates a 0.3 to 3hz range trueLineWidth = (3 - 0.3) * numpy.random.random_sample() + 0.3 points = numpy.random.randint(500, 1000) x = numpy.linspace(1.322, 1.38, points) y1 = L(x, 1.342, trueLineWidth / self.sf) y2 = L(x, 1.354, trueLineWidth / self.sf) bl = numpy.linspace(500, 1, points) y = ((y1 + y2) * 10) + bl calculatedLW = lineWidth(y, x, self.sf, [1.322, 1.38], multiplicity='doublet') numpy.testing.assert_allclose(calculatedLW, trueLineWidth, atol=0.001)
def test_lineWidth_quartet(self): from nPYc.utilities._lineWidth import lineWidth x = numpy.linspace(4.07, 4.145, 1000) # Aproximates a 0.3 to 3hz range trueLineWidth = (3 - 0.3) * numpy.random.random_sample() + 0.3 y1 = L(x, 4.090, trueLineWidth / self.sf) y2 = L(x, 4.1013, trueLineWidth / self.sf) y3 = L(x, 4.113, trueLineWidth / self.sf) y4 = L(x, 4.124, trueLineWidth / self.sf) bl = numpy.linspace(10, 1, 1000) n = numpy.random.randn(1000) y = ((y1 + y4) / 3) + (y2 + y3) + bl calculatedLW = lineWidth(y, x, self.sf, [4.07, 4.145], multiplicity='quartet') numpy.testing.assert_allclose(calculatedLW, trueLineWidth, atol=0.001)
def test_lineWidth_peakIntesityFraction(self): from nPYc.utilities._lineWidth import lineWidth x = numpy.linspace(4.07, 4.145, 1000) # Aproximates a 0.3 to 3hz range trueLineWidth = (3 - 0.3) * numpy.random.random_sample() + 0.3 y1 = L(x, 4.090, trueLineWidth / self.sf) y2 = L(x, 4.1013, trueLineWidth / self.sf) y3 = L(x, 4.113, trueLineWidth / self.sf) y4 = L(x, 4.124, trueLineWidth / self.sf) bl = numpy.linspace(10, 1, 1000) n = numpy.random.randn(1000) y = ((y1 + y4) / 3) + (y2 + y3) + bl peakBaselineRatio = (y2.sum()/numpy.absolute(bl.sum())) * 100 with self.subTest(msg='Peak ratio too low'): calculatedLW = lineWidth(y, x, self.sf, [4.07, 4.145], multiplicity='quartet', peakIntesityFraction=peakBaselineRatio+1) self.assertTrue(numpy.isnan(calculatedLW))
def test_lineWidth_singlet(self): from nPYc.utilities._lineWidth import lineWidth calculatedLW = lineWidth(self.x, self.y, 1, [-5, 5], multiplicity='singlet') numpy.testing.assert_allclose(calculatedLW, self.trueLineWidth, atol=0.001)