1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 from os import sep
25
26
27 from data_store import Relax_data_store; ds = Relax_data_store()
28 from math import atan, pi
29 from pipe_control import state
30 from pipe_control.mol_res_spin import get_spin_ids, return_spin
31 from specific_analyses.relax_disp.checks import get_times
32 from specific_analyses.relax_disp.data import calc_rotating_frame_params, count_relax_times, find_intensity_keys, get_curve_type, has_exponential_exp_type, loop_exp_frq, loop_exp_frq_offset, loop_exp_frq_offset_point, loop_exp_frq_offset_point_time, loop_time, return_offset_data, return_spin_lock_nu1
33 from status import Status; status = Status()
34 from test_suite.unit_tests.base_classes import UnitTestCase
35
36
38 """Unit tests for the functions of the specific_analyses.relax_disp.data module."""
39
41 """Setup some structures for the unit tests."""
42
43
44 ds.add(pipe_name='orig', pipe_type='relax_disp')
45
46
48 """Unit test of the calc_rotating_frame_params() function for R1rho setup.
49
50 This uses the data of the saved state attached to U{bug #21344<https://web.archive.org/web/https://gna.org/bugs/?21344>}.
51 """
52
53
54 statefile = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21344_trunc.bz2'
55 state.load_state(statefile, force=True)
56
57 curspin_id = ':5@N'
58 curspin = return_spin(curspin_id)
59
60
61 theta_spin_dic, Domega_spin_dic, w_eff_spin_dic, dic_key_list = calc_rotating_frame_params(spin = curspin, spin_id = curspin_id)
62
63 for dic_key in dic_key_list:
64 print(dic_key, theta_spin_dic[dic_key], Domega_spin_dic[dic_key], w_eff_spin_dic[dic_key])
65
66
68 """Unit test of the count_relax_times() function.
69
70 This uses the data of the saved state attached to U{bug #21665<https://web.archive.org/web/https://gna.org/bugs/?21665>}.
71 """
72
73
74 statefile = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21665.bz2'
75 state.load_state(statefile, force=True)
76
77
78 data = [
79 ['SQ CPMG', 499862140.0],
80 ['SQ CPMG', 599890858.69999993]
81 ]
82
83
84 indices = [
85 [0, 0],
86 [0, 1]
87 ]
88
89
90 print("Checking the number of time counts.")
91 for id in cdp.exp_type.keys():
92 exp_type = cdp.exp_type[id]
93 frq = cdp.spectrometer_frq[id]
94 point = cdp.cpmg_frqs[id]
95 count = count_relax_times(exp_type = exp_type, frq = frq, point = point, ei = cdp.exp_type_list.index(cdp.exp_type[id]))
96 print(id, exp_type, frq, point, count)
97
98
99 if id.split('A')[0] == 'Z_':
100 self.assertEqual(exp_type, data[0][0])
101 self.assertEqual(frq, data[0][1])
102 elif id.split('B')[0] == 'Z_':
103 self.assertEqual(exp_type, data[1][0])
104 self.assertEqual(frq, data[1][1])
105
106 self.assertEqual(count, 1)
107
108
110 """Unit test of the count_relax_times() function.
111
112 This uses the data of the saved state attached to U{bug #21344<https://web.archive.org/web/https://gna.org/bugs/?21344>}.
113 """
114
115
116 statefile = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21344_trunc.bz2'
117 state.load_state(statefile, force=True)
118
119
120 data = dict()
121 data['46_0_35_0'] = ['R1rho', 799777399.1, 118.078, 431.0, 0.0]
122 data['48_0_35_4'] = ['R1rho', 799777399.1, 118.078, 431.0, 0.04]
123 data['47_0_35_10'] = ['R1rho', 799777399.1, 118.078, 431.0, 0.1]
124 data['49_0_35_20'] = ['R1rho', 799777399.1, 118.078, 431.0, 0.2]
125 data['36_0_39_0'] = ['R1rho', 799777399.1, 118.078, 651.2, 0.0]
126 data['39_0_39_4'] = ['R1rho', 799777399.1, 118.078, 651.2, 0.04]
127 data['37_0_39_10'] = ['R1rho', 799777399.1, 118.078, 651.2, 0.1]
128 data['40_0_39_20'] = ['R1rho', 799777399.1, 118.078, 651.2, 0.2]
129 data['38_0_39_40'] = ['R1rho', 799777399.1, 118.078, 651.2, 0.4]
130 data['41_0_41_0'] = ['R1rho', 799777399.1, 118.078, 800.5, 0.0]
131 data['44_0_41_4'] = ['R1rho', 799777399.1, 118.078, 800.5, 0.04]
132 data['42_0_41_10'] = ['R1rho', 799777399.1, 118.078, 800.5, 0.1]
133 data['45_0_41_20'] = ['R1rho', 799777399.1, 118.078, 800.5, 0.2]
134 data['43_0_41_40'] = ['R1rho', 799777399.1, 118.078, 800.5, 0.4]
135 data['31_0_43_0'] = ['R1rho', 799777399.1, 118.078, 984.0, 0.0]
136 data['34_0_43_4'] = ['R1rho', 799777399.1, 118.078, 984.0, 0.04]
137 data['32_0_43_10'] = ['R1rho', 799777399.1, 118.078, 984.0, 0.1]
138 data['35_0_43_20'] = ['R1rho', 799777399.1, 118.078, 984.0, 0.2]
139 data['33_0_43_40'] = ['R1rho', 799777399.1, 118.078, 984.0, 0.4]
140 data['1_0_46_0'] = ['R1rho', 799777399.1, 118.078, 1341.11, 0.0]
141 data['4_0_46_4'] = ['R1rho', 799777399.1, 118.078, 1341.11, 0.04]
142 data['2_0_46_10'] = ['R1rho', 799777399.1, 118.078, 1341.11, 0.1]
143 data['5_0_46_20'] = ['R1rho', 799777399.1, 118.078, 1341.11, 0.2]
144 data['3_0_46_40'] = ['R1rho', 799777399.1, 118.078, 1341.11, 0.4]
145 data['60_0_48_0'] = ['R1rho', 799777399.1, 118.078, 1648.5, 0.0]
146 data['63_0_48_4'] = ['R1rho', 799777399.1, 118.078, 1648.5, 0.04]
147 data['61_0_48_10'] = ['R1rho', 799777399.1, 118.078, 1648.5, 0.1]
148 data['62_0_48_14'] = ['R1rho', 799777399.1, 118.078, 1648.5, 0.14]
149 data['64_0_48_20'] = ['R1rho', 799777399.1, 118.078, 1648.5, 0.2]
150 data['11_500_46_0'] = ['R1rho', 799777399.1, 124.24703146206046, 1341.11, 0.0]
151 data['14_500_46_4'] = ['R1rho', 799777399.1, 124.24703146206046, 1341.11, 0.04]
152 data['12_500_46_10'] = ['R1rho', 799777399.1, 124.24703146206046, 1341.11, 0.1]
153 data['15_500_46_20'] = ['R1rho', 799777399.1, 124.24703146206046, 1341.11, 0.2]
154 data['13_500_46_40'] = ['R1rho', 799777399.1, 124.24703146206046, 1341.11, 0.4]
155 data['50_1000_41_0'] = ['R1rho', 799777399.1, 130.41606292412092, 800.5, 0.0]
156 data['53_1000_41_4'] = ['R1rho', 799777399.1, 130.41606292412092, 800.5, 0.04]
157 data['51_1000_41_10'] = ['R1rho', 799777399.1, 130.41606292412092, 800.5, 0.1]
158 data['54_1000_41_20'] = ['R1rho', 799777399.1, 130.41606292412092, 800.5, 0.2]
159 data['52_1000_41_40'] = ['R1rho', 799777399.1, 130.41606292412092, 800.5, 0.4]
160 data['21_1000_46_0'] = ['R1rho', 799777399.1, 130.41606292412092, 1341.11, 0.0]
161 data['24_1000_46_4'] = ['R1rho', 799777399.1, 130.41606292412092, 1341.11, 0.04]
162 data['22_1000_46_10'] = ['R1rho', 799777399.1, 130.41606292412092, 1341.11, 0.1]
163 data['25_1000_46_20'] = ['R1rho', 799777399.1, 130.41606292412092, 1341.11, 0.2]
164 data['23_1000_46_40'] = ['R1rho', 799777399.1, 130.41606292412092, 1341.11, 0.4]
165 data['65_1000_48_0'] = ['R1rho', 799777399.1, 130.41606292412092, 1648.5, 0.0]
166 data['68_1000_48_4'] = ['R1rho', 799777399.1, 130.41606292412092, 1648.5, 0.04]
167 data['66_1000_48_10'] = ['R1rho', 799777399.1, 130.41606292412092, 1648.5, 0.1]
168 data['67_1000_48_14'] = ['R1rho', 799777399.1, 130.41606292412092, 1648.5, 0.14]
169 data['69_1000_48_20'] = ['R1rho', 799777399.1, 130.41606292412092, 1648.5, 0.2]
170 data['55_2000_41_0'] = ['R1rho', 799777399.1, 142.75412584824184, 800.5, 0.0]
171 data['58_2000_41_4'] = ['R1rho', 799777399.1, 142.75412584824184, 800.5, 0.04]
172 data['56_2000_41_10'] = ['R1rho', 799777399.1, 142.75412584824184, 800.5, 0.1]
173 data['59_2000_41_20'] = ['R1rho', 799777399.1, 142.75412584824184, 800.5, 0.2]
174 data['57_2000_41_40'] = ['R1rho', 799777399.1, 142.75412584824184, 800.5, 0.4]
175 data['6_2000_46_0'] = ['R1rho', 799777399.1, 142.75412584824184, 1341.11, 0.0]
176 data['9_2000_46_4'] = ['R1rho', 799777399.1, 142.75412584824184, 1341.11, 0.04]
177 data['7_2000_46_10'] = ['R1rho', 799777399.1, 142.75412584824184, 1341.11, 0.1]
178 data['10_2000_46_20'] = ['R1rho', 799777399.1, 142.75412584824184, 1341.11, 0.2]
179 data['8_2000_46_40'] = ['R1rho', 799777399.1, 142.75412584824184, 1341.11, 0.4]
180 data['16_5000_46_0'] = ['R1rho', 799777399.1, 179.76831462060457, 1341.11, 0.0]
181 data['19_5000_46_4'] = ['R1rho', 799777399.1, 179.76831462060457, 1341.11, 0.04]
182 data['17_5000_46_10'] = ['R1rho', 799777399.1, 179.76831462060457, 1341.11, 0.1]
183 data['20_5000_46_20'] = ['R1rho', 799777399.1, 179.76831462060457, 1341.11, 0.2]
184 data['18_5000_46_40'] = ['R1rho', 799777399.1, 179.76831462060457, 1341.11, 0.4]
185 data['26_10000_46_0'] = ['R1rho', 799777399.1, 241.45862924120914, 1341.11, 0.0]
186 data['29_10000_46_4'] = ['R1rho', 799777399.1, 241.45862924120914, 1341.11, 0.04]
187 data['27_10000_46_10'] = ['R1rho', 799777399.1, 241.45862924120914, 1341.11, 0.1]
188 data['30_10000_46_20'] = ['R1rho', 799777399.1, 241.45862924120914, 1341.11, 0.2]
189 data['28_10000_46_40'] = ['R1rho', 799777399.1, 241.45862924120914, 1341.11, 0.4]
190
191 time_comp = {
192 '118.078_431.00':4,
193 '118.078_651.20':5,
194 '118.078_800.50':5,
195 '118.078_984.00':5,
196 '118.078_1341.11':5,
197 '118.078_1648.50':5,
198 '124.247_1341.11':5,
199 '130.416_800.50':5,
200 '130.416_1341.11':5,
201 '130.416_1648.50':5,
202 '142.754_800.50':5,
203 '142.754_1341.11':5,
204 '179.768_1341.11':5,
205 '241.459_1341.11':5}
206
207
208 print("Checking the number of time counts.")
209 for id in cdp.exp_type.keys():
210 exp_type = cdp.exp_type[id]
211 frq = cdp.spectrometer_frq[id]
212 offset = cdp.spin_lock_offset[id]
213 point = cdp.spin_lock_nu1[id]
214 count = count_relax_times(exp_type = exp_type, frq = frq, offset=offset, point = point, ei = cdp.exp_type_list.index(cdp.exp_type[id]))
215 print(id, exp_type, frq, offset, point, count)
216
217
218 print(time_comp)
219 self.assertEqual(count, time_comp['%.3f_%.2f'%(offset, point)])
220
221
223 """Unit test of the find_intensity_keys() function.
224
225 This uses the data of the saved state attached to U{bug #21344<https://web.archive.org/web/https://gna.org/bugs/?21344>}.
226 """
227
228
229 statefile = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21344_trunc.bz2'
230 state.load_state(statefile, force=True)
231
232
233 data = dict()
234 data['118_431.00_0.00'] = ['46_0_35_0', 'R1rho', 799777399.1, 118.078, 431.0, 0.0]
235 data['118_431.00_0.04'] = ['48_0_35_4', 'R1rho', 799777399.1, 118.078, 431.0, 0.04]
236 data['118_431.00_0.10'] = ['47_0_35_10', 'R1rho', 799777399.1, 118.078, 431.0, 0.1]
237 data['118_431.00_0.20'] = ['49_0_35_20', 'R1rho', 799777399.1, 118.078, 431.0, 0.2]
238 data['118_651.20_0.00'] = ['36_0_39_0', 'R1rho', 799777399.1, 118.078, 651.2, 0.0]
239 data['118_651.20_0.04'] = ['39_0_39_4', 'R1rho', 799777399.1, 118.078, 651.2, 0.04]
240 data['118_651.20_0.10'] = ['37_0_39_10', 'R1rho', 799777399.1, 118.078, 651.2, 0.1]
241 data['118_651.20_0.20'] = ['40_0_39_20', 'R1rho', 799777399.1, 118.078, 651.2, 0.2]
242 data['118_651.20_0.40'] = ['38_0_39_40', 'R1rho', 799777399.1, 118.078, 651.2, 0.4]
243 data['118_800.50_0.00'] = ['41_0_41_0', 'R1rho', 799777399.1, 118.078, 800.5, 0.0]
244 data['118_800.50_0.04'] = ['44_0_41_4', 'R1rho', 799777399.1, 118.078, 800.5, 0.04]
245 data['118_800.50_0.10'] = ['42_0_41_10', 'R1rho', 799777399.1, 118.078, 800.5, 0.1]
246 data['118_800.50_0.20'] = ['45_0_41_20', 'R1rho', 799777399.1, 118.078, 800.5, 0.2]
247 data['118_800.50_0.40'] = ['43_0_41_40', 'R1rho', 799777399.1, 118.078, 800.5, 0.4]
248 data['118_984.00_0.00'] = ['31_0_43_0', 'R1rho', 799777399.1, 118.078, 984.0, 0.0]
249 data['118_984.00_0.04'] = ['34_0_43_4', 'R1rho', 799777399.1, 118.078, 984.0, 0.04]
250 data['118_984.00_0.10'] = ['32_0_43_10', 'R1rho', 799777399.1, 118.078, 984.0, 0.1]
251 data['118_984.00_0.20'] = ['35_0_43_20', 'R1rho', 799777399.1, 118.078, 984.0, 0.2]
252 data['118_984.00_0.40'] = ['33_0_43_40', 'R1rho', 799777399.1, 118.078, 984.0, 0.4]
253 data['118_1341.11_0.00'] = ['1_0_46_0', 'R1rho', 799777399.1, 118.078, 1341.11, 0.0]
254 data['118_1341.11_0.04'] = ['4_0_46_4', 'R1rho', 799777399.1, 118.078, 1341.11, 0.04]
255 data['118_1341.11_0.10'] = ['2_0_46_10', 'R1rho', 799777399.1, 118.078, 1341.11, 0.1]
256 data['118_1341.11_0.20'] = ['5_0_46_20', 'R1rho', 799777399.1, 118.078, 1341.11, 0.2]
257 data['118_1341.11_0.40'] = ['3_0_46_40', 'R1rho', 799777399.1, 118.078, 1341.11, 0.4]
258 data['118_1648.50_0.00'] = ['60_0_48_0', 'R1rho', 799777399.1, 118.078, 1648.5, 0.0]
259 data['118_1648.50_0.04'] = ['63_0_48_4', 'R1rho', 799777399.1, 118.078, 1648.5, 0.04]
260 data['118_1648.50_0.10'] = ['61_0_48_10', 'R1rho', 799777399.1, 118.078, 1648.5, 0.1]
261 data['118_1648.50_0.14'] = ['62_0_48_14', 'R1rho', 799777399.1, 118.078, 1648.5, 0.14]
262 data['118_1648.50_0.20'] = ['64_0_48_20', 'R1rho', 799777399.1, 118.078, 1648.5, 0.2]
263 data['124_1341.11_0.00'] = ['11_500_46_0', 'R1rho', 799777399.1, 124.247031462, 1341.11, 0.0]
264 data['124_1341.11_0.04'] = ['14_500_46_4', 'R1rho', 799777399.1, 124.247031462, 1341.11, 0.04]
265 data['124_1341.11_0.10'] = ['12_500_46_10', 'R1rho', 799777399.1, 124.247031462, 1341.11, 0.1]
266 data['124_1341.11_0.20'] = ['15_500_46_20', 'R1rho', 799777399.1, 124.247031462, 1341.11, 0.2]
267 data['124_1341.11_0.40'] = ['13_500_46_40', 'R1rho', 799777399.1, 124.247031462, 1341.11, 0.4]
268 data['130_800.50_0.00'] = ['50_1000_41_0', 'R1rho', 799777399.1, 130.416062924, 800.5, 0.0]
269 data['130_800.50_0.04'] = ['53_1000_41_4', 'R1rho', 799777399.1, 130.416062924, 800.5, 0.04]
270 data['130_800.50_0.10'] = ['51_1000_41_10', 'R1rho', 799777399.1, 130.416062924, 800.5, 0.1]
271 data['130_800.50_0.20'] = ['54_1000_41_20', 'R1rho', 799777399.1, 130.416062924, 800.5, 0.2]
272 data['130_800.50_0.40'] = ['52_1000_41_40', 'R1rho', 799777399.1, 130.416062924, 800.5, 0.4]
273 data['130_1341.11_0.00'] = ['21_1000_46_0', 'R1rho', 799777399.1, 130.416062924, 1341.11, 0.0]
274 data['130_1341.11_0.04'] = ['24_1000_46_4', 'R1rho', 799777399.1, 130.416062924, 1341.11, 0.04]
275 data['130_1341.11_0.10'] = ['22_1000_46_10', 'R1rho', 799777399.1, 130.416062924, 1341.11, 0.1]
276 data['130_1341.11_0.20'] = ['25_1000_46_20', 'R1rho', 799777399.1, 130.416062924, 1341.11, 0.2]
277 data['130_1341.11_0.40'] = ['23_1000_46_40', 'R1rho', 799777399.1, 130.416062924, 1341.11, 0.4]
278 data['130_1648.50_0.00'] = ['65_1000_48_0', 'R1rho', 799777399.1, 130.416062924, 1648.5, 0.0]
279 data['130_1648.50_0.04'] = ['68_1000_48_4', 'R1rho', 799777399.1, 130.416062924, 1648.5, 0.04]
280 data['130_1648.50_0.10'] = ['66_1000_48_10', 'R1rho', 799777399.1, 130.416062924, 1648.5, 0.1]
281 data['130_1648.50_0.14'] = ['67_1000_48_14', 'R1rho', 799777399.1, 130.416062924, 1648.5, 0.14]
282 data['130_1648.50_0.20'] = ['69_1000_48_20', 'R1rho', 799777399.1, 130.416062924, 1648.5, 0.2]
283 data['143_800.50_0.00'] = ['55_2000_41_0', 'R1rho', 799777399.1, 142.754125848, 800.5, 0.0]
284 data['143_800.50_0.04'] = ['58_2000_41_4', 'R1rho', 799777399.1, 142.754125848, 800.5, 0.04]
285 data['143_800.50_0.10'] = ['56_2000_41_10', 'R1rho', 799777399.1, 142.754125848, 800.5, 0.1]
286 data['143_800.50_0.20'] = ['59_2000_41_20', 'R1rho', 799777399.1, 142.754125848, 800.5, 0.2]
287 data['143_800.50_0.40'] = ['57_2000_41_40', 'R1rho', 799777399.1, 142.754125848, 800.5, 0.4]
288 data['143_1341.11_0.00'] = ['6_2000_46_0', 'R1rho', 799777399.1, 142.754125848, 1341.11, 0.0]
289 data['143_1341.11_0.04'] = ['9_2000_46_4', 'R1rho', 799777399.1, 142.754125848, 1341.11, 0.04]
290 data['143_1341.11_0.10'] = ['7_2000_46_10', 'R1rho', 799777399.1, 142.754125848, 1341.11, 0.1]
291 data['143_1341.11_0.20'] = ['10_2000_46_20', 'R1rho', 799777399.1, 142.754125848, 1341.11, 0.2]
292 data['143_1341.11_0.40'] = ['8_2000_46_40', 'R1rho', 799777399.1, 142.754125848, 1341.11, 0.4]
293 data['180_1341.11_0.00'] = ['16_5000_46_0', 'R1rho', 799777399.1, 179.768314621, 1341.11, 0.0]
294 data['180_1341.11_0.04'] = ['19_5000_46_4', 'R1rho', 799777399.1, 179.768314621, 1341.11, 0.04]
295 data['180_1341.11_0.10'] = ['17_5000_46_10', 'R1rho', 799777399.1, 179.768314621, 1341.11, 0.1]
296 data['180_1341.11_0.20'] = ['20_5000_46_20', 'R1rho', 799777399.1, 179.768314621, 1341.11, 0.2]
297 data['180_1341.11_0.40'] = ['18_5000_46_40', 'R1rho', 799777399.1, 179.768314621, 1341.11, 0.4]
298 data['241_1341.11_0.00'] = ['26_10000_46_0', 'R1rho', 799777399.1, 241.458629241, 1341.11, 0.0]
299 data['241_1341.11_0.04'] = ['29_10000_46_4', 'R1rho', 799777399.1, 241.458629241, 1341.11, 0.04]
300 data['241_1341.11_0.10'] = ['27_10000_46_10', 'R1rho', 799777399.1, 241.458629241, 1341.11, 0.1]
301 data['241_1341.11_0.20'] = ['30_10000_46_20', 'R1rho', 799777399.1, 241.458629241, 1341.11, 0.2]
302 data['241_1341.11_0.40'] = ['28_10000_46_40', 'R1rho', 799777399.1, 241.458629241, 1341.11, 0.4]
303
304
305 print("Checking the id return experiment.")
306 for id in cdp.exp_type.keys():
307 exp_type = cdp.exp_type[id]
308 frq = cdp.spectrometer_frq[id]
309 offset = cdp.spin_lock_offset[id]
310 point = cdp.spin_lock_nu1[id]
311
312
313 for time in loop_time(exp_type=exp_type, frq=frq, offset=offset, point=point):
314 ids = find_intensity_keys(exp_type=exp_type, frq=frq, offset=offset, point=point, time=time)
315
316 print(exp_type, frq, offset, point, time, data["%3.0f_%3.2f_%1.2f"%(offset, point, time)][5], id, ids)
317
318
319 self.assertEqual(len(ids), 1)
320
321 self.assertEqual(time, data["%3.0f_%3.2f_%1.2f"%(offset, point, time)][5])
322 self.assertEqual(ids[0], data["%3.0f_%3.2f_%1.2f"%(offset, point, time)][0])
323
324
326 """Unit test of the get_curve_type() function.
327
328 This uses the data of the saved state attached to U{bug #21665<https://web.archive.org/web/https://gna.org/bugs/?21665>}.
329 """
330
331
332 statefile = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21665.bz2'
333 state.load_state(statefile, force=True)
334
335
336 curve_type = get_curve_type()
337 print(curve_type)
338 self.assertEqual(curve_type, 'fixed time')
339
340
342 """Unit test of the get_times() function.
343
344 This uses the data of the saved state attached to U{bug #21665<https://web.archive.org/web/https://gna.org/bugs/?21665>}.
345 """
346
347
348 statefile = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21665.bz2'
349 state.load_state(statefile, force=True)
350
351
352 times = get_times()
353 for exp_type in times:
354 print(times[exp_type])
355 self.assertEqual(len(times[exp_type]), 2)
356
357
359 """Unit test of the has_exponential_exp_type() function.
360
361 This uses the data of the saved state attached to U{bug #21665<https://web.archive.org/web/https://gna.org/bugs/?21665>}.
362 """
363
364
365 statefile = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21665.bz2'
366 state.load_state(statefile, force=True)
367
368
369 exponential_exp_type = has_exponential_exp_type()
370 print(exponential_exp_type)
371 self.assertEqual(exponential_exp_type, False)
372
373
375 """Unit test of the loop_exp_frq() function.
376
377 This uses the data of the saved state attached to U{bug #21665<https://web.archive.org/web/https://gna.org/bugs/?21665>}.
378 """
379
380
381 statefile = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21665.bz2'
382 state.load_state(statefile, force=True)
383
384
385 data = [
386 ['SQ CPMG', 499862140.0],
387 ['SQ CPMG', 599890858.69999993]
388 ]
389
390
391 indices = [
392 [0, 0],
393 [0, 1]
394 ]
395
396
397 print("Checking the number of iterations of the loop.")
398 count = 0
399 for exp_type, frq, ei, mi in loop_exp_frq(return_indices=True):
400 print(exp_type, frq, ei, mi)
401 count += 1
402 self.assertEqual(count, 2)
403
404
405 print("Checking the values returned by the loop.")
406 index = 0
407 for exp_type, frq, ei, mi in loop_exp_frq(return_indices=True):
408
409 self.assertEqual(exp_type, data[index][0])
410 self.assertEqual(ei, indices[index][0])
411
412
413 self.assertEqual(frq, data[index][1])
414 self.assertEqual(mi, indices[index][1])
415
416
417 index += 1
418
419
421 """Unit test of the loop_exp_frq_offset() function.
422
423 This uses the data of the saved state attached to U{bug #21665<https://web.archive.org/web/https://gna.org/bugs/?21665>}.
424 """
425
426
427 statefile = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21665.bz2'
428 state.load_state(statefile, force=True)
429
430
431 data = [
432 ['SQ CPMG', 499862140.0, 0],
433 ['SQ CPMG', 599890858.69999993, 0]
434 ]
435
436
437 indices = [
438 [0, 0, 0],
439 [0, 1, 0]
440 ]
441
442
443 print("Checking the number of iterations of the loop.")
444 count = 0
445 for exp_type, frq, offset, ei, mi, oi in loop_exp_frq_offset(return_indices=True):
446 print(exp_type, frq, offset, ei, mi, oi)
447 count += 1
448 self.assertEqual(count, 2)
449
450
451 print("Checking the values returned by the loop.")
452 index = 0
453 for exp_type, frq, offset, ei, mi, oi in loop_exp_frq_offset(return_indices=True):
454
455 self.assertEqual(exp_type, data[index][0])
456 self.assertEqual(ei, indices[index][0])
457
458
459 self.assertEqual(frq, data[index][1])
460 self.assertEqual(mi, indices[index][1])
461
462
463 self.assertEqual(offset, data[index][2])
464 self.assertEqual(oi, indices[index][2])
465
466
467 index += 1
468
469
471 """Unit test of the loop_exp_frq_offset_point() function.
472
473 This uses the data of the saved state attached to U{bug #21665<https://web.archive.org/web/https://gna.org/bugs/?21665>}.
474 """
475
476
477 statefile = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21665.bz2'
478 state.load_state(statefile, force=True)
479
480
481 data = [
482 ['SQ CPMG', 499862140.0, 0, [50.0, 100.0, 150.0, 200.0, 250.0, 300.0, 350.0, 400.0, 450.0, 500.0, 550.0, 600.0, 650.0, 700.0, 800.0, 900.0, 1000.0]],
483 ['SQ CPMG', 599890858.69999993, 0, [33.3333, 66.666, 100.0, 133.333, 166.666, 200.0, 233.333, 266.666, 300.0, 333.333, 366.666, 400.0, 466.666, 533.333, 666.666, 866.666, 1000.0]]
484 ]
485
486
487 indices = [
488 [0, 0, 0, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]],
489 [0, 1, 0, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]]
490 ]
491
492
493 print("Checking the number of iterations of the loop.")
494 count = 0
495 for exp_type, frq, offset, point, ei, mi, oi, di in loop_exp_frq_offset_point(return_indices=True):
496 print(exp_type, frq, offset, point, ei, mi, oi, di)
497 count += 1
498 self.assertEqual(count, 34)
499
500
501 print("Checking the values returned by the loop.")
502 frq_index = 0
503 disp_index = 0
504 for exp_type, frq, offset, point, ei, mi, oi, di in loop_exp_frq_offset_point(return_indices=True):
505
506 self.assertEqual(exp_type, data[frq_index][0])
507 self.assertEqual(ei, indices[frq_index][0])
508
509
510 self.assertEqual(frq, data[frq_index][1])
511 self.assertEqual(mi, indices[frq_index][1])
512
513
514 self.assertEqual(offset, data[frq_index][2])
515 self.assertEqual(oi, indices[frq_index][2])
516
517
518 self.assertAlmostEqual(point, data[frq_index][3][disp_index], 2)
519 self.assertEqual(di, indices[frq_index][3][disp_index])
520
521
522 if disp_index == 16:
523 frq_index += 1
524 disp_index = 0
525 else:
526 disp_index += 1
527
528
530 """Unit test of the loop_exp_frq_offset_point_time() function.
531
532 This uses the data of the saved state attached to U{bug #21665<https://web.archive.org/web/https://gna.org/bugs/?21665>}.
533 """
534
535
536 statefile = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21665.bz2'
537 state.load_state(statefile, force=True)
538
539
540 data = [
541 ['SQ CPMG', 499862140.0, 0, [50.0, 100.0, 150.0, 200.0, 250.0, 300.0, 350.0, 400.0, 450.0, 500.0, 550.0, 600.0, 650.0, 700.0, 800.0, 900.0, 1000.0], 0.04],
542 ['SQ CPMG', 599890858.69999993, 0, [33.3333, 66.666, 100.0, 133.333, 166.666, 200.0, 233.333, 266.666, 300.0, 333.333, 366.666, 400.0, 466.666, 533.333, 666.666, 866.666, 1000.0], 0.06]
543 ]
544
545
546 indices = [
547 [0, 0, 0, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], 0],
548 [0, 1, 0, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], 0]
549 ]
550
551
552 print("Checking the number of iterations of the loop.")
553 count = 0
554 for exp_type, frq, offset, point, time, ei, mi, oi, di, ti in loop_exp_frq_offset_point_time(return_indices=True):
555 print(exp_type, frq, offset, point, time, ei, mi, oi, di, ti)
556 count += 1
557 self.assertEqual(count, 34)
558
559
560 print("Checking the values returned by the loop.")
561 frq_index = 0
562 disp_index = 0
563 for exp_type, frq, offset, point, time, ei, mi, oi, di, ti in loop_exp_frq_offset_point_time(return_indices=True):
564
565 self.assertEqual(exp_type, data[frq_index][0])
566 self.assertEqual(ei, indices[frq_index][0])
567
568
569 self.assertEqual(frq, data[frq_index][1])
570 self.assertEqual(mi, indices[frq_index][1])
571
572
573 self.assertEqual(offset, data[frq_index][2])
574 self.assertEqual(oi, indices[frq_index][2])
575
576
577 self.assertAlmostEqual(point, data[frq_index][3][disp_index], 2)
578 self.assertEqual(di, indices[frq_index][3][disp_index])
579
580
581 self.assertEqual(time, data[frq_index][4])
582 self.assertEqual(ti, indices[frq_index][4])
583
584
585 if disp_index == 16:
586 frq_index += 1
587 disp_index = 0
588 else:
589 disp_index += 1
590
591
593 """U{Bug #21665<https://web.archive.org/web/https://gna.org/bugs/?21665>} catch, the failure due to a a CPMG analysis recorded at two fields at two delay times, using calc()."""
594
595
596 statefile = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21665.bz2'
597 state.load_state(statefile, force=True)
598
599
600 ncyc_1 = [20, 16, 10, 36, 2, 12, 4, 22, 18, 40, 14, 26, 8, 32, 24, 6, 28]
601 sfrq_1 = 499.86214*1E6
602 time_T2_1 = 0.04
603 cpmg_1 = sorted([ncyc/time_T2_1 for ncyc in ncyc_1])
604
605 ncyc_2 = [28, 4, 32, 60, 2, 10, 16, 8, 20, 52, 18, 40, 6, 12, 24, 14, 22]
606 sfrq_2 = 599.8908587*1E6
607 time_T2_2 = 0.06
608 cpmg_2 = sorted([ncyc/time_T2_2 for ncyc in ncyc_2])
609
610
611
612 i = -1
613 j = -1
614 for exp_type, frq, offset, point, time, ei, mi, oi, di, ti in loop_exp_frq_offset_point_time(return_indices=True):
615 if frq == sfrq_1:
616 i += 1
617 self.assertEqual(time, time_T2_1)
618 self.assertAlmostEqual(point, cpmg_1[i], 3)
619 if frq == sfrq_2:
620 j += 1
621 self.assertEqual(time, time_T2_2)
622 self.assertAlmostEqual(point, cpmg_2[j], 3)
623
624
626 """Unit test of the loop_time() function.
627
628 This uses the data of the saved state attached to U{bug #21665<https://web.archive.org/web/https://gna.org/bugs/?21665>}.
629 """
630
631
632 statefile = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21665.bz2'
633 state.load_state(statefile, force=True)
634
635
636 data = [
637 ['SQ CPMG', 499862140.0, 0, [50.0, 100.0, 150.0, 200.0, 250.0, 300.0, 350.0, 400.0, 450.0, 500.0, 550.0, 600.0, 650.0, 700.0, 800.0, 900.0, 1000.0], 0.04],
638 ['SQ CPMG', 599890858.69999993, 0, [33.3333, 66.666, 100.0, 133.333, 166.666, 200.0, 233.333, 266.666, 300.0, 333.333, 366.666, 400.0, 466.666, 533.333, 666.666, 866.666, 1000.0], 0.06]
639 ]
640
641
642 indices = [
643 [0, 0, 0, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], 0],
644 [0, 1, 0, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], 0]
645 ]
646
647
648 print("Checking the number of iterations of the loop.")
649 count_frq = 0
650 for dat in data:
651 frq = dat[1]
652 for time, ti in loop_time(frq=frq, return_indices=True):
653 print(time, ti)
654 count_frq += 1
655 self.assertEqual(count_frq, 2)
656
657
659 """Unit test of the loop_time() function for R1rho setup.
660
661 This uses the data of the saved state attached to U{bug #21344<https://web.archive.org/web/https://gna.org/bugs/?21344>}.
662 """
663
664
665 statefile = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21344_trunc.bz2'
666 state.load_state(statefile, force=True)
667
668
669 offset_point_time_list = [
670 [118.078, 431.0, [0.0, 0.04, 0.1, 0.2]],
671 [118.078, 651.2, [0.0, 0.04, 0.1, 0.2, 0.4]],
672 [118.078, 800.5, [0.0, 0.04, 0.1, 0.2, 0.4]],
673 [118.078, 984.0, [0.0, 0.04, 0.1, 0.2, 0.4]],
674 [118.078, 1341.11, [0.0, 0.04, 0.1, 0.2, 0.4]],
675 [118.078, 1648.5, [0.0, 0.04, 0.1, 0.14, 0.2]],
676 [124.247031462, 1341.11, [0.0, 0.04, 0.1, 0.2, 0.4]],
677 [130.416062924, 800.5, [0.0, 0.04, 0.1, 0.2, 0.4]],
678 [130.416062924, 1341.11, [0.0, 0.04, 0.1, 0.2, 0.4]],
679 [130.416062924, 1648.5, [0.0, 0.04, 0.1, 0.14, 0.2]],
680 [142.754125848, 800.5, [0.0, 0.04, 0.1, 0.2, 0.4]],
681 [142.754125848, 1341.11, [0.0, 0.04, 0.1, 0.2, 0.4]],
682 [179.768314621, 1341.11, [0.0, 0.04, 0.1, 0.2, 0.4]],
683 [241.458629241, 1341.11, [0.0, 0.04, 0.1, 0.2, 0.4]]]
684
685
686
687 print("Checking the number of iterations of the loop.")
688 frq = 799777399.1
689
690 for offset, point, time_list in offset_point_time_list:
691
692 count = 0
693 for time, ti in loop_time(frq=frq, offset=offset, point=point, return_indices=True):
694 print(frq, offset, point, time, ti, count)
695 self.assertEqual(time, time_list[count])
696 self.assertEqual(ti, count)
697 count += 1
698
699
701 """Unit test of the return_offset_data() function for R1rho setup.
702
703 This uses the data of the saved state attached to U{bug #21344<https://web.archive.org/web/https://gna.org/bugs/?21344>}.
704 """
705
706
707 statefile = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21344_trunc.bz2'
708 state.load_state(statefile, force=True)
709
710
711 field_count = cdp.spectrometer_frq_count
712
713
714 spin_lock_nu1 = return_spin_lock_nu1(ref_flag=False)
715
716
717 all_spin_ids = get_spin_ids()
718
719
720 cur_spin_ids = []
721 cur_spins = []
722 for curspin_id in all_spin_ids:
723
724 curspin = return_spin(curspin_id)
725
726
727 if curspin.select == True:
728 cur_spin_ids.append(curspin_id)
729 cur_spins.append(curspin)
730
731
732 sfrq = cdp.spectrometer_frq_list[0]
733
734
735 g1H = 26.7522212 * 1e7
736 g15N = -2.7126 * 1e7
737
738
739 chemical_shifts, offsets, tilt_angles, Delta_omega, w_eff = return_offset_data(spins=cur_spins, spin_ids=cur_spin_ids, field_count=field_count, fields=spin_lock_nu1)
740
741
742 print("Printing the following")
743 print("exp_type curspin_id frq offset{ppm} offsets[ei][si][mi][oi]{rad/s} ei mi oi si di cur_spin.chemical_shift{ppm} chemical_shifts[ei][si][mi]{rad/s} spin_lock_nu1{Hz} tilt_angles[ei][si][mi][oi]{rad}")
744 for si in range(len(cur_spin_ids)):
745 curspin_id = cur_spin_ids[si]
746 cur_spin = cur_spins[si]
747 for exp_type, frq, offset, ei, mi, oi in loop_exp_frq_offset(return_indices=True):
748
749 spin_lock_fields = spin_lock_nu1[ei][mi][oi]
750 for di in range(len(spin_lock_fields)):
751 print("%-8s %-10s %11.1f %8.4f %12.5f %i %i %i %i %i %7.3f %12.5f %12.5f %12.5f"%(exp_type, curspin_id, frq, offset, offsets[ei][si][mi][oi], ei, mi, oi, si, di, cur_spin.chemical_shift, chemical_shifts[ei][si][mi], spin_lock_fields[di], tilt_angles[ei][si][mi][oi][di]))
752
753 self.assertEqual(chemical_shifts[ei][si][mi], cur_spin.chemical_shift * 2.0 * pi * sfrq / g1H * g15N * 1e-6)
754
755 self.assertEqual(offsets[ei][si][mi][oi], offset * 2.0 * pi * sfrq / g1H * g15N * 1e-6)
756
757 c_omega1 = spin_lock_fields[di] * 2.0 * pi
758 c_Delta_omega = chemical_shifts[ei][si][mi] - offsets[ei][si][mi][oi]
759 if c_omega1 / c_Delta_omega > 0:
760 c_theta = atan(c_omega1 / c_Delta_omega)
761 else:
762 c_theta = pi + atan(c_omega1 / c_Delta_omega)
763 self.assertAlmostEqual(tilt_angles[ei][si][mi][oi][di], c_theta, 15)
764