Author: bugman Date: Thu Dec 18 12:23:42 2014 New Revision: 27130 URL: http://svn.gna.org/viewcvs/relax?rev=27130&view=rev Log: Shifted the matrix output of the structure.atomic_fluctuations user function into lib.plotting.text. The new lib.plotting.text module will be used by the relax library plotting API to output data into plain text format. The current correlation_matrix() function, which has been added to the API correlation_matrix() function dictionary, simply has the file writing code of the structure.atomic_fluctuations user function. This significantly simplifies the user function. Added: trunk/lib/plotting/text.py - copied, changed from r27128, trunk/lib/plotting/gnuplot.py Modified: trunk/lib/plotting/__init__.py trunk/lib/plotting/api.py trunk/pipe_control/structure/main.py Modified: trunk/lib/plotting/__init__.py URL: http://svn.gna.org/viewcvs/relax/trunk/lib/plotting/__init__.py?rev=27130&r1=27129&r2=27130&view=diff ============================================================================== --- trunk/lib/plotting/__init__.py (original) +++ trunk/lib/plotting/__init__.py Thu Dec 18 12:23:42 2014 @@ -25,5 +25,6 @@ # The package content list. __all__ = [ 'api', - 'gnuplot' + 'gnuplot', + 'text' ] Modified: trunk/lib/plotting/api.py URL: http://svn.gna.org/viewcvs/relax/trunk/lib/plotting/api.py?rev=27130&r1=27129&r2=27130&view=diff ============================================================================== --- trunk/lib/plotting/api.py (original) +++ trunk/lib/plotting/api.py Thu Dec 18 12:23:42 2014 @@ -25,6 +25,7 @@ # relax module imports. from lib.errors import RelaxError from lib.plotting import gnuplot +from lib.plotting import text def correlation_matrix(format=None, matrix=None, labels=None, file=None, dir=None, force=False): @@ -44,7 +45,8 @@ # The supported formats. function = { - 'gnuplot': gnuplot.correlation_matrix + 'gnuplot': gnuplot.correlation_matrix, + 'text': text.correlation_matrix } # Unsupported format. Copied: trunk/lib/plotting/text.py (from r27128, trunk/lib/plotting/gnuplot.py) URL: http://svn.gna.org/viewcvs/relax/trunk/lib/plotting/text.py?p2=trunk/lib/plotting/text.py&p1=trunk/lib/plotting/gnuplot.py&r1=27128&r2=27130&rev=27130&view=diff ============================================================================== --- trunk/lib/plotting/gnuplot.py (original) +++ trunk/lib/plotting/text.py Thu Dec 18 12:23:42 2014 @@ -20,10 +20,10 @@ ############################################################################### # Module docstring. -"""Module for data plotting using gnuplot.""" +"""Module for data plotting in plain text format.""" # relax module imports. -from lib.io import open_write_file, swap_extension +from lib.io import open_write_file def correlation_matrix(matrix=None, labels=None, file=None, dir=None, force=False): @@ -39,17 +39,32 @@ @type dir: str or None """ - # The script file name. - file_name = swap_extension(file=file, ext='gnu') + # Open the text file for writing. + output = open_write_file(file, dir=dir, force=force) - # Open the script file for writing. - output = open_write_file(file_name, dir=dir, force=force) + # The dimensions. + n = len(matrix) - # Set the plot type. - output.write("set pm3d map\n") + # The header line. + output.write('#') + for i in range(n): + if i == 0: + output.write(" %18s" % labels[i]) + else: + output.write(" %20s" % labels[i]) + output.write('\n') - # Load and show the text data. - output.write("splot \"%s\" matrix\n" % file) + # Output the matrix. + for i in range(n): + for j in range(n): + # Output the matrix. + if j == 0: + output.write("%20.15f" % matrix[i, j]) + else: + output.write(" %20.15f" % matrix[i, j]) + + # End of the current line. + output.write('\n') # Close the file. output.close() Modified: trunk/pipe_control/structure/main.py URL: http://svn.gna.org/viewcvs/relax/trunk/pipe_control/structure/main.py?rev=27130&r1=27129&r2=27130&view=diff ============================================================================== --- trunk/pipe_control/structure/main.py (original) +++ trunk/pipe_control/structure/main.py Thu Dec 18 12:23:42 2014 @@ -251,9 +251,6 @@ # Checks. check_pipe() check_structure() - format_list = ['text', 'gnuplot'] - if format not in format_list: - raise RelaxError("The format '%s' must be one of %s." % (format, format_list)) # Assemble the atomic coordinates. coord, ids, mol_names, res_names, res_nums, atom_names, elements = assemble_coordinates(pipes=pipes, molecules=molecules, models=models, atom_id=atom_id, seq_info_flag=True) @@ -266,18 +263,10 @@ output = open_write_file(file, dir=dir, force=force) # The header line. - output.write('#') labels = [] for i in range(len(atom_names)): # The spin identification string. labels.append(generate_spin_id_unique(mol_name=mol_names[i], res_num=res_nums[i], res_name=res_names[i], spin_name=atom_names[i])) - - # Output the spin ID. - if i == 0: - output.write(" %18s" % labels[i]) - else: - output.write(" %20s" % labels[i]) - output.write('\n') # Generate the pairwise matrix. n = len(atom_names) @@ -292,22 +281,8 @@ # Calculate and store the corrected sample standard deviation. matrix[i, j] = std(array(dist, float64), ddof=1) - # Output the matrix. - if j == 0: - output.write("%20.15f" % matrix[i, j]) - else: - output.write(" %20.15f" % matrix[i, j]) - - # End of the current line. - output.write('\n') - - # Close the file. - output.close() - - # The gnuplot script. - if format == 'gnuplot': - # Call the plotting API. - correlation_matrix(format=format, matrix=matrix, labels=labels, file=file, dir=dir, force=force) + # Call the plotting API. + correlation_matrix(format=format, matrix=matrix, labels=labels, file=file, dir=dir, force=force) def connect_atom(index1=None, index2=None):