Skip to content

Commit cd2fba7

Browse files
committed
read time series data
1 parent 574aa36 commit cd2fba7

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

post-processing-tool/src/main/java/com/bc/fiduceo/post/plugin/era5/Era5Archive.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,13 @@ static String mapVariable(String variable) {
3838
}
3939

4040
static String getTimeString(String collection, Calendar utcCalendar) {
41-
final Calendar clonedCalendar = (Calendar) utcCalendar.clone();
42-
43-
int hour = clonedCalendar.get(Calendar.HOUR_OF_DAY);
44-
if (hour < 6 && collection.startsWith("fc_")) {
45-
clonedCalendar.add(Calendar.DATE, -1);
46-
}
47-
48-
final int year = clonedCalendar.get(Calendar.YEAR);
41+
int hour = utcCalendar.get(Calendar.HOUR_OF_DAY);
42+
final int year = utcCalendar.get(Calendar.YEAR);
4943

50-
final int month = clonedCalendar.get(Calendar.MONTH) + 1;
44+
final int month = utcCalendar.get(Calendar.MONTH) + 1;
5145
final String monthString = twoDigitsFormat.format(month);
5246

53-
final int day = clonedCalendar.get(Calendar.DAY_OF_MONTH);
47+
final int day = utcCalendar.get(Calendar.DAY_OF_MONTH);
5448
final String dayString = twoDigitsFormat.format(day);
5549

5650
if (collection.startsWith("an_")) {
@@ -86,6 +80,8 @@ String get(String variableType, int timeStamp) {
8680
String variable = variableType.substring(cutPoint + 1, variableType.length());
8781
variable = mapVariable(variable);
8882

83+
adjustCalendarForForecast(utcCalendar, collection);
84+
8985
final String timeString = getTimeString(collection, utcCalendar);
9086
final String fileName = getFileName(collection, variable, timeString);
9187

@@ -101,4 +97,12 @@ String get(String variableType, int timeStamp) {
10197
year + File.separator + monthString + File.separator + dayString + File.separator +
10298
fileName;
10399
}
100+
101+
// @todo 1 tb/tb make static and add test 2020-12-11
102+
private void adjustCalendarForForecast(Calendar utcCalendar, String collection) {
103+
int hour = utcCalendar.get(Calendar.HOUR_OF_DAY);
104+
if (hour <= 6 && collection.startsWith("fc_")) {
105+
utcCalendar.add(Calendar.DATE, -1);
106+
}
107+
}
104108
}

post-processing-tool/src/main/java/com/bc/fiduceo/post/plugin/era5/MatchupFields.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,10 @@ void compute(Configuration config, NetcdfFile reader, NetcdfFileWriter writer) t
8686
timeIndex.set(m, t);
8787
final int timeStamp = targetTimeArray.getInt(timeIndex);
8888
// @todo 1 tb/tb continue here 2020-12-10
89-
// final Variable variable = variableCache.get(variableKey, timeStamp);
89+
final Variable variable = variableCache.get(variableKey, timeStamp);
9090
}
9191
}
92-
9392
}
94-
95-
96-
9793
} finally {
9894
variableCache.close();
9995
}
@@ -107,7 +103,7 @@ private static Array createTimeArray(NetcdfFile reader, MatchupFieldsConfigurati
107103
final Array targetTimeArray = Array.factory(DataType.INT, nwpTimeVariable.getShape());
108104
final Index targetIndex = targetTimeArray.getIndex();
109105

110-
final int offset = -matchupConfig.get_time_steps_past();
106+
final int offset = - matchupConfig.get_time_steps_past();
111107
final Index index = era5TimeArray.getIndex();
112108
for (int i = 0; i < numMatchups; i++) {
113109
index.set(i);

post-processing-tool/src/test/java/com/bc/fiduceo/post/plugin/era5/Era5ArchiveTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public void testGetTimeString_fc(){
7373
utcCalendar.set(Calendar.HOUR_OF_DAY, 3);
7474

7575
String metssTime = Era5Archive.getTimeString("fc_sfc_metss", utcCalendar);
76-
assertEquals("2008060318009", metssTime);
76+
assertEquals("2008060418009", metssTime);
7777

7878
utcCalendar.setTimeInMillis(1212600800000L);
7979
utcCalendar.set(Calendar.HOUR_OF_DAY, 11);

0 commit comments

Comments
 (0)