def test_4(self): TWC = SPS5Section200MHzTWC() filter, n_taps, n_filling, n_fit = feedforward_filter(TWC, self.T_s, debug=False, opt_output=True) self.assertEqual( n_taps, 43, msg="In TestFeedforwardFilter, test_4: n_taps incorrect") self.assertEqual( n_filling, 31, msg="In TestFeedforwardFilter, test_4: n_filling incorrect") self.assertEqual( n_fit, 74, msg="In TestFeedforwardFilter, test_4: n_fit incorrect") # filter_ref = np.array( # [ 0.0189205535, -0.0105637125, 0.0007262783, 0.0007262783, # 0.0006531768, -0.0105310359, -0.0104579343, 0.0007262783, # 0.0007262783, 0.0007262783, 0.0063272331, -0.0083221785, # 0.0010894175, 0.0010894175, 0.0010894175, 0.0010894175, # 0.0010894175, 0.0010894175, 0.0010894175, 0.0010894175, # 0.0010894175, 0.0010894175, 0.0010894175, 0.0010894175, # 0.0010894175, 0.0010894175, 0.0010894175, 0.0010894175, # 0.0010894175, 0.0010894175, 0.0010894175, 0.0105496942, # -0.0041924387, 0.0014525567, 0.0014525567, 0.0013063535, # 0.0114011487, 0.0104579343, -0.0007262783, -0.0007262783, # -0.0007262783, 0.0104756312, -0.018823192]) filter_ref = np.copy(feedforward_filter_TWC5) np.testing.assert_allclose( filter, filter_ref, rtol=1e-8, atol=1e-9, err_msg="In TestFeedforwardFilter, test_4: filter array incorrect") del TWC
def test_1(self): # Modified filling time to match reference case TWC = SPS3Section200MHzTWC() TWC.tau = 420e-9 filter, n_taps, n_filling, n_fit = feedforward_filter(TWC, 4 / 125 * 1e-6, debug=False, taps=31, opt_output=True) self.assertEqual( n_taps, 31, msg="In TestFeedforwardFilter, test_1: n_taps incorrect") self.assertEqual( n_filling, 13, msg="In TestFeedforwardFilter, test_1: n_filling incorrect") self.assertEqual( n_fit, 44, msg="In TestFeedforwardFilter, test_1: n_fit incorrect") filter_ref = np.array([ -0.0227533635, 0.0211514102, 0.0032929202, -0.0026111554, 0.0119559316, 0.0043905603, 0.0043905603, 0.0040101282, -0.0241480816, -0.0237676496, 0.0043905603, 0.0043905603, 0.0043905603, -0.0107783487, 0.0184915005, 0.0065858404, -0.0052223108, 0.0239118633, 0.0087811206, 0.0087811206, 0.0080202564, 0.0295926259, 0.0237676496, -0.0043905603, -0.0043905603, -0.0043905603, -0.0119750148, 0.0026599098, -0.0032929202, -0.021005147, 0.022696114 ]) np.testing.assert_allclose( filter, filter_ref, rtol=1e-8, atol=1e-9, err_msg="In TestFeedforwardFilter, test_1: filter array incorrect") del TWC
def test_3(self): TWC = SPS4Section200MHzTWC() filter, n_taps, n_filling, n_fit = feedforward_filter(TWC, self.T_s, debug=False, opt_output=True) self.assertEqual( n_taps, 37, msg="In TestFeedforwardFilter, test_3: n_taps incorrect") self.assertEqual( n_filling, 24, msg="In TestFeedforwardFilter, test_3: n_filling incorrect") self.assertEqual( n_fit, 61, msg="In TestFeedforwardFilter, test_3: n_fit incorrect") # filter_ref = np.array( # [ 0.0048142895, 0.0035544775, 0.0011144336, 0.0011144336, # 0.0011144336, -0.0056984584, -0.0122587698, -0.0054458778, # 0.0011144336, 0.0011144336, 0.0011144336, -0.0001684528, # -0.000662115, 0.0016716504, 0.0016716504, 0.0016716504, # 0.0016716504, 0.0016716504, 0.0016716504, 0.0016716504, # 0.0016716504, 0.0016716504, 0.0016716504, 0.0016716504, # 0.0040787952, 0.0034488892, 0.0022288672, 0.0022288672, # 0.0022288672, 0.0090417593, 0.0146881621, 0.0062036196, # -0.0011144336, -0.0011144336, -0.0011144336, -0.0036802064, # -0.0046675309]) filter_ref = np.copy(feedforward_filter_TWC4) np.testing.assert_allclose( filter, filter_ref, rtol=1e-8, atol=1e-9, err_msg="In TestFeedforwardFilter, test_3: filter array incorrect") del TWC
def test_2(self): TWC = SPS3Section200MHzTWC() filter, n_taps, n_filling, n_fit = feedforward_filter(TWC, self.T_s, debug=False, opt_output=True) self.assertEqual( n_taps, 31, msg="In TestFeedforwardFilter, test_2: n_taps incorrect") self.assertEqual( n_filling, 18, msg="In TestFeedforwardFilter, test_2: n_filling incorrect") self.assertEqual( n_fit, 49, msg="In TestFeedforwardFilter, test_2: n_fit incorrect") # filter_ref = np.array( # [-0.0070484734, 0.0161859736, 0.0020289928, 0.0020289928, # 0.0020289928, -0.0071641302, -0.0162319424, -0.0070388194, # 0.0020289928, 0.0020289928, 0.0020289928, - 0.0050718734, # 0.0065971343, 0.0030434892, 0.0030434892, 0.0030434892, # 0.0030434892, 0.0030434892, -0.0004807475, 0.011136476, # 0.0040579856, 0.0040579856, 0.0040579856, 0.0132511086, # 0.019651364, 0.0074147518, -0.0020289928, -0.0020289928, # -0.0020289928, -0.0162307252, 0.0071072903]) filter_ref = np.copy(feedforward_filter_TWC3) np.testing.assert_allclose( filter, filter_ref, rtol=1e-8, atol=1e-9, err_msg="In TestFeedforwardFilter, test_2: filter array incorrect") del TWC
rf = RFStation(ring, h, V, phi, n_rf=1) logging.info("...... RF parameters set!") T_s = bunch_spacing * rf.t_rf[0, 0] logging.info("RF period %.6e s", rf.t_rf[0, 0]) logging.info("Sampling period %.6e s", T_s) if FILTER_DESIGN: logging.info("...... Filter design test") logging.info("3-section cavity filter design with modified filling time" + " and fixed n_taps") TWC = SPS3Section200MHzTWC() TWC.tau = 420e-9 filter, n_taps, n_filling, n_fit = feedforward_filter(TWC, 4 / 125 * 1e-6, debug=True, taps=31, opt_output=True) # print(filter) logging.info("3-section cavity filter design") TWC_3 = SPS3Section200MHzTWC() filter = feedforward_filter(TWC_3, T_s, debug=True) # print(filter) logging.info("4-section cavity filter design") TWC_4 = SPS4Section200MHzTWC() filter = feedforward_filter(TWC_4, T_s, debug=True) # print(filter) logging.info("5-section cavity filter design")
if FILTER_DESIGN: logging.info("...... Filter design test") logging.info("3-section cavity filter design with modified filling time" + " and fixed n_taps") # TWC = SPS3Section200MHzTWC() # TWC.tau = 420e-9 # filter, n_taps, n_filling, n_fit = feedforward_filter(TWC, 4/125*1e-6, # debug=True, taps=31, opt_output=True) # print('3-section filter (modified sampling):\n', filter) logging.info("3-section cavity filter design") TWC_3 = SPS3Section200MHzTWC() filter = feedforward_filter( TWC_3, T_s, debug=True ) #, taps=31) # set taps = 31 together with T_s = 1./31.25e6 to get a 3-sec filter very close to the one in CERN note (Fig. 8 ) print('3-section filter:\n', filter, len(filter)) # quit() logging.info("4-section cavity filter design") TWC_4 = SPS4Section200MHzTWC() filter = feedforward_filter(TWC_4, T_s, debug=True) print('4-section filter:\n', filter, len(filter)) logging.info("5-section cavity filter design") TWC_5 = SPS5Section200MHzTWC() filter = feedforward_filter(TWC_5, T_s, debug=True) print('5-section filter:\n', filter, len(filter)) if FEEDFORWARD: