def FitResolution(self, data, model, resolution=75000.0):

        logging.info("Fitting Resolution")

        #Subsample the model to speed this part up (it doesn't affect the accuracy much)
        dx = (data.x[1] - data.x[0]) / 3.0
        xgrid = np.arange(model.x[0], model.x[-1] + dx, dx)
        #xgrid = np.linspace(model.x[0], model.x[-1], model.size()/5)
        newmodel = FittingUtilities.RebinData(model, xgrid)

        ResolutionFitErrorBrute = lambda resolution, data, model: np.sum(
            self.ResolutionFitError(resolution, data, model))

        try:
            resolution = fminbound(ResolutionFitErrorBrute, self.resolution_bounds[0], self.resolution_bounds[1], xtol=1,
                                   args=(data, newmodel))
        except ValueError:
            print("ValueError encountered while fitting the detector resolution. Falling back to guess resolution!")


        logging.info("Optimal resolution found at R = {}".format(float(resolution)))
        newmodel = FittingUtilities.ReduceResolution(newmodel, float(resolution))
        return FittingUtilities.RebinData(newmodel, data.x), float(resolution)


    ### -----------------------------------------------
Initialize animated topomap.
dataset/ETHPy150Open kgullikson88/Telluric-Fitter/src/TelluricFitter.py/TelluricFitter.FitResolution--crossover with--dataset/ETHPy150Open mne-tools/mne-python/mne/viz/topomap.py/_init_anim