Beispiel #1
0
        private void MakeVelo()
        {
            List <SignalPoint> sourceSignal = new List <SignalPoint>();


            string path = @"D:\stud_repo\astu\DS\FourierTransform\FourierTransform\test\velo\velo04.txt";

            sourceSignal = ReadData(path, "velo");

            var    cs          = sourceSignal.Select(p => new Complex(p.Y, 0)).ToArray();
            var    transform   = FourierTransformer.DFT(cs, false);
            double hc          = _profiles["velo"].Frequency / sourceSignal.Count;
            int    targetIndex = (int)Math.Floor(3.0 / hc + 0.5);

            for (int i = 0; i < targetIndex; i++)
            {
                transform[i] = transform[transform.Length - i - 1] = 0;
            }
            var result = FourierTransformer.DFT(transform, true)
                         .Select((c, index) => new SignalPoint {
                X = index / 360.0, Y = c.Real
            }).ToList();

            ShowCharts(sourceSignal, result, "reo");
        }
Beispiel #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            const int M = 8;

            int p = (int)Math.Floor(Math.Log(1.0 * _transformedSource.Count / M, 2));
            int availableCount = M * (int)Math.Pow(2, p);
            var range          = _transformedSource.GetRange(0, availableCount);
            var signalCut      = range.Select(pt => new Complex(pt.Y, 0)).ToArray();

            //var src = _transformedSource.Select(p => new Complex(p.Y, 0)).ToArray();
            Stopwatch sw = new Stopwatch();

            sw.Start();
            var transform = FourierTransformer.DFT(signalCut, false);

            sw.Stop();
            TimeSpan timeSpan = sw.Elapsed;

            label1.Text = string.Format("Time: {0}m {1}s {2}ms", timeSpan.Minutes, timeSpan.Seconds, timeSpan.Milliseconds);
            var dft = FourierTransformer.CalculateSpecs(transform);

            sourceChart.DataSource = range;
            sourceChart.DataBind();

            ampSpec.DataSource                = dft.amplitudeSpec.GetRange(0, dft.amplitudeSpec.Count / 2);
            ampSpec.Series[0].XValueMember    = "X";
            ampSpec.Series[0].YValueMembers   = "Y";
            ampSpec.ChartAreas[0].AxisX.Title = "Гц";
            ampSpec.DataBind();


            phaseSpec.DataSource                = dft.phaseSpec.GetRange(0, dft.phaseSpec.Count / 2);
            phaseSpec.Series[0].XValueMember    = "X";
            phaseSpec.Series[0].YValueMembers   = "Y";
            phaseSpec.ChartAreas[0].AxisX.Title = "Гц";
            phaseSpec.DataBind();
        }
Beispiel #3
0
        private void MakeCardio()
        {
            List <SignalPoint> sourceSignal = new List <SignalPoint>();


            string path = @"D:\stud_repo\astu\DS\FourierTransform\FourierTransform\test\car\cardio05.txt";

            sourceSignal = ReadData(path, "cardio");

            //var ab = Fourier.FourierTransformer.CalculateAB(sourceSignal);
            var    cs          = sourceSignal.Select(p => new Complex(p.Y, 0)).ToArray();
            var    transform   = FourierTransformer.DFT(cs, false);
            double hc          = _profiles["cardio"].Frequency / sourceSignal.Count;
            int    targetIndex = (int)Math.Floor(50.0 / hc + 0.5);

            transform[targetIndex - 1] = transform[targetIndex] = transform[targetIndex + 1] = 0;
            //ab.b[targetIndex - 1] = ab.b[targetIndex] = ab.b[targetIndex + 1] = 0;
            var result = FourierTransformer.DFT(transform, true)
                         .Select((c, index) => new SignalPoint {
                X = index / 360.0, Y = c.Real
            }).ToList();

            ShowCharts(sourceSignal, result, "cardio");
        }