'Apply CTF gradient compensation.
.. warning:: The compensation matrices are stored with single
precision, so repeatedly switching between different
of compensation (e.g., 0->1->3->2) can increase
numerical noise, especially if data are saved to
disk in between changing grades. It is thus best to
only use a single gradient compensation level in
final analyses.
Parameters
grade : int
CTF gradient compensation level.
verbose : bool, str, int, or None
If not None, override default verbose level (see
:func:`mne.verbose` and :ref:`Logging documentation <tut_logging>`
for more).
Returns
raw : instance of Raw
The modified Raw instance. Works in-place.'

@verbose
def apply_gradient_compensation(self, grade, verbose=None):

    grade = int(grade)
    current_comp = self.compensation_grade
    if (current_comp != grade):
        if self.proj:
            raise RuntimeError('Cannot    change    compensation    on    data    where    projectors    have    been    applied')
        from_comp = (current_comp if self.preload else self._read_comp_grade)
        comp = make_compensator(self.info, from_comp, grade)
        logger.info(('Compensator    constructed    to    change    %d    ->    %d' % (current_comp, grade)))
        set_current_comp(self.info, grade)
        if self.preload:
            logger.info('Applying    compensator    to    loaded    data')
            lims = np.concatenate([np.arange(0, len(self.times), 10000), [len(self.times)]])
            for (start, stop) in zip(lims[:(-1)], lims[1:]):
                self._data[:, start:stop] = np.dot(comp, self._data[:, start:stop])
        else:
            self._comp = comp
    return self
