1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 """The results user function definitions."""
24
25
26 import dep_check
27 if dep_check.wx_module:
28 from wx import FD_OPEN, FD_SAVE
29 else:
30 FD_OPEN = -1
31 FD_SAVE = -1
32
33
34 from pipe_control import results
35 from user_functions.data import Uf_info; uf_info = Uf_info()
36 from user_functions.objects import Desc_container
37
38
39
40 uf_class = uf_info.add_class('results')
41 uf_class.title = "Class for manipulating results."
42 uf_class.menu_text = "&results"
43 uf_class.gui_icon = "relax.relax"
44
45
46
47 uf = uf_info.add_uf('results.display')
48 uf.title = "Display the results."
49 uf.title_short = "Results display."
50 uf.display = True
51
52 uf.desc.append(Desc_container())
53 uf.desc[-1].add_paragraph("This will print to screen (STDOUT) the results contained within the current data pipe.")
54 uf.backend = results.display
55 uf.menu_text = "&display"
56 uf.gui_icon = "oxygen.actions.document-preview"
57 uf.wizard_size = (600, 300)
58 uf.wizard_apply_button = False
59
60
61
62 uf = uf_info.add_uf('results.read')
63 uf.title = "Read the contents of a relax results file into the relax data store."
64 uf.title_short = "Results reading."
65 uf.add_keyarg(
66 name = "file",
67 default = "results",
68 py_type = "str",
69 arg_type = "file sel",
70 desc_short = "file name",
71 desc = "The name of the file to read results from.",
72 wiz_filesel_wildcard = "relax results files (*.bz2)|*.bz2|relax results files (*.gz)|*.gz|relax results files (*.*)|*.*",
73 wiz_filesel_style = FD_OPEN,
74 wiz_filesel_preview = False
75 )
76 uf.add_keyarg(
77 name = "dir",
78 py_type = "str",
79 arg_type = "dir",
80 desc_short = "directory name",
81 desc = "The directory where the file is located.",
82 can_be_none = True
83 )
84
85 uf.desc.append(Desc_container())
86 uf.desc[-1].add_paragraph("This is able to handle uncompressed, bzip2 compressed files, or gzip compressed files automatically. The full file name including extension can be supplied, however, if the file cannot be found the file with '.bz2' appended followed by the file name with '.gz' appended will be searched for.")
87 uf.backend = results.read
88 uf.menu_text = "&read"
89 uf.gui_icon = "oxygen.actions.document-open"
90 uf.wizard_size = (700, 500)
91 uf.wizard_apply_button = False
92
93
94
95 uf = uf_info.add_uf('results.write')
96 uf.title = "Write the results to a file."
97 uf.title_short = "Results writing."
98 uf.add_keyarg(
99 name = "file",
100 default = "results",
101 py_type = "str_or_inst",
102 arg_type = "file sel",
103 desc_short = "file name",
104 desc = "The name of the file to output results to. The default is 'results'. Optionally this can be a file object, or any object with a write() method.",
105 wiz_filesel_wildcard = "relax results files (*.bz2)|*.bz2|relax results files (*.gz)|*.gz|relax results files (*.*)|*.*",
106 wiz_filesel_style = FD_SAVE
107 )
108 uf.add_keyarg(
109 name = "dir",
110 default = "pipe_name",
111 py_type = "str",
112 arg_type = "dir",
113 desc_short = "directory name",
114 desc = "The directory name.",
115 can_be_none = True
116 )
117 uf.add_keyarg(
118 name = "compress_type",
119 default = 1,
120 py_type = "int",
121 desc_short = "compression type",
122 desc = "The type of compression to use when creating the file.",
123 wiz_element_type = "combo",
124 wiz_combo_choices = [
125 "No compression",
126 "bzip2 compression",
127 "gzip compression"
128 ],
129 wiz_combo_data = [
130 0,
131 1,
132 2
133 ],
134 wiz_read_only = True,
135 )
136 uf.add_keyarg(
137 name = "force",
138 default = False,
139 py_type = "bool",
140 desc_short = "force flag",
141 desc = "A flag which if True will cause the results file to be overwritten."
142 )
143
144 uf.desc.append(Desc_container())
145 uf.desc[-1].add_paragraph("This will write the entire contents of the current data pipe into an XML formatted file. This results file can then be read back into relax at a later point in time, or transfered to another machine. This is in contrast to the state.save user function whereby the entire data store, including all data pipes, are saved into a similarly XML formatted file.")
146 uf.desc[-1].add_paragraph("To place the results file in the current working directory in the prompt and scripting modes, leave the directory unset. If the directory is set to the special name 'pipe_name', then the results file will be placed into a directory with the same name as the current data pipe.")
147 uf.desc[-1].add_paragraph("The default behaviour of this function is to compress the file using bzip2 compression. If the extension '.bz2' is not included in the file name, it will be added. The compression can, however, be changed to either no compression or gzip compression. This is controlled by the compression type which can be set to")
148 uf.desc[-1].add_item_list_element("0", "No compression (no file extension),")
149 uf.desc[-1].add_item_list_element("1", "bzip2 compression ('.bz2' file extension),")
150 uf.desc[-1].add_item_list_element("2", "gzip compression ('.gz' file extension).")
151 uf.desc[-1].add_paragraph("The complementary read function will automatically handle the compressed files.")
152 uf.backend = results.write
153 uf.menu_text = "&write"
154 uf.gui_icon = "oxygen.actions.document-save"
155 uf.wizard_height_desc = 450
156 uf.wizard_size = (1000, 750)
157 uf.wizard_apply_button = False
158