1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 import sys
24
25 import help
26
27
30
31 self.__relax_help__ = \
32 """Class for manipulating results."""
33
34
35 self.__relax_help__ = self.__relax_help__ + "\n" + help.relax_class_help
36
37
38 self.__relax__ = relax
39
40
41 - def display(self, run=None, format='columnar'):
42 """Function for displaying the results of the run.
43
44 Keyword Arguments
45 ~~~~~~~~~~~~~~~~~
46
47 run: The name of the run.
48
49 format: The format of the output.
50 """
51
52
53 if self.__relax__.interpreter.intro:
54 text = sys.ps3 + "results.display("
55 text = text + "run=" + `run`
56 text = text + ", format=" + `format` + ")"
57 print text
58
59
60 if type(run) != str:
61 raise RelaxStrError, ('run', run)
62
63
64 self.__relax__.generic.results.display(run=run)
65
66
67 - def read(self, run=None, file='results', dir='run', format='columnar'):
68 """Function for reading results from a file.
69
70 Keyword Arguments
71 ~~~~~~~~~~~~~~~~~
72
73 run: The name of the run.
74
75 file: The name of the file to read results from.
76
77 dir: The directory where the file is located.
78
79
80 Description
81 ~~~~~~~~~~~
82
83 If no directory name is given, the results file will be searched for in a directory named
84 after the run name. To search for the results file in the current working directory, set
85 dir to None.
86
87 This function is able to handle uncompressed, bzip2 compressed files, or gzip compressed
88 files automatically. The full file name including extension can be supplied, however, if
89 the file cannot be found, this function will search for the file name with '.bz2' appended
90 followed by the file name with '.gz' appended.
91 """
92
93
94 if self.__relax__.interpreter.intro:
95 text = sys.ps3 + "results.read("
96 text = text + "run=" + `run`
97 text = text + ", file=" + `file`
98 if dir == 'run':
99 text = text + ", dir=" + `run`
100 else:
101 text = text + ", dir=" + `dir`
102 text = text + ", format=" + `format` + ")"
103 print text
104
105
106 if type(run) != str:
107 raise RelaxStrError, ('run', run)
108
109
110 if type(file) != str:
111 raise RelaxStrError, ('file name', file)
112
113
114 if dir != None and type(dir) != str:
115 raise RelaxNoneStrError, ('directory name', dir)
116
117
118 if type(format) != str:
119 raise RelaxStrError, ('format', format)
120
121
122 self.__relax__.generic.results.read(run=run, file=file, directory=dir, format=format)
123
124
125 - def write(self, run=None, file='results', dir='run', force=0, format='columnar', compress_type=1):
126 """Function for writing results of the run to a file.
127
128 Keyword Arguments
129 ~~~~~~~~~~~~~~~~~
130
131 run: The name of the run.
132
133 file: The name of the file to output results to. The default is 'results'.
134
135 dir: The directory name.
136
137 force: A flag which, if set to 1, will cause the results file to be overwritten.
138
139 format: The format of the output.
140
141 compress_type: The type of compression to use when creating the file.
142
143
144 Description
145 ~~~~~~~~~~~
146
147 If no directory name is given, the results file will be placed in a directory named after
148 the run name. To place the results file in the current working directory, set dir to None.
149
150 The default behaviour of this function is to compress the file using bzip2 compression. If
151 the extension '.bz2' is not included in the file name, it will be added. The compression
152 can, however, be changed to either no compression or gzip compression. This is controlled
153 by the compress_type argument which can be set to:
154 0 - No compression (no file extension).
155 1 - bzip2 compression ('.bz2' file extension).
156 2 - gzip compression ('.gz' file extension).
157 The complementary read function will automatically handle the compressed files.
158 """
159
160
161 if self.__relax__.interpreter.intro:
162 text = sys.ps3 + "results.write("
163 text = text + "run=" + `run`
164 text = text + ", file=" + `file`
165 if dir == 'run':
166 text = text + ", dir=" + `run`
167 else:
168 text = text + ", dir=" + `dir`
169 text = text + ", force=" + `force`
170 text = text + ", format=" + `format`
171 text = text + ", compress_type=" + `compress_type` + ")"
172 print text
173
174
175 if type(run) != str:
176 raise RelaxStrError, ('run', run)
177
178
179 if type(file) != str:
180 raise RelaxStrError, ('file name', file)
181
182
183 if dir != None and type(dir) != str:
184 raise RelaxNoneStrError, ('directory name', dir)
185
186
187 if type(force) != int or (force != 0 and force != 1):
188 raise RelaxBinError, ('force flag', force)
189
190
191 if type(format) != str:
192 raise RelaxStrError, ('format', format)
193
194
195 if type(compress_type) != int:
196 raise RelaxIntError, ('compression type', compress_type)
197
198
199 self.__relax__.generic.results.write(run=run, file=file, directory=dir, force=force, format=format, compress_type=compress_type)
200