Skip to content

Commit

Permalink
Remove curves sanitizer (#421)
Browse files Browse the repository at this point in the history
* Bump powsybl-core to 6.6.1
* Remove curves sanitizer
* Use TimeSeriesCsvConfig skip duplicate option

Signed-off-by: lisrte <[email protected]>
  • Loading branch information
Lisrte authored Jan 23, 2025
1 parent 9d482f6 commit 08c0ed8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<TimelineEvent> timeLine = result.getTimeLine();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,23 +182,16 @@ 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;
statusText = "Dynawo curves folder not found";
}
}

private DoubleTimeSeries sanitizeDoubleTimeSeries(DoubleTimeSeries series) {
Set<Long> 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)) {
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

<properties>
<java.version>17</java.version>
<powsybl-core.version>6.6.0</powsybl-core.version>
<powsybl-core.version>6.6.1</powsybl-core.version>
<groovy.version>4.0.14</groovy.version> <!-- used for groovy-json but also for groovydoc (dynawo-dsl) -->
<asciitable.version>0.3.2</asciitable.version>
<jackson.version>2.17.1</jackson.version>
Expand Down

0 comments on commit 08c0ed8

Please sign in to comment.