def setUp(self): x = numpy.arange(5000) # (height1, center1, fwhm1, beamfwhm...) slit_params = (50, 500, 200, 100, 50, 600, 80, 30, 20, 2000, 150, 150, 50, 2250, 110, 100, 40, 3000, 50, 10, 23, 4980, 250, 20) self.y1 = functions.sum_slit(x, *slit_params) # 5% noise self.y1 = add_relative_noise(self.y1, 5.) # (height1, center1, fwhm1...) step_params = (50, 500, 200, 50, 600, 80, 20, 2000, 150, 50, 2250, 110, 40, 3000, 50, 23, 4980, 250,) self.y2 = functions.sum_stepup(x, *step_params) # 5% noise self.y2 = add_relative_noise(self.y2, 5.) self.y3 = functions.sum_stepdown(x, *step_params) # 5% noise self.y3 = add_relative_noise(self.y3, 5.)
def setUp(self): x = numpy.arange(5000) # (height1, center1, fwhm1, beamfwhm...) slit_params = (50, 500, 200, 100, 50, 600, 80, 30, 20, 2000, 150, 150, 50, 2250, 110, 100, 40, 3000, 50, 10, 23, 4980, 250, 20) self.y1 = functions.sum_slit(x, *slit_params) # 5% noise self.y1 = add_relative_noise(self.y1, 5.) # (height1, center1, fwhm1...) step_params = ( 50, 500, 200, 50, 600, 80, 20, 2000, 150, 50, 2250, 110, 40, 3000, 50, 23, 4980, 250, ) self.y2 = functions.sum_stepup(x, *step_params) # 5% noise self.y2 = add_relative_noise(self.y2, 5.) self.y3 = functions.sum_stepdown(x, *step_params) # 5% noise self.y3 = add_relative_noise(self.y3, 5.)
def testStepUp(self): """sanity check for step up: - derivative must be largest around the step center - max value must be close to height parameter """ x0 = numpy.arange(1000) center = 444 height = 1234 fwhm = 210 y0 = functions.sum_stepup(x0, height, center, fwhm) self.assertLess(max(y0), height) self.assertAlmostEqual(max(y0), height, places=1) self.assertAlmostEqual(min(y0), 0, places=1) deriv0 = _numerical_derivative(functions.sum_stepup, x0, [height, center, fwhm]) # Test center position within +- 1 sample of max derivative index_max_deriv = numpy.argmax(deriv0) self.assertLess(abs(index_max_deriv - center), 1)
def setUp(self): x = numpy.arange(5000) # (height1, center1, fwhm1, beamfwhm...) slit_params = (50, 500, 200, 100, 50, 600, 80, 30, 20, 2000, 150, 150, 50, 2250, 110, 100, 40, 3000, 50, 10, 23, 4980, 250, 20) self.y1 = functions.sum_slit(x, *slit_params) # 5% noise noise1 = 2 * numpy.random.random(5000) - 1 noise1 *= 0.05 self.y1 *= (1 + noise1) # (height1, center1, fwhm1...) step_params = (50, 500, 200, 50, 600, 80, 20, 2000, 150, 50, 2250, 110, 40, 3000, 50, 23, 4980, 250,) self.y2 = functions.sum_stepup(x, *step_params) # 5% noise noise2 = 2 * numpy.random.random(5000) - 1 noise2 *= 0.05 self.y2 *= (1 + noise2) self.y3 = functions.sum_stepdown(x, *step_params) # 5% noise noise3 = 2 * numpy.random.random(5000) - 1 noise3 *= 0.05 self.y3 *= (1 + noise3)