Author: bugman Date: Mon Mar 18 13:19:29 2013 New Revision: 18847 URL: http://svn.gna.org/viewcvs/relax?rev=18847&view=rev Log: Added a comment to the output from value.display and value.write to describe the parameter. This idea is discussed at http://thread.gmane.org/gmane.science.nmr.relax.user/1428. The idea is to take the parameter description from the specific analysis API and add it to the top of the file or output. This is to help understand what the Rex value are. For example for the Rex parameter the first line would be: # Parameter description: Chemical exchange relaxation (sigma_ex = Rex / omega**2). Modified: trunk/generic_fns/relax_data.py trunk/generic_fns/value.py Modified: trunk/generic_fns/relax_data.py URL: http://svn.gna.org/viewcvs/relax/trunk/generic_fns/relax_data.py?rev=18847&r1=18846&r2=18847&view=diff ============================================================================== --- trunk/generic_fns/relax_data.py (original) +++ trunk/generic_fns/relax_data.py Mon Mar 18 13:19:29 2013 @@ -591,7 +591,7 @@ raise RelaxNoRiError(ri_id) # Print the data. - value.write_data(param=ri_id, file=sys.stdout, return_value=return_value) + value.write_data(param=ri_id, file=sys.stdout, return_value=return_value, return_data_desc=return_data_desc) def frq(ri_id=None, frq=None): @@ -1204,4 +1204,4 @@ file = ri_id + ".out" # Write the data. - value.write(param=ri_id, file=file, dir=dir, bc=bc, force=force, return_value=return_value) + value.write(param=ri_id, file=file, dir=dir, bc=bc, force=force, return_value=return_value, return_data_desc=return_data_desc) Modified: trunk/generic_fns/value.py URL: http://svn.gna.org/viewcvs/relax/trunk/generic_fns/value.py?rev=18847&r1=18846&r2=18847&view=diff ============================================================================== --- trunk/generic_fns/value.py (original) +++ trunk/generic_fns/value.py Mon Mar 18 13:19:29 2013 @@ -426,23 +426,23 @@ pipes.switch(orig_pipe) -def write(param=None, file=None, dir=None, bc=False, force=False, return_value=None): +def write(param=None, file=None, dir=None, bc=False, force=False, return_value=None, return_data_desc=None): """Write data to a file. - @keyword param: The name of the parameter to write to file. - @type param: str - @keyword file: The file to write the data to. - @type file: str - @keyword dir: The name of the directory to place the file into (defaults to the - current directory). - @type dir: str - @keyword bc: A flag which if True will cause the back calculated values to be written. - @type bc: bool - @keyword force: A flag which if True will cause any pre-existing file to be overwritten. - @type force: bool - @keyword return_value: An optional function which if supplied will override the default value - returning function. - @type return_value: None or func + @keyword param: The name of the parameter to write to file. + @type param: str + @keyword file: The file to write the data to. + @type file: str + @keyword dir: The name of the directory to place the file into (defaults to the current directory). + @type dir: str + @keyword bc: A flag which if True will cause the back calculated values to be written. + @type bc: bool + @keyword force: A flag which if True will cause any pre-existing file to be overwritten. + @type force: bool + @keyword return_value: An optional function which if supplied will override the default value returning function. + @type return_value: None or func + @keyword return_data_desc: An optional function which if supplied will override the default parameter description returning function. + @type return_data_desc: None or func """ # Test if the current pipe exists. @@ -457,7 +457,7 @@ file = open_write_file(file, dir, force) # Write the data. - write_data(param, file, bc, return_value) + write_data(param=param, file=file, bc=bc, return_value=return_value, return_data_desc=return_data_desc) # Close the file. file.close() @@ -466,22 +466,26 @@ add_result_file(type='text', label='Text', file=file_path) -def write_data(param=None, file=None, bc=False, return_value=None): +def write_data(param=None, file=None, bc=False, return_value=None, return_data_desc=None): """The function which actually writes the data. - @keyword param: The parameter to write. - @type param: str - @keyword file: The file to write the data to. - @type file: str - @keyword bc: A flag which if True will cause the back calculated values to be written. - @type bc: bool - @keyword return_value: An optional function which if supplied will override the default value returning function. - @type return_value: None or func - """ - - # Get the value and error returning function if required. + @keyword param: The parameter to write. + @type param: str + @keyword file: The file to write the data to. + @type file: str + @keyword bc: A flag which if True will cause the back calculated values to be written. + @type bc: bool + @keyword return_value: An optional function which if supplied will override the default value returning function. + @type return_value: None or func + @keyword return_data_desc: An optional function which if supplied will override the default parameter description returning function. + @type return_data_desc: None or func + """ + + # Get the value and error returning function parameter description function if required. if not return_value: return_value = specific_fns.setup.get_specific_fn('return_value', pipes.get_type()) + if not return_data_desc: + return_data_desc = specific_fns.setup.get_specific_fn('return_data_desc', pipes.get_type()) # Format string. format = "%-30s%-30s" @@ -495,6 +499,12 @@ values = [] errors = [] + # Get the parameter description and add it to the file. + desc = return_data_desc(param) + if desc: + file.write("# Parameter description: %s.\n" % desc) + file.write("#\n") + # Loop over the sequence. for spin, mol_name, res_num, res_name in spin_loop(full_info=True): # Get the value and error.