From 8a65326a5cac9ff335585a8dc5a1383f25d05102 Mon Sep 17 00:00:00 2001 From: Lisrte Date: Thu, 23 Jan 2025 14:06:55 +0100 Subject: [PATCH] Remove curves sanitizer (#421) * Bump powsybl-core to 6.6.1 * Remove curves sanitizer * Use TimeSeriesCsvConfig skip duplicate option Signed-off-by: lisrte (cherry picked from commit 08c0ed84f1fc48876e1899326888cf9ab2937de2) --- .../com/powsybl/dynawo/it/DynawoSimulationTest.java | 2 +- .../com/powsybl/dynawo/DynawoSimulationHandler.java | 13 +++---------- pom.xml | 2 +- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/dynawo-integration-tests/src/test/java/com/powsybl/dynawo/it/DynawoSimulationTest.java b/dynawo-integration-tests/src/test/java/com/powsybl/dynawo/it/DynawoSimulationTest.java index 9d18241ed..279a09e60 100644 --- a/dynawo-integration-tests/src/test/java/com/powsybl/dynawo/it/DynawoSimulationTest.java +++ b/dynawo-integration-tests/src/test/java/com/powsybl/dynawo/it/DynawoSimulationTest.java @@ -72,7 +72,7 @@ void testIeee14() { assertEquals(27, result.getCurves().size()); DoubleTimeSeries ts1 = result.getCurve("_GEN____1_SM_generator_UStatorPu"); assertEquals("_GEN____1_SM_generator_UStatorPu", ts1.getMetadata().getName()); - assertEquals(192, ts1.toArray().length); + assertEquals(258, ts1.toArray().length); assertEquals(14, result.getFinalStateValues().size()); assertEquals(1.046227, result.getFinalStateValues().get("NETWORK__BUS___10_TN_Upu_value")); List timeLine = result.getTimeLine(); diff --git a/dynawo-simulation/src/main/java/com/powsybl/dynawo/DynawoSimulationHandler.java b/dynawo-simulation/src/main/java/com/powsybl/dynawo/DynawoSimulationHandler.java index abd1c71e8..6d3c3cb28 100644 --- a/dynawo-simulation/src/main/java/com/powsybl/dynawo/DynawoSimulationHandler.java +++ b/dynawo-simulation/src/main/java/com/powsybl/dynawo/DynawoSimulationHandler.java @@ -182,8 +182,9 @@ private void setTimeline(Path outputsFolder) { private void setCurves(Path workingDir) { Path curvesPath = workingDir.resolve(CURVES_OUTPUT_PATH).resolve(CURVES_FILENAME); if (Files.exists(curvesPath)) { - TimeSeries.parseCsv(curvesPath, new TimeSeriesCsvConfig(TimeSeriesConstants.DEFAULT_SEPARATOR, false, TimeSeries.TimeFormat.FRACTIONS_OF_SECOND)) - .values().forEach(l -> l.forEach(curve -> curves.put(curve.getMetadata().getName(), sanitizeDoubleTimeSeries((DoubleTimeSeries) curve)))); + TimeSeries.parseCsv(curvesPath, new TimeSeriesCsvConfig(TimeSeriesConstants.DEFAULT_SEPARATOR, false, + TimeSeries.TimeFormat.FRACTIONS_OF_SECOND, true, true)) + .values().forEach(l -> l.forEach(curve -> curves.put(curve.getMetadata().getName(), (DoubleTimeSeries) curve))); } else { LOGGER.warn("Curves folder not found"); status = DynamicSimulationResult.Status.FAILURE; @@ -191,14 +192,6 @@ private void setCurves(Path workingDir) { } } - private DoubleTimeSeries sanitizeDoubleTimeSeries(DoubleTimeSeries series) { - Set times = new LinkedHashSet<>(); - double[] values = series.stream().filter(dp -> times.add(dp.getTime())).mapToDouble(DoublePoint::getValue).toArray(); - return TimeSeries.createDouble(series.getMetadata().getName(), - new IrregularTimeSeriesIndex(times.stream().mapToLong(l -> l).toArray()), - values); - } - private void setFinalStateValues(Path workingDir) { Path fsvPath = workingDir.resolve(FSV_OUTPUT_PATH).resolve(FSV_OUTPUT_FILENAME); if (Files.exists(fsvPath)) { diff --git a/pom.xml b/pom.xml index 209214b85..11acabf8f 100644 --- a/pom.xml +++ b/pom.xml @@ -57,7 +57,7 @@ 17 - 6.6.0 + 6.6.1 4.0.14 0.3.2 2.17.1