Ejemplo n.º 1
0
def back_calc():
    """Back calculate the peak intensities.

    The simple two parameter exponential curve (Rx, I0) is assumed.
    """

    # Loop over the spins.
    for spin in spin_loop():
        # Skip deselected spins.
        if not spin.select:
            continue

        # The parameter vector.
        param_vector = array([spin.rx, spin.i0], float64)

        # Initialise the relaxation fit functions.
        setup(num_params=len(spin.params),
              num_times=len(cdp.relax_times),
              values=spin.ave_intensities,
              sd=cdp.sd,
              relax_times=cdp.relax_times,
              scaling_matrix=identity(2, float64))

        # Make a single function call.  This will cause back calculation and the data will be stored in the C module.
        func(param_vector)

        # Get the data and store it in the spin specific data structure.
        spin.fit_int = back_calc_I()
Ejemplo n.º 2
0
    def back_calc_data(self):
        """Return the back-calculated data from the C code.

        @return:    The back-calculated peak intensities.
        @rtype:     list of float
        """

        # Return the data.
        return back_calc_I()
Ejemplo n.º 3
0
    def back_calc_data(self):
        """Return the back-calculated data from the C code.

        @return:    The back-calculated peak intensities.
        @rtype:     list of float
        """

        # Return the data.
        return back_calc_I()
Ejemplo n.º 4
0
    def _back_calc(self, spin=None, relax_time_id=None):
        """Back-calculation of peak intensity for the given relaxation time.

        @keyword spin:              The spin container.
        @type spin:                 SpinContainer instance
        @keyword relax_time_id:     The ID string for the desired relaxation time.
        @type relax_time_id:        str
        @return:                    The peak intensity for the desired relaxation time.
        @rtype:                     float
        """

        # Create the initial parameter vector.
        param_vector = self._assemble_param_vector(spin=spin)

        # Create a scaling matrix.
        scaling_matrix = self._assemble_scaling_matrix(spin=spin, scaling=False)

        # The keys.
        keys = list(spin.intensities.keys())

        # The peak intensities and times.
        values = []
        errors = []
        times = []
        for key in keys:
            values.append(spin.intensities[key])
            errors.append(spin.intensity_err[key])
            times.append(cdp.relax_times[key])

        # The scaling matrix in a diagonalised list form.
        scaling_list = []
        for i in range(len(scaling_matrix)):
            scaling_list.append(scaling_matrix[i, i])

        # Initialise the relaxation fit functions.
        setup(num_params=len(spin.params), num_times=len(cdp.relax_times), values=values, sd=errors, relax_times=times, scaling_matrix=scaling_list)

        # Make a single function call.  This will cause back calculation and the data will be stored in the C module.
        self._func(param_vector)

        # Get the data back.
        results = back_calc_I()

        # Return the correct peak height.
        return results[keys.index(relax_time_id)]
Ejemplo n.º 5
0
def back_calc():
    """Back calculate the peak intensities.

    The simple two parameter exponential curve (Rx, I0) is assumed.
    """

    # Loop over the spins.
    for spin in spin_loop():
        # Skip deselected spins.
        if not spin.select:
            continue

        # The parameter vector.
        param_vector = array([spin.rx, spin.i0], float64)

        # Initialise the relaxation fit functions.
        setup(num_params=len(spin.params), num_times=len(cdp.relax_times), values=spin.ave_intensities, sd=cdp.sd, relax_times=cdp.relax_times, scaling_matrix=identity(2, float64))

        # Make a single function call.  This will cause back calculation and the data will be stored in the C module.
        func(param_vector)

        # Get the data and store it in the spin specific data structure.
        spin.fit_int = back_calc_I()