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
a08b1cac
Commit
a08b1cac
authored
2 years ago
by
Tucker Gary Siegel
Browse files
Options
Downloads
Patches
Plain Diff
confidence interval repeat years
parent
1bf3a553
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
controllers/misc_controller.go
+1
-0
1 addition, 0 deletions
controllers/misc_controller.go
models/confidence_interval.go
+11
-0
11 additions, 0 deletions
models/confidence_interval.go
services/confidence_interval_service.go
+11
-2
11 additions, 2 deletions
services/confidence_interval_service.go
with
23 additions
and
2 deletions
controllers/misc_controller.go
+
1
−
0
View file @
a08b1cac
...
@@ -53,6 +53,7 @@ func GetAnalogYear(c *fiber.Ctx) error {
...
@@ -53,6 +53,7 @@ func GetAnalogYear(c *fiber.Ctx) error {
// @Param latitude query number true "Latitude to search for"
// @Param latitude query number true "Latitude to search for"
// @Param longitude query number true "Longitude to search for"
// @Param longitude query number true "Longitude to search for"
// @Param plantingDate query string true "Plant date, ISO8601 or RFC3339 format"
// @Param plantingDate query string true "Plant date, ISO8601 or RFC3339 format"
// @Param repeatYears query number false "number of times to repeat the request. When included with planting date, will extrapolate plantingdate -> end of repeatYears range"
// @Router /gdd/confidence [get]
// @Router /gdd/confidence [get]
func
GetConfidenceInterval
(
c
*
fiber
.
Ctx
)
error
{
func
GetConfidenceInterval
(
c
*
fiber
.
Ctx
)
error
{
r
:=
models
.
ConfidenceIntervalRequest
{}
.
Build
(
c
)
r
:=
models
.
ConfidenceIntervalRequest
{}
.
Build
(
c
)
...
...
This diff is collapsed.
Click to expand it.
models/confidence_interval.go
+
11
−
0
View file @
a08b1cac
...
@@ -21,6 +21,7 @@ type ConfidenceIntervalRequest struct {
...
@@ -21,6 +21,7 @@ type ConfidenceIntervalRequest struct {
Longitude
float64
`json:"longitude"`
Longitude
float64
`json:"longitude"`
Interval
float64
`json:"interval"`
Interval
float64
`json:"interval"`
PlantingDate
time
.
Time
`json:"plantingDate"`
PlantingDate
time
.
Time
`json:"plantingDate"`
RepeatYears
int
`json:"repeatYears"`
}
}
type
ConfidenceIntervalResposne
struct
{
type
ConfidenceIntervalResposne
struct
{
...
@@ -67,6 +68,15 @@ func (r ConfidenceIntervalRequest) Validate() error {
...
@@ -67,6 +68,15 @@ func (r ConfidenceIntervalRequest) Validate() error {
}
}
func
(
r
ConfidenceIntervalRequest
)
Build
(
c
*
fiber
.
Ctx
)
ConfidenceIntervalRequest
{
func
(
r
ConfidenceIntervalRequest
)
Build
(
c
*
fiber
.
Ctx
)
ConfidenceIntervalRequest
{
repeatYears
,
errYears
:=
strconv
.
Atoi
(
c
.
Query
(
"repeatYears"
,
"1"
))
if
errYears
!=
nil
{
panic
(
errors
.
NewBadRequest
(
nil
)
.
PutDetail
(
"reason"
,
"repeat years must be an integer"
))
}
if
repeatYears
<
1
||
repeatYears
>
3
{
panic
(
errors
.
NewBadRequest
(
nil
)
.
PutDetail
(
"reason"
,
"repeat years must be between 1 and 3 inclusive"
))
}
product
:=
c
.
Query
(
"product"
,
"NONE"
)
product
:=
c
.
Query
(
"product"
,
"NONE"
)
latitude
,
_
:=
strconv
.
ParseFloat
(
c
.
Query
(
"latitude"
,
"-100000.0"
),
64
)
latitude
,
_
:=
strconv
.
ParseFloat
(
c
.
Query
(
"latitude"
,
"-100000.0"
),
64
)
longitude
,
_
:=
strconv
.
ParseFloat
(
c
.
Query
(
"longitude"
,
"-100000.0"
),
64
)
longitude
,
_
:=
strconv
.
ParseFloat
(
c
.
Query
(
"longitude"
,
"-100000.0"
),
64
)
...
@@ -88,6 +98,7 @@ func (r ConfidenceIntervalRequest) Build(c *fiber.Ctx) ConfidenceIntervalRequest
...
@@ -88,6 +98,7 @@ func (r ConfidenceIntervalRequest) Build(c *fiber.Ctx) ConfidenceIntervalRequest
Longitude
:
longitude
,
Longitude
:
longitude
,
Interval
:
interval
,
Interval
:
interval
,
PlantingDate
:
plantingDate
,
PlantingDate
:
plantingDate
,
RepeatYears
:
repeatYears
,
}
}
if
rNew
.
Validate
()
!=
nil
{
if
rNew
.
Validate
()
!=
nil
{
...
...
This diff is collapsed.
Click to expand it.
services/confidence_interval_service.go
+
11
−
2
View file @
a08b1cac
...
@@ -14,6 +14,11 @@ func GetConfidenceInterval(request models.ConfidenceIntervalRequest) models.Conf
...
@@ -14,6 +14,11 @@ func GetConfidenceInterval(request models.ConfidenceIntervalRequest) models.Conf
// zScore := models.IntervalConvert[request.Interval]
// zScore := models.IntervalConvert[request.Interval]
// zScore := models.IntervalConvertPercentiles[request.Interval]
// zScore := models.IntervalConvertPercentiles[request.Interval]
r
:=
1
if
request
.
RepeatYears
>
0
{
r
=
request
.
RepeatYears
}
var
lowerBound
[]
float64
var
lowerBound
[]
float64
var
upperBound
[]
float64
var
upperBound
[]
float64
...
@@ -26,10 +31,14 @@ func GetConfidenceInterval(request models.ConfidenceIntervalRequest) models.Conf
...
@@ -26,10 +31,14 @@ func GetConfidenceInterval(request models.ConfidenceIntervalRequest) models.Conf
}
}
rows
:=
[][]
float64
{}
rows
:=
[][]
float64
{}
for
i
:=
sliceDateInt
;
i
<
len
(
gs
[
0
]
.
MinTemps
);
i
++
{
for
i
:=
sliceDateInt
;
i
<
len
(
gs
[
0
]
.
MinTemps
)
*
r
;
i
++
{
row
:=
[]
float64
{}
row
:=
[]
float64
{}
idx
:=
i
if
i
>=
len
(
gs
[
0
]
.
MinTemps
)
{
idx
-=
len
(
gs
[
0
]
.
MinTemps
)
}
for
j
:=
0
;
j
<
len
(
gs
);
j
++
{
for
j
:=
0
;
j
<
len
(
gs
);
j
++
{
row
=
append
(
row
,
utils
.
CalculateSingleGdd
(
gs
[
j
]
.
MinTemps
[
i
],
gs
[
j
]
.
MaxTemps
[
i
],
product
))
row
=
append
(
row
,
utils
.
CalculateSingleGdd
(
gs
[
j
]
.
MinTemps
[
i
dx
],
gs
[
j
]
.
MaxTemps
[
i
dx
],
product
))
if
i
>
sliceDateInt
{
if
i
>
sliceDateInt
{
row
[
j
]
+=
rows
[
len
(
rows
)
-
1
][
j
]
row
[
j
]
+=
rows
[
len
(
rows
)
-
1
][
j
]
}
}
...
...
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