A class to fit Lorentzians. Note that the standard normalised definition of the Lorentzian is not used, rather one that has a peak height of 1 is used. This makes the estimated amplitude parameter more meaningful (i.e. it's the height of the peak). The w parameter that is returned is the FWHM.
Inheritance: DAQ.Analyze.PeakFitter
        public static double[] FitLorenzianToData(double[] voltages, double[] signal)
        {
            double high = getMax(voltages).value;
            double low = getMin(voltages).value;
            System.Diagnostics.Debug.WriteLine("   " + low.ToString() + "   " + high.ToString());
            LorentzianFitter lorentzianFitter = new LorentzianFitter();

            // takes the parameters (in this order, in the double[])
            // N: background
            // Q: signal
            // c: centre
            // w: width

            dataPoint max = getMax(signal);
            dataPoint min = getMin(signal);
            lorentzianFitter.Fit(voltages, signal,
                new double[] {min.value, max.value - min.value,
                    voltages[max.index], (high - low)/10,
                });

            double[] coefficients = lorentzianFitter.Parameters;

            fitFailSafe(coefficients, low, high);

            return new double[] { coefficients[3], coefficients[2], coefficients[1], coefficients[0] }; //to be consistent with old convention.
        }
        public static double[] FitLorenzianToSlaveData(CavityScanData data, double limitLow, double limitHigh)
        {
            double[] voltages = data.parameters.CalculateRampVoltages();

            LorentzianFitter lorentzianFitter = new LorentzianFitter();

            // takes the parameters (in this order, in the double[])
            // N: background
            // Q: signal
            // c: centre
            // w: width

            dataPoint max = getMax(data.SlavePhotodiodeData);
            dataPoint min = getMin(data.SlavePhotodiodeData);
            lorentzianFitter.Fit(voltages, data.SlavePhotodiodeData,
                new double[] {min.value, max.value - min.value,
                    voltages[max.index], (data.parameters.High - data.parameters.Low)/10,
                });

            double[] coefficients = lorentzianFitter.Parameters;

            fitFailSafe(coefficients, limitLow, limitHigh);

            return new double[] { coefficients[3], coefficients[2], coefficients[1], coefficients[0] }; //to be consistent with old convention.
        }