Exemplo n.º 1
0
        public void Test_SplineFilter()
        {
            var filter = new SplineFilter(3);

            Assert.IsNotNull(filter);

            Assert.AreEqual(3.0, filter.Run(3.0));
            Assert.AreEqual(2.0, filter.Run(1.0));
            Assert.IsTrue(DoubleHelper.Equals(4.66666, filter.Run(10.0)));
            Assert.IsTrue(DoubleHelper.Equals(4.33333, filter.Run(2.0)));
        }
Exemplo n.º 2
0
        public void ApplyFilter()
        {
            switch (fPostAction)
            {
            case PostAction.paSpline:
            {
                SplineFilter splineFilter = new SplineFilter(fSplineCount);
                for (int i = 0; i < fData.Count; i++)
                {
                    TrendPoint trendPt = this[i];
                    trendPt.pFilteredValue = splineFilter.Run(trendPt.pValue);
                }
                //splineFilter.Dispose();
            }
            break;

            case PostAction.paFilter:
            {
                int count = fData.Count;
                if (count != 0)
                {
                    LowPassFilter lowPassFilter = new LowPassFilter(count);
                    try {
                        for (int i = 0; i < count; i++)
                        {
                            lowPassFilter.SetInputDataItem(i, this[i].pValue);
                        }

                        lowPassFilter.SetMode(fFilter.Mode);
                        lowPassFilter.SetBandWidth(fFilter.BandWidth);
                        lowPassFilter.SetOvershoot(fFilter.Overshoot);
                        lowPassFilter.SetFrequencyResolution(fFilter.FrequencyResolution);
                        lowPassFilter.SetSuppressionDegree(fFilter.SuppressionDegree);
                        lowPassFilter.SetSubstractionNoiseDegree(fFilter.SubstractionNoiseDegree);
                        lowPassFilter.Execute();

                        for (int i = 0; i < count; i++)
                        {
                            this[i].pFilteredValue = lowPassFilter.GetOutputDataItem(i);
                        }
                    } finally {
                        //lowPassFilter.Dispose();
                    }
                }
            }
            break;
            }
        }