1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 """Module for checks for the frame order analysis."""
24
25
26 from lib.checks import Check
27 from lib.errors import RelaxError
28 from pipe_control.pipes import cdp_name, get_pipe
29
30
31 -def check_domain_func(domain=None):
32 """Check if the domain has been defined.
33
34 @keyword domain: The domain to check for. If None, then the check will be for any domain being defined.
35 @type domain: None or str
36 @return: The initialised RelaxError object if the domain is not defined, or nothing.
37 @rtype: None or RelaxError instance
38 """
39
40
41 if not hasattr(cdp, 'domain'):
42 return RelaxError("No domains have been defined. Please use the domain user function.")
43 if domain != None and domain not in cdp.domain:
44 return RelaxError("The domain '%s' has not been defined. Please use the domain user function." % domain)
45
46
47 check_domain = Check(check_domain_func)
48
49
51 """Check if the frame order model has been set up.
52
53 @keyword pipe_name: The data pipe to check for, if not the current pipe.
54 @type pipe_name: None or str
55 @return: The initialised RelaxError object if the model is not set up, or nothing.
56 @rtype: None or RelaxError instance
57 """
58
59
60 if pipe_name == None:
61 pipe_name = cdp_name()
62
63
64 dp = get_pipe(pipe_name)
65
66
67 if not hasattr(dp, 'model'):
68 return RelaxError("The frame order model has not been set up, please use the frame_order.select_model user function.")
69
70
71 check_model = Check(check_model_func)
72
73
75 """Check if the frame order parameters exist.
76
77 @return: The initialised RelaxError object if the model parameters have not been setup, or nothing.
78 @rtype: None or RelaxError instance
79 """
80
81
82 if not hasattr(cdp, 'params'):
83 return RelaxError("The frame order model has not been set up, no parameters have been defined.")
84
85
86 else:
87
88 missing = []
89 for param in cdp.params:
90
91 if not hasattr(cdp, param):
92 missing.append(param)
93
94
95 else:
96 obj = getattr(cdp, param)
97 if obj == None:
98 missing.append(param)
99
100
101 if len(missing):
102 return RelaxError("The frame order parameters %s have not been set up." % missing)
103
104
105 check_parameters = Check(check_parameters_func)
106
107
109 """Check that the pivot point has been set.
110
111 @keyword pipe_name: The data pipe to check the pivot for. This defaults to the current data pipe if not set.
112 @type pipe_name: str
113 @return: The initialised RelaxError object if the pivot point has not been set, or nothing.
114 @rtype: None or RelaxError instance
115 """
116
117
118 if pipe_name == None:
119 pipe_name = cdp_name()
120
121
122 dp = get_pipe(pipe_name)
123
124
125 if not hasattr(dp, 'pivot_x'):
126 return RelaxError("The pivot point has not been set, please use the frame_order.pivot user function to define the point.")
127
128
129 check_pivot = Check(check_pivot_func)
130