diff --git a/services/forecast_service.go b/services/forecast_service.go index 71dd7f419db6d5319630f88ca93b51309056b571..07d18d25242ceb58c5e58beb07f733cd767352d4 100644 --- a/services/forecast_service.go +++ b/services/forecast_service.go @@ -43,7 +43,7 @@ func getDatesForCfsMatches(cfs [][]float64, lastDateInt int, currentMatch int, k dist := math.Abs(matches[keys[tempCMatch]] - v) // if z == 0 { - // fmt.Println(keys[tempCMatch], dist, matches[keys[tempCMatch]], v, lastDateInt+i-1) + // fmt.Println(keys[tempCMatch], dist, matches[keys[tempCMatch]], v, lastDateInt+i-1, tempCMatch, len(keys)) // } // check if the last value is closer than the current. if it is, then the last value is the one to return if dist > lastDist { @@ -180,6 +180,7 @@ func forecast(ctx context.Context, gddReq models.GddRequest, plantdate time.Time adjustedCfs := calculateAccumulatedCfsBasedOnAccumulatedObserved(product, date, accumulatedGdds, cfs) cfsHist := getDatesForCfsMatches(adjustedCfs, date, currentMatch, keys, matches) // this loop will actually build the 5 bins + // fmt.Println(date) for k, v := range cfsHist { binnedDates, keys, largestKey := bin(v) @@ -207,13 +208,16 @@ func forecast(ctx context.Context, gddReq models.GddRequest, plantdate time.Time min += stepSize } + // fmt.Println(k, temp) + // convert to output model bins := []models.Bin{} c := 0 for d, v := range temp { + fdoy := time.Date(plantdate.Year(), time.January, 1, 0, 0, 0, 0, plantdate.Location()) bins = append(bins, models.Bin{ Value: (float64(v) + alpha) / (float64(sum) + float64(binCount)*alpha), - Date: plantdate.AddDate(0, 0, d-date), + Date: fdoy.AddDate(0, 0, d), }) c += 1 }