Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
V
VIPSCommon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
VIPSCommon
Commits
827a1c9a
Commit
827a1c9a
authored
10 years ago
by
Tor-Einar Skog
Browse files
Options
Downloads
Patches
Plain Diff
Added check for empty input
parent
cba1e678
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/no/bioforsk/vips/util/WeatherUtil.java
+36
-1
36 additions, 1 deletion
src/main/java/no/bioforsk/vips/util/WeatherUtil.java
with
36 additions
and
1 deletion
src/main/java/no/bioforsk/vips/util/WeatherUtil.java
+
36
−
1
View file @
827a1c9a
...
@@ -202,7 +202,7 @@ public class WeatherUtil {
...
@@ -202,7 +202,7 @@ public class WeatherUtil {
/**
/**
*
*
* @param observation hourly Values (logInterval 1h)
* @param observation hourly Values (logInterval 1h)
* @return aggregated daily values (logInterval 24h/1d)
* @return aggregated daily values (logInterval 24h/1d)
or NULL if no observations are given
*/
*/
public
List
<
WeatherObservation
>
getAggregatedDailyValues
(
public
List
<
WeatherObservation
>
getAggregatedDailyValues
(
List
<
WeatherObservation
>
observations
,
List
<
WeatherObservation
>
observations
,
...
@@ -212,6 +212,10 @@ public class WeatherUtil {
...
@@ -212,6 +212,10 @@ public class WeatherUtil {
throws
WeatherObservationListException
,
throws
WeatherObservationListException
,
InvalidAggregationTypeException
InvalidAggregationTypeException
{
{
if
(
observations
==
null
||
observations
.
isEmpty
())
{
return
null
;
}
// First we organize the hourly values into one bucket per day
// First we organize the hourly values into one bucket per day
Map
<
Date
,
Map
>
dateBucket
=
new
HashMap
<
Date
,
Map
>();
Map
<
Date
,
Map
>
dateBucket
=
new
HashMap
<
Date
,
Map
>();
String
expectedParameter
=
observations
.
get
(
0
).
getElementMeasurementTypeId
();
String
expectedParameter
=
observations
.
get
(
0
).
getElementMeasurementTypeId
();
...
@@ -326,6 +330,12 @@ public class WeatherUtil {
...
@@ -326,6 +330,12 @@ public class WeatherUtil {
return
maximum
;
return
maximum
;
}
}
/**
* Sets hours, minutes, seconds and milliseconds to ZERO
* @param timeStamp
* @param timeZone
* @return
*/
public
Date
normalizeToExactDate
(
Date
timeStamp
,
TimeZone
timeZone
)
public
Date
normalizeToExactDate
(
Date
timeStamp
,
TimeZone
timeZone
)
{
{
Calendar
cal
=
Calendar
.
getInstance
(
timeZone
);
Calendar
cal
=
Calendar
.
getInstance
(
timeZone
);
...
@@ -336,6 +346,31 @@ public class WeatherUtil {
...
@@ -336,6 +346,31 @@ public class WeatherUtil {
cal
.
set
(
Calendar
.
MILLISECOND
,
0
);
cal
.
set
(
Calendar
.
MILLISECOND
,
0
);
return
cal
.
getTime
();
return
cal
.
getTime
();
}
}
/**
* Assuming that this is a midnight timestamp that has been skewed
* due to DST changes, the method attempts to return a correct midnight
* time stamp in the requested time zone
* @param timeStamp
* @param timeZone
* @return
*/
public
Date
pragmaticAdjustmentToMidnight
(
Date
timeStamp
,
TimeZone
timeZone
)
{
Calendar
cal
=
Calendar
.
getInstance
(
timeZone
);
cal
.
setTime
(
timeStamp
);
// If we're close to BEFORE midnight, add one day
if
(
cal
.
get
(
Calendar
.
HOUR_OF_DAY
)
>=
22
)
{
cal
.
add
(
Calendar
.
DATE
,
1
);
}
// Then set hours, minutes etc. to zero
cal
.
set
(
Calendar
.
HOUR_OF_DAY
,
0
);
cal
.
set
(
Calendar
.
MINUTE
,
0
);
cal
.
set
(
Calendar
.
SECOND
,
0
);
cal
.
set
(
Calendar
.
MILLISECOND
,
0
);
return
cal
.
getTime
();
}
/**
/**
* Given input data, attempts to calculate leaf wetness. Does not overwrite provided leaf wetness data.
* Given input data, attempts to calculate leaf wetness. Does not overwrite provided leaf wetness data.
...
...
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