Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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;
        }