public override void Initialize(DateTime Start, DateTime End, IEnumerable <Catchment> Catchments) { base.Initialize(Start, End, Catchments); //Reading the slopes Dictionary <int, double> Slopes = new Dictionary <int, double>(); using (HydroNumerics.Geometry.Shapes.DBFReader dbf = new Geometry.Shapes.DBFReader(Slope.FileName)) { for (int i = 0; i < dbf.NoOfEntries; i++) { int id = dbf.ReadInt(i, Slope.ColumnNames[0]); double value = dbf.ReadDouble(i, Slope.ColumnNames[1]); Slopes.Add(id, value); } } //Reading the soiltypes Dictionary <int, double> FineSand = new Dictionary <int, double>(); Dictionary <int, double> CoarseSand = new Dictionary <int, double>(); Dictionary <int, double> Humus = new Dictionary <int, double>(); using (HydroNumerics.Geometry.Shapes.DBFReader dbf = new Geometry.Shapes.DBFReader(SoilTypeFile.FileName)) { for (int i = 0; i < dbf.NoOfEntries; i++) { int id = dbf.ReadInt(i, SoilTypeFile.ColumnNames[0]); double value = dbf.ReadDouble(i, SoilTypeFile.ColumnNames[1]); string text = dbf.ReadString(i, SoilTypeFile.ColumnNames[2]).ToLower().Trim(); switch (text) { case "coarse sandy soil": CoarseSand.Add(id, value); break; case "fine sandy soil": FineSand.Add(id, value); break; case "organic soil": Humus.Add(id, value); break; default: break; } } } //Make sure we have both precipitation, M11Flow and upstream m11flow foreach (var c in Catchments.Where(cp => cp.Precipitation != null & cp.NetInflow != null)) { List <double> values = new List <double>(); deposition.Add(c.ID, values); double slope = 0; Slopes.TryGetValue(c.ID, out slope); double coarsesand = 0; CoarseSand.TryGetValue(c.ID, out coarsesand); double finesand = 0; FineSand.TryGetValue(c.ID, out finesand); double organicsoil = 0; Humus.TryGetValue(c.ID, out organicsoil); for (int i = Start.Year; i <= End.Year; i++) { values.Add(EvaluateEquation(coarsesand, finesand, organicsoil, c.Precipitation.GetTs(TimeStepUnit.Year).GetValue(new DateTime(i, 1, 1)), slope)); } } FirstYear = Start.Year; NewMessage("Initialized."); }
public override void Initialize(DateTime Start, DateTime End, IEnumerable<Catchment> Catchments) { base.Initialize(Start, End, Catchments); //Reading the slopes Dictionary<int, double> Slopes = new Dictionary<int, double>(); using (HydroNumerics.Geometry.Shapes.DBFReader dbf = new Geometry.Shapes.DBFReader(Slope.FileName)) { for (int i = 0; i < dbf.NoOfEntries; i++) { int id = dbf.ReadInt(i, Slope.ColumnNames[0]); double value = dbf.ReadDouble(i, Slope.ColumnNames[1]); Slopes.Add(id, value); } } //Reading the soiltypes Dictionary<int, double> FineSand = new Dictionary<int, double>(); Dictionary<int, double> CoarseSand = new Dictionary<int, double>(); Dictionary<int, double> Humus = new Dictionary<int, double>(); using (HydroNumerics.Geometry.Shapes.DBFReader dbf = new Geometry.Shapes.DBFReader(SoilTypeFile.FileName)) { for (int i = 0; i < dbf.NoOfEntries; i++) { int id = dbf.ReadInt(i, SoilTypeFile.ColumnNames[0]); double value = dbf.ReadDouble(i, SoilTypeFile.ColumnNames[1]); string text = dbf.ReadString(i, SoilTypeFile.ColumnNames[2]).ToLower().Trim(); switch (text) { case "coarse sandy soil": CoarseSand.Add(id, value); break; case "fine sandy soil": FineSand.Add(id, value); break; case "organic soil": Humus.Add(id, value); break; default: break; } } } //Make sure we have both precipitation, M11Flow and upstream m11flow foreach (var c in Catchments.Where(cp => cp.Precipitation != null & cp.NetInflow != null )) { List<double> values = new List<double>(); deposition.Add(c.ID, values); double slope = 0; Slopes.TryGetValue(c.ID, out slope); double coarsesand = 0; CoarseSand.TryGetValue(c.ID, out coarsesand); double finesand = 0; FineSand.TryGetValue(c.ID, out finesand); double organicsoil = 0; Humus.TryGetValue(c.ID, out organicsoil); for (int i = Start.Year; i <= End.Year; i++) { values.Add(EvaluateEquation(coarsesand, finesand, organicsoil, c.Precipitation.GetTs(TimeStepUnit.Year).GetValue(new DateTime(i, 1, 1), InterpolationMethods.DeleteValue), slope)); } } FirstYear = Start.Year; NewMessage("Initialized."); }