Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
17 changes: 17 additions & 0 deletions src/main/java/edu/ie3/datamodel/io/source/LoadProfileSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,23 @@ protected Try<LoadProfileEntry<V>, FactoryException> createEntries(
/** Returns the load profile energy scaling for this load profile time series. */
public abstract Optional<ComparableQuantity<Energy>> 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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down