1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 from copy import deepcopy
24
25
28 """Class containing the function for creating a run."""
29
30 self.relax = relax
31
32
33 - def create(self, run=None, run_type=None):
34 """Function for creating a run."""
35
36
37 if run in self.relax.data.run_names:
38 raise RelaxRunError, run
39
40
41 valid = ['ct', 'jw', 'mf', 'noe', 'relax_fit', 'srls']
42
43
44 if not run_type in valid:
45 raise RelaxError, "The run type name " + `run_type` + " is invalid and must be one of the strings in the list " + `valid` + "."
46
47
48 if run_type == 'relax_fit' and not C_module_exp_fn:
49 raise RelaxError, "Relaxation curve fitting is not availible. Try compiling the C modules on your platform."
50
51
52 self.relax.data.run_names.append(run)
53 self.relax.data.run_types.append(run_type)
54
55
57 """Function for deleting a run."""
58
59
60 if run != None and not run in self.relax.data.run_names:
61 raise RelaxNoRunError, run
62
63
64 for name in dir(self.relax.data):
65
66 object = getattr(self.relax.data, name)
67
68
69 if not hasattr(object, 'keys'):
70 continue
71
72
73 if object.has_key(run):
74 del(object[run])
75
76
77 self.eliminate_unused_runs()
78
79
81 """Function for eliminating any runs for which there is no data."""
82
83
84 keep_runs = []
85
86
87 for name in dir(self.relax.data):
88
89 object = getattr(self.relax.data, name)
90 if not hasattr(object, 'keys'):
91 continue
92
93
94 for key in object.keys():
95 if not key in keep_runs:
96 keep_runs.append(key)
97
98
99 for run in self.relax.data.run_names:
100 if not run in keep_runs:
101
102 index = self.relax.data.run_names.index(run)
103
104
105 self.relax.data.run_names.remove(run)
106
107
108 temp = self.relax.data.run_types.pop(index)
109
110
112 """Function for creating a list of runs."""
113
114
115 if run == None:
116 runs = deepcopy(self.relax.data.run_names)
117
118
119 elif type(run) == str:
120 runs = [run]
121
122
123 else:
124 runs = run
125
126
127 return runs
128