Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dawn-gdd
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
dawn
go-backend
dawn-gdd
Commits
65926eff
Commit
65926eff
authored
2 years ago
by
Tucker Gary Siegel
Browse files
Options
Downloads
Patches
Plain Diff
u
parent
7838e3fe
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
services/forecast_service.go
+26
-23
26 additions, 23 deletions
services/forecast_service.go
utils/dispatch/dispatch.go
+0
-2
0 additions, 2 deletions
utils/dispatch/dispatch.go
with
26 additions
and
25 deletions
services/forecast_service.go
+
26
−
23
View file @
65926eff
...
@@ -37,7 +37,8 @@ func getDatesForCfsMatches(cfs [][]float64, lastDateInt int, currentMatch int, k
...
@@ -37,7 +37,8 @@ func getDatesForCfsMatches(cfs [][]float64, lastDateInt int, currentMatch int, k
lastDist
:=
matches
[
keys
[
currentMatch
]]
lastDist
:=
matches
[
keys
[
currentMatch
]]
tempCMatch
:=
currentMatch
tempCMatch
:=
currentMatch
for
i
,
v
:=
range
c
{
for
i
,
v
:=
range
c
{
dist
:=
math
.
Abs
(
matches
[
keys
[
currentMatch
]]
-
v
)
dist
:=
math
.
Abs
(
matches
[
keys
[
tempCMatch
]]
-
v
)
// check if the last value is closer than the current. if it is, then the last value is the one to return
// 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
dist
>
lastDist
{
if
v
,
exists
:=
out
[
keys
[
tempCMatch
]];
exists
{
if
v
,
exists
:=
out
[
keys
[
tempCMatch
]];
exists
{
...
@@ -49,6 +50,7 @@ func getDatesForCfsMatches(cfs [][]float64, lastDateInt int, currentMatch int, k
...
@@ -49,6 +50,7 @@ func getDatesForCfsMatches(cfs [][]float64, lastDateInt int, currentMatch int, k
if
tempCMatch
>=
len
(
keys
)
{
if
tempCMatch
>=
len
(
keys
)
{
break
break
}
}
dist
=
matches
[
keys
[
tempCMatch
]]
}
}
lastDist
=
dist
lastDist
=
dist
}
}
...
@@ -120,41 +122,42 @@ func forecast(ctx common.DawnCtx, gddReq models.GddRequest, plantdate time.Time,
...
@@ -120,41 +122,42 @@ func forecast(ctx common.DawnCtx, gddReq models.GddRequest, plantdate time.Time,
// start at plantdate, begin accumulating OBSERVED until we run out
// start at plantdate, begin accumulating OBSERVED until we run out
// since this observed, we should only have 1 bin with a value of 100%
// since this observed, we should only have 1 bin with a value of 100%
// at the end, we should have all observed stages along with all accumulated gdds of the planting year
// at the end, we should have all observed stages along with all accumulated gdds of the planting year
observedValues
:=
observed
.
GddValues
[
start
:
]
accumulatedGdds
:=
0.0
accumulatedGdds
:=
0.0
lastDist
:=
matches
[
keys
[
currentMatch
]]
date
:=
0
date
:=
0
for
i
:=
0
;
i
<
len
(
observedValues
);
i
++
{
date
=
i
if
start
<
len
(
observed
.
GddValues
)
{
dist
:=
math
.
Abs
(
matches
[
keys
[
currentMatch
]]
-
accumulatedGdds
)
observedValues
:=
observed
.
GddValues
[
start
:
]
// check if the last value is closer than the current. if it is, then the last value is the one to return
lastDist
:=
matches
[
keys
[
currentMatch
]]
if
dist
>
lastDist
{
for
i
:=
0
;
i
<
len
(
observedValues
);
i
++
{
out
[
keys
[
currentMatch
]]
=
&
models
.
Bins
{
date
=
i
Bins
:
[]
models
.
Bin
{
dist
:=
math
.
Abs
(
matches
[
keys
[
currentMatch
]]
-
accumulatedGdds
)
{
// check if the last value is closer than the current. if it is, then the last value is the one to return
Value
:
1
,
if
dist
>
lastDist
{
Date
:
plantdate
.
AddDate
(
0
,
0
,
i
-
1
),
out
[
keys
[
currentMatch
]]
=
&
models
.
Bins
{
Bins
:
[]
models
.
Bin
{
{
Value
:
1
,
Date
:
plantdate
.
AddDate
(
0
,
0
,
i
-
1
),
},
},
},
},
}
}
currentMatch
+=
1
currentMatch
+=
1
if
currentMatch
>=
len
(
keys
)
{
if
currentMatch
>=
len
(
keys
)
{
break
break
}
dist
=
matches
[
keys
[
currentMatch
]]
}
}
dist
=
matches
[
keys
[
currentMatch
]]
accumulatedGdds
+=
observedValues
[
i
]
lastDist
=
dist
}
}
accumulatedGdds
+=
observedValues
[
i
]
lastDist
=
dist
}
}
if
currentMatch
==
len
(
keys
)
{
if
currentMatch
==
len
(
keys
)
{
return
out
return
out
}
}
// adjust cfs values to start at the accumulated value
// adjust cfs values to start at the accumulated value
adjustedCfs
:=
calculateAccumulatedCfsBasedOnAccumulatedObserved
(
product
,
accumulatedGdds
,
cfs
)
adjustedCfs
:=
calculateAccumulatedCfsBasedOnAccumulatedObserved
(
product
,
accumulatedGdds
,
cfs
)
cfsHist
:=
getDatesForCfsMatches
(
adjustedCfs
,
date
,
currentMatch
,
keys
,
matches
)
cfsHist
:=
getDatesForCfsMatches
(
adjustedCfs
,
date
,
currentMatch
,
keys
,
matches
)
// this loop will actually build the 5 bins
// this loop will actually build the 5 bins
for
k
,
v
:=
range
cfsHist
{
for
k
,
v
:=
range
cfsHist
{
...
...
This diff is collapsed.
Click to expand it.
utils/dispatch/dispatch.go
+
0
−
2
View file @
65926eff
...
@@ -18,8 +18,6 @@ Example:
...
@@ -18,8 +18,6 @@ Example:
gddThread.Result(gdds)
gddThread.Result(gdds)
}()
}()
gddThread.Wait()
gdds, err := gddThread.Get()
gdds, err := gddThread.Get()
if err != nil {
if err != nil {
panic(err)
panic(err)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment