private static Series HGHTarget(FloodControlPoint pt, double forecastValue, DateTime t1, DateTime t2) { HydrometRuleCurve m_ruleCurve = RuleCurveFactory.Create(pt, 7100); Series target = new Series("Target"); string flag = ""; DateTime t = t1; while (t < t2.AddDays(-1)) { t = t.AddDays(1).Date; double val = -m_ruleCurve.LookupRequiredSpace(t, forecastValue, out flag) * pt.PercentSpace / 100 + pt.TotalUpstreamActiveSpace; target.Add(t, val); } return(target); }
/// <summary> /// Create a list of targts /// </summary> /// <param name="pt"></param> /// <param name="waterYear"></param> /// <param name="start"></param> /// <param name="optionalPercents"></param> /// <param name="m_ruleCurve"></param> /// <param name="t2"></param> /// <param name="forecastMonth"></param> /// <param name="forecastValue"></param> /// <returns></returns> private static SeriesList GetTargets(FloodControlPoint pt, int waterYear, Point start, int[] optionalPercents, int forecastMonth, double forecastValue, bool dashed) { SeriesList rval = new SeriesList(); HydrometRuleCurve m_ruleCurve = RuleCurveFactory.Create(pt, 7100, dashed); var t1 = new DateTime(waterYear, pt.ForecastMonthStart, 1); var t2 = new DateTime(waterYear, pt.ForecastMonthEnd, 1).EndOfMonth(); var avg30yrQU = Get30YearAverageSeries(pt.DailyStationQU, "qu", forecastMonth); // sum volume for the forecast period var t = new DateTime(start.DateTime.Year, start.DateTime.Month, 1); double historicalAverageResidual = SumResidual(avg30yrQU, t, t2); // capture if running the process before forecast season starts (before Jan) if (DateTime.Now.Month > 9) { historicalAverageResidual = SumResidual(avg30yrQU, t.AddYears(1), t2.AddYears(1)); } double percent = forecastValue / historicalAverageResidual; //get thirty year average QU from daily //avg30yrQU = Get30YearAverageSeries(pt.DailyStationQU, "qu", forecastMonth); Series targetx = CalculateTarget(pt, percent, waterYear, start, m_ruleCurve, avg30yrQU, t2, forecastValue); targetx.Name = "Forecast (" + (100 * percent).ToString("F0") + "%)" + (forecastValue / 1000.0).ToString("F0"); //targetx.Add(start); rval.Add(targetx); for (int i = 0; i < optionalPercents.Length; i++) { var fc = historicalAverageResidual * optionalPercents[i] / 100.0; targetx = CalculateTarget(pt, optionalPercents[i] / 100.0, waterYear, start, m_ruleCurve, avg30yrQU , t2, fc); targetx.Name = "Target (" + optionalPercents[i].ToString("F0") + "%) "; //targetx.Add(start); rval.Add(targetx); } return(rval); }