diff --git a/CHANGELOG.md b/CHANGELOG.md index 68dc1959c..5af286bea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Enhanced check for invalid field names in sources [#1383](https://github.com/ie3-institute/PowerSystemDataModel/issues/1383) - Enhancing value retrieval in `TimeSeriesSource` [1280](https://github.com/ie3-institute/PowerSystemDataModel/issues/1280) +- Enhancing the `LoadProfileSource` to return the resolution [1288](https://github.com/ie3-institute/PowerSystemDataModel/issues/1288) ### Fixed diff --git a/src/main/java/edu/ie3/datamodel/io/source/LoadProfileSource.java b/src/main/java/edu/ie3/datamodel/io/source/LoadProfileSource.java index 60e30dd4e..e356a8f5a 100644 --- a/src/main/java/edu/ie3/datamodel/io/source/LoadProfileSource.java +++ b/src/main/java/edu/ie3/datamodel/io/source/LoadProfileSource.java @@ -88,6 +88,23 @@ protected Try, FactoryException> createEntries( /** Returns the load profile energy scaling for this load profile time series. */ public abstract Optional> getLoadProfileEnergyScaling(); + /** + * Returns the resolution for the given {@link LoadProfile}. + * + * @param loadProfile given load profile + * @return the resolution in seconds. + */ + public static long getResolution(LoadProfile loadProfile) { + + if (loadProfile == LoadProfile.DefaultLoadProfiles.NO_LOAD_PROFILE) { + // since no load profile was assigned, we return the maximal possible value + return Long.MAX_VALUE; + } else { + // currently all registered profiles and all sources use 15 minutes intervals + return 900L; + } + } + /** * Method to read in the build-in {@link BdewStandardLoadProfile}s. * diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/LoadProfileSourceTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/LoadProfileSourceTest.groovy index 013e93e67..e6f492090 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/LoadProfileSourceTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/LoadProfileSourceTest.groovy @@ -8,11 +8,25 @@ package edu.ie3.datamodel.io.source import static edu.ie3.datamodel.models.profile.LoadProfile.RandomLoadProfile.RANDOM_LOAD_PROFILE import edu.ie3.datamodel.models.profile.BdewStandardLoadProfile +import edu.ie3.datamodel.models.profile.LoadProfile import spock.lang.Specification class LoadProfileSourceTest extends Specification { - def "A LoadProfileSourceTest should read in all build-in BDEWStandardLoadProfiles"() { + def "A LoadProfileSource should return the correct profile resolution for a given load profile"() { + given: + def allProfiles = LoadProfile.getAllProfiles() + + + when: + def resolutions = Arrays.stream(allProfiles).map { it -> LoadProfileSource.getResolution(it) }.toList() + + then: + resolutions.every { resolution -> resolution == 900 } + } + + + def "A LoadProfileSource should read in all build-in BDEWStandardLoadProfiles"() { when: def profiles = LoadProfileSource.bdewLoadProfiles @@ -22,7 +36,7 @@ class LoadProfileSourceTest extends Specification { profiles.values().every { it.timeSeries.entries.size() == 96 } } - def "A LoadProfileSourceTest should read in the build-in RandomLoadProfile"() { + def "A LoadProfileSource should read in the build-in RandomLoadProfile"() { when: def random = LoadProfileSource.randomLoadProfile.timeSeries