public void MikeSheFileNameTest() { LayersCollection LC= new LayersCollection(); Wells.Well W = new HydroNumerics.Wells.Well("w1", 50, 50); W.AddNewIntake(1); Screen sc = new Screen(W.Intakes.First()); sc.BottomAsKote = 2; sc.TopAsKote = 5; List<IWell> wells = new List<IWell>(); wells.Add(W); LC.Wells = wells; LC.MikeSheFileName = @"..\..\..\TestData\testmodel.she"; }
/// <summary> /// Reads in the wells defined in detailed timeseries input section /// </summary> /// <param name="Mshe"></param> public static IEnumerable<IWell> ReadInDetailedTimeSeries(Model Mshe) { MikeSheWell CurrentWell; IIntake CurrentIntake; TSObject _tso = null; foreach (var dt in Mshe.Input.MIKESHE_FLOWMODEL.StoringOfResults.DetailedTimeseriesOutput.Item_1s) { CurrentWell = new MikeSheWell(dt.Name); CurrentWell.X = dt.X; CurrentWell.Y = dt.Y; CurrentWell.UsedForExtraction = false; CurrentIntake = CurrentWell.AddNewIntake(1); Screen sc = new Screen(CurrentIntake); sc.DepthToTop = dt.Z; sc.DepthToBottom = dt.Z; CurrentWell.Row = Mshe.GridInfo.GetRowIndex(CurrentWell.X); CurrentWell.Column = Mshe.GridInfo.GetColumnIndex(CurrentWell.Y); CurrentWell.Terrain = Mshe.GridInfo.SurfaceTopography.Data[CurrentWell.Row, CurrentWell.Column]; //Read in observations if they are included if (dt.InclObserved == 1) { if (_tso == null || _tso.Connection.FilePath != dt.TIME_SERIES_FILE.FILE_NAME) { _tso = new TSObjectClass(); _tso.Connection.FilePath = dt.TIME_SERIES_FILE.FILE_NAME; _tso.Connection.Open(); } //Loop the observations and add for (int i = 1; i <= _tso.Time.NrTimeSteps; i++) { CurrentIntake.HeadObservations.Items.Add(new TimestampValue((DateTime)_tso.Time.GetTimeForTimeStepNr(i), (float)_tso.Item(dt.TIME_SERIES_FILE.ITEM_NUMBERS).GetDataForTimeStepNr(i))); } } yield return CurrentWell; } }
/// <summary> /// Creates wells from DataRows based on ShapeReaderConfiguration /// </summary> /// <param name="DS"></param> /// <param name="SRC"></param> public static void FillInFromNovanaShape(DataRow[] DS, ShapeReaderConfiguration SRC, IWellCollection Wells, IPlantCollection Plants) { bool ReadPumpActivity = false; bool ReadPlants = false; bool ReadLayer = false; if (DS.First().Table.Columns.Contains(SRC.FraAArHeader) & DS.First().Table.Columns.Contains(SRC.TilAArHeader)) ReadPumpActivity = true; if (DS.First().Table.Columns.Contains(SRC.LayerHeader)) ReadLayer = true; if (Plants != null) if (DS.First().Table.Columns.Contains(SRC.PlantIDHeader)) ReadPlants = true; IWell CurrentWell; IIntake CurrentIntake; foreach (DataRow DR in DS) { string wellID = DR[SRC.WellIDHeader].ToString(); //Find the well in the dictionary if (Wells.Contains(wellID)) { CurrentWell = Wells[wellID]; } else { //Add a new well if it was not found CurrentWell = new Well(wellID); CurrentWell.UsedForExtraction = true; Wells.Add(CurrentWell); } int intakeno = Convert.ToInt32(DR[SRC.IntakeNumber]); CurrentIntake = CurrentWell.Intakes.FirstOrDefault(var => var.IDNumber == intakeno); if (CurrentIntake == null) CurrentIntake = CurrentWell.AddNewIntake(intakeno); if (ReadLayer) if (!Convert.IsDBNull(DR[SRC.LayerHeader])) CurrentIntake.Layer = Convert.ToInt32(DR[SRC.LayerHeader]); if (ReadPlants) { Plant CurrentPlant; int PlantID = Convert.ToInt32(DR[SRC.PlantIDHeader]); if (!Plants.TryGetValue(PlantID, out CurrentPlant)) { CurrentPlant = new Plant(PlantID); Plants.Add(CurrentPlant); } PumpingIntake CurrentPumpingIntake = new PumpingIntake(CurrentIntake, CurrentPlant); CurrentPlant.PumpingIntakes.Add(CurrentPumpingIntake); if (ReadPumpActivity) { CurrentPumpingIntake.Start = new DateTime(Convert.ToInt32(DR[SRC.FraAArHeader]), 1, 1); CurrentPumpingIntake.End = new DateTime(Convert.ToInt32(DR[SRC.TilAArHeader]), 12, 31); } } CurrentWell.X = Convert.ToDouble(DR[SRC.XHeader]); CurrentWell.Y = Convert.ToDouble(DR[SRC.YHeader]); CurrentWell.Terrain = Convert.ToDouble(DR[SRC.TerrainHeader]); Screen CurrentScreen = new Screen(CurrentIntake); CurrentScreen.BottomAsKote = Convert.ToDouble(DR[SRC.BOTTOMHeader]); CurrentScreen.TopAsKote = Convert.ToDouble(DR[SRC.TOPHeader]); } }
public ScreenViewModel(Screen screen, ChangesViewModel cvm) { _screen = screen; CVM = cvm; }
public IWellCollection ReadWellsInSteps() { string[] NotExtractionPurpose = new string[] { "A", "G", "I", "J", "L", "R", "U", "M", "P"}; string[] ExtractionUse = new string[]{"C","V","VA","VD","VH","VI","VM","VP","VV"}; string[] NotExtractionUse = new string[] { "A", "G", "I", "J", "L", "R", "U", "M", "P"}; IWellCollection Wells = new IWellCollection(); JupiterWell CurrentWell; JupiterIntake CurrentIntake; #region Borehole JXL.ReadWellsOnly(); //Loop the wells foreach (var Boring in JXL.BOREHOLE) { CurrentWell = new JupiterWell(Boring.BOREHOLENO); Wells.Add(CurrentWell); if (!Boring.IsXUTMNull()) CurrentWell.X = Boring.XUTM; else //If no x set x to 0! CurrentWell.X = 0; if (!Boring.IsYUTMNull()) CurrentWell.Y = Boring.YUTM; else CurrentWell.Y = 0; CurrentWell.Description = Boring.LOCATION; if (Boring.ELEVATION ==-999 & Boring.CTRPELEVA!=-999) CurrentWell.Terrain = Boring.CTRPELEVA; else CurrentWell.Terrain = Boring.ELEVATION; if (!Boring.IsDRILLDEPTHNull()) CurrentWell.Depth = Boring.DRILLDEPTH; CurrentWell.UsedForExtraction = true; CurrentWell.Use = Boring.USE; CurrentWell.Purpose = Boring.PURPOSE; //Hvis USE er noget andet end indvinding if (NotExtractionUse.Contains(Boring.USE.ToUpper())) CurrentWell.UsedForExtraction = false; //Hvis den er oprettet med et andet formål og USE ikke er sat til indvinding er det ikke en indvindingsboring if (NotExtractionPurpose.Contains(Boring.PURPOSE.ToUpper()) & !ExtractionUse.Contains(Boring.USE.ToUpper())) CurrentWell.UsedForExtraction = false; if (!Boring.IsDRILENDATENull()) CurrentWell.StartDate = Boring.DRILENDATE; if (!Boring.IsABANDONDATNull()) CurrentWell.EndDate = Boring.ABANDONDAT; } JXL.BOREHOLE.Clear(); #endregion #region Intakes //Intakes JXL.ReadIntakes(); foreach (var Intake in JXL.INTAKE) { if (Wells.Contains(Intake.BOREHOLENO)) { JupiterIntake I = Wells[Intake.BOREHOLENO].AddNewIntake(Intake.INTAKENO) as JupiterIntake; if (I != null) { if (!Intake.IsSTRINGNONull()) { I.StringNo = Intake.STRINGNO; I.ResRock = Intake.RESERVOIRROCK; } } } } foreach( var Casing in JXL.CASING) { if (Wells.Contains(Casing.BOREHOLENO)) { if (!Casing.IsSTRINGNONull()) { IIntake I = Wells[Casing.BOREHOLENO].Intakes.FirstOrDefault(var => ((JupiterIntake)var).StringNo == Casing.STRINGNO); if (I != null) if (!Casing.IsBOTTOMNull()) I.Depth = Casing.BOTTOM; } } } JXL.INTAKE.Clear(); JXL.CASING.Clear(); #endregion #region Screens //Screens JXL.ReadScreens(); foreach (var screen in JXL.SCREEN) { if (Wells.Contains(screen.BOREHOLENO)) { CurrentIntake = Wells[screen.BOREHOLENO].Intakes.FirstOrDefault(var => var.IDNumber == screen.INTAKENO) as JupiterIntake; if (CurrentIntake != null) { Screen CurrentScreen = new Screen(CurrentIntake); if (!screen.IsTOPNull()) CurrentScreen.DepthToTop = screen.TOP; if (!screen.IsBOTTOMNull()) CurrentScreen.DepthToBottom = screen.BOTTOM; CurrentScreen.Number = screen.SCREENNO; if (!screen.IsSTARTDATENull()) CurrentScreen.StartDate = screen.STARTDATE; if (!screen.IsENDDATENull()) CurrentScreen.EndDate = screen.ENDDATE; } } } JXL.SCREEN.Clear(); #endregion return Wells; }
/// <summary> /// Applies the change in the description to a plant or a well. /// Returns true if the change could be applied. /// No checks on previous values or dates. /// </summary> /// <param name="plants"></param> /// <param name="wells"></param> /// <param name="cd"></param> /// <returns></returns> public bool ApplySingleChange(IPlantCollection plants, IWellCollection wells, ChangeDescription cd) { string wellid = ""; int plantid; int intakeno = -1; IWell CurrentWell; bool succeded = false; switch (cd.Table) { case JupiterTables.BOREHOLE: wellid = cd.PrimaryKeys["BOREHOLENO"]; if (wells.TryGetValue(wellid, out CurrentWell)) { foreach (var c in cd.ChangeValues) { switch (c.Column.ToUpper()) { case "XUTM": CurrentWell.X = double.Parse(c.NewValue); succeded = true; break; case "YUTM": CurrentWell.Y = double.Parse(c.NewValue); succeded = true; break; case "ELEVATION": CurrentWell.Terrain = double.Parse(c.NewValue); succeded = true; break; default: break; } } } break; case JupiterTables.SCREEN: wellid = cd.PrimaryKeys["BOREHOLENO"]; if (wells.TryGetValue(wellid, out CurrentWell)) { int screenNumber = int.Parse(cd.PrimaryKeys["SCREENNO"]); if (cd.Action == TableAction.EditValue) { var screen = CurrentWell.Intakes.SelectMany(var => var.Screens).FirstOrDefault(var2 => var2.Number == screenNumber); if (screen != null) { foreach (var cv in cd.ChangeValues) { if (cv.Column == "TOP") screen.DepthToTop = double.Parse(cv.NewValue); else if (cv.Column == "BOTTOM") screen.DepthToBottom = double.Parse(cv.NewValue); succeded = true; } } } else if (cd.Action == TableAction.InsertRow) { intakeno = int.Parse(cd.ChangeValues.Single(var => var.Column == "INTAKENO").NewValue); IIntake CurrentIntake = CurrentWell.Intakes.Single(var => var.IDNumber == intakeno); if (CurrentIntake != null) { Screen sc = new Screen(CurrentIntake); sc.DepthToTop = double.Parse(cd.ChangeValues.Single(var => var.Column == "TOP").NewValue); sc.DepthToBottom = double.Parse(cd.ChangeValues.Single(var => var.Column == "BOTTOM").NewValue); succeded = true; } } } break; case JupiterTables.DRWPLANTINTAKE: if (cd.Action == TableAction.EditValue || cd.Action == TableAction.DeleteRow) { int tableid; if (int.TryParse(cd.PrimaryKeys.First().Value, out tableid)) { if (DataBaseConnection.TryGetPlant(tableid, out plantid, out wellid, out intakeno)) succeded = true; } else //No ID Change of a change { if (cd.Action == TableAction.EditValue) { if (int.TryParse(cd.ChangeValues[0].NewValue, out plantid)) { wellid = cd.ChangeValues[1].NewValue; if (int.TryParse(cd.ChangeValues[2].NewValue, out intakeno)) succeded = true; } } else if (int.TryParse(cd.ChangeValues[0].OldValue, out plantid)) { wellid = cd.ChangeValues[1].OldValue; if (int.TryParse(cd.ChangeValues[2].OldValue, out intakeno)) succeded = true; } } if (succeded) { var pi = plants[plantid].PumpingIntakes.FirstOrDefault(var => var.Intake.well.ID == wellid & var.Intake.IDNumber == intakeno); if (pi != null) { if (cd.Action == TableAction.DeleteRow) plants[plantid].PumpingIntakes.Remove(pi); else { var start = cd.ChangeValues.SingleOrDefault(var => var.Column == "STARTDATE"); if (start != null) pi.StartNullable = DateTime.Parse(start.NewValue); var end = cd.ChangeValues.SingleOrDefault(var => var.Column == "ENDDATE"); if (end != null) pi.EndNullable = DateTime.Parse(end.NewValue); } succeded = true; } } } else //insertrow { plantid = int.Parse(cd.ChangeValues.First(var => var.Column == "PLANTID").NewValue); Plant p; if (plants.TryGetValue(plantid, out p)) { wellid = cd.ChangeValues.First(var => var.Column == "BOREHOLENO").NewValue; IWell w; if (wells.TryGetValue(wellid, out w)) { intakeno = int.Parse(cd.ChangeValues.First(var => var.Column == "INTAKENO").NewValue); IIntake I = w.Intakes.First(var => var.IDNumber == intakeno); if (I != null) { PumpingIntake pi = new PumpingIntake(I, p); var s = cd.ChangeValues.FirstOrDefault(var => var.Column == "STARTDATE"); if (s != null) pi.StartNullable = DateTime.Parse(s.NewValue); s = cd.ChangeValues.FirstOrDefault(var => var.Column == "ENDDATE"); if (s != null) pi.EndNullable = DateTime.Parse(s.NewValue); p.PumpingIntakes.Add(pi); succeded = true; } } } } break; case JupiterTables.WATLEVEL: wellid = cd.PrimaryKeys["BOREHOLENO"]; if (wells.TryGetValue(wellid, out CurrentWell)) { DateTime TimeOfMeasure; int WatlevelNo = int.Parse(cd.PrimaryKeys["WATLEVELNO"]); if (DataBaseConnection.TryGetIntakeNoTimeOfMeas(CurrentWell, WatlevelNo, out intakeno, out TimeOfMeasure)) { IIntake CurrentIntake = CurrentWell.Intakes.SingleOrDefault(var => var.IDNumber == intakeno); if (CurrentIntake != null) { var item = CurrentIntake.HeadObservations.Items.FirstOrDefault(var => var.Time == TimeOfMeasure); if (item != null) { CurrentIntake.HeadObservations.Items.Remove(item); succeded = true; } } } } break; default: break; } return succeded; }
public ChangeDescription NewScreen(Screen screen) { ChangeDescription change = GetScreenChange(screen); change.Action = TableAction.InsertRow; change.ChangeValues.Add(new Change("TOP", screen.DepthToTop.ToString(), "")); change.ChangeValues.Add(new Change("BOTTOM", screen.DepthToBottom.ToString(), "")); change.ChangeValues.Add(new Change("INTAKENO", screen.Intake.IDNumber.ToString(), "")); return change; }
public ChangeDescription ChangeBottomOnScreen(Screen screen, double NewValue) { ChangeDescription Cd = GetScreenChange(screen); ChangeBottomOnScreen(Cd, screen, NewValue); return Cd; }
public void ChangeBottomOnScreen(ChangeDescription Cd, Screen screen, double NewValue) { Cd.ChangeValues.Add(new Change("BOTTOM", NewValue.ToString(), screen.DepthToBottom.ToString())); }
public ChangeDescription ChangeTopOnScreen(Screen screen, double NewValue) { ChangeDescription Cd = GetScreenChange(screen); Cd.ChangeValues.Add(new Change("TOP", NewValue.ToString(), screen.DepthToTop.ToString())); return Cd; }
public ChangeDescription GetScreenChange(Screen screen) { ChangeDescription change = new ChangeDescription(JupiterTables.SCREEN); change.User = UserName; change.Project = ProjectName; change.Action = TableAction.EditValue; change.PrimaryKeys["BOREHOLENO"] = screen.Intake.well.ID; change.PrimaryKeys["SCREENNO"] = screen.Number.ToString(); return change; }
public ScreenViewModel AddScreen() { Screen sc = new Screen(_well.Intakes.First()); sc.Number = _well.Intakes.Max(var1 => var1.Screens.Max(var => var.Number)) + 1; ScreenViewModel svm = new ScreenViewModel(sc, CVM); Screens.Add(svm); return svm; }
public void ReadWellsFromShape() { ShapeReader SR = new ShapeReader(_config.WellShapeFile); DataTable _wellData = SR.Data.Read(); SR.Dispose(); foreach (DataRow dr in _wellData.Rows) { IrrigationWell IW = new IrrigationWell(dr[_config.IdHeader].ToString()); IW.X = Convert.ToDouble(dr[_config.XHeader]); IW.Y = Convert.ToDouble(dr[_config.YHeader]); IIntake I = IW.AddNewIntake(1); IW.MaxDepth = Convert.ToDouble(dr[_config.MaxDepthHeader]); IW.MaxRate = Convert.ToDouble(dr[_config.MaxRateHeader]); Screen CurrentScreen = new Screen(I); CurrentScreen.DepthToBottom = Convert.ToDouble(dr[_config.BottomHeader]); CurrentScreen.DepthToTop = Convert.ToDouble(dr[_config.TopHeader]); _wells.Add(IW); } _wellData.Dispose(); }
public void BindAddedWells() { _logstring.Append("IntakeId\tOriginal screen top\tOriginal screen bottom\tNew layer number\t New Screen top\tNew screen bottom\n"); int i = 0; foreach (Layer L in Layers) { for (int j = L.OriginalIntakes.Count; j < L.Intakes.Count; j++) { IIntake I = L.Intakes[j]; _logstring.Append(I.ToString() + "\t" + I.Screens.First().TopAsKote + "\t" + I.Screens.First().BottomAsKote + "\t" + L.LayerNumber); I.Screens.Clear(); Screen sc = new Screen(I); int col; int row; MShe.GridInfo.TryGetIndex(I.well.X, I.well.Y, out col, out row); sc.TopAsKote = MShe.GridInfo.UpperLevelOfComputationalLayers.Data[i][row, col] - 0.01; sc.BottomAsKote = MShe.GridInfo.LowerLevelOfComputationalLayers.Data[i][row, col] - 0.01; _logstring.Append("\t" + I.Screens.First().TopAsKote + "\t" + I.Screens.First().BottomAsKote + "\n"); } i++; } DistributeIntakesOnLayers(); }