コード例 #1
0
ファイル: DFS3Test.cs プロジェクト: msruzy/hydronumerics
        public void CreateFile()
        {
            DFS3 df = new DFS3("test.dfs3", 1);

            df.NumberOfColumns     = 5;
            df.NumberOfRows        = 7;
            df.NumberOfLayers      = 3;
            df.XOrigin             = 9000;
            df.YOrigin             = 6000;
            df.Orientation         = 1;
            df.GridSize            = 15;
            df.TimeOfFirstTimestep = DateTime.Now;
            df.TimeStep            = TimeSpan.FromHours(2);

            df.FirstItem.Name    = "SGS Kriged dyn. corr.precip";
            df.FirstItem.EumItem = eumItem.eumIPrecipitationRate;
            df.FirstItem.EumUnit = eumUnit.eumUmillimeterPerDay;


            Matrix3d m3 = new Matrix3d(df.NumberOfRows, df.NumberOfColumns, df.NumberOfLayers);

            m3[0] = new DenseMatrix(df.NumberOfRows, df.NumberOfColumns);
            m3[1] = new DenseMatrix(df.NumberOfRows, df.NumberOfColumns, 3);
            m3[2] = new DenseMatrix(df.NumberOfRows, df.NumberOfColumns, 2);

            m3[3, 4, 0] = 25;


            df.SetData(0, 1, m3);
            m3[3, 4, 0] = 24;
            m3[3, 4, 1] = 100;
            m3[3, 4, 2] = 110;
            df.SetData(1, 1, m3);
            df.Dispose();

            df = new DFS3("test.dfs3");

            Assert.AreEqual(eumItem.eumIPrecipitationRate, df.FirstItem.EumItem);

            Matrix m2 = df.GetData(0, 1)[0];

            Assert.AreEqual(25, m2[3, 4]);
        }
コード例 #2
0
ファイル: UnitTest1.cs プロジェクト: msruzy/hydronumerics
        public void TestMethod1()
        {
            DFS3 df = new DFS3(@"C:\Users\Jacob\Documents\MIKE Zero Projects\SHEPar1.she - Result Files\SHEPar1_3DSZflow.dfs3");

            for (int i = 0; i < 30; i++)
            {
                var mat = df.GetData(i, 1);
                mat[0][1, 1] = -0.5;
                mat[1][1, 1] = -0.5;

                df.SetData(i, 1, mat);
            }
            df.Dispose();
        }
コード例 #3
0
ファイル: DFS3Test.cs プロジェクト: msruzy/hydronumerics
        public void SetDataTest()
        {
            Matrix3d M = _dfs.GetData(0, 1);

            M[90, 130, 1] = 100000;
            _dfsWrite.SetData(0, 1, M);

            //Check that buffer is updated
            Assert.AreEqual(_dfsWrite.GetData(0, 1)[90, 130, 1], 100000);

            //Note that here is a potential pitfall. Because of the reference and the buffering it will appear as if the data also
            //changes in _dfs
            Assert.AreEqual(_dfs.GetData(0, 1)[90, 130, 1], 100000);
        }
コード例 #4
0
ファイル: GridFunctions.cs プロジェクト: msruzy/hydronumerics
        public static void InsertPointValues(XElement OperationData)
        {
            string filename = OperationData.Element("DFSFileName").Value;

            int  Item        = OperationData.Element("Item") == null ? 1 : int.Parse(OperationData.Element("Item").Value);
            bool ClearValues = OperationData.Element("ClearValues") == null ? true: bool.Parse(OperationData.Element("ClearValues").Value);

            List <Tuple <double, double, int, int, double> > points = new List <Tuple <double, double, int, int, double> >();

            foreach (var p in OperationData.Element("Points").Elements())
            {
                Tuple <double, double, int, int, double> point = new Tuple <double, double, int, int, double>(
                    p.Element("X") == null ? -1 : double.Parse(p.Element("X").Value),
                    p.Element("Y") == null ? -1 : double.Parse(p.Element("Y").Value),
                    p.Element("Z") == null ? 0 : int.Parse(p.Element("Z").Value),
                    p.Element("TimeStep") == null ? 0 : int.Parse(p.Element("TimeStep").Value),
                    double.Parse(p.Element("Value").Value));
                points.Add(point);
            }

            if (Path.GetExtension(filename).EndsWith("0"))
            {
                using (DFS0 dfs = new DFS0(filename))
                {
                    if (ClearValues)
                    {
                        for (int i = 0; i < dfs.NumberOfTimeSteps; i++)
                        {
                            dfs.SetData(i, Item, 0);
                        }
                    }
                    foreach (var p in points)
                    {
                        dfs.SetData(p.Item4, Item, p.Item5);
                    }
                }
            }
            else if (Path.GetExtension(filename).EndsWith("2"))
            {
                using (DFS2 dfs = new DFS2(filename))
                {
                    if (ClearValues)
                    {
                        for (int i = 0; i < dfs.NumberOfTimeSteps; i++)
                        {
                            dfs.SetData(i, Item, new DenseMatrix(dfs.NumberOfRows, dfs.NumberOfColumns));
                        }
                    }
                    foreach (var p in points)
                    {
                        var data   = dfs.GetData(p.Item4, Item);
                        int column = dfs.GetColumnIndex(p.Item1);
                        int row    = dfs.GetRowIndex(p.Item2);

                        if (column >= 0 & row >= 0)
                        {
                            data[row, column] = p.Item5;
                        }

                        dfs.SetData(p.Item4, Item, data);
                    }
                }
            }
            else if (Path.GetExtension(filename).EndsWith("3"))
            {
                using (DFS3 dfs = new DFS3(filename))
                {
                    if (ClearValues)
                    {
                        for (int i = 0; i < dfs.NumberOfTimeSteps; i++)
                        {
                            dfs.SetData(i, Item, new Matrix3d(dfs.NumberOfRows, dfs.NumberOfColumns, dfs.NumberOfLayers));
                        }
                    }
                    foreach (var p in points)
                    {
                        var data   = dfs.GetData(p.Item4, Item);
                        int column = dfs.GetColumnIndex(p.Item1);
                        int row    = dfs.GetRowIndex(p.Item2);

                        if (column >= 0 & row >= 0)
                        {
                            data[row, column, p.Item3] = p.Item5;
                        }

                        dfs.SetData(p.Item4, Item, data);
                    }
                }
            }
        }