Author: bugman Date: Thu Apr 14 17:19:46 2011 New Revision: 12822 URL: http://svn.gna.org/viewcvs/relax?rev=12822&view=rev Log: The grace file created by pcs.corr_plot() now separates each element into its own graph. Modified: 1.3/generic_fns/pcs.py Modified: 1.3/generic_fns/pcs.py URL: http://svn.gna.org/viewcvs/relax/1.3/generic_fns/pcs.py?rev=12822&r1=12821&r2=12822&view=diff ============================================================================== --- 1.3/generic_fns/pcs.py (original) +++ 1.3/generic_fns/pcs.py Thu Apr 14 17:19:46 2011 @@ -235,45 +235,57 @@ # The diagonal. data.append([[-100, -100, 0], [100, 100, 0]]) + # The spin types. + types = [] + for spin in spin_loop(): + if spin.element not in types: + types.append(spin.element) + # Loop over the PCS data. for align_id in cdp.pcs_ids: - # Append a new list for this alignment. - data.append([]) - - # Errors present? - err_flag = False - for spin in spin_loop(): - # Skip deselected spins. - if not spin.select: - continue - - # Error present. - if hasattr(spin, 'pcs_err') and align_id in spin.pcs_err.keys(): - err_flag = True - break - - # Loop over the spins. - for spin, spin_id in spin_loop(return_id=True): - # Skip deselected spins. - if not spin.select: - continue - - # Skip if data is missing. - if not hasattr(spin, 'pcs') or not hasattr(spin, 'pcs_bc') or not align_id in spin.pcs.keys() or not align_id in spin.pcs_bc.keys(): - continue - - # Append the data. - data[-1].append([spin.pcs_bc[align_id], spin.pcs[align_id]]) - - # Errors. - if err_flag: + # Loop over the spin types. + for i in range(len(types)): + # Append a new list for this alignment. + data.append([]) + + # Errors present? + err_flag = False + for spin in spin_loop(): + # Skip deselected spins. + if not spin.select: + continue + + # Error present. if hasattr(spin, 'pcs_err') and align_id in spin.pcs_err.keys(): - data[-1][-1].append(spin.pcs_err[align_id]) - else: - data[-1][-1].append(None) - - # Label. - data[-1][-1].append(spin_id) + err_flag = True + break + + # Loop over the spins. + for spin, spin_id in spin_loop(return_id=True): + # Skip deselected spins. + if not spin.select: + continue + + # Incorrect spin type. + if spin.element != types[i]: + continue + + # Skip if data is missing. + if not hasattr(spin, 'pcs') or not hasattr(spin, 'pcs_bc') or not align_id in spin.pcs.keys() or not align_id in spin.pcs_bc.keys(): + continue + + # Append the data. + data[-1].append([spin.pcs_bc[align_id], spin.pcs[align_id]]) + + # Errors. + if err_flag: + if hasattr(spin, 'pcs_err') and align_id in spin.pcs_err.keys(): + data[-1][-1].append(spin.pcs_err[align_id]) + else: + data[-1][-1].append(None) + + # Label. + data[-1][-1].append(spin_id) # The data size. size = len(data) @@ -289,8 +301,14 @@ # Grace file. if format == 'grace': + # The set names. + set_names = [None] + for i in range(len(cdp.pcs_ids)): + for j in range(len(types)): + set_names.append("%s (%s)" % (cdp.pcs_ids[i], types[j])) + # The header. - grace.write_xy_header(file=file, title="PCS correlation plot", sets=size, set_names=[None]+cdp.pcs_ids, linestyle=[2]+[0]*size, data_type=['pcs_bc', 'pcs'], axis_min=[-0.5, -0.5], axis_max=[0.5, 0.5], legend_pos=[1, 0.5]) + grace.write_xy_header(file=file, title="PCS correlation plot", sets=size, set_names=set_names, linestyle=[2]+[0]*size, data_type=['pcs_bc', 'pcs'], axis_min=[-0.5, -0.5], axis_max=[0.5, 0.5], legend_pos=[1, 0.5]) # The main data. grace.write_xy_data(data=data, file=file, graph_type=graph_type)