示例#1
0
            /// <summary>
            /// Get the averaged value.  This will take the accumulated values and generate
            /// an averaged value.  It will then multiply the scale value to the averaged
            /// value.  The average value is then stored to the array.
            /// If no data has been accumulated, NULL will be returned.
            /// </summary>
            /// <param name="scale">Scale value to multiply to the averaged value.</param>
            /// <returns>An array of averaged value and a scale value multiplied in.</returns>
            public virtual float[,] GetAverage(float scale = 1.0f)
            {
                // Accumulate the data
                AccumulatedData data = AccumulateData();

                // Then average the data
                return(AverageData(data, scale));
            }
示例#2
0
            /// <summary>
            /// Average all the given accumulated data.  This will then multiple a
            /// scale value to the averaged data.
            /// </summary>
            /// <param name="accumData">Accumulated values.</param>
            /// <param name="scale">Scale value to multiply to averaged value.</param>
            /// <returns>Array with the averaged and scaled value.</returns>
            protected float[,] AverageData(AccumulatedData accumData, float scale)
            {
                // Create an array, if no data is accumulated, null will be retruned
                float[,] result = null;

                if (accumData.AvgAccum != null && accumData.AvgCount != null)
                {
                    // Create the results array based off the accumulated values
                    result = new float[accumData.AvgAccum.GetLength(0), accumData.AvgAccum.GetLength(1)];

                    // Set Min and Max bin
                    int minBin = 0;
                    int maxBin = accumData.AvgAccum.GetLength(0);
                    int numBeams = accumData.AvgCount.GetLength(1);

                    // Average all the accumulated data
                    for (int bin = minBin; bin < maxBin; bin++)
                    {
                        // Check if it has at least 1 beams
                        if (numBeams > 0)
                        {
                            // Calculate the average values
                            float B0 = 0.0f;
                            if (accumData.AvgCount[bin, DataSet.Ensemble.BEAM_0_INDEX] > 0)
                            {
                                B0 = accumData.AvgAccum[bin, DataSet.Ensemble.BEAM_0_INDEX] / accumData.AvgCount[bin, DataSet.Ensemble.BEAM_0_INDEX];       // Beam 0 Average
                                // Set results
                                B0 *= scale;
                                result[bin, DataSet.Ensemble.BEAM_0_INDEX] = B0;
                            }
                            else
                            {
                                result[bin, DataSet.Ensemble.BEAM_0_INDEX] = DataSet.Ensemble.BAD_VELOCITY;
                            }
                        }

                        // Check if it has at least 2 beams
                        if (numBeams > 1)
                        {
                            float B1 = 0.0f;
                            if (accumData.AvgCount[bin, DataSet.Ensemble.BEAM_1_INDEX] > 0)
                            {
                                B1 = accumData.AvgAccum[bin, DataSet.Ensemble.BEAM_1_INDEX] / accumData.AvgCount[bin, DataSet.Ensemble.BEAM_1_INDEX];       // Beam 1 Average

                                // Set Results
                                B1 *= scale;
                                result[bin, DataSet.Ensemble.BEAM_1_INDEX] = B1;
                            }
                            else
                            {
                                result[bin, DataSet.Ensemble.BEAM_1_INDEX] = DataSet.Ensemble.BAD_VELOCITY;
                            }
                        }

                        // Check if it has a least 3 beams
                        if (numBeams > 2)
                        {
                            float B2 = 0.0f;
                            if (accumData.AvgCount[bin, DataSet.Ensemble.BEAM_2_INDEX] > 0)
                            {
                                B2 = accumData.AvgAccum[bin, DataSet.Ensemble.BEAM_2_INDEX] / accumData.AvgCount[bin, DataSet.Ensemble.BEAM_2_INDEX];       // Beam 2 Average

                                // Set Results
                                B2 *= scale;
                                result[bin, DataSet.Ensemble.BEAM_2_INDEX] = B2;
                            }
                            else
                            {
                                result[bin, DataSet.Ensemble.BEAM_2_INDEX] = DataSet.Ensemble.BAD_VELOCITY;
                            }
                        }

                        // Check if it has a least 4 beams
                        if (numBeams > 3)
                        {
                            float B3 = 0.0f;
                            if (accumData.AvgCount[bin, DataSet.Ensemble.BEAM_3_INDEX] > 0)
                            {
                                B3 = accumData.AvgAccum[bin, DataSet.Ensemble.BEAM_3_INDEX] / accumData.AvgCount[bin, DataSet.Ensemble.BEAM_3_INDEX];       // Beam 3 Average

                                // Set Result
                                B3 *= scale;
                                result[bin, DataSet.Ensemble.BEAM_3_INDEX] = B3;
                            }
                            else
                            {
                                result[bin, DataSet.Ensemble.BEAM_3_INDEX] = DataSet.Ensemble.BAD_VELOCITY;
                            }
                        }
                    }
                }

                return result;
            }
示例#3
0
            /// <summary>
            /// This will accumulate all the data.  THis will go through each
            /// accumulated data and accumulate the values.  It will check for
            /// bad values before accumulating.  If the value is bad, it will
            /// not be included in the accumulated data.  This will keep track
            /// of the accumulated data and the number of data points for each bin.
            /// The results will then be stored to a struct and returned.
            /// </summary>
            /// <returns>Struct containing the accumulated data.</returns>
            protected AccumulatedData AccumulateData()
            {
                AccumulatedData result = new AccumulatedData();

                if (_accumData.Count > 0)
                {
                    // Get the number of bins and beams
                    // These values should be the same for all the accumulated data
                    float[,] firstData = _accumData.First();
                    int numBins = firstData.GetLength(0);
                    int numBeams = firstData.GetLength(1);

                    // Create arrays to accumulate the data
                    float[,] avgAccum = new float[numBins, numBeams];
                    int[,] avgCount = new int[numBins, numBeams];

                    // Accumulate the data for each accumulate array
                    for (int x = 0; x < _accumData.Count; x++)
                    {
                        // Get the data from the list
                        float[,] data = _accumData[x];

                        // Accumulate the values
                        for (int bin = 0; bin < data.GetLength(0); bin++)
                        {
                            // Beam 0
                            if (numBeams > 0)
                            {
                                float b0 = data[bin, DataSet.Ensemble.BEAM_0_INDEX];
                                if (b0 != DataSet.Ensemble.BAD_VELOCITY)
                                {
                                    avgAccum[bin, DataSet.Ensemble.BEAM_0_INDEX] += b0;
                                    avgCount[bin, DataSet.Ensemble.BEAM_0_INDEX]++;
                                }
                            }

                            // Beam 1
                            if (numBeams > 1)
                            {
                                float b1 = data[bin, DataSet.Ensemble.BEAM_1_INDEX];
                                if (b1 != DataSet.Ensemble.BAD_VELOCITY)
                                {
                                    avgAccum[bin, DataSet.Ensemble.BEAM_1_INDEX] += b1;
                                    avgCount[bin, DataSet.Ensemble.BEAM_1_INDEX]++;
                                }
                            }

                            // Beam 2
                            if (numBeams > 2)
                            {
                                float b2 = data[bin, DataSet.Ensemble.BEAM_2_INDEX];
                                if (b2 != DataSet.Ensemble.BAD_VELOCITY)
                                {
                                    avgAccum[bin, DataSet.Ensemble.BEAM_2_INDEX] += b2;
                                    avgCount[bin, DataSet.Ensemble.BEAM_2_INDEX]++;
                                }
                            }

                            // Beam 3
                            if (numBeams > 3)
                            {
                                float b3 = data[bin, DataSet.Ensemble.BEAM_3_INDEX];
                                if (b3 != DataSet.Ensemble.BAD_VELOCITY)
                                {
                                    avgAccum[bin, DataSet.Ensemble.BEAM_3_INDEX] += b3;
                                    avgCount[bin, DataSet.Ensemble.BEAM_3_INDEX]++;
                                }
                            }
                        }
                    }

                    // Set the accumulated data
                    result.AvgAccum = avgAccum;
                    result.AvgCount = avgCount;
                }

                return result;
            }
示例#4
0
            /// <summary>
            /// Average all the given accumulated data.  This will then multiple a
            /// scale value to the averaged data.
            /// </summary>
            /// <param name="accumData">Accumulated values.</param>
            /// <param name="scale">Scale value to multiply to averaged value.</param>
            /// <returns>Array with the averaged and scaled value.</returns>
            protected float[,] AverageData(AccumulatedData accumData, float scale)
            {
                // Create an array, if no data is accumulated, null will be retruned
                float[,] result = null;

                if (accumData.AvgAccum != null && accumData.AvgCount != null)
                {
                    // Create the results array based off the accumulated values
                    result = new float[accumData.AvgAccum.GetLength(0), accumData.AvgAccum.GetLength(1)];

                    // Set Min and Max bin
                    int minBin   = 0;
                    int maxBin   = accumData.AvgAccum.GetLength(0);
                    int numBeams = accumData.AvgCount.GetLength(1);

                    // Average all the accumulated data
                    for (int bin = minBin; bin < maxBin; bin++)
                    {
                        // Check if it has at least 1 beams
                        if (numBeams > 0)
                        {
                            // Calculate the average values
                            float B0 = 0.0f;
                            if (accumData.AvgCount[bin, DataSet.Ensemble.BEAM_0_INDEX] > 0)
                            {
                                B0 = accumData.AvgAccum[bin, DataSet.Ensemble.BEAM_0_INDEX] / accumData.AvgCount[bin, DataSet.Ensemble.BEAM_0_INDEX];       // Beam 0 Average
                                // Set results
                                B0 *= scale;
                                result[bin, DataSet.Ensemble.BEAM_0_INDEX] = B0;
                            }
                            else
                            {
                                result[bin, DataSet.Ensemble.BEAM_0_INDEX] = DataSet.Ensemble.BAD_VELOCITY;
                            }
                        }

                        // Check if it has at least 2 beams
                        if (numBeams > 1)
                        {
                            float B1 = 0.0f;
                            if (accumData.AvgCount[bin, DataSet.Ensemble.BEAM_1_INDEX] > 0)
                            {
                                B1 = accumData.AvgAccum[bin, DataSet.Ensemble.BEAM_1_INDEX] / accumData.AvgCount[bin, DataSet.Ensemble.BEAM_1_INDEX];       // Beam 1 Average

                                // Set Results
                                B1 *= scale;
                                result[bin, DataSet.Ensemble.BEAM_1_INDEX] = B1;
                            }
                            else
                            {
                                result[bin, DataSet.Ensemble.BEAM_1_INDEX] = DataSet.Ensemble.BAD_VELOCITY;
                            }
                        }

                        // Check if it has a least 3 beams
                        if (numBeams > 2)
                        {
                            float B2 = 0.0f;
                            if (accumData.AvgCount[bin, DataSet.Ensemble.BEAM_2_INDEX] > 0)
                            {
                                B2 = accumData.AvgAccum[bin, DataSet.Ensemble.BEAM_2_INDEX] / accumData.AvgCount[bin, DataSet.Ensemble.BEAM_2_INDEX];       // Beam 2 Average

                                // Set Results
                                B2 *= scale;
                                result[bin, DataSet.Ensemble.BEAM_2_INDEX] = B2;
                            }
                            else
                            {
                                result[bin, DataSet.Ensemble.BEAM_2_INDEX] = DataSet.Ensemble.BAD_VELOCITY;
                            }
                        }

                        // Check if it has a least 4 beams
                        if (numBeams > 3)
                        {
                            float B3 = 0.0f;
                            if (accumData.AvgCount[bin, DataSet.Ensemble.BEAM_3_INDEX] > 0)
                            {
                                B3 = accumData.AvgAccum[bin, DataSet.Ensemble.BEAM_3_INDEX] / accumData.AvgCount[bin, DataSet.Ensemble.BEAM_3_INDEX];       // Beam 3 Average

                                // Set Result
                                B3 *= scale;
                                result[bin, DataSet.Ensemble.BEAM_3_INDEX] = B3;
                            }
                            else
                            {
                                result[bin, DataSet.Ensemble.BEAM_3_INDEX] = DataSet.Ensemble.BAD_VELOCITY;
                            }
                        }
                    }
                }

                return(result);
            }
示例#5
0
            /// <summary>
            /// This will accumulate all the data.  THis will go through each
            /// accumulated data and accumulate the values.  It will check for
            /// bad values before accumulating.  If the value is bad, it will
            /// not be included in the accumulated data.  This will keep track
            /// of the accumulated data and the number of data points for each bin.
            /// The results will then be stored to a struct and returned.
            /// </summary>
            /// <returns>Struct containing the accumulated data.</returns>
            protected AccumulatedData AccumulateData()
            {
                AccumulatedData result = new AccumulatedData();

                if (_accumData.Count > 0)
                {
                    // Get the number of bins and beams
                    // These values should be the same for all the accumulated data
                    float[,] firstData = _accumData.First();
                    int numBins  = firstData.GetLength(0);
                    int numBeams = firstData.GetLength(1);

                    // Create arrays to accumulate the data
                    float[,] avgAccum = new float[numBins, numBeams];
                    int[,] avgCount   = new int[numBins, numBeams];

                    // Accumulate the data for each accumulate array
                    for (int x = 0; x < _accumData.Count; x++)
                    {
                        // Get the data from the list
                        float[,] data = _accumData[x];

                        // Accumulate the values
                        for (int bin = 0; bin < data.GetLength(0); bin++)
                        {
                            // Beam 0
                            if (numBeams > 0)
                            {
                                float b0 = data[bin, DataSet.Ensemble.BEAM_0_INDEX];
                                if (b0 != DataSet.Ensemble.BAD_VELOCITY)
                                {
                                    avgAccum[bin, DataSet.Ensemble.BEAM_0_INDEX] += b0;
                                    avgCount[bin, DataSet.Ensemble.BEAM_0_INDEX]++;
                                }
                            }

                            // Beam 1
                            if (numBeams > 1)
                            {
                                float b1 = data[bin, DataSet.Ensemble.BEAM_1_INDEX];
                                if (b1 != DataSet.Ensemble.BAD_VELOCITY)
                                {
                                    avgAccum[bin, DataSet.Ensemble.BEAM_1_INDEX] += b1;
                                    avgCount[bin, DataSet.Ensemble.BEAM_1_INDEX]++;
                                }
                            }

                            // Beam 2
                            if (numBeams > 2)
                            {
                                float b2 = data[bin, DataSet.Ensemble.BEAM_2_INDEX];
                                if (b2 != DataSet.Ensemble.BAD_VELOCITY)
                                {
                                    avgAccum[bin, DataSet.Ensemble.BEAM_2_INDEX] += b2;
                                    avgCount[bin, DataSet.Ensemble.BEAM_2_INDEX]++;
                                }
                            }

                            // Beam 3
                            if (numBeams > 3)
                            {
                                float b3 = data[bin, DataSet.Ensemble.BEAM_3_INDEX];
                                if (b3 != DataSet.Ensemble.BAD_VELOCITY)
                                {
                                    avgAccum[bin, DataSet.Ensemble.BEAM_3_INDEX] += b3;
                                    avgCount[bin, DataSet.Ensemble.BEAM_3_INDEX]++;
                                }
                            }
                        }
                    }

                    // Set the accumulated data
                    result.AvgAccum = avgAccum;
                    result.AvgCount = avgCount;
                }

                return(result);
            }