Exemple #1
0
        public double GetMainFreqAndFillPsdDataFromComLists()
        {
            //var lo = "";
            //foreach (var v in listComY)
            //{
            //    lo += $",{v}";
            //}
            //remove mean from list
            var avgX             = Results.listComX.Average();
            var avgY             = Results.listComY.Average();
            var listWithoutMeanX = Results.listComX.Select(x => x - avgX).ToList();
            var listWithoutMeanY = Results.listComY.Select(x => x - avgY).ToList();
            //returned value is max from average of two spectrums
            FftResult fftX = Fft.GetAmpSpectrumAndMax(frameRate, listWithoutMeanX, false);// false bc avg is already removed
            FftResult fftY = Fft.GetAmpSpectrumAndMax(frameRate, listWithoutMeanY, false);

            List <double> avgSpecList = new List <double>();

            //List<(double,double)> psdAvgData = new List<(double, double)>();
            Results.PsdAvgData = new List <(double, double)>();
            //List<(double,double)> psdXData = new List<(double, double)>();
            //List<(double,double)> psdYData = new List<(double, double)>();
            for (int i = 0; i < fftX.Values.Count; i++)

            {
                double avg = (fftX.Values[i] + fftY.Values[i]) / 2;
                avgSpecList.Add(avg);
                Results.PsdAvgData.Add((fftX.Frequencies[i], avg));

                //psdXData.Add((fftX.Frequencies[i],))
            }
            int maxIndex = avgSpecList.IndexOf(avgSpecList.Max());

            return(fftX.Frequencies[maxIndex]);
        }
Exemple #2
0
        public void GetFftDuringSignal(int segmentSize, int step)
        {
            var fftProgressSignal = Fft.ComputeFftDuringSignalForTwoSignals(frameRate, Results.ListComXNoAvg, Results.ListComYNoAvg, segmentSize, step, false);

            if (fftProgressSignal.Count == 1)
            {
                fftProgressSignal.Add(fftProgressSignal.First());
            }

            Results.FreqProgress = fftProgressSignal;
            var firstTime     = Results.FrameTimes.First();
            var numberOfTicks = fftProgressSignal.Count;
            var segmentInSec  = (Results.FrameTimes.Last() - firstTime).TotalSeconds / (numberOfTicks - 1);
            var range         = Enumerable.Range(0, numberOfTicks).Select(x => x * segmentInSec + firstTime.TotalSeconds).ToList();

            Results.FreqProgressTime = range;
        }