-
Notifications
You must be signed in to change notification settings - Fork 7
Adding sources for load profile time series. #1135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
danielfeismann
merged 43 commits into
dev
from
ms/#1106-transfer-LoadProfile-parsing-code-from-SIMONA
Feb 26, 2025
Merged
Changes from all commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
cb22fab
Adding BDEW standard load profiles.
staudtMarius 77d4d4b
Adding BDEW standard load profiles.
staudtMarius c38fd54
Merge branch 'dev' into ms/#1106-transfer-LoadProfile-parsing-code-fr…
staudtMarius c247138
Merge branch 'refs/heads/dev' into ms/#1106-transfer-LoadProfile-pars…
staudtMarius e2c8564
Adding more bdew standard load profiles.
staudtMarius 8ecea73
Adding random load profile. Adapting some tests.
staudtMarius c7ff5ed
Merge branch 'dev' into ms/#1106-transfer-LoadProfile-parsing-code-fr…
staudtMarius e5bbbe3
Merge branch 'dev' into ms/#1106-transfer-LoadProfile-parsing-code-fr…
staudtMarius f059052
Improving load profile time series.
staudtMarius 683a2b7
Fixing codacy issues.
staudtMarius 51f3bdb
Adding `maxPower` to `BdewLoadProfileTimeSeries`.
staudtMarius 086a492
Adding power information.
staudtMarius ba498fd
Adding `maxPower` to `LoadProfileTimeSeries`. Adding sql sources for …
staudtMarius 7806707
fmt
staudtMarius ac0e758
Improving code.
staudtMarius 753b46c
Merge branch 'dev' into ms/#1106-transfer-LoadProfile-parsing-code-fr…
staudtMarius 749d7bc
Merge branch 'refs/heads/dev' into ms/#1106-transfer-LoadProfile-pars…
staudtMarius 08ed24e
Improving code.
staudtMarius 8c4c8b6
Improving code.
staudtMarius ec46b85
Merge branch 'dev' into ms/#1106-transfer-LoadProfile-parsing-code-fr…
staudtMarius 3779c1f
Removing uuid for load profile time series.
staudtMarius 49f34fe
Merge branch 'dev' into ms/#1106-transfer-LoadProfile-parsing-code-fr…
staudtMarius e4f35fd
Merge branch 'dev' into ms/#1106-transfer-LoadProfile-parsing-code-fr…
staudtMarius cc26b88
Improving code.
staudtMarius 22279f3
Fixing small issue in `SqlTimeSeriesMetaInformationSource`. Renaming …
staudtMarius 3691920
Improving code.
staudtMarius c090165
Merge branch 'dev' into ms/#1106-transfer-LoadProfile-parsing-code-fr…
staudtMarius 42619a9
Merge branch 'dev' into ms/#1106-transfer-LoadProfile-parsing-code-fr…
staudtMarius 9639c88
Fixing some sonarqube issues.
staudtMarius eb66dbe
Merge branch 'dev' into ms/#1106-transfer-LoadProfile-parsing-code-fr…
staudtMarius d4ab293
Merge branch 'dev' into ms/#1106-transfer-LoadProfile-parsing-code-fr…
staudtMarius 11d3e9b
Merge branch 'dev' into ms/#1106-transfer-LoadProfile-parsing-code-fr…
staudtMarius 628468d
Merge branch 'dev' into ms/#1106-transfer-LoadProfile-parsing-code-fr…
staudtMarius 7bb1b23
Adding some tests.
staudtMarius 2c325ce
Merge branch 'dev' into ms/#1106-transfer-LoadProfile-parsing-code-fr…
staudtMarius 560cc77
Adapting to changes in `dev`.
staudtMarius 1eb6a59
Merge branch 'dev' into ms/#1106-transfer-LoadProfile-parsing-code-fr…
staudtMarius 44f9ec8
Merge branch 'dev' into ms/#1106-transfer-LoadProfile-parsing-code-fr…
staudtMarius d75926f
Adapting `LoadProfileSource`s.
staudtMarius 30daa89
Merge branch 'dev' into ms/#1106-transfer-LoadProfile-parsing-code-fr…
staudtMarius ec5742e
Enhancing documentation.
staudtMarius d02ea97
Enhancing documentation.
staudtMarius d8bec21
Merge branch 'dev' into ms/#1106-transfer-LoadProfile-parsing-code-fr…
staudtMarius File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/main/java/edu/ie3/datamodel/io/csv/CsvLoadProfileMetaInformation.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| /* | ||
| * © 2024. TU Dortmund University, | ||
| * Institute of Energy Systems, Energy Efficiency and Energy Economics, | ||
| * Research group Distribution grid planning and operation | ||
| */ | ||
| package edu.ie3.datamodel.io.csv; | ||
|
|
||
| import edu.ie3.datamodel.io.naming.timeseries.LoadProfileMetaInformation; | ||
| import java.nio.file.Path; | ||
| import java.util.Objects; | ||
|
|
||
| public class CsvLoadProfileMetaInformation extends LoadProfileMetaInformation { | ||
| private final Path fullFilePath; | ||
|
Check failure on line 13 in src/main/java/edu/ie3/datamodel/io/csv/CsvLoadProfileMetaInformation.java
|
||
|
|
||
| public CsvLoadProfileMetaInformation(String profile, Path fullFilePath) { | ||
| super(profile); | ||
| this.fullFilePath = fullFilePath; | ||
| } | ||
|
|
||
| public CsvLoadProfileMetaInformation( | ||
| LoadProfileMetaInformation metaInformation, Path fullFilePath) { | ||
| this(metaInformation.getProfile(), fullFilePath); | ||
| } | ||
|
|
||
| public Path getFullFilePath() { | ||
| return fullFilePath; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(Object o) { | ||
| if (this == o) return true; | ||
| if (!(o instanceof CsvLoadProfileMetaInformation that)) return false; | ||
| if (!super.equals(o)) return false; | ||
| return fullFilePath.equals(that.fullFilePath); | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return Objects.hash(super.hashCode(), fullFilePath); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return "CsvLoadProfileMetaInformation{" | ||
| + "uuid='" | ||
| + getUuid() | ||
| + '\'' | ||
| + ", profile='" | ||
| + getProfile() | ||
| + '\'' | ||
| + "fullFilePath=" | ||
| + fullFilePath | ||
| + '}'; | ||
| } | ||
| } | ||
130 changes: 130 additions & 0 deletions
130
src/main/java/edu/ie3/datamodel/io/source/LoadProfileSource.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,130 @@ | ||
| /* | ||
| * © 2024. TU Dortmund University, | ||
| * Institute of Energy Systems, Energy Efficiency and Energy Economics, | ||
| * Research group Distribution grid planning and operation | ||
| */ | ||
| package edu.ie3.datamodel.io.source; | ||
|
|
||
| import static edu.ie3.datamodel.models.profile.LoadProfile.RandomLoadProfile.RANDOM_LOAD_PROFILE; | ||
|
|
||
| import edu.ie3.datamodel.exceptions.FactoryException; | ||
| import edu.ie3.datamodel.exceptions.SourceException; | ||
| import edu.ie3.datamodel.io.csv.CsvLoadProfileMetaInformation; | ||
| import edu.ie3.datamodel.io.factory.timeseries.BdewLoadProfileFactory; | ||
| import edu.ie3.datamodel.io.factory.timeseries.LoadProfileData; | ||
| import edu.ie3.datamodel.io.factory.timeseries.LoadProfileFactory; | ||
| import edu.ie3.datamodel.io.factory.timeseries.RandomLoadProfileFactory; | ||
| import edu.ie3.datamodel.io.source.csv.CsvDataSource; | ||
| import edu.ie3.datamodel.io.source.csv.CsvLoadProfileSource; | ||
| import edu.ie3.datamodel.models.profile.BdewStandardLoadProfile; | ||
| import edu.ie3.datamodel.models.profile.LoadProfile; | ||
| import edu.ie3.datamodel.models.timeseries.repetitive.LoadProfileEntry; | ||
| import edu.ie3.datamodel.models.timeseries.repetitive.LoadProfileTimeSeries; | ||
| import edu.ie3.datamodel.models.timeseries.repetitive.RandomLoadProfileTimeSeries; | ||
| import edu.ie3.datamodel.models.value.PValue; | ||
| import edu.ie3.datamodel.models.value.Value; | ||
| import edu.ie3.datamodel.models.value.load.BdewLoadValues; | ||
| import edu.ie3.datamodel.models.value.load.LoadValues; | ||
| import edu.ie3.datamodel.models.value.load.RandomLoadValues; | ||
| import edu.ie3.datamodel.utils.Try; | ||
| import java.time.ZonedDateTime; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.Optional; | ||
| import java.util.function.Function; | ||
| import java.util.stream.Collectors; | ||
| import javax.measure.quantity.Energy; | ||
| import javax.measure.quantity.Power; | ||
| import tech.units.indriya.ComparableQuantity; | ||
|
|
||
| public abstract class LoadProfileSource<P extends LoadProfile, V extends LoadValues> | ||
| extends EntitySource { | ||
| protected final Class<V> entryClass; | ||
| protected final LoadProfileFactory<P, V> entryFactory; | ||
|
|
||
| protected LoadProfileSource(Class<V> entryClass, LoadProfileFactory<P, V> entryFactory) { | ||
| this.entryClass = entryClass; | ||
| this.entryFactory = entryFactory; | ||
| } | ||
|
|
||
| /** | ||
| * Build a list of type {@code E}, whereas the underlying {@link Value} does not need any | ||
| * additional information. | ||
| * | ||
| * @param fieldToValues Mapping from field id to values | ||
| * @return {@link Try} of simple time based value | ||
| */ | ||
| protected Try<LoadProfileEntry<V>, FactoryException> createEntries( | ||
| Map<String, String> fieldToValues) { | ||
| LoadProfileData<V> factoryData = new LoadProfileData<>(fieldToValues, entryClass); | ||
| return entryFactory.get(factoryData); | ||
| } | ||
|
|
||
| public abstract LoadProfileTimeSeries<V> getTimeSeries(); | ||
|
|
||
| /** | ||
| * Method to return all time keys after a given timestamp. | ||
| * | ||
| * @param time given time | ||
| * @return a list of time keys | ||
| */ | ||
| public abstract List<ZonedDateTime> getTimeKeysAfter(ZonedDateTime time); | ||
|
|
||
| /** | ||
| * Method to get the value for a given time. | ||
| * | ||
| * @param time for which a value is needed | ||
| * @return an optional | ||
| * @throws SourceException if an exception occurred | ||
| */ | ||
| public abstract Optional<PValue> getValue(ZonedDateTime time) throws SourceException; | ||
|
|
||
| /** Returns the load profile of this source. */ | ||
| public abstract P getLoadProfile(); | ||
|
|
||
| /** Returns the maximal power value of the time series */ | ||
| public abstract Optional<ComparableQuantity<Power>> getMaxPower(); | ||
|
|
||
| /** Returns the load profile energy scaling for this load profile time series. */ | ||
| public abstract Optional<ComparableQuantity<Energy>> getLoadProfileEnergyScaling(); | ||
|
|
||
| /** | ||
| * Method to read in the build-in {@link BdewStandardLoadProfile}s. | ||
| * | ||
| * @return a map: load profile to load profile source | ||
| */ | ||
| public static Map< | ||
| BdewStandardLoadProfile, CsvLoadProfileSource<BdewStandardLoadProfile, BdewLoadValues>> | ||
| getBdewLoadProfiles() throws SourceException { | ||
| CsvDataSource buildInSource = getBuildInSource(LoadProfileSource.class, "/load"); | ||
|
|
||
| BdewLoadProfileFactory factory = new BdewLoadProfileFactory(); | ||
|
|
||
| return buildInSource | ||
| .getCsvLoadProfileMetaInformation(BdewStandardLoadProfile.values()) | ||
| .values() | ||
| .stream() | ||
| .map( | ||
| metaInformation -> | ||
| new CsvLoadProfileSource<>( | ||
| buildInSource, metaInformation, BdewLoadValues.class, factory)) | ||
| .collect(Collectors.toMap(CsvLoadProfileSource::getLoadProfile, Function.identity())); | ||
| } | ||
|
|
||
| /** | ||
| * Method to read in the build-in {@link RandomLoadProfileTimeSeries}. | ||
| * | ||
| * @return the random load profile source | ||
| */ | ||
| public static CsvLoadProfileSource<LoadProfile.RandomLoadProfile, RandomLoadValues> | ||
| getRandomLoadProfile() throws SourceException { | ||
| CsvDataSource buildInSource = getBuildInSource(LoadProfileSource.class, "/load"); | ||
|
|
||
| CsvLoadProfileMetaInformation metaInformation = | ||
| buildInSource.getCsvLoadProfileMetaInformation(RANDOM_LOAD_PROFILE).values().stream() | ||
| .findAny() | ||
| .orElseThrow(); | ||
| return new CsvLoadProfileSource<>( | ||
| buildInSource, metaInformation, RandomLoadValues.class, new RandomLoadProfileFactory()); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.