Skip to content
Snippets Groups Projects
Commit 55cf8c0a authored by Tucker Gary Siegel's avatar Tucker Gary Siegel
Browse files

possible fix

parent 00db1255
No related branches found
Tags 1.0.0
No related merge requests found
......@@ -20,8 +20,9 @@ func calculateAccumulatedCfsBasedOnAccumulatedObserved(product enums.Product, st
for _, c := range cfs {
tempAccum := accumulated
temp := []float64{}
sd := startDate - c.Date.Time().YearDay()
for i := range c.MinTemps {
if i < startDate {
if i < sd {
continue
}
tempAccum = tempAccum + utils.CalculateSingleGdd(c.MinTemps[i], c.MaxTemps[i], product)
......@@ -42,11 +43,11 @@ func getDatesForCfsMatches(cfs [][]float64, lastDateInt int, currentMatch int, k
for i, v := range c {
dist := math.Abs(matches[keys[tempCMatch]] - v)
// if z == 0 {
// 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 {
// if z == 0 {
// fmt.Println(keys[tempCMatch], dist, matches[keys[tempCMatch]], v, lastDateInt+i-1, tempCMatch, len(keys))
// }
if v, exists := out[keys[tempCMatch]]; exists {
out[keys[tempCMatch]] = append(v, lastDateInt+i-1)
} else {
......@@ -170,7 +171,7 @@ func forecast(ctx context.Context, gddReq models.GddRequest, plantdate time.Time
lastDist = dist
}
} else {
date = gddReq.PlantingDate.YearDay() - 1
date = gddReq.PlantingDate.YearDay()
}
if currentMatch == len(keys) {
......@@ -180,6 +181,10 @@ 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(cfsHist)
// for k, v := range cfsHist {
// fmt.Println(k, v)
// }
// fmt.Println(date)
for k, v := range cfsHist {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment