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