1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 """Module containing the functions which interface relax with OpenDX."""
25
26
27
28 from os import system
29 import string
30
31
32 import isosurface_3D
33 from relax_errors import RelaxError
34 from relax_io import test_binary
35
36
37 -def map(params=None, map_type='Iso3D', spin_id=None, inc=20, lower=None, upper=None, axis_incs=10, file_prefix="map", dir="dx", point=None, point_file="point", remap=None):
38 """Map the space corresponding to the spin identifier and create the OpenDX files.
39
40 @keyword params:
41 @type params:
42 @keyword map_type: The type of map to create. The available options are:
43 - 'Iso3D', a 3D isosurface visualisation of the space.
44 @type map_type: str
45 @keyword spin_id: The spin identification string.
46 @type spin_id: str
47 @keyword inc: The resolution of the plot. This is the number of increments per
48 dimension.
49 @type inc: int
50 @keyword lower: The lower bounds of the space to map. If supplied, this should be a
51 list of floats, its length equal to the number of parameters in the
52 model.
53 @type lower: None or list of float
54 @keyword upper: The upper bounds of the space to map. If supplied, this should be a
55 list of floats, its length equal to the number of parameters in the
56 model.
57 @type upper: None or list of float
58 @keyword axis_incs: The number of tick marks to display in the OpenDX plot in each
59 dimension.
60 @type axis_incs: int
61 @keyword file_prefix: The file prefix for all the created files.
62 @type file_prefix: str
63 @keyword dir: The directory to place the files into.
64 @type dir: str or None
65 @keyword point: If supplied, a red sphere will be placed at these coordinates.
66 @type point: None or list of float
67 @keyword point_file: The file prefix for the point output files.
68 @type point_file: str or None
69 @keyword remap: A function which is used to remap the space. The function should accept
70 the parameter array (list of float) and return an array of equal length
71 (again list of float).
72 @type remap: None or func
73 """
74
75
76 if inc <= 1:
77 raise RelaxError("The increment value needs to be greater than 1.")
78 if axis_incs <= 1:
79 raise RelaxError("The axis increment value needs to be greater than 1.")
80
81
82 if string.lower(map_type) == "iso3d":
83 if len(params) != 3:
84 raise RelaxError("The 3D isosurface map requires a 3 parameter model.")
85
86
87 isosurface_3D.Iso3D(params, spin_id, inc, lower, upper, axis_incs, file_prefix, dir, point, point_file, remap)
88 else:
89 raise RelaxError("The map type '" + map_type + "' is not supported.")
90
91
92 -def run(file_prefix="map", dir="dx", dx_exe="dx", vp_exec=True):
93 """Execute OpenDX.
94
95 @keyword file_prefix: The file prefix for all the created files.
96 @type file_prefix: str
97 @keyword dir: The directory to place the files into.
98 @type dir: str or None
99 @keyword dx_exe: The path to the OpenDX executable file. This can be changed if the
100 binary 'dx' is not located in the system path.
101 @type dx_exe: str
102 @keyword vp_exec: If True, then the OpenDX visual program will be launched.
103 @type vp_exec: bool
104 """
105
106
107 dir_text = ""
108 if dir != None:
109 dir_text = " -directory " + dir
110
111
112 execute_text = ""
113 if vp_exec:
114 execute_text = " -execute"
115
116
117 test_binary(dx_exe)
118
119
120 system(dx_exe + dir_text + " -program " + file_prefix + ".net" + execute_text + " &")
121