From 946679eee8535c8854d0f7cf3b601c1381c5be80 Mon Sep 17 00:00:00 2001 From: Nick Van Date: Tue, 15 Oct 2024 20:28:02 -0500 Subject: [PATCH] Update NetCDF Gridded Data Time Revert NetCDF Gridded Data time reading logic to read in intervals via 'getCoordBoundsDate' instead of instantaneous time. --- .../usace/hec/vortex/io/GridDatasetReader.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/vortex-api/src/main/java/mil/army/usace/hec/vortex/io/GridDatasetReader.java b/vortex-api/src/main/java/mil/army/usace/hec/vortex/io/GridDatasetReader.java index 5094c4f0..bf6dc0da 100644 --- a/vortex-api/src/main/java/mil/army/usace/hec/vortex/io/GridDatasetReader.java +++ b/vortex-api/src/main/java/mil/army/usace/hec/vortex/io/GridDatasetReader.java @@ -375,7 +375,7 @@ private String getAttributeStringValue(Attribute attribute) { private List getTimeRecordsWithTimeAxis1D(CoordinateAxis1DTime tAxis) { List list = new ArrayList<>(); if (!tAxis.isInterval() && !isSpecialTimeBounds()) { - return getTimeInstants(tAxis); + return getCoordinateBounds(tAxis); } for (int i = 0; i < (int) tAxis.getSize(); i++) { @@ -421,10 +421,16 @@ private boolean isSpecialTimeBounds() { return specialFileType != null && specialFileType != UNDEFINED; } - private List getTimeInstants(CoordinateAxis1DTime timeAxis) { - return timeAxis.getCalendarDates().stream() - .map(TimeConverter::toZonedDateTime) - .map(t -> VortexDataInterval.of(t, t)) - .toList(); + private List getCoordinateBounds(CoordinateAxis1DTime timeAxis) { + List list = new ArrayList<>(); + for (int i = 0; i < timeAxis.getSize(); i++) { + CalendarDate[] dates = timeAxis.getCoordBoundsDate(i); + ZonedDateTime startTime = TimeConverter.toZonedDateTime(dates[0]); + ZonedDateTime endTime = TimeConverter.toZonedDateTime(dates[1]); + VortexDataInterval interval = new VortexDataInterval(startTime, endTime); + list.add(interval); + } + + return List.copyOf(list); } }