public void GetIndexTest() { Model mshe = new Model(@"..\..\..\TestData\TestModelDemo.she"); int Column; int Row; Assert.IsTrue(mshe.GridInfo.TryGetIndex(11, 11, out Column, out Row)); Assert.AreEqual(1, Column); Assert.AreEqual(1, Row); Assert.IsTrue(mshe.GridInfo.TryGetIndex(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(); }
public MikeSheGridInfo(string PreProcessed3DFile, string PreProcessed2DFile) { _preproDFS3 = new DFS3(PreProcessed3DFile); _preproDFS2 = new DFS2(PreProcessed2DFile); //Open Files and call initialize Initialize(_preproDFS3, _preproDFS2); }
public void ConstructTest() { string file1 = @"..\..\..\TestData\omr4_jag_3DSZ.dfs3"; string file2 = @"..\..\..\TestData\omr4_jag_3DSZ_copy.dfs3"; File.Copy(file1, file2, true); _dfs = new DFS3(file1); _dfsWrite = new DFS3(file2); }
/// <summary> /// Sums layers from a DFS3 into a DFS2 /// </summary> /// <param name="OperationData"></param> public static void LayerSummation(XElement OperationData) { string Dfs3File = OperationData.Element("DFS3FileName").Value; string DFS2OutPut = OperationData.Element("DFS2OutputFileName").Value; DFS3.MaxEntriesInBuffer = 1; DFS2.MaxEntriesInBuffer = 1; DFS3 input = new DFS3(Dfs3File); var Items = ParseString(OperationData.Element("Items").Value, 1, input.Items.Count()); var Layers = ParseString(OperationData.Element("Layers").Value, 0, input.NumberOfLayers - 1); DenseMatrix Sumdata = new DenseMatrix(input.NumberOfRows, input.NumberOfColumns); //Create the output file and copy info from input file DFS2 output = new DFS2(DFS2OutPut, Items.Count()); output.CopyFromTemplate(input); int l = 0; //Create the items foreach (int j in Items) { int i = j - 1; output.Items[l].EumItem = input.Items[i].EumItem; output.Items[l].EumUnit = input.Items[i].EumUnit; output.Items[l].Name = input.Items[i].Name; l++; } for (int i = 0; i < input.NumberOfTimeSteps; i++) { foreach (int j in Items) { IMatrix3d data = input.GetData(i, j); Sumdata = data[Layers[0]]; for (int k = 1; k < Layers.Count(); k++) { Sumdata = Sumdata + data[Layers[k]]; } RecreateDeleteValues(data[Layers[0]], Sumdata, input.DeleteValue); output.SetData(i, j, Sumdata); } } input.Dispose(); output.Dispose(); }
public static string GetASCIIGrid(this DFS3 dfsfile, int TimeStep, int Item, int Layer) { ASCIIGrid ascii = new ASCIIGrid(); ascii.NumberOfColumns = dfsfile.NumberOfColumns; ascii.NumberOfRows = dfsfile.NumberOfRows; ascii.XOrigin = dfsfile.XOrigin; ascii.YOrigin = dfsfile.YOrigin; ascii.GridSize = dfsfile.GridSize; ascii.DeleteValue = dfsfile.DeleteValue; ascii.Data = dfsfile.GetData(TimeStep, Item)[Layer]; return(ascii.ToString()); }
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(); }
/// <summary> /// Opens the necessary dfs-files and sets up the references to the properties /// </summary> /// <param name="fileNames"></param> private void Initialize3DSZ(string sz3dFile) { SZ3D = new DFS3(sz3dFile); if (SZ3D != null) { DeleteValue = SZ3D.DeleteValue; for (int i = 0; i < SZ3D.Items.Length; i++) { if (SZ3D.Items[i].Name.Equals(HeadElevationString, StringComparison.OrdinalIgnoreCase)) { _heads = new DataSetsFromDFS3(SZ3D, i + 1); //Also create the phreatic heads; _phreaticHead = new PhreaticPotential(_heads, _grid, SZ3D.DeleteValue); } } } }
void v_SimulationFinished(object sender, EventArgs e) { Model mshe = sender as Model; var dfs = DfsFileFactory.OpenFile(mshe.Files.SZ3DFileName); double[] percentiles = new double[] { 0.1 }; string filename = Path.Combine(mshe.Files.ResultsDirectory, "SZ3D_percentiles.dfs3"); var dfsout = DfsFileFactory.CreateFile(filename, percentiles.Count()); dfsout.CopyFromTemplate(dfs); dfs.Percentile(1, dfsout, percentiles, 80000000); dfsout.Dispose(); DFS3 dfsout2 = new DFS3(filename); Console.WriteLine(dfsout2.GetData(0, 1)[10, 10, 0]); dfsout2.Dispose(); RunNext(mshe); }
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]); }
public void TimeMaxTest() { new XElement("GridOperations"); XElement Op = new XElement("GridOperation", new XAttribute("Type", "TimeMax"), new XElement("DFSFileName", @"..\..\..\TestData\TestModel.she - Result Files\TestModel_3DSZflow.dfs3"), new XElement("Items", ""), new XElement("TimeInterval", "Year"), new XElement("DFSOutputFileName", @"..\..\..\TestData\TestModel.she - Result Files\YearlyMax.dfs3") ); GridFunctions.TimeMax(Op); DFS3 dfs = new DFS3(@"..\..\..\TestData\TestModel.she - Result Files\YearlyMax.dfs3"); Assert.AreEqual(1, dfs.NumberOfTimeSteps); Assert.AreEqual(2.000215e-005, dfs.GetData(0, 1)[19, 14, 0], 1e-7); Assert.AreEqual(2.527396e-007, dfs.GetData(0, 4)[21, 17, 0], 1e-9); dfs.Dispose(); }
public void TimeMinTest() { new XElement("GridOperations"); XElement Op = new XElement("GridOperation", new XAttribute("Type", "TimeMin"), new XElement("DFSFileName", @"..\..\..\TestData\TestModel.she - Result Files\TestModel_3DSZflow.dfs3"), new XElement("Items", ""), new XElement("TimeInterval", "Year"), new XElement("DFSOutputFileName", @"..\..\..\TestData\TestModel.she - Result Files\YearlyMin.dfs3") ); GridFunctions.TimeMin(Op); DFS3 dfs = new DFS3(@"..\..\..\TestData\TestModel.she - Result Files\YearlyMin.dfs3"); Assert.AreEqual(1, dfs.NumberOfTimeSteps); Assert.AreEqual(5, dfs.NumberOfItems); Assert.AreEqual(-1.601641e-007, dfs.GetData(0, 1)[24, 7, 0], 1e-10); Assert.AreEqual(-100.7973, dfs.GetData(0, 3)[18, 11, 0], 1e-2); dfs.Dispose(); }
public void TimeSummationTest() { new XElement("GridOperations"); XElement Op = new XElement("GridOperation", new XAttribute("Type", "TimeSummation"), new XElement("DFSFileName", @"..\..\..\TestData\TestModel.she - Result Files\TestModel_3DSZflow.dfs3"), new XElement("Items", ""), new XElement("TimeInterval", "Year"), new XElement("DFSOutputFileName", @"..\..\..\TestData\TestModel.she - Result Files\YearlySum.dfs3") ); GridFunctions.TimeSummation(Op); DFS3 dfs = new DFS3(@"..\..\..\TestData\TestModel.she - Result Files\YearlySum.dfs3"); Assert.AreEqual(1, dfs.NumberOfTimeSteps); Assert.AreEqual(5, dfs.NumberOfItems); Assert.AreEqual(-6.925168e-007, dfs.GetData(0, 1)[25, 6, 0], 1e-10); Assert.AreEqual(-3.86626e-005, dfs.GetData(0, 4)[21, 16, 0], 1e-8); dfs.Dispose(); }
private void Initialize3DSZFlow(string sz3dFlowFile) { DFS3 SZ3DFlow = new DFS3(sz3dFlowFile); if (SZ3DFlow != null) { for (int i = 0; i < SZ3DFlow.Items.Length; i++) { switch (SZ3DFlow.Items[i].Name) { case "groundwater flow in x-direction": _xflow = new DataSetsFromDFS3(SZ3DFlow, i + 1); break; case "groundwater flow in y-direction": _yflow = new DataSetsFromDFS3(SZ3DFlow, i + 1); break; case "groundwater flow in z-direction": _zflow = new DataSetsFromDFS3(SZ3DFlow, i + 1); break; case "groundwater extraction": _groundWaterExtraction = new DataSetsFromDFS3(SZ3DFlow, i + 1); break; case "SZ exchange flow with river": _sZExchangeFlowWithRiver = new DataSetsFromDFS3(SZ3DFlow, i + 1); break; case "SZ drainage flow from point": _sZDrainageFlow = new DataSetsFromDFS3(SZ3DFlow, i + 1); break; default: break; } } } }
public ExtractData(string FileName, string Dfs3FileName) { mShe = new Model(FileName); DFS3 dfs = new DFS3(Dfs3FileName); List <List <double> > wells = new List <List <double> >(); foreach (var W in mShe.ExtractionWells) { wells.Add(new List <double>()); } for (int i = 0; i < dfs.NumberOfTimeSteps; i++) { for (int j = 0; j < mShe.ExtractionWells.Count; j++) { var w = mShe.ExtractionWells[j]; wells[j].Add(dfs.GetData(i, 1)[w.Row, w.Column, w.Layer]); } } }
private void MakePlots() { if (!PlotsMade) //Only do this once { Model mShe = new Model(SheFileName); DFS3 dfs = new DFS3(Dfs3FileName); Item dfsI = dfs.Items[ItemNumber - 1]; List <TimestampSeries> well_Concentration = new List <TimestampSeries>(); int[] TimeSteps = ParseString(TimeStepsAsString, 0, dfs.NumberOfTimeSteps - 1); int[] WellNumbers = ParseString(WellsAsString, 0, mShe.ExtractionWells.Count - 1); List <MikeSheWell> wells = new List <MikeSheWell>(); foreach (int j in WellNumbers) { wells.Add(mShe.ExtractionWells[j]); } foreach (int i in TimeSteps) { int k = 0; foreach (var w in wells) { if (i == TimeSteps[0]) { well_Concentration.Add(new TimestampSeries(w.ID, new Unit(dfsI.EumQuantity.UnitAbbreviation, 1, 0))); } well_Concentration[k].Items.Add(new TimestampValue(dfs.TimeSteps[i], (dfs.GetData(i, ItemNumber)[w.Row, w.Column, w.Layer]))); k++; } } //Sets the upper title Header.Content = dfsI.Name; //Sets the title of the y-axis var ytitle = new VerticalAxisTitle(); ytitle.Content = dfsI.EumQuantity.ItemDescription + " [" + dfsI.EumQuantity.UnitAbbreviation + "]"; TheChart.Children.Add(ytitle); int l = 0; //Loop the wells for plotting foreach (var w in wells) { if (g != null) { TheChart.Children.Remove(g); TheChart.FitToView(); } var axis = new Microsoft.Research.DynamicDataDisplay.Charts.HorizontalDateTimeAxis(); TheChart.MainHorizontalAxis = axis; TheChart.MainVerticalAxis = new Microsoft.Research.DynamicDataDisplay.Charts.VerticalAxis(); //set the data source EnumerableDataSource <TimestampValue> ds = new EnumerableDataSource <TimestampValue>(well_Concentration[l].Items); ds.SetXMapping(var => axis.ConvertToDouble(var.Time)); ds.SetYMapping(var => var.Value); //create the graph g = TheChart.AddLineGraph(ds, new Pen(Brushes.Black, 3), new PenDescription(w.ID)); //create a filename outfile = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Dfs3FileName), "Well_No" + "_" + WellNumbers[l].ToString() + "_" + dfsI.EumQuantity.ItemDescription); //now save to file this.UpdateLayout(); MainWindow.SaveScreen(this, outfile + ".jpg", (int)ActualWidth, (int)ActualHeight); //Now create the dfs0-file using (DFS0 dfs0 = new DFS0(outfile + ".dfs0", 1)) { dfs0.FirstItem.Name = dfsI.Name; dfs0.FirstItem.EumItem = dfsI.EumItem; dfs0.FirstItem.EumUnit = dfsI.EumUnit; dfs0.FirstItem.ValueType = dfsI.ValueType; int t = 0; foreach (var v in well_Concentration[l].Items) { dfs0.InsertTimeStep(v.Time); dfs0.SetData(t, 1, v.Value); t++; } } //Now create the text-file using (StreamWriter sw = new StreamWriter(outfile + ".txt", false)) { foreach (var v in well_Concentration[l].Items) { sw.WriteLine(v.Time + "; " + v.Value); } } l++; } mShe.Dispose(); dfs.Dispose(); PlotsMade = true; } }
internal MikeSheGridInfo(DFS3 PreProcessed3D, DFS2 Preprocessed2D) { Initialize(PreProcessed3D, Preprocessed2D); }
private void Initialize(DFS3 PreProcessed3D, DFS2 Preprocessed2D) { //Generate 3D properties if (PreProcessed3D != null) { for (int i = 0; i < PreProcessed3D.Items.Length; i++) { switch (PreProcessed3D.Items[i].Name) { case "Boundary conditions for the saturated zone": _boundaryConditionsForTheSaturatedZone = new DataSetsFromDFS3(PreProcessed3D, i + 1); break; case "Lower level of computational layers in the saturated zone": _lowerLevelOfComputationalLayers = new DataSetsFromDFS3(PreProcessed3D, i + 1); break; case "Thickness of computational layers in the saturated zone": _thicknessOfComputationalLayers = new DataSetsFromDFS3(PreProcessed3D, i + 1); break; default: //Unknown item break; } } } //Generate 2D properties by looping the items for (int i = 0; i < Preprocessed2D.Items.Length; i++) { switch (Preprocessed2D.Items[i].Name) { case "Model domain and grid": _modelDomainAndGrid = new DataSetsFromDFS2(Preprocessed2D, i + 1); break; case "Surface topography": _surfaceTopography = new DataSetsFromDFS2(Preprocessed2D, i + 1); break; default: //Unknown item break; } } _deleteValue = Preprocessed2D.DeleteValue; GridSize = Preprocessed2D.GridSize; NumberOfRows = Preprocessed2D.NumberOfRows;; NumberOfColumns = Preprocessed2D.NumberOfColumns; if (PreProcessed3D == null) { NumberOfLayers = 1; } else { NumberOfLayers = PreProcessed3D.NumberOfLayers; } //For MikeShe the origin is lower left whereas it is center of lower left for DFS XOrigin = Preprocessed2D.XOrigin; YOrigin = Preprocessed2D.YOrigin; }
private void Initialize(string PreProcessed3dSzFile, string PreProcessed2dSzFile) { //Open File with 3D data if (System.IO.File.Exists(PreProcessed3dSzFile)) { _PreProcessed_3DSZ = new DFS3(PreProcessed3dSzFile); //Generate 3D properties for (int i = 0; i < _PreProcessed_3DSZ.Items.Length; i++) { switch (_PreProcessed_3DSZ.Items[i].Name) { case "Horizontal conductivity in the saturated zone": _horizontalConductivity = new DataSetsFromDFS3(_PreProcessed_3DSZ, i + 1); break; case "Vertical conductivity in the saturated zone": _verticalConductivity = new DataSetsFromDFS3(_PreProcessed_3DSZ, i + 1); break; case "Transmissivity in the saturated zone": _transmissivity = new DataSetsFromDFS3(_PreProcessed_3DSZ, i + 1); break; case "Specific yield in the saturated zone": _specificYield = new DataSetsFromDFS3(_PreProcessed_3DSZ, i + 1); break; case "Specific storage in the saturated zone": _specificStorage = new DataSetsFromDFS3(_PreProcessed_3DSZ, i + 1); break; case "Initial potential heads in the saturated zone": _initialHeads = new DataSetsFromDFS3(_PreProcessed_3DSZ, i + 1); break; default: //Unknown item break; } } } //Open File with 2D data _prePro2D = new DFS2(PreProcessed2dSzFile); //Generate 2D properties by looping the items for (int i = 0; i < _prePro2D.Items.Length; i++) { switch (_prePro2D.Items[i].Name) { case "Net Rainfall Fraction": _netRainFallFraction = new DataSetsFromDFS2(_prePro2D, i + 1); break; case "Infiltration Fraction": _infiltrationFraction = new DataSetsFromDFS2(_prePro2D, i + 1); break; default: //Unknown item break; } } //Now construct the grid from the open files _grid = new MikeSheGridInfo(_PreProcessed_3DSZ, _prePro2D); }
static void Main(string[] args) { string DFS3FileName = args.FirstOrDefault(var => Path.GetExtension(var).Equals(".dfs3")); var SheFiles = args.Where(var => Path.GetExtension(var).Equals(".she")); if (DFS3FileName == null) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "Known file types (*.dfs3)|*.dfs3"; //Only open .dfs2-files ofd.Title = "Select a .dfs2-file with grid codes marking the areas where timeseries should be aggregated"; if (ofd.ShowDialog() == DialogResult.OK) DFS3FileName = ofd.FileName; else return; } if (SheFiles.Count() == 0) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "Known file types (*.she)|*.she"; //Only open .asc-files ofd.Title = "Select the she-files with the scenarios"; ofd.Multiselect = true; if (ofd.ShowDialog() == DialogResult.OK) SheFiles = ofd.FileNames; else return; } DFS3 GridFile = new DFS3(DFS3FileName); foreach (var file in SheFiles) { Model M = new Model(file); ITSObject timeseries = new TSObjectClass(); timeseries.Time.AddTimeSteps(M.Results.PhreaticHead.TimeSteps.Count()); for (int t = 0; t < M.Results.PhreaticHead.TimeSteps.Count(); t++) { for (int k=0;k<GridFile.NumberOfLayers;k++) { Dictionary<int,List<double>> AggregatedValues = new Dictionary<int,List<double>>(); for (int i =0;i< GridFile.NumberOfRows;i++) { for (int j=0;j<GridFile.NumberOfColumns;j++) { int gridcode = (int)GridFile.GetData(0,1)[i,j,k]; List<double> Values; if(!AggregatedValues.TryGetValue(gridcode, out Values)) { Values = new List<double>(); AggregatedValues.Add(gridcode,Values); } Values.Add(M.Results.PhreaticHead.TimeData(t)[i,j,k]); } } foreach(var kvp in AggregatedValues) { } } timeseries.Time.SetTimeForTimeStepNr(t,M.Results.PhreaticHead.TimeSteps[t]); timeseries.Item(0).SetDataForTimeStepNr(t, } } }
private void MakePlots() { if (!PlotsMade) //Only do this once { Model mShe = new Model(SheFileName); DFS3 dfs = new DFS3(Dfs3FileName); Item dfsI = dfs.Items[ItemNumber - 1]; string BaseFileName = System.IO.Path.ChangeExtension(Dfs3FileName, ""); int[] TimeSteps = Dfs3plotdfs0.MainWindow.ParseString(TimeStepsAsString, 0, dfs.NumberOfTimeSteps - 1); int[] Layers = Dfs3plotdfs0.MainWindow.ParseString(LayersAsString, 0, dfs.NumberOfLayers - 1); //Set graph headers Header.Content = dfsI.Name; Unit.Content = dfsI.EumQuantity.UnitAbbreviation; //Give plot the same scale as the dfs grid plotter.Width = plotter.Height * ((double)dfs.NumberOfColumns) / (double)dfs.NumberOfRows; //Plot the extraction wells EnumerableDataSource <MikeSheWell> ds = new EnumerableDataSource <MikeSheWell>(mShe.ExtractionWells); ds.SetXMapping(var => var.X); ds.SetYMapping(var => var.Y); var point = new Microsoft.Research.DynamicDataDisplay.PointMarkers.CirclePointMarker(); point.Size = 10; point.Pen = new Pen(Brushes.Black, 3); plotter.AddLineGraph(ds, null, point, null); //Now loop, first on time steps then on layers foreach (int T in TimeSteps) { foreach (int L in Layers) { Header2.Content = "Time: " + dfs.TimeSteps[T].ToShortDateString() + ", Layer: " + L; var M = dfs.GetData(T, ItemNumber)[L]; NaiveColorMap nc = new NaiveColorMap(); M.Transpose(); //Need to transpose nc.Data = M.ToArray(); M.Transpose(); //Transpose back as this is a reference to data held in the buffer nc.Palette = Microsoft.Research.DynamicDataDisplay.Common.Palettes.UniformLinearPalettes.RedGreenBluePalette; var bmp = nc.BuildImage(); image.Source = bmp; //Set the color scale paletteControl.Palette = nc.Palette; paletteControl.Range = nc.Data.GetMinMax(); //Set the size var visible = new Microsoft.Research.DynamicDataDisplay.DataRect(dfs.XOrigin, dfs.YOrigin, dfs.GridSize * dfs.NumberOfColumns, dfs.GridSize * dfs.NumberOfRows); ViewportPanel.SetViewportBounds(image, visible); plotter.Visible = visible; //Write the bitmap this.UpdateLayout(); string fname = BaseFileName + "TimeStep_" + T + "_Layer_" + L; Dfs3plotdfs0.MainWindow.SaveScreen(this, fname + ".jpg", (int)ActualWidth, (int)ActualHeight); //Now write the ascii grid using (StreamWriter sw = new StreamWriter(fname + ".asc")) { sw.Write(dfs.GetASCIIGrid(T, ItemNumber, L)); } } } } }
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); } } } }