def FitResolution(self, data, model, resolution=75000.0):
        """
        Fits the instrumental resolution with a Gaussian. This method is
        called by GenerateModel, and is not meant to be called by the user!
        """

        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)


    ### -----------------------------------------------
dataset/ETHPy150Open kgullikson88/Telluric-Fitter/src/TelluricFitter.py/TelluricFitter.FitResolution/original