Author: bugman Date: Fri Sep 6 12:14:00 2013 New Revision: 20888 URL: http://svn.gna.org/viewcvs/relax?rev=20888&view=rev Log: The get_curve_type() function now works with the spectrum ID. This specific_analyses.relax_disp.disp_data.get_curve_type() function already existed but it operated on all the loaded data. Now it can handle a single spectrum ID. The count_relax_times() function has been added to aid get_curve_type(). Modified: branches/relax_disp/specific_analyses/relax_disp/disp_data.py Modified: branches/relax_disp/specific_analyses/relax_disp/disp_data.py URL: http://svn.gna.org/viewcvs/relax/branches/relax_disp/specific_analyses/relax_disp/disp_data.py?rev=20888&r1=20887&r2=20888&view=diff ============================================================================== --- branches/relax_disp/specific_analyses/relax_disp/disp_data.py (original) +++ branches/relax_disp/specific_analyses/relax_disp/disp_data.py Fri Sep 6 12:14:00 2013 @@ -47,7 +47,7 @@ from pipe_control.mol_res_spin import exists_mol_res_spin_data, return_spin, spin_loop from pipe_control.result_files import add_result_file from pipe_control.spectrum import check_spectrum_id -from specific_analyses.relax_disp.checks import check_mixed_curve_types +from specific_analyses.relax_disp.checks import check_exp_type, check_mixed_curve_types from specific_analyses.relax_disp.variables import EXP_TYPE_CPMG_FIXED, EXP_TYPE_CPMG_EXP, EXP_TYPE_DESC_CPMG_FIXED, EXP_TYPE_DESC_CPMG_EXP, EXP_TYPE_DESC_R1RHO_FIXED, EXP_TYPE_DESC_R1RHO_EXP, EXP_TYPE_LIST, EXP_TYPE_LIST_CPMG, EXP_TYPE_LIST_FIXED_TIME, EXP_TYPE_LIST_R1RHO, EXP_TYPE_LIST_VAR_TIME, EXP_TYPE_R1RHO_FIXED, EXP_TYPE_R1RHO_EXP from stat import S_IRWXU, S_IRGRP, S_IROTH from os import chmod, path, sep @@ -138,6 +138,25 @@ return cdp.spectrometer_frq_count +def count_relax_times(exp_type=None): + """Count the number of relaxation times present. + + @keyword exp_type: The experiment type. + @type exp_type: str + @return: The relaxation time count for the given experiment. + @rtype: int + """ + + # Loop. + times = [] + for frq, point, time in loop_frq_point_time(exp_type=exp_type): + if time not in times: + times.append(time) + + # Return the count. + return len(times) + + def cpmg_frq(spectrum_id=None, cpmg_frq=None): """Set the CPMG frequency associated with a given spectrum. @@ -282,20 +301,34 @@ return ids -def get_curve_type(): +def get_curve_type(id=None): """Return the unique curve type. - @return: The curve type - either 'fixed time' or 'exponential'. - @rtype: str - """ - - # Data checks. - check_mixed_curve_types() - - # Determine the curve type. - curve_type = 'fixed time' - if has_exponential_exp_type(): + @keyword id: The spectrum ID. If not supplied, then all data will be assumed. + @type id: str + @return: The curve type - either 'fixed time' or 'exponential'. + @rtype: str + """ + + # Data check. + check_exp_type() + + # All data. + if id == None: + # Data checks. + check_mixed_curve_types() + + # Determine the curve type. + curve_type = 'fixed time' + if has_exponential_exp_type(): + curve_type = 'exponential' + + # A specific ID. + else: + # Determine the curve type. curve_type = 'exponential' + if count_relax_times(cdp.exp_type[id]) == 1: + curve_type = 'fixed time' # Return the type. return curve_type