当前位置: 首页>>代码示例>>C#>>正文


C# DataGroup.Add方法代码示例

本文整理汇总了C#中DataGroup.Add方法的典型用法代码示例。如果您正苦于以下问题:C# DataGroup.Add方法的具体用法?C# DataGroup.Add怎么用?C# DataGroup.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataGroup的用法示例。


在下文中一共展示了DataGroup.Add方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Combine

        public static DataGroup Combine(params DataGroup[] dataGroups)
        {
            DataGroup combination = new DataGroup();

            foreach (DataGroup dataGroup in dataGroups)
            {
                foreach (DataSeries dataSeries in dataGroup.DataSeries)
                    combination.Add(dataSeries);
            }

            return combination;
        }
开发者ID:GridProtectionAlliance,项目名称:openXDA,代码行数:12,代码来源:Transform.cs

示例2: ToCycleDataGroup

        public static CycleDataGroup ToCycleDataGroup(DataSeries dataSeries, double frequency)
        {
            DataGroup dataGroup = new DataGroup();

            DataSeries rmsSeries = new DataSeries();
            DataSeries phaseSeries = new DataSeries();
            DataSeries peakSeries = new DataSeries();
            DataSeries errorSeries = new DataSeries();

            int samplesPerCycle;
            double[] yValues;
            double[] tValues;
            double sum;

            DateTime cycleTime;
            SineWave sineFit;

            if ((object)dataSeries == null)
                return null;

            // Set series info to the source series info
            rmsSeries.SeriesInfo = dataSeries.SeriesInfo;
            phaseSeries.SeriesInfo = dataSeries.SeriesInfo;
            peakSeries.SeriesInfo = dataSeries.SeriesInfo;
            errorSeries.SeriesInfo = dataSeries.SeriesInfo;

            // Get samples per cycle of the data series based on the given frequency
            samplesPerCycle = CalculateSamplesPerCycle(dataSeries, frequency);

            // Initialize arrays of y-values and t-values for calculating cycle data
            yValues = new double[samplesPerCycle];
            tValues = new double[samplesPerCycle];

            // Obtain a list of time gaps in the data series
            List<int> gapIndexes = Enumerable.Range(0, dataSeries.DataPoints.Count - 1)
                .Where(index =>
                {
                    DataPoint p1 = dataSeries[index];
                    DataPoint p2 = dataSeries[index + 1];
                    double cycleDiff = (p2.Time - p1.Time).TotalSeconds * frequency;
                    return (cycleDiff >= 0.25);
                })
                .ToList();

            for (int i = 0; i <= dataSeries.DataPoints.Count - samplesPerCycle; i++)
            {
                // If the cycle following i contains a data gap, do not calculate cycle data
                if (gapIndexes.Any(index => i <= index && (i + samplesPerCycle - 1) > index))
                    continue;

                // Use the time of the first data point in the cycle as the time of the cycle
                cycleTime = dataSeries.DataPoints[i].Time;
                sum = 0.0D;

                // Copy values from the original data series into the y-value and t-value arrays
                for (int j = 0; j < samplesPerCycle; j++)
                {
                    yValues[j] = dataSeries.DataPoints[i + j].Value;
                    tValues[j] = (dataSeries.DataPoints[i + j].Time - cycleTime).TotalSeconds;
                    sum += yValues[j] * yValues[j];
                }

                // Use a curve fitting algorithm to estimate the sine wave over this cycle
                sineFit = WaveFit.SineFit(yValues, tValues, frequency);

                // Add data points to each of the cycle data series
                rmsSeries.DataPoints.Add(new DataPoint()
                {
                    Time = cycleTime,
                    Value = Math.Sqrt(sum / samplesPerCycle)
                });

                phaseSeries.DataPoints.Add(new DataPoint()
                {
                    Time = cycleTime,
                    Value = sineFit.Phase
                });

                peakSeries.DataPoints.Add(new DataPoint()
                {
                    Time = cycleTime,
                    Value = sineFit.Amplitude
                });

                errorSeries.DataPoints.Add(new DataPoint()
                {
                    Time = cycleTime,

                    Value = tValues
                        .Select(sineFit.CalculateY)
                        .Zip(yValues, (estimate, value) => Math.Abs(estimate - value))
                        .Sum()
                });
            }

            // Add a series to the data group for each series of cycle data
            dataGroup.Add(rmsSeries);
            dataGroup.Add(phaseSeries);
            dataGroup.Add(peakSeries);
            dataGroup.Add(errorSeries);
//.........这里部分代码省略.........
开发者ID:GridProtectionAlliance,项目名称:openXDA,代码行数:101,代码来源:Transform.cs

示例3: TransformGroup

        /// <summary>
        /// Transforms the group.
        /// </summary>
        /// <param name="inputGroup">The input group.</param>
        /// <returns>Two result groups as result of one transformation step.</returns>
        private DataGroup[] TransformGroup(DataGroup inputGroup)
        {
            var addGroup = new DataGroup("+");
            for (int i = 0; i < inputGroup.Count; i += 2)
            {
                var val = (inputGroup[i] + inputGroup[i + 1]) / Math.Sqrt(2.0);
                var roundedVal = Math.Round(val, 3);
                addGroup.Add(roundedVal);
            }

            var subGroup = new DataGroup("-");
            for (int i = 0; i < inputGroup.Count; i += 2)
            {
                var val = (inputGroup[i] - inputGroup[i + 1]) / Math.Sqrt(2.0);
                var roundedVal = Math.Round(val, 3);
                subGroup.Add(roundedVal);
            }

            return new[] { addGroup, subGroup };
        }
开发者ID:cwschroeder,项目名称:Wavelet,代码行数:25,代码来源:DataRow.cs

示例4: GetFaultLocationData

        private static DataGroup GetFaultLocationData(Meter meter, FaultLocationData.FaultCurveDataTable faultCurveTable)
        {
            DataGroup faultLocationData = new DataGroup();
            DataGroup parsedGroup = new DataGroup();

            foreach (FaultLocationData.FaultCurveRow faultCurveRow in faultCurveTable)
            {
                parsedGroup.FromData(meter, faultCurveRow.Data);

                foreach (DataSeries series in parsedGroup.DataSeries)
                    faultLocationData.Add(series);
            }

            return faultLocationData;
        }
开发者ID:GridProtectionAlliance,项目名称:openXDA,代码行数:15,代码来源:CSVWriter.cs


注:本文中的DataGroup.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。