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