Exemple #1
0
        public List <XYZ> GetAccelerationXYZFromCSV()
        {
            List <XYZ> listToReturn = new List <XYZ>();

            AllDataEntries.ToList().ForEach(x => listToReturn.Add(
                                                new XYZ(x.INS_Accelerometer.X, x.INS_Accelerometer.Y, x.INS_Accelerometer.Z, x.INS_Accelerometer.TimeOfData)
                                                ));
            return(listToReturn);
        }
Exemple #2
0
        public ConcurrentQueue <Tuple <DataEntry, double, double> > CalculateVariance(int periodLength = 50)
        {
            List <DataEntry> data = AllDataEntries.ToList();
            ConcurrentQueue <Tuple <DataEntry, double, double> > output = new ConcurrentQueue <Tuple <DataEntry, double, double> >();
            List <DataEntry> batch = new List <DataEntry>();
            double           tendencySlope;
            double           tendencyOffset;
            double           residualSS;

            int periodCount = data.Count() - periodLength;

            for (int i = 0; i < periodCount; i++)
            {
                batch          = data.GetRange(i, periodLength);
                tendencySlope  = CalculateTendencySlope(batch);
                tendencySlope  = Math.Pow(tendencySlope, 3);
                tendencyOffset = CalculateTendensyOffset(batch, tendencySlope);
                residualSS     = CalculateResidualSumOfSquares(batch, tendencySlope, tendencyOffset);
                output.Enqueue(new Tuple <DataEntry, double, double>(data[i + periodLength / 2], residualSS, tendencySlope));
            }

            return(output);

            /*List<DataEntry> data = AllDataEntries.ToList();
             * ConcurrentQueue<Tuple<DataEntry, double>> output = new ConcurrentQueue<Tuple<DataEntry, double>>();
             * double maxEntry;
             * double minEntry;
             * double variance;
             * double squareVariance;
             *
             * int periodCount = data.Count() / periodLength;
             * for (int i = 0; i < periodCount; i++)
             * {
             *  maxEntry = data.GetRange(i * periodLength, periodLength).Max(x => x.INS_Accelerometer.X);
             *  minEntry = data.GetRange(i * periodLength, periodLength).Min(x => x.INS_Accelerometer.X);
             *  variance = maxEntry - minEntry;
             *  squareVariance = Math.Pow(variance, 2);
             *
             *  for (int j = i * periodLength; j < (i + 1) * periodLength; j++)
             *  {
             *      output.Enqueue(new Tuple<DataEntry, double>(data[j], variance));
             *  }
             * }
             * return output;*/
        }
Exemple #3
0
        //Calculates variance, velocity, slope and slope difference
        public ConcurrentQueue <Tuple <DataEntry, double, double, double, double> > CalculateAcceleration(int batchSize = 200)
        {
            List <DataEntry> data = AllDataEntries.ToList();
            ConcurrentQueue <Tuple <DataEntry, double, double, double, double> > output = new ConcurrentQueue <Tuple <DataEntry, double, double, double, double> >();
            List <DataEntry> accelerationList = new List <DataEntry>();

            accelerationList.Add(new DataEntry(new XYZ(0.0, 0.0, 0.0), new XYZ(0.0, 0.0, 0.0), new XYZ(0.0, 0.0, 0.0), 0.0));

            foreach (DataEntry entry in data)
            {
                double    value = (entry.INS_Accelerometer.X / 1000.0) * _gravitationalConst;
                double    time  = entry.INS_Accelerometer.TimeOfData / 1000.0;
                DataEntry pos   = new DataEntry(new XYZ(0.0, 0.0, 0.0), new XYZ(value, 0.0, 0.0, time), new XYZ(0.0, 0.0, 0.0), 0);

                accelerationList.Add(pos);
            }

            List <DataEntry> velocityList = CalculateVelocity(accelerationList);

            for (int i = batchSize; i < velocityList.Count - batchSize; i++)
            {
                List <DataEntry> firstBatchList  = velocityList.GetRange(i - batchSize, batchSize).ToList();
                List <DataEntry> secondBatchList = velocityList.GetRange(i - 1, batchSize).ToList();
                double           thresFirst      = CalculateTendencySlope(firstBatchList);
                double           thresSecond     = CalculateTendencySlope(secondBatchList);


                var    batch          = data.GetRange(i - batchSize / 2, batchSize).ToList();
                double tendencySlope  = CalculateTendencySlope(batch);
                double tendencyOffset = CalculateTendensyOffset(batch, tendencySlope);
                double residualSS     = CalculateResidualSumOfSquares(batch, tendencySlope, tendencyOffset);

                output.Enqueue(new Tuple <DataEntry, double, double, double, double>(data[i], velocityList[i].INS_Accelerometer.X, tendencySlope, tendencySlope / (Math.Pow(residualSS, 2)), Math.Abs(thresFirst - thresSecond)));
            }
            return(output);
        }