Author: bugman Date: Fri Oct 24 15:40:05 2008 New Revision: 7964 URL: http://svn.gna.org/viewcvs/relax?rev=7964&view=rev Log: Renamed and converted the read() method to relax_time(). The method now simply creates a structure in the relax data store matching cdp.spectrum_ids and storing the associated relaxation time periods. Modified: branches/spectral_errors/specific_fns/relax_fit.py Modified: branches/spectral_errors/specific_fns/relax_fit.py URL: http://svn.gna.org/viewcvs/relax/branches/spectral_errors/specific_fns/relax_fit.py?rev=7964&r1=7963&r2=7964&view=diff ============================================================================== --- branches/spectral_errors/specific_fns/relax_fit.py (original) +++ branches/spectral_errors/specific_fns/relax_fit.py Fri Oct 24 15:40:05 2008 @@ -943,66 +943,41 @@ continue - def read(self, file=None, dir=None, relax_time=0.0, format=None, heteronuc=None, proton=None, int_col=None): - """Read in the peak intensity data. - - This method sets up the global data structures in the current data pipe and then calls - intensity.read(). - - - @keyword file: The name of the file containing the peak intensities. - @type file: str - @keyword dir: The directory where the file is located. - @type dir: str - @keyword relax_time: The time, in seconds, of the relaxation period. - @type relax_time: float - @keyword format: The type of file containing peak intensities. This can currently be - one of 'sparky', 'xeasy' or 'nmrview'. - @type format: str - @keyword heteronuc: The name of the heteronucleus as specified in the peak intensity - file. - @type heteronuc: str - @keyword proton: The name of the proton as specified in the peak intensity file. - @type proton: str - @keyword int_col: The column containing the peak intensity data (for a non-standard - formatted file). - @type int_col: int + def relax_time(self, time=0.0, spectrum_id=None): + """Set the relaxation time period associated with a given spectrum. + + @keyword time: The time, in seconds, of the relaxation period. + @type time: float + @keyword spectrum_id: The spectrum identification string. + @type spectrum_id: str """ # Alias the current data pipe. cdp = pipes.get_pipe() + # Test if the spectrum id exists. + if spectrum_id not in cdp.spectrum_ids: + raise RelaxError, "The peak heights corresponding to spectrum id '%s' have not been loaded." % spectrum_id + # Store the relaxation time in the class instance. - self.__relax_time = float(relax_time) - - # Global relaxation time data structure. + self.__relax_time = float(time) + + # The index. + index = cdp.spectrum_ids.index(spectrum_id) + + # Initialise the global relaxation time data structure if needed. if not hasattr(cdp, 'relax_times'): - cdp.relax_times = [] - - # Number of spectra. - if not hasattr(cdp, 'num_spectra'): - cdp.num_spectra = [] - - # Determine if the relaxation time already exists for the residue (duplicated spectra). - index = None - for i in xrange(len(cdp.relax_times)): - if relax_time == cdp.relax_times[i]: - index = i - - # A new relaxation time. - if index == None: - # Add the time. - cdp.relax_times.append(relax_time) - - # First spectrum. - cdp.num_spectra.append(1) - - # Duplicated spectra. - else: - cdp.num_spectra[index] = cdp.num_spectra[index] + 1 - - # Generic intensity function. - intensity.read(file=file, dir=dir, format=format, heteronuc=heteronuc, proton=proton, int_col=int_col, assign_func=self.assign_function) + cdp.relax_times = [None] * len(cdp.spectrum_ids) + + # Index not present in the global relaxation time data structure. + while 1: + if index > len(cdp.relax_times) - 1: + cdp.relax_times.append(None) + else: + break + + # Add the time at the correct position. + cdp.relax_times[index] = time def return_data(self, spin):