Skip to content

Commit cc7577d

Browse files
Merge branch 'dev' into df/#1394-hpTypeInput-validation-srated
# Conflicts: # CHANGELOG.md
2 parents 48d3e6c + 54091ca commit cc7577d

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
### Added
1010
- Enhanced check for invalid field names in sources [#1383](https://github.com/ie3-institute/PowerSystemDataModel/issues/1383)
1111
- 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)
1213
- Enhancing Validation for sRated of `HpTypeInput` [1394](https://github.com/ie3-institute/PowerSystemDataModel/issues/1394)
1314

1415
### Fixed

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/test/groovy/edu/ie3/datamodel/io/source/LoadProfileSourceTest.groovy

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,25 @@ package edu.ie3.datamodel.io.source
88
import static edu.ie3.datamodel.models.profile.LoadProfile.RandomLoadProfile.RANDOM_LOAD_PROFILE
99

1010
import edu.ie3.datamodel.models.profile.BdewStandardLoadProfile
11+
import edu.ie3.datamodel.models.profile.LoadProfile
1112
import spock.lang.Specification
1213

1314
class LoadProfileSourceTest extends Specification {
1415

15-
def "A LoadProfileSourceTest should read in all build-in BDEWStandardLoadProfiles"() {
16+
def "A LoadProfileSource should return the correct profile resolution for a given load profile"() {
17+
given:
18+
def allProfiles = LoadProfile.getAllProfiles()
19+
20+
21+
when:
22+
def resolutions = Arrays.stream(allProfiles).map { it -> LoadProfileSource.getResolution(it) }.toList()
23+
24+
then:
25+
resolutions.every { resolution -> resolution == 900 }
26+
}
27+
28+
29+
def "A LoadProfileSource should read in all build-in BDEWStandardLoadProfiles"() {
1630
when:
1731
def profiles = LoadProfileSource.bdewLoadProfiles
1832

@@ -22,7 +36,7 @@ class LoadProfileSourceTest extends Specification {
2236
profiles.values().every { it.timeSeries.entries.size() == 96 }
2337
}
2438

25-
def "A LoadProfileSourceTest should read in the build-in RandomLoadProfile"() {
39+
def "A LoadProfileSource should read in the build-in RandomLoadProfile"() {
2640
when:
2741
def random = LoadProfileSource.randomLoadProfile.timeSeries
2842

0 commit comments

Comments
 (0)