Author: tlinnet Date: Thu May 8 19:42:03 2014 New Revision: 23097 URL: http://svn.gna.org/viewcvs/relax?rev=23097&view=rev Log: Modified dx.map to accept more than one point. task #7791: (https://gna.org/task/index.php?7791 ) the dx.map should accept a list of list with values for points. Modified: trunk/lib/software/opendx/files.py trunk/pipe_control/opendx.py Modified: trunk/lib/software/opendx/files.py URL: http://svn.gna.org/viewcvs/relax/trunk/lib/software/opendx/files.py?rev=23097&r1=23096&r2=23097&view=diff ============================================================================== --- trunk/lib/software/opendx/files.py (original) +++ trunk/lib/software/opendx/files.py Thu May 8 19:42:03 2014 @@ -107,7 +107,7 @@ file.close() -def write_point(file_prefix=None, dir=None, inc=None, point=None, bounds=None, N=None): +def write_point(file_prefix=None, dir=None, inc=None, point=None, num_points=None, bounds=None, N=None): """Creating a sphere at a given position within the map. The formula used to calculate the coordinate position is:: @@ -133,6 +133,8 @@ @type inc: int @keyword point: The list of coordinates of the point. @type point: numpy rank-1 float array or list of numpy rank-1 float array. + @keyword num_points: The number of points. + @type num_points: int @keyword bounds: The bounds of the map. @type bounds: numpy rank-2 float array @keyword N: The dimension of the map. @@ -147,14 +149,25 @@ point_file_general = open_write_file(file_name=file_prefix+".general", dir=dir, force=True) # Calculate the coordinate values. - coords = inc * (point - bounds[:, 0]) / (bounds[:, 1] - bounds[:, 0]) - for i in range(N): - point_file.write("%-15.5g" % coords[i]) - point_file.write("1\n") + if num_points > 1: + for i in range(num_points): + i_point = point[i] + + coords = inc * (i_point - bounds[:, 0]) / (bounds[:, 1] - bounds[:, 0]) + for i in range(N): + point_file.write("%-15.5g" % coords[i]) + point_file.write("1\n") + else: + i_point = point + + coords = inc * (i_point - bounds[:, 0]) / (bounds[:, 1] - bounds[:, 0]) + for i in range(N): + point_file.write("%-15.5g" % coords[i]) + point_file.write("1\n") # The text of the point .general file. point_file_general.write("file = %s\n" % file_prefix) - point_file_general.write("points = 1\n") + point_file_general.write("points = %s\n" % num_points) point_file_general.write("format = ascii\n") point_file_general.write("interleaving = field\n") point_file_general.write("field = locations, field0\n") @@ -228,7 +241,7 @@ file.write("// MODULE main\n") # Include the sphere. - if num_points == 1: + if num_points > 0: file.write("\n") file.write("// page assignment: Colour Space\torder=3, windowed=0, showing=0\n") file.write("// page assignment: ColourScene\t\torder=5, windowed=0, showing=0\n") @@ -259,7 +272,7 @@ file.write(" // \n") # Include the sphere. - if num_points == 1: + if num_points > 0: file.write("\n") file.write(" // node Import[4]: x = 177, y = 62, inputs = 6, label = %s\n" % point_file) file.write(" // input[1]: defaulting = 0, visible = 1, type = 32, value = \"%s.general\"\n" % point_file) @@ -517,7 +530,7 @@ file.write(" // \n") # Include the sphere. - if num_points == 1: + if num_points > 0: file.write("\n") file.write(" // node Collect[8]: x = 293, y = 431, inputs = 2, label = Collect\n") file.write(" // page group: Grey Space\n") @@ -541,7 +554,7 @@ file.write(" // \n") # Include the sphere. - if num_points == 1: + if num_points > 0: file.write("\n") file.write("GreySpace = main_Collect_8_out_1;\n") @@ -636,7 +649,7 @@ file.write(" // \n") # Include the sphere. - if num_points == 1: + if num_points > 0: file.write("\n") file.write(" // node Color[11]: x = 133, y = 278, inputs = 5, label = Color\n") file.write(" // input[2]: defaulting = 0, visible = 1, type = 8, value = [1 0 0]\n") @@ -773,7 +786,7 @@ file.write(" // \n") # Include the sphere. - if num_points == 1: + if num_points > 0: file.write("\n") file.write(" // node Collect[12]: x = 293, y = 431, inputs = 2, label = Collect\n") file.write(" // page group: Colour Space\n") @@ -797,7 +810,7 @@ file.write(" // \n") # Include the sphere. - if num_points == 1: + if num_points > 0: file.write("\n") file.write("ColourSpace = main_Collect_12_out_1;\n") @@ -1035,7 +1048,7 @@ file.write("}\n") # Include the sphere. - if num_points == 1: + if num_points > 0: file.write("\n") file.write("main_Import_4_in_1 = \"%s.general\";\n" % point_file) file.write("main_Import_4_in_2 = NULL;\n") @@ -1125,7 +1138,7 @@ file.write("main_Collect_7_out_1 = NULL;\n") # Include the sphere. - if num_points == 1: + if num_points > 0: file.write("\n") file.write("main_Collect_8_out_1 = NULL;\n") @@ -1164,7 +1177,7 @@ file.write("main_AutoAxes_2_out_1 = NULL;\n") # Include the sphere. - if num_points == 1: + if num_points > 0: file.write("\n") file.write("main_Color_11_in_2 = [1 0 0];\n") file.write("main_Color_11_in_3 = 1.0;\n") @@ -1205,7 +1218,7 @@ file.write("main_Collect_11_out_1 = NULL;\n") # Include the sphere. - if num_points == 1: + if num_points > 0: file.write("\n") file.write("main_Collect_12_out_1 = NULL;\n") Modified: trunk/pipe_control/opendx.py URL: http://svn.gna.org/viewcvs/relax/trunk/pipe_control/opendx.py?rev=23097&r1=23096&r2=23097&view=diff ============================================================================== --- trunk/pipe_control/opendx.py (original) +++ trunk/pipe_control/opendx.py Thu May 8 19:42:03 2014 @@ -174,14 +174,8 @@ write_general(file_prefix=self.file_prefix, dir=self.dir, inc=self.inc) # Create the OpenDX .general and data files for the given point. - if self.num_points == 1: - write_point(file_prefix=self.point_file, dir=self.dir, inc=self.inc, point=self.point, bounds=self.bounds, N=self.n) - - # Generate the OpenDX .general and data files for each point. - elif self.num_points > 1: - for i in range(self.num_points): - file_prefix = "%s_%i"%(self.point_file, i) - write_point(file_prefix=file_prefix, dir=self.dir, inc=self.inc, point=self.point[i], bounds=self.bounds, N=self.n) + if self.num_points > 1: + write_point(file_prefix=self.point_file, dir=self.dir, inc=self.inc, point=self.point, num_points=self.num_points, bounds=self.bounds, N=self.n) # Generate the map. self.create_map()