Author: bugman Date: Mon Oct 12 16:00:39 2009 New Revision: 9747 URL: http://svn.gna.org/viewcvs/relax?rev=9747&view=rev Log: __linear_ave() is no longer a private function. Modified: 1.3/generic_fns/mol_res_spin.py Modified: 1.3/generic_fns/mol_res_spin.py URL: http://svn.gna.org/viewcvs/relax/1.3/generic_fns/mol_res_spin.py?rev=9747&r1=9746&r2=9747&view=diff ============================================================================== --- 1.3/generic_fns/mol_res_spin.py (original) +++ 1.3/generic_fns/mol_res_spin.py Mon Oct 12 16:00:39 2009 @@ -491,36 +491,6 @@ -def __linear_ave(positions): - """Perform linear averaging of the atomic positions. - - @param positions: The atomic positions. The first index is that of the positions to be - averaged over. The second index is over the different models. The last - index is over the x, y, and z coordinates. - @type positions: list of lists of numpy float arrays - @return: The averaged positions as a list of vectors. - @rtype: list of numpy float arrays - """ - - # Loop over the multiple models. - ave = [] - for model_index in range(len(positions[0])): - # Append an empty vector. - ave.append(array([0.0, 0.0, 0.0])) - - # Loop over the x, y, and z coordinates. - for coord_index in range(3): - # Loop over the atomic positions. - for atom_index in range(len(positions)): - ave[model_index][coord_index] = ave[model_index][coord_index] + positions[atom_index][model_index][coord_index] - - # Average. - ave[model_index][coord_index] = ave[model_index][coord_index] / len(positions) - - # Return the averaged positions. - return ave - - def copy_molecule(pipe_from=None, mol_from=None, pipe_to=None, mol_to=None): """Copy the contents of a molecule container to a new molecule. @@ -955,7 +925,7 @@ spin.averaging = averaging spin.members = members if averaging == 'linear': - spin.pos = __linear_ave(positions) + spin.pos = linear_ave(positions) def create_spin(spin_num=None, spin_name=None, res_num=None, res_name=None, mol_name=None): @@ -1457,6 +1427,36 @@ # Yield the molecule data container. yield mol + + +def linear_ave(positions): + """Perform linear averaging of the atomic positions. + + @param positions: The atomic positions. The first index is that of the positions to be + averaged over. The second index is over the different models. The last + index is over the x, y, and z coordinates. + @type positions: list of lists of numpy float arrays + @return: The averaged positions as a list of vectors. + @rtype: list of numpy float arrays + """ + + # Loop over the multiple models. + ave = [] + for model_index in range(len(positions[0])): + # Append an empty vector. + ave.append(array([0.0, 0.0, 0.0])) + + # Loop over the x, y, and z coordinates. + for coord_index in range(3): + # Loop over the atomic positions. + for atom_index in range(len(positions)): + ave[model_index][coord_index] = ave[model_index][coord_index] + positions[atom_index][model_index][coord_index] + + # Average. + ave[model_index][coord_index] = ave[model_index][coord_index] / len(positions) + + # Return the averaged positions. + return ave def name_molecule(mol_id, name=None, force=False):