/// <summary> /// Script that takes Snow parameters from RDI (NAM) /// and applies it to the matching urban catchment (Model A or Model B). /// Assumes the model is set up as RDI+A or RDI+B. /// </summary> //[Script] // Disabled right now. Remove the // in front of [Script] to enable again public void CatchmenUrbanSnowFromRDI(Mike1DData m1DData) { if (m1DData.UseRR && m1DData.RainfallRunoffData != null) { // Loop over all catchments foreach (ICatchment catchment in m1DData.RainfallRunoffData.Catchments) { // Find the combined catchment if (catchment is CatchmentCombined) { // Find the two catchment models, being RDI+A or RDI+B CatchmentCombined catchmentCombined = catchment as CatchmentCombined; ICatchmentNamData catchmentNAM = null; // RDI catchment ICatchmentUrbanData catchmentUrb = null; // Urban catchment // Loop through all sub-catchments foreach (string subCatchId in catchmentCombined.SubCatchmentNames.Keys) { // Based on sub-catchment id, find actual catchment ICatchment c = m1DData.RainfallRunoffData.Catchments.Find(subCatchId); // Check if catchment is RDI/NAM or urban catchment (Model A/B) if (c is ICatchmentNamData) { catchmentNAM = (ICatchmentNamData)c; } if (c is ICatchmentUrbanData) { catchmentUrb = (ICatchmentUrbanData)c; } } // Check if both RDI and A/B was found if (catchmentNAM != null && catchmentUrb != null) { // Apply RDI snow parameters on urban catchment. catchmentUrb.UseSnowModule = catchmentNAM.IncludeSnow; // Convert from mm/day to m/s catchmentUrb.SnowMeltCoefficient = catchmentNAM.ConstDegreeDayCoef * 0.001 / (3600 * 24); } } } } }
public void CreateSumTotalRunoffCatchment(Mike1DData mike1DData) { CatchmentCombined sumTotalRunoffCatchment = new CatchmentCombined("SumAllCatchments") { ScaleByArea = false, Area = 1, }; double minTimestep = double.MaxValue; double maxTimestep = double.MinValue; foreach (ICatchment catchment in mike1DData.RainfallRunoffData.Catchments) { if (!(catchment is CatchmentCombined)) { sumTotalRunoffCatchment.AddNewCatchment(catchment.ModelId, 1.0); minTimestep = System.Math.Min(minTimestep, catchment.TimeStep.TotalSeconds); maxTimestep = System.Math.Max(maxTimestep, catchment.TimeStep.TotalSeconds); } } sumTotalRunoffCatchment.TimeStep = TimeSpan.FromSeconds(minTimestep); mike1DData.RainfallRunoffData.Catchments.Add(sumTotalRunoffCatchment); }
public void CreateSumAllCatchment(IMike1DController controller) { Mike1DData mike1DData = controller.Mike1DData; sumTotalRunoffCatchment = new CatchmentCombined("SumAllCatchments") { ScaleByArea = false, Area = 1, }; double minTimestep = double.MaxValue; double maxTimestep = double.MinValue; foreach (ICatchment catchment in mike1DData.RainfallRunoffData.Catchments) { if (!(catchment is CatchmentCombined)) { sumTotalRunoffCatchment.AddNewCatchment(catchment.ModelId, 1.0); minTimestep = System.Math.Min(minTimestep, catchment.TimeStep.TotalSeconds); maxTimestep = System.Math.Max(maxTimestep, catchment.TimeStep.TotalSeconds); } } sumTotalRunoffCatchment.TimeStep = TimeSpan.FromSeconds(minTimestep); mike1DData.RainfallRunoffData.Catchments.Add(sumTotalRunoffCatchment); // Setup writer to write total runoff to csv file writer = new StreamWriter("SumTotalRunoff.csv"); writer.WriteLine("sep=;"); sumTotalRunoffCatchment.PostTimeStepEvent += delegate(DateTime time) { writer.WriteLine("{0};{1}", time.ToString(Util.DateTimeFormatString), runoffGetter().ToString(CultureInfo.InvariantCulture)); }; controller.ControllerEvent += HandleControllerEvent; }