Ejemplo n.º 1
0
        private static void getSkolz(double rang, int steps)
        {
            int           sizeLocal = 5;
            List <double> timeArr   = new List <double>();
            List <double> azimutArr = new List <double>();
            double        targetTimeStart;

            int temp = 0;

            for (int i = 0; i < range.Count; i++)
            {
                if (range[i].getMeasure() == rang)
                {
                    targetTimeStart = range[i].getMeasure();

                    temp = getNearest(radioAzimut, range[i].getTime());
                    for (int j = 0; j < sizeLocal; j++)
                    {
                        timeArr.Add(radioAzimut[temp].getTime());
                        azimutArr.Add(radioAzimut[temp].getMeasure());

                        temp++;
                        if (azimutArr[j] > 6)
                        {
                            azimutArr[j] = azimutArr[j] - (360 * Math.PI / 180);
                        }
                    }
                }
            }

            for (int i = 0; i < steps; i++)
            {
                MNK      mnkLocalAzimut    = new MNK(timeArr.ToArray(), azimutArr.ToArray(), sizeLocal);
                double[] answerLocalAzimut = mnkLocalAzimut.Calculate();

                Console.WriteLine("{0:E}\t{1:E}", answerLocalAzimut[1], answerLocalAzimut[0]);
                timeArr.RemoveAt(0);
                timeArr.Add(radioAzimut[temp].getTime());

                azimutArr.RemoveAt(0);
                azimutArr.Add(radioAzimut[temp].getMeasure());

                temp++;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Собирает и выводит статистику по заданному расстоянию
        /// </summary>
        /// <param name="rang">Целевое расстояние</param>
        ///
        static void CalculateByRange(double rang)
        {
            Console.WriteLine("Расстояние = " + rang);
            int sizeLocal = 5;

            double[] targetAzimutLocal        = new double[sizeLocal];
            double[] targetUgolMestaLocal     = new double[sizeLocal];
            double[] targetTimeAzimutLocal    = new double[sizeLocal];
            double[] targetTimeUgolMestaLocal = new double[sizeLocal];

            double targetTimeStart = 0;
            double targetTimeEnd   = 0;

            for (int i = 0; i < range.Count; i++)
            {
                if (range[i].getMeasure() == rang)
                {
                    targetTimeStart = range[i].getTime();
                    if (range.Count - 1 - i <= sizeLocal)
                    {
                        sizeLocal             = range.Count - i - 1;
                        targetAzimutLocal     = new double[sizeLocal];
                        targetUgolMestaLocal  = new double[sizeLocal];
                        targetTimeAzimutLocal = new double[sizeLocal];
                    }

                    //int tempI = i;
                    int temp = getNearest(radioAzimut, range[i].getTime());
                    for (int j = 0; j < sizeLocal; j++)
                    {
                        targetTimeAzimutLocal[j] = radioAzimut[temp].getTime() - targetTimeStart;
                        targetAzimutLocal[j]     = radioAzimut[temp].getMeasure();
                        temp++;

                        if (targetAzimutLocal[j] > 6)
                        {
                            targetAzimutLocal[j] = targetAzimutLocal[j] - (360 * Math.PI / 180);
                        }
                    }

                    targetTimeEnd = Math.Round(Math.Max(targetTimeEnd, targetTimeAzimutLocal[sizeLocal - 1] + targetTimeStart), 2);


                    temp = getNearest(radioUgolMesta, range[i].getTime());

                    //Если temp = 0 => не нашлись измерения в диапазоне < minTime секунд
                    if (temp == 0)
                    {
                        Console.WriteLine("ИЗМЕРЕНИЯ УГЛА МЕСТА ОТСУТСТВУЮТ");
                    }
                    //
                    for (int j = 0; j < sizeLocal; j++)
                    {
                        targetTimeUgolMestaLocal[j] = radioUgolMesta[temp].getTime() - targetTimeStart;
                        targetUgolMestaLocal[j]     = radioUgolMesta[temp].getMeasure();
                        temp++;
                    }

                    targetTimeEnd = Math.Round(Math.Max(targetTimeEnd, targetTimeUgolMestaLocal[sizeLocal - 1] + targetTimeStart), 2);


                    break;
                }
            }

            int sizeOptic  = 100;
            int indexStart = 0;
            int indexEnd   = 0;

            indexStart = getNearest(opticAzimut, targetTimeStart);
            indexEnd   = getNearest(opticAzimut, targetTimeEnd);
            sizeOptic  = indexEnd - indexStart + 1;


            Console.WriteLine("Start {0}, End {1}", indexStart, indexEnd);

            double[] targetAzimutOptic    = new double[sizeOptic];
            double[] targetUgolMestaOptic = new double[sizeOptic];
            double[] targetTimeOptic      = new double[sizeOptic];

            for (int i = indexStart, j = 0; i < indexEnd; i++, j++)
            {
                targetAzimutOptic[j]    = opticAzimut[i].getMeasure();
                targetUgolMestaOptic[j] = opticUgolMesta[i].getMeasure();
                targetTimeOptic[j]      = opticAzimut[i].getTime() - targetTimeStart;

                if (targetAzimutOptic[j] > 6)
                {
                    targetAzimutOptic[j] = targetAzimutOptic[j] - (360 * Math.PI / 180);
                }
            }

            MNK mnkLocalAzimut = new MNK(targetTimeAzimutLocal, targetAzimutLocal, sizeLocal);

            double[] answerLocalAzimut = mnkLocalAzimut.Calculate();

            MNK mnkLocalUgolMesta = new MNK(targetTimeUgolMestaLocal, targetUgolMestaLocal, sizeLocal);

            double[] answerLocalUgolMesta = mnkLocalUgolMesta.Calculate();

            Console.WriteLine("Radio");
            for (int i = 1; i >= 0; i--)
            {
                Console.WriteLine(answerLocalAzimut[i] + "\t" + answerLocalUgolMesta[i]);
            }

            MNK mnkOpticAzimut = new MNK(targetTimeOptic, targetAzimutOptic, sizeOptic);

            double[] answerOpticAzimut = mnkOpticAzimut.Calculate();

            MNK mnkOpticUgolMesta = new MNK(targetTimeOptic, targetUgolMestaOptic, sizeOptic);

            double[] answerOpticUgolMesta = mnkOpticUgolMesta.Calculate();

            Console.WriteLine("//////////////////////////////////////////////\n");
            for (int i = 0; i < targetAzimutLocal.Length; i++)
            {
                Console.WriteLine(targetAzimutLocal[i]);
            }
            Console.WriteLine("\n///////////////////////////////////////////////");

            Console.WriteLine("DELTA");


            double[] statisticAzimut    = getStatistic(answerLocalAzimut, targetAzimutOptic, targetTimeOptic, sizeOptic);
            double[] statisticUgolMesta = getStatistic(answerLocalUgolMesta, targetUgolMestaOptic, targetTimeOptic, sizeOptic);

            Console.WriteLine("Мат. ожидание\t{0}\t{1}", statisticAzimut[0], statisticUgolMesta[0]);
            Console.WriteLine("Отклонение\t{0}\t{1}", statisticAzimut[1], statisticUgolMesta[1]);

            Console.WriteLine("\n///////////////////////////////////////////////\n");

            //ProcessStartInfo start = new ProcessStartInfo();
            //start.FileName = pythonScriptString;

            //int div = 2;
            //int step = 0;
            //int indexOld = 0;
            //while (step < div)
            //{
            //    double[] targetTimeOpticDiv2 = new double[targetTimeOptic.Length / div];
            //    double[] targetAzimutOpticDiv2 = new double[targetAzimutOptic.Length / div];
            //    for (int j = 0; j < targetTimeOpticDiv2.Length; j++)
            //    {
            //        targetTimeOpticDiv2[j] = targetTimeOptic[indexOld];
            //        targetAzimutOpticDiv2[j] = targetAzimutOptic[indexOld];
            //        indexOld++;
            //    }
            //    ShowGraph(answerLocalAzimut, targetTimeOpticDiv2, targetAzimutOpticDiv2);
            //    step++;
            //}
            ShowGraph(answerLocalAzimut, targetTimeOptic, targetAzimutOptic, targetTimeAzimutLocal, targetAzimutLocal);
            //Console.ReadKey();
        }