Package opendx :: Module main
[hide private]
[frames] | no frames]

Source Code for Module opendx.main

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2003-2005, 2007-2008 Edward d'Auvergne                        # 
  4  #                                                                             # 
  5  # This file is part of the program relax.                                     # 
  6  #                                                                             # 
  7  # relax is free software; you can redistribute it and/or modify               # 
  8  # it under the terms of the GNU General Public License as published by        # 
  9  # the Free Software Foundation; either version 2 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # relax is distributed in the hope that it will be useful,                    # 
 13  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 15  # GNU General Public License for more details.                                # 
 16  #                                                                             # 
 17  # You should have received a copy of the GNU General Public License           # 
 18  # along with relax; if not, write to the Free Software                        # 
 19  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   # 
 20  #                                                                             # 
 21  ############################################################################### 
 22   
 23  # Module docsting. 
 24  """Module containing the functions which interface relax with OpenDX.""" 
 25   
 26   
 27  # Python module imports. 
 28  from os import system 
 29  import string 
 30   
 31  # relax module imports. 
 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 # Check the args. 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 # Space type. 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 # Create the map. 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 # Text for changing to the directory dir. 107 dir_text = "" 108 if dir != None: 109 dir_text = " -directory " + dir 110 111 # Text for executing OpenDX. 112 execute_text = "" 113 if vp_exec: 114 execute_text = " -execute" 115 116 # Test the binary file string corresponds to a valid executable. 117 test_binary(dx_exe) 118 119 # Run OpenDX. 120 system(dx_exe + dir_text + " -program " + file_prefix + ".net" + execute_text + " &")
121