コード例 #1
0
        public void AnalyzeMainPeak(double alpha, int searchWindow, double threshold, double maxDistance,
                                    Action <int> reportProgress)
        {
            peaks.Clean();

            var kalman = new Kalman();

            var voltages = dataCursor.GetAllVoltages();
            var filter   = 0.0;

            for (var voltage = 0; voltage < voltages.Count; voltage++)
            {
                reportProgress.Invoke(100 * voltage / voltages.Count);

                var currentRawData = dataCursor.GetSpectrum(voltage);
                var processedData  = dataSmoother.Smooth(currentRawData, alpha);

                var fittedPeaks = peaksFinder.Find(currentRawData, processedData, searchWindow, threshold, 1);

                if (fittedPeaks.Count == 0)
                {
                    continue;
                }

                var modelPeak = fittedPeaks.First();

                var reference = peaks.Get(0);
                if (reference != null && reference.Count > 0)
                {
                    if (Math.Abs(filter - modelPeak.Gamma) > maxDistance)
                    {
                        continue;
                    }
                }

                if (modelPeak.Alpha > 0 && modelPeak.Beta > 0 && modelPeak.Gamma > 0)
                {
                    peaks.Update(0, voltages[voltage], modelPeak, true);
                    filter = kalman.Update(modelPeak.Gamma);
                }
            }
        }