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

change

parent 01909870
No related branches found
No related tags found
No related merge requests found
......@@ -49,7 +49,7 @@ func buildLocationRequestLarger(location entities.Location, year *int) bson.M {
"location": bson.M{
"$nearSphere": bson.M{
"$geometry": location,
"$maxDistance": 150000,
"$maxDistance": 100000,
},
},
"year": *year,
......@@ -59,7 +59,7 @@ func buildLocationRequestLarger(location entities.Location, year *int) bson.M {
"location": bson.M{
"$nearSphere": bson.M{
"$geometry": location,
"$maxDistance": 150000,
"$maxDistance": 100000,
},
},
}
......@@ -148,7 +148,6 @@ func CfsFindAllByLocation(location entities.Location) entities.CfsGdd {
coll := Session.Collection("cfs")
filter := buildLocationRequestLarger(location, nil)
var g entities.CfsGdd
err := coll.FindOne(Session.Ctx, filter).Decode(&g)
......
......@@ -29,6 +29,7 @@ func GetStageYearData(ctx common.DawnCtx, request models.GddRequest) models.Stag
minGdds = append(minGdds, analogYearData.GddValues[len(minGdds):]...)
maxGdds = append(maxGdds, analogYearData.GddValues[len(maxGdds):]...)
}
// fmt.Println(time.Since(t).Milliseconds())
returnData := models.StageData{
MeanGdds: meanGdds,
......@@ -60,7 +61,6 @@ func CalculateStages(ctx common.DawnCtx, request models.StageRequest) map[string
state := map[string]models.StageStateInner{}
stageMatches := models.BuildStageMatches(request.Mode, request.Value)
for i := start; i < len(fyData.MaxGdds); i++ {
accMin += fyData.MinGdds[i]
......
......@@ -57,25 +57,27 @@ func GetGefsGddValues(request models.GddRequest) models.GefsGddResponse {
}
func GetCfsGddValues(request models.GddRequest) models.CfsGddResponse {
product := enums.GetProductFromString(request.Product)
location := request.BuildLocation()
g := persistence.CfsFindAllByLocation(location)
product := enums.GetProductFromString(request.Product)
var returnGdds models.CfsGddResponse
var gdds []float64
var lowerBound []float64
var upperBound []float64
factor := math.Pow(float64(g.Count), 0.5)
for i := 0; i < len(g.MaxTemps); i++ {
variance := (g.VarMin[i] + g.VarMax[i])
variance *= math.Pow(0.5, 2)
variance *= 0.25 // 0.5 ^ 2
std := math.Pow(variance, 0.5)
value := utils.CalculateSingleGdd(g.MinTemps[i], g.MaxTemps[i], product)
lowerBoundValue := (value - (std / (math.Pow(float64(g.Count), 0.5)) * 1.960))
upperBoundValue := (value + (std / (math.Pow(float64(g.Count), 0.5)) * 1.960))
lowerBoundValue := (value - (std / factor * 1.960))
upperBoundValue := (value + (std / factor * 1.960))
lowerBoundValue = utils.ClipMinFloat(lowerBoundValue, 0.0)
upperBoundValue = utils.ClipMinFloat(upperBoundValue, 0.0)
......
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