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
Merge requests
!1
Added preprocessor for FINNCEREAL model.
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Added preprocessor for FINNCEREAL model.
Luke
into
master
Overview
0
Commits
1
Pipelines
0
Changes
2
Merged
Jussi Nikander
requested to merge
Luke
into
master
7 years ago
Overview
0
Commits
1
Pipelines
0
Changes
2
Expand
My modifications to VIPSLogic.
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
2f1d2341
1 commit,
7 years ago
2 files
+
172
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
src/main/java/no/nibio/vips/logic/scheduling/model/preprocessor/FinnCerealModelsPreprocessor.java
0 → 100644
+
95
−
0
Options
package
no.nibio.vips.logic.scheduling.model.preprocessor
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
no.nibio.vips.entity.ModelConfiguration
;
import
no.nibio.vips.entity.WeatherObservation
;
import
no.nibio.vips.logic.entity.ForecastConfiguration
;
import
no.nibio.vips.logic.entity.PointOfInterestWeatherStation
;
import
no.nibio.vips.logic.scheduling.model.ModelRunPreprocessor
;
import
no.nibio.vips.logic.scheduling.model.PreprocessorException
;
import
no.nibio.vips.model.ConfigValidationException
;
import
no.nibio.vips.util.WeatherElements
;
import
no.nibio.vips.util.WeatherObservationListException
;
import
no.nibio.vips.util.WeatherUtil
;
import
no.nibio.vips.util.weather.WeatherDataSourceException
;
import
no.nibio.vips.util.weather.WeatherDataSourceUtil
;
public
class
FinnCerealModelsPreprocessor
extends
ModelRunPreprocessor
{
public
static
final
String
SOWING_DATE
=
"FINNCEREAL_FIELD_SOWING_DATE"
;
public
static
final
String
PREVIOUS_CROP
=
"FINNCEREAL_PREVIOUS_CROP"
;
public
static
final
String
TILLAGE
=
"FINNCEREAL_TILLAGE_METHOD"
;
public
static
final
String
SUSCEPTIBILITY
=
"FINNCEREAL_CROP_SUSCEPTIBILITY"
;
public
static
final
String
MODEL
=
"FINNCEREAL_MODEL_NAME"
;
/**
* This method implementation is based on the DOWNCASTModelPreprocessor implemention of getModelCOnfiguration.
*/
@Override
public
ModelConfiguration
getModelConfiguration
(
ForecastConfiguration
configuration
)
throws
PreprocessorException
{
ModelConfiguration
config
=
new
ModelConfiguration
();
PointOfInterestWeatherStation
weatherStation
=
(
PointOfInterestWeatherStation
)
configuration
.
getWeatherStationPointOfInterestId
();
WeatherDataSourceUtil
wdsUtil
=
new
WeatherDataSourceUtil
();
WeatherUtil
wUtil
=
new
WeatherUtil
();
List
<
WeatherObservation
>
observations
;
Date
sowingDate
=
null
;
SimpleDateFormat
format
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
try
{
sowingDate
=
format
.
parse
(
configuration
.
getForecastModelConfigurationValue
(
SOWING_DATE
));
observations
=
wdsUtil
.
getWeatherObservations
(
weatherStation
,
WeatherObservation
.
LOG_INTERVAL_ID_1H
,
new
String
[]{
WeatherElements
.
WIND_SPEED_2M
,
WeatherElements
.
WIND_SPEED_10MIN_2M
,
WeatherElements
.
RELATIVE_HUMIDITY_MEAN
,
WeatherElements
.
PRECIPITATION
,
WeatherElements
.
TEMPERATURE_MEAN
},
sowingDate
,
configuration
.
getDateEndInTimeZone
());
observations
=
wUtil
.
checkForAndFixHourlyTimeSeriesHoles
(
observations
);
List
<
WeatherObservation
>
temperature
=
observations
.
stream
().
filter
(
t
->
t
.
getElementMeasurementTypeId
().
equals
(
WeatherElements
.
TEMPERATURE_MEAN
))
.
collect
(
Collectors
.
toList
());
List
<
WeatherObservation
>
rainfall
=
observations
.
stream
().
filter
(
t
->
t
.
getElementMeasurementTypeId
().
equals
(
WeatherElements
.
PRECIPITATION
))
.
collect
(
Collectors
.
toList
());
List
<
WeatherObservation
>
rh
=
observations
.
stream
().
filter
(
t
->
t
.
getElementMeasurementTypeId
().
equals
(
WeatherElements
.
RELATIVE_HUMIDITY_MEAN
))
.
collect
(
Collectors
.
toList
());
List
<
WeatherObservation
>
windSpeedAll
=
observations
.
stream
().
filter
(
t
->
t
.
getElementMeasurementTypeId
().
equals
(
WeatherElements
.
WIND_SPEED_2M
))
.
collect
(
Collectors
.
toList
());
if
(
windSpeedAll
.
isEmpty
())
{
windSpeedAll
=
observations
.
stream
().
filter
(
t
->
t
.
getElementMeasurementTypeId
().
equals
(
WeatherElements
.
WIND_SPEED_10MIN_2M
))
.
collect
(
Collectors
.
toList
());
}
config
.
setModelId
(
this
.
getModelId
());
config
.
setConfigParameter
(
"timeZone"
,
weatherStation
.
getTimeZone
());
config
.
setConfigParameter
(
"temperature"
,
temperature
);
config
.
setConfigParameter
(
"rainfall"
,
rainfall
);
config
.
setConfigParameter
(
"rh"
,
rh
);
config
.
setConfigParameter
(
"windspeed"
,
windSpeedAll
);
config
.
setConfigParameter
(
"precedingCrop"
,
configuration
.
getForecastModelConfigurationValue
(
PREVIOUS_CROP
));
config
.
setConfigParameter
(
"tillageMethod"
,
configuration
.
getForecastModelConfigurationValue
(
TILLAGE
));
config
.
setConfigParameter
(
"diseaseSusceptibility"
,
configuration
.
getForecastModelConfigurationValue
(
SUSCEPTIBILITY
));
config
.
setConfigParameter
(
"model"
,
configuration
.
getForecastModelConfigurationValue
(
MODEL
));
}
catch
(
WeatherDataSourceException
|
WeatherObservationListException
|
ParseException
ex
)
{
throw
new
PreprocessorException
(
ex
.
getMessage
());
}
return
config
;
}
@Override
public
String
getModelId
()
{
return
"FINNCEREAL"
;
}
}
Loading