示例#1
0
        public void AddDefaults()
        {
            Grid1D Ox = new Grid1D(10, 3);
            Grid1D Oy = new Grid1D(10, 3);

            v2Datas = new List <V2Data>();
            V2DataOnGrid[]     grid        = new V2DataOnGrid[4];
            V2DataCollection[] collections = new V2DataCollection[4];

            for (int i = 0; i < 3; i++)
            {
                grid[i]        = new V2DataOnGrid("data info2" /*+ i.ToString()*/, 2, Ox, Oy); // test i = 2
                collections[i] = new V2DataCollection("collection info" + i.ToString(), i);
            }

            for (int i = 0; i < 3; i++)
            {
                grid[i].initRandom(0, 100);
                collections[i].initRandom(4, 100, 100, 0, 100);
                this.Add(grid[i]);
                this.Add(collections[i]);
            }

            Grid1D nullOx = new Grid1D(0, 0);
            Grid1D nullOy = new Grid1D(0, 0);

            grid[3]        = new V2DataOnGrid("null", 100, nullOx, nullOy);
            collections[3] = new V2DataCollection("null", 100);

            grid[3].initRandom(0, 100);
            collections[3].initRandom(0, 100, 100, 0, 100);
            this.Add(grid[3]);
            this.Add(collections[3]);
        }
示例#2
0
        public V3DataOnGrid(string info, DateTime time, Grid1D xgrid, Grid1D ygrid) : base(info, time)
        {
            XGrid = xgrid;
            YGrid = ygrid;

            Value = new double[xgrid.NSteps, ygrid.NSteps];
        }
示例#3
0
        public void AddDefaults()
        {
            Grid1D Ox = new Grid1D(1, 3);
            Grid1D Oy = new Grid1D(1, 3);

            v2Datas = new List <V2Data>();
            V2DataOnGrid[]     mag         = new V2DataOnGrid[4];
            V2DataCollection[] collections = new V2DataCollection[4];
            for (int i = 0; i < 4; i++)
            {
                //mag[i] = new V2DataOnGrid("Data", 123, Ox, Oy);
                //collections[i] = new V2DataCollection("Data", 123);
                mag[i]         = new V2DataOnGrid("Data " + i.ToString(), i, Ox, Oy);
                collections[i] = new V2DataCollection("Collection number: " + i.ToString(), i);
            }
            for (int i = 0; i < 4; i++)
            {
                mag[i].initRandom(0, 10);
                collections[i].initRandom(4, 10, 10, 0, 100);
                this.Add(mag[i]);
                this.Add(collections[i]);
            }

            Grid1D NULLOX = new Grid1D(0, 0);
            Grid1D NULLOY = new Grid1D(0, 0);

            mag[3]         = new V2DataOnGrid("NULL", 10, NULLOX, NULLOY);
            collections[3] = new V2DataCollection("NULL", 10);

            mag[3].initRandom(0, 10);
            collections[3].initRandom(0, 10, 10, 0, 10);
            this.Add(mag[3]);
            this.Add(collections[3]);
        }
示例#4
0
 public V2DataOnGrid(string info, double freq, Grid1D ox, Grid1D oy) : base(info, freq)
 {
     Info  = info;
     Freq  = freq;
     Grids = new Grid1D[2] {
         ox, oy
     };
 }
示例#5
0
        public void AddDefaultDataOnGrid()
        {
            Grid1D       Ox   = new Grid1D(10, 3);
            Grid1D       Oy   = new Grid1D(10, 3);
            V2DataOnGrid grid = new V2DataOnGrid("data info ", 2, Ox, Oy);

            grid.initRandom(0, 100);
            this.Add(grid);
        }
示例#6
0
        public void AddTest()
        {
            Grid1D Ox = new Grid1D(10, 3);
            Grid1D Oy = new Grid1D(10, 3);

            //v2Datas = new List<V2Data>();
            V2DataOnGrid[]     grid        = new V2DataOnGrid[4];
            V2DataCollection[] collections = new V2DataCollection[4];


            for (int i = 0; i < 3; i++)
            {
                grid[i]        = new V2DataOnGrid("TEST", 2, Ox, Oy);
                collections[i] = new V2DataCollection("sklnskvjzdfbjnsk" + i.ToString(), i);
            }

            for (int i = 0; i < 3; i++)
            {
                grid[i].initRandom(0, 100);
                collections[i].initTest(4, 100, 100, 0, 100);
                this.Add(grid[i]);
                this.Add(collections[i]);
            }
        }
示例#7
0
        public V3DataOnGrid(string filename) : base("", new DateTime())
        {
            // .: FORMAT :.
            // {string   Info}\n
            // {DateTime Time}\n
            // {float StepX}\n
            // {int NStepsX}\n
            // {float StepY}\n
            // {int NStepsY}\n
            // {double Value[0, 0]}\n
            // {double Value[0, 1]}\n
            // ...
            // {double Value[0, NStepsY]}\n
            // {double Value[1, 0]}\n
            // ...
            // {double Value[NStepsX, NStepsY]}\n

            FileStream  fs          = null;
            CultureInfo cultureInfo = new CultureInfo("ru-RU");

            cultureInfo.NumberFormat.NumberDecimalSeparator = ",";
            try
            {
                fs = new FileStream(filename, FileMode.Open);
                StreamReader sr = new StreamReader(fs);
                // base class
                Info = sr.ReadLine();
                Time = Convert.ToDateTime(sr.ReadLine(), cultureInfo);

                float Step;
                int   NSteps;
                // XGrid
                Step   = (float)Convert.ToDouble(sr.ReadLine(), cultureInfo);
                NSteps = Convert.ToInt32(sr.ReadLine(), cultureInfo);
                XGrid  = new Grid1D(Step, NSteps);
                // YGrid
                Step   = (float)Convert.ToDouble(sr.ReadLine(), cultureInfo);
                NSteps = Convert.ToInt32(sr.ReadLine(), cultureInfo);
                YGrid  = new Grid1D(Step, NSteps);

                // Value[,]
                Value = new double[XGrid.NSteps, YGrid.NSteps];
                for (int i = 0; i < XGrid.NSteps; ++i)
                {
                    for (int j = 0; j < YGrid.NSteps; ++j)
                    {
                        Value[i, j] = Convert.ToDouble(sr.ReadLine(), cultureInfo);
                    }
                }

                sr.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                throw ex;
            }
            finally
            {
                if (fs != null)
                {
                    fs.Close();
                }
            }
        }
示例#8
0
        public V2DataOnGrid(string filename) : base()
        {
            CultureInfo CI   = new CultureInfo(System.Threading.Thread.CurrentThread.CurrentCulture.Name);
            CultureInfo CIen = new CultureInfo("en-US");
            CultureInfo CIru = new CultureInfo("ru-RU");
            CultureInfo CIzh = new CultureInfo("zh-CN");

            if ((CI == CIru) || (CI == CIzh))
            {
                if (CI == CIru)
                {
                    CI = CIru;
                }
                else
                {
                    CI = CIzh;
                }
            }
            else
            {
                CI = CIen;
            }

            FileStream f = null;

            try
            {
                Directory.SetCurrentDirectory("..\\..\\..\\");
                f = new FileStream(filename, FileMode.Open);
                StreamReader reader = new StreamReader(f);

                Info = reader.ReadLine();                   //Info
                Freq = double.Parse(reader.ReadLine(), CI); //Freq
                string[] str;
                Grids = new Grid1D[2];

                for (int i = 0; i < 2; i++)
                {
                    str            = reader.ReadLine().Split(' ');//Count and Step
                    Grids[i].Count = int.Parse(str[0], CI);
                    Grids[i].Step  = float.Parse(str[1], CI);
                }

                Node = new Complex[Grids[0].Count, Grids[1].Count];
                string[] strnode;
                string[] strcompl;

                for (int i = 0; i < Grids[0].Count; i++)//Matrix
                {
                    strnode = reader.ReadLine().Split(' ');
                    for (int j = 0; j < Grids[1].Count; j++)
                    {
                        strcompl   = strnode[j].Split('|');
                        Node[i, j] = new Complex(double.Parse(strcompl[0], CI), double.Parse(strcompl[1], CI));
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                if (f != null)
                {
                    f.Close();
                }
            }
        }
示例#9
0
        public V2DataOnGrid(string filename) : base()
        {
            /* ФОРМАТ ВХОДНОГО ФАЙЛА
             * 1 строка - Info      - информация о таблице
             * 2 строка - Freq      - значение частоты
             * 3 строка - Grid1D Ox - значения Num и Step через пробел
             * 4 строка - Grid1D Oy - значения Num и Step через пробел
             *
             * 5 строка и дальше - таблица
             * Узел таблицы разделяется пробелом
             * Поля комлексного числа (действительная и мнимая части) нижним подчеркиванием
             *
             */

            /********* Пример входного файла *********/

            /*
             * Information
             * 100
             * 3 10
             * 5 10
             * 12,0_5,23 11,67_7,78 7,16_4,00 8,34_-7,55 1,09_1,09
             * 2,44_-5,43 16,11_7,90 -2,33_4,55 8,76_-7,10 1,01_-1,40
             * 1,67_5,29 1,10_7,36 7,18_-44,44 4,89_-1,10 1,09_1,34
             *
             */
            CultureInfo CIru = new CultureInfo("RU-ru");        // исправлена локализация

            FileStream fs = null;

            try
            {
                //Directory.SetCurrentDirectory()
                Directory.SetCurrentDirectory("..\\..\\..\\");  // путь к исходным файлам проекта
                fs = new FileStream(filename, FileMode.Open);
                StreamReader reader = new StreamReader(fs);

                Info = reader.ReadLine();
                Freq = double.Parse(reader.ReadLine(), CIru);
                string[] str;
                Grids = new Grid1D[2];

                for (int i = 0; i < 2; i++)
                {
                    str           = reader.ReadLine().Split(' ');
                    Grids[i].Num  = int.Parse(str[0], CIru);
                    Grids[i].Step = float.Parse(str[1], CIru);
                }

                Node = new Complex[Grids[0].Num, Grids[1].Num];
                string[] strnode;
                string[] strcompl;

                for (int i = 0; i < Grids[0].Num; i++)
                {
                    strnode = reader.ReadLine().Split(' ');
                    for (int j = 0; j < Grids[1].Num; j++)
                    {
                        strcompl   = strnode[j].Split('_');             // исправлен разделитель
                        Node[i, j] = new Complex(double.Parse(strcompl[0], CIru), double.Parse(strcompl[1], CIru));
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                if (fs != null)
                {
                    fs.Close();
                }
                if (Grids == null)
                {
                    Exception ex = new Exception("Cannot add grid from file");
                    //const string V = "Add grids from file";
                    throw ex;
                }
            }
        }