/// <summary> /// Creates Summary Crop Water Use Charts /// </summary> /// <param name="cbtt"></param> /// <param name="t"></param> /// <returns></returns> private static List <string> CreateSummaryReport(string cbtt, DateTime t, CropDatesDataSet.CropDatesRow[] cropRow) { var rval = new List <string>(); //var cropRow = CropDatesDataSet.GetCropFiles(t.Year, cbtt); var et = new HydrometDailySeries(cbtt, "ETRS"); //var et = new KimberlyPenmanEtSeries(cbtt); // Below is the calculation to determine how many days to read back. Set to calculate based on ETr Start Date. var etStartDate = cropRow[0].startdate.DayOfYear; var etTodayDate = t.DayOfYear; int numDaysRead = etTodayDate - etStartDate; et.Read(t.AddDays(-numDaysRead), t.AddDays(-1)); // Produces Summary Chart heading. rval.Add(" " + " " + cbtt + " - " + "ET SUMMARY" + " - " + t.ToString("yyyy") + " "); string s1 = " DATE "; string s2 = " "; string s5 = " ----"; for (int i = 0; i < cropRow.Length; i++) { var row = cropRow[i]; s1 = s1 + row.cropname.PadRight(5); //s2 = s2 + " " + row.UIDX.ToString("F0").PadLeft(3) + " "; s2 = s2 + " " + "".PadLeft(3) + " "; s5 = s5 + " " + "----"; } rval.Add(s2); rval.Add(s1); rval.Add(s5 + " "); // Populates Summary Chart by generating strings of ET values. string dateString = " "; for (int dateIndex = 1; dateIndex < numDaysRead; dateIndex++) { var t1 = et[dateIndex].DateTime; dateString = " " + t1.ToString("MM/dd").PadLeft(4); string valueString = ""; for (int cropIndex = 0; cropIndex < cropRow.Length; cropIndex++) { var row = cropRow[cropIndex]; var etValue = CropCurves.WaterUse(t1, et[dateIndex].Value, row); if (t1 < cropRow[cropIndex].startdate || t1 > cropRow[cropIndex].terminatedate) { valueString += " -- "; } else { valueString += etValue.ToString("F2").PadLeft(5); } } rval.Add(dateString + valueString); } return(rval); }
/// <summary> /// Calculates the Daily Crop ET. /// </summary> /// <param name="numDaysRead">Number of days between Chart Generation date and the Start Date</param> /// <param name="n">The number of days from today for which you want the Crop ET</param> /// <param name="et"></param> /// <param name="row"></param> /// <returns></returns> internal static string ETCropDaily(int numDaysRead, int n, HydrometDailySeries et, CropDatesDataSet.CropDatesRow row) { double val = 0.00; if (numDaysRead > n) { val = CropCurves.WaterUse(et[numDaysRead - n].DateTime, et[numDaysRead - n].Value, row); } else { } if (val < 0) { return("msng"); } else { return(val.ToString("F2")); } }