Skip to content

Commit e76432d

Browse files
Merge branch 'dev' into df/#1357-validation-load
2 parents dd38b26 + 54091ca commit e76432d

File tree

13 files changed

+145
-9
lines changed

13 files changed

+145
-9
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88

99
### Added
1010
- Enhanced check for invalid field names in sources [#1383](https://github.com/ie3-institute/PowerSystemDataModel/issues/1383)
11+
- Enhancing value retrieval in `TimeSeriesSource` [1280](https://github.com/ie3-institute/PowerSystemDataModel/issues/1280)
12+
- Enhancing the `LoadProfileSource` to return the resolution [1288](https://github.com/ie3-institute/PowerSystemDataModel/issues/1288)
1113

1214
### Fixed
1315

@@ -30,6 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3032
- Extend azimuth angle range to [-180°, 180°] for PV inputs [#1330](https://github.com/ie3-institute/PowerSystemDataModel/issues/1330)
3133
- Improved error messages when reading and validating an invalid grid [#1354](https://github.com/ie3-institute/PowerSystemDataModel/issues/1354)
3234
- Changed `SubgridContainer` to represent galvanically seperated grids [#1226](https://github.com/ie3-institute/PowerSystemDataModel/issues/1226)
35+
- Fixed CFF-Version [#1392](https://github.com/ie3-institute/PowerSystemDataModel/issues/1392)
3336

3437
## [7.0.0] - 2025-05-08
3538

CITATION.cff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cff-version: 1.0.0
1+
cff-version: 1.2.0
22
title: "PowerSystemDataModel - Provides an elaborated data model to model energy systems with a high granularity."
33
message: "If you use this software, please cite it as below."
44
type: software

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ ext {
1818
//version (changing these should be considered thoroughly!)
1919
javaVersion = JavaVersion.VERSION_17
2020
groovyVersion = "4.0"
21-
groovyBinaryVersion = "4.0.27"
21+
groovyBinaryVersion = "4.0.28"
2222

2323
junitVersion = '1.12.0'
2424
testcontainersVersion = '1.21.3'

src/main/java/edu/ie3/datamodel/io/source/LoadProfileSource.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,23 @@ protected Try<LoadProfileEntry<V>, FactoryException> createEntries(
8888
/** Returns the load profile energy scaling for this load profile time series. */
8989
public abstract Optional<ComparableQuantity<Energy>> getLoadProfileEnergyScaling();
9090

91+
/**
92+
* Returns the resolution for the given {@link LoadProfile}.
93+
*
94+
* @param loadProfile given load profile
95+
* @return the resolution in seconds.
96+
*/
97+
public static long getResolution(LoadProfile loadProfile) {
98+
99+
if (loadProfile == LoadProfile.DefaultLoadProfiles.NO_LOAD_PROFILE) {
100+
// since no load profile was assigned, we return the maximal possible value
101+
return Long.MAX_VALUE;
102+
} else {
103+
// currently all registered profiles and all sources use 15 minutes intervals
104+
return 900L;
105+
}
106+
}
107+
91108
/**
92109
* Method to read in the build-in {@link BdewStandardLoadProfile}s.
93110
*

src/main/java/edu/ie3/datamodel/io/source/TimeSeriesSource.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,22 @@ public abstract IndividualTimeSeries<V> getTimeSeries(ClosedInterval<ZonedDateTi
5252

5353
public abstract Optional<V> getValue(ZonedDateTime time);
5454

55+
/**
56+
* Method to retrieve the value of the given time or the last timestamp before the given time.
57+
*
58+
* @param time given time
59+
* @return an option for a value
60+
*/
61+
public Optional<V> getValueOrLast(ZonedDateTime time) {
62+
Optional<V> value = getValue(time);
63+
64+
if (value.isEmpty()) {
65+
return getPreviousTimeBasedValue(time).map(TimeBasedValue::getValue);
66+
}
67+
68+
return value;
69+
}
70+
5571
public abstract Optional<TimeBasedValue<V>> getPreviousTimeBasedValue(ZonedDateTime time);
5672

5773
/**
@@ -61,4 +77,12 @@ public abstract IndividualTimeSeries<V> getTimeSeries(ClosedInterval<ZonedDateTi
6177
* @return a list of time keys
6278
*/
6379
public abstract List<ZonedDateTime> getTimeKeysAfter(ZonedDateTime time);
80+
81+
/**
82+
* Method to return all last known time keys before a given timestamp.
83+
*
84+
* @param time given time
85+
* @return an option for the time key
86+
*/
87+
public abstract Optional<ZonedDateTime> getLastTimeKeyBefore(ZonedDateTime time);
6488
}

src/main/java/edu/ie3/datamodel/io/source/csv/CsvTimeSeriesSource.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@ public List<ZonedDateTime> getTimeKeysAfter(ZonedDateTime time) {
142142
return timeSeries.getTimeKeysAfter(time);
143143
}
144144

145+
@Override
146+
public Optional<ZonedDateTime> getLastTimeKeyBefore(ZonedDateTime time) {
147+
return timeSeries.getPreviousDateTime(time);
148+
}
149+
145150
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
146151

147152
/**

src/main/java/edu/ie3/datamodel/io/source/sql/SqlTimeSeriesSource.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,15 @@ public List<ZonedDateTime> getTimeKeysAfter(ZonedDateTime time) {
199199
.toList();
200200
}
201201

202+
@Override
203+
public Optional<ZonedDateTime> getLastTimeKeyBefore(ZonedDateTime time) {
204+
return dataSource
205+
.executeQuery(
206+
queryForValueBefore, ps -> ps.setTimestamp(1, Timestamp.from(time.toInstant())))
207+
.map(valueFactory::extractTime)
208+
.max(ZonedDateTime::compareTo);
209+
}
210+
202211
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
203212

204213
/** Creates a set of TimeBasedValues from database */

src/main/java/edu/ie3/datamodel/models/timeseries/TimeSeries.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public Optional<TimeBasedValue<R>> getTimeBasedValue(ZonedDateTime time) {
6262
* @param time Reference in time
6363
* @return The next earlier known time instant
6464
*/
65-
protected abstract Optional<ZonedDateTime> getPreviousDateTime(ZonedDateTime time);
65+
public abstract Optional<ZonedDateTime> getPreviousDateTime(ZonedDateTime time);
6666

6767
/**
6868
* Get the next later known time instant

src/main/java/edu/ie3/datamodel/models/timeseries/individual/IndividualTimeSeries.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ public Optional<V> getValue(ZonedDateTime time) {
5353
}
5454

5555
@Override
56-
protected Optional<ZonedDateTime> getPreviousDateTime(ZonedDateTime time) {
56+
public Optional<ZonedDateTime> getPreviousDateTime(ZonedDateTime time) {
5757
return timeToValue.keySet().stream()
58-
.filter(valueTime -> valueTime.compareTo(time) < 0)
59-
.max(Comparator.naturalOrder());
58+
.filter(valueTime -> valueTime.isBefore(time))
59+
.max(ZonedDateTime::compareTo);
6060
}
6161

6262
@Override

src/main/java/edu/ie3/datamodel/models/timeseries/repetitive/LoadProfileTimeSeries.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public Set<LoadProfileEntry<V>> getEntries() {
7878
}
7979

8080
@Override
81-
protected Optional<ZonedDateTime> getPreviousDateTime(ZonedDateTime time) {
81+
public Optional<ZonedDateTime> getPreviousDateTime(ZonedDateTime time) {
8282
return Optional.of(time.minusMinutes(15));
8383
}
8484

0 commit comments

Comments
 (0)