Package dx :: Module base_map
[hide private]
[frames] | no frames]

Source Code for Module dx.base_map

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2003, 2004 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   
 24  from Numeric import Float64, array, zeros 
 25   
 26   
27 -class Base_Map:
28 - def __init__(self):
29 """The space mapping base class."""
30 31
32 - def map_space(self, run, index, n, inc, lower, upper, swap, file, dir, point, point_file, remap, labels):
33 """Generic function for mapping a space.""" 34 35 # Function type. 36 function_type = self.relax.data.run_types[self.relax.data.run_names.index(run)] 37 38 # Specific map bounds, map labels, and calculation functions. 39 self.map_bounds = self.relax.specific_setup.setup('map_bounds', function_type) 40 self.map_labels = self.relax.specific_setup.setup('map_labels', function_type, raise_error=0) 41 self.calculate = self.relax.specific_setup.setup('calculate', function_type) 42 43 # Function arguments. 44 self.run = run 45 self.index = index 46 self.n = n 47 self.inc = inc 48 self.swap = swap 49 self.file = file 50 self.dir = dir 51 self.point_file = point_file 52 self.remap = remap 53 self.labels = labels 54 55 # Axis swapping. 56 if self.swap == None: 57 self.swap = range(self.n) 58 59 # Points. 60 if point != None: 61 self.point = array(point, Float64) 62 self.num_points = 1 63 else: 64 self.num_points = 0 65 66 # The OpenDX directory. 67 self.relax.IO.mkdir(self.dir, print_flag=0) 68 69 # Get the map bounds. 70 self.bounds = self.map_bounds(self.run, self.index) 71 if lower != None: 72 self.bounds[:, 0] = array(lower, Float64) 73 if upper != None: 74 self.bounds[:, 1] = array(upper, Float64) 75 76 # Setup the step sizes. 77 self.step_size = zeros(self.n, Float64) 78 for i in xrange(self.n): 79 self.step_size[i] = (self.bounds[i, 1] - self.bounds[i, 0]) / self.inc 80 81 # Create the OpenDX .net program file. 82 print "Creating the OpenDX '.net' program file.\n" 83 self.program() 84 85 # Create the OpenDX .cfg program configuration file. 86 print "Creating the OpenDX '.cfg' program configuration file.\n" 87 self.config() 88 89 # Create the OpenDX .general file. 90 print "Creating the OpenDX '.general' file.\n" 91 self.general() 92 93 # Create the OpenDX .general and data files for the given point. 94 if self.num_points == 1: 95 print "Creating the OpenDX '.general' and data files for the given point.\n" 96 self.create_point() 97 98 # Generate the map. 99 print "Creating the map.\n" 100 self.create_map()
101