コード例 #1
0
    public void GetIndexTest()
    {
      Model mshe = new Model(@"..\..\..\TestData\TestModelDemo.she");

      int Column;
      int Row;

      Assert.IsTrue(mshe.GridInfo.GetIndex(11,11,out Column, out Row));
      Assert.AreEqual(1, Column);
      Assert.AreEqual(1, Row);

      Assert.IsTrue(mshe.GridInfo.GetIndex(19, 19, out Column, out Row));
      Assert.AreEqual(1, Column);
      Assert.AreEqual(1, Row);

      mshe.Dispose();

      DFS3 heads = new DFS3(@"..\..\..\TestData\TestModelDemo.she - Result Files\TestModelDemo_3DSZ.dfs3");

      Assert.AreEqual(1, heads.GetColumnIndex(11));

      Assert.AreEqual(2, heads.GetColumnIndex(19));

      heads.Dispose();
      

    }
コード例 #2
0
ファイル: Program.cs プロジェクト: shobaravi/mikeshewrapper
        static void Main(string[] args)
        {
            Dictionary<string, Accumulator> vals = new Dictionary<string, Accumulator>();

              Model m = new Model(args[0]);

              JupiterXL JXL = new JupiterXL(args[1]);
              JXL.ReadWells(true, false);
              JXL.ReadInLithology();

              foreach (var geo in JXL.LITHSAMP)
              {
            if (!geo.IsROCKSYMBOLNull() && !geo.IsBOTTOMNull() && !geo.IsTOPNull() && geo.ROCKSYMBOL.Trim() != "")
            {
              var Boring = JXL.BOREHOLE.FindByBOREHOLENO(geo.BOREHOLENO);

              if (Boring != null && !Boring.IsXUTMNull() && !Boring.IsYUTMNull())
              {
            int Column = m.GridInfo.GetColumnIndex(Boring.XUTM);
            int row = m.GridInfo.GetRowIndex(Boring.YUTM);
            if (row >= 0 & Column >= 0)
            {
              int Layer = m.GridInfo.GetLayer(Column, row, m.GridInfo.SurfaceTopography.Data[row, Column] - (geo.TOP + geo.BOTTOM) / 2);
              if (Layer >= 0)
              {
                Accumulator Ledningsevner;
                if (!vals.TryGetValue(geo.ROCKSYMBOL, out Ledningsevner))
                {
                  Ledningsevner = new Accumulator();
                  vals.Add(geo.ROCKSYMBOL, Ledningsevner);
                }
                Ledningsevner.Add(Math.Log10(m.Processed.HorizontalConductivity.Data[row, Column, Layer]));
              }

            }
              }
            }
              }//End of loop

              Accumulator all = new Accumulator();
              for (int lay = 0; lay < m.GridInfo.NumberOfLayers; lay++)
            for (int row = 0; row < m.GridInfo.NumberOfRows; row++)
              for (int col = 0; col < m.GridInfo.NumberOfColumns; col++)
            if (m.GridInfo.ModelDomainAndGrid.Data[row, col] == 1)
              all.Add(Math.Log10(m.Processed.HorizontalConductivity.Data[row, col, lay]));

              vals.Add("All", all);

              using (StreamWriter sw = new StreamWriter(@"F:\temp\out.txt", false, Encoding.Default))
              {
            sw.WriteLine("Rocksymbol\tNoOfEntries\tMean\tVariance\tStandard Deviation");
            foreach (KeyValuePair<string, Accumulator> KVP in vals.OrderByDescending((acc) => acc.Value.Count))
            {
              sw.WriteLine(KVP.Key + "\t" + KVP.Value.Count + "\t" + KVP.Value.Mean + "\t" + KVP.Value.Variance + "\t" + KVP.Value.Sigma);
            }
              }
              JXL.Dispose();
        }
コード例 #3
0
        public void ReadInFromMsheModel()
        {
            List<IIntake> Intakes = new List<IIntake>();
              Model M = new Model(@"..\..\..\TestData\TestModel.she");
              foreach (IWell IW in HeadObservations.ReadInDetailedTimeSeries(M))
            foreach (IIntake I in IW.Intakes)
              Intakes.Add(I);

              HeadObservations.GetSimulatedValuesFromDetailedTSOutput(@"..\..\..\TestData\TestModel.she - Result Files\TestModelDetailedTS_SZ.dfs0", Intakes);
              Assert.AreEqual(2, Intakes.Count);
              M.Dispose();
        }
コード例 #4
0
 public Controller(Configuration Config)
 {
     _config = Config;
       _she = new Model(_config.SheFile);
 }
コード例 #5
0
ファイル: Program.cs プロジェクト: shobaravi/mikeshewrapper
        public static void Main(string[] args)
        {
            try
              {
            MikeSheGridInfo _grid = null;
            Results _res = null;
            string ObsFileName;

            //Input is a -she-file and an observation file
            if (args.Length == 2)
            {
              Model MS = new Model(args[0]);
              _grid = MS.GridInfo;
              _res = MS.Results;
              ObsFileName = args[1];
            }
            //Input is an .xml-file
            else if (args.Length == 1)
            {
              Configuration cf = Configuration.ConfigurationFactory(args[0]);

              _grid = new MikeSheGridInfo(cf.PreProcessedDFS3, cf.PreProcessedDFS2);

              if (cf.HeadItemText != null)
            _res = new Results(cf.ResultFile, _grid, cf.HeadItemText);
              else
            _res = new Results(cf.ResultFile, _grid);

              if (_res.Heads == null)
            throw new Exception("Heads could not be found. Check that item: \"" + _res.HeadElevationString + "\" exists in + " + cf.ResultFile);

              ObsFileName = cf.ObservationFile;
            }
            else
            {
              OpenFileDialog Ofd = new OpenFileDialog();

              Ofd.Filter = "Known file types (*.she)|*.she";
              Ofd.ShowReadOnly = true;
              Ofd.Title = "Select a MikeShe setup file";

              if (DialogResult.OK == Ofd.ShowDialog())
              {
            Model MS = new Model(Ofd.FileName);
            _grid = MS.GridInfo;
            _res = MS.Results;
            Ofd.Filter = "Known file types (*.txt)|*.txt";
            Ofd.ShowReadOnly = true;
            Ofd.Title = "Select a LayerStatistics setup file";

            if (DialogResult.OK == Ofd.ShowDialog())
              ObsFileName = Ofd.FileName;
            else
              return;
              }
              else
            return;
            }

            InputOutput IO = new InputOutput(_grid.NumberOfLayers);

            //Read in the wells
            Dictionary<string, MikeSheWell> Wells = IO.ReadFromLSText(ObsFileName);

            int NLay = _grid.NumberOfLayers;
            double [] ME = new double[NLay];
            double [] RMSE = new double[NLay];
            int [] ObsUsed = new int[NLay];
            int [] ObsTotal = new int[NLay];

            //Initialiserer
            for (int i=0;i<NLay;i++)
            {
              ME[i]       = 0;
              RMSE[i]     = 0;
              ObsUsed[i]  = 0;
              ObsTotal[i] = 0;
            }

            //Only operate on wells within the mikeshe area
            var SelectedWells = HeadObservations.SelectByMikeSheModelArea(_grid, Wells.Values);

            //Loops the wells that are within the model area
            foreach (MikeSheWell W in SelectedWells)
            {
              if (W.Layer == -3)
              {

            W.Layer = _grid.GetLayerFromDepth(W.Column, W.Row, W.Depth );
              }
              else
              {
            W.Depth =_grid.SurfaceTopography.Data[W.Row,W.Column]- (_grid.LowerLevelOfComputationalLayers.Data[W.Row, W.Column, W.Layer] + 0.5 * _grid.ThicknessOfComputationalLayers.Data[W.Row, W.Column, W.Layer]);
              }

              //Henter de simulerede værdier

              HeadObservations.GetSimulatedValuesFromGridOutput(_res, _grid, W);

              //Samler resultaterne for hver lag
              foreach (ObservationEntry TSE in W.Intakes.First().Observations)
              {
            if (TSE.SimulatedValueCell == _res.DeleteValue)
            {
                ObsTotal[W.Layer]++;
                TSE.Comment = "Cell is dry";
            }
            else if(TSE.SimulatedValueCell.HasValue)
            {
              ME[W.Layer] += TSE.ME.Value;
              RMSE[W.Layer] += TSE.RMSE.Value;
              ObsUsed[W.Layer]++;
              ObsTotal[W.Layer]++;
            }
              }
            }

            //Divide with the number of observations.
            for (int i=0;i<NLay;i++)
            {
              ME[i]   = ME[i]/ObsUsed[i];
              RMSE[i] = Math.Pow(RMSE[i]/ObsUsed[i], 0.5);
            }

            //Write output
            IO.WriteObservations(SelectedWells);
            IO.WriteLayers(ME,RMSE,ObsUsed,ObsTotal);

            //Dispose MikeShe
            _grid.Dispose();
            _res.Dispose();

              }
              catch (Exception e)
              {
            MessageBox.Show("Der er opstået en fejl af typen: " + e.Message);
              }
        }
コード例 #6
0
        public void SelectByMikeSheModelAreaTest()
        {
            List<MikeSheWell> Wells = new List<MikeSheWell>();
              Wells.Add(new MikeSheWell("well1", 10000, 10000));
              Wells.Add(new MikeSheWell("well2", 250, 250));
              Wells.Add(new MikeSheWell("well3", 300, 300));

              Model M = new Model(@"..\..\..\TestData\TestModel.she");

              var SelectedWells = HeadObservations.SelectByMikeSheModelArea(M.GridInfo, Wells);

              Assert.AreEqual(2, SelectedWells.Count());

              M.Dispose();
        }