Sets the calibration to use with this stimulus, 
        creates a filter that will be applied to output signal generated by this model.
        Set arguments to `None` to clear calibration.

        :param dbBoostArray: frequency response of the system (in dB)
        :type dbBoostArray: numpy.ndarray
        :param frequencies: corresponding frequencies for the dbBoostArray
        :type frequencies: numpy.ndarray
        :param frange: The desired frequency range for which to apply the calibration, in Hz
        :type frange: (int, int)

def setCalibration(self, dbBoostArray, frequencies, frange):
        """Sets the calibration to use with this stimulus, 
        creates a filter that will be applied to output signal generated by this model.
        Set arguments to `None` to clear calibration.

        :param dbBoostArray: frequency response of the system (in dB)
        :type dbBoostArray: numpy.ndarray
        :param frequencies: corresponding frequencies for the dbBoostArray
        :type frequencies: numpy.ndarray
        :param frange: The desired frequency range for which to apply the calibration, in Hz
        :type frange: (int, int)
        """
        if dbBoostArray is not None and frequencies is not None:
            logger = logging.getLogger('main')
            if dbBoostArray.shape != frequencies.shape:
                logger.error("ERROR: calibration array and frequency array must have same dimensions")
                return
            if frange is None:
                # maximum possible range
                frange = (frequencies[0], frequencies[-1])

            logger.debug('setting calibration with samplerate {}'.format(self.samplerate()))
            fs = self.samplerate()
            if fs in StimulusModel.kernelCache:
                logger.debug('---->using cached filter')
                # makes the assumption that the cache will be cleared if the frequency reponse
                # changes
                self.impulseResponse = StimulusModel.kernelCache[fs]
            else:
                logger.debug('---->calculating new filter for fs {}'.format(fs))
                self.impulseResponse = impulse_response(fs, dbBoostArray, frequencies, frange)
                # mutable type so will affect data structure persistently
                StimulusModel.kernelCache[fs] = self.impulseResponse

            # store this so we can quickly check if a calibration needs to be re-done    
            self._calibration_fs = fs
            
            # calculate for the default samplerate, if not already, since
            # we are very likely to need it, and it's better to have this done
            # up front, than cause lag in the UI later
            if DEFAULT_SAMPLERATE not in StimulusModel.kernelCache:
                StimulusModel.kernelCache[DEFAULT_SAMPLERATE] = impulse_response(DEFAULT_SAMPLERATE, dbBoostArray, frequencies, frange)

            # hang on to these for re-calculating impulse response on samplerate change
            self._attenuationVector = dbBoostArray
            self._calFrequencies = frequencies
            self._calFrange = frange

        else:
            self.impulseResponse = None