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
!29
Model leaf
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Model leaf
modelLeaf
into
develop
Overview
0
Commits
2
Pipelines
0
Changes
3
Merged
Tor-Einar Skog
requested to merge
modelLeaf
into
develop
2 years ago
Overview
0
Commits
2
Pipelines
0
Changes
3
Expand
Added preprocessor for the LEAFBLOTCH model
0
0
Merge request reports
Compare
develop
develop (base)
and
latest version
latest version
0120be00
2 commits,
2 years ago
3 files
+
151
−
1
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
Search (e.g. *.vue) (Ctrl+P)
src/main/java/no/nibio/vips/logic/scheduling/model/preprocessor/LeafBlotchModelPreprocessor.java
0 → 100644
+
122
−
0
Options
/*
* Copyright (c) 2022 NIBIO <http://www.nibio.no/>.
*
* This file is part of VIPSLogic.
* VIPSLogic is free software: you can redistribute it and/or modify
* it under the terms of the NIBIO Open Source License as published by
* NIBIO, either version 1 of the License, or (at your option) any
* later version.
*
* VIPSLogic is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* NIBIO Open Source License for more details.
*
* You should have received a copy of the NIBIO Open Source License
* along with VIPSLogic. If not, see <http://www.nibio.no/licenses/>.
*
*/
package
no.nibio.vips.logic.scheduling.model.preprocessor
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.TimeZone
;
import
java.util.logging.Logger
;
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.logic.util.SystemTime
;
import
no.nibio.vips.util.WeatherElements
;
import
no.nibio.vips.util.WeatherUtil
;
import
no.nibio.vips.util.weather.WeatherDataSourceException
;
import
no.nibio.vips.util.weather.WeatherDataSourceUtil
;
/**
*
* @author mila
*/
public
class
LeafBlotchModelPreprocessor
extends
ModelRunPreprocessor
{
public
final
static
String
LEAFBLOTCH_sowingDate
=
"LEAFBLOTCH_SOWING_DATE"
;
@Override
public
ModelConfiguration
getModelConfiguration
(
ForecastConfiguration
configuration
)
throws
PreprocessorException
{
PointOfInterestWeatherStation
weatherStation
=
(
PointOfInterestWeatherStation
)
configuration
.
getWeatherStationPointOfInterestId
();
//Latitude for the calculation
Double
latitude
=
weatherStation
.
getLatitude
();
// What timezone is the calculation for
TimeZone
timeZone
=
TimeZone
.
getTimeZone
(
weatherStation
.
getTimeZone
());
Calendar
cal
=
Calendar
.
getInstance
(
timeZone
);
cal
.
setTime
(
SystemTime
.
getSystemTime
());
cal
.
add
(
Calendar
.
DATE
,
3
);
WeatherUtil
wUtil
=
new
WeatherUtil
();
Date
endDate
=
wUtil
.
normalizeToExactDate
(
cal
.
getTime
(),
timeZone
);
SimpleDateFormat
format
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
format
.
setTimeZone
(
timeZone
);
Date
startDate
=
null
;
try
{
startDate
=
format
.
parse
(
configuration
.
getForecastModelConfigurationValue
(
LEAFBLOTCH_sowingDate
));
}
catch
(
ParseException
ex
)
{
//Logger.getLogger(LeafBlotchModelPreprocess.class.getName()).log(Level.SEVERE, null, ex);
}
ModelConfiguration
retVal
=
new
ModelConfiguration
();
WeatherDataSourceUtil
wdsUtil
=
new
WeatherDataSourceUtil
();
//Hourly weather observations:
List
<
WeatherObservation
>
observations
;
try
{
observations
=
wdsUtil
.
getWeatherObservations
(
weatherStation
,
WeatherObservation
.
LOG_INTERVAL_ID_1H
,
new
String
[]{
WeatherElements
.
TEMPERATURE_MEAN
,
WeatherElements
.
PRECIPITATION
,
WeatherElements
.
RELATIVE_HUMIDITY_MEAN
},
startDate
,
endDate
);
}
catch
(
WeatherDataSourceException
ex
)
{
throw
new
PreprocessorException
(
ex
.
getMessage
());
}
//Daily weather observations:
List
<
WeatherObservation
>
dailyObs
;
try
{
dailyObs
=
wdsUtil
.
getWeatherObservations
(
weatherStation
,
WeatherObservation
.
LOG_INTERVAL_ID_1D
,
new
String
[]{
WeatherElements
.
TEMPERATURE_MEAN
},
startDate
,
endDate
);
}
catch
(
WeatherDataSourceException
ex
)
{
throw
new
PreprocessorException
(
ex
.
getMessage
());
}
//Combining hourly and daily data
observations
.
addAll
(
dailyObs
);
retVal
.
setModelId
(
this
.
getModelId
());
retVal
.
setConfigParameter
(
"timeZone"
,
timeZone
.
getID
());
retVal
.
setConfigParameter
(
"observations"
,
observations
);
retVal
.
setConfigParameter
(
"latitude"
,
latitude
);
retVal
.
setConfigParameter
(
"sowingDate"
,
format
.
format
(
startDate
));
return
retVal
;
}
@Override
public
String
getModelId
()
{
return
"LEAFBLOTCH"
;
}
}
Loading