1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 """The model-free analysis parameter functions."""
24
25
26 from math import pi
27 from numpy import array, float64, int8, zeros
28 from re import match
29
30
31 from lib.errors import RelaxError
32 from pipe_control import diffusion_tensor
33 from pipe_control.mol_res_spin import spin_loop
34 from specific_analyses.model_free.model import determine_model_type
35
36
93
94
96 """Function for assembling a list of all the model parameter names.
97
98 @param model_type: The model-free model type. This must be one of 'mf', 'local_tm',
99 'diff', or 'all'.
100 @type model_type: str
101 @param spin_id: The spin identification string.
102 @type spin_id: str
103 @return: A list containing all the parameters of the model-free model.
104 @rtype: list of str
105 """
106
107
108 param_names = []
109
110
111 if model_type == 'diff' or model_type == 'all':
112
113 if cdp.diff_tensor.type == 'sphere':
114 param_names.append('tm')
115
116
117 elif cdp.diff_tensor.type == 'spheroid':
118 param_names.append('tm')
119 param_names.append('Da')
120 param_names.append('theta')
121 param_names.append('phi')
122
123
124 elif cdp.diff_tensor.type == 'ellipsoid':
125 param_names.append('tm')
126 param_names.append('Da')
127 param_names.append('Dr')
128 param_names.append('alpha')
129 param_names.append('beta')
130 param_names.append('gamma')
131
132
133 if model_type != 'diff':
134
135 for spin in spin_loop(spin_id):
136
137 if not spin.select:
138 continue
139
140
141 param_names = param_names + spin.params
142
143
144 return param_names
145
146
148 """Assemble the model-free parameter vector (as numpy array).
149
150 If the spin argument is supplied, then the spin_id argument will be ignored.
151
152 @keyword spin: The spin data container.
153 @type spin: SpinContainer instance
154 @keyword spin_id: The spin identification string.
155 @type spin_id: str
156 @keyword sim_index: The optional MC simulation index.
157 @type sim_index: int
158 @keyword model_type: The optional model type, one of 'all', 'diff', 'mf', or 'local_tm'.
159 @type model_type: str or None
160 @return: An array of the parameter values of the model-free model.
161 @rtype: numpy array
162 """
163
164
165 param_vector = []
166
167
168 if not model_type:
169 model_type = determine_model_type()
170
171
172 if model_type == 'diff' or model_type == 'all':
173
174 if sim_index == None:
175
176 if cdp.diff_tensor.type == 'sphere':
177 if hasattr(cdp.diff_tensor, 'tm'):
178 param_vector.append(cdp.diff_tensor.tm)
179 else:
180 param_vector.append(None)
181
182
183 elif cdp.diff_tensor.type == 'spheroid':
184 if hasattr(cdp.diff_tensor, 'tm'):
185 param_vector.append(cdp.diff_tensor.tm)
186 param_vector.append(cdp.diff_tensor.Da)
187 param_vector.append(cdp.diff_tensor.theta)
188 param_vector.append(cdp.diff_tensor.phi)
189 else:
190 param_vector += [None, None, None, None]
191
192
193 elif cdp.diff_tensor.type == 'ellipsoid':
194 if hasattr(cdp.diff_tensor, 'tm'):
195 param_vector.append(cdp.diff_tensor.tm)
196 param_vector.append(cdp.diff_tensor.Da)
197 param_vector.append(cdp.diff_tensor.Dr)
198 param_vector.append(cdp.diff_tensor.alpha)
199 param_vector.append(cdp.diff_tensor.beta)
200 param_vector.append(cdp.diff_tensor.gamma)
201 else:
202 param_vector += [None, None, None, None, None, None]
203
204
205 else:
206
207 if cdp.diff_tensor.type == 'sphere':
208 param_vector.append(cdp.diff_tensor.tm_sim[sim_index])
209
210
211 elif cdp.diff_tensor.type == 'spheroid':
212 param_vector.append(cdp.diff_tensor.tm_sim[sim_index])
213 param_vector.append(cdp.diff_tensor.Da_sim[sim_index])
214 param_vector.append(cdp.diff_tensor.theta_sim[sim_index])
215 param_vector.append(cdp.diff_tensor.phi_sim[sim_index])
216
217
218 elif cdp.diff_tensor.type == 'ellipsoid':
219 param_vector.append(cdp.diff_tensor.tm_sim[sim_index])
220 param_vector.append(cdp.diff_tensor.Da_sim[sim_index])
221 param_vector.append(cdp.diff_tensor.Dr_sim[sim_index])
222 param_vector.append(cdp.diff_tensor.alpha_sim[sim_index])
223 param_vector.append(cdp.diff_tensor.beta_sim[sim_index])
224 param_vector.append(cdp.diff_tensor.gamma_sim[sim_index])
225
226
227 if model_type != 'diff':
228
229 if spin:
230 loop = [spin]
231 else:
232 loop = spin_loop(spin_id)
233
234
235 for spin in loop:
236
237 if not spin.select:
238 continue
239
240
241 if not hasattr(spin, 'params'):
242 continue
243
244
245 for i in range(len(spin.params)):
246
247 if spin.params[i] == 'local_tm':
248 if sim_index == None:
249 param_vector.append(spin.local_tm)
250 else:
251 param_vector.append(spin.local_tm_sim[sim_index])
252
253
254 elif spin.params[i] == 's2':
255 if sim_index == None:
256 param_vector.append(spin.s2)
257 else:
258 param_vector.append(spin.s2_sim[sim_index])
259
260
261 elif spin.params[i] == 's2f':
262 if sim_index == None:
263 param_vector.append(spin.s2f)
264 else:
265 param_vector.append(spin.s2f_sim[sim_index])
266
267
268 elif spin.params[i] == 's2s':
269 if sim_index == None:
270 param_vector.append(spin.s2s)
271 else:
272 param_vector.append(spin.s2s_sim[sim_index])
273
274
275 elif spin.params[i] == 'te':
276 if sim_index == None:
277 param_vector.append(spin.te)
278 else:
279 param_vector.append(spin.te_sim[sim_index])
280
281
282 elif spin.params[i] == 'tf':
283 if sim_index == None:
284 param_vector.append(spin.tf)
285 else:
286 param_vector.append(spin.tf_sim[sim_index])
287
288
289 elif spin.params[i] == 'ts':
290 if sim_index == None:
291 param_vector.append(spin.ts)
292 else:
293 param_vector.append(spin.ts_sim[sim_index])
294
295
296 elif spin.params[i] == 'rex':
297 if sim_index == None:
298 param_vector.append(spin.rex)
299 else:
300 param_vector.append(spin.rex_sim[sim_index])
301
302
303 elif spin.params[i] == 'r':
304 if sim_index == None:
305 param_vector.append(spin.r)
306 else:
307 param_vector.append(spin.r_sim[sim_index])
308
309
310 elif spin.params[i] == 'csa':
311 if sim_index == None:
312 param_vector.append(spin.csa)
313 else:
314 param_vector.append(spin.csa_sim[sim_index])
315
316
317 else:
318 raise RelaxError("Unknown parameter.")
319
320
321 return array(param_vector, float64)
322
323
325 """Calculate and return the Rex conversion factor.
326
327 @return: The Rex conversion factor.
328 @rtype: float
329 """
330
331
332 if not hasattr(cdp, 'spectrometer_frq'):
333 raise RelaxError("No spectrometer frequency information is present in the current data pipe.")
334
335
336 if hasattr(cdp, 'ri_ids'):
337 frq = cdp.spectrometer_frq[cdp.ri_ids[0]]
338
339
340 else:
341 frqs = sorted(cdp.spectrometer_frq.values())
342 frq = frqs[-1]
343
344
345 return 1.0 / (2.0 * pi * frq)**2
346
347
349 """Disassemble the model-free parameter vector.
350
351 @param model_type: The model-free model type. This must be one of 'mf', 'local_tm',
352 'diff', or 'all'.
353 @type model_type: str
354 @keyword param_vector: The model-free parameter vector.
355 @type param_vector: numpy array
356 @keyword spin: The spin data container. If this argument is supplied, then the spin_id
357 argument will be ignored.
358 @type spin: SpinContainer instance
359 @keyword spin_id: The spin identification string.
360 @type spin_id: str
361 @keyword sim_index: The optional MC simulation index.
362 @type sim_index: int
363 """
364
365
366 param_index = 0
367
368
369 if sim_index != None and (model_type == 'diff' or model_type == 'all'):
370
371 if cdp.diff_tensor.type == 'sphere':
372
373 cdp.diff_tensor.set(param='tm', value=param_vector[0], category='sim', sim_index=sim_index)
374
375
376 param_index = param_index + 1
377
378
379 elif cdp.diff_tensor.type == 'spheroid':
380
381 cdp.diff_tensor.set(param='tm', value=param_vector[0], category='sim', sim_index=sim_index)
382 cdp.diff_tensor.set(param='Da', value=param_vector[1], category='sim', sim_index=sim_index)
383 cdp.diff_tensor.set(param='theta', value=param_vector[2], category='sim', sim_index=sim_index)
384 cdp.diff_tensor.set(param='phi', value=param_vector[3], category='sim', sim_index=sim_index)
385 diffusion_tensor.fold_angles(sim_index=sim_index)
386
387
388 param_index = param_index + 4
389
390
391 elif cdp.diff_tensor.type == 'ellipsoid':
392
393 cdp.diff_tensor.set(param='tm', value=param_vector[0], category='sim', sim_index=sim_index)
394 cdp.diff_tensor.set(param='Da', value=param_vector[1], category='sim', sim_index=sim_index)
395 cdp.diff_tensor.set(param='Dr', value=param_vector[2], category='sim', sim_index=sim_index)
396 cdp.diff_tensor.set(param='alpha', value=param_vector[3], category='sim', sim_index=sim_index)
397 cdp.diff_tensor.set(param='beta', value=param_vector[4], category='sim', sim_index=sim_index)
398 cdp.diff_tensor.set(param='gamma', value=param_vector[5], category='sim', sim_index=sim_index)
399 diffusion_tensor.fold_angles(sim_index=sim_index)
400
401
402 param_index = param_index + 6
403
404
405 elif model_type == 'diff' or model_type == 'all':
406
407 if cdp.diff_tensor.type == 'sphere':
408
409 cdp.diff_tensor.set(param='tm', value=param_vector[0])
410
411
412 param_index = param_index + 1
413
414
415 elif cdp.diff_tensor.type == 'spheroid':
416
417 cdp.diff_tensor.set(param='tm', value=param_vector[0])
418 cdp.diff_tensor.set(param='Da', value=param_vector[1])
419 cdp.diff_tensor.set(param='theta', value=param_vector[2])
420 cdp.diff_tensor.set(param='phi', value=param_vector[3])
421 diffusion_tensor.fold_angles()
422
423
424 param_index = param_index + 4
425
426
427 elif cdp.diff_tensor.type == 'ellipsoid':
428
429 cdp.diff_tensor.set(param='tm', value=param_vector[0])
430 cdp.diff_tensor.set(param='Da', value=param_vector[1])
431 cdp.diff_tensor.set(param='Dr', value=param_vector[2])
432 cdp.diff_tensor.set(param='alpha', value=param_vector[3])
433 cdp.diff_tensor.set(param='beta', value=param_vector[4])
434 cdp.diff_tensor.set(param='gamma', value=param_vector[5])
435 diffusion_tensor.fold_angles()
436
437
438 param_index = param_index + 6
439
440
441 if model_type != 'diff':
442
443 if spin:
444 loop = [spin]
445 else:
446 loop = spin_loop(spin_id)
447
448
449 for spin in loop:
450
451 if not spin.select:
452 continue
453
454
455 for j in range(len(spin.params)):
456
457 if spin.params[j] == 'local_tm':
458 if sim_index == None:
459 spin.local_tm = param_vector[param_index]
460 else:
461 spin.local_tm_sim[sim_index] = param_vector[param_index]
462
463
464 elif spin.params[j] == 's2':
465 if sim_index == None:
466 spin.s2 = param_vector[param_index]
467 else:
468 spin.s2_sim[sim_index] = param_vector[param_index]
469
470
471 elif spin.params[j] == 's2f':
472 if sim_index == None:
473 spin.s2f = param_vector[param_index]
474 else:
475 spin.s2f_sim[sim_index] = param_vector[param_index]
476
477
478 elif spin.params[j] == 's2s':
479 if sim_index == None:
480 spin.s2s = param_vector[param_index]
481 else:
482 spin.s2s_sim[sim_index] = param_vector[param_index]
483
484
485 elif spin.params[j] == 'te':
486 if sim_index == None:
487 spin.te = param_vector[param_index]
488 else:
489 spin.te_sim[sim_index] = param_vector[param_index]
490
491
492 elif spin.params[j] == 'tf':
493 if sim_index == None:
494 spin.tf = param_vector[param_index]
495 else:
496 spin.tf_sim[sim_index] = param_vector[param_index]
497
498
499 elif spin.params[j] == 'ts':
500 if sim_index == None:
501 spin.ts = param_vector[param_index]
502 else:
503 spin.ts_sim[sim_index] = param_vector[param_index]
504
505
506 elif spin.params[j] == 'rex':
507 if sim_index == None:
508 spin.rex = param_vector[param_index]
509 else:
510 spin.rex_sim[sim_index] = param_vector[param_index]
511
512
513 elif spin.params[j] == 'r':
514 if sim_index == None:
515 spin.r = param_vector[param_index]
516 else:
517 spin.r_sim[sim_index] = param_vector[param_index]
518
519
520 elif spin.params[j] == 'csa':
521 if sim_index == None:
522 spin.csa = param_vector[param_index]
523 else:
524 spin.csa_sim[sim_index] = param_vector[param_index]
525
526
527 else:
528 raise RelaxError("Unknown parameter.")
529
530
531 param_index = param_index + 1
532
533
534 if model_type != 'diff':
535
536 if spin:
537 loop = [spin]
538 else:
539 loop = spin_loop(spin_id)
540
541
542 for spin in loop:
543
544 if not spin.select:
545 continue
546
547
548 if sim_index == None:
549
550 if 's2' not in spin.params and 's2f' in spin.params and 's2s' in spin.params:
551 spin.s2 = spin.s2f * spin.s2s
552
553
554 if 's2f' not in spin.params and 's2' in spin.params and 's2s' in spin.params:
555 if spin.s2s == 0.0:
556 spin.s2f = 1e99
557 else:
558 spin.s2f = spin.s2 / spin.s2s
559
560
561 if 's2s' not in spin.params and 's2' in spin.params and 's2f' in spin.params:
562 if spin.s2f == 0.0:
563 spin.s2s = 1e99
564 else:
565 spin.s2s = spin.s2 / spin.s2f
566
567
568 else:
569
570 if 's2' not in spin.params and 's2f' in spin.params and 's2s' in spin.params:
571 spin.s2_sim[sim_index] = spin.s2f_sim[sim_index] * spin.s2s_sim[sim_index]
572
573
574 if 's2f' not in spin.params and 's2' in spin.params and 's2s' in spin.params:
575 if spin.s2s_sim[sim_index] == 0.0:
576 spin.s2f_sim[sim_index] = 1e99
577 else:
578 spin.s2f_sim[sim_index] = spin.s2_sim[sim_index] / spin.s2s_sim[sim_index]
579
580
581 if 's2s' not in spin.params and 's2' in spin.params and 's2f' in spin.params:
582 if spin.s2f_sim[sim_index] == 0.0:
583 spin.s2s_sim[sim_index] = 1e99
584 else:
585 spin.s2s_sim[sim_index] = spin.s2_sim[sim_index] / spin.s2f_sim[sim_index]
586
587
588 -def linear_constraints(num_params, model_type=None, spin=None, spin_id=None, scaling_matrix=None):
589 """Set up the model-free linear constraint matrices A and b.
590
591 Standard notation
592 =================
593
594 The order parameter constraints are::
595
596 0 <= S2 <= 1
597 0 <= S2f <= 1
598 0 <= S2s <= 1
599
600 By substituting the formula S2 = S2f.S2s into the above inequalities, the additional two
601 inequalities can be derived::
602
603 S2 <= S2f
604 S2 <= S2s
605
606 Correlation time constraints are::
607
608 te >= 0
609 tf >= 0
610 ts >= 0
611
612 tf <= ts
613
614 te, tf, ts <= 2 * tm
615
616 Additional constraints used include::
617
618 Rex >= 0
619 0.9e-10 <= r <= 2e-10
620 -300e-6 <= CSA <= 0
621
622
623 Rearranged notation
624 ===================
625
626 The above inequality constraints can be rearranged into::
627
628 S2 >= 0
629 -S2 >= -1
630 S2f >= 0
631 -S2f >= -1
632 S2s >= 0
633 -S2s >= -1
634 S2f - S2 >= 0
635 S2s - S2 >= 0
636 te >= 0
637 tf >= 0
638 ts >= 0
639 ts - tf >= 0
640 Rex >= 0
641 r >= 0.9e-10
642 -r >= -2e-10
643 CSA >= -300e-6
644 -CSA >= 0
645
646
647 Matrix notation
648 ===============
649
650 In the notation A.x >= b, where A is an matrix of coefficients, x is an array of parameter
651 values, and b is a vector of scalars, these inequality constraints are::
652
653 | 1 0 0 0 0 0 0 0 0 | | 0 |
654 | | | |
655 |-1 0 0 0 0 0 0 0 0 | | -1 |
656 | | | |
657 | 0 1 0 0 0 0 0 0 0 | | 0 |
658 | | | |
659 | 0 -1 0 0 0 0 0 0 0 | | -1 |
660 | | | |
661 | 0 0 1 0 0 0 0 0 0 | | S2 | | 0 |
662 | | | | | |
663 | 0 0 -1 0 0 0 0 0 0 | | S2f | | -1 |
664 | | | | | |
665 |-1 1 0 0 0 0 0 0 0 | | S2s | | 0 |
666 | | | | | |
667 |-1 0 1 0 0 0 0 0 0 | | te | | 0 |
668 | | | | | |
669 | 0 0 0 1 0 0 0 0 0 | . | tf | >= | 0 |
670 | | | | | |
671 | 0 0 0 0 1 0 0 0 0 | | ts | | 0 |
672 | | | | | |
673 | 0 0 0 0 0 1 0 0 0 | | Rex | | 0 |
674 | | | | | |
675 | 0 0 0 0 -1 1 0 0 0 | | r | | 0 |
676 | | | | | |
677 | 0 0 0 0 0 0 1 0 0 | | CSA | | 0 |
678 | | | |
679 | 0 0 0 0 0 0 0 1 0 | | 0.9e-10 |
680 | | | |
681 | 0 0 0 0 0 0 0 -1 0 | | -2e-10 |
682 | | | |
683 | 0 0 0 0 0 0 0 0 1 | | -300e-6 |
684 | | | |
685 | 0 0 0 0 0 0 0 0 -1 | | 0 |
686
687
688 @param num_params: The number of parameters in the model.
689 @type num_params: int
690 @keyword model_type: The model type, one of 'all', 'diff', 'mf', or 'local_tm'.
691 @type model_type: str
692 @keyword spin: The spin data container. If this argument is supplied, then the
693 spin_id argument will be ignored.
694 @type spin: SpinContainer instance
695 @keyword spin_id: The spin identification string.
696 @type spin_id: str
697 @keyword scaling_matrix: The diagonal, square scaling matrix.
698 @type scaling_matrix: numpy diagonal matrix
699 """
700
701
702 upper_time_limit = 1
703
704
705 A = []
706 b = []
707 zero_array = zeros(num_params, float64)
708 i = 0
709 j = 0
710
711
712 if model_type != 'mf' and diffusion_tensor.diff_data_exists():
713
714 if cdp.diff_tensor.type == 'sphere':
715
716 A.append(zero_array * 0.0)
717 A.append(zero_array * 0.0)
718 A[j][i] = 1.0
719 A[j+1][i] = -1.0
720 b.append(0.0 / scaling_matrix[i, i])
721 b.append(-200.0 * 1e-9 / scaling_matrix[i, i])
722 i = i + 1
723 j = j + 2
724
725
726 elif cdp.diff_tensor.type == 'spheroid':
727
728 A.append(zero_array * 0.0)
729 A.append(zero_array * 0.0)
730 A[j][i] = 1.0
731 A[j+1][i] = -1.0
732 b.append(0.0 / scaling_matrix[i, i])
733 b.append(-200.0 * 1e-9 / scaling_matrix[i, i])
734 i = i + 1
735 j = j + 2
736
737
738 if cdp.diff_tensor.spheroid_type == 'prolate':
739 A.append(zero_array * 0.0)
740 A[j][i] = 1.0
741 b.append(0.0 / scaling_matrix[i, i])
742 i = i + 1
743 j = j + 1
744
745
746 i = i + 2
747
748
749 elif cdp.diff_tensor.spheroid_type == 'oblate':
750 A.append(zero_array * 0.0)
751 A[j][i] = -1.0
752 b.append(0.0 / scaling_matrix[i, i])
753 i = i + 1
754 j = j + 1
755
756
757 i = i + 2
758
759 else:
760
761 i = i + 3
762
763
764 elif cdp.diff_tensor.type == 'ellipsoid':
765
766 A.append(zero_array * 0.0)
767 A.append(zero_array * 0.0)
768 A[j][i] = 1.0
769 A[j+1][i] = -1.0
770 b.append(0.0 / scaling_matrix[i, i])
771 b.append(-200.0 * 1e-9 / scaling_matrix[i, i])
772 i = i + 1
773 j = j + 2
774
775
776 A.append(zero_array * 0.0)
777 A[j][i] = 1.0
778 b.append(0.0 / scaling_matrix[i, i])
779 i = i + 1
780 j = j + 1
781
782
783 A.append(zero_array * 0.0)
784 A.append(zero_array * 0.0)
785 A[j][i] = 1.0
786 A[j+1][i] = -1.0
787 b.append(0.0 / scaling_matrix[i, i])
788 b.append(-1.0 / scaling_matrix[i, i])
789 i = i + 1
790 j = j + 2
791
792
793 i = i + 3
794
795
796 if model_type != 'diff':
797
798 if spin:
799 loop = [spin]
800 else:
801 loop = spin_loop(spin_id)
802
803
804 for spin in loop:
805
806 if not spin.select:
807 continue
808
809
810 old_i = i
811
812
813 for l in range(len(spin.params)):
814
815 if spin.params[l] == 'local_tm':
816 if upper_time_limit:
817
818 A.append(zero_array * 0.0)
819 A.append(zero_array * 0.0)
820 A[j][i] = 1.0
821 A[j+1][i] = -1.0
822 b.append(0.0 / scaling_matrix[i, i])
823 b.append(-200.0 * 1e-9 / scaling_matrix[i, i])
824 j = j + 2
825 else:
826
827 A.append(zero_array * 0.0)
828 A[j][i] = 1.0
829 b.append(0.0 / scaling_matrix[i, i])
830 j = j + 1
831
832
833 elif match('s2', spin.params[l]):
834
835 A.append(zero_array * 0.0)
836 A.append(zero_array * 0.0)
837 A[j][i] = 1.0
838 A[j+1][i] = -1.0
839 b.append(0.0 / scaling_matrix[i, i])
840 b.append(-1.0 / scaling_matrix[i, i])
841 j = j + 2
842
843
844 if spin.params[l] == 's2':
845 for m in range(len(spin.params)):
846 if spin.params[m] == 's2f' or spin.params[m] == 's2s':
847 A.append(zero_array * 0.0)
848 A[j][i] = -1.0
849 A[j][old_i+m] = 1.0
850 b.append(0.0)
851 j = j + 1
852
853
854 elif match('t[efs]', spin.params[l]):
855
856 A.append(zero_array * 0.0)
857 A[j][i] = 1.0
858 b.append(0.0 / scaling_matrix[i, i])
859 j = j + 1
860
861
862 if spin.params[l] == 'ts':
863 for m in range(len(spin.params)):
864 if spin.params[m] == 'tf':
865 A.append(zero_array * 0.0)
866 A[j][i] = 1.0
867 A[j][old_i+m] = -1.0
868 b.append(0.0)
869 j = j + 1
870
871
872 if upper_time_limit:
873 if not spin.params[l] == 'tf':
874 if model_type == 'mf':
875 A.append(zero_array * 0.0)
876 A[j][i] = -1.0
877 b.append(-2.0 * cdp.diff_tensor.tm / scaling_matrix[i, i])
878 else:
879 A.append(zero_array * 0.0)
880 A[j][0] = 2.0
881 A[j][i] = -1.0
882 b.append(0.0)
883
884 j = j + 1
885
886
887 elif spin.params[l] == 'rex':
888 A.append(zero_array * 0.0)
889 A[j][i] = 1.0
890 b.append(0.0 / scaling_matrix[i, i])
891 j = j + 1
892
893
894 elif spin.params[l] == 'r':
895
896 A.append(zero_array * 0.0)
897 A.append(zero_array * 0.0)
898 A[j][i] = 1.0
899 A[j+1][i] = -1.0
900 b.append(0.9e-10 / scaling_matrix[i, i])
901 b.append(-2e-10 / scaling_matrix[i, i])
902 j = j + 2
903
904
905 elif spin.params[l] == 'csa':
906
907 A.append(zero_array * 0.0)
908 A.append(zero_array * 0.0)
909 A[j][i] = 1.0
910 A[j+1][i] = -1.0
911 b.append(-300e-6 / scaling_matrix[i, i])
912 b.append(0.0 / scaling_matrix[i, i])
913 j = j + 2
914
915
916 i = i + 1
917
918
919 A = array(A, int8)
920 b = array(b, float64)
921
922 return A, b
923
924
926 """Return the units for the Rex parameter.
927
928 @return: The field strength dependent Rex units.
929 @rtype: str
930 """
931
932
933 if not hasattr(cdp, 'frq_labels') or len(cdp.frq_labels) == 0:
934 return ''
935
936
937 return cdp.frq_labels[0] + ' MHz'
938