Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
V
VIPSLogic
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VIPS
VIPSLogic
Commits
6ba326d1
Commit
6ba326d1
authored
2 years ago
by
Tor-Einar Skog
Browse files
Options
Downloads
Patches
Plain Diff
Roughage: Custom growth start calc date [GROVFOR-10]
parent
8e05df6c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/no/nibio/vips/logic/modules/roughage/RoughageService.java
+16
-12
16 additions, 12 deletions
...no/nibio/vips/logic/modules/roughage/RoughageService.java
with
16 additions
and
12 deletions
src/main/java/no/nibio/vips/logic/modules/roughage/RoughageService.java
+
16
−
12
View file @
6ba326d1
...
...
@@ -104,6 +104,7 @@ public class RoughageService {
@QueryParam
(
"wateringAffectsNormalData"
)
String
wateringAffectsNormalData
,
@QueryParam
(
"firstHarvest"
)
String
firstHarvestStr
,
@QueryParam
(
"secondHarvest"
)
String
secondHarvestStr
,
@QueryParam
(
"firstPossibleGrowthStartDate"
)
String
firstPossibleGrowthStartDateStr
,
@QueryParam
(
"soilType"
)
Integer
soilType
,
@QueryParam
(
"cloverShare"
)
Integer
cloverShare
,
@QueryParam
(
"userWeatherScenarios"
)
String
useWeatherScenarios
,
...
...
@@ -119,21 +120,23 @@ public class RoughageService {
TimeZone
timeZone
=
TimeZone
.
getTimeZone
(
timeZoneStr
);
Date
firstHarvest
=
parseUtil
.
parseISODate
(
firstHarvestStr
,
timeZone
);
Date
secondHarvest
=
secondHarvestStr
!=
null
?
parseUtil
.
parseISODate
(
secondHarvestStr
,
timeZone
)
:
null
;
// Calculating start and end date of weather data retrieval
// Start is April 1st
Calendar
cal
=
Calendar
.
getInstance
(
timeZone
);
cal
.
setTime
(
firstHarvest
);
cal
.
set
(
Calendar
.
MONTH
,
Calendar
.
MARCH
);
cal
.
set
(
Calendar
.
DATE
,
1
);
// Calculating start and end date of weather data retrieval
// Start is March 1st unless specified otherwise
Date
firstPossibleGrowthStartDate
=
firstPossibleGrowthStartDateStr
!=
null
?
parseUtil
.
parseISODate
(
firstPossibleGrowthStartDateStr
,
timeZone
)
:
null
;
WeatherUtil
wUtil
=
new
WeatherUtil
();
Date
marchFirst
=
wUtil
.
normalizeToExactDate
(
cal
.
getTime
(),
timeZone
);
Calendar
cal
=
Calendar
.
getInstance
(
timeZone
);
if
(
firstPossibleGrowthStartDate
==
null
)
{
cal
.
setTime
(
firstHarvest
);
cal
.
set
(
Calendar
.
MONTH
,
Calendar
.
MARCH
);
cal
.
set
(
Calendar
.
DATE
,
1
);
firstPossibleGrowthStartDate
=
wUtil
.
normalizeToExactDate
(
cal
.
getTime
(),
timeZone
);
}
// End date for weather data depends on season
// We try September 30th. If that's in the future,
// We add 10 days to today
Date
dateOfLastWeatherData
;
cal
.
setTime
(
marchFirst
);
cal
.
setTime
(
firstPossibleGrowthStartDate
);
cal
.
set
(
Calendar
.
MONTH
,
Calendar
.
SEPTEMBER
);
cal
.
set
(
Calendar
.
DATE
,
30
);
Date
endOfSeptember
=
cal
.
getTime
();
...
...
@@ -164,7 +167,7 @@ public class RoughageService {
WeatherElements
.
SOIL_TEMPERATURE_10CM_MEAN
,
WeatherElements
.
POTENTIAL_EVAPORATION
},
marchFirst
,
firstPossibleGrowthStartDate
,
dateOfLastWeatherData
);
}
catch
(
WeatherDataSourceException
ex
)
{
...
...
@@ -367,9 +370,10 @@ public class RoughageService {
config
.
setConfigParameter
(
"observations"
,
observations
);
config
.
setConfigParameter
(
"timeZone"
,
timeZone
.
getID
());
config
.
setConfigParameter
(
"firstHarvest"
,
firstHarvest
);
config
.
setConfigParameter
(
"firstPossibleGrowthStartDate"
,
firstPossibleGrowthStartDate
);
config
.
setConfigParameter
(
"soilType"
,
soilType
);
config
.
setConfigParameter
(
"cloverShare"
,
cloverShare
);
// Optional parameters
if
(
secondHarvest
!=
null
)
{
...
...
@@ -426,7 +430,7 @@ public class RoughageService {
WeatherElements
.
SOIL_TEMPERATURE_10CM_MEAN
,
WeatherElements
.
POTENTIAL_EVAPORATION
},
marchFirst
,
firstPossibleGrowthStartDate
,
//dateOfLastWeatherData
latestObsDate
);
...
...
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