Skip to content

Commit 93899ec

Browse files
committed
Merge branch 'dev' into ms/#1182-add-getPreviousValue-to-TimeSeriesSource
# Conflicts: # CHANGELOG.md
2 parents 0862338 + 2e86e0e commit 93899ec

27 files changed

+274
-78
lines changed

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ updates:
99
target-branch: dev
1010
reviewers:
1111
- t-ober
12-
- sensarmad
12+
- staudtMarius
1313
- sebastian-peter
1414
- danielfeismann
1515
- jo-bao

CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
### Added
1010
- Enhance `TimeSeriesSource` with method to retrieve all time keys after a given key [#543](https://github.com/ie3-institute/PowerSystemDataModel/issues/543)
1111
- Enhance `WeatherSource` with method to retrieve all time keys after a given key [#572](https://github.com/ie3-institute/PowerSystemDataModel/issues/572)
12+
- Adding timeseries for voltage values [#1128](https://github.com/ie3-institute/PowerSystemDataModel/issues/1128)
13+
- Added Staudt to list of reviewers [#1190](https://github.com/ie3-institute/PowerSystemDataModel/issues/1190)
1214
- Enhance `TimeSeriesSource` with method to retrieve the previous value before a given key [#1182](https://github.com/ie3-institute/PowerSystemDataModel/issues/1182)
1315

1416
### Fixed
1517

1618
### Changed
1719
- Storage minimum level parameter removed from cylindrical thermal storage [#1123](https://github.com/ie3-institute/PowerSystemDataModel/issues/1123)
18-
- Converted eval-rst to myst syntax in ReadTheDocs, fixed line wrapping and widths[#1137](https://github.com/ie3-institute/PowerSystemDataModel/issues/1137)
20+
- Converted eval-rst to myst syntax in ReadTheDocs, fixed line wrapping and widths [#1137](https://github.com/ie3-institute/PowerSystemDataModel/issues/1137)
1921
- Improving usage of streams on sql fetches [#827](https://github.com/ie3-institute/PowerSystemDataModel/issues/827)
2022
- Improving error message when using the outdated csv format [#1112](https://github.com/ie3-institute/PowerSystemDataModel/issues/1112)
21-
23+
- Changed ThermalUnitValidation: Ensure that thermal boundaries of thermal house are not the same [#1186](https://github.com/ie3-institute/PowerSystemDataModel/issues/1186)
24+
- Converted `MappingEntry` into a normal class [#1087](https://github.com/ie3-institute/PowerSystemDataModel/issues/1087)
25+
- Renamed timeseries mapping `participant` column to `asset` [#1191](https://github.com/ie3-institute/PowerSystemDataModel/issues/1191)
2226

2327
## [5.1.0] - 2024-06-24
2428

build.gradle

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ plugins {
44
id 'maven-publish'
55
id 'signing'
66
id 'pmd' // code check, working on source code
7-
id 'com.diffplug.spotless' version '6.25.0' //code format
8-
id 'com.github.spotbugs' version '6.0.26' // code check, working on byte code
7+
id 'com.diffplug.spotless' version '7.0.0' //code format
8+
id 'com.github.spotbugs' version '6.0.27' // code check, working on byte code
99
id 'de.undercouch.download' version '5.6.0'
1010
id 'kr.motd.sphinx' version '2.10.1' // documentation generation
1111
id 'jacoco' // java code coverage plugin
12-
id "org.sonarqube" version "6.0.0.5145" // sonarqube
12+
id "org.sonarqube" version "6.0.1.5171" // sonarqube
1313
id 'net.thauvin.erik.gradle.semver' version '1.0.4' // semantic versioning
1414
}
1515

@@ -55,7 +55,7 @@ dependencies {
5555
// ie³ power system utils
5656
implementation 'com.github.ie3-institute:PowerSystemUtils:2.2.1'
5757

58-
implementation 'tech.units:indriya:2.2.1'
58+
implementation 'tech.units:indriya:2.2.2'
5959

6060
// JTS Topology Suite for GeoPositions, License: EPL 1.0 / EDL 1.0
6161
implementation ('org.locationtech.jts:jts-core:1.20.0'){
@@ -70,10 +70,10 @@ dependencies {
7070
// testing
7171
testImplementation "org.apache.groovy:groovy:$groovyBinaryVersion"
7272

73-
testImplementation 'org.junit.jupiter:junit-jupiter:5.11.3'
73+
testImplementation 'org.junit.jupiter:junit-jupiter:5.11.4'
7474
testImplementation "org.spockframework:spock-core:2.3-groovy-$groovyVersion"
7575
testImplementation 'org.objenesis:objenesis:3.4' // Mock creation with constructor parameters
76-
testImplementation 'net.bytebuddy:byte-buddy:1.15.10' // Mocks of classes
76+
testImplementation 'net.bytebuddy:byte-buddy:1.15.11' // Mocks of classes
7777

7878
// testcontainers (docker framework for testing)
7979
testImplementation "org.testcontainers:testcontainers:$testcontainersVersion"
@@ -83,18 +83,18 @@ dependencies {
8383
testImplementation "org.testcontainers:couchbase:$testcontainersVersion"
8484

8585
// logging
86-
implementation platform('org.apache.logging.log4j:log4j-bom:2.24.2')
86+
implementation platform('org.apache.logging.log4j:log4j-bom:2.24.3')
8787
implementation 'org.apache.logging.log4j:log4j-api' // log4j
8888
implementation 'org.apache.logging.log4j:log4j-core' // log4j
8989
implementation 'org.apache.logging.log4j:log4j-slf4j-impl' // log4j -> slf4j
9090

9191
// Databases
9292
implementation 'org.influxdb:influxdb-java:2.24'
93-
implementation 'com.couchbase.client:java-client:3.7.5'
93+
implementation 'com.couchbase.client:java-client:3.7.6'
9494
runtimeOnly 'org.postgresql:postgresql:42.7.4' // postgresql jdbc driver required during runtime
9595

9696
implementation 'commons-io:commons-io:2.18.0' // I/O functionalities
97-
implementation 'commons-codec:commons-codec:1.17.1' // needed by commons-compress
97+
implementation 'commons-codec:commons-codec:1.17.2' // needed by commons-compress
9898
implementation 'org.apache.commons:commons-compress:1.27.1' // I/O functionalities
9999
}
100100

docs/readthedocs/io/csvfiles.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,30 +122,34 @@ This is the UUID from the example above `2fcb3e53-b94a-4b96-bea4-c469e499f1a1`.
122122
The following keys are supported until now:
123123
```{list-table}
124124
:widths: auto
125+
:class: wrapping
125126
:header-rows: 1
126127
127128
* - Key
128-
- Information and supported head line
129+
- Information and supported head line.
129130
* - c
130131
- An energy price (e.g. in €/MWh; c stands for charge).
131132
Permissible head line: ``time,price``
132133
* - p
133-
- Active power
134+
- Active power.
134135
Permissible head line: ``time,p``
135136
* - pq
136-
- Active and reactive power
137+
- Active and reactive power.
137138
Permissible head line: ``time,p,q``
138139
* - h
139-
- Heat power demand
140+
- Heat power demand.
140141
Permissible head line: ``time,h``
141142
* - ph
142-
- Active and heat power
143+
- Active and heat power.
143144
Permissible head line: ``time,p,h``
144145
* - pqh
145-
- Active, reactive and heat power
146+
- Active, reactive and heat power.
146147
Permissible head line: ``time,p,q,h``
148+
* - v
149+
- Voltage mangnitude in pu and angle in °.
150+
Permissible head line: ``time,vMag,vAng``
147151
* - weather
148-
- Weather information
152+
- Weather information.
149153
Permissible head line: ``time,coordinate,direct_irradiation,diffuse_irradiation,temperature,wind_velocity,wind_direction``
150154
151155
```

docs/readthedocs/models/input/additionaldata/timeseries.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ The following different values are available:
4848
4949
* - `WindValue`
5050
- Combination of wind direction and wind velocity
51-
51+
52+
* - `VoltageValue`
53+
- Combination of voltage magnitude in p.u. and angle in °
54+
5255
* - `WeatherValue`
5356
- Combination of irradiance, temperature and wind information
5457

src/main/java/edu/ie3/datamodel/exceptions/EntityProcessorException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
package edu.ie3.datamodel.exceptions;
77

88
/**
9-
* Is thrown, when an something went wrong during entity field mapping creation in a {@link
9+
* Is thrown, when something went wrong during entity field mapping creation in a {@link
1010
* edu.ie3.datamodel.io.processor.EntityProcessor}
1111
*/
1212
public class EntityProcessorException extends Exception {

src/main/java/edu/ie3/datamodel/io/factory/FactoryData.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,22 @@ public <Q extends Quantity<Q>> ComparableQuantity<Q> getQuantity(String field, U
7878
return Quantities.getQuantity(getDouble(field), unit);
7979
}
8080

81+
/**
82+
* Returns field value for given field name, or empty Optional if field does not exist.
83+
*
84+
* @param field field name
85+
* @param unit unit of Quantity
86+
* @param <Q> unit type parameter
87+
* @return field value
88+
*/
89+
public <Q extends Quantity<Q>> Optional<ComparableQuantity<Q>> getQuantityOptional(
90+
String field, Unit<Q> unit) {
91+
return Optional.ofNullable(fieldsToAttributes.get(field))
92+
.filter(str -> !str.isEmpty())
93+
.map(Double::parseDouble)
94+
.map(value -> Quantities.getQuantity(value, unit));
95+
}
96+
8197
/**
8298
* Returns int value for given field name. Throws {@link FactoryException} if field does not exist
8399
* or parsing fails.

src/main/java/edu/ie3/datamodel/io/factory/timeseries/TimeBasedSimpleValueFactory.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ public class TimeBasedSimpleValueFactory<V extends Value>
2525
private static final String REACTIVE_POWER = "q";
2626
private static final String HEAT_DEMAND = "heatDemand";
2727

28+
/* voltage */
29+
private static final String VMAG = "vMag";
30+
private static final String VANG = "VAng";
31+
2832
public TimeBasedSimpleValueFactory(Class<? extends V> valueClasses) {
2933
super(valueClasses);
3034
}
@@ -35,6 +39,7 @@ public TimeBasedSimpleValueFactory(
3539
}
3640

3741
@Override
42+
@SuppressWarnings("unchecked")
3843
protected TimeBasedValue<V> buildModel(SimpleTimeBasedValueData<V> data) {
3944
ZonedDateTime time = timeUtil.toZonedDateTime(data.getField(TIME));
4045
V value;
@@ -64,6 +69,12 @@ protected TimeBasedValue<V> buildModel(SimpleTimeBasedValueData<V> data) {
6469
data.getQuantity(REACTIVE_POWER, REACTIVE_POWER_IN));
6570
} else if (PValue.class.isAssignableFrom(data.getTargetClass())) {
6671
value = (V) new PValue(data.getQuantity(ACTIVE_POWER, ACTIVE_POWER_IN));
72+
} else if (VoltageValue.class.isAssignableFrom(data.getTargetClass())) {
73+
value =
74+
(V)
75+
new VoltageValue(
76+
data.getQuantity(VMAG, VOLTAGE_MAGNITUDE),
77+
data.getQuantityOptional(VANG, VOLTAGE_ANGLE));
6778
} else {
6879
throw new FactoryException(
6980
"The given factory cannot handle target class '" + data.getTargetClass() + "'.");
@@ -88,6 +99,8 @@ protected List<Set<String>> getFields(Class<?> entityClass) {
8899
minConstructorParams.addAll(Arrays.asList(ACTIVE_POWER, REACTIVE_POWER));
89100
} else if (PValue.class.isAssignableFrom(entityClass)) {
90101
minConstructorParams.add(ACTIVE_POWER);
102+
} else if (VoltageValue.class.isAssignableFrom(entityClass)) {
103+
minConstructorParams.addAll(List.of(VMAG, VANG));
91104
} else {
92105
throw new FactoryException(
93106
"The given factory cannot handle target class '" + entityClass + "'.");

src/main/java/edu/ie3/datamodel/io/factory/timeseries/TimeSeriesMappingFactory.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,13 @@
88
import edu.ie3.datamodel.io.factory.EntityData;
99
import edu.ie3.datamodel.io.factory.EntityFactory;
1010
import edu.ie3.datamodel.io.source.TimeSeriesMappingSource;
11-
import java.util.Collections;
1211
import java.util.List;
1312
import java.util.Set;
1413
import java.util.UUID;
15-
import java.util.stream.Collectors;
16-
import java.util.stream.Stream;
1714

1815
public class TimeSeriesMappingFactory
1916
extends EntityFactory<TimeSeriesMappingSource.MappingEntry, EntityData> {
20-
private static final String PARTICIPANT = "participant";
17+
private static final String ASSET = "asset";
2118
private static final String TIME_SERIES = "timeSeries";
2219

2320
public TimeSeriesMappingFactory() {
@@ -26,14 +23,13 @@ public TimeSeriesMappingFactory() {
2623

2724
@Override
2825
protected List<Set<String>> getFields(Class<?> entityClass) {
29-
return Collections.singletonList(
30-
Stream.of(PARTICIPANT, TIME_SERIES).collect(Collectors.toSet()));
26+
return List.of(newSet(ASSET, TIME_SERIES));
3127
}
3228

3329
@Override
3430
protected TimeSeriesMappingSource.MappingEntry buildModel(EntityData data) {
35-
UUID participant = data.getUUID(PARTICIPANT);
31+
UUID asset = data.getUUID(ASSET);
3632
UUID timeSeries = data.getUUID(TIME_SERIES);
37-
return new TimeSeriesMappingSource.MappingEntry(participant, timeSeries);
33+
return new TimeSeriesMappingSource.MappingEntry(asset, timeSeries);
3834
}
3935
}

src/main/java/edu/ie3/datamodel/io/naming/timeseries/ColumnScheme.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ public enum ColumnScheme {
1919
HEAT_DEMAND("h", HeatDemandValue.class),
2020
ACTIVE_POWER_AND_HEAT_DEMAND("ph", HeatAndPValue.class),
2121
APPARENT_POWER_AND_HEAT_DEMAND("pqh", HeatAndSValue.class),
22-
WEATHER("weather", WeatherValue.class);
22+
WEATHER("weather", WeatherValue.class),
23+
VOLTAGE("v", VoltageValue.class);
2324

2425
private final String scheme;
2526
private final Class<? extends Value> valueClass;
@@ -57,6 +58,7 @@ public static <V extends Value> Optional<ColumnScheme> parse(Class<V> valueClass
5758
if (PValue.class.isAssignableFrom(valueClass)) return Optional.of(ACTIVE_POWER);
5859
if (HeatDemandValue.class.isAssignableFrom(valueClass)) return Optional.of(HEAT_DEMAND);
5960
if (WeatherValue.class.isAssignableFrom(valueClass)) return Optional.of(WEATHER);
61+
if (VoltageValue.class.isAssignableFrom(valueClass)) return Optional.of(VOLTAGE);
6062
return Optional.empty();
6163
}
6264
}

0 commit comments

Comments
 (0)