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
62f915f8
Commit
62f915f8
authored
11 years ago
by
Tor-Einar Skog
Browse files
Options
Downloads
Patches
Plain Diff
Adding timezone awareness to avoid trouble with daily temperature timestamps
parent
04651731
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/no/bioforsk/vips/util/WeatherUtil.java
+2
-2
2 additions, 2 deletions
src/main/java/no/bioforsk/vips/util/WeatherUtil.java
src/test/java/no/bioforsk/vips/util/WeatherUtilTest.java
+5
-4
5 additions, 4 deletions
src/test/java/no/bioforsk/vips/util/WeatherUtilTest.java
with
7 additions
and
6 deletions
src/main/java/no/bioforsk/vips/util/WeatherUtil.java
+
2
−
2
View file @
62f915f8
...
@@ -680,11 +680,11 @@ public class WeatherUtil {
...
@@ -680,11 +680,11 @@ public class WeatherUtil {
* @param logInterval @see WeatherObservation
* @param logInterval @see WeatherObservation
* @return
* @return
*/
*/
public
Date
findFirstHoleInObservationSeries
(
List
<
WeatherObservation
>
observations
,
Integer
logInterval
)
public
Date
findFirstHoleInObservationSeries
(
List
<
WeatherObservation
>
observations
,
Integer
logInterval
,
TimeZone
timeZone
)
{
{
Collections
.
sort
(
observations
);
Collections
.
sort
(
observations
);
Date
currentTime
=
observations
.
get
(
0
).
getTimeMeasured
();
Date
currentTime
=
observations
.
get
(
0
).
getTimeMeasured
();
Calendar
cal
=
Calendar
.
getInstance
();
Calendar
cal
=
Calendar
.
getInstance
(
timeZone
);
for
(
WeatherObservation
obs:
observations
)
for
(
WeatherObservation
obs:
observations
)
{
{
if
(
obs
.
getTimeMeasured
().
compareTo
(
currentTime
)
!=
0
)
if
(
obs
.
getTimeMeasured
().
compareTo
(
currentTime
)
!=
0
)
...
...
This diff is collapsed.
Click to expand it.
src/test/java/no/bioforsk/vips/util/WeatherUtilTest.java
+
5
−
4
View file @
62f915f8
...
@@ -307,25 +307,26 @@ public class WeatherUtilTest extends TestCase {
...
@@ -307,25 +307,26 @@ public class WeatherUtilTest extends TestCase {
public
void
testFindFirstHoleInObservationSeries
()
public
void
testFindFirstHoleInObservationSeries
()
{
{
TimeZone
tz
=
TimeZone
.
getTimeZone
(
"Europe/Oslo"
);
System
.
out
.
println
(
"testFindFirstHoleInObservationSeries"
);
System
.
out
.
println
(
"testFindFirstHoleInObservationSeries"
);
List
<
WeatherObservation
>
TM
=
this
.
getObservations
(
"/JSONWeatherDataTMDailyComplete.json"
);
List
<
WeatherObservation
>
TM
=
this
.
getObservations
(
"/JSONWeatherDataTMDailyComplete.json"
);
WeatherUtil
instance
=
new
WeatherUtil
();
WeatherUtil
instance
=
new
WeatherUtil
();
assertNull
(
instance
.
findFirstHoleInObservationSeries
(
TM
,
WeatherObservation
.
LOG_INTERVAL_ID_1D
));
assertNull
(
instance
.
findFirstHoleInObservationSeries
(
TM
,
WeatherObservation
.
LOG_INTERVAL_ID_1D
,
tz
));
TM
=
this
.
getObservations
(
"/JSONWeatherDataTMDailyFaulty.json"
);
TM
=
this
.
getObservations
(
"/JSONWeatherDataTMDailyFaulty.json"
);
Date
result
=
instance
.
findFirstHoleInObservationSeries
(
TM
,
WeatherObservation
.
LOG_INTERVAL_ID_1D
);
Date
result
=
instance
.
findFirstHoleInObservationSeries
(
TM
,
WeatherObservation
.
LOG_INTERVAL_ID_1D
,
tz
);
System
.
out
.
println
(
"Found hole here: "
+
result
);
System
.
out
.
println
(
"Found hole here: "
+
result
);
assertNotNull
(
result
);
assertNotNull
(
result
);
// TEST hourly data
// TEST hourly data
TM
=
this
.
getObservations
(
"/weatherDataWithoutHolesRR.json"
);
TM
=
this
.
getObservations
(
"/weatherDataWithoutHolesRR.json"
);
result
=
instance
.
findFirstHoleInObservationSeries
(
TM
,
WeatherObservation
.
LOG_INTERVAL_ID_1H
);
result
=
instance
.
findFirstHoleInObservationSeries
(
TM
,
WeatherObservation
.
LOG_INTERVAL_ID_1H
,
tz
);
if
(
result
!=
null
)
if
(
result
!=
null
)
System
.
out
.
println
(
"Found hole here: "
+
result
);
System
.
out
.
println
(
"Found hole here: "
+
result
);
assertNull
(
result
);
assertNull
(
result
);
TM
=
this
.
getObservations
(
"/weatherDataWithHolesRR.json"
);
TM
=
this
.
getObservations
(
"/weatherDataWithHolesRR.json"
);
result
=
instance
.
findFirstHoleInObservationSeries
(
TM
,
WeatherObservation
.
LOG_INTERVAL_ID_1H
);
result
=
instance
.
findFirstHoleInObservationSeries
(
TM
,
WeatherObservation
.
LOG_INTERVAL_ID_1H
,
tz
);
System
.
out
.
println
(
"Found hole here: "
+
result
);
System
.
out
.
println
(
"Found hole here: "
+
result
);
assertNotNull
(
result
);
assertNotNull
(
result
);
}
}
...
...
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