Author: bugman Date: Mon Jul 25 14:33:28 2011 New Revision: 13856 URL: http://svn.gna.org/viewcvs/relax?rev=13856&view=rev Log: The 'bc' arg is now part of the value.write() user function, and all of the return_value functions. The arg is also propagated to the back-end of the relax_data.write() user function. Modified: 1.3/generic_fns/relax_data.py 1.3/generic_fns/value.py 1.3/prompt/relax_data.py 1.3/prompt/value.py 1.3/specific_fns/api_base.py 1.3/specific_fns/api_common.py Modified: 1.3/generic_fns/relax_data.py URL: http://svn.gna.org/viewcvs/relax/1.3/generic_fns/relax_data.py?rev=13856&r1=13855&r2=13856&view=diff ============================================================================== --- 1.3/generic_fns/relax_data.py (original) +++ 1.3/generic_fns/relax_data.py Mon Jul 25 14:33:28 2011 @@ -92,7 +92,7 @@ cdp.ri_type[ri_id] = ri_type cdp.frq[ri_id] = frq - # Specific Ri back-calculate function setup. + # Specific Ri back calculate function setup. back_calculate = specific_fns.setup.get_specific_fn('back_calc_ri', pipes.get_type()) # The IDs to loop over. @@ -832,19 +832,25 @@ return 'The relaxation data errors' -def return_value(spin, data_type): +def return_value(spin, data_type, bc=False): """Return the value and error corresponding to 'data_type'. @param spin: The spin container. @type spin: SpinContainer instance @param data_type: The relaxation data ID string. @type data_type: str + @keyword bc: A flag which if True will cause the back calculated relaxation data to be written. + @type bc: bool """ # Relaxation data. data = None - if hasattr(spin, 'ri_data') and spin.ri_data != None and data_type in spin.ri_data.keys(): + if not bc and hasattr(spin, 'ri_data') and spin.ri_data != None and data_type in spin.ri_data.keys(): data = spin.ri_data[data_type] + + # Back calculated relaxation data + if bc and hasattr(spin, 'ri_data_bc') and spin.ri_data_bc != None and data_type in spin.ri_data_bc.keys(): + data = spin.ri_data_bc[data_type] # Relaxation errors. error = None @@ -930,7 +936,7 @@ @type file: str @keyword dir: The directory to write to. @type dir: str or None - @keyword bc: A flag which if True will cause the back-calculated relaxation data to be written. + @keyword bc: A flag which if True will cause the back calculated relaxation data 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 @@ -952,4 +958,4 @@ file = ri_id + ".out" # Write the data. - value.write(param=ri_id, file=file, dir=dir, force=force, return_value=return_value) + value.write(param=ri_id, file=file, dir=dir, bc=bc, force=force, return_value=return_value) Modified: 1.3/generic_fns/value.py URL: http://svn.gna.org/viewcvs/relax/1.3/generic_fns/value.py?rev=13856&r1=13855&r2=13856&view=diff ============================================================================== --- 1.3/generic_fns/value.py (original) +++ 1.3/generic_fns/value.py Mon Jul 25 14:33:28 2011 @@ -373,7 +373,7 @@ pipes.switch(orig_pipe) -def write(param=None, file=None, dir=None, force=False, return_value=None): +def write(param=None, file=None, dir=None, bc=False, force=False, return_value=None): """Write data to a file. @keyword param: The name of the parameter to write to file. @@ -383,6 +383,8 @@ @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 @@ -401,24 +403,22 @@ file = open_write_file(file, dir, force) # Write the data. - write_data(param, file, return_value) + write_data(param, file, bc, return_value) # Close the file. file.close() -def write_data(param=None, file=None, return_value=None): +def write_data(param=None, file=None, bc=False, return_value=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 dir: The name of the directory to place the file into (defaults to the - current directory). - @type dir: str - @keyword return_value: An optional function which if supplied will override the default value - returning function. + @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 """ @@ -441,7 +441,7 @@ # Loop over the sequence. for spin, mol_name, res_num, res_name in spin_loop(full_info=True): # Get the value and error. - value, error = return_value(spin, param) + value, error = return_value(spin, param, bc=bc) # Append the data. mol_names.append(mol_name) Modified: 1.3/prompt/relax_data.py URL: http://svn.gna.org/viewcvs/relax/1.3/prompt/relax_data.py?rev=13856&r1=13855&r2=13856&view=diff ============================================================================== --- 1.3/prompt/relax_data.py (original) +++ 1.3/prompt/relax_data.py Mon Jul 25 14:33:28 2011 @@ -432,7 +432,7 @@ dir: The directory name. - bc: A flag which if True will cause the back-calculated relaxation data to be written to + bc: A flag which if True will cause the back calculated relaxation data to be written to file rather than the actual data. force: A flag which if True will cause the file to be overwritten. @@ -459,7 +459,7 @@ arg_check.is_str(ri_id, 'relaxation label') arg_check.is_str(file, 'file name') arg_check.is_str(dir, 'directory name', can_be_none=True) - arg_check.is_bool(bc, 'back-calculated data flag') + arg_check.is_bool(bc, 'back calculated data flag') arg_check.is_bool(force, 'force flag') # Execute the functional code. Modified: 1.3/prompt/value.py URL: http://svn.gna.org/viewcvs/relax/1.3/prompt/value.py?rev=13856&r1=13855&r2=13856&view=diff ============================================================================== --- 1.3/prompt/value.py (original) +++ 1.3/prompt/value.py Mon Jul 25 14:33:28 2011 @@ -1,6 +1,6 @@ ############################################################################### # # -# Copyright (C) 2003-2010 Edward d'Auvergne # +# Copyright (C) 2003-2011 Edward d'Auvergne # # # # This file is part of the program relax. # # # @@ -378,7 +378,7 @@ value.set(val=val, param=param, spin_id=spin_id) - def write(self, param=None, file=None, dir=None, force=False): + def write(self, param=None, file=None, dir=None, bc=False, force=False): """Write spin specific data values to a file. Keyword Arguments @@ -389,6 +389,9 @@ file: The name of the file. dir: The directory name. + + bc: A flag which if True will cause the back calculated values to be written to file + rather than the actual data. force: A flag which, if set to True, will cause the file to be overwritten. @@ -424,6 +427,7 @@ text = text + "param=" + repr(param) text = text + ", file=" + repr(file) text = text + ", dir=" + repr(dir) + text = text + ", bc=" + repr(bc) text = text + ", force=" + repr(force) + ")" print(text) @@ -431,10 +435,11 @@ arg_check.is_str(param, 'parameter') arg_check.is_str(file, 'file name') arg_check.is_str(dir, 'directory name', can_be_none=True) + arg_check.is_bool(bc, 'back calculated value flag') arg_check.is_bool(force, 'force flag') # Execute the functional code. - value.write(param=param, file=file, dir=dir, force=force) + value.write(param=param, file=file, dir=dir, bc=bc, force=force) # Docstring modification. Modified: 1.3/specific_fns/api_base.py URL: http://svn.gna.org/viewcvs/relax/1.3/specific_fns/api_base.py?rev=13856&r1=13855&r2=13856&view=diff ============================================================================== --- 1.3/specific_fns/api_base.py (original) +++ 1.3/specific_fns/api_base.py Mon Jul 25 14:33:28 2011 @@ -553,7 +553,7 @@ raise RelaxImplementError - def return_value(self, spin, param, sim=None): + def return_value(self, spin, param, sim=None, bc=False): """Return the value and error corresponding to the parameter. If sim is set to an integer, return the value of the simulation and None. @@ -563,8 +563,10 @@ @type spin: SpinContainer @param param: The name of the parameter to return values for. @type param: str - @param sim: The Monte Carlo simulation index. + @keyword sim: The Monte Carlo simulation index. @type sim: None or int + @keyword bc: The back-calculated data flag. If True, then the back-calculated data will be returned rather than the actual data. + @type bc: bool @return: The value and error corresponding to @rtype: tuple of length 2 of floats or None """ Modified: 1.3/specific_fns/api_common.py URL: http://svn.gna.org/viewcvs/relax/1.3/specific_fns/api_common.py?rev=13856&r1=13855&r2=13856&view=diff ============================================================================== --- 1.3/specific_fns/api_common.py (original) +++ 1.3/specific_fns/api_common.py Mon Jul 25 14:33:28 2011 @@ -281,7 +281,7 @@ return error - def _return_value_general(self, spin, param, sim=None): + def _return_value_general(self, spin, param, sim=None, bc=False): """Return the value and error corresponding to the parameter 'param'. If sim is set to an integer, return the value of the simulation and None. The values are taken from the given SpinContainer object. @@ -293,6 +293,8 @@ @type param: str @param sim: The Monte Carlo simulation index. @type sim: None or int + @keyword bc: The back-calculated data flag. If True, then the back-calculated data will be returned rather than the actual data. + @type bc: bool @return: The value and error corresponding to @rtype: tuple of length 2 of floats or None """ @@ -303,10 +305,11 @@ # Get the object name. object_name = self.return_data_name(param) - # The error and simulation names. + # The error, simulation and back calculated names. if object_name: object_error = object_name + '_err' object_sim = object_name + '_sim' + object_bc = object_name + '_bc' key = None # The data type does not exist. @@ -316,6 +319,7 @@ object_name = 'intensities' object_error = 'intensity_err' object_sim = 'intensity_sim' + object_bc = 'intensity_bc' key = param # Unknown data type. @@ -325,6 +329,10 @@ # Initial values. value = None error = None + + # Switch to back calculated data. + if bc: + object_name = object_bc # Value or sim value? if sim != None: