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
155 0: No compression (no file extension),
156 1: bzip2 compression ('.bz2' file extension),
157 2: gzip compression ('.gz' file extension).
158
159 The complementary read function will automatically handle the compressed files.
160 """
161
162
163 if self.__relax__.interpreter.intro:
164 text = sys.ps3 + "results.write("
165 text = text + "run=" + `run`
166 text = text + ", file=" + `file`
167 if dir == 'run':
168 text = text + ", dir=" + `run`
169 else:
170 text = text + ", dir=" + `dir`
171 text = text + ", force=" + `force`
172 text = text + ", format=" + `format`
173 text = text + ", compress_type=" + `compress_type` + ")"
174 print text
175
176
177 if type(run) != str:
178 raise RelaxStrError, ('run', run)
179
180
181 if type(file) != str:
182 raise RelaxStrError, ('file name', file)
183
184
185 if dir != None and type(dir) != str:
186 raise RelaxNoneStrError, ('directory name', dir)
187
188
189 if type(force) != int or (force != 0 and force != 1):
190 raise RelaxBinError, ('force flag', force)
191
192
193 if type(format) != str:
194 raise RelaxStrError, ('format', format)
195
196
197 if type(compress_type) != int:
198 raise RelaxIntError, ('compression type', compress_type)
199
200
201 self.__relax__.generic.results.write(run=run, file=file, directory=dir, force=force, format=format, compress_type=compress_type)
202