Author: bugman Date: Fri Mar 18 12:19:38 2011 New Revision: 12817 URL: http://svn.gna.org/viewcvs/relax?rev=12817&view=rev Log: Added a new relaxation data function create_frq_label(). This is for generating a frequency label in MHz rounded to the nearest factor of 10. Modified: 1.3/generic_fns/relax_data.py Modified: 1.3/generic_fns/relax_data.py URL: http://svn.gna.org/viewcvs/relax/1.3/generic_fns/relax_data.py?rev=12817&r1=12816&r2=12817&view=diff ============================================================================== --- 1.3/generic_fns/relax_data.py (original) +++ 1.3/generic_fns/relax_data.py Fri Mar 18 12:19:38 2011 @@ -154,7 +154,7 @@ frq = float(data['frq']) * 1e6 # Round the label to the nearest factor of 10. - frq_label = str(int(round(float(data['frq'])/10)*10)) + frq_label = create_frq_label(float(data['frq']) * 1e6) # The ID string. ri_id = "%s_%s" % (ri_type, frq_label) @@ -439,6 +439,25 @@ # Copy the value and error from pipe_from. spin_to.ri_data[ri_id] = spin_from.ri_data[ri_id] spin_to.ri_data_err[ri_id] = spin_from.ri_data_err[ri_id] + + +def create_frq_label(frq): + """Generate a frequency label in MHz, rounded to the nearest factor of 10. + + @param frq: The frequency in Hz. + @type frq: float + @return: The MHz frequency label. + @rtype: str + """ + + # Convert to MHz. + label = frq / 1e6 + + # Rounding to the nearest factor of 10. + label = int(round(frq/10)*10) + + # Convert to str and return. + return str(label) def delete(ri_id=None):