From 6bb6984b1f2243070cb87b98e190fe0a02682edf Mon Sep 17 00:00:00 2001 From: pierrepetersmeier <155652256+pierrepetersmeier@users.noreply.github.com> Date: Wed, 18 Jun 2025 16:26:19 +0200 Subject: [PATCH 01/36] Add ground temperature (1m) as option to weather data. --- .../CosmoTimeBasedWeatherValueFactory.java | 61 ++++++++++++++----- .../IconTimeBasedWeatherValueFactory.java | 5 ++ .../datamodel/models/value/WeatherValue.java | 25 +++++++- 3 files changed, 75 insertions(+), 16 deletions(-) diff --git a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactory.java index 09048fb89..6d5986b89 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactory.java @@ -7,20 +7,23 @@ import edu.ie3.datamodel.models.StandardUnits; import edu.ie3.datamodel.models.timeseries.individual.TimeBasedValue; +import edu.ie3.datamodel.models.value.SolarIrradianceValue; +import edu.ie3.datamodel.models.value.TemperatureValue; import edu.ie3.datamodel.models.value.WeatherValue; +import edu.ie3.datamodel.models.value.WindValue; import edu.ie3.util.TimeUtil; import edu.ie3.util.quantities.PowerSystemUnits; import edu.ie3.util.quantities.interfaces.Irradiance; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; -import java.util.Collections; -import java.util.List; -import java.util.Set; +import java.util.*; import javax.measure.quantity.Angle; +import javax.measure.quantity.Length; import javax.measure.quantity.Speed; import javax.measure.quantity.Temperature; import org.locationtech.jts.geom.Point; import tech.units.indriya.ComparableQuantity; +import tech.units.indriya.quantity.Quantities; /** * Factory implementation of {@link TimeBasedWeatherValueFactory}, that is able to handle field to @@ -33,6 +36,9 @@ public class CosmoTimeBasedWeatherValueFactory extends TimeBasedWeatherValueFact private static final String WIND_DIRECTION = "windDirection"; private static final String WIND_VELOCITY = "windVelocity"; + private static final String GROUND_TEMPERATURE_SURFACE = "groundTemperatureSurface"; + private static final String GROUND_TEMPERATURE_1M = "groundTemperature1m"; + public CosmoTimeBasedWeatherValueFactory(TimeUtil timeUtil) { super(timeUtil); } @@ -55,6 +61,11 @@ protected List> getFields(Class entityClass) { TEMPERATURE, WIND_DIRECTION, WIND_VELOCITY); + + Set allParameters = + expandSet(minConstructorParams, GROUND_TEMPERATURE_SURFACE, GROUND_TEMPERATURE_1M); + minConstructorParams.remove(COORDINATE_ID); + allParameters.remove(COORDINATE_ID); return Collections.singletonList(minConstructorParams); } @@ -62,16 +73,37 @@ protected List> getFields(Class entityClass) { protected TimeBasedValue buildModel(TimeBasedWeatherValueData data) { Point coordinate = data.getCoordinate(); ZonedDateTime time = timeUtil.toZonedDateTime(data.getField(TIME)); - ComparableQuantity directIrradiance = - data.getQuantity(DIRECT_IRRADIANCE, PowerSystemUnits.WATT_PER_SQUAREMETRE); - ComparableQuantity diffuseIrradiance = - data.getQuantity(DIFFUSE_IRRADIANCE, PowerSystemUnits.WATT_PER_SQUAREMETRE); - ComparableQuantity temperature = - data.getQuantity(TEMPERATURE, StandardUnits.TEMPERATURE); - ComparableQuantity windDirection = - data.getQuantity(WIND_DIRECTION, StandardUnits.WIND_DIRECTION); - ComparableQuantity windVelocity = - data.getQuantity(WIND_VELOCITY, StandardUnits.WIND_VELOCITY); + SolarIrradianceValue solarIrradiance = new SolarIrradianceValue( + data.getQuantity(DIRECT_IRRADIANCE, PowerSystemUnits.WATT_PER_SQUAREMETRE), + data.getQuantity(DIFFUSE_IRRADIANCE, PowerSystemUnits.WATT_PER_SQUAREMETRE) + ); + TemperatureValue temperature = new TemperatureValue( + data.getQuantity(TEMPERATURE, StandardUnits.TEMPERATURE) + ); + WindValue wind = new WindValue( + data.getQuantity(WIND_DIRECTION, StandardUnits.WIND_DIRECTION), + data.getQuantity(WIND_VELOCITY, StandardUnits.WIND_VELOCITY) + ); + + Map, TemperatureValue> groundTemperatures = new HashMap<>(); + + + data.getField(GROUND_TEMPERATURE_SURFACE).ifPresent(value -> { + ComparableQuantity depth = Quantities.getQuantity(0, StandardUnits.DEPTH); + TemperatureValue tempValue = new TemperatureValue( + data.getQuantity(GROUND_TEMPERATURE_SURFACE, StandardUnits.TEMPERATURE) + ); + groundTemperatures.put(depth, tempValue); + }); + + data.getField(GROUND_TEMPERATURE_1M).ifPresent(value -> { + ComparableQuantity depth = Quantities.getQuantity(1, StandardUnits.DEPTH); + TemperatureValue tempValue = new TemperatureValue( + data.getQuantity(GROUND_TEMPERATURE_1M, StandardUnits.TEMPERATURE) + ); + groundTemperatures.put(depth, tempValue); + }); + WeatherValue weatherValue = new WeatherValue( coordinate, @@ -79,7 +111,8 @@ protected TimeBasedValue buildModel(TimeBasedWeatherValueData data diffuseIrradiance, temperature, windDirection, - windVelocity); + windVelocity, + groundTemperatures); return new TimeBasedValue<>(time, weatherValue); } } diff --git a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java index 189e40c57..fbd3341c5 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java @@ -34,6 +34,11 @@ public class IconTimeBasedWeatherValueFactory extends TimeBasedWeatherValueFacto private static final String WIND_VELOCITY_U = "u131m"; private static final String WIND_VELOCITY_V = "v131m"; + /** Ground-/Skin-Temperature at surface (0m) */ + private static final String GROUND_TEMP_SURFACE = "tG"; + /** Soil-Temperature at 100cm depth (example parameter name) */ + private static final String SOIL_TEMP_100CM = "tso100cm"; + public IconTimeBasedWeatherValueFactory() { super(); } diff --git a/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java b/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java index 09ec1787f..c4ee481bd 100644 --- a/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java +++ b/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java @@ -6,8 +6,12 @@ package edu.ie3.datamodel.models.value; import edu.ie3.util.quantities.interfaces.Irradiance; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; import java.util.Objects; import javax.measure.quantity.Angle; +import javax.measure.quantity.Length; import javax.measure.quantity.Speed; import javax.measure.quantity.Temperature; import org.locationtech.jts.geom.Point; @@ -25,11 +29,14 @@ public class WeatherValue implements Value { /** Wind values for this coordinate */ private final WindValue wind; + /** Optional: A map of ground temperatures at different depths. The key represents the depth. */ + private Map, TemperatureValue> groundTemperatures = Map.of(); /** * @param coordinate of this weather value set * @param solarIrradiance values for this coordinate * @param temperature values for this coordinate * @param wind values for this coordinate + * @param groundTemperatures A map of ground temperatures at different depths */ public WeatherValue( Point coordinate, @@ -40,6 +47,7 @@ public WeatherValue( this.solarIrradiance = solarIrradiance; this.temperature = temperature; this.wind = wind; + this.groundTemperatures = Collections.unmodifiableMap(new HashMap<>(groundTemperatures)); } /** @@ -81,6 +89,16 @@ public WindValue getWind() { return wind; } + /** + * Returns a map of ground temperatures, with the depth as key. The map is unmodifiable. Returns + * an empty map if no values are available. + * + * @return A map of ground temperatures. + */ + public Map, TemperatureValue> getGroundTemperatures() { + return groundTemperatures; + } + @Override public boolean equals(Object o) { if (this == o) return true; @@ -89,12 +107,13 @@ public boolean equals(Object o) { return coordinate.equals(that.coordinate) && solarIrradiance.equals(that.solarIrradiance) && temperature.equals(that.temperature) - && wind.equals(that.wind); + && wind.equals(that.wind) + && groundTemperatures.equals(that.groundTemperatures); } @Override public int hashCode() { - return Objects.hash(coordinate, solarIrradiance, temperature, wind); + return Objects.hash(coordinate, solarIrradiance, temperature, wind, groundTemperatures); } @Override @@ -108,6 +127,8 @@ public String toString() { + temperature + ", wind=" + wind + + groundTemperatures + + ", groundTemperatures=" + '}'; } } From 920be80ac66be2c36b5d3ffce5b2ec1798b06402 Mon Sep 17 00:00:00 2001 From: pierrepetersmeier <155652256+pierrepetersmeier@users.noreply.github.com> Date: Wed, 2 Jul 2025 16:43:50 +0200 Subject: [PATCH 02/36] Address review feedback and align test suite --- CHANGELOG.md | 3 + .../CosmoTimeBasedWeatherValueFactory.java | 101 ++++----- .../IconTimeBasedWeatherValueFactory.java | 78 +++---- .../timeseries/TimeSeriesProcessor.java | 122 ++-------- .../datamodel/models/value/WeatherValue.java | 104 ++++----- ...smoTimeBasedWeatherValueFactoryTest.groovy | 49 ++-- ...conTimeBasedWeatherValueFactoryTest.groovy | 86 ++++--- .../CouchbaseWeatherSourceCosmoIT.groovy | 25 +- .../CouchbaseWeatherSourceIconIT.groovy | 20 +- .../csv/CsvWeatherSourceCosmoTest.groovy | 46 ++-- .../csv/CsvWeatherSourceIconTest.groovy | 139 +----------- .../InfluxDbWeatherSourceCosmoIT.groovy | 27 +-- .../InfluxDbWeatherSourceIconIT.groovy | 24 +- .../source/sql/SqlWeatherSourceCosmoIT.groovy | 21 +- .../source/sql/SqlWeatherSourceIconIT.groovy | 16 +- .../UniquenessValidationUtilsTest.groovy | 24 +- .../test/common/CosmoWeatherTestData.groovy | 22 +- .../test/common/IconWeatherTestData.groovy | 33 ++- .../ie3/test/common/TimeSeriesTestData.groovy | 214 +++++++++--------- .../helper/WeatherSourceTestHelper.groovy | 19 +- 20 files changed, 498 insertions(+), 675 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a7593a97d..6eb37954e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased/Snapshot] +### Added +- Add ground temperature (1m) as option to weather data. [#1343](https://github.com/ie3-institute/PowerSystemDataModel/issues/1343) + ### Fixed - Fixed handling of `CongestionResult.InputModelType` in `EntityProcessor` [#1325](https://github.com/ie3-institute/PowerSystemDataModel/issues/1325) - -Fixed em fields in input models [#1331](https://github.com/ie3-institute/PowerSystemDataModel/issues/1331) diff --git a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactory.java index 6d5986b89..9e60785b0 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactory.java @@ -1,21 +1,19 @@ /* - * © 2021. TU Dortmund University, + * © 2020. TU Dortmund University, * Institute of Energy Systems, Energy Efficiency and Energy Economics, * Research group Distribution grid planning and operation */ package edu.ie3.datamodel.io.factory.timeseries; +import edu.ie3.datamodel.exceptions.FactoryException; import edu.ie3.datamodel.models.StandardUnits; import edu.ie3.datamodel.models.timeseries.individual.TimeBasedValue; -import edu.ie3.datamodel.models.value.SolarIrradianceValue; import edu.ie3.datamodel.models.value.TemperatureValue; import edu.ie3.datamodel.models.value.WeatherValue; -import edu.ie3.datamodel.models.value.WindValue; import edu.ie3.util.TimeUtil; import edu.ie3.util.quantities.PowerSystemUnits; import edu.ie3.util.quantities.interfaces.Irradiance; import java.time.ZonedDateTime; -import java.time.format.DateTimeFormatter; import java.util.*; import javax.measure.quantity.Angle; import javax.measure.quantity.Length; @@ -24,18 +22,16 @@ import org.locationtech.jts.geom.Point; import tech.units.indriya.ComparableQuantity; import tech.units.indriya.quantity.Quantities; +import tech.units.indriya.unit.Units; -/** - * Factory implementation of {@link TimeBasedWeatherValueFactory}, that is able to handle field to - * value mapping in the typical PowerSystemDataModel (PSDM) column scheme - */ public class CosmoTimeBasedWeatherValueFactory extends TimeBasedWeatherValueFactory { + private static final String TIME = "time"; + private static final String COORDINATE_ID = "coordinateId"; private static final String DIFFUSE_IRRADIANCE = "diffuseIrradiance"; private static final String DIRECT_IRRADIANCE = "directIrradiance"; private static final String TEMPERATURE = "temperature"; private static final String WIND_DIRECTION = "windDirection"; private static final String WIND_VELOCITY = "windVelocity"; - private static final String GROUND_TEMPERATURE_SURFACE = "groundTemperatureSurface"; private static final String GROUND_TEMPERATURE_1M = "groundTemperature1m"; @@ -43,66 +39,58 @@ public CosmoTimeBasedWeatherValueFactory(TimeUtil timeUtil) { super(timeUtil); } - public CosmoTimeBasedWeatherValueFactory(DateTimeFormatter dateTimeFormatter) { - super(dateTimeFormatter); - } - - public CosmoTimeBasedWeatherValueFactory() { - super(); - } - @Override protected List> getFields(Class entityClass) { Set minConstructorParams = - newSet( - COORDINATE_ID, - DIFFUSE_IRRADIANCE, - DIRECT_IRRADIANCE, - TEMPERATURE, - WIND_DIRECTION, - WIND_VELOCITY); + new HashSet<>( + Set.of( + COORDINATE_ID, + TIME, + DIFFUSE_IRRADIANCE, + DIRECT_IRRADIANCE, + TEMPERATURE, + WIND_DIRECTION, + WIND_VELOCITY)); - Set allParameters = - expandSet(minConstructorParams, GROUND_TEMPERATURE_SURFACE, GROUND_TEMPERATURE_1M); - minConstructorParams.remove(COORDINATE_ID); - allParameters.remove(COORDINATE_ID); - return Collections.singletonList(minConstructorParams); + Set withGroundTemps = new HashSet<>(minConstructorParams); + withGroundTemps.add(GROUND_TEMPERATURE_SURFACE); + withGroundTemps.add(GROUND_TEMPERATURE_1M); + + return List.of(minConstructorParams, withGroundTemps); } @Override protected TimeBasedValue buildModel(TimeBasedWeatherValueData data) { Point coordinate = data.getCoordinate(); ZonedDateTime time = timeUtil.toZonedDateTime(data.getField(TIME)); - SolarIrradianceValue solarIrradiance = new SolarIrradianceValue( - data.getQuantity(DIRECT_IRRADIANCE, PowerSystemUnits.WATT_PER_SQUAREMETRE), - data.getQuantity(DIFFUSE_IRRADIANCE, PowerSystemUnits.WATT_PER_SQUAREMETRE) - ); - TemperatureValue temperature = new TemperatureValue( - data.getQuantity(TEMPERATURE, StandardUnits.TEMPERATURE) - ); - WindValue wind = new WindValue( - data.getQuantity(WIND_DIRECTION, StandardUnits.WIND_DIRECTION), - data.getQuantity(WIND_VELOCITY, StandardUnits.WIND_VELOCITY) - ); - Map, TemperatureValue> groundTemperatures = new HashMap<>(); + ComparableQuantity directIrradiance = + data.getQuantity(DIRECT_IRRADIANCE, PowerSystemUnits.WATT_PER_SQUAREMETRE); + ComparableQuantity diffuseIrradiance = + data.getQuantity(DIFFUSE_IRRADIANCE, PowerSystemUnits.WATT_PER_SQUAREMETRE); + ComparableQuantity temperature = + data.getQuantity(TEMPERATURE, StandardUnits.TEMPERATURE); + ComparableQuantity windDirection = + data.getQuantity(WIND_DIRECTION, StandardUnits.WIND_DIRECTION); + ComparableQuantity windVelocity = + data.getQuantity(WIND_VELOCITY, StandardUnits.WIND_VELOCITY); + Map, TemperatureValue> groundTemperatures = new HashMap<>(); - data.getField(GROUND_TEMPERATURE_SURFACE).ifPresent(value -> { - ComparableQuantity depth = Quantities.getQuantity(0, StandardUnits.DEPTH); - TemperatureValue tempValue = new TemperatureValue( - data.getQuantity(GROUND_TEMPERATURE_SURFACE, StandardUnits.TEMPERATURE) - ); - groundTemperatures.put(depth, tempValue); - }); + try { + TemperatureValue tempValue = + new TemperatureValue( + data.getQuantity(GROUND_TEMPERATURE_SURFACE, StandardUnits.TEMPERATURE)); + groundTemperatures.put(Quantities.getQuantity(0, Units.METRE), tempValue); + } catch (FactoryException ignored) { + } - data.getField(GROUND_TEMPERATURE_1M).ifPresent(value -> { - ComparableQuantity depth = Quantities.getQuantity(1, StandardUnits.DEPTH); - TemperatureValue tempValue = new TemperatureValue( - data.getQuantity(GROUND_TEMPERATURE_1M, StandardUnits.TEMPERATURE) - ); - groundTemperatures.put(depth, tempValue); - }); + try { + TemperatureValue tempValue = + new TemperatureValue(data.getQuantity(GROUND_TEMPERATURE_1M, StandardUnits.TEMPERATURE)); + groundTemperatures.put(Quantities.getQuantity(1, Units.METRE), tempValue); + } catch (FactoryException ignored) { + } WeatherValue weatherValue = new WeatherValue( @@ -112,7 +100,8 @@ protected TimeBasedValue buildModel(TimeBasedWeatherValueData data temperature, windDirection, windVelocity, - groundTemperatures); + groundTemperatures); + return new TimeBasedValue<>(time, weatherValue); } } diff --git a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java index fbd3341c5..642918f6e 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java @@ -5,8 +5,10 @@ */ package edu.ie3.datamodel.io.factory.timeseries; +import edu.ie3.datamodel.exceptions.FactoryException; import edu.ie3.datamodel.models.StandardUnits; import edu.ie3.datamodel.models.timeseries.individual.TimeBasedValue; +import edu.ie3.datamodel.models.value.TemperatureValue; import edu.ie3.datamodel.models.value.WeatherValue; import edu.ie3.util.quantities.PowerSystemUnits; import edu.ie3.util.quantities.interfaces.Irradiance; @@ -14,6 +16,7 @@ import java.time.format.DateTimeFormatter; import java.util.*; import javax.measure.quantity.Angle; +import javax.measure.quantity.Length; import javax.measure.quantity.Speed; import javax.measure.quantity.Temperature; import org.locationtech.jts.geom.Point; @@ -21,22 +24,13 @@ import tech.units.indriya.quantity.Quantities; import tech.units.indriya.unit.Units; -/** - * Factory implementation of {@link TimeBasedWeatherValueFactory}, that is able to handle field to - * value mapping in the column scheme, ie3 uses to store its data from German Federal - * Weather Service's ICON-EU model - */ public class IconTimeBasedWeatherValueFactory extends TimeBasedWeatherValueFactory { - /* Redefine the column names to meet the icon specifications */ private static final String DIFFUSE_IRRADIANCE = "aswdifdS"; private static final String DIRECT_IRRADIANCE = "aswdirS"; private static final String TEMPERATURE = "t2m"; private static final String WIND_VELOCITY_U = "u131m"; private static final String WIND_VELOCITY_V = "v131m"; - - /** Ground-/Skin-Temperature at surface (0m) */ private static final String GROUND_TEMP_SURFACE = "tG"; - /** Soil-Temperature at 100cm depth (example parameter name) */ private static final String SOIL_TEMP_100CM = "tso100cm"; public IconTimeBasedWeatherValueFactory() { @@ -52,13 +46,19 @@ protected List> getFields(Class entityClass) { Set minParameters = newSet( DIFFUSE_IRRADIANCE, DIRECT_IRRADIANCE, TEMPERATURE, WIND_VELOCITY_U, WIND_VELOCITY_V); + + Set minParametersWithGroundTemp = new HashSet<>(minParameters); + minParametersWithGroundTemp.add(GROUND_TEMP_SURFACE); + minParametersWithGroundTemp.add(SOIL_TEMP_100CM); + Set allParameters = expandSet( minParameters, "albrad", "asobs", "aswdifuS", - "tG", + GROUND_TEMP_SURFACE, + SOIL_TEMP_100CM, "u10m", "u20m", "u216m", @@ -78,7 +78,7 @@ protected List> getFields(Class entityClass) { "sobsrad", "t131m"); - return Arrays.asList(minParameters, allParameters); + return Arrays.asList(minParameters, minParametersWithGroundTemp, allParameters); } @Override @@ -93,6 +93,25 @@ protected TimeBasedValue buildModel(TimeBasedWeatherValueData data data.getQuantity(TEMPERATURE, Units.KELVIN).to(StandardUnits.TEMPERATURE); ComparableQuantity windDirection = getWindDirection(data); ComparableQuantity windVelocity = getWindVelocity(data); + + Map, TemperatureValue> groundTemperatures = new HashMap<>(); + + try { + TemperatureValue tempValue = + new TemperatureValue( + data.getQuantity(GROUND_TEMP_SURFACE, Units.KELVIN).to(StandardUnits.TEMPERATURE)); + groundTemperatures.put(Quantities.getQuantity(0, Units.METRE), tempValue); + } catch (FactoryException ignored) { + } + + try { + TemperatureValue tempValue = + new TemperatureValue( + data.getQuantity(SOIL_TEMP_100CM, Units.KELVIN).to(StandardUnits.TEMPERATURE)); + groundTemperatures.put(Quantities.getQuantity(1, Units.METRE), tempValue); + } catch (FactoryException ignored) { + } + WeatherValue weatherValue = new WeatherValue( coordinate, @@ -100,49 +119,22 @@ protected TimeBasedValue buildModel(TimeBasedWeatherValueData data diffuseIrradiance, temperature, windDirection, - windVelocity); + windVelocity, + groundTemperatures); + return new TimeBasedValue<>(time, weatherValue); } - /** - * Determines the wind direction. In ICON the wind velocity is given in three dimensional - * Cartesian coordinates. Here, the upward component is neglected. 0° or 0 rad are defined to - * point northwards. The angle increases clockwise. Please note, that the wind direction is the - * direction, the wind comes from and not goes to. We choose to use the wind velocity - * calculations at 131 m above ground, as this is a height that pretty good matches the common hub - * height of today's onshore wind generators, that are commonly connected to the voltage levels of - * interest. - * - * @param data Collective information to convert - * @return A {@link ComparableQuantity} of type {@link Speed}, that is converted to {@link - * StandardUnits#WIND_VELOCITY} - */ private static ComparableQuantity getWindDirection(TimeBasedWeatherValueData data) { - /* Get the three dimensional parts of the wind velocity vector in cartesian coordinates */ - double u = - data.getDouble(WIND_VELOCITY_U); // Wind component from west to east (parallel to latitudes) - double v = - data.getDouble( - WIND_VELOCITY_V); // Wind component from south to north (parallel to longitudes) + double u = data.getDouble(WIND_VELOCITY_U); + double v = data.getDouble(WIND_VELOCITY_V); double angle = Math.toDegrees(Math.atan2(-u, -v)); return Quantities.getQuantity(angle < 0 ? angle + 360d : angle, PowerSystemUnits.DEGREE_GEOM) .to(StandardUnits.WIND_DIRECTION); } - /** - * Determines the wind velocity. In ICON the wind velocity is given in three dimensional Cartesian - * coordinates. Here, the upward component is neglected. We choose to use the wind velocity - * calculations at 131 m above ground, as this is a height that pretty good matches the common hub - * height of today's onshore wind generators, that are commonly connected to the voltage levels of - * interest. - * - * @param data Collective information to convert - * @return A {@link ComparableQuantity} of type {@link Speed}, that is converted to {@link - * StandardUnits#WIND_VELOCITY} - */ private static ComparableQuantity getWindVelocity(TimeBasedWeatherValueData data) { - /* Get the three dimensional parts of the wind velocity vector in cartesian coordinates */ double u = data.getDouble(WIND_VELOCITY_U); double v = data.getDouble(WIND_VELOCITY_V); diff --git a/src/main/java/edu/ie3/datamodel/io/processor/timeseries/TimeSeriesProcessor.java b/src/main/java/edu/ie3/datamodel/io/processor/timeseries/TimeSeriesProcessor.java index d536bbb02..24769a805 100644 --- a/src/main/java/edu/ie3/datamodel/io/processor/timeseries/TimeSeriesProcessor.java +++ b/src/main/java/edu/ie3/datamodel/io/processor/timeseries/TimeSeriesProcessor.java @@ -13,14 +13,15 @@ import edu.ie3.datamodel.models.timeseries.TimeSeriesEntry; import edu.ie3.datamodel.models.timeseries.individual.IndividualTimeSeries; import edu.ie3.datamodel.models.timeseries.individual.TimeBasedValue; -import edu.ie3.datamodel.models.timeseries.repetitive.*; +import edu.ie3.datamodel.models.timeseries.repetitive.BdewLoadProfileTimeSeries; +import edu.ie3.datamodel.models.timeseries.repetitive.LoadProfileEntry; +import edu.ie3.datamodel.models.timeseries.repetitive.RandomLoadProfileTimeSeries; import edu.ie3.datamodel.models.value.*; import edu.ie3.datamodel.models.value.load.BdewLoadValues; import edu.ie3.datamodel.models.value.load.RandomLoadValues; import java.lang.reflect.Method; import java.util.*; import java.util.stream.Collectors; -import java.util.stream.Stream; public class TimeSeriesProcessor< T extends TimeSeries, @@ -28,10 +29,6 @@ public class TimeSeriesProcessor< V extends Value, R extends Value> extends EntityProcessor { - /** - * List of all combinations of time series class, entry class and value class, this processor is - * able to handle - */ public static final List eligibleKeys = List.of( new TimeSeriesProcessorKey( @@ -59,25 +56,14 @@ public class TimeSeriesProcessor< new TimeSeriesProcessorKey( RandomLoadProfileTimeSeries.class, LoadProfileEntry.class, RandomLoadValues.class)); - /** - * Specific combination of time series class, entry class and value class, this processor is - * foreseen to handle. - */ private final TimeSeriesProcessorKey registeredKey; - - /** - * Mapping from field name to the source, where to find the information and which getter method to - * invoke - */ private final SortedMap fieldToSource; - private final String[] flattenedHeaderElements; public TimeSeriesProcessor(Class timeSeriesClass, Class entryClass, Class valueClass) throws EntityProcessorException { super(timeSeriesClass); - /* Check, if this processor can handle the foreseen combination of time series, entry and value */ TimeSeriesProcessorKey timeSeriesKey = new TimeSeriesProcessorKey(timeSeriesClass, entryClass, valueClass); if (!eligibleKeys.contains(timeSeriesKey)) @@ -92,10 +78,7 @@ public TimeSeriesProcessor(Class timeSeriesClass, Class entryClass, Class< .collect(Collectors.joining(", "))); this.registeredKey = timeSeriesKey; - /* Register, where to get which information from */ this.fieldToSource = buildFieldToSource(timeSeriesClass, entryClass, valueClass); - - /* Collect all header elements */ this.flattenedHeaderElements = fieldToSource.keySet().toArray(new String[0]); } @@ -103,19 +86,9 @@ public TimeSeriesProcessorKey getRegisteredKey() { return registeredKey; } - /** - * Collects the mapping, where to find which information and how to get them (in terms of getter - * method). - * - * @param timeSeriesClass Class of the time series - * @param entryClass Class of the entry in the time series for the "outer" fields - * @param valueClass Class of the actual value in the entries for the "inner" fields - * @return A mapping from field name to a tuple of source information and equivalent getter method - */ private SortedMap buildFieldToSource( Class timeSeriesClass, Class entryClass, Class valueClass) throws EntityProcessorException { - /* Get the mapping from field name to getter method ignoring the getter for returning all entries */ Map timeSeriesMapping = mapFieldNameToGetter( timeSeriesClass, Arrays.asList("entries", "uuid", "type", "loadProfile")) @@ -125,67 +98,37 @@ private SortedMap buildFieldToSource( Collectors.toMap( Map.Entry::getKey, entry -> new FieldSourceToMethod(TIMESERIES, entry.getValue()))); - /* Get the mapping from field name to getter method for the entry, but ignoring the getter for the value */ + Map entryMapping = mapFieldNameToGetter(entryClass, Collections.singletonList("value")).entrySet().stream() .collect( Collectors.toMap( Map.Entry::getKey, entry -> new FieldSourceToMethod(ENTRY, entry.getValue()))); + Map valueMapping; - if (!valueClass.equals(WeatherValue.class)) { + if (valueClass.equals(WeatherValue.class)) { valueMapping = - mapFieldNameToGetter(valueClass).entrySet().stream() + mapFieldNameToGetter(valueClass, Collections.singletonList("groundTemperatures")) + .entrySet() + .stream() .collect( Collectors.toMap( Map.Entry::getKey, entry -> new FieldSourceToMethod(VALUE, entry.getValue()))); } else { - /* Treat the nested weather values specially. */ - /* Flatten the nested structure of Weather value */ valueMapping = - Stream.concat( - Stream.concat( - Stream.concat( - mapFieldNameToGetter( - valueClass, - Arrays.asList("solarIrradiance", "temperature", "wind")) - .entrySet() - .stream() - .map( - entry -> - new AbstractMap.SimpleEntry<>( - entry.getKey(), - new FieldSourceToMethod(VALUE, entry.getValue()))), - mapFieldNameToGetter(SolarIrradianceValue.class).entrySet().stream() - .map( - entry -> - new AbstractMap.SimpleEntry<>( - entry.getKey(), - new FieldSourceToMethod( - WEATHER_IRRADIANCE, entry.getValue())))), - mapFieldNameToGetter(TemperatureValue.class).entrySet().stream() - .map( - entry -> - new AbstractMap.SimpleEntry<>( - entry.getKey(), - new FieldSourceToMethod( - WEATHER_TEMPERATURE, entry.getValue())))), - mapFieldNameToGetter(WindValue.class).entrySet().stream() - .map( - entry -> - new AbstractMap.SimpleEntry<>( - entry.getKey(), - new FieldSourceToMethod(WEATHER_WIND, entry.getValue())))) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + mapFieldNameToGetter(valueClass).entrySet().stream() + .collect( + Collectors.toMap( + Map.Entry::getKey, + entry -> new FieldSourceToMethod(VALUE, entry.getValue()))); } - /* Put everything together */ HashMap jointMapping = new HashMap<>(); jointMapping.putAll(timeSeriesMapping); jointMapping.putAll(entryMapping); jointMapping.putAll(valueMapping); - /* Let uuid be the first entry */ return putUuidFirst(jointMapping); } @@ -195,12 +138,6 @@ public LinkedHashMap handleEntity(TimeSeries entity) { "Don't invoke this simple method, but TimeSeriesProcessor#handleTimeSeries(TimeSeries)."); } - /** - * Handles the time series by processing each entry and collecting the results - * - * @param timeSeries Time series to handle - * @return A set of mappings from field name to value - */ public Set> handleTimeSeries(T timeSeries) throws EntityProcessorException { TimeSeriesProcessorKey key = new TimeSeriesProcessorKey(timeSeries); @@ -218,48 +155,23 @@ public Set> handleTimeSeries(T timeSeries) for (E entry : timeSeries.getEntries()) { Map entryResult = handleEntry(timeSeries, entry); - - /* Prepare the actual result and add them to the set of all results */ fieldToValueSet.add(new LinkedHashMap<>(entryResult)); } return fieldToValueSet; } - /** - * Processes a single entry to a mapping from field name to value as String representation. The - * information from the time series are added as well. - * - * @param timeSeries Time series for additional information - * @param entry Actual entry to handle - * @return A sorted map from field name to value as String representation - */ private Map handleEntry(T timeSeries, E entry) throws EntityProcessorException { - /* Handle the information in the time series */ Map timeSeriesFieldToMethod = extractFieldToMethod(TIMESERIES); LinkedHashMap timeSeriesResults = processObject(timeSeries, timeSeriesFieldToMethod); - /* Handle the information in the entry */ Map entryFieldToMethod = extractFieldToMethod(ENTRY); LinkedHashMap entryResults = processObject(entry, entryFieldToMethod); - /* Handle the information in the value */ Map valueFieldToMethod = extractFieldToMethod(VALUE); LinkedHashMap valueResult = processObject(entry.getValue(), valueFieldToMethod); - /* Treat WeatherValues specially, as they are nested ones */ - if (entry.getValue() instanceof WeatherValue weatherValue) { - Map irradianceFieldToMethod = extractFieldToMethod(WEATHER_IRRADIANCE); - valueResult.putAll(processObject(weatherValue.getSolarIrradiance(), irradianceFieldToMethod)); - - Map temperatureFieldToMethod = extractFieldToMethod(WEATHER_TEMPERATURE); - valueResult.putAll(processObject(weatherValue.getTemperature(), temperatureFieldToMethod)); - - Map windFieldToMethod = extractFieldToMethod(WEATHER_WIND); - valueResult.putAll(processObject(weatherValue.getWind(), windFieldToMethod)); - } - /* Join all information and sort them */ Map combinedResult = new HashMap<>(); combinedResult.putAll(timeSeriesResults); combinedResult.putAll(entryResults); @@ -267,12 +179,6 @@ private Map handleEntry(T timeSeries, E entry) throws EntityProc return putUuidFirst(combinedResult); } - /** - * Extracts the field name to method map for the specific source - * - * @param source Source to extract field name to methods for - * @return Field name to methods for the desired source - */ private Map extractFieldToMethod(FieldSourceToMethod.FieldSource source) { return fieldToSource.entrySet().stream() .filter(entry -> entry.getValue().source().equals(source)) diff --git a/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java b/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java index c4ee481bd..4132f02da 100644 --- a/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java +++ b/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java @@ -17,76 +17,63 @@ import org.locationtech.jts.geom.Point; import tech.units.indriya.ComparableQuantity; -/** Describes weather as a combination of solar irradiance, temperature and wind values */ public class WeatherValue implements Value { - /** The coordinate of this weather value set */ private final Point coordinate; - /** solar irradiance values for this coordinate */ - private final SolarIrradianceValue solarIrradiance; + private final ComparableQuantity diffSolar; + private final ComparableQuantity directSolar; + private final ComparableQuantity temperature; + private final ComparableQuantity windDir; + private final ComparableQuantity windVel; + private final Map, TemperatureValue> groundTemperatures; - /** Temperature value for this coordinate */ - private final TemperatureValue temperature; - /** Wind values for this coordinate */ - private final WindValue wind; - - /** Optional: A map of ground temperatures at different depths. The key represents the depth. */ - private Map, TemperatureValue> groundTemperatures = Map.of(); /** * @param coordinate of this weather value set - * @param solarIrradiance values for this coordinate - * @param temperature values for this coordinate - * @param wind values for this coordinate + * @param directSolar Direct solar irradiance + * @param diffSolar Diffuse solar irradiance + * @param temperature Temperature in 2m height + * @param windDir Wind direction + * @param windVel Wind velocity * @param groundTemperatures A map of ground temperatures at different depths */ public WeatherValue( Point coordinate, - SolarIrradianceValue solarIrradiance, - TemperatureValue temperature, - WindValue wind) { + ComparableQuantity directSolar, + ComparableQuantity diffSolar, + ComparableQuantity temperature, + ComparableQuantity windDir, + ComparableQuantity windVel, + Map, TemperatureValue> groundTemperatures) { this.coordinate = coordinate; - this.solarIrradiance = solarIrradiance; + this.directSolar = directSolar; + this.diffSolar = diffSolar; this.temperature = temperature; - this.wind = wind; + this.windDir = windDir; + this.windVel = windVel; this.groundTemperatures = Collections.unmodifiableMap(new HashMap<>(groundTemperatures)); } - /** - * @param coordinate of this weather value set - * @param directSolarIrradiance Direct sun irradiance for this coordinate (typically in W/m²) - * @param diffuseSolarIrradiance Diffuse sun irradiance for this coordinate (typically in W/m²) - * @param temperature for this coordinate (typically in K) - * @param direction Direction, the wind comes from as an angle from north increasing clockwise - * (typically in rad) - * @param velocity Wind velocity for this coordinate (typically in m/s) - */ - public WeatherValue( - Point coordinate, - ComparableQuantity directSolarIrradiance, - ComparableQuantity diffuseSolarIrradiance, - ComparableQuantity temperature, - ComparableQuantity direction, - ComparableQuantity velocity) { - this( - coordinate, - new SolarIrradianceValue(directSolarIrradiance, diffuseSolarIrradiance), - new TemperatureValue(temperature), - new WindValue(direction, velocity)); - } - public Point getCoordinate() { return coordinate; } - public SolarIrradianceValue getSolarIrradiance() { - return solarIrradiance; + public ComparableQuantity getDiffSolar() { + return diffSolar; + } + + public ComparableQuantity getDirectSolar() { + return directSolar; } - public TemperatureValue getTemperature() { + public ComparableQuantity getTemperature() { return temperature; } - public WindValue getWind() { - return wind; + public ComparableQuantity getWindDir() { + return windDir; + } + + public ComparableQuantity getWindVel() { + return windVel; } /** @@ -105,15 +92,18 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) return false; WeatherValue that = (WeatherValue) o; return coordinate.equals(that.coordinate) - && solarIrradiance.equals(that.solarIrradiance) + && diffSolar.equals(that.diffSolar) + && directSolar.equals(that.directSolar) && temperature.equals(that.temperature) - && wind.equals(that.wind) + && windDir.equals(that.windDir) + && windVel.equals(that.windVel) && groundTemperatures.equals(that.groundTemperatures); } @Override public int hashCode() { - return Objects.hash(coordinate, solarIrradiance, temperature, wind, groundTemperatures); + return Objects.hash( + coordinate, diffSolar, directSolar, temperature, windDir, windVel, groundTemperatures); } @Override @@ -121,14 +111,18 @@ public String toString() { return "WeatherValue{" + "coordinate=" + coordinate - + ", solarIrradiance=" - + solarIrradiance + + ", diffSolar=" + + diffSolar + + ", directSolar=" + + directSolar + ", temperature=" + temperature - + ", wind=" - + wind - + groundTemperatures + + ", windDir=" + + windDir + + ", windVel=" + + windVel + ", groundTemperatures=" + + groundTemperatures + '}'; } } diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy index e85aebf3b..5afb30729 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy @@ -7,26 +7,31 @@ package edu.ie3.datamodel.io.factory.timeseries import edu.ie3.datamodel.models.StandardUnits import edu.ie3.datamodel.models.timeseries.individual.TimeBasedValue +import edu.ie3.datamodel.models.value.TemperatureValue import edu.ie3.datamodel.models.value.WeatherValue import edu.ie3.test.common.CosmoWeatherTestData import edu.ie3.util.TimeUtil import spock.lang.Specification import tech.units.indriya.quantity.Quantities +import tech.units.indriya.unit.Units + +import java.util.Optional class CosmoTimeBasedWeatherValueFactoryTest extends Specification { - def "A PsdmTimeBasedWeatherValueFactory should be able to create time series with missing values"() { + def "A CosmoTimeBasedWeatherValueFactory creates values correctly when optional ground temperatures are missing"() { given: - def factory = new CosmoTimeBasedWeatherValueFactory() + def factory = new CosmoTimeBasedWeatherValueFactory(TimeUtil.withDefaults) def coordinate = CosmoWeatherTestData.COORDINATE_193186 def time = TimeUtil.withDefaults.toZonedDateTime("2019-01-01T00:00:00Z") Map parameter = [ - "uuid" : "980f7714-8def-479f-baae-4deed6c8d6d1", "time" : TimeUtil.withDefaults.toString(time), + "uuid" : "980f7714-8def-479f-baae-4deed6c8d6d1", + "coordinateId" : "193186", "diffuseIrradiance": "282.671997070312", "directIrradiance" : "286.872985839844", - "temperature" : "", + "temperature" : "278.019012451172", "windDirection" : "0", "windVelocity" : "1.66103506088257" ] @@ -37,9 +42,10 @@ class CosmoTimeBasedWeatherValueFactoryTest extends Specification { time, new WeatherValue(coordinate, Quantities.getQuantity(286.872985839844d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(282.671997070312d, StandardUnits.SOLAR_IRRADIANCE), - null, + Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE), Quantities.getQuantity(0d, StandardUnits.WIND_DIRECTION), - Quantities.getQuantity(1.66103506088257d, StandardUnits.WIND_VELOCITY))) + Quantities.getQuantity(1.66103506088257d, StandardUnits.WIND_VELOCITY), + Collections.emptyMap())) when: def model = factory.buildModel(data) @@ -48,31 +54,40 @@ class CosmoTimeBasedWeatherValueFactoryTest extends Specification { model == expectedResults } - def "A PsdmTimeBasedWeatherValueFactory should be able to create time series values"() { + def "A CosmoTimeBasedWeatherValueFactory creates values correctly when ground temperatures are present"() { given: - def factory = new CosmoTimeBasedWeatherValueFactory() + def factory = new CosmoTimeBasedWeatherValueFactory(TimeUtil.withDefaults) def coordinate = CosmoWeatherTestData.COORDINATE_193186 def time = TimeUtil.withDefaults.toZonedDateTime("2019-01-01T00:00:00Z") Map parameter = [ - "time" : TimeUtil.withDefaults.toString(time), - "uuid" : "980f7714-8def-479f-baae-4deed6c8d6d1", - "diffuseIrradiance": "282.671997070312", - "directIrradiance" : "286.872985839844", - "temperature" : "278.019012451172", - "windDirection" : "0", - "windVelocity" : "1.66103506088257" + "time" : TimeUtil.withDefaults.toString(time), + "uuid" : "980f7714-8def-479f-baae-4deed6c8d6d1", + "coordinateId" : "193186", + "diffuseIrradiance" : "282.671997070312", + "directIrradiance" : "286.872985839844", + "temperature" : "278.019012451172", + "windDirection" : "0", + "windVelocity" : "1.66103506088257", + "groundTemperatureSurface": "275.5", + "groundTemperature1m" : "279.0" ] def data = new TimeBasedWeatherValueData(parameter, coordinate) + def expectedGroundTemps = [ + (Quantities.getQuantity(0, Units.METRE)): new TemperatureValue(Quantities.getQuantity(275.5d, StandardUnits.TEMPERATURE)), + (Quantities.getQuantity(1, Units.METRE)): new TemperatureValue(Quantities.getQuantity(279.0d, StandardUnits.TEMPERATURE)) + ] + def expectedResults = new TimeBasedValue( time, new WeatherValue(coordinate, Quantities.getQuantity(286.872985839844d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(282.671997070312d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE), Quantities.getQuantity(0d, StandardUnits.WIND_DIRECTION), - Quantities.getQuantity(1.66103506088257d, StandardUnits.WIND_VELOCITY))) + Quantities.getQuantity(1.66103506088257d, StandardUnits.WIND_VELOCITY), + expectedGroundTemps)) when: def model = factory.buildModel(data) @@ -80,4 +95,4 @@ class CosmoTimeBasedWeatherValueFactoryTest extends Specification { then: model == expectedResults } -} +} \ No newline at end of file diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactoryTest.groovy index cac18982c..b87944468 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactoryTest.groovy @@ -6,6 +6,8 @@ package edu.ie3.datamodel.io.factory.timeseries import edu.ie3.datamodel.models.StandardUnits +import edu.ie3.datamodel.models.value.TemperatureValue +import edu.ie3.datamodel.models.value.WeatherValue import edu.ie3.test.common.CosmoWeatherTestData import edu.ie3.util.TimeUtil import edu.ie3.util.quantities.PowerSystemUnits @@ -15,6 +17,8 @@ import spock.lang.Specification import tech.units.indriya.quantity.Quantities import tech.units.indriya.unit.Units +import java.util.Optional + class IconTimeBasedWeatherValueFactoryTest extends Specification { def "A time based weather value factory for ICON column scheme determines wind velocity angle correctly"() { given: @@ -77,34 +81,50 @@ class IconTimeBasedWeatherValueFactoryTest extends Specification { def parameter = [ "time" : "2019-08-01T01:00:00Z", - "albRad" : "13.015240669", - "asobS" : "3.555093673828124", "aswdifdS" : "1.8088226191406245", - "aswdifuS" : "0.5713421484374998", "aswdirS" : "2.317613203124999", "t2m" : "289.1179319051744", - "tg" : "288.4101691197649", - "u10m" : "0.3021732864307963", + "tG" : "288.4101691197649", "u131m" : "2.6058700426057797", - "u20m" : "0.32384365019387784", - "u216m" : "3.9015497418041756", - "u65m" : "1.2823686334340363", - "v10m" : "1.3852550649486943", "v131m" : "3.8391590569599927", - "v20m" : "1.3726831152710628", - "v216m" : "4.339362039492466", - "v65m" : "2.809877942347672", - "w131m" : "-0.02633474740256081", - "w20m" : "-0.0100060345167524", - "w216m" : "-0.030348050471342078", - "w65m" : "-0.01817112027569893", - "z0" : "0.955323922526438", - "coordinateId": "67775", - "p131m" : "", - "p20m" : "", - "p65m" : "", - "sobsRad" : "", - "t131m" : "" + "coordinateId": "67775" + ] + def data = new TimeBasedWeatherValueData(parameter, coordinate) + + when: + def actual = factory.buildModel(data) + + then: + actual.with { + it.time == TimeUtil.withDefaults.toZonedDateTime("2019-08-01T01:00:00Z") + it.value.coordinate == coordinate + it.value.directSolar == Quantities.getQuantity(2.317613203124999, StandardUnits.SOLAR_IRRADIANCE) + it.value.diffSolar == Quantities.getQuantity(1.8088226191406245, StandardUnits.SOLAR_IRRADIANCE) + QuantityUtil.isEquivalentAbs(it.value.temperature, Quantities.getQuantity(289.1179319051744d, Units.KELVIN).to(StandardUnits.TEMPERATURE), 1e-6) + QuantityUtil.isEquivalentAbs(it.value.windDir, Quantities.getQuantity(214.16711674907722, StandardUnits.WIND_DIRECTION), 1e-6) + QuantityUtil.isEquivalentAbs(it.value.windVel, Quantities.getQuantity(4.640010877529081, StandardUnits.WIND_VELOCITY), 1e-6) + + it.value.groundTemperatures.size() == 1 + def expectedGroundTemp = new TemperatureValue(Quantities.getQuantity(288.4101691197649d, Units.KELVIN).to(StandardUnits.TEMPERATURE)) + it.value.groundTemperatures[Quantities.getQuantity(0, Units.METRE)] == expectedGroundTemp + } + } + + def "A time based weather value factory for ICON column scheme builds a value with all ground temperatures"() { + given: + def factory = new IconTimeBasedWeatherValueFactory() + def coordinate = CosmoWeatherTestData.COORDINATE_67775 + + def parameter = [ + "time" : "2019-08-01T01:00:00Z", + "aswdifdS" : "1.80", + "aswdirS" : "2.31", + "t2m" : "289.11", + "tG" : "288.41", + "tso100cm" : "286.5", + "u131m" : "2.60", + "v131m" : "3.83", + "coordinateId": "67775" ] def data = new TimeBasedWeatherValueData(parameter, coordinate) @@ -113,18 +133,12 @@ class IconTimeBasedWeatherValueFactoryTest extends Specification { then: actual.with { - assert it.time == TimeUtil.withDefaults.toZonedDateTime("2019-08-01T01:00:00Z") - assert it.value.coordinate == coordinate - assert it.value.solarIrradiance.directIrradiance.present - assert it.value.solarIrradiance.directIrradiance.get() == Quantities.getQuantity(0.002317613203124999, PowerSystemUnits.KILOWATT_PER_SQUAREMETRE) - assert it.value.solarIrradiance.diffuseIrradiance.present - assert it.value.solarIrradiance.diffuseIrradiance.get() == Quantities.getQuantity(0.0018088226191406245, PowerSystemUnits.KILOWATT_PER_SQUAREMETRE) - assert it.value.temperature.temperature.present - assert QuantityUtil.isEquivalentAbs(it.value.temperature.temperature.get(), Quantities.getQuantity(15.9679319051744, Units.CELSIUS)) - assert it.value.wind.direction.present - assert QuantityUtil.isEquivalentAbs(it.value.wind.direction.get(), Quantities.getQuantity(214.16711674907722, PowerSystemUnits.DEGREE_GEOM)) - assert it.value.wind.velocity.present - assert QuantityUtil.isEquivalentAbs(it.value.wind.velocity.get(), Quantities.getQuantity(4.640010877529081, PowerSystemUnits.METRE_PER_SECOND)) + it.value.groundTemperatures.size() == 2 + def expectedSurfaceTemp = new TemperatureValue(Quantities.getQuantity(288.41d, Units.KELVIN).to(StandardUnits.TEMPERATURE)) + def expected1mTemp = new TemperatureValue(Quantities.getQuantity(286.5d, Units.KELVIN).to(StandardUnits.TEMPERATURE)) + + it.value.groundTemperatures[Quantities.getQuantity(0, Units.METRE)] == expectedSurfaceTemp + it.value.groundTemperatures[Quantities.getQuantity(1, Units.METRE)] == expected1mTemp } } -} +} \ No newline at end of file diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/couchbase/CouchbaseWeatherSourceCosmoIT.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/couchbase/CouchbaseWeatherSourceCosmoIT.groovy index a032cb5bc..31ddd62d0 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/couchbase/CouchbaseWeatherSourceCosmoIT.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/couchbase/CouchbaseWeatherSourceCosmoIT.groovy @@ -13,6 +13,7 @@ import edu.ie3.datamodel.models.value.WeatherValue import edu.ie3.test.common.CosmoWeatherTestData import edu.ie3.test.helper.TestContainerHelper import edu.ie3.test.helper.WeatherSourceTestHelper +import edu.ie3.util.TimeUtil import edu.ie3.util.interval.ClosedInterval import org.locationtech.jts.geom.Point import org.testcontainers.couchbase.BucketDefinition @@ -25,7 +26,7 @@ import spock.lang.Specification import java.time.Duration @Testcontainers -class CouchbaseWeatherSourceCosmoIT extends Specification implements TestContainerHelper, WeatherSourceTestHelper { +class CouchbaseWeatherSourceCosmoIT extends Specification implements TestContainerHelper { @Shared BucketDefinition bucketDefinition = new BucketDefinition("ie3_in") @@ -34,7 +35,7 @@ class CouchbaseWeatherSourceCosmoIT extends Specification implements TestContain CouchbaseContainer couchbaseContainer = new CouchbaseContainer("couchbase/server:6.6.0") .withBucket(bucketDefinition) .withExposedPorts(8091, 8092, 8093, 8094, 11210) - .withStartupAttempts(3) // 3 attempts because startup (node renaming) sometimes fails when executed too early + .withStartupAttempts(3) @Shared CouchbaseWeatherSource source @@ -42,18 +43,15 @@ class CouchbaseWeatherSourceCosmoIT extends Specification implements TestContain static String coordinateIdColumnName = "coordinateid" def setupSpec() { - // Copy import file with json array of documents into docker MountableFile couchbaseWeatherJsonsFile = getMountableFile("_weather/cosmo/weather.json") couchbaseContainer.copyFileToContainer(couchbaseWeatherJsonsFile, "/home/weather_cosmo.json") - // create an index for the document keys couchbaseContainer.execInContainer("cbq", "-e", "http://localhost:8093", "-u", couchbaseContainer.username, "-p", couchbaseContainer.password, "-s", "CREATE index id_idx ON `" + bucketDefinition.name + "` (META().id);") - //import the json documents from the copied file couchbaseContainer.execInContainer("cbimport", "json", "-cluster", "http://localhost:8091", "--bucket", "ie3_in", @@ -63,7 +61,6 @@ class CouchbaseWeatherSourceCosmoIT extends Specification implements TestContain "--generate-key", "weather::%" + coordinateIdColumnName + "%::%time%", "--dataset", "file:///home/weather_cosmo.json") - // increased timeout to deal with CI under high load def connector = new CouchbaseConnector( couchbaseContainer.connectionString, bucketDefinition.name, @@ -71,7 +68,7 @@ class CouchbaseWeatherSourceCosmoIT extends Specification implements TestContain couchbaseContainer.password, Duration.ofSeconds(20)) def dtfPattern = "yyyy-MM-dd'T'HH:mm:ssxxx" - def weatherFactory = new CosmoTimeBasedWeatherValueFactory() + def weatherFactory = new CosmoTimeBasedWeatherValueFactory(TimeUtil.withDefaults) source = new CouchbaseWeatherSource(connector, CosmoWeatherTestData.coordinateSource, coordinateIdColumnName, weatherFactory, dtfPattern) } @@ -91,7 +88,7 @@ class CouchbaseWeatherSourceCosmoIT extends Specification implements TestContain then: optTimeBasedValue.present - equalsIgnoreUUID(optTimeBasedValue.get(), expectedTimeBasedValue) + WeatherSourceTestHelper.equalsIgnoreUUID(optTimeBasedValue.get(), expectedTimeBasedValue) } def "A CouchbaseWeatherSource can read multiple time series values for multiple coordinates"() { @@ -115,8 +112,8 @@ class CouchbaseWeatherSourceCosmoIT extends Specification implements TestContain Map> coordinateToTimeSeries = source.getWeather(timeInterval, coordinates) then: coordinateToTimeSeries.keySet().size() == 2 - equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193186), timeSeries193186) - equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193187), timeSeries193187) + WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193186), timeSeries193186) + WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193187), timeSeries193187) } @@ -143,9 +140,9 @@ class CouchbaseWeatherSourceCosmoIT extends Specification implements TestContain Map> coordinateToTimeSeries = source.getWeather(timeInterval) then: coordinateToTimeSeries.keySet().size() == 3 - equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193186).entries, timeSeries193186.entries) - equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193187).entries, timeSeries193187.entries) - equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193188).entries, timeSeries193188.entries) + WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193186).entries, timeSeries193186.entries) + WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193187).entries, timeSeries193187.entries) + WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193188).entries, timeSeries193188.entries) } def "A CouchbaseWeatherSource returns all time keys after a given time key correctly"() { @@ -164,4 +161,4 @@ class CouchbaseWeatherSourceCosmoIT extends Specification implements TestContain ] actual.get(CosmoWeatherTestData.COORDINATE_193187) == [CosmoWeatherTestData.TIME_16H] } -} +} \ No newline at end of file diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/couchbase/CouchbaseWeatherSourceIconIT.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/couchbase/CouchbaseWeatherSourceIconIT.groovy index bf3f272f0..f19709806 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/couchbase/CouchbaseWeatherSourceIconIT.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/couchbase/CouchbaseWeatherSourceIconIT.groovy @@ -24,7 +24,7 @@ import java.time.Duration import java.time.ZoneId @Testcontainers -class CouchbaseWeatherSourceIconIT extends Specification implements TestContainerHelper, WeatherSourceTestHelper { +class CouchbaseWeatherSourceIconIT extends Specification implements TestContainerHelper { @Shared BucketDefinition bucketDefinition = new BucketDefinition("ie3_in") @@ -33,7 +33,7 @@ class CouchbaseWeatherSourceIconIT extends Specification implements TestContaine CouchbaseContainer couchbaseContainer = new CouchbaseContainer("couchbase/server:6.6.0") .withBucket(bucketDefinition) .withExposedPorts(8091, 8092, 8093, 8094, 11210) - .withStartupAttempts(3) // 3 attempts because startup (node renaming) sometimes fails when executed too early + .withStartupAttempts(3) @Shared CouchbaseWeatherSource source @@ -41,18 +41,15 @@ class CouchbaseWeatherSourceIconIT extends Specification implements TestContaine static String coordinateIdColumnName = "coordinateid" def setupSpec() { - // Copy import file with json array of documents into docker def couchbaseWeatherJsonsFile = getMountableFile("_weather/icon/weather.json") couchbaseContainer.copyFileToContainer(couchbaseWeatherJsonsFile, "/home/weather_icon.json") - // create an index for the document keys couchbaseContainer.execInContainer("cbq", "-e", "http://localhost:8093", "-u", couchbaseContainer.username, "-p", couchbaseContainer.password, "-s", "CREATE index id_idx ON `" + bucketDefinition.name + "` (META().id);") - //import the json documents from the copied file couchbaseContainer.execInContainer("cbimport", "json", "-cluster", "http://localhost:8091", "--bucket", "ie3_in", @@ -62,7 +59,6 @@ class CouchbaseWeatherSourceIconIT extends Specification implements TestContaine "--generate-key", "weather::%" + coordinateIdColumnName + "%::%time%", "--dataset", "file:///home/weather_icon.json") - // increased timeout to deal with CI under high load def connector = new CouchbaseConnector( couchbaseContainer.connectionString, bucketDefinition.name, @@ -91,7 +87,7 @@ class CouchbaseWeatherSourceIconIT extends Specification implements TestContaine then: optTimeBasedValue.present - equalsIgnoreUUID(optTimeBasedValue.get(), expectedTimeBasedValue) + WeatherSourceTestHelper.equalsIgnoreUUID(optTimeBasedValue.get(), expectedTimeBasedValue) } def "A CouchbaseWeatherSource can read multiple time series values for multiple coordinates"() { @@ -117,8 +113,8 @@ class CouchbaseWeatherSourceIconIT extends Specification implements TestContaine then: coordinateToTimeSeries.keySet().size() == 2 - equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67775), timeSeries67775) - equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67776), timeSeries67776) + WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67775), timeSeries67775) + WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67776), timeSeries67776) } def "A CouchbaseWeatherSource can read all weather data in a given time interval"() { @@ -141,8 +137,8 @@ class CouchbaseWeatherSourceIconIT extends Specification implements TestContaine then: coordinateToTimeSeries.keySet().size() == 2 - equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67775).entries, timeSeries67775.entries) - equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67776).entries, timeSeries67776.entries) + WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67775).entries, timeSeries67775.entries) + WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67776).entries, timeSeries67776.entries) } def "The CouchbaseWeatherSource returns all time keys after a given time key correctly"() { @@ -161,4 +157,4 @@ class CouchbaseWeatherSourceIconIT extends Specification implements TestContaine ] actual.get(IconWeatherTestData.COORDINATE_67776) == [IconWeatherTestData.TIME_16H] } -} +} \ No newline at end of file diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceCosmoTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceCosmoTest.groovy index cc5e709f2..2c75f60a4 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceCosmoTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceCosmoTest.groovy @@ -12,10 +12,7 @@ import edu.ie3.datamodel.io.naming.FileNamingStrategy import edu.ie3.datamodel.io.source.IdCoordinateSource import edu.ie3.datamodel.models.timeseries.individual.IndividualTimeSeries import edu.ie3.datamodel.models.timeseries.individual.TimeBasedValue -import edu.ie3.datamodel.models.value.SolarIrradianceValue -import edu.ie3.datamodel.models.value.TemperatureValue import edu.ie3.datamodel.models.value.WeatherValue -import edu.ie3.datamodel.models.value.WindValue import edu.ie3.test.common.CosmoWeatherTestData import edu.ie3.test.helper.WeatherSourceTestHelper import edu.ie3.util.TimeUtil @@ -27,7 +24,9 @@ import spock.lang.Shared import spock.lang.Specification import tech.units.indriya.quantity.Quantities -class CsvWeatherSourceCosmoTest extends Specification implements CsvTestDataMeta, WeatherSourceTestHelper { +import java.util.Collections + +class CsvWeatherSourceCosmoTest extends Specification implements CsvTestDataMeta { @Shared CsvWeatherSource source @@ -37,7 +36,7 @@ class CsvWeatherSourceCosmoTest extends Specification implements CsvTestDataMeta def setupSpec() { coordinateSource = CosmoWeatherTestData.coordinateSource - def weatherFactory = new CosmoTimeBasedWeatherValueFactory() + def weatherFactory = new CosmoTimeBasedWeatherValueFactory(TimeUtil.withDefaults) source = new CsvWeatherSource(";", weatherCosmoFolderPath, new FileNamingStrategy(), coordinateSource, weatherFactory) } @@ -50,7 +49,7 @@ class CsvWeatherSourceCosmoTest extends Specification implements CsvTestDataMeta then: optTimeBasedValue.present - equalsIgnoreUUID(optTimeBasedValue.get(), expectedTimeBasedValue) + WeatherSourceTestHelper.equalsIgnoreUUID(optTimeBasedValue.get(), expectedTimeBasedValue) } def "A CsvWeatherSource can read multiple time series values for multiple coordinates"() { @@ -76,8 +75,8 @@ class CsvWeatherSourceCosmoTest extends Specification implements CsvTestDataMeta then: coordinateToTimeSeries.keySet().size() == 2 - equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193186), timeSeries193186) - equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193187), timeSeries193187) + WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193186), timeSeries193186) + WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193187), timeSeries193187) } @@ -105,9 +104,9 @@ class CsvWeatherSourceCosmoTest extends Specification implements CsvTestDataMeta then: coordinateToTimeSeries.keySet().size() == 3 - equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193186).entries, timeSeries193186.entries) - equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193187).entries, timeSeries193187.entries) - equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193188).entries, timeSeries193188.entries) + WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193186).entries, timeSeries193186.entries) + WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193187).entries, timeSeries193187.entries) + WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193188).entries, timeSeries193188.entries) } def "The CsvWeatherSource is able to build a single WeatherValue from field to value mapping"() { @@ -115,7 +114,7 @@ class CsvWeatherSourceCosmoTest extends Specification implements CsvTestDataMeta def defaultCoordinate = GeoUtils.DEFAULT_GEOMETRY_FACTORY.createPoint(new Coordinate(7.4116482, 51.4843281)) def coordinateSource = Mock(IdCoordinateSource) coordinateSource.getCoordinate(_) >> { args -> args[0] == 5 ? Optional.of(defaultCoordinate) : Optional.empty() } - def weatherFactory = new CosmoTimeBasedWeatherValueFactory() + def weatherFactory = new CosmoTimeBasedWeatherValueFactory(TimeUtil.withDefaults) def source = new CsvWeatherSource(";", weatherCosmoFolderPath, new FileNamingStrategy(), coordinateSource, weatherFactory) def fieldToValues = [ "uuid" : "71a79f59-eebf-40c1-8358-ba7414077d57", @@ -131,17 +130,12 @@ class CsvWeatherSourceCosmoTest extends Specification implements CsvTestDataMeta TimeUtil.withDefaults.toZonedDateTime("2020-10-16T12:40:42Z"), new WeatherValue( defaultCoordinate, - new SolarIrradianceValue( Quantities.getQuantity(1.234, SOLAR_IRRADIANCE), - Quantities.getQuantity(5.678, SOLAR_IRRADIANCE) - ), - new TemperatureValue( - Quantities.getQuantity(9.1011, TEMPERATURE) - ), - new WindValue( - Quantities.getQuantity(12.1314, WIND_DIRECTION), - Quantities.getQuantity(15.1617, WIND_VELOCITY) - ) + Quantities.getQuantity(5.678, SOLAR_IRRADIANCE), + Quantities.getQuantity(9.1011, TEMPERATURE), + Quantities.getQuantity(15.1617, WIND_DIRECTION), + Quantities.getQuantity(12.1314, WIND_VELOCITY), + Collections.emptyMap() ) ) @@ -158,7 +152,7 @@ class CsvWeatherSourceCosmoTest extends Specification implements CsvTestDataMeta def defaultCoordinate = GeoUtils.DEFAULT_GEOMETRY_FACTORY.createPoint(new Coordinate(7.4116482, 51.4843281)) def coordinateSource = Mock(IdCoordinateSource) coordinateSource.getCoordinate(_) >> { args -> args[0] == 5 ? Optional.of(defaultCoordinate) : Optional.empty() } - def weatherFactory = new CosmoTimeBasedWeatherValueFactory() + def weatherFactory = new CosmoTimeBasedWeatherValueFactory(TimeUtil.withDefaults) def source = new CsvWeatherSource(";", weatherCosmoFolderPath, new FileNamingStrategy(), coordinateSource, weatherFactory) def fieldToValues = [ "uuid" : "71a79f59-eebf-40c1-8358-ba7414077d57", @@ -183,7 +177,7 @@ class CsvWeatherSourceCosmoTest extends Specification implements CsvTestDataMeta def defaultCoordinate = GeoUtils.DEFAULT_GEOMETRY_FACTORY.createPoint(new Coordinate(7.4116482, 51.4843281)) def coordinateSource = Mock(IdCoordinateSource) coordinateSource.getCoordinate(_) >> { args -> args[0] == 5 ? Optional.of(defaultCoordinate) : Optional.empty() } - def weatherFactory = new CosmoTimeBasedWeatherValueFactory() + def weatherFactory = new CosmoTimeBasedWeatherValueFactory(TimeUtil.withDefaults) def source = new CsvWeatherSource(";", weatherCosmoFolderPath, new FileNamingStrategy(), coordinateSource, weatherFactory) def fieldToValues = [ "uuid" : "71a79f59-eebf-40c1-8358-ba7414077d57", @@ -206,7 +200,7 @@ class CsvWeatherSourceCosmoTest extends Specification implements CsvTestDataMeta given: def coordinateSource = Mock(IdCoordinateSource) coordinateSource.getCoordinate(_) >> Optional.empty() - def weatherFactory = new CosmoTimeBasedWeatherValueFactory() + def weatherFactory = new CosmoTimeBasedWeatherValueFactory(TimeUtil.withDefaults) def source = new CsvWeatherSource(";", weatherCosmoFolderPath, new FileNamingStrategy(), coordinateSource, weatherFactory) def fieldToValues = [ "uuid" : "71a79f59-eebf-40c1-8358-ba7414077d57", @@ -243,4 +237,4 @@ class CsvWeatherSourceCosmoTest extends Specification implements CsvTestDataMeta actual.get(CosmoWeatherTestData.COORDINATE_193187) == [CosmoWeatherTestData.TIME_16H] actual.get(CosmoWeatherTestData.COORDINATE_193188) == [] } -} +} \ No newline at end of file diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceIconTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceIconTest.groovy index 7d90727b2..fc3497e80 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceIconTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceIconTest.groovy @@ -21,7 +21,7 @@ import org.locationtech.jts.geom.Point import spock.lang.Shared import spock.lang.Specification -class CsvWeatherSourceIconTest extends Specification implements CsvTestDataMeta, WeatherSourceTestHelper { +class CsvWeatherSourceIconTest extends Specification implements CsvTestDataMeta { @Shared CsvWeatherSource source @@ -44,7 +44,7 @@ class CsvWeatherSourceIconTest extends Specification implements CsvTestDataMeta, then: optTimeBasedValue.present - equalsIgnoreUUID(optTimeBasedValue.get(), expectedTimeBasedValue) + WeatherSourceTestHelper.equalsIgnoreUUID(optTimeBasedValue.get(), expectedTimeBasedValue) } def "A CsvWeatherSource can read multiple time series values for multiple coordinates"() { @@ -70,8 +70,8 @@ class CsvWeatherSourceIconTest extends Specification implements CsvTestDataMeta, then: coordinateToTimeSeries.keySet().size() == 2 - equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67775), timeSeries67775) - equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67776), timeSeries67776) + WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67775), timeSeries67775) + WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67776), timeSeries67776) } @@ -95,8 +95,8 @@ class CsvWeatherSourceIconTest extends Specification implements CsvTestDataMeta, then: coordinateToTimeSeries.keySet().size() == 2 - equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67775).entries, timeSeries67775.entries) - equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67776).entries, timeSeries67776.entries) + WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67775).entries, timeSeries67775.entries) + WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67776).entries, timeSeries67776.entries) } def "The CsvWeatherSource is able to extract correct coordinate from field to value mapping"() { @@ -110,34 +110,7 @@ class CsvWeatherSourceIconTest extends Specification implements CsvTestDataMeta, fieldToValues.putAll( [ "datum" : "2019-08-01 01:00:00", - "albRad" : "13.015240669", - "asobS" : "3.555093673828124", - "aswdifdS" : "1.8088226191406245", - "aswdifuS" : "0.5713421484374998", - "aswdirS" : "2.317613203124999", - "t2m" : "289.1179319051744", - "tg" : "288.4101691197649", - "u10m" : "0.3021732864307963", - "u131m" : "2.6058700426057797", - "u20m" : "0.32384365019387784", - "u216m" : "3.9015497418041756", - "u65m" : "1.2823686334340363", - "v10m" : "1.3852550649486943", - "v131m" : "3.8391590569599927", - "v20m" : "1.3726831152710628", - "v216m" : "4.339362039492466", - "v65m" : "2.809877942347672", - "w131m" : "-0.02633474740256081", - "w20m" : "-0.0100060345167524", - "w216m" : "-0.030348050471342078", - "w65m" : "-0.01817112027569893", - "z0" : "0.955323922526438", "coordinateId": "67775", - "p131m" : "", - "p20m" : "", - "p65m" : "", - "sobsRad" : "", - "t131m" : "" ]) when: @@ -153,37 +126,7 @@ class CsvWeatherSourceIconTest extends Specification implements CsvTestDataMeta, def coordinateSource = new WeatherTestData.DummyIdCoordinateSource() def weatherFactory = new IconTimeBasedWeatherValueFactory() def source = new CsvWeatherSource(",", weatherIconFolderPath, new FileNamingStrategy(), coordinateSource, weatherFactory) - def fieldToValues = [ - "datum" : "2019-08-01 01:00:00", - "albRad" : "13.015240669", - "asobS" : "3.555093673828124", - "aswdifdS" : "1.8088226191406245", - "aswdifuS" : "0.5713421484374998", - "aswdirS" : "2.317613203124999", - "t2m" : "289.1179319051744", - "tg" : "288.4101691197649", - "u10m" : "0.3021732864307963", - "u131m" : "2.6058700426057797", - "u20m" : "0.32384365019387784", - "u216m" : "3.9015497418041756", - "u65m" : "1.2823686334340363", - "v10m" : "1.3852550649486943", - "v131m" : "3.8391590569599927", - "v20m" : "1.3726831152710628", - "v216m" : "4.339362039492466", - "v65m" : "2.809877942347672", - "w131m" : "-0.02633474740256081", - "w20m" : "-0.0100060345167524", - "w216m" : "-0.030348050471342078", - "w65m" : "-0.01817112027569893", - "z0" : "0.955323922526438", - "coordinateId": "", - "p131m" : "", - "p20m" : "", - "p65m" : "", - "sobsRad" : "", - "t131m" : "" - ] + def fieldToValues = ["coordinateId": ""] when: def actual = source.buildWeatherValue(fieldToValues) @@ -197,36 +140,7 @@ class CsvWeatherSourceIconTest extends Specification implements CsvTestDataMeta, def coordinateSource = new WeatherTestData.DummyIdCoordinateSource() def weatherFactory = new IconTimeBasedWeatherValueFactory() def source = new CsvWeatherSource(",", weatherIconFolderPath, new FileNamingStrategy(), coordinateSource, weatherFactory) - def fieldToValues = [ - "datum" : "2019-08-01 01:00:00", - "albRad" : "13.015240669", - "asobS" : "3.555093673828124", - "aswdifdS": "1.8088226191406245", - "aswdifuS": "0.5713421484374998", - "aswdirS" : "2.317613203124999", - "t2m" : "289.1179319051744", - "tg" : "288.4101691197649", - "u10m" : "0.3021732864307963", - "u131m" : "2.6058700426057797", - "u20m" : "0.32384365019387784", - "u216m" : "3.9015497418041756", - "u65m" : "1.2823686334340363", - "v10m" : "1.3852550649486943", - "v131m" : "3.8391590569599927", - "v20m" : "1.3726831152710628", - "v216m" : "4.339362039492466", - "v65m" : "2.809877942347672", - "w131m" : "-0.02633474740256081", - "w20m" : "-0.0100060345167524", - "w216m" : "-0.030348050471342078", - "w65m" : "-0.01817112027569893", - "z0" : "0.955323922526438", - "p131m" : "", - "p20m" : "", - "p65m" : "", - "sobsRad" : "", - "t131m" : "" - ] + def fieldToValues = [:] when: def actual = source.buildWeatherValue(fieldToValues) @@ -237,40 +151,11 @@ class CsvWeatherSourceIconTest extends Specification implements CsvTestDataMeta, def "The CsvWeatherSource returns no WeatherValue, if the coordinate cannot be obtained"() { given: - def coordinateSource = new WeatherTestData.DummyIdCoordinateSource() + def coordinateSource = Mock(IdCoordinateSource) + coordinateSource.getCoordinate(_) >> Optional.empty() def weatherFactory = new IconTimeBasedWeatherValueFactory() def source = new CsvWeatherSource(",", weatherIconFolderPath, new FileNamingStrategy(), coordinateSource, weatherFactory) - def fieldToValues = [ - "datum" : "2019-08-01 01:00:00", - "albrad" : "13.015240669", - "asobS" : "3.555093673828124", - "aswdifdS" : "1.8088226191406245", - "aswdifuS" : "0.5713421484374998", - "aswdirS" : "2.317613203124999", - "t2m" : "289.1179319051744", - "tg" : "288.4101691197649", - "u10m" : "0.3021732864307963", - "u131m" : "2.6058700426057797", - "u20m" : "0.32384365019387784", - "u216m" : "3.9015497418041756", - "u65m" : "1.2823686334340363", - "v10m" : "1.3852550649486943", - "v131m" : "3.8391590569599927", - "v20m" : "1.3726831152710628", - "v216m" : "4.339362039492466", - "v65m" : "2.809877942347672", - "w131m" : "-0.02633474740256081", - "w20m" : "-0.0100060345167524", - "w216m" : "-0.030348050471342078", - "w65m" : "-0.01817112027569893", - "z0" : "0.955323922526438", - "coordinateId": "67777", - "p131m" : "", - "p20m" : "", - "p65m" : "", - "sobsRad" : "", - "t131m" : "" - ] + def fieldToValues = ["coordinateId": "67777"] when: def actual = source.buildWeatherValue(fieldToValues) @@ -295,4 +180,4 @@ class CsvWeatherSourceIconTest extends Specification implements CsvTestDataMeta, ] actual.get(IconWeatherTestData.COORDINATE_67776) == [IconWeatherTestData.TIME_16H] } -} +} \ No newline at end of file diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/influxdb/InfluxDbWeatherSourceCosmoIT.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/influxdb/InfluxDbWeatherSourceCosmoIT.groovy index d2b212a2a..f94790e3e 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/influxdb/InfluxDbWeatherSourceCosmoIT.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/influxdb/InfluxDbWeatherSourceCosmoIT.groovy @@ -13,6 +13,7 @@ import edu.ie3.datamodel.models.value.WeatherValue import edu.ie3.test.common.CosmoWeatherTestData import edu.ie3.test.helper.TestContainerHelper import edu.ie3.test.helper.WeatherSourceTestHelper +import edu.ie3.util.TimeUtil import edu.ie3.util.geo.GeoUtils import edu.ie3.util.interval.ClosedInterval import org.locationtech.jts.geom.Point @@ -24,8 +25,10 @@ import org.testcontainers.utility.MountableFile import spock.lang.Shared import spock.lang.Specification +import java.time.Duration + @Testcontainers -class InfluxDbWeatherSourceCosmoIT extends Specification implements TestContainerHelper, WeatherSourceTestHelper { +class InfluxDbWeatherSourceCosmoIT extends Specification implements TestContainerHelper { @Shared InfluxDBContainer influxDbContainer = new InfluxDBContainer(DockerImageName.parse("influxdb").withTag("1.8.10")) @@ -36,8 +39,6 @@ class InfluxDbWeatherSourceCosmoIT extends Specification implements TestContaine InfluxDbWeatherSource source def setupSpec() { - // Copy import file into docker and then import it via influx CLI - // more information on file format and usage here: https://docs.influxdata.com/influxdb/v1.7/tools/shell/#import-data-from-a-file-with-import MountableFile influxWeatherImportFile = getMountableFile("_weather/cosmo/weather.txt") influxDbContainer.copyFileToContainer(influxWeatherImportFile, "/home/weather_cosmo.txt") @@ -45,7 +46,7 @@ class InfluxDbWeatherSourceCosmoIT extends Specification implements TestContaine assert res.stderr.empty def connector = new InfluxDbConnector(influxDbContainer.url, "test_weather", "test_scenario") - def weatherFactory = new CosmoTimeBasedWeatherValueFactory() + def weatherFactory = new CosmoTimeBasedWeatherValueFactory(TimeUtil.withDefaults) source = new InfluxDbWeatherSource(connector, CosmoWeatherTestData.coordinateSource, weatherFactory) } @@ -66,7 +67,7 @@ class InfluxDbWeatherSourceCosmoIT extends Specification implements TestContaine then: optTimeBasedValue.present - equalsIgnoreUUID(optTimeBasedValue.get(), expectedTimeBasedValue) + WeatherSourceTestHelper.equalsIgnoreUUID(optTimeBasedValue.get(), expectedTimeBasedValue) } def "An InfluxDbWeatherSource can read multiple time series values for multiple coordinates"() { @@ -92,8 +93,8 @@ class InfluxDbWeatherSourceCosmoIT extends Specification implements TestContaine then: coordinateToTimeSeries.keySet().size() == 2 - equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193186), timeseries_193186) - equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193187), timeseries_193187) + WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193186), timeseries_193186) + WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193187), timeseries_193187) } def "An InfluxDbWeatherSource can read all weather data in a given time interval"() { @@ -120,9 +121,9 @@ class InfluxDbWeatherSourceCosmoIT extends Specification implements TestContaine then: coordinateToTimeSeries.keySet().size() == 3 - equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193186).entries, timeseries_193186.entries) - equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193187).entries, timeseries_193187.entries) - equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193188).entries, timeseries_193188.entries) + WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193186).entries, timeseries_193186.entries) + WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193187).entries, timeseries_193187.entries) + WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193188).entries, timeseries_193188.entries) } def "An InfluxDbWeatherSource will return an equivalent to 'empty' when being unable to map a coordinate to its ID"() { @@ -149,9 +150,9 @@ class InfluxDbWeatherSourceCosmoIT extends Specification implements TestContaine then: coordinateAtDate == Optional.empty() - equalsIgnoreUUID(coordinateInInterval, emptyTimeSeries) + WeatherSourceTestHelper.equalsIgnoreUUID(coordinateInInterval, emptyTimeSeries) coordinatesToTimeSeries.keySet() == [validCoordinate].toSet() - equalsIgnoreUUID(coordinatesToTimeSeries.get(validCoordinate), timeseries_193186) + WeatherSourceTestHelper.equalsIgnoreUUID(coordinatesToTimeSeries.get(validCoordinate), timeseries_193186) } def "A InfluxDbWeatherSource returns all time keys after a given time key correctly"() { @@ -170,4 +171,4 @@ class InfluxDbWeatherSourceCosmoIT extends Specification implements TestContaine ] actual.get(CosmoWeatherTestData.COORDINATE_193187) == [CosmoWeatherTestData.TIME_16H] } -} +} \ No newline at end of file diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/influxdb/InfluxDbWeatherSourceIconIT.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/influxdb/InfluxDbWeatherSourceIconIT.groovy index ce3a6dfcb..9b061a778 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/influxdb/InfluxDbWeatherSourceIconIT.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/influxdb/InfluxDbWeatherSourceIconIT.groovy @@ -22,8 +22,12 @@ import org.testcontainers.utility.MountableFile import spock.lang.Shared import spock.lang.Specification +import java.util.Collections +import java.util.Optional +import java.util.UUID + @Testcontainers -class InfluxDbWeatherSourceIconIT extends Specification implements WeatherSourceTestHelper, TestContainerHelper { +class InfluxDbWeatherSourceIconIT extends Specification implements TestContainerHelper { @Shared InfluxDBContainer influxDbContainer = new InfluxDBContainer(DockerImageName.parse("influxdb").withTag("1.8.10")) @@ -34,8 +38,6 @@ class InfluxDbWeatherSourceIconIT extends Specification implements WeatherSource InfluxDbWeatherSource source def setupSpec() { - // Copy import file into docker and then import it via influx CLI - // more information on file format and usage here: https://docs.influxdata.com/influxdb/v1.7/tools/shell/#import-data-from-a-file-with-import MountableFile influxWeatherImportFile = getMountableFile("_weather/icon/weather.txt") influxDbContainer.copyFileToContainer(influxWeatherImportFile, "/home/weather_icon.txt") @@ -64,7 +66,7 @@ class InfluxDbWeatherSourceIconIT extends Specification implements WeatherSource then: optTimeBasedValue.present - equalsIgnoreUUID(optTimeBasedValue.get(), expectedTimeBasedValue) + WeatherSourceTestHelper.equalsIgnoreUUID(optTimeBasedValue.get(), expectedTimeBasedValue) } def "An InfluxDbWeatherSource can read multiple time series values for multiple coordinates"() { @@ -90,8 +92,8 @@ class InfluxDbWeatherSourceIconIT extends Specification implements WeatherSource then: coordinateToTimeSeries.keySet().size() == 2 - equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67775), timeseries67775) - equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67776), timeseries67776) + WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67775), timeseries67775) + WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67776), timeseries67776) } def "An InfluxDbWeatherSource can read all weather data in a given time interval"() { @@ -114,8 +116,8 @@ class InfluxDbWeatherSourceIconIT extends Specification implements WeatherSource then: coordinateToTimeSeries.keySet().size() == 2 - equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67775).entries, timeseries67775.entries) - equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67776).entries, timeseries67776.entries) + WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67775).entries, timeseries67775.entries) + WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67776).entries, timeseries67776.entries) } def "An InfluxDbWeatherSource will return an equivalent to 'empty' when being unable to map a coordinate to its ID"() { @@ -142,9 +144,9 @@ class InfluxDbWeatherSourceIconIT extends Specification implements WeatherSource then: coordinateAtDate == Optional.empty() - equalsIgnoreUUID(coordinateInInterval, emptyTimeSeries) + WeatherSourceTestHelper.equalsIgnoreUUID(coordinateInInterval, emptyTimeSeries) coordinatesToTimeSeries.keySet() == [validCoordinate].toSet() - equalsIgnoreUUID(coordinatesToTimeSeries.get(validCoordinate), timeseries67775) + WeatherSourceTestHelper.equalsIgnoreUUID(coordinatesToTimeSeries.get(validCoordinate), timeseries67775) } def "The InfluxDbWeatherSource returns all time keys after a given time key correctly"() { @@ -163,4 +165,4 @@ class InfluxDbWeatherSourceIconIT extends Specification implements WeatherSource ] actual.get(IconWeatherTestData.COORDINATE_67776) == [IconWeatherTestData.TIME_16H] } -} +} \ No newline at end of file diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/sql/SqlWeatherSourceCosmoIT.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/sql/SqlWeatherSourceCosmoIT.groovy index 1a7e0a0d3..55107802c 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/sql/SqlWeatherSourceCosmoIT.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/sql/SqlWeatherSourceCosmoIT.groovy @@ -13,6 +13,7 @@ import edu.ie3.datamodel.models.value.WeatherValue import edu.ie3.test.common.CosmoWeatherTestData import edu.ie3.test.helper.TestContainerHelper import edu.ie3.test.helper.WeatherSourceTestHelper +import edu.ie3.util.TimeUtil import edu.ie3.util.geo.GeoUtils import edu.ie3.util.interval.ClosedInterval import org.locationtech.jts.geom.Point @@ -24,7 +25,7 @@ import spock.lang.Shared import spock.lang.Specification @Testcontainers -class SqlWeatherSourceCosmoIT extends Specification implements TestContainerHelper, WeatherSourceTestHelper { +class SqlWeatherSourceCosmoIT extends Specification implements TestContainerHelper { @Shared PostgreSQLContainer postgreSQLContainer = new PostgreSQLContainer("postgres:14.2") @@ -36,15 +37,13 @@ class SqlWeatherSourceCosmoIT extends Specification implements TestContainerHelp static String weatherTableName = "weather" def setupSpec() { - // Copy sql import script into docker MountableFile sqlImportFile = getMountableFile("_weather/cosmo/weather.sql") postgreSQLContainer.copyFileToContainer(sqlImportFile, "/home/weather_cosmo.sql") - // Execute import script Container.ExecResult res = postgreSQLContainer.execInContainer("psql", "-Utest", "-f/home/weather_cosmo.sql") assert res.stderr.empty def connector = new SqlConnector(postgreSQLContainer.jdbcUrl, postgreSQLContainer.username, postgreSQLContainer.password) - def weatherFactory = new CosmoTimeBasedWeatherValueFactory() + def weatherFactory = new CosmoTimeBasedWeatherValueFactory(TimeUtil.withDefaults) source = new SqlWeatherSource(connector, CosmoWeatherTestData.coordinateSource, schemaName, weatherTableName, weatherFactory) } @@ -57,7 +56,7 @@ class SqlWeatherSourceCosmoIT extends Specification implements TestContainerHelp then: optTimeBasedValue.present - equalsIgnoreUUID(optTimeBasedValue.get(), expectedTimeBasedValue ) + WeatherSourceTestHelper.equalsIgnoreUUID(optTimeBasedValue.get(), expectedTimeBasedValue ) } def "A SqlWeatherSource returns nothing for an invalid coordinate"() { @@ -91,8 +90,8 @@ class SqlWeatherSourceCosmoIT extends Specification implements TestContainerHelp then: coordinateToTimeSeries.keySet().size() == 2 - equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193186), timeSeries193186) - equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193187), timeSeries193187) + WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193186), timeSeries193186) + WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193187), timeSeries193187) } def "A SqlWeatherSource returns nothing for invalid coordinates"() { @@ -134,9 +133,9 @@ class SqlWeatherSourceCosmoIT extends Specification implements TestContainerHelp then: coordinateToTimeSeries.keySet().size() == 3 - equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193186).entries, timeSeries193186.entries) - equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193187).entries, timeSeries193187.entries) - equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193188).entries, timeSeries193188.entries) + WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193186).entries, timeSeries193186.entries) + WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193187).entries, timeSeries193187.entries) + WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193188).entries, timeSeries193188.entries) } def "A SqlWeatherSource returns all time keys after a given time key correctly"() { @@ -155,4 +154,4 @@ class SqlWeatherSourceCosmoIT extends Specification implements TestContainerHelp ] actual.get(CosmoWeatherTestData.COORDINATE_193187) == [CosmoWeatherTestData.TIME_16H] } -} +} \ No newline at end of file diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/sql/SqlWeatherSourceIconIT.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/sql/SqlWeatherSourceIconIT.groovy index 65cdb72d9..792748be9 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/sql/SqlWeatherSourceIconIT.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/sql/SqlWeatherSourceIconIT.groovy @@ -24,7 +24,7 @@ import spock.lang.Shared import spock.lang.Specification @Testcontainers -class SqlWeatherSourceIconIT extends Specification implements TestContainerHelper, WeatherSourceTestHelper { +class SqlWeatherSourceIconIT extends Specification implements TestContainerHelper { @Shared PostgreSQLContainer postgreSQLContainer = new PostgreSQLContainer("postgres:14.2") @@ -36,10 +36,8 @@ class SqlWeatherSourceIconIT extends Specification implements TestContainerHelpe static String weatherTableName = "weather" def setupSpec() { - // Copy sql import script into docker MountableFile sqlImportFile = getMountableFile("_weather/icon/weather.sql") postgreSQLContainer.copyFileToContainer(sqlImportFile, "/home/weather_icon.sql") - // Execute import script Container.ExecResult res = postgreSQLContainer.execInContainer("psql", "-Utest", "-f/home/weather_icon.sql") assert res.stderr.empty @@ -55,7 +53,7 @@ class SqlWeatherSourceIconIT extends Specification implements TestContainerHelpe def optTimeBasedValue = source.getWeather(IconWeatherTestData.TIME_15H, IconWeatherTestData.COORDINATE_67775) then: optTimeBasedValue.present - equalsIgnoreUUID(optTimeBasedValue.get(), expectedTimeBasedValue ) + WeatherSourceTestHelper.equalsIgnoreUUID(optTimeBasedValue.get(), expectedTimeBasedValue ) } def "A NativeSqlWeatherSource can read multiple timeseries values for multiple coordinates"() { @@ -81,8 +79,8 @@ class SqlWeatherSourceIconIT extends Specification implements TestContainerHelpe then: coordinateToTimeSeries.keySet().size() == 2 - equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67775), timeSeries67775) - equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67776), timeSeries67776) + WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67775), timeSeries67775) + WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67776), timeSeries67776) } def "A NativeSqlWeatherSource can read all weather data in a given time interval"() { @@ -105,8 +103,8 @@ class SqlWeatherSourceIconIT extends Specification implements TestContainerHelpe then: coordinateToTimeSeries.keySet().size() == 2 - equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67775).entries, timeSeries67775.entries) - equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67776).entries, timeSeries67776.entries) + WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67775).entries, timeSeries67775.entries) + WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67776).entries, timeSeries67776.entries) } def "A NativeSqlWeatherSource returns all time keys after a given time key correctly"() { @@ -125,4 +123,4 @@ class SqlWeatherSourceIconIT extends Specification implements TestContainerHelpe ] actual.get(IconWeatherTestData.COORDINATE_67776) == [IconWeatherTestData.TIME_16H] } -} +} \ No newline at end of file diff --git a/src/test/groovy/edu/ie3/datamodel/utils/validation/UniquenessValidationUtilsTest.groovy b/src/test/groovy/edu/ie3/datamodel/utils/validation/UniquenessValidationUtilsTest.groovy index 82066c52c..45a24b586 100644 --- a/src/test/groovy/edu/ie3/datamodel/utils/validation/UniquenessValidationUtilsTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/utils/validation/UniquenessValidationUtilsTest.groovy @@ -21,10 +21,7 @@ import edu.ie3.datamodel.models.result.CongestionResult import edu.ie3.datamodel.models.result.NodeResult import edu.ie3.datamodel.models.result.ResultEntity import edu.ie3.datamodel.models.timeseries.individual.TimeBasedValue -import edu.ie3.datamodel.models.value.SolarIrradianceValue -import edu.ie3.datamodel.models.value.TemperatureValue import edu.ie3.datamodel.models.value.WeatherValue -import edu.ie3.datamodel.models.value.WindValue import edu.ie3.datamodel.utils.Try import edu.ie3.util.geo.GeoUtils import spock.lang.Specification @@ -32,6 +29,7 @@ import tech.units.indriya.quantity.Quantities import tech.units.indriya.unit.Units import java.time.ZonedDateTime +import java.util.Collections import javax.measure.Quantity import javax.measure.quantity.Angle import javax.measure.quantity.Dimensionless @@ -209,9 +207,12 @@ class UniquenessValidationUtilsTest extends Specification { ZonedDateTime time = ZonedDateTime.now() WeatherValue value = new WeatherValue( GeoUtils.buildPoint(50d, 7d), - new SolarIrradianceValue(Quantities.getQuantity(10d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(10d, StandardUnits.SOLAR_IRRADIANCE)), - new TemperatureValue(Quantities.getQuantity(5d, Units.CELSIUS)), - new WindValue(Quantities.getQuantity(5d, DEGREE_GEOM), Quantities.getQuantity(10d, METRE_PER_SECOND)) + Quantities.getQuantity(10d, StandardUnits.SOLAR_IRRADIANCE), + Quantities.getQuantity(10d, StandardUnits.SOLAR_IRRADIANCE), + Quantities.getQuantity(5d, Units.CELSIUS), + Quantities.getQuantity(5d, DEGREE_GEOM), + Quantities.getQuantity(10d, METRE_PER_SECOND), + Collections.emptyMap() ) Set> uniqueValues = [ @@ -231,9 +232,12 @@ class UniquenessValidationUtilsTest extends Specification { ZonedDateTime time = ZonedDateTime.now() WeatherValue value = new WeatherValue( GeoUtils.buildPoint(50d, 7d), - new SolarIrradianceValue(Quantities.getQuantity(10d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(10d, StandardUnits.SOLAR_IRRADIANCE)), - new TemperatureValue(Quantities.getQuantity(5d, Units.CELSIUS)), - new WindValue(Quantities.getQuantity(5d, DEGREE_GEOM), Quantities.getQuantity(10d, METRE_PER_SECOND)) + Quantities.getQuantity(10d, StandardUnits.SOLAR_IRRADIANCE), + Quantities.getQuantity(10d, StandardUnits.SOLAR_IRRADIANCE), + Quantities.getQuantity(5d, Units.CELSIUS), + Quantities.getQuantity(5d, DEGREE_GEOM), + Quantities.getQuantity(10d, METRE_PER_SECOND), + Collections.emptyMap() ) Set> notUniqueValues = [ new TimeBasedValue(time, value), @@ -247,4 +251,4 @@ class UniquenessValidationUtilsTest extends Specification { DuplicateEntitiesException de = thrown() de.message.startsWith("'TimeBasedValue' entities with duplicated") } -} +} \ No newline at end of file diff --git a/src/test/groovy/edu/ie3/test/common/CosmoWeatherTestData.groovy b/src/test/groovy/edu/ie3/test/common/CosmoWeatherTestData.groovy index ac4412c8e..f61cf27c3 100644 --- a/src/test/groovy/edu/ie3/test/common/CosmoWeatherTestData.groovy +++ b/src/test/groovy/edu/ie3/test/common/CosmoWeatherTestData.groovy @@ -10,8 +10,8 @@ import edu.ie3.datamodel.models.value.WeatherValue import edu.ie3.util.TimeUtil import tech.units.indriya.quantity.Quantities -import java.time.ZoneId import java.time.ZonedDateTime +import java.util.Collections class CosmoWeatherTestData extends WeatherTestData { public static final ZonedDateTime TIME_15H = TimeUtil.withDefaults.toZonedDateTime("2020-04-28T15:00:00+00:00") @@ -24,7 +24,8 @@ class CosmoWeatherTestData extends WeatherTestData { Quantities.getQuantity(286.872985839844d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE), Quantities.getQuantity(0d, StandardUnits.WIND_DIRECTION), - Quantities.getQuantity(1.66103506088257d, StandardUnits.WIND_VELOCITY) + Quantities.getQuantity(1.66103506088257d, StandardUnits.WIND_VELOCITY), + Collections.emptyMap() ) public static final WeatherValue WEATHER_VALUE_193186_16H = new WeatherValue( @@ -33,7 +34,8 @@ class CosmoWeatherTestData extends WeatherTestData { Quantities.getQuantity(286.872d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(278.012d, StandardUnits.TEMPERATURE), Quantities.getQuantity(0d, StandardUnits.WIND_DIRECTION), - Quantities.getQuantity(1.662d, StandardUnits.WIND_VELOCITY) + Quantities.getQuantity(1.662d, StandardUnits.WIND_VELOCITY), + Collections.emptyMap() ) public static final WeatherValue WEATHER_VALUE_193186_17H = new WeatherValue( @@ -42,7 +44,8 @@ class CosmoWeatherTestData extends WeatherTestData { Quantities.getQuantity(286.873d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(278.013d, StandardUnits.TEMPERATURE), Quantities.getQuantity(0d, StandardUnits.WIND_DIRECTION), - Quantities.getQuantity(1.663d, StandardUnits.WIND_VELOCITY) + Quantities.getQuantity(1.663d, StandardUnits.WIND_VELOCITY), + Collections.emptyMap() ) public static final WeatherValue WEATHER_VALUE_193187_15H = new WeatherValue( @@ -51,7 +54,8 @@ class CosmoWeatherTestData extends WeatherTestData { Quantities.getQuantity(287.872985839844d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(279.019012451172d, StandardUnits.TEMPERATURE), Quantities.getQuantity(0d, StandardUnits.WIND_DIRECTION), - Quantities.getQuantity(1.76103506088257d, StandardUnits.WIND_VELOCITY) + Quantities.getQuantity(1.76103506088257d, StandardUnits.WIND_VELOCITY), + Collections.emptyMap() ) public static final WeatherValue WEATHER_VALUE_193187_16H = new WeatherValue( @@ -60,7 +64,8 @@ class CosmoWeatherTestData extends WeatherTestData { Quantities.getQuantity(287.872d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(279.012d, StandardUnits.TEMPERATURE), Quantities.getQuantity(0d, StandardUnits.WIND_DIRECTION), - Quantities.getQuantity(1.762d, StandardUnits.WIND_VELOCITY) + Quantities.getQuantity(1.762d, StandardUnits.WIND_VELOCITY), + Collections.emptyMap() ) public static final WeatherValue WEATHER_VALUE_193188_15H = new WeatherValue( @@ -69,6 +74,7 @@ class CosmoWeatherTestData extends WeatherTestData { Quantities.getQuantity(288.872985839844d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(280.019012451172d, StandardUnits.TEMPERATURE), Quantities.getQuantity(0d, StandardUnits.WIND_DIRECTION), - Quantities.getQuantity(1.86103506088257d, StandardUnits.WIND_VELOCITY) + Quantities.getQuantity(1.86103506088257d, StandardUnits.WIND_VELOCITY), + Collections.emptyMap() ) -} +} \ No newline at end of file diff --git a/src/test/groovy/edu/ie3/test/common/IconWeatherTestData.groovy b/src/test/groovy/edu/ie3/test/common/IconWeatherTestData.groovy index 0a251f9d3..265cb03b2 100644 --- a/src/test/groovy/edu/ie3/test/common/IconWeatherTestData.groovy +++ b/src/test/groovy/edu/ie3/test/common/IconWeatherTestData.groovy @@ -6,12 +6,14 @@ package edu.ie3.test.common import edu.ie3.datamodel.models.StandardUnits +import edu.ie3.datamodel.models.value.TemperatureValue import edu.ie3.datamodel.models.value.WeatherValue import edu.ie3.util.TimeUtil import tech.units.indriya.quantity.Quantities +import tech.units.indriya.unit.Units -import java.time.ZoneId import java.time.ZonedDateTime +import java.util.Collections class IconWeatherTestData extends WeatherTestData { public static final ZonedDateTime TIME_15H = TimeUtil.withDefaults.toZonedDateTime("2019-08-01T15:00:00+00:00") @@ -24,7 +26,10 @@ class IconWeatherTestData extends WeatherTestData { Quantities.getQuantity(228.021339757131, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(24.4741992659816, StandardUnits.TEMPERATURE), Quantities.getQuantity(270.45278309919627, StandardUnits.WIND_DIRECTION), - Quantities.getQuantity(3.76601470961371, StandardUnits.WIND_VELOCITY) + Quantities.getQuantity(3.76601470961371, StandardUnits.WIND_VELOCITY), + [ + (Quantities.getQuantity(0, Units.METRE)): new TemperatureValue(Quantities.getQuantity(27.5132065668998, Units.CELSIUS)) + ] ) public static final WeatherValue WEATHER_VALUE_67775_16H = new WeatherValue( @@ -33,7 +38,10 @@ class IconWeatherTestData extends WeatherTestData { Quantities.getQuantity(200.46049098038043, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(24.1700023473353, StandardUnits.TEMPERATURE), Quantities.getQuantity(278.144331776102, StandardUnits.WIND_DIRECTION), - Quantities.getQuantity(4.05744164637287, StandardUnits.WIND_VELOCITY) + Quantities.getQuantity(4.05744164637287, StandardUnits.WIND_VELOCITY), + [ + (Quantities.getQuantity(0, Units.METRE)): new TemperatureValue(Quantities.getQuantity(25.6947737622156, Units.CELSIUS)) + ] ) public static final WeatherValue WEATHER_VALUE_67775_17H = new WeatherValue( @@ -42,7 +50,10 @@ class IconWeatherTestData extends WeatherTestData { Quantities.getQuantity(180.73429610400223, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(23.6787403584074, StandardUnits.TEMPERATURE), Quantities.getQuantity(286.891007103442, StandardUnits.WIND_DIRECTION), - Quantities.getQuantity(3.81526300455393, StandardUnits.WIND_VELOCITY) + Quantities.getQuantity(3.81526300455393, StandardUnits.WIND_VELOCITY), + [ + (Quantities.getQuantity(0, Units.METRE)): new TemperatureValue(Quantities.getQuantity(24.5096017457568, Units.CELSIUS)) + ] ) public static final WeatherValue WEATHER_VALUE_67776_15H = new WeatherValue( @@ -51,15 +62,21 @@ class IconWeatherTestData extends WeatherTestData { Quantities.getQuantity(245.24079037841295, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(22.365335568404, StandardUnits.TEMPERATURE), Quantities.getQuantity(245.604554131632, StandardUnits.WIND_DIRECTION), - Quantities.getQuantity(4.39390441381814, StandardUnits.WIND_VELOCITY) + Quantities.getQuantity(4.39390441381814, StandardUnits.WIND_VELOCITY), + [ + (Quantities.getQuantity(0, Units.METRE)): new TemperatureValue(Quantities.getQuantity(24.28684351873816, Units.CELSIUS)) + ] ) public static final WeatherValue WEATHER_VALUE_67776_16H = new WeatherValue( COORDINATE_67776, - Quantities.getQuantity(091.70939132297, StandardUnits.SOLAR_IRRADIANCE), + Quantities.getQuantity(91.70939132297, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(241.641483540946, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(20.305111314491, StandardUnits.TEMPERATURE), Quantities.getQuantity(252.810224701109, StandardUnits.WIND_DIRECTION), - Quantities.getQuantity(3.44242472583919, StandardUnits.WIND_VELOCITY) + Quantities.getQuantity(3.44242472583919, StandardUnits.WIND_VELOCITY), + [ + (Quantities.getQuantity(0, Units.METRE)): new TemperatureValue(Quantities.getQuantity(21.8376832274387, Units.CELSIUS)) + ] ) -} +} \ No newline at end of file diff --git a/src/test/groovy/edu/ie3/test/common/TimeSeriesTestData.groovy b/src/test/groovy/edu/ie3/test/common/TimeSeriesTestData.groovy index 99925e5ab..9f2195309 100644 --- a/src/test/groovy/edu/ie3/test/common/TimeSeriesTestData.groovy +++ b/src/test/groovy/edu/ie3/test/common/TimeSeriesTestData.groovy @@ -29,6 +29,7 @@ import tech.units.indriya.quantity.Quantities import java.time.ZoneId import java.time.ZonedDateTime +import java.util.Collections trait TimeSeriesTestData { GeometryFactory geometryFactory = new GeometryFactory(new PrecisionModel(), 4326) @@ -58,16 +59,16 @@ trait TimeSeriesTestData { Set> individualEnergyPriceTimeSeriesProcessed = [ [ - "time" : "2020-04-02T10:00:00Z", - "price" : "5.0" + "time" : "2020-04-02T10:00:00Z", + "price" : "5.0" ] as LinkedHashMap, [ - "time" : "2020-04-02T10:15:00Z", - "price" : "15.0" + "time" : "2020-04-02T10:15:00Z", + "price" : "15.0" ] as LinkedHashMap, [ - "time" : "2020-04-02T10:30:00Z", - "price" : "10.0" + "time" : "2020-04-02T10:30:00Z", + "price" : "10.0" ] as LinkedHashMap ] as Set @@ -97,16 +98,16 @@ trait TimeSeriesTestData { Set> individualTemperatureTimeSeriesProcessed = [ [ - "time" : "2020-04-02T10:00:00Z", - "temperature" : "5.0" + "time" : "2020-04-02T10:00:00Z", + "temperature" : "5.0" ] as LinkedHashMap, [ - "time" : "2020-04-02T10:15:00Z", - "temperature" : "15.0" + "time" : "2020-04-02T10:15:00Z", + "temperature" : "15.0" ] as LinkedHashMap, [ - "time" : "2020-04-02T10:30:00Z", - "temperature" : "10.0" + "time" : "2020-04-02T10:30:00Z", + "temperature" : "10.0" ] as LinkedHashMap ] as Set @@ -127,19 +128,19 @@ trait TimeSeriesTestData { Set> individualWindTimeSeriesProcessed = [ [ - "direction" : "5.0", - "time" : "2020-04-02T10:00:00Z", - "velocity" : "10.0" + "direction" : "5.0", + "time" : "2020-04-02T10:00:00Z", + "velocity" : "10.0" ] as LinkedHashMap, [ - "direction" : "15.0", - "time" : "2020-04-02T10:15:00Z", - "velocity" : "20.0" + "direction" : "15.0", + "time" : "2020-04-02T10:15:00Z", + "velocity" : "20.0" ] as LinkedHashMap, [ - "direction" : "10.0", - "time" : "2020-04-02T10:30:00Z", - "velocity" : "15.0" + "direction" : "10.0", + "time" : "2020-04-02T10:30:00Z", + "velocity" : "15.0" ] as LinkedHashMap ] as Set @@ -160,19 +161,19 @@ trait TimeSeriesTestData { Set> individualIrradianceTimeSeriesProcessed = [ [ - "directIrradiance" : "5.0", - "diffuseIrradiance" : "10.0", - "time" : "2020-04-02T10:00:00Z" + "directIrradiance" : "5.0", + "diffuseIrradiance" : "10.0", + "time" : "2020-04-02T10:00:00Z" ] as LinkedHashMap, [ - "directIrradiance" : "15.0", - "diffuseIrradiance" : "20.0", - "time" : "2020-04-02T10:15:00Z" + "directIrradiance" : "15.0", + "diffuseIrradiance" : "20.0", + "time" : "2020-04-02T10:15:00Z" ] as LinkedHashMap, [ - "directIrradiance" : "10.0", - "diffuseIrradiance" : "15.0", - "time" : "2020-04-02T10:30:00Z" + "directIrradiance" : "10.0", + "diffuseIrradiance" : "15.0", + "time" : "2020-04-02T10:30:00Z" ] as LinkedHashMap ] as Set @@ -183,27 +184,36 @@ trait TimeSeriesTestData { ZonedDateTime.of(2020, 4, 2, 10, 0, 0, 0, ZoneId.of("UTC")), new WeatherValue( defaultLocation, - new SolarIrradianceValue(Quantities.getQuantity(5d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(10d, StandardUnits.SOLAR_IRRADIANCE)), - new TemperatureValue(Quantities.getQuantity(5d, CELSIUS)), - new WindValue(Quantities.getQuantity(5d, DEGREE_GEOM), Quantities.getQuantity(10d, METRE_PER_SECOND)) + Quantities.getQuantity(5d, StandardUnits.SOLAR_IRRADIANCE), + Quantities.getQuantity(10d, StandardUnits.SOLAR_IRRADIANCE), + Quantities.getQuantity(5d, CELSIUS), + Quantities.getQuantity(5d, DEGREE_GEOM), + Quantities.getQuantity(10d, METRE_PER_SECOND), + Collections.emptyMap() ) ), new TimeBasedValue<>( ZonedDateTime.of(2020, 4, 2, 10, 15, 0, 0, ZoneId.of("UTC")), new WeatherValue( defaultLocation, - new SolarIrradianceValue(Quantities.getQuantity(15d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(20d, StandardUnits.SOLAR_IRRADIANCE)), - new TemperatureValue(Quantities.getQuantity(15d, CELSIUS)), - new WindValue(Quantities.getQuantity(15d, DEGREE_GEOM), Quantities.getQuantity(20d, METRE_PER_SECOND)) + Quantities.getQuantity(15d, StandardUnits.SOLAR_IRRADIANCE), + Quantities.getQuantity(20d, StandardUnits.SOLAR_IRRADIANCE), + Quantities.getQuantity(15d, CELSIUS), + Quantities.getQuantity(15d, DEGREE_GEOM), + Quantities.getQuantity(20d, METRE_PER_SECOND), + Collections.emptyMap() ) ), new TimeBasedValue<>( ZonedDateTime.of(2020, 4, 2, 10, 30, 0, 0, ZoneId.of("UTC")), new WeatherValue( defaultLocation, - new SolarIrradianceValue(Quantities.getQuantity(10d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(15d, StandardUnits.SOLAR_IRRADIANCE)), - new TemperatureValue(Quantities.getQuantity(10d, CELSIUS)), - new WindValue(Quantities.getQuantity(10d, DEGREE_GEOM), Quantities.getQuantity(15d, METRE_PER_SECOND)) + Quantities.getQuantity(10d, StandardUnits.SOLAR_IRRADIANCE), + Quantities.getQuantity(15d, StandardUnits.SOLAR_IRRADIANCE), + Quantities.getQuantity(10d, CELSIUS), + Quantities.getQuantity(10d, DEGREE_GEOM), + Quantities.getQuantity(15d, METRE_PER_SECOND), + Collections.emptyMap() ) ), ] as Set @@ -211,31 +221,31 @@ trait TimeSeriesTestData { Set> individualWeatherTimeSeriesProcessed = [ [ - "coordinate" : "{\"type\":\"Point\",\"coordinates\":[7.412152,51.492758],\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}}}", - "diffuseIrradiance" : "10.0", - "directIrradiance" : "5.0", - "direction" : "5.0", - "temperature" : "5.0", - "time" : "2020-04-02T10:00:00Z", - "velocity" : "10.0" + "coordinate" : "{\"type\":\"Point\",\"coordinates\":[7.412152,51.492758],\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}}}", + "diffSolar" : "10.0", + "directSolar" : "5.0", + "windDir" : "5.0", + "temperature" : "5.0", + "time" : "2020-04-02T10:00:00Z", + "windVel" : "10.0" ] as LinkedHashMap, [ - "coordinate" : "{\"type\":\"Point\",\"coordinates\":[7.412152,51.492758],\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}}}", - "diffuseIrradiance" : "20.0", - "directIrradiance" : "15.0", - "direction" : "15.0", - "temperature" : "15.0", - "time" : "2020-04-02T10:15:00Z", - "velocity" : "20.0" + "coordinate" : "{\"type\":\"Point\",\"coordinates\":[7.412152,51.492758],\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}}}", + "diffSolar" : "20.0", + "directSolar" : "15.0", + "windDir" : "15.0", + "temperature" : "15.0", + "time" : "2020-04-02T10:15:00Z", + "windVel" : "20.0" ] as LinkedHashMap, [ - "coordinate" : "{\"type\":\"Point\",\"coordinates\":[7.412152,51.492758],\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}}}", - "diffuseIrradiance" : "15.0", - "directIrradiance" : "10.0", - "direction" : "10.0", - "temperature" : "10.0", - "time" : "2020-04-02T10:30:00Z", - "velocity" : "15.0" + "coordinate" : "{\"type\":\"Point\",\"coordinates\":[7.412152,51.492758],\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}}}", + "diffSolar" : "15.0", + "directSolar" : "10.0", + "windDir" : "10.0", + "temperature" : "10.0", + "time" : "2020-04-02T10:30:00Z", + "windVel" : "15.0" ] as LinkedHashMap ] as Set @@ -256,16 +266,16 @@ trait TimeSeriesTestData { Set> individualHeatDemandTimeSeriesProcessed = [ [ - "heatDemand" : "5.0", - "time" : "2020-04-02T10:00:00Z" + "heatDemand" : "5.0", + "time" : "2020-04-02T10:00:00Z" ] as LinkedHashMap, [ - "heatDemand" : "15.0", - "time" : "2020-04-02T10:15:00Z" + "heatDemand" : "15.0", + "time" : "2020-04-02T10:15:00Z" ] as LinkedHashMap, [ - "heatDemand" : "10.0", - "time" : "2020-04-02T10:30:00Z" + "heatDemand" : "10.0", + "time" : "2020-04-02T10:30:00Z" ] as LinkedHashMap ] as Set @@ -286,16 +296,16 @@ trait TimeSeriesTestData { Set> individualPTimeSeriesProcessed = [ [ - "p" : "5.0", - "time" : "2020-04-02T10:00:00Z" + "p" : "5.0", + "time" : "2020-04-02T10:00:00Z" ] as LinkedHashMap, [ - "p" : "15.0", - "time" : "2020-04-02T10:15:00Z" + "p" : "15.0", + "time" : "2020-04-02T10:15:00Z" ] as LinkedHashMap, [ - "p" : "10.0", - "time" : "2020-04-02T10:30:00Z" + "p" : "10.0", + "time" : "2020-04-02T10:30:00Z" ] as LinkedHashMap ] as Set @@ -316,19 +326,19 @@ trait TimeSeriesTestData { Set> individualHeatAndPTimeSeriesProcessed = [ [ - "heatDemand" : "10.0", - "p" : "5.0", - "time" : "2020-04-02T10:00:00Z" + "heatDemand" : "10.0", + "p" : "5.0", + "time" : "2020-04-02T10:00:00Z" ] as LinkedHashMap, [ - "heatDemand" : "20.0", - "p" : "15.0", - "time" : "2020-04-02T10:15:00Z" + "heatDemand" : "20.0", + "p" : "15.0", + "time" : "2020-04-02T10:15:00Z" ] as LinkedHashMap, [ - "heatDemand" : "15.0", - "p" : "10.0", - "time" : "2020-04-02T10:30:00Z" + "heatDemand" : "15.0", + "p" : "10.0", + "time" : "2020-04-02T10:30:00Z" ] as LinkedHashMap ] as Set @@ -349,19 +359,19 @@ trait TimeSeriesTestData { Set> individualSTimeSeriesProcessed = [ [ - "p" : "5.0", - "q" : "10.0", - "time" : "2020-04-02T10:00:00Z" + "p" : "5.0", + "q" : "10.0", + "time" : "2020-04-02T10:00:00Z" ] as LinkedHashMap, [ - "p" : "15.0", - "q" : "20.0", - "time" : "2020-04-02T10:15:00Z" + "p" : "15.0", + "q" : "20.0", + "time" : "2020-04-02T10:15:00Z" ] as LinkedHashMap, [ - "p" : "10.0", - "q" : "15.0", - "time" : "2020-04-02T10:30:00Z" + "p" : "10.0", + "q" : "15.0", + "time" : "2020-04-02T10:30:00Z" ] as LinkedHashMap ] as Set @@ -382,22 +392,22 @@ trait TimeSeriesTestData { Set> individualHeatAndSTimeSeriesProcessed = [ [ - "heatDemand" : "15.0", - "p" : "5.0", - "q" : "10.0", - "time" : "2020-04-02T10:00:00Z" + "heatDemand" : "15.0", + "p" : "5.0", + "q" : "10.0", + "time" : "2020-04-02T10:00:00Z" ] as LinkedHashMap, [ - "heatDemand" : "25.0", - "p" : "15.0", - "q" : "20.0", - "time" : "2020-04-02T10:15:00Z" + "heatDemand" : "25.0", + "p" : "15.0", + "q" : "20.0", + "time" : "2020-04-02T10:15:00Z" ] as LinkedHashMap, [ - "heatDemand" : "20.0", - "p" : "10.0", - "q" : "15.0", - "time" : "2020-04-02T10:30:00Z" + "heatDemand" : "20.0", + "p" : "10.0", + "q" : "15.0", + "time" : "2020-04-02T10:30:00Z" ] as LinkedHashMap ] as Set diff --git a/src/test/groovy/edu/ie3/test/helper/WeatherSourceTestHelper.groovy b/src/test/groovy/edu/ie3/test/helper/WeatherSourceTestHelper.groovy index 6c4576d9e..c8459baca 100644 --- a/src/test/groovy/edu/ie3/test/helper/WeatherSourceTestHelper.groovy +++ b/src/test/groovy/edu/ie3/test/helper/WeatherSourceTestHelper.groovy @@ -10,11 +10,11 @@ import edu.ie3.datamodel.models.timeseries.individual.TimeBasedValue import edu.ie3.datamodel.models.value.WeatherValue import edu.ie3.util.quantities.QuantityUtil -trait WeatherSourceTestHelper { +class WeatherSourceTestHelper { static boolean equalsIgnoreUUID(IndividualTimeSeries ts1, IndividualTimeSeries ts2) { - return equalsIgnoreUUID(ts1.entries, ts2.entries) + return WeatherSourceTestHelper.equalsIgnoreUUID(ts1.entries, ts2.entries) } static boolean equalsIgnoreUUID(Collection> c1, @@ -22,7 +22,7 @@ trait WeatherSourceTestHelper { if (c1 == null || c2 == null) return (c1 == null && c2 == null) if (c1.size() != c2.size()) return false for (TimeBasedValue value1 : c1) { - if (!c2.stream().anyMatch({ value2 -> equalsIgnoreUUID(value1, value2) })) return false + if (!c2.stream().anyMatch({ value2 -> WeatherSourceTestHelper.equalsIgnoreUUID(value1, value2) })) return false } return true } @@ -33,10 +33,11 @@ trait WeatherSourceTestHelper { def weatherValue1 = val1.value def weatherValue2 = val2.value - return weatherValue1.solarIrradiance.directIrradiance.present == weatherValue2.solarIrradiance.directIrradiance.present && QuantityUtil.isEquivalentAbs(weatherValue1.solarIrradiance.directIrradiance.get(), weatherValue2.solarIrradiance.directIrradiance.get(), 1E-10) && - weatherValue1.solarIrradiance.diffuseIrradiance.present == weatherValue2.solarIrradiance.diffuseIrradiance.present && QuantityUtil.isEquivalentAbs(weatherValue1.solarIrradiance.diffuseIrradiance.get(), weatherValue2.solarIrradiance.diffuseIrradiance.get(), 1E-10) && - weatherValue1.temperature.temperature.present == weatherValue2.temperature.temperature.present && QuantityUtil.isEquivalentAbs(weatherValue1.temperature.temperature.get(), weatherValue2.temperature.temperature.get(), 1E-10) && - weatherValue1.wind.velocity.present == weatherValue2.wind.velocity.present && QuantityUtil.isEquivalentAbs(weatherValue1.wind.velocity.get(), weatherValue2.wind.velocity.get(), 1E-10) && - weatherValue1.wind.direction.present == weatherValue2.wind.direction.present && QuantityUtil.isEquivalentAbs(weatherValue1.wind.direction.get(), weatherValue2.wind.direction.get(), 1E-10) + return QuantityUtil.isEquivalentAbs(weatherValue1.directSolar, weatherValue2.directSolar, 1E-10) && + QuantityUtil.isEquivalentAbs(weatherValue1.diffSolar, weatherValue2.diffSolar, 1E-10) && + QuantityUtil.isEquivalentAbs(weatherValue1.temperature, weatherValue2.temperature, 1E-10) && + QuantityUtil.isEquivalentAbs(weatherValue1.windVel, weatherValue2.windVel, 1E-10) && + QuantityUtil.isEquivalentAbs(weatherValue1.windDir, weatherValue2.windDir, 1E-10) && + weatherValue1.groundTemperatures == weatherValue2.groundTemperatures } -} +} \ No newline at end of file From 1b8dd0968e09f42a39af6bcaa4b9f44718c20be6 Mon Sep 17 00:00:00 2001 From: pierrepetersmeier <155652256+pierrepetersmeier@users.noreply.github.com> Date: Wed, 9 Jul 2025 23:20:40 +0200 Subject: [PATCH 03/36] fixing the comments and tests. --- .../CosmoTimeBasedWeatherValueFactory.java | 13 ++ .../IconTimeBasedWeatherValueFactory.java | 33 +++++ .../timeseries/TimeSeriesProcessor.java | 62 ++++++-- ...conTimeBasedWeatherValueFactoryTest.groovy | 77 +++++++--- .../CouchbaseWeatherSourceCosmoIT.groovy | 23 +-- .../CouchbaseWeatherSourceIconIT.groovy | 21 +-- .../csv/CsvWeatherSourceCosmoTest.groovy | 14 +- .../csv/CsvWeatherSourceIconTest.groovy | 132 ++++++++++++++++-- .../InfluxDbWeatherSourceCosmoIT.groovy | 20 +-- .../InfluxDbWeatherSourceIconIT.groovy | 18 +-- .../source/sql/SqlWeatherSourceCosmoIT.groovy | 16 ++- .../source/sql/SqlWeatherSourceIconIT.groovy | 14 +- .../helper/WeatherSourceTestHelper.groovy | 2 +- 13 files changed, 348 insertions(+), 97 deletions(-) diff --git a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactory.java index 9e60785b0..ba51a2454 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactory.java @@ -14,6 +14,7 @@ import edu.ie3.util.quantities.PowerSystemUnits; import edu.ie3.util.quantities.interfaces.Irradiance; import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; import java.util.*; import javax.measure.quantity.Angle; import javax.measure.quantity.Length; @@ -24,6 +25,10 @@ import tech.units.indriya.quantity.Quantities; import tech.units.indriya.unit.Units; +/** + * Factory implementation of {@link TimeBasedWeatherValueFactory}, that is able to handle field to + * value mapping in the typical PowerSystemDataModel (PSDM) column scheme + */ public class CosmoTimeBasedWeatherValueFactory extends TimeBasedWeatherValueFactory { private static final String TIME = "time"; private static final String COORDINATE_ID = "coordinateId"; @@ -39,6 +44,14 @@ public CosmoTimeBasedWeatherValueFactory(TimeUtil timeUtil) { super(timeUtil); } + public CosmoTimeBasedWeatherValueFactory(DateTimeFormatter dateTimeFormatter) { + super(dateTimeFormatter); + } + + public CosmoTimeBasedWeatherValueFactory() { + super(); + } + @Override protected List> getFields(Class entityClass) { Set minConstructorParams = diff --git a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java index 642918f6e..5ebd65ce1 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java @@ -24,7 +24,13 @@ import tech.units.indriya.quantity.Quantities; import tech.units.indriya.unit.Units; +/** + * Factory implementation of {@link TimeBasedWeatherValueFactory}, that is able to handle field to + * value mapping in the column scheme, ie3 uses to store its data from German Federal + * Weather Service's ICON-EU model + */ public class IconTimeBasedWeatherValueFactory extends TimeBasedWeatherValueFactory { + /* Redefine the column names to meet the icon specifications */ private static final String DIFFUSE_IRRADIANCE = "aswdifdS"; private static final String DIRECT_IRRADIANCE = "aswdirS"; private static final String TEMPERATURE = "t2m"; @@ -57,6 +63,7 @@ protected List> getFields(Class entityClass) { "albrad", "asobs", "aswdifuS", + "tG", GROUND_TEMP_SURFACE, SOIL_TEMP_100CM, "u10m", @@ -125,7 +132,21 @@ protected TimeBasedValue buildModel(TimeBasedWeatherValueData data return new TimeBasedValue<>(time, weatherValue); } + /** + * Determines the wind direction. In ICON the wind velocity is given in three dimensional + * Cartesian coordinates. Here, the upward component is neglected. 0° or 0 rad are defined to + * point northwards. The angle increases clockwise. Please note, that the wind direction is the + * direction, the wind comes from and not goes to. We choose to use the wind velocity + * calculations at 131 m above ground, as this is a height that pretty good matches the common hub + * height of today's onshore wind generators, that are commonly connected to the voltage levels of + * interest. + * + * @param data Collective information to convert + * @return A {@link ComparableQuantity} of type {@link Speed}, that is converted to {@link + * StandardUnits#WIND_VELOCITY} + */ private static ComparableQuantity getWindDirection(TimeBasedWeatherValueData data) { + /* Get the three dimensional parts of the wind velocity vector in cartesian coordinates */ double u = data.getDouble(WIND_VELOCITY_U); double v = data.getDouble(WIND_VELOCITY_V); @@ -134,7 +155,19 @@ private static ComparableQuantity getWindDirection(TimeBasedWeatherValueD .to(StandardUnits.WIND_DIRECTION); } + /** + * Determines the wind velocity. In ICON the wind velocity is given in three dimensional Cartesian + * coordinates. Here, the upward component is neglected. We choose to use the wind velocity + * calculations at 131 m above ground, as this is a height that pretty good matches the common hub + * height of today's onshore wind generators, that are commonly connected to the voltage levels of + * interest. + * + * @param data Collective information to convert + * @return A {@link ComparableQuantity} of type {@link Speed}, that is converted to {@link + * StandardUnits#WIND_VELOCITY} + */ private static ComparableQuantity getWindVelocity(TimeBasedWeatherValueData data) { + /* Get the three dimensional parts of the wind velocity vector in cartesian coordinates */ double u = data.getDouble(WIND_VELOCITY_U); double v = data.getDouble(WIND_VELOCITY_V); diff --git a/src/main/java/edu/ie3/datamodel/io/processor/timeseries/TimeSeriesProcessor.java b/src/main/java/edu/ie3/datamodel/io/processor/timeseries/TimeSeriesProcessor.java index 24769a805..d28b29ea4 100644 --- a/src/main/java/edu/ie3/datamodel/io/processor/timeseries/TimeSeriesProcessor.java +++ b/src/main/java/edu/ie3/datamodel/io/processor/timeseries/TimeSeriesProcessor.java @@ -29,6 +29,10 @@ public class TimeSeriesProcessor< V extends Value, R extends Value> extends EntityProcessor { + /** + * List of all combinations of time series class, entry class and value class, this processor is + * able to handle + */ public static final List eligibleKeys = List.of( new TimeSeriesProcessorKey( @@ -56,7 +60,15 @@ public class TimeSeriesProcessor< new TimeSeriesProcessorKey( RandomLoadProfileTimeSeries.class, LoadProfileEntry.class, RandomLoadValues.class)); + /** + * Specific combination of time series class, entry class and value class, this processor is + * foreseen to handle. + */ private final TimeSeriesProcessorKey registeredKey; + /** + * Mapping from field name to the source, where to find the information and which getter method to + * invoke + */ private final SortedMap fieldToSource; private final String[] flattenedHeaderElements; @@ -85,10 +97,19 @@ public TimeSeriesProcessor(Class timeSeriesClass, Class entryClass, Class< public TimeSeriesProcessorKey getRegisteredKey() { return registeredKey; } - + /** + * Collects the mapping, where to find which information and how to get them (in terms of getter + * method). + * + * @param timeSeriesClass Class of the time series + * @param entryClass Class of the entry in the time series for the "outer" fields + * @param valueClass Class of the actual value in the entries for the "inner" fields + * @return A mapping from field name to a tuple of source information and equivalent getter method + */ private SortedMap buildFieldToSource( Class timeSeriesClass, Class entryClass, Class valueClass) throws EntityProcessorException { + /* Get the mapping from field name to getter method ignoring the getter for returning all entries */ Map timeSeriesMapping = mapFieldNameToGetter( timeSeriesClass, Arrays.asList("entries", "uuid", "type", "loadProfile")) @@ -98,7 +119,7 @@ private SortedMap buildFieldToSource( Collectors.toMap( Map.Entry::getKey, entry -> new FieldSourceToMethod(TIMESERIES, entry.getValue()))); - + /* Get the mapping from field name to getter method for the entry, but ignoring the getter for the value */ Map entryMapping = mapFieldNameToGetter(entryClass, Collections.singletonList("value")).entrySet().stream() .collect( @@ -116,6 +137,8 @@ private SortedMap buildFieldToSource( Map.Entry::getKey, entry -> new FieldSourceToMethod(VALUE, entry.getValue()))); } else { + /* Treat the nested weather values specially. */ + /* Flatten the nested structure of Weather value */ valueMapping = mapFieldNameToGetter(valueClass).entrySet().stream() .collect( @@ -123,12 +146,12 @@ private SortedMap buildFieldToSource( Map.Entry::getKey, entry -> new FieldSourceToMethod(VALUE, entry.getValue()))); } - + /* Put everything together */ HashMap jointMapping = new HashMap<>(); jointMapping.putAll(timeSeriesMapping); jointMapping.putAll(entryMapping); jointMapping.putAll(valueMapping); - + /* Let uuid be the first entry */ return putUuidFirst(jointMapping); } @@ -137,7 +160,12 @@ public LinkedHashMap handleEntity(TimeSeries entity) { throw new UnsupportedOperationException( "Don't invoke this simple method, but TimeSeriesProcessor#handleTimeSeries(TimeSeries)."); } - + /** + * Handles the time series by processing each entry and collecting the results + * + * @param timeSeries Time series to handle + * @return A set of mappings from field name to value + */ public Set> handleTimeSeries(T timeSeries) throws EntityProcessorException { TimeSeriesProcessorKey key = new TimeSeriesProcessorKey(timeSeries); @@ -155,30 +183,44 @@ public Set> handleTimeSeries(T timeSeries) for (E entry : timeSeries.getEntries()) { Map entryResult = handleEntry(timeSeries, entry); + /* Prepare the actual result and add them to the set of all results */ fieldToValueSet.add(new LinkedHashMap<>(entryResult)); } return fieldToValueSet; } - + /** + * Processes a single entry to a mapping from field name to value as String representation. The + * information from the time series are added as well. + * + * @param timeSeries Time series for additional information + * @param entry Actual entry to handle + * @return A sorted map from field name to value as String representation + */ private Map handleEntry(T timeSeries, E entry) throws EntityProcessorException { + /* Handle the information in the time series */ Map timeSeriesFieldToMethod = extractFieldToMethod(TIMESERIES); LinkedHashMap timeSeriesResults = processObject(timeSeries, timeSeriesFieldToMethod); - + /* Handle the information in the entry */ Map entryFieldToMethod = extractFieldToMethod(ENTRY); LinkedHashMap entryResults = processObject(entry, entryFieldToMethod); - + /* Handle the information in the value */ Map valueFieldToMethod = extractFieldToMethod(VALUE); LinkedHashMap valueResult = processObject(entry.getValue(), valueFieldToMethod); - + /* Join all information and sort them */ Map combinedResult = new HashMap<>(); combinedResult.putAll(timeSeriesResults); combinedResult.putAll(entryResults); combinedResult.putAll(valueResult); return putUuidFirst(combinedResult); } - + /** + * Extracts the field name to method map for the specific source + * + * @param source Source to extract field name to methods for + * @return Field name to methods for the desired source + */ private Map extractFieldToMethod(FieldSourceToMethod.FieldSource source) { return fieldToSource.entrySet().stream() .filter(entry -> entry.getValue().source().equals(source)) diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactoryTest.groovy index b87944468..1ed9e76e8 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactoryTest.groovy @@ -80,14 +80,36 @@ class IconTimeBasedWeatherValueFactoryTest extends Specification { def coordinate = CosmoWeatherTestData.COORDINATE_67775 def parameter = [ - "time" : "2019-08-01T01:00:00Z", - "aswdifdS" : "1.8088226191406245", - "aswdirS" : "2.317613203124999", - "t2m" : "289.1179319051744", - "tG" : "288.4101691197649", - "u131m" : "2.6058700426057797", - "v131m" : "3.8391590569599927", - "coordinateId": "67775" + "time" : "2019-08-01T01:00:00Z", + "albRad" : "13.015240669", + "asobS" : "3.555093673828124", + "aswdifdS" : "1.8088226191406245", + "aswdifuS" : "0.5713421484374998", + "aswdirS" : "2.317613203124999", + "t2m" : "289.1179319051744", + "tg" : "288.4101691197649", + "u10m" : "0.3021732864307963", + "tG" : "288.4101691197649", + "u131m" : "2.6058700426057797", + "u20m" : "0.32384365019387784", + "u216m" : "3.9015497418041756", + "u65m" : "1.2823686334340363", + "v10m" : "1.3852550649486943", + "v131m" : "3.8391590569599927", + "v20m" : "1.3726831152710628", + "v216m" : "4.339362039492466", + "v65m" : "2.809877942347672", + "w131m" : "-0.02633474740256081", + "w20m" : "-0.0100060345167524", + "w216m" : "-0.030348050471342078", + "w65m" : "-0.01817112027569893", + "z0" : "0.955323922526438", + "coordinateId": "67775", + "p131m" : "", + "p20m" : "", + "p65m" : "", + "sobsRad" : "", + "t131m" : "" ] def data = new TimeBasedWeatherValueData(parameter, coordinate) @@ -116,15 +138,36 @@ class IconTimeBasedWeatherValueFactoryTest extends Specification { def coordinate = CosmoWeatherTestData.COORDINATE_67775 def parameter = [ - "time" : "2019-08-01T01:00:00Z", - "aswdifdS" : "1.80", - "aswdirS" : "2.31", - "t2m" : "289.11", - "tG" : "288.41", - "tso100cm" : "286.5", - "u131m" : "2.60", - "v131m" : "3.83", - "coordinateId": "67775" + "time" : "2019-08-01T01:00:00Z", + "albRad" : "13.015240669", + "asobS" : "3.555093673828124", + "aswdifdS" : "1.8088226191406245", + "aswdifuS" : "0.5713421484374998", + "aswdirS" : "2.317613203124999", + "t2m" : "289.1179319051744", + "tg" : "288.4101691197649", + "u10m" : "0.3021732864307963", + "tG" : "288.4101691197649", + "u131m" : "2.6058700426057797", + "u20m" : "0.32384365019387784", + "u216m" : "3.9015497418041756", + "u65m" : "1.2823686334340363", + "v10m" : "1.3852550649486943", + "v131m" : "3.8391590569599927", + "v20m" : "1.3726831152710628", + "v216m" : "4.339362039492466", + "v65m" : "2.809877942347672", + "w131m" : "-0.02633474740256081", + "w20m" : "-0.0100060345167524", + "w216m" : "-0.030348050471342078", + "w65m" : "-0.01817112027569893", + "z0" : "0.955323922526438", + "coordinateId": "67775", + "p131m" : "", + "p20m" : "", + "p65m" : "", + "sobsRad" : "", + "t131m" : "" ] def data = new TimeBasedWeatherValueData(parameter, coordinate) diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/couchbase/CouchbaseWeatherSourceCosmoIT.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/couchbase/CouchbaseWeatherSourceCosmoIT.groovy index 31ddd62d0..1a14b0cc7 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/couchbase/CouchbaseWeatherSourceCosmoIT.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/couchbase/CouchbaseWeatherSourceCosmoIT.groovy @@ -26,7 +26,7 @@ import spock.lang.Specification import java.time.Duration @Testcontainers -class CouchbaseWeatherSourceCosmoIT extends Specification implements TestContainerHelper { +class CouchbaseWeatherSourceCosmoIT extends Specification implements TestContainerHelper, WeatherSourceTestHelper { @Shared BucketDefinition bucketDefinition = new BucketDefinition("ie3_in") @@ -35,7 +35,7 @@ class CouchbaseWeatherSourceCosmoIT extends Specification implements TestContain CouchbaseContainer couchbaseContainer = new CouchbaseContainer("couchbase/server:6.6.0") .withBucket(bucketDefinition) .withExposedPorts(8091, 8092, 8093, 8094, 11210) - .withStartupAttempts(3) + .withStartupAttempts(3) // 3 attempts because startup (node renaming) sometimes fails when executed too early @Shared CouchbaseWeatherSource source @@ -43,15 +43,16 @@ class CouchbaseWeatherSourceCosmoIT extends Specification implements TestContain static String coordinateIdColumnName = "coordinateid" def setupSpec() { + // Copy import file with json array of documents into docker MountableFile couchbaseWeatherJsonsFile = getMountableFile("_weather/cosmo/weather.json") couchbaseContainer.copyFileToContainer(couchbaseWeatherJsonsFile, "/home/weather_cosmo.json") - +// create an index for the document keys couchbaseContainer.execInContainer("cbq", "-e", "http://localhost:8093", "-u", couchbaseContainer.username, "-p", couchbaseContainer.password, "-s", "CREATE index id_idx ON `" + bucketDefinition.name + "` (META().id);") - +//import the json documents from the copied file couchbaseContainer.execInContainer("cbimport", "json", "-cluster", "http://localhost:8091", "--bucket", "ie3_in", @@ -60,7 +61,7 @@ class CouchbaseWeatherSourceCosmoIT extends Specification implements TestContain "--format", "list", "--generate-key", "weather::%" + coordinateIdColumnName + "%::%time%", "--dataset", "file:///home/weather_cosmo.json") - + // increased timeout to deal with CI under high load def connector = new CouchbaseConnector( couchbaseContainer.connectionString, bucketDefinition.name, @@ -88,7 +89,7 @@ class CouchbaseWeatherSourceCosmoIT extends Specification implements TestContain then: optTimeBasedValue.present - WeatherSourceTestHelper.equalsIgnoreUUID(optTimeBasedValue.get(), expectedTimeBasedValue) + equalsIgnoreUUID(optTimeBasedValue.get(), expectedTimeBasedValue) } def "A CouchbaseWeatherSource can read multiple time series values for multiple coordinates"() { @@ -112,8 +113,8 @@ class CouchbaseWeatherSourceCosmoIT extends Specification implements TestContain Map> coordinateToTimeSeries = source.getWeather(timeInterval, coordinates) then: coordinateToTimeSeries.keySet().size() == 2 - WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193186), timeSeries193186) - WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193187), timeSeries193187) + equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193186), timeSeries193186) + equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193187), timeSeries193187) } @@ -140,9 +141,9 @@ class CouchbaseWeatherSourceCosmoIT extends Specification implements TestContain Map> coordinateToTimeSeries = source.getWeather(timeInterval) then: coordinateToTimeSeries.keySet().size() == 3 - WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193186).entries, timeSeries193186.entries) - WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193187).entries, timeSeries193187.entries) - WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193188).entries, timeSeries193188.entries) + equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193186).entries, timeSeries193186.entries) + equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193187).entries, timeSeries193187.entries) + equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193188).entries, timeSeries193188.entries) } def "A CouchbaseWeatherSource returns all time keys after a given time key correctly"() { diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/couchbase/CouchbaseWeatherSourceIconIT.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/couchbase/CouchbaseWeatherSourceIconIT.groovy index f19709806..1d7d452af 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/couchbase/CouchbaseWeatherSourceIconIT.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/couchbase/CouchbaseWeatherSourceIconIT.groovy @@ -24,7 +24,7 @@ import java.time.Duration import java.time.ZoneId @Testcontainers -class CouchbaseWeatherSourceIconIT extends Specification implements TestContainerHelper { +class CouchbaseWeatherSourceIconIT extends Specification implements TestContainerHelper, WeatherSourceTestHelper { @Shared BucketDefinition bucketDefinition = new BucketDefinition("ie3_in") @@ -33,7 +33,7 @@ class CouchbaseWeatherSourceIconIT extends Specification implements TestContaine CouchbaseContainer couchbaseContainer = new CouchbaseContainer("couchbase/server:6.6.0") .withBucket(bucketDefinition) .withExposedPorts(8091, 8092, 8093, 8094, 11210) - .withStartupAttempts(3) + .withStartupAttempts(3) // 3 attempts because startup (node renaming) sometimes fails when executed too early @Shared CouchbaseWeatherSource source @@ -41,15 +41,16 @@ class CouchbaseWeatherSourceIconIT extends Specification implements TestContaine static String coordinateIdColumnName = "coordinateid" def setupSpec() { + // Copy import file with json array of documents into docker def couchbaseWeatherJsonsFile = getMountableFile("_weather/icon/weather.json") couchbaseContainer.copyFileToContainer(couchbaseWeatherJsonsFile, "/home/weather_icon.json") - +// create an index for the document keys couchbaseContainer.execInContainer("cbq", "-e", "http://localhost:8093", "-u", couchbaseContainer.username, "-p", couchbaseContainer.password, "-s", "CREATE index id_idx ON `" + bucketDefinition.name + "` (META().id);") - +//import the json documents from the copied file couchbaseContainer.execInContainer("cbimport", "json", "-cluster", "http://localhost:8091", "--bucket", "ie3_in", @@ -58,7 +59,7 @@ class CouchbaseWeatherSourceIconIT extends Specification implements TestContaine "--format", "list", "--generate-key", "weather::%" + coordinateIdColumnName + "%::%time%", "--dataset", "file:///home/weather_icon.json") - + // increased timeout to deal with CI under high load def connector = new CouchbaseConnector( couchbaseContainer.connectionString, bucketDefinition.name, @@ -87,7 +88,7 @@ class CouchbaseWeatherSourceIconIT extends Specification implements TestContaine then: optTimeBasedValue.present - WeatherSourceTestHelper.equalsIgnoreUUID(optTimeBasedValue.get(), expectedTimeBasedValue) + equalsIgnoreUUID(optTimeBasedValue.get(), expectedTimeBasedValue) } def "A CouchbaseWeatherSource can read multiple time series values for multiple coordinates"() { @@ -113,8 +114,8 @@ class CouchbaseWeatherSourceIconIT extends Specification implements TestContaine then: coordinateToTimeSeries.keySet().size() == 2 - WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67775), timeSeries67775) - WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67776), timeSeries67776) + equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67775), timeSeries67775) + equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67776), timeSeries67776) } def "A CouchbaseWeatherSource can read all weather data in a given time interval"() { @@ -137,8 +138,8 @@ class CouchbaseWeatherSourceIconIT extends Specification implements TestContaine then: coordinateToTimeSeries.keySet().size() == 2 - WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67775).entries, timeSeries67775.entries) - WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67776).entries, timeSeries67776.entries) +equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67775).entries, timeSeries67775.entries) + equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67776).entries, timeSeries67776.entries) } def "The CouchbaseWeatherSource returns all time keys after a given time key correctly"() { diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceCosmoTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceCosmoTest.groovy index 2c75f60a4..fa85bf1a6 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceCosmoTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceCosmoTest.groovy @@ -26,7 +26,7 @@ import tech.units.indriya.quantity.Quantities import java.util.Collections -class CsvWeatherSourceCosmoTest extends Specification implements CsvTestDataMeta { +class CsvWeatherSourceCosmoTest extends Specification implements CsvTestDataMeta, WeatherSourceTestHelper { @Shared CsvWeatherSource source @@ -49,7 +49,7 @@ class CsvWeatherSourceCosmoTest extends Specification implements CsvTestDataMeta then: optTimeBasedValue.present - WeatherSourceTestHelper.equalsIgnoreUUID(optTimeBasedValue.get(), expectedTimeBasedValue) + equalsIgnoreUUID(optTimeBasedValue.get(), expectedTimeBasedValue) } def "A CsvWeatherSource can read multiple time series values for multiple coordinates"() { @@ -75,8 +75,8 @@ class CsvWeatherSourceCosmoTest extends Specification implements CsvTestDataMeta then: coordinateToTimeSeries.keySet().size() == 2 - WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193186), timeSeries193186) - WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193187), timeSeries193187) + equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193186), timeSeries193186) + equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193187), timeSeries193187) } @@ -104,9 +104,9 @@ class CsvWeatherSourceCosmoTest extends Specification implements CsvTestDataMeta then: coordinateToTimeSeries.keySet().size() == 3 - WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193186).entries, timeSeries193186.entries) - WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193187).entries, timeSeries193187.entries) - WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193188).entries, timeSeries193188.entries) + equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193186).entries, timeSeries193186.entries) + equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193187).entries, timeSeries193187.entries) + equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193188).entries, timeSeries193188.entries) } def "The CsvWeatherSource is able to build a single WeatherValue from field to value mapping"() { diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceIconTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceIconTest.groovy index fc3497e80..ab41b749d 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceIconTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceIconTest.groovy @@ -21,7 +21,7 @@ import org.locationtech.jts.geom.Point import spock.lang.Shared import spock.lang.Specification -class CsvWeatherSourceIconTest extends Specification implements CsvTestDataMeta { +class CsvWeatherSourceIconTest extends Specification implements CsvTestDataMeta, WeatherSourceTestHelper { @Shared CsvWeatherSource source @@ -44,7 +44,7 @@ class CsvWeatherSourceIconTest extends Specification implements CsvTestDataMeta then: optTimeBasedValue.present - WeatherSourceTestHelper.equalsIgnoreUUID(optTimeBasedValue.get(), expectedTimeBasedValue) + equalsIgnoreUUID(optTimeBasedValue.get(), expectedTimeBasedValue) } def "A CsvWeatherSource can read multiple time series values for multiple coordinates"() { @@ -70,8 +70,8 @@ class CsvWeatherSourceIconTest extends Specification implements CsvTestDataMeta then: coordinateToTimeSeries.keySet().size() == 2 - WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67775), timeSeries67775) - WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67776), timeSeries67776) + equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67775), timeSeries67775) + equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67776), timeSeries67776) } @@ -95,8 +95,8 @@ class CsvWeatherSourceIconTest extends Specification implements CsvTestDataMeta then: coordinateToTimeSeries.keySet().size() == 2 - WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67775).entries, timeSeries67775.entries) - WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67776).entries, timeSeries67776.entries) + equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67775).entries, timeSeries67775.entries) + equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67776).entries, timeSeries67776.entries) } def "The CsvWeatherSource is able to extract correct coordinate from field to value mapping"() { @@ -109,8 +109,35 @@ class CsvWeatherSourceIconTest extends Specification implements CsvTestDataMeta def fieldToValues = new TreeMap<>(String.CASE_INSENSITIVE_ORDER) fieldToValues.putAll( [ - "datum" : "2019-08-01 01:00:00", - "coordinateId": "67775", + "datum" : "2019-08-01 01:00:00", + "albRad" : "13.015240669", + "asobS" : "3.555093673828124", + "aswdifdS" : "1.8088226191406245", + "aswdifuS" : "0.5713421484374998", + "aswdirS" : "2.317613203124999", + "t2m" : "289.1179319051744", + "tg" : "288.4101691197649", + "u10m" : "0.3021732864307963", + "u131m" : "2.6058700426057797", + "u20m" : "0.32384365019387784", + "u216m" : "3.9015497418041756", + "u65m" : "1.2823686334340363", + "v10m" : "1.3852550649486943", + "v131m" : "3.8391590569599927", + "v20m" : "1.3726831152710628", + "v216m" : "4.339362039492466", + "v65m" : "2.809877942347672", + "w131m" : "-0.02633474740256081", + "w20m" : "-0.0100060345167524", + "w216m" : "-0.030348050471342078", + "w65m" : "-0.01817112027569893", + "z0" : "0.955323922526438", + "coordinateId": "67775", + "p131m" : "", + "p20m" : "", + "p65m" : "", + "sobsRad" : "", + "t131m" : "" ]) when: @@ -126,7 +153,35 @@ class CsvWeatherSourceIconTest extends Specification implements CsvTestDataMeta def coordinateSource = new WeatherTestData.DummyIdCoordinateSource() def weatherFactory = new IconTimeBasedWeatherValueFactory() def source = new CsvWeatherSource(",", weatherIconFolderPath, new FileNamingStrategy(), coordinateSource, weatherFactory) - def fieldToValues = ["coordinateId": ""] + def fieldToValues = [ "datum" : "2019-08-01 01:00:00", + "albRad" : "13.015240669", + "asobS" : "3.555093673828124", + "aswdifdS" : "1.8088226191406245", + "aswdifuS" : "0.5713421484374998", + "aswdirS" : "2.317613203124999", + "t2m" : "289.1179319051744", + "tg" : "288.4101691197649", + "u10m" : "0.3021732864307963", + "u131m" : "2.6058700426057797", + "u20m" : "0.32384365019387784", + "u216m" : "3.9015497418041756", + "u65m" : "1.2823686334340363", + "v10m" : "1.3852550649486943", + "v131m" : "3.8391590569599927", + "v20m" : "1.3726831152710628", + "v216m" : "4.339362039492466", + "v65m" : "2.809877942347672", + "w131m" : "-0.02633474740256081", + "w20m" : "-0.0100060345167524", + "w216m" : "-0.030348050471342078", + "w65m" : "-0.01817112027569893", + "z0" : "0.955323922526438", + "coordinateId": "", + "p131m" : "", + "p20m" : "", + "p65m" : "", + "sobsRad" : "", + "t131m" : ""] when: def actual = source.buildWeatherValue(fieldToValues) @@ -140,7 +195,34 @@ class CsvWeatherSourceIconTest extends Specification implements CsvTestDataMeta def coordinateSource = new WeatherTestData.DummyIdCoordinateSource() def weatherFactory = new IconTimeBasedWeatherValueFactory() def source = new CsvWeatherSource(",", weatherIconFolderPath, new FileNamingStrategy(), coordinateSource, weatherFactory) - def fieldToValues = [:] + def fieldToValues = [ "datum" : "2019-08-01 01:00:00", + "albRad" : "13.015240669", + "asobS" : "3.555093673828124", + "aswdifdS": "1.8088226191406245", + "aswdifuS": "0.5713421484374998", + "aswdirS" : "2.317613203124999", + "t2m" : "289.1179319051744", + "tg" : "288.4101691197649", + "u10m" : "0.3021732864307963", + "u131m" : "2.6058700426057797", + "u20m" : "0.32384365019387784", + "u216m" : "3.9015497418041756", + "u65m" : "1.2823686334340363", + "v10m" : "1.3852550649486943", + "v131m" : "3.8391590569599927", + "v20m" : "1.3726831152710628", + "v216m" : "4.339362039492466", + "v65m" : "2.809877942347672", + "w131m" : "-0.02633474740256081", + "w20m" : "-0.0100060345167524", + "w216m" : "-0.030348050471342078", + "w65m" : "-0.01817112027569893", + "z0" : "0.955323922526438", + "p131m" : "", + "p20m" : "", + "p65m" : "", + "sobsRad" : "", + "t131m" : ""] when: def actual = source.buildWeatherValue(fieldToValues) @@ -155,7 +237,35 @@ class CsvWeatherSourceIconTest extends Specification implements CsvTestDataMeta coordinateSource.getCoordinate(_) >> Optional.empty() def weatherFactory = new IconTimeBasedWeatherValueFactory() def source = new CsvWeatherSource(",", weatherIconFolderPath, new FileNamingStrategy(), coordinateSource, weatherFactory) - def fieldToValues = ["coordinateId": "67777"] + def fieldToValues = [ "datum" : "2019-08-01 01:00:00", + "albRad" : "13.015240669", + "asobS" : "3.555093673828124", + "aswdifdS" : "1.8088226191406245", + "aswdifuS" : "0.5713421484374998", + "aswdirS" : "2.317613203124999", + "t2m" : "289.1179319051744", + "tg" : "288.4101691197649", + "u10m" : "0.3021732864307963", + "u131m" : "2.6058700426057797", + "u20m" : "0.32384365019387784", + "u216m" : "3.9015497418041756", + "u65m" : "1.2823686334340363", + "v10m" : "1.3852550649486943", + "v131m" : "3.8391590569599927", + "v20m" : "1.3726831152710628", + "v216m" : "4.339362039492466", + "v65m" : "2.809877942347672", + "w131m" : "-0.02633474740256081", + "w20m" : "-0.0100060345167524", + "w216m" : "-0.030348050471342078", + "w65m" : "-0.01817112027569893", + "z0" : "0.955323922526438", + "coordinateId": "67777", + "p131m" : "", + "p20m" : "", + "p65m" : "", + "sobsRad" : "", + "t131m" : ""] when: def actual = source.buildWeatherValue(fieldToValues) diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/influxdb/InfluxDbWeatherSourceCosmoIT.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/influxdb/InfluxDbWeatherSourceCosmoIT.groovy index f94790e3e..e3719295e 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/influxdb/InfluxDbWeatherSourceCosmoIT.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/influxdb/InfluxDbWeatherSourceCosmoIT.groovy @@ -28,7 +28,7 @@ import spock.lang.Specification import java.time.Duration @Testcontainers -class InfluxDbWeatherSourceCosmoIT extends Specification implements TestContainerHelper { +class InfluxDbWeatherSourceCosmoIT extends Specification implements TestContainerHelper, WeatherSourceTestHelper { @Shared InfluxDBContainer influxDbContainer = new InfluxDBContainer(DockerImageName.parse("influxdb").withTag("1.8.10")) @@ -39,6 +39,8 @@ class InfluxDbWeatherSourceCosmoIT extends Specification implements TestContaine InfluxDbWeatherSource source def setupSpec() { + // Copy import file into docker and then import it via influx CLI + // more information on file format and usage here: https://docs.influxdata.com/influxdb/v1.7/tools/shell/#import-data-from-a-file-with-import MountableFile influxWeatherImportFile = getMountableFile("_weather/cosmo/weather.txt") influxDbContainer.copyFileToContainer(influxWeatherImportFile, "/home/weather_cosmo.txt") @@ -67,7 +69,7 @@ class InfluxDbWeatherSourceCosmoIT extends Specification implements TestContaine then: optTimeBasedValue.present - WeatherSourceTestHelper.equalsIgnoreUUID(optTimeBasedValue.get(), expectedTimeBasedValue) + equalsIgnoreUUID(optTimeBasedValue.get(), expectedTimeBasedValue) } def "An InfluxDbWeatherSource can read multiple time series values for multiple coordinates"() { @@ -93,8 +95,8 @@ class InfluxDbWeatherSourceCosmoIT extends Specification implements TestContaine then: coordinateToTimeSeries.keySet().size() == 2 - WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193186), timeseries_193186) - WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193187), timeseries_193187) + equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193186), timeseries_193186) + equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193187), timeseries_193187) } def "An InfluxDbWeatherSource can read all weather data in a given time interval"() { @@ -121,9 +123,9 @@ class InfluxDbWeatherSourceCosmoIT extends Specification implements TestContaine then: coordinateToTimeSeries.keySet().size() == 3 - WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193186).entries, timeseries_193186.entries) - WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193187).entries, timeseries_193187.entries) - WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193188).entries, timeseries_193188.entries) + equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193186).entries, timeseries_193186.entries) + equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193187).entries, timeseries_193187.entries) + equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193188).entries, timeseries_193188.entries) } def "An InfluxDbWeatherSource will return an equivalent to 'empty' when being unable to map a coordinate to its ID"() { @@ -150,9 +152,9 @@ class InfluxDbWeatherSourceCosmoIT extends Specification implements TestContaine then: coordinateAtDate == Optional.empty() - WeatherSourceTestHelper.equalsIgnoreUUID(coordinateInInterval, emptyTimeSeries) + equalsIgnoreUUID(coordinateInInterval, emptyTimeSeries) coordinatesToTimeSeries.keySet() == [validCoordinate].toSet() - WeatherSourceTestHelper.equalsIgnoreUUID(coordinatesToTimeSeries.get(validCoordinate), timeseries_193186) + equalsIgnoreUUID(coordinatesToTimeSeries.get(validCoordinate), timeseries_193186) } def "A InfluxDbWeatherSource returns all time keys after a given time key correctly"() { diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/influxdb/InfluxDbWeatherSourceIconIT.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/influxdb/InfluxDbWeatherSourceIconIT.groovy index 9b061a778..789e8c100 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/influxdb/InfluxDbWeatherSourceIconIT.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/influxdb/InfluxDbWeatherSourceIconIT.groovy @@ -27,7 +27,7 @@ import java.util.Optional import java.util.UUID @Testcontainers -class InfluxDbWeatherSourceIconIT extends Specification implements TestContainerHelper { +class InfluxDbWeatherSourceIconIT extends Specification implements TestContainerHelper, WeatherSourceTestHelper { @Shared InfluxDBContainer influxDbContainer = new InfluxDBContainer(DockerImageName.parse("influxdb").withTag("1.8.10")) @@ -38,6 +38,8 @@ class InfluxDbWeatherSourceIconIT extends Specification implements TestContainer InfluxDbWeatherSource source def setupSpec() { + // Copy import file into docker and then import it via influx CLI + // more information on file format and usage here: https://docs.influxdata.com/influxdb/v1.7/tools/shell/#import-data-from-a-file-with-import MountableFile influxWeatherImportFile = getMountableFile("_weather/icon/weather.txt") influxDbContainer.copyFileToContainer(influxWeatherImportFile, "/home/weather_icon.txt") @@ -66,7 +68,7 @@ class InfluxDbWeatherSourceIconIT extends Specification implements TestContainer then: optTimeBasedValue.present - WeatherSourceTestHelper.equalsIgnoreUUID(optTimeBasedValue.get(), expectedTimeBasedValue) + equalsIgnoreUUID(optTimeBasedValue.get(), expectedTimeBasedValue) } def "An InfluxDbWeatherSource can read multiple time series values for multiple coordinates"() { @@ -92,8 +94,8 @@ class InfluxDbWeatherSourceIconIT extends Specification implements TestContainer then: coordinateToTimeSeries.keySet().size() == 2 - WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67775), timeseries67775) - WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67776), timeseries67776) + equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67775), timeseries67775) + equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67776), timeseries67776) } def "An InfluxDbWeatherSource can read all weather data in a given time interval"() { @@ -116,8 +118,8 @@ class InfluxDbWeatherSourceIconIT extends Specification implements TestContainer then: coordinateToTimeSeries.keySet().size() == 2 - WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67775).entries, timeseries67775.entries) - WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67776).entries, timeseries67776.entries) + equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67775).entries, timeseries67775.entries) + equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67776).entries, timeseries67776.entries) } def "An InfluxDbWeatherSource will return an equivalent to 'empty' when being unable to map a coordinate to its ID"() { @@ -144,9 +146,9 @@ class InfluxDbWeatherSourceIconIT extends Specification implements TestContainer then: coordinateAtDate == Optional.empty() - WeatherSourceTestHelper.equalsIgnoreUUID(coordinateInInterval, emptyTimeSeries) + equalsIgnoreUUID(coordinateInInterval, emptyTimeSeries) coordinatesToTimeSeries.keySet() == [validCoordinate].toSet() - WeatherSourceTestHelper.equalsIgnoreUUID(coordinatesToTimeSeries.get(validCoordinate), timeseries67775) + equalsIgnoreUUID(coordinatesToTimeSeries.get(validCoordinate), timeseries67775) } def "The InfluxDbWeatherSource returns all time keys after a given time key correctly"() { diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/sql/SqlWeatherSourceCosmoIT.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/sql/SqlWeatherSourceCosmoIT.groovy index 55107802c..212c8d90b 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/sql/SqlWeatherSourceCosmoIT.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/sql/SqlWeatherSourceCosmoIT.groovy @@ -25,7 +25,7 @@ import spock.lang.Shared import spock.lang.Specification @Testcontainers -class SqlWeatherSourceCosmoIT extends Specification implements TestContainerHelper { +class SqlWeatherSourceCosmoIT extends Specification implements TestContainerHelper, WeatherSourceTestHelper { @Shared PostgreSQLContainer postgreSQLContainer = new PostgreSQLContainer("postgres:14.2") @@ -37,8 +37,10 @@ class SqlWeatherSourceCosmoIT extends Specification implements TestContainerHelp static String weatherTableName = "weather" def setupSpec() { + // Copy sql import script into docker MountableFile sqlImportFile = getMountableFile("_weather/cosmo/weather.sql") postgreSQLContainer.copyFileToContainer(sqlImportFile, "/home/weather_cosmo.sql") + // Execute import script Container.ExecResult res = postgreSQLContainer.execInContainer("psql", "-Utest", "-f/home/weather_cosmo.sql") assert res.stderr.empty @@ -56,7 +58,7 @@ class SqlWeatherSourceCosmoIT extends Specification implements TestContainerHelp then: optTimeBasedValue.present - WeatherSourceTestHelper.equalsIgnoreUUID(optTimeBasedValue.get(), expectedTimeBasedValue ) + equalsIgnoreUUID(optTimeBasedValue.get(), expectedTimeBasedValue ) } def "A SqlWeatherSource returns nothing for an invalid coordinate"() { @@ -90,8 +92,8 @@ class SqlWeatherSourceCosmoIT extends Specification implements TestContainerHelp then: coordinateToTimeSeries.keySet().size() == 2 - WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193186), timeSeries193186) - WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193187), timeSeries193187) + equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193186), timeSeries193186) + equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193187), timeSeries193187) } def "A SqlWeatherSource returns nothing for invalid coordinates"() { @@ -133,9 +135,9 @@ class SqlWeatherSourceCosmoIT extends Specification implements TestContainerHelp then: coordinateToTimeSeries.keySet().size() == 3 - WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193186).entries, timeSeries193186.entries) - WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193187).entries, timeSeries193187.entries) - WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193188).entries, timeSeries193188.entries) + equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193186).entries, timeSeries193186.entries) + equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193187).entries, timeSeries193187.entries) + equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193188).entries, timeSeries193188.entries) } def "A SqlWeatherSource returns all time keys after a given time key correctly"() { diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/sql/SqlWeatherSourceIconIT.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/sql/SqlWeatherSourceIconIT.groovy index 792748be9..7b98c18a7 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/sql/SqlWeatherSourceIconIT.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/sql/SqlWeatherSourceIconIT.groovy @@ -24,7 +24,7 @@ import spock.lang.Shared import spock.lang.Specification @Testcontainers -class SqlWeatherSourceIconIT extends Specification implements TestContainerHelper { +class SqlWeatherSourceIconIT extends Specification implements TestContainerHelper, WeatherSourceTestHelper { @Shared PostgreSQLContainer postgreSQLContainer = new PostgreSQLContainer("postgres:14.2") @@ -36,8 +36,10 @@ class SqlWeatherSourceIconIT extends Specification implements TestContainerHelpe static String weatherTableName = "weather" def setupSpec() { + // Copy sql import script into docker MountableFile sqlImportFile = getMountableFile("_weather/icon/weather.sql") postgreSQLContainer.copyFileToContainer(sqlImportFile, "/home/weather_icon.sql") + // Execute import script Container.ExecResult res = postgreSQLContainer.execInContainer("psql", "-Utest", "-f/home/weather_icon.sql") assert res.stderr.empty @@ -53,7 +55,7 @@ class SqlWeatherSourceIconIT extends Specification implements TestContainerHelpe def optTimeBasedValue = source.getWeather(IconWeatherTestData.TIME_15H, IconWeatherTestData.COORDINATE_67775) then: optTimeBasedValue.present - WeatherSourceTestHelper.equalsIgnoreUUID(optTimeBasedValue.get(), expectedTimeBasedValue ) + equalsIgnoreUUID(optTimeBasedValue.get(), expectedTimeBasedValue ) } def "A NativeSqlWeatherSource can read multiple timeseries values for multiple coordinates"() { @@ -79,8 +81,8 @@ class SqlWeatherSourceIconIT extends Specification implements TestContainerHelpe then: coordinateToTimeSeries.keySet().size() == 2 - WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67775), timeSeries67775) - WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67776), timeSeries67776) + equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67775), timeSeries67775) + equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67776), timeSeries67776) } def "A NativeSqlWeatherSource can read all weather data in a given time interval"() { @@ -103,8 +105,8 @@ class SqlWeatherSourceIconIT extends Specification implements TestContainerHelpe then: coordinateToTimeSeries.keySet().size() == 2 - WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67775).entries, timeSeries67775.entries) - WeatherSourceTestHelper.equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67776).entries, timeSeries67776.entries) + equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67775).entries, timeSeries67775.entries) + equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67776).entries, timeSeries67776.entries) } def "A NativeSqlWeatherSource returns all time keys after a given time key correctly"() { diff --git a/src/test/groovy/edu/ie3/test/helper/WeatherSourceTestHelper.groovy b/src/test/groovy/edu/ie3/test/helper/WeatherSourceTestHelper.groovy index c8459baca..f6ea29054 100644 --- a/src/test/groovy/edu/ie3/test/helper/WeatherSourceTestHelper.groovy +++ b/src/test/groovy/edu/ie3/test/helper/WeatherSourceTestHelper.groovy @@ -10,7 +10,7 @@ import edu.ie3.datamodel.models.timeseries.individual.TimeBasedValue import edu.ie3.datamodel.models.value.WeatherValue import edu.ie3.util.quantities.QuantityUtil -class WeatherSourceTestHelper { +trait WeatherSourceTestHelper { static boolean equalsIgnoreUUID(IndividualTimeSeries ts1, IndividualTimeSeries ts2) { From 6a77ffc7f07d42f7c0150e120f6bb3fba8d49b02 Mon Sep 17 00:00:00 2001 From: pierrepetersmeier <155652256+pierrepetersmeier@users.noreply.github.com> Date: Wed, 9 Jul 2025 23:21:52 +0200 Subject: [PATCH 04/36] fmt --- .../timeseries/TimeSeriesProcessor.java | 1 + ...conTimeBasedWeatherValueFactoryTest.groovy | 120 ++++----- .../CouchbaseWeatherSourceCosmoIT.groovy | 8 +- .../CouchbaseWeatherSourceIconIT.groovy | 16 +- .../csv/CsvWeatherSourceCosmoTest.groovy | 6 +- .../csv/CsvWeatherSourceIconTest.groovy | 228 +++++++++--------- .../InfluxDbWeatherSourceCosmoIT.groovy | 2 +- 7 files changed, 191 insertions(+), 190 deletions(-) diff --git a/src/main/java/edu/ie3/datamodel/io/processor/timeseries/TimeSeriesProcessor.java b/src/main/java/edu/ie3/datamodel/io/processor/timeseries/TimeSeriesProcessor.java index d28b29ea4..97cb8bf70 100644 --- a/src/main/java/edu/ie3/datamodel/io/processor/timeseries/TimeSeriesProcessor.java +++ b/src/main/java/edu/ie3/datamodel/io/processor/timeseries/TimeSeriesProcessor.java @@ -70,6 +70,7 @@ public class TimeSeriesProcessor< * invoke */ private final SortedMap fieldToSource; + private final String[] flattenedHeaderElements; public TimeSeriesProcessor(Class timeSeriesClass, Class entryClass, Class valueClass) diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactoryTest.groovy index 1ed9e76e8..0347d434a 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactoryTest.groovy @@ -80,36 +80,36 @@ class IconTimeBasedWeatherValueFactoryTest extends Specification { def coordinate = CosmoWeatherTestData.COORDINATE_67775 def parameter = [ - "time" : "2019-08-01T01:00:00Z", - "albRad" : "13.015240669", - "asobS" : "3.555093673828124", - "aswdifdS" : "1.8088226191406245", - "aswdifuS" : "0.5713421484374998", - "aswdirS" : "2.317613203124999", - "t2m" : "289.1179319051744", - "tg" : "288.4101691197649", - "u10m" : "0.3021732864307963", - "tG" : "288.4101691197649", - "u131m" : "2.6058700426057797", - "u20m" : "0.32384365019387784", - "u216m" : "3.9015497418041756", - "u65m" : "1.2823686334340363", - "v10m" : "1.3852550649486943", - "v131m" : "3.8391590569599927", - "v20m" : "1.3726831152710628", - "v216m" : "4.339362039492466", - "v65m" : "2.809877942347672", - "w131m" : "-0.02633474740256081", - "w20m" : "-0.0100060345167524", - "w216m" : "-0.030348050471342078", - "w65m" : "-0.01817112027569893", - "z0" : "0.955323922526438", - "coordinateId": "67775", - "p131m" : "", - "p20m" : "", - "p65m" : "", - "sobsRad" : "", - "t131m" : "" + "time" : "2019-08-01T01:00:00Z", + "albRad" : "13.015240669", + "asobS" : "3.555093673828124", + "aswdifdS" : "1.8088226191406245", + "aswdifuS" : "0.5713421484374998", + "aswdirS" : "2.317613203124999", + "t2m" : "289.1179319051744", + "tg" : "288.4101691197649", + "u10m" : "0.3021732864307963", + "tG" : "288.4101691197649", + "u131m" : "2.6058700426057797", + "u20m" : "0.32384365019387784", + "u216m" : "3.9015497418041756", + "u65m" : "1.2823686334340363", + "v10m" : "1.3852550649486943", + "v131m" : "3.8391590569599927", + "v20m" : "1.3726831152710628", + "v216m" : "4.339362039492466", + "v65m" : "2.809877942347672", + "w131m" : "-0.02633474740256081", + "w20m" : "-0.0100060345167524", + "w216m" : "-0.030348050471342078", + "w65m" : "-0.01817112027569893", + "z0" : "0.955323922526438", + "coordinateId": "67775", + "p131m" : "", + "p20m" : "", + "p65m" : "", + "sobsRad" : "", + "t131m" : "" ] def data = new TimeBasedWeatherValueData(parameter, coordinate) @@ -138,36 +138,36 @@ class IconTimeBasedWeatherValueFactoryTest extends Specification { def coordinate = CosmoWeatherTestData.COORDINATE_67775 def parameter = [ - "time" : "2019-08-01T01:00:00Z", - "albRad" : "13.015240669", - "asobS" : "3.555093673828124", - "aswdifdS" : "1.8088226191406245", - "aswdifuS" : "0.5713421484374998", - "aswdirS" : "2.317613203124999", - "t2m" : "289.1179319051744", - "tg" : "288.4101691197649", - "u10m" : "0.3021732864307963", - "tG" : "288.4101691197649", - "u131m" : "2.6058700426057797", - "u20m" : "0.32384365019387784", - "u216m" : "3.9015497418041756", - "u65m" : "1.2823686334340363", - "v10m" : "1.3852550649486943", - "v131m" : "3.8391590569599927", - "v20m" : "1.3726831152710628", - "v216m" : "4.339362039492466", - "v65m" : "2.809877942347672", - "w131m" : "-0.02633474740256081", - "w20m" : "-0.0100060345167524", - "w216m" : "-0.030348050471342078", - "w65m" : "-0.01817112027569893", - "z0" : "0.955323922526438", - "coordinateId": "67775", - "p131m" : "", - "p20m" : "", - "p65m" : "", - "sobsRad" : "", - "t131m" : "" + "time" : "2019-08-01T01:00:00Z", + "albRad" : "13.015240669", + "asobS" : "3.555093673828124", + "aswdifdS" : "1.8088226191406245", + "aswdifuS" : "0.5713421484374998", + "aswdirS" : "2.317613203124999", + "t2m" : "289.1179319051744", + "tg" : "288.4101691197649", + "u10m" : "0.3021732864307963", + "tG" : "288.4101691197649", + "u131m" : "2.6058700426057797", + "u20m" : "0.32384365019387784", + "u216m" : "3.9015497418041756", + "u65m" : "1.2823686334340363", + "v10m" : "1.3852550649486943", + "v131m" : "3.8391590569599927", + "v20m" : "1.3726831152710628", + "v216m" : "4.339362039492466", + "v65m" : "2.809877942347672", + "w131m" : "-0.02633474740256081", + "w20m" : "-0.0100060345167524", + "w216m" : "-0.030348050471342078", + "w65m" : "-0.01817112027569893", + "z0" : "0.955323922526438", + "coordinateId": "67775", + "p131m" : "", + "p20m" : "", + "p65m" : "", + "sobsRad" : "", + "t131m" : "" ] def data = new TimeBasedWeatherValueData(parameter, coordinate) diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/couchbase/CouchbaseWeatherSourceCosmoIT.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/couchbase/CouchbaseWeatherSourceCosmoIT.groovy index 1a14b0cc7..c216ce0e0 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/couchbase/CouchbaseWeatherSourceCosmoIT.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/couchbase/CouchbaseWeatherSourceCosmoIT.groovy @@ -35,7 +35,7 @@ class CouchbaseWeatherSourceCosmoIT extends Specification implements TestContain CouchbaseContainer couchbaseContainer = new CouchbaseContainer("couchbase/server:6.6.0") .withBucket(bucketDefinition) .withExposedPorts(8091, 8092, 8093, 8094, 11210) - .withStartupAttempts(3) // 3 attempts because startup (node renaming) sometimes fails when executed too early + .withStartupAttempts(3) // 3 attempts because startup (node renaming) sometimes fails when executed too early @Shared CouchbaseWeatherSource source @@ -46,13 +46,13 @@ class CouchbaseWeatherSourceCosmoIT extends Specification implements TestContain // Copy import file with json array of documents into docker MountableFile couchbaseWeatherJsonsFile = getMountableFile("_weather/cosmo/weather.json") couchbaseContainer.copyFileToContainer(couchbaseWeatherJsonsFile, "/home/weather_cosmo.json") -// create an index for the document keys + // create an index for the document keys couchbaseContainer.execInContainer("cbq", "-e", "http://localhost:8093", "-u", couchbaseContainer.username, "-p", couchbaseContainer.password, "-s", "CREATE index id_idx ON `" + bucketDefinition.name + "` (META().id);") -//import the json documents from the copied file + //import the json documents from the copied file couchbaseContainer.execInContainer("cbimport", "json", "-cluster", "http://localhost:8091", "--bucket", "ie3_in", @@ -142,7 +142,7 @@ class CouchbaseWeatherSourceCosmoIT extends Specification implements TestContain then: coordinateToTimeSeries.keySet().size() == 3 equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193186).entries, timeSeries193186.entries) - equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193187).entries, timeSeries193187.entries) + equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193187).entries, timeSeries193187.entries) equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193188).entries, timeSeries193188.entries) } diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/couchbase/CouchbaseWeatherSourceIconIT.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/couchbase/CouchbaseWeatherSourceIconIT.groovy index 1d7d452af..49e2d2934 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/couchbase/CouchbaseWeatherSourceIconIT.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/couchbase/CouchbaseWeatherSourceIconIT.groovy @@ -33,7 +33,7 @@ class CouchbaseWeatherSourceIconIT extends Specification implements TestContaine CouchbaseContainer couchbaseContainer = new CouchbaseContainer("couchbase/server:6.6.0") .withBucket(bucketDefinition) .withExposedPorts(8091, 8092, 8093, 8094, 11210) - .withStartupAttempts(3) // 3 attempts because startup (node renaming) sometimes fails when executed too early + .withStartupAttempts(3) // 3 attempts because startup (node renaming) sometimes fails when executed too early @Shared CouchbaseWeatherSource source @@ -44,13 +44,13 @@ class CouchbaseWeatherSourceIconIT extends Specification implements TestContaine // Copy import file with json array of documents into docker def couchbaseWeatherJsonsFile = getMountableFile("_weather/icon/weather.json") couchbaseContainer.copyFileToContainer(couchbaseWeatherJsonsFile, "/home/weather_icon.json") -// create an index for the document keys + // create an index for the document keys couchbaseContainer.execInContainer("cbq", "-e", "http://localhost:8093", "-u", couchbaseContainer.username, "-p", couchbaseContainer.password, "-s", "CREATE index id_idx ON `" + bucketDefinition.name + "` (META().id);") -//import the json documents from the copied file + //import the json documents from the copied file couchbaseContainer.execInContainer("cbimport", "json", "-cluster", "http://localhost:8091", "--bucket", "ie3_in", @@ -88,7 +88,7 @@ class CouchbaseWeatherSourceIconIT extends Specification implements TestContaine then: optTimeBasedValue.present - equalsIgnoreUUID(optTimeBasedValue.get(), expectedTimeBasedValue) + equalsIgnoreUUID(optTimeBasedValue.get(), expectedTimeBasedValue) } def "A CouchbaseWeatherSource can read multiple time series values for multiple coordinates"() { @@ -114,8 +114,8 @@ class CouchbaseWeatherSourceIconIT extends Specification implements TestContaine then: coordinateToTimeSeries.keySet().size() == 2 - equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67775), timeSeries67775) - equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67776), timeSeries67776) + equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67775), timeSeries67775) + equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67776), timeSeries67776) } def "A CouchbaseWeatherSource can read all weather data in a given time interval"() { @@ -138,8 +138,8 @@ class CouchbaseWeatherSourceIconIT extends Specification implements TestContaine then: coordinateToTimeSeries.keySet().size() == 2 -equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67775).entries, timeSeries67775.entries) - equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67776).entries, timeSeries67776.entries) + equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67775).entries, timeSeries67775.entries) + equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67776).entries, timeSeries67776.entries) } def "The CouchbaseWeatherSource returns all time keys after a given time key correctly"() { diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceCosmoTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceCosmoTest.groovy index fa85bf1a6..e1ca89bba 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceCosmoTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceCosmoTest.groovy @@ -49,7 +49,7 @@ class CsvWeatherSourceCosmoTest extends Specification implements CsvTestDataMeta then: optTimeBasedValue.present - equalsIgnoreUUID(optTimeBasedValue.get(), expectedTimeBasedValue) + equalsIgnoreUUID(optTimeBasedValue.get(), expectedTimeBasedValue) } def "A CsvWeatherSource can read multiple time series values for multiple coordinates"() { @@ -105,8 +105,8 @@ class CsvWeatherSourceCosmoTest extends Specification implements CsvTestDataMeta then: coordinateToTimeSeries.keySet().size() == 3 equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193186).entries, timeSeries193186.entries) - equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193187).entries, timeSeries193187.entries) - equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193188).entries, timeSeries193188.entries) + equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193187).entries, timeSeries193187.entries) + equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193188).entries, timeSeries193188.entries) } def "The CsvWeatherSource is able to build a single WeatherValue from field to value mapping"() { diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceIconTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceIconTest.groovy index ab41b749d..1aaa26b78 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceIconTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceIconTest.groovy @@ -71,7 +71,7 @@ class CsvWeatherSourceIconTest extends Specification implements CsvTestDataMeta, then: coordinateToTimeSeries.keySet().size() == 2 equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67775), timeSeries67775) - equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67776), timeSeries67776) + equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67776), timeSeries67776) } @@ -95,7 +95,7 @@ class CsvWeatherSourceIconTest extends Specification implements CsvTestDataMeta, then: coordinateToTimeSeries.keySet().size() == 2 - equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67775).entries, timeSeries67775.entries) + equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67775).entries, timeSeries67775.entries) equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67776).entries, timeSeries67776.entries) } @@ -109,35 +109,35 @@ class CsvWeatherSourceIconTest extends Specification implements CsvTestDataMeta, def fieldToValues = new TreeMap<>(String.CASE_INSENSITIVE_ORDER) fieldToValues.putAll( [ - "datum" : "2019-08-01 01:00:00", - "albRad" : "13.015240669", - "asobS" : "3.555093673828124", - "aswdifdS" : "1.8088226191406245", - "aswdifuS" : "0.5713421484374998", - "aswdirS" : "2.317613203124999", - "t2m" : "289.1179319051744", - "tg" : "288.4101691197649", - "u10m" : "0.3021732864307963", - "u131m" : "2.6058700426057797", - "u20m" : "0.32384365019387784", - "u216m" : "3.9015497418041756", - "u65m" : "1.2823686334340363", - "v10m" : "1.3852550649486943", - "v131m" : "3.8391590569599927", - "v20m" : "1.3726831152710628", - "v216m" : "4.339362039492466", - "v65m" : "2.809877942347672", - "w131m" : "-0.02633474740256081", - "w20m" : "-0.0100060345167524", - "w216m" : "-0.030348050471342078", - "w65m" : "-0.01817112027569893", - "z0" : "0.955323922526438", - "coordinateId": "67775", - "p131m" : "", - "p20m" : "", - "p65m" : "", - "sobsRad" : "", - "t131m" : "" + "datum" : "2019-08-01 01:00:00", + "albRad" : "13.015240669", + "asobS" : "3.555093673828124", + "aswdifdS" : "1.8088226191406245", + "aswdifuS" : "0.5713421484374998", + "aswdirS" : "2.317613203124999", + "t2m" : "289.1179319051744", + "tg" : "288.4101691197649", + "u10m" : "0.3021732864307963", + "u131m" : "2.6058700426057797", + "u20m" : "0.32384365019387784", + "u216m" : "3.9015497418041756", + "u65m" : "1.2823686334340363", + "v10m" : "1.3852550649486943", + "v131m" : "3.8391590569599927", + "v20m" : "1.3726831152710628", + "v216m" : "4.339362039492466", + "v65m" : "2.809877942347672", + "w131m" : "-0.02633474740256081", + "w20m" : "-0.0100060345167524", + "w216m" : "-0.030348050471342078", + "w65m" : "-0.01817112027569893", + "z0" : "0.955323922526438", + "coordinateId": "67775", + "p131m" : "", + "p20m" : "", + "p65m" : "", + "sobsRad" : "", + "t131m" : "" ]) when: @@ -154,34 +154,34 @@ class CsvWeatherSourceIconTest extends Specification implements CsvTestDataMeta, def weatherFactory = new IconTimeBasedWeatherValueFactory() def source = new CsvWeatherSource(",", weatherIconFolderPath, new FileNamingStrategy(), coordinateSource, weatherFactory) def fieldToValues = [ "datum" : "2019-08-01 01:00:00", - "albRad" : "13.015240669", - "asobS" : "3.555093673828124", - "aswdifdS" : "1.8088226191406245", - "aswdifuS" : "0.5713421484374998", - "aswdirS" : "2.317613203124999", - "t2m" : "289.1179319051744", - "tg" : "288.4101691197649", - "u10m" : "0.3021732864307963", - "u131m" : "2.6058700426057797", - "u20m" : "0.32384365019387784", - "u216m" : "3.9015497418041756", - "u65m" : "1.2823686334340363", - "v10m" : "1.3852550649486943", - "v131m" : "3.8391590569599927", - "v20m" : "1.3726831152710628", - "v216m" : "4.339362039492466", - "v65m" : "2.809877942347672", - "w131m" : "-0.02633474740256081", - "w20m" : "-0.0100060345167524", - "w216m" : "-0.030348050471342078", - "w65m" : "-0.01817112027569893", - "z0" : "0.955323922526438", - "coordinateId": "", - "p131m" : "", - "p20m" : "", - "p65m" : "", - "sobsRad" : "", - "t131m" : ""] + "albRad" : "13.015240669", + "asobS" : "3.555093673828124", + "aswdifdS" : "1.8088226191406245", + "aswdifuS" : "0.5713421484374998", + "aswdirS" : "2.317613203124999", + "t2m" : "289.1179319051744", + "tg" : "288.4101691197649", + "u10m" : "0.3021732864307963", + "u131m" : "2.6058700426057797", + "u20m" : "0.32384365019387784", + "u216m" : "3.9015497418041756", + "u65m" : "1.2823686334340363", + "v10m" : "1.3852550649486943", + "v131m" : "3.8391590569599927", + "v20m" : "1.3726831152710628", + "v216m" : "4.339362039492466", + "v65m" : "2.809877942347672", + "w131m" : "-0.02633474740256081", + "w20m" : "-0.0100060345167524", + "w216m" : "-0.030348050471342078", + "w65m" : "-0.01817112027569893", + "z0" : "0.955323922526438", + "coordinateId": "", + "p131m" : "", + "p20m" : "", + "p65m" : "", + "sobsRad" : "", + "t131m" : ""] when: def actual = source.buildWeatherValue(fieldToValues) @@ -196,33 +196,33 @@ class CsvWeatherSourceIconTest extends Specification implements CsvTestDataMeta, def weatherFactory = new IconTimeBasedWeatherValueFactory() def source = new CsvWeatherSource(",", weatherIconFolderPath, new FileNamingStrategy(), coordinateSource, weatherFactory) def fieldToValues = [ "datum" : "2019-08-01 01:00:00", - "albRad" : "13.015240669", - "asobS" : "3.555093673828124", - "aswdifdS": "1.8088226191406245", - "aswdifuS": "0.5713421484374998", - "aswdirS" : "2.317613203124999", - "t2m" : "289.1179319051744", - "tg" : "288.4101691197649", - "u10m" : "0.3021732864307963", - "u131m" : "2.6058700426057797", - "u20m" : "0.32384365019387784", - "u216m" : "3.9015497418041756", - "u65m" : "1.2823686334340363", - "v10m" : "1.3852550649486943", - "v131m" : "3.8391590569599927", - "v20m" : "1.3726831152710628", - "v216m" : "4.339362039492466", - "v65m" : "2.809877942347672", - "w131m" : "-0.02633474740256081", - "w20m" : "-0.0100060345167524", - "w216m" : "-0.030348050471342078", - "w65m" : "-0.01817112027569893", - "z0" : "0.955323922526438", - "p131m" : "", - "p20m" : "", - "p65m" : "", - "sobsRad" : "", - "t131m" : ""] + "albRad" : "13.015240669", + "asobS" : "3.555093673828124", + "aswdifdS": "1.8088226191406245", + "aswdifuS": "0.5713421484374998", + "aswdirS" : "2.317613203124999", + "t2m" : "289.1179319051744", + "tg" : "288.4101691197649", + "u10m" : "0.3021732864307963", + "u131m" : "2.6058700426057797", + "u20m" : "0.32384365019387784", + "u216m" : "3.9015497418041756", + "u65m" : "1.2823686334340363", + "v10m" : "1.3852550649486943", + "v131m" : "3.8391590569599927", + "v20m" : "1.3726831152710628", + "v216m" : "4.339362039492466", + "v65m" : "2.809877942347672", + "w131m" : "-0.02633474740256081", + "w20m" : "-0.0100060345167524", + "w216m" : "-0.030348050471342078", + "w65m" : "-0.01817112027569893", + "z0" : "0.955323922526438", + "p131m" : "", + "p20m" : "", + "p65m" : "", + "sobsRad" : "", + "t131m" : ""] when: def actual = source.buildWeatherValue(fieldToValues) @@ -238,34 +238,34 @@ class CsvWeatherSourceIconTest extends Specification implements CsvTestDataMeta, def weatherFactory = new IconTimeBasedWeatherValueFactory() def source = new CsvWeatherSource(",", weatherIconFolderPath, new FileNamingStrategy(), coordinateSource, weatherFactory) def fieldToValues = [ "datum" : "2019-08-01 01:00:00", - "albRad" : "13.015240669", - "asobS" : "3.555093673828124", - "aswdifdS" : "1.8088226191406245", - "aswdifuS" : "0.5713421484374998", - "aswdirS" : "2.317613203124999", - "t2m" : "289.1179319051744", - "tg" : "288.4101691197649", - "u10m" : "0.3021732864307963", - "u131m" : "2.6058700426057797", - "u20m" : "0.32384365019387784", - "u216m" : "3.9015497418041756", - "u65m" : "1.2823686334340363", - "v10m" : "1.3852550649486943", - "v131m" : "3.8391590569599927", - "v20m" : "1.3726831152710628", - "v216m" : "4.339362039492466", - "v65m" : "2.809877942347672", - "w131m" : "-0.02633474740256081", - "w20m" : "-0.0100060345167524", - "w216m" : "-0.030348050471342078", - "w65m" : "-0.01817112027569893", - "z0" : "0.955323922526438", - "coordinateId": "67777", - "p131m" : "", - "p20m" : "", - "p65m" : "", - "sobsRad" : "", - "t131m" : ""] + "albRad" : "13.015240669", + "asobS" : "3.555093673828124", + "aswdifdS" : "1.8088226191406245", + "aswdifuS" : "0.5713421484374998", + "aswdirS" : "2.317613203124999", + "t2m" : "289.1179319051744", + "tg" : "288.4101691197649", + "u10m" : "0.3021732864307963", + "u131m" : "2.6058700426057797", + "u20m" : "0.32384365019387784", + "u216m" : "3.9015497418041756", + "u65m" : "1.2823686334340363", + "v10m" : "1.3852550649486943", + "v131m" : "3.8391590569599927", + "v20m" : "1.3726831152710628", + "v216m" : "4.339362039492466", + "v65m" : "2.809877942347672", + "w131m" : "-0.02633474740256081", + "w20m" : "-0.0100060345167524", + "w216m" : "-0.030348050471342078", + "w65m" : "-0.01817112027569893", + "z0" : "0.955323922526438", + "coordinateId": "67777", + "p131m" : "", + "p20m" : "", + "p65m" : "", + "sobsRad" : "", + "t131m" : ""] when: def actual = source.buildWeatherValue(fieldToValues) diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/influxdb/InfluxDbWeatherSourceCosmoIT.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/influxdb/InfluxDbWeatherSourceCosmoIT.groovy index e3719295e..2994d6c00 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/influxdb/InfluxDbWeatherSourceCosmoIT.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/influxdb/InfluxDbWeatherSourceCosmoIT.groovy @@ -123,7 +123,7 @@ class InfluxDbWeatherSourceCosmoIT extends Specification implements TestContaine then: coordinateToTimeSeries.keySet().size() == 3 - equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193186).entries, timeseries_193186.entries) + equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193186).entries, timeseries_193186.entries) equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193187).entries, timeseries_193187.entries) equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193188).entries, timeseries_193188.entries) } From 9f767ed259229ed3c9f3aca806dd3b0479202d83 Mon Sep 17 00:00:00 2001 From: pierrepetersmeier <155652256+pierrepetersmeier@users.noreply.github.com> Date: Fri, 11 Jul 2025 11:51:32 +0200 Subject: [PATCH 05/36] Meeting --- .../CosmoTimeBasedWeatherValueFactory.java | 6 +- .../IconTimeBasedWeatherValueFactory.java | 7 +- .../timeseries/TimeSeriesProcessor.java | 26 +++++ .../datamodel/models/value/WeatherValue.java | 106 +++++++++--------- 4 files changed, 88 insertions(+), 57 deletions(-) diff --git a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactory.java index ba51a2454..81da82a1f 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactory.java @@ -1,5 +1,5 @@ /* - * © 2020. TU Dortmund University, + * © 2021. TU Dortmund University, * Institute of Energy Systems, Energy Efficiency and Energy Economics, * Research group Distribution grid planning and operation */ @@ -30,8 +30,6 @@ * value mapping in the typical PowerSystemDataModel (PSDM) column scheme */ public class CosmoTimeBasedWeatherValueFactory extends TimeBasedWeatherValueFactory { - private static final String TIME = "time"; - private static final String COORDINATE_ID = "coordinateId"; private static final String DIFFUSE_IRRADIANCE = "diffuseIrradiance"; private static final String DIRECT_IRRADIANCE = "directIrradiance"; private static final String TEMPERATURE = "temperature"; @@ -58,7 +56,6 @@ protected List> getFields(Class entityClass) { new HashSet<>( Set.of( COORDINATE_ID, - TIME, DIFFUSE_IRRADIANCE, DIRECT_IRRADIANCE, TEMPERATURE, @@ -76,7 +73,6 @@ protected List> getFields(Class entityClass) { protected TimeBasedValue buildModel(TimeBasedWeatherValueData data) { Point coordinate = data.getCoordinate(); ZonedDateTime time = timeUtil.toZonedDateTime(data.getField(TIME)); - ComparableQuantity directIrradiance = data.getQuantity(DIRECT_IRRADIANCE, PowerSystemUnits.WATT_PER_SQUAREMETRE); ComparableQuantity diffuseIrradiance = diff --git a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java index 5ebd65ce1..3814f831a 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java @@ -147,8 +147,11 @@ protected TimeBasedValue buildModel(TimeBasedWeatherValueData data */ private static ComparableQuantity getWindDirection(TimeBasedWeatherValueData data) { /* Get the three dimensional parts of the wind velocity vector in cartesian coordinates */ - double u = data.getDouble(WIND_VELOCITY_U); - double v = data.getDouble(WIND_VELOCITY_V); + double u = + data.getDouble(WIND_VELOCITY_U); // Wind component from west to east (parallel to latitudes) + double v = + data.getDouble( + WIND_VELOCITY_V); // Wind component from south to north (parallel to longitudes) double angle = Math.toDegrees(Math.atan2(-u, -v)); return Quantities.getQuantity(angle < 0 ? angle + 360d : angle, PowerSystemUnits.DEGREE_GEOM) diff --git a/src/main/java/edu/ie3/datamodel/io/processor/timeseries/TimeSeriesProcessor.java b/src/main/java/edu/ie3/datamodel/io/processor/timeseries/TimeSeriesProcessor.java index 97cb8bf70..2640d1bb9 100644 --- a/src/main/java/edu/ie3/datamodel/io/processor/timeseries/TimeSeriesProcessor.java +++ b/src/main/java/edu/ie3/datamodel/io/processor/timeseries/TimeSeriesProcessor.java @@ -65,6 +65,7 @@ public class TimeSeriesProcessor< * foreseen to handle. */ private final TimeSeriesProcessorKey registeredKey; + /** * Mapping from field name to the source, where to find the information and which getter method to * invoke @@ -77,6 +78,7 @@ public TimeSeriesProcessor(Class timeSeriesClass, Class entryClass, Class< throws EntityProcessorException { super(timeSeriesClass); + /* Check, if this processor can handle the foreseen combination of time series, entry and value */ TimeSeriesProcessorKey timeSeriesKey = new TimeSeriesProcessorKey(timeSeriesClass, entryClass, valueClass); if (!eligibleKeys.contains(timeSeriesKey)) @@ -91,13 +93,17 @@ public TimeSeriesProcessor(Class timeSeriesClass, Class entryClass, Class< .collect(Collectors.joining(", "))); this.registeredKey = timeSeriesKey; + /* Register, where to get which information from */ this.fieldToSource = buildFieldToSource(timeSeriesClass, entryClass, valueClass); + + /* Collect all header elements */ this.flattenedHeaderElements = fieldToSource.keySet().toArray(new String[0]); } public TimeSeriesProcessorKey getRegisteredKey() { return registeredKey; } + /** * Collects the mapping, where to find which information and how to get them (in terms of getter * method). @@ -147,11 +153,13 @@ private SortedMap buildFieldToSource( Map.Entry::getKey, entry -> new FieldSourceToMethod(VALUE, entry.getValue()))); } + /* Put everything together */ HashMap jointMapping = new HashMap<>(); jointMapping.putAll(timeSeriesMapping); jointMapping.putAll(entryMapping); jointMapping.putAll(valueMapping); + /* Let uuid be the first entry */ return putUuidFirst(jointMapping); } @@ -161,6 +169,7 @@ public LinkedHashMap handleEntity(TimeSeries entity) { throw new UnsupportedOperationException( "Don't invoke this simple method, but TimeSeriesProcessor#handleTimeSeries(TimeSeries)."); } + /** * Handles the time series by processing each entry and collecting the results * @@ -184,12 +193,14 @@ public Set> handleTimeSeries(T timeSeries) for (E entry : timeSeries.getEntries()) { Map entryResult = handleEntry(timeSeries, entry); + /* Prepare the actual result and add them to the set of all results */ fieldToValueSet.add(new LinkedHashMap<>(entryResult)); } return fieldToValueSet; } + /** * Processes a single entry to a mapping from field name to value as String representation. The * information from the time series are added as well. @@ -203,12 +214,26 @@ private Map handleEntry(T timeSeries, E entry) throws EntityProc Map timeSeriesFieldToMethod = extractFieldToMethod(TIMESERIES); LinkedHashMap timeSeriesResults = processObject(timeSeries, timeSeriesFieldToMethod); + /* Handle the information in the entry */ Map entryFieldToMethod = extractFieldToMethod(ENTRY); LinkedHashMap entryResults = processObject(entry, entryFieldToMethod); + /* Handle the information in the value */ Map valueFieldToMethod = extractFieldToMethod(VALUE); LinkedHashMap valueResult = processObject(entry.getValue(), valueFieldToMethod); + /* Treat WeatherValues specially, as they are nested ones */ + if (entry.getValue() instanceof WeatherValue weatherValue) { + Map irradianceFieldToMethod = extractFieldToMethod(WEATHER_IRRADIANCE); + valueResult.putAll(processObject(weatherValue.getSolarIrradiance(), irradianceFieldToMethod)); + + Map temperatureFieldToMethod = extractFieldToMethod(WEATHER_TEMPERATURE); + valueResult.putAll(processObject(weatherValue.getTemperature(), temperatureFieldToMethod)); + + Map windFieldToMethod = extractFieldToMethod(WEATHER_WIND); + valueResult.putAll(processObject(weatherValue.getWind(), windFieldToMethod)); + } + /* Join all information and sort them */ Map combinedResult = new HashMap<>(); combinedResult.putAll(timeSeriesResults); @@ -216,6 +241,7 @@ private Map handleEntry(T timeSeries, E entry) throws EntityProc combinedResult.putAll(valueResult); return putUuidFirst(combinedResult); } + /** * Extracts the field name to method map for the specific source * diff --git a/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java b/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java index 4132f02da..800140da8 100644 --- a/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java +++ b/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java @@ -17,63 +17,77 @@ import org.locationtech.jts.geom.Point; import tech.units.indriya.ComparableQuantity; +/** Describes weather as a combination of solar irradiance, temperature and wind values */ public class WeatherValue implements Value { + /** The coordinate of this weather value set */ private final Point coordinate; - private final ComparableQuantity diffSolar; - private final ComparableQuantity directSolar; - private final ComparableQuantity temperature; - private final ComparableQuantity windDir; - private final ComparableQuantity windVel; + /** solar irradiance values for this coordinate */ + private final SolarIrradianceValue solarIrradiance; + + /** Temperature value for this coordinate */ + private final TemperatureValue temperature; + /** Wind values for this coordinate */ + private final WindValue wind; + private final Map, TemperatureValue> groundTemperatures; /** * @param coordinate of this weather value set - * @param directSolar Direct solar irradiance - * @param diffSolar Diffuse solar irradiance - * @param temperature Temperature in 2m height - * @param windDir Wind direction - * @param windVel Wind velocity + * @param solarIrradiance values for this coordinate + * @param temperature values for this coordinate + * @param wind values for this coordinate * @param groundTemperatures A map of ground temperatures at different depths */ public WeatherValue( Point coordinate, - ComparableQuantity directSolar, - ComparableQuantity diffSolar, - ComparableQuantity temperature, - ComparableQuantity windDir, - ComparableQuantity windVel, - Map, TemperatureValue> groundTemperatures) { + SolarIrradianceValue solarIrradiance, + TemperatureValue temperature, + WindValue wind,Map, TemperatureValue> groundTemperatures) { this.coordinate = coordinate; this.directSolar = directSolar; this.diffSolar = diffSolar; this.temperature = temperature; - this.windDir = windDir; - this.windVel = windVel; - this.groundTemperatures = Collections.unmodifiableMap(new HashMap<>(groundTemperatures)); + this.wind = wind; } - public Point getCoordinate() { - return coordinate; + /** + * @param coordinate of this weather value set + * @param directSolarIrradiance Direct sun irradiance for this coordinate (typically in W/m²) + * @param diffuseSolarIrradiance Diffuse sun irradiance for this coordinate (typically in W/m²) + * @param temperature for this coordinate (typically in K) + * @param direction Direction, the wind comes from as an angle from north increasing clockwise + * (typically in rad) + * @param velocity Wind velocity for this coordinate (typically in m/s) + */ + public WeatherValue( + Point coordinate, + ComparableQuantity directSolarIrradiance, + ComparableQuantity diffuseSolarIrradiance, + ComparableQuantity temperature, + ComparableQuantity direction, + ComparableQuantity velocity) { + this.groundTemperatures = Collections.unmodifiableMap(new HashMap<>(groundTemperatures) + this( + coordinate, + new SolarIrradianceValue(directSolarIrradiance, diffuseSolarIrradiance), + new TemperatureValue(temperature), + new WindValue(direction, velocity)); } - public ComparableQuantity getDiffSolar() { - return diffSolar; + public Point getCoordinate() { + return coordinate; } - public ComparableQuantity getDirectSolar() { - return directSolar; + public SolarIrradianceValue getSolarIrradiance() { + return solarIrradiance; } - public ComparableQuantity getTemperature() { + public TemperatureValue getTemperature() { return temperature; } - public ComparableQuantity getWindDir() { - return windDir; - } - - public ComparableQuantity getWindVel() { - return windVel; + public WindValue getWind() { + return wind; } /** @@ -84,7 +98,6 @@ public ComparableQuantity getWindVel() { */ public Map, TemperatureValue> getGroundTemperatures() { return groundTemperatures; - } @Override public boolean equals(Object o) { @@ -92,18 +105,15 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) return false; WeatherValue that = (WeatherValue) o; return coordinate.equals(that.coordinate) - && diffSolar.equals(that.diffSolar) - && directSolar.equals(that.directSolar) + && solarIrradiance.equals(that.solarIrradiance) && temperature.equals(that.temperature) - && windDir.equals(that.windDir) - && windVel.equals(that.windVel) - && groundTemperatures.equals(that.groundTemperatures); + && wind.equals(that.wind) + && groundTemperatures.equals(that.groundTemperatures); } @Override public int hashCode() { - return Objects.hash( - coordinate, diffSolar, directSolar, temperature, windDir, windVel, groundTemperatures); + return Objects.hash(coordinate, solarIrradiance, temperature, wind,groundTemperatures); } @Override @@ -111,18 +121,14 @@ public String toString() { return "WeatherValue{" + "coordinate=" + coordinate - + ", diffSolar=" - + diffSolar - + ", directSolar=" - + directSolar + + ", solarIrradiance=" + + solarIrradiance + ", temperature=" + temperature - + ", windDir=" - + windDir - + ", windVel=" - + windVel - + ", groundTemperatures=" - + groundTemperatures + + ", wind=" + + wind + + ", groundTemperatures=" + + groundTemperatures + '}'; } } From b015b666e31dfcc59227c3f93b10f2636c7323bf Mon Sep 17 00:00:00 2001 From: pierrepetersmeier <155652256+pierrepetersmeier@users.noreply.github.com> Date: Wed, 16 Jul 2025 10:23:01 +0200 Subject: [PATCH 06/36] Add GroundTemperatureValue and refactor WeatherValue, CosmoTimeBasedWeatherValueFactory and IconTimeBasedWeatherValueFactory --- .../CosmoTimeBasedWeatherValueFactory.java | 57 ++--- .../IconTimeBasedWeatherValueFactory.java | 54 +--- .../timeseries/TimeSeriesProcessor.java | 51 +++- .../models/value/GroundTemperatureValue.java | 46 ++++ .../datamodel/models/value/WeatherValue.java | 57 ++--- .../ie3/datamodel/utils/ContainerUtils.java | 121 +-------- .../GridContainerValidationUtils.java | 20 +- .../utils/validation/ValidationUtils.java | 19 +- ...smoTimeBasedWeatherValueFactoryTest.groovy | 49 ++-- ...conTimeBasedWeatherValueFactoryTest.groovy | 83 +------ .../CouchbaseWeatherSourceCosmoIT.groovy | 8 +- .../CouchbaseWeatherSourceIconIT.groovy | 5 +- .../csv/CsvWeatherSourceCosmoTest.groovy | 32 ++- .../csv/CsvWeatherSourceIconTest.groovy | 25 +- .../InfluxDbWeatherSourceCosmoIT.groovy | 7 +- .../InfluxDbWeatherSourceIconIT.groovy | 8 +- .../source/sql/SqlWeatherSourceCosmoIT.groovy | 5 +- .../source/sql/SqlWeatherSourceIconIT.groovy | 2 +- .../datamodel/utils/ContainerUtilsTest.groovy | 233 +----------------- .../UniquenessValidationUtilsTest.groovy | 24 +- .../test/common/CosmoWeatherTestData.groovy | 22 +- .../test/common/IconWeatherTestData.groovy | 33 +-- .../ie3/test/common/TimeSeriesTestData.groovy | 214 ++++++++-------- .../helper/WeatherSourceTestHelper.groovy | 19 +- 24 files changed, 379 insertions(+), 815 deletions(-) create mode 100644 src/main/java/edu/ie3/datamodel/models/value/GroundTemperatureValue.java diff --git a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactory.java index 81da82a1f..048c76c14 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactory.java @@ -5,38 +5,39 @@ */ package edu.ie3.datamodel.io.factory.timeseries; -import edu.ie3.datamodel.exceptions.FactoryException; import edu.ie3.datamodel.models.StandardUnits; import edu.ie3.datamodel.models.timeseries.individual.TimeBasedValue; -import edu.ie3.datamodel.models.value.TemperatureValue; import edu.ie3.datamodel.models.value.WeatherValue; import edu.ie3.util.TimeUtil; import edu.ie3.util.quantities.PowerSystemUnits; import edu.ie3.util.quantities.interfaces.Irradiance; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; -import java.util.*; +import java.util.List; +import java.util.Set; import javax.measure.quantity.Angle; -import javax.measure.quantity.Length; import javax.measure.quantity.Speed; import javax.measure.quantity.Temperature; import org.locationtech.jts.geom.Point; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import tech.units.indriya.ComparableQuantity; -import tech.units.indriya.quantity.Quantities; -import tech.units.indriya.unit.Units; /** * Factory implementation of {@link TimeBasedWeatherValueFactory}, that is able to handle field to * value mapping in the typical PowerSystemDataModel (PSDM) column scheme */ public class CosmoTimeBasedWeatherValueFactory extends TimeBasedWeatherValueFactory { + + private static final Logger logger = + LoggerFactory.getLogger(CosmoTimeBasedWeatherValueFactory.class); + private static final String DIFFUSE_IRRADIANCE = "diffuseIrradiance"; private static final String DIRECT_IRRADIANCE = "directIrradiance"; private static final String TEMPERATURE = "temperature"; + private static final String GROUND_TEMPERATURE = "groundTemperature"; private static final String WIND_DIRECTION = "windDirection"; private static final String WIND_VELOCITY = "windVelocity"; - private static final String GROUND_TEMPERATURE_SURFACE = "groundTemperatureSurface"; - private static final String GROUND_TEMPERATURE_1M = "groundTemperature1m"; public CosmoTimeBasedWeatherValueFactory(TimeUtil timeUtil) { super(timeUtil); @@ -53,20 +54,17 @@ public CosmoTimeBasedWeatherValueFactory() { @Override protected List> getFields(Class entityClass) { Set minConstructorParams = - new HashSet<>( - Set.of( - COORDINATE_ID, - DIFFUSE_IRRADIANCE, - DIRECT_IRRADIANCE, - TEMPERATURE, - WIND_DIRECTION, - WIND_VELOCITY)); + newSet( + COORDINATE_ID, + DIFFUSE_IRRADIANCE, + DIRECT_IRRADIANCE, + TEMPERATURE, + WIND_DIRECTION, + WIND_VELOCITY); - Set withGroundTemps = new HashSet<>(minConstructorParams); - withGroundTemps.add(GROUND_TEMPERATURE_SURFACE); - withGroundTemps.add(GROUND_TEMPERATURE_1M); + Set withGroundTemp = expandSet(minConstructorParams, GROUND_TEMPERATURE); - return List.of(minConstructorParams, withGroundTemps); + return List.of(minConstructorParams, withGroundTemp); } @Override @@ -84,21 +82,12 @@ protected TimeBasedValue buildModel(TimeBasedWeatherValueData data ComparableQuantity windVelocity = data.getQuantity(WIND_VELOCITY, StandardUnits.WIND_VELOCITY); - Map, TemperatureValue> groundTemperatures = new HashMap<>(); - + ComparableQuantity groundTemperature = null; try { - TemperatureValue tempValue = - new TemperatureValue( - data.getQuantity(GROUND_TEMPERATURE_SURFACE, StandardUnits.TEMPERATURE)); - groundTemperatures.put(Quantities.getQuantity(0, Units.METRE), tempValue); - } catch (FactoryException ignored) { - } + groundTemperature = data.getQuantity(GROUND_TEMPERATURE, StandardUnits.TEMPERATURE); + } catch (IllegalArgumentException e) { - try { - TemperatureValue tempValue = - new TemperatureValue(data.getQuantity(GROUND_TEMPERATURE_1M, StandardUnits.TEMPERATURE)); - groundTemperatures.put(Quantities.getQuantity(1, Units.METRE), tempValue); - } catch (FactoryException ignored) { + logger.warn("Field '{}' not found in data, proceeding without it.", GROUND_TEMPERATURE); } WeatherValue weatherValue = @@ -109,7 +98,7 @@ protected TimeBasedValue buildModel(TimeBasedWeatherValueData data temperature, windDirection, windVelocity, - groundTemperatures); + groundTemperature); return new TimeBasedValue<>(time, weatherValue); } diff --git a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java index 3814f831a..2b2bf808a 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java @@ -5,10 +5,8 @@ */ package edu.ie3.datamodel.io.factory.timeseries; -import edu.ie3.datamodel.exceptions.FactoryException; import edu.ie3.datamodel.models.StandardUnits; import edu.ie3.datamodel.models.timeseries.individual.TimeBasedValue; -import edu.ie3.datamodel.models.value.TemperatureValue; import edu.ie3.datamodel.models.value.WeatherValue; import edu.ie3.util.quantities.PowerSystemUnits; import edu.ie3.util.quantities.interfaces.Irradiance; @@ -16,10 +14,11 @@ import java.time.format.DateTimeFormatter; import java.util.*; import javax.measure.quantity.Angle; -import javax.measure.quantity.Length; import javax.measure.quantity.Speed; import javax.measure.quantity.Temperature; import org.locationtech.jts.geom.Point; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import tech.units.indriya.ComparableQuantity; import tech.units.indriya.quantity.Quantities; import tech.units.indriya.unit.Units; @@ -30,14 +29,16 @@ * Weather Service's ICON-EU model */ public class IconTimeBasedWeatherValueFactory extends TimeBasedWeatherValueFactory { + + private static final Logger logger = LoggerFactory.getLogger(IconTimeBasedWeatherValueFactory.class); + /* Redefine the column names to meet the icon specifications */ private static final String DIFFUSE_IRRADIANCE = "aswdifdS"; private static final String DIRECT_IRRADIANCE = "aswdirS"; private static final String TEMPERATURE = "t2m"; + private static final String GROUND_TEMPERATURE = "tG"; private static final String WIND_VELOCITY_U = "u131m"; private static final String WIND_VELOCITY_V = "v131m"; - private static final String GROUND_TEMP_SURFACE = "tG"; - private static final String SOIL_TEMP_100CM = "tso100cm"; public IconTimeBasedWeatherValueFactory() { super(); @@ -53,10 +54,6 @@ protected List> getFields(Class entityClass) { newSet( DIFFUSE_IRRADIANCE, DIRECT_IRRADIANCE, TEMPERATURE, WIND_VELOCITY_U, WIND_VELOCITY_V); - Set minParametersWithGroundTemp = new HashSet<>(minParameters); - minParametersWithGroundTemp.add(GROUND_TEMP_SURFACE); - minParametersWithGroundTemp.add(SOIL_TEMP_100CM); - Set allParameters = expandSet( minParameters, @@ -64,8 +61,6 @@ protected List> getFields(Class entityClass) { "asobs", "aswdifuS", "tG", - GROUND_TEMP_SURFACE, - SOIL_TEMP_100CM, "u10m", "u20m", "u216m", @@ -85,7 +80,7 @@ protected List> getFields(Class entityClass) { "sobsrad", "t131m"); - return Arrays.asList(minParameters, minParametersWithGroundTemp, allParameters); + return Arrays.asList(minParameters, allParameters); } @Override @@ -101,22 +96,13 @@ protected TimeBasedValue buildModel(TimeBasedWeatherValueData data ComparableQuantity windDirection = getWindDirection(data); ComparableQuantity windVelocity = getWindVelocity(data); - Map, TemperatureValue> groundTemperatures = new HashMap<>(); - + ComparableQuantity groundTemperature = null; try { - TemperatureValue tempValue = - new TemperatureValue( - data.getQuantity(GROUND_TEMP_SURFACE, Units.KELVIN).to(StandardUnits.TEMPERATURE)); - groundTemperatures.put(Quantities.getQuantity(0, Units.METRE), tempValue); - } catch (FactoryException ignored) { - } + groundTemperature = + data.getQuantity(GROUND_TEMPERATURE, Units.KELVIN).to(StandardUnits.TEMPERATURE); + } catch (IllegalArgumentException e) { - try { - TemperatureValue tempValue = - new TemperatureValue( - data.getQuantity(SOIL_TEMP_100CM, Units.KELVIN).to(StandardUnits.TEMPERATURE)); - groundTemperatures.put(Quantities.getQuantity(1, Units.METRE), tempValue); - } catch (FactoryException ignored) { + logger.warn("Field '{}' not found in data, proceeding without it.", GROUND_TEMPERATURE); } WeatherValue weatherValue = @@ -127,24 +113,10 @@ protected TimeBasedValue buildModel(TimeBasedWeatherValueData data temperature, windDirection, windVelocity, - groundTemperatures); - + groundTemperature); return new TimeBasedValue<>(time, weatherValue); } - /** - * Determines the wind direction. In ICON the wind velocity is given in three dimensional - * Cartesian coordinates. Here, the upward component is neglected. 0° or 0 rad are defined to - * point northwards. The angle increases clockwise. Please note, that the wind direction is the - * direction, the wind comes from and not goes to. We choose to use the wind velocity - * calculations at 131 m above ground, as this is a height that pretty good matches the common hub - * height of today's onshore wind generators, that are commonly connected to the voltage levels of - * interest. - * - * @param data Collective information to convert - * @return A {@link ComparableQuantity} of type {@link Speed}, that is converted to {@link - * StandardUnits#WIND_VELOCITY} - */ private static ComparableQuantity getWindDirection(TimeBasedWeatherValueData data) { /* Get the three dimensional parts of the wind velocity vector in cartesian coordinates */ double u = diff --git a/src/main/java/edu/ie3/datamodel/io/processor/timeseries/TimeSeriesProcessor.java b/src/main/java/edu/ie3/datamodel/io/processor/timeseries/TimeSeriesProcessor.java index 2640d1bb9..d536bbb02 100644 --- a/src/main/java/edu/ie3/datamodel/io/processor/timeseries/TimeSeriesProcessor.java +++ b/src/main/java/edu/ie3/datamodel/io/processor/timeseries/TimeSeriesProcessor.java @@ -13,15 +13,14 @@ import edu.ie3.datamodel.models.timeseries.TimeSeriesEntry; import edu.ie3.datamodel.models.timeseries.individual.IndividualTimeSeries; import edu.ie3.datamodel.models.timeseries.individual.TimeBasedValue; -import edu.ie3.datamodel.models.timeseries.repetitive.BdewLoadProfileTimeSeries; -import edu.ie3.datamodel.models.timeseries.repetitive.LoadProfileEntry; -import edu.ie3.datamodel.models.timeseries.repetitive.RandomLoadProfileTimeSeries; +import edu.ie3.datamodel.models.timeseries.repetitive.*; import edu.ie3.datamodel.models.value.*; import edu.ie3.datamodel.models.value.load.BdewLoadValues; import edu.ie3.datamodel.models.value.load.RandomLoadValues; import java.lang.reflect.Method; import java.util.*; import java.util.stream.Collectors; +import java.util.stream.Stream; public class TimeSeriesProcessor< T extends TimeSeries, @@ -132,13 +131,10 @@ private SortedMap buildFieldToSource( .collect( Collectors.toMap( Map.Entry::getKey, entry -> new FieldSourceToMethod(ENTRY, entry.getValue()))); - Map valueMapping; - if (valueClass.equals(WeatherValue.class)) { + if (!valueClass.equals(WeatherValue.class)) { valueMapping = - mapFieldNameToGetter(valueClass, Collections.singletonList("groundTemperatures")) - .entrySet() - .stream() + mapFieldNameToGetter(valueClass).entrySet().stream() .collect( Collectors.toMap( Map.Entry::getKey, @@ -147,11 +143,40 @@ private SortedMap buildFieldToSource( /* Treat the nested weather values specially. */ /* Flatten the nested structure of Weather value */ valueMapping = - mapFieldNameToGetter(valueClass).entrySet().stream() - .collect( - Collectors.toMap( - Map.Entry::getKey, - entry -> new FieldSourceToMethod(VALUE, entry.getValue()))); + Stream.concat( + Stream.concat( + Stream.concat( + mapFieldNameToGetter( + valueClass, + Arrays.asList("solarIrradiance", "temperature", "wind")) + .entrySet() + .stream() + .map( + entry -> + new AbstractMap.SimpleEntry<>( + entry.getKey(), + new FieldSourceToMethod(VALUE, entry.getValue()))), + mapFieldNameToGetter(SolarIrradianceValue.class).entrySet().stream() + .map( + entry -> + new AbstractMap.SimpleEntry<>( + entry.getKey(), + new FieldSourceToMethod( + WEATHER_IRRADIANCE, entry.getValue())))), + mapFieldNameToGetter(TemperatureValue.class).entrySet().stream() + .map( + entry -> + new AbstractMap.SimpleEntry<>( + entry.getKey(), + new FieldSourceToMethod( + WEATHER_TEMPERATURE, entry.getValue())))), + mapFieldNameToGetter(WindValue.class).entrySet().stream() + .map( + entry -> + new AbstractMap.SimpleEntry<>( + entry.getKey(), + new FieldSourceToMethod(WEATHER_WIND, entry.getValue())))) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); } /* Put everything together */ diff --git a/src/main/java/edu/ie3/datamodel/models/value/GroundTemperatureValue.java b/src/main/java/edu/ie3/datamodel/models/value/GroundTemperatureValue.java new file mode 100644 index 000000000..ba1bbfb0b --- /dev/null +++ b/src/main/java/edu/ie3/datamodel/models/value/GroundTemperatureValue.java @@ -0,0 +1,46 @@ +/* + * © 2025. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation +*/ +package edu.ie3.datamodel.models.value; + +import edu.ie3.datamodel.models.StandardUnits; +import java.util.Objects; +import java.util.Optional; +import javax.measure.quantity.Temperature; +import tech.units.indriya.ComparableQuantity; + +/** Describes a ground temperature value. */ +public class GroundTemperatureValue implements Value { + + /** Ground temperature (typically in K) */ + private final ComparableQuantity temperature; + + /** @param temperature Ground temperature (typically in K) */ + public GroundTemperatureValue(ComparableQuantity temperature) { + this.temperature = temperature == null ? null : temperature.to(StandardUnits.TEMPERATURE); + } + + public Optional> getTemperature() { + return Optional.ofNullable(temperature); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + GroundTemperatureValue that = (GroundTemperatureValue) o; + return Objects.equals(temperature, that.temperature); + } + + @Override + public int hashCode() { + return Objects.hash(temperature); + } + + @Override + public String toString() { + return "GroundTemperatureValue{" + "temperature=" + temperature + '}'; + } +} diff --git a/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java b/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java index 800140da8..7adc67ffc 100644 --- a/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java +++ b/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java @@ -6,18 +6,18 @@ package edu.ie3.datamodel.models.value; import edu.ie3.util.quantities.interfaces.Irradiance; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; import java.util.Objects; +import java.util.Optional; import javax.measure.quantity.Angle; -import javax.measure.quantity.Length; import javax.measure.quantity.Speed; import javax.measure.quantity.Temperature; import org.locationtech.jts.geom.Point; import tech.units.indriya.ComparableQuantity; -/** Describes weather as a combination of solar irradiance, temperature and wind values */ +/** + * Describes weather as a combination of solar irradiance, temperature, wind, and ground temperature + * values. + */ public class WeatherValue implements Value { /** The coordinate of this weather value set */ private final Point coordinate; @@ -28,26 +28,26 @@ public class WeatherValue implements Value { private final TemperatureValue temperature; /** Wind values for this coordinate */ private final WindValue wind; - - private final Map, TemperatureValue> groundTemperatures; + private final GroundTemperatureValue groundTemperature; /** * @param coordinate of this weather value set * @param solarIrradiance values for this coordinate * @param temperature values for this coordinate * @param wind values for this coordinate - * @param groundTemperatures A map of ground temperatures at different depths + * @param groundTemperature values for this coordinate (can be null) */ public WeatherValue( Point coordinate, SolarIrradianceValue solarIrradiance, TemperatureValue temperature, - WindValue wind,Map, TemperatureValue> groundTemperatures) { + WindValue wind, + GroundTemperatureValue groundTemperature) { this.coordinate = coordinate; - this.directSolar = directSolar; - this.diffSolar = diffSolar; + this.solarIrradiance = solarIrradiance; this.temperature = temperature; this.wind = wind; + this.groundTemperature = groundTemperature; } /** @@ -58,6 +58,7 @@ public WeatherValue( * @param direction Direction, the wind comes from as an angle from north increasing clockwise * (typically in rad) * @param velocity Wind velocity for this coordinate (typically in m/s) + * @param groundTemperature Ground temperature (typically in K) */ public WeatherValue( Point coordinate, @@ -65,13 +66,14 @@ public WeatherValue( ComparableQuantity diffuseSolarIrradiance, ComparableQuantity temperature, ComparableQuantity direction, - ComparableQuantity velocity) { - this.groundTemperatures = Collections.unmodifiableMap(new HashMap<>(groundTemperatures) + ComparableQuantity velocity, + ComparableQuantity groundTemperature) { this( coordinate, new SolarIrradianceValue(directSolarIrradiance, diffuseSolarIrradiance), new TemperatureValue(temperature), - new WindValue(direction, velocity)); + new WindValue(direction, velocity), + new GroundTemperatureValue(groundTemperature)); } public Point getCoordinate() { @@ -90,30 +92,25 @@ public WindValue getWind() { return wind; } - /** - * Returns a map of ground temperatures, with the depth as key. The map is unmodifiable. Returns - * an empty map if no values are available. - * - * @return A map of ground temperatures. - */ - public Map, TemperatureValue> getGroundTemperatures() { - return groundTemperatures; + public Optional getGroundTemperature() { + return Optional.ofNullable(groundTemperature); + } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; WeatherValue that = (WeatherValue) o; - return coordinate.equals(that.coordinate) - && solarIrradiance.equals(that.solarIrradiance) - && temperature.equals(that.temperature) - && wind.equals(that.wind) - && groundTemperatures.equals(that.groundTemperatures); + return Objects.equals(coordinate, that.coordinate) + && Objects.equals(solarIrradiance, that.solarIrradiance) + && Objects.equals(temperature, that.temperature) + && Objects.equals(wind, that.wind) + && Objects.equals(groundTemperature, that.groundTemperature); } @Override public int hashCode() { - return Objects.hash(coordinate, solarIrradiance, temperature, wind,groundTemperatures); + return Objects.hash(coordinate, solarIrradiance, temperature, wind, groundTemperature); } @Override @@ -127,8 +124,8 @@ public String toString() { + temperature + ", wind=" + wind - + ", groundTemperatures=" - + groundTemperatures + + ", groundTemperature=" + + groundTemperature + '}'; } } diff --git a/src/main/java/edu/ie3/datamodel/utils/ContainerUtils.java b/src/main/java/edu/ie3/datamodel/utils/ContainerUtils.java index 5033221a2..522dfeaa4 100644 --- a/src/main/java/edu/ie3/datamodel/utils/ContainerUtils.java +++ b/src/main/java/edu/ie3/datamodel/utils/ContainerUtils.java @@ -426,41 +426,11 @@ public static GraphicElements filterForSubnet(GraphicElements input, int subnet) */ public static VoltageLevel determinePredominantVoltLvl(RawGridElements rawGrid, int subnet) throws InvalidGridException { - /* Exclude all nodes, that are at the high voltage side of the transformer */ - Set gridNodes = new HashSet<>(rawGrid.getNodes()); - gridNodes.removeAll( - /* Remove all nodes, that are upstream of transformers, this comprises all those, that are connected by - * switches */ - rawGrid.getTransformer2Ws().stream() - .flatMap( - transformer -> - ContainerUtils.traverseAlongSwitchChain(transformer.getNodeA(), rawGrid) - .stream()) - .collect(Collectors.toSet())); - gridNodes.removeAll( - rawGrid.getTransformer3Ws().stream() - .flatMap( - transformer -> { - if (transformer.getNodeA().getSubnet() == subnet) - return Stream.of(transformer.getNodeB(), transformer.getNodeC()); - else if (transformer.getNodeB().getSubnet() == subnet) - return Stream.concat( - ContainerUtils.traverseAlongSwitchChain(transformer.getNodeA(), rawGrid) - .stream(), - Stream.of(transformer.getNodeC(), transformer.getNodeInternal())); - else - return Stream.concat( - ContainerUtils.traverseAlongSwitchChain(transformer.getNodeA(), rawGrid) - .stream(), - Stream.of(transformer.getNodeB(), transformer.getNodeInternal())); - }) - .collect(Collectors.toSet())); - /* Build a mapping, which voltage level appears how often */ Map voltageLevelCount = - gridNodes.stream() - .map(NodeInput::getVoltLvl) - .collect(Collectors.groupingBy(voltLvl -> voltLvl, Collectors.counting())); + rawGrid.getNodes().stream() + .filter(n -> n.getSubnet() == subnet) + .collect(Collectors.groupingBy(NodeInput::getVoltLvl, Collectors.counting())); /* At this point only one voltage level should be apparent */ int amountOfVoltLvl = voltageLevelCount.size(); @@ -677,14 +647,8 @@ private static TransformerSubGridContainers getSubGridContainers( RawGridElements rawGridElements, Map subGrids) throws TopologyException { - /* Get the sub grid container at port A - travel upstream as long as nodes are connected - * _only_ by switches */ - NodeInput topNode = traverseAlongSwitchChain(transformer.getNodeA(), rawGridElements).getLast(); - if (Objects.isNull(topNode)) - throw new TopologyException( - "Cannot find most upstream node of transformer '" + transformer + "'"); - - SubGridContainer containerA = subGrids.get(topNode.getSubnet()); + /* Get the sub grid container at port A */ + SubGridContainer containerA = subGrids.get(transformer.getNodeA().getSubnet()); /* Get the sub grid container at port B */ SubGridContainer containerB = subGrids.get(transformer.getNodeB().getSubnet()); @@ -696,81 +660,6 @@ private static TransformerSubGridContainers getSubGridContainers( } else return new TransformerSubGridContainers(containerA, containerB); } - /** - * Traversing along a chain of switches and return the traveled nodes. The end thereby is defined - * by a node, that either is a dead end or is connected to any other type of connector (e.g. - * lines, transformers) and therefore leads to other parts of a "real" grid. If the starting node - * is not part of any switch, the starting node is returned. - * - * @param startNode Node that is meant to be the start of the switch chain - * @param rawGridElements Elements of the pure grid structure. - * @return The end node of the switch chain - */ - public static LinkedList traverseAlongSwitchChain( - NodeInput startNode, RawGridElements rawGridElements) { - Set possibleJunctions = - Stream.concat( - Stream.concat( - rawGridElements.getLines().parallelStream(), - rawGridElements.getTransformer2Ws().parallelStream()), - rawGridElements.getTransformer3Ws().parallelStream()) - .flatMap(connector -> connector.allNodes().parallelStream()) - .collect(Collectors.toSet()); - return traverseAlongSwitchChain(startNode, rawGridElements.getSwitches(), possibleJunctions); - } - - /** - * Traversing along a chain of switches and return the traveled nodes. The end thereby is defined - * by a node, that either is a dead end or part of the provided node set. If the starting node is - * not part of any switch, the starting node is returned. - * - * @param startNode Node that is meant to be the start of the switch chain - * @param switches Set of available switches - * @param possibleJunctions Set of nodes that denote possible junctions to "real" grid - * @return The end node of the switch chain - */ - private static LinkedList traverseAlongSwitchChain( - NodeInput startNode, Set switches, Set possibleJunctions) { - LinkedList traveledNodes = new LinkedList<>(); - traveledNodes.addFirst(startNode); - - /* Get the switch, that is connected to the starting node and determine the next node */ - List nextSwitches = - switches.stream().filter(switcher -> switcher.allNodes().contains(startNode)).toList(); - switch (nextSwitches.size()) { - case 0: - /* No further switch found -> Return the starting node */ - break; - case 1: - /* One next switch has been found -> Travel in this direction */ - SwitchInput nextSwitch = nextSwitches.get(0); - Optional candidateNodes = - nextSwitch.allNodes().stream().filter(node -> node != startNode).findFirst(); - NodeInput nextNode = - candidateNodes.orElseThrow( - () -> - new IllegalArgumentException( - "There is no further node available at switch " + nextSwitch)); - if (possibleJunctions.contains(nextNode)) { - /* This is a junction, leading to another Connector than a switch */ - traveledNodes.addLast(nextNode); - } else { - /* Add the traveled nodes to the nodes to be excluded, to avoid endless loops in cyclic switch topologies */ - HashSet newNodesToExclude = new HashSet<>(possibleJunctions); - newNodesToExclude.add(nextNode); - HashSet newSwitches = new HashSet<>(switches); - newSwitches.remove(nextSwitch); - traveledNodes.addAll(traverseAlongSwitchChain(nextNode, newSwitches, newNodesToExclude)); - } - break; - default: - throw new IllegalArgumentException( - "Cannot traverse along switch chain, as there is a junction included at node " - + startNode); - } - return traveledNodes; - } - /** * Combines a given collection of sub grid containers to a joint model. If the single models do * not fit together, exceptions are thrown. diff --git a/src/main/java/edu/ie3/datamodel/utils/validation/GridContainerValidationUtils.java b/src/main/java/edu/ie3/datamodel/utils/validation/GridContainerValidationUtils.java index 471c83567..0c4ecac7a 100644 --- a/src/main/java/edu/ie3/datamodel/utils/validation/GridContainerValidationUtils.java +++ b/src/main/java/edu/ie3/datamodel/utils/validation/GridContainerValidationUtils.java @@ -20,7 +20,6 @@ import edu.ie3.datamodel.models.input.container.*; import edu.ie3.datamodel.models.input.graphics.GraphicInput; import edu.ie3.datamodel.models.input.system.SystemParticipantInput; -import edu.ie3.datamodel.utils.ContainerUtils; import edu.ie3.datamodel.utils.Try; import edu.ie3.datamodel.utils.Try.Failure; import edu.ie3.datamodel.utils.Try.Success; @@ -28,7 +27,6 @@ import java.util.*; import java.util.function.Predicate; import java.util.stream.Collectors; -import java.util.stream.Stream; import org.jgrapht.Graph; import org.jgrapht.alg.connectivity.ConnectivityInspector; import org.jgrapht.graph.DefaultEdge; @@ -140,26 +138,12 @@ private GridContainerValidationUtils() { exceptions.addAll(ConnectorValidationUtils.check(transformer)); }); - /* Checking switches - * Because of the fact, that a transformer with switch gear in "upstream" direction has its corresponding node in - * upper grid connected to a switch, instead of to the transformer directly: Collect all nodes at the end of the - * upstream switch chain and add them to the set of allowed nodes */ - HashSet validSwitchNodes = new HashSet<>(nodes); - validSwitchNodes.addAll( - Stream.of(rawGridElements.getTransformer2Ws(), rawGridElements.getTransformer2Ws()) - .flatMap(Set::stream) - .parallel() - .map( - transformer -> - ContainerUtils.traverseAlongSwitchChain(transformer.getNodeA(), rawGridElements) - .getLast()) - .toList()); - + /* Checking switches */ rawGridElements .getSwitches() .forEach( switcher -> { - exceptions.add(checkNodeAvailability(switcher, validSwitchNodes)); + exceptions.add(checkNodeAvailability(switcher, nodes)); exceptions.addAll(ConnectorValidationUtils.check(switcher)); }); diff --git a/src/main/java/edu/ie3/datamodel/utils/validation/ValidationUtils.java b/src/main/java/edu/ie3/datamodel/utils/validation/ValidationUtils.java index 6d664aba1..80006953b 100644 --- a/src/main/java/edu/ie3/datamodel/utils/validation/ValidationUtils.java +++ b/src/main/java/edu/ie3/datamodel/utils/validation/ValidationUtils.java @@ -5,12 +5,12 @@ */ package edu.ie3.datamodel.utils.validation; -import edu.ie3.datamodel.exceptions.FailedValidationException; -import edu.ie3.datamodel.exceptions.InvalidEntityException; -import edu.ie3.datamodel.exceptions.UnsafeEntityException; -import edu.ie3.datamodel.exceptions.ValidationException; +import edu.ie3.datamodel.exceptions.*; import edu.ie3.datamodel.models.UniqueEntity; -import edu.ie3.datamodel.models.input.*; +import edu.ie3.datamodel.models.input.AssetInput; +import edu.ie3.datamodel.models.input.AssetTypeInput; +import edu.ie3.datamodel.models.input.MeasurementUnitInput; +import edu.ie3.datamodel.models.input.NodeInput; import edu.ie3.datamodel.models.input.connector.ConnectorInput; import edu.ie3.datamodel.models.input.connector.type.LineTypeInput; import edu.ie3.datamodel.models.input.connector.type.Transformer2WTypeInput; @@ -22,11 +22,8 @@ import edu.ie3.datamodel.models.input.system.type.SystemParticipantTypeInput; import edu.ie3.datamodel.models.input.thermal.ThermalUnitInput; import edu.ie3.datamodel.utils.Try; -import edu.ie3.datamodel.utils.Try.Failure; -import edu.ie3.datamodel.utils.Try.Success; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; +import edu.ie3.datamodel.utils.Try.*; +import java.util.*; import java.util.function.Predicate; import java.util.stream.Collectors; import javax.measure.Quantity; @@ -160,8 +157,6 @@ else if (ThermalUnitInput.class.isAssignableFrom(assetInput.getClass())) exceptions.addAll(ThermalValidationUtils.check((ThermalUnitInput) assetInput)); else if (ThermalGrid.class.isAssignableFrom(assetInput.getClass())) exceptions.addAll(ThermalValidationUtils.check((ThermalUnitInput) assetInput)); - else if (EmInput.class.isAssignableFrom(assetInput.getClass())) - exceptions.addAll(EnergyManagementValidationUtils.check((EmInput) assetInput)); else { logNotImplemented(assetInput); } diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy index 5afb30729..e85aebf3b 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy @@ -7,31 +7,26 @@ package edu.ie3.datamodel.io.factory.timeseries import edu.ie3.datamodel.models.StandardUnits import edu.ie3.datamodel.models.timeseries.individual.TimeBasedValue -import edu.ie3.datamodel.models.value.TemperatureValue import edu.ie3.datamodel.models.value.WeatherValue import edu.ie3.test.common.CosmoWeatherTestData import edu.ie3.util.TimeUtil import spock.lang.Specification import tech.units.indriya.quantity.Quantities -import tech.units.indriya.unit.Units - -import java.util.Optional class CosmoTimeBasedWeatherValueFactoryTest extends Specification { - def "A CosmoTimeBasedWeatherValueFactory creates values correctly when optional ground temperatures are missing"() { + def "A PsdmTimeBasedWeatherValueFactory should be able to create time series with missing values"() { given: - def factory = new CosmoTimeBasedWeatherValueFactory(TimeUtil.withDefaults) + def factory = new CosmoTimeBasedWeatherValueFactory() def coordinate = CosmoWeatherTestData.COORDINATE_193186 def time = TimeUtil.withDefaults.toZonedDateTime("2019-01-01T00:00:00Z") Map parameter = [ - "time" : TimeUtil.withDefaults.toString(time), "uuid" : "980f7714-8def-479f-baae-4deed6c8d6d1", - "coordinateId" : "193186", + "time" : TimeUtil.withDefaults.toString(time), "diffuseIrradiance": "282.671997070312", "directIrradiance" : "286.872985839844", - "temperature" : "278.019012451172", + "temperature" : "", "windDirection" : "0", "windVelocity" : "1.66103506088257" ] @@ -42,10 +37,9 @@ class CosmoTimeBasedWeatherValueFactoryTest extends Specification { time, new WeatherValue(coordinate, Quantities.getQuantity(286.872985839844d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(282.671997070312d, StandardUnits.SOLAR_IRRADIANCE), - Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE), + null, Quantities.getQuantity(0d, StandardUnits.WIND_DIRECTION), - Quantities.getQuantity(1.66103506088257d, StandardUnits.WIND_VELOCITY), - Collections.emptyMap())) + Quantities.getQuantity(1.66103506088257d, StandardUnits.WIND_VELOCITY))) when: def model = factory.buildModel(data) @@ -54,40 +48,31 @@ class CosmoTimeBasedWeatherValueFactoryTest extends Specification { model == expectedResults } - def "A CosmoTimeBasedWeatherValueFactory creates values correctly when ground temperatures are present"() { + def "A PsdmTimeBasedWeatherValueFactory should be able to create time series values"() { given: - def factory = new CosmoTimeBasedWeatherValueFactory(TimeUtil.withDefaults) + def factory = new CosmoTimeBasedWeatherValueFactory() def coordinate = CosmoWeatherTestData.COORDINATE_193186 def time = TimeUtil.withDefaults.toZonedDateTime("2019-01-01T00:00:00Z") Map parameter = [ - "time" : TimeUtil.withDefaults.toString(time), - "uuid" : "980f7714-8def-479f-baae-4deed6c8d6d1", - "coordinateId" : "193186", - "diffuseIrradiance" : "282.671997070312", - "directIrradiance" : "286.872985839844", - "temperature" : "278.019012451172", - "windDirection" : "0", - "windVelocity" : "1.66103506088257", - "groundTemperatureSurface": "275.5", - "groundTemperature1m" : "279.0" + "time" : TimeUtil.withDefaults.toString(time), + "uuid" : "980f7714-8def-479f-baae-4deed6c8d6d1", + "diffuseIrradiance": "282.671997070312", + "directIrradiance" : "286.872985839844", + "temperature" : "278.019012451172", + "windDirection" : "0", + "windVelocity" : "1.66103506088257" ] def data = new TimeBasedWeatherValueData(parameter, coordinate) - def expectedGroundTemps = [ - (Quantities.getQuantity(0, Units.METRE)): new TemperatureValue(Quantities.getQuantity(275.5d, StandardUnits.TEMPERATURE)), - (Quantities.getQuantity(1, Units.METRE)): new TemperatureValue(Quantities.getQuantity(279.0d, StandardUnits.TEMPERATURE)) - ] - def expectedResults = new TimeBasedValue( time, new WeatherValue(coordinate, Quantities.getQuantity(286.872985839844d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(282.671997070312d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE), Quantities.getQuantity(0d, StandardUnits.WIND_DIRECTION), - Quantities.getQuantity(1.66103506088257d, StandardUnits.WIND_VELOCITY), - expectedGroundTemps)) + Quantities.getQuantity(1.66103506088257d, StandardUnits.WIND_VELOCITY))) when: def model = factory.buildModel(data) @@ -95,4 +80,4 @@ class CosmoTimeBasedWeatherValueFactoryTest extends Specification { then: model == expectedResults } -} \ No newline at end of file +} diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactoryTest.groovy index 0347d434a..cac18982c 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactoryTest.groovy @@ -6,8 +6,6 @@ package edu.ie3.datamodel.io.factory.timeseries import edu.ie3.datamodel.models.StandardUnits -import edu.ie3.datamodel.models.value.TemperatureValue -import edu.ie3.datamodel.models.value.WeatherValue import edu.ie3.test.common.CosmoWeatherTestData import edu.ie3.util.TimeUtil import edu.ie3.util.quantities.PowerSystemUnits @@ -17,8 +15,6 @@ import spock.lang.Specification import tech.units.indriya.quantity.Quantities import tech.units.indriya.unit.Units -import java.util.Optional - class IconTimeBasedWeatherValueFactoryTest extends Specification { def "A time based weather value factory for ICON column scheme determines wind velocity angle correctly"() { given: @@ -89,65 +85,6 @@ class IconTimeBasedWeatherValueFactoryTest extends Specification { "t2m" : "289.1179319051744", "tg" : "288.4101691197649", "u10m" : "0.3021732864307963", - "tG" : "288.4101691197649", - "u131m" : "2.6058700426057797", - "u20m" : "0.32384365019387784", - "u216m" : "3.9015497418041756", - "u65m" : "1.2823686334340363", - "v10m" : "1.3852550649486943", - "v131m" : "3.8391590569599927", - "v20m" : "1.3726831152710628", - "v216m" : "4.339362039492466", - "v65m" : "2.809877942347672", - "w131m" : "-0.02633474740256081", - "w20m" : "-0.0100060345167524", - "w216m" : "-0.030348050471342078", - "w65m" : "-0.01817112027569893", - "z0" : "0.955323922526438", - "coordinateId": "67775", - "p131m" : "", - "p20m" : "", - "p65m" : "", - "sobsRad" : "", - "t131m" : "" - ] - def data = new TimeBasedWeatherValueData(parameter, coordinate) - - when: - def actual = factory.buildModel(data) - - then: - actual.with { - it.time == TimeUtil.withDefaults.toZonedDateTime("2019-08-01T01:00:00Z") - it.value.coordinate == coordinate - it.value.directSolar == Quantities.getQuantity(2.317613203124999, StandardUnits.SOLAR_IRRADIANCE) - it.value.diffSolar == Quantities.getQuantity(1.8088226191406245, StandardUnits.SOLAR_IRRADIANCE) - QuantityUtil.isEquivalentAbs(it.value.temperature, Quantities.getQuantity(289.1179319051744d, Units.KELVIN).to(StandardUnits.TEMPERATURE), 1e-6) - QuantityUtil.isEquivalentAbs(it.value.windDir, Quantities.getQuantity(214.16711674907722, StandardUnits.WIND_DIRECTION), 1e-6) - QuantityUtil.isEquivalentAbs(it.value.windVel, Quantities.getQuantity(4.640010877529081, StandardUnits.WIND_VELOCITY), 1e-6) - - it.value.groundTemperatures.size() == 1 - def expectedGroundTemp = new TemperatureValue(Quantities.getQuantity(288.4101691197649d, Units.KELVIN).to(StandardUnits.TEMPERATURE)) - it.value.groundTemperatures[Quantities.getQuantity(0, Units.METRE)] == expectedGroundTemp - } - } - - def "A time based weather value factory for ICON column scheme builds a value with all ground temperatures"() { - given: - def factory = new IconTimeBasedWeatherValueFactory() - def coordinate = CosmoWeatherTestData.COORDINATE_67775 - - def parameter = [ - "time" : "2019-08-01T01:00:00Z", - "albRad" : "13.015240669", - "asobS" : "3.555093673828124", - "aswdifdS" : "1.8088226191406245", - "aswdifuS" : "0.5713421484374998", - "aswdirS" : "2.317613203124999", - "t2m" : "289.1179319051744", - "tg" : "288.4101691197649", - "u10m" : "0.3021732864307963", - "tG" : "288.4101691197649", "u131m" : "2.6058700426057797", "u20m" : "0.32384365019387784", "u216m" : "3.9015497418041756", @@ -176,12 +113,18 @@ class IconTimeBasedWeatherValueFactoryTest extends Specification { then: actual.with { - it.value.groundTemperatures.size() == 2 - def expectedSurfaceTemp = new TemperatureValue(Quantities.getQuantity(288.41d, Units.KELVIN).to(StandardUnits.TEMPERATURE)) - def expected1mTemp = new TemperatureValue(Quantities.getQuantity(286.5d, Units.KELVIN).to(StandardUnits.TEMPERATURE)) - - it.value.groundTemperatures[Quantities.getQuantity(0, Units.METRE)] == expectedSurfaceTemp - it.value.groundTemperatures[Quantities.getQuantity(1, Units.METRE)] == expected1mTemp + assert it.time == TimeUtil.withDefaults.toZonedDateTime("2019-08-01T01:00:00Z") + assert it.value.coordinate == coordinate + assert it.value.solarIrradiance.directIrradiance.present + assert it.value.solarIrradiance.directIrradiance.get() == Quantities.getQuantity(0.002317613203124999, PowerSystemUnits.KILOWATT_PER_SQUAREMETRE) + assert it.value.solarIrradiance.diffuseIrradiance.present + assert it.value.solarIrradiance.diffuseIrradiance.get() == Quantities.getQuantity(0.0018088226191406245, PowerSystemUnits.KILOWATT_PER_SQUAREMETRE) + assert it.value.temperature.temperature.present + assert QuantityUtil.isEquivalentAbs(it.value.temperature.temperature.get(), Quantities.getQuantity(15.9679319051744, Units.CELSIUS)) + assert it.value.wind.direction.present + assert QuantityUtil.isEquivalentAbs(it.value.wind.direction.get(), Quantities.getQuantity(214.16711674907722, PowerSystemUnits.DEGREE_GEOM)) + assert it.value.wind.velocity.present + assert QuantityUtil.isEquivalentAbs(it.value.wind.velocity.get(), Quantities.getQuantity(4.640010877529081, PowerSystemUnits.METRE_PER_SECOND)) } } -} \ No newline at end of file +} diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/couchbase/CouchbaseWeatherSourceCosmoIT.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/couchbase/CouchbaseWeatherSourceCosmoIT.groovy index c216ce0e0..a032cb5bc 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/couchbase/CouchbaseWeatherSourceCosmoIT.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/couchbase/CouchbaseWeatherSourceCosmoIT.groovy @@ -13,7 +13,6 @@ import edu.ie3.datamodel.models.value.WeatherValue import edu.ie3.test.common.CosmoWeatherTestData import edu.ie3.test.helper.TestContainerHelper import edu.ie3.test.helper.WeatherSourceTestHelper -import edu.ie3.util.TimeUtil import edu.ie3.util.interval.ClosedInterval import org.locationtech.jts.geom.Point import org.testcontainers.couchbase.BucketDefinition @@ -46,12 +45,14 @@ class CouchbaseWeatherSourceCosmoIT extends Specification implements TestContain // Copy import file with json array of documents into docker MountableFile couchbaseWeatherJsonsFile = getMountableFile("_weather/cosmo/weather.json") couchbaseContainer.copyFileToContainer(couchbaseWeatherJsonsFile, "/home/weather_cosmo.json") + // create an index for the document keys couchbaseContainer.execInContainer("cbq", "-e", "http://localhost:8093", "-u", couchbaseContainer.username, "-p", couchbaseContainer.password, "-s", "CREATE index id_idx ON `" + bucketDefinition.name + "` (META().id);") + //import the json documents from the copied file couchbaseContainer.execInContainer("cbimport", "json", "-cluster", "http://localhost:8091", @@ -61,6 +62,7 @@ class CouchbaseWeatherSourceCosmoIT extends Specification implements TestContain "--format", "list", "--generate-key", "weather::%" + coordinateIdColumnName + "%::%time%", "--dataset", "file:///home/weather_cosmo.json") + // increased timeout to deal with CI under high load def connector = new CouchbaseConnector( couchbaseContainer.connectionString, @@ -69,7 +71,7 @@ class CouchbaseWeatherSourceCosmoIT extends Specification implements TestContain couchbaseContainer.password, Duration.ofSeconds(20)) def dtfPattern = "yyyy-MM-dd'T'HH:mm:ssxxx" - def weatherFactory = new CosmoTimeBasedWeatherValueFactory(TimeUtil.withDefaults) + def weatherFactory = new CosmoTimeBasedWeatherValueFactory() source = new CouchbaseWeatherSource(connector, CosmoWeatherTestData.coordinateSource, coordinateIdColumnName, weatherFactory, dtfPattern) } @@ -162,4 +164,4 @@ class CouchbaseWeatherSourceCosmoIT extends Specification implements TestContain ] actual.get(CosmoWeatherTestData.COORDINATE_193187) == [CosmoWeatherTestData.TIME_16H] } -} \ No newline at end of file +} diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/couchbase/CouchbaseWeatherSourceIconIT.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/couchbase/CouchbaseWeatherSourceIconIT.groovy index 49e2d2934..bf3f272f0 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/couchbase/CouchbaseWeatherSourceIconIT.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/couchbase/CouchbaseWeatherSourceIconIT.groovy @@ -44,12 +44,14 @@ class CouchbaseWeatherSourceIconIT extends Specification implements TestContaine // Copy import file with json array of documents into docker def couchbaseWeatherJsonsFile = getMountableFile("_weather/icon/weather.json") couchbaseContainer.copyFileToContainer(couchbaseWeatherJsonsFile, "/home/weather_icon.json") + // create an index for the document keys couchbaseContainer.execInContainer("cbq", "-e", "http://localhost:8093", "-u", couchbaseContainer.username, "-p", couchbaseContainer.password, "-s", "CREATE index id_idx ON `" + bucketDefinition.name + "` (META().id);") + //import the json documents from the copied file couchbaseContainer.execInContainer("cbimport", "json", "-cluster", "http://localhost:8091", @@ -59,6 +61,7 @@ class CouchbaseWeatherSourceIconIT extends Specification implements TestContaine "--format", "list", "--generate-key", "weather::%" + coordinateIdColumnName + "%::%time%", "--dataset", "file:///home/weather_icon.json") + // increased timeout to deal with CI under high load def connector = new CouchbaseConnector( couchbaseContainer.connectionString, @@ -158,4 +161,4 @@ class CouchbaseWeatherSourceIconIT extends Specification implements TestContaine ] actual.get(IconWeatherTestData.COORDINATE_67776) == [IconWeatherTestData.TIME_16H] } -} \ No newline at end of file +} diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceCosmoTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceCosmoTest.groovy index e1ca89bba..cc5e709f2 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceCosmoTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceCosmoTest.groovy @@ -12,7 +12,10 @@ import edu.ie3.datamodel.io.naming.FileNamingStrategy import edu.ie3.datamodel.io.source.IdCoordinateSource import edu.ie3.datamodel.models.timeseries.individual.IndividualTimeSeries import edu.ie3.datamodel.models.timeseries.individual.TimeBasedValue +import edu.ie3.datamodel.models.value.SolarIrradianceValue +import edu.ie3.datamodel.models.value.TemperatureValue import edu.ie3.datamodel.models.value.WeatherValue +import edu.ie3.datamodel.models.value.WindValue import edu.ie3.test.common.CosmoWeatherTestData import edu.ie3.test.helper.WeatherSourceTestHelper import edu.ie3.util.TimeUtil @@ -24,8 +27,6 @@ import spock.lang.Shared import spock.lang.Specification import tech.units.indriya.quantity.Quantities -import java.util.Collections - class CsvWeatherSourceCosmoTest extends Specification implements CsvTestDataMeta, WeatherSourceTestHelper { @Shared @@ -36,7 +37,7 @@ class CsvWeatherSourceCosmoTest extends Specification implements CsvTestDataMeta def setupSpec() { coordinateSource = CosmoWeatherTestData.coordinateSource - def weatherFactory = new CosmoTimeBasedWeatherValueFactory(TimeUtil.withDefaults) + def weatherFactory = new CosmoTimeBasedWeatherValueFactory() source = new CsvWeatherSource(";", weatherCosmoFolderPath, new FileNamingStrategy(), coordinateSource, weatherFactory) } @@ -114,7 +115,7 @@ class CsvWeatherSourceCosmoTest extends Specification implements CsvTestDataMeta def defaultCoordinate = GeoUtils.DEFAULT_GEOMETRY_FACTORY.createPoint(new Coordinate(7.4116482, 51.4843281)) def coordinateSource = Mock(IdCoordinateSource) coordinateSource.getCoordinate(_) >> { args -> args[0] == 5 ? Optional.of(defaultCoordinate) : Optional.empty() } - def weatherFactory = new CosmoTimeBasedWeatherValueFactory(TimeUtil.withDefaults) + def weatherFactory = new CosmoTimeBasedWeatherValueFactory() def source = new CsvWeatherSource(";", weatherCosmoFolderPath, new FileNamingStrategy(), coordinateSource, weatherFactory) def fieldToValues = [ "uuid" : "71a79f59-eebf-40c1-8358-ba7414077d57", @@ -130,12 +131,17 @@ class CsvWeatherSourceCosmoTest extends Specification implements CsvTestDataMeta TimeUtil.withDefaults.toZonedDateTime("2020-10-16T12:40:42Z"), new WeatherValue( defaultCoordinate, + new SolarIrradianceValue( Quantities.getQuantity(1.234, SOLAR_IRRADIANCE), - Quantities.getQuantity(5.678, SOLAR_IRRADIANCE), - Quantities.getQuantity(9.1011, TEMPERATURE), - Quantities.getQuantity(15.1617, WIND_DIRECTION), - Quantities.getQuantity(12.1314, WIND_VELOCITY), - Collections.emptyMap() + Quantities.getQuantity(5.678, SOLAR_IRRADIANCE) + ), + new TemperatureValue( + Quantities.getQuantity(9.1011, TEMPERATURE) + ), + new WindValue( + Quantities.getQuantity(12.1314, WIND_DIRECTION), + Quantities.getQuantity(15.1617, WIND_VELOCITY) + ) ) ) @@ -152,7 +158,7 @@ class CsvWeatherSourceCosmoTest extends Specification implements CsvTestDataMeta def defaultCoordinate = GeoUtils.DEFAULT_GEOMETRY_FACTORY.createPoint(new Coordinate(7.4116482, 51.4843281)) def coordinateSource = Mock(IdCoordinateSource) coordinateSource.getCoordinate(_) >> { args -> args[0] == 5 ? Optional.of(defaultCoordinate) : Optional.empty() } - def weatherFactory = new CosmoTimeBasedWeatherValueFactory(TimeUtil.withDefaults) + def weatherFactory = new CosmoTimeBasedWeatherValueFactory() def source = new CsvWeatherSource(";", weatherCosmoFolderPath, new FileNamingStrategy(), coordinateSource, weatherFactory) def fieldToValues = [ "uuid" : "71a79f59-eebf-40c1-8358-ba7414077d57", @@ -177,7 +183,7 @@ class CsvWeatherSourceCosmoTest extends Specification implements CsvTestDataMeta def defaultCoordinate = GeoUtils.DEFAULT_GEOMETRY_FACTORY.createPoint(new Coordinate(7.4116482, 51.4843281)) def coordinateSource = Mock(IdCoordinateSource) coordinateSource.getCoordinate(_) >> { args -> args[0] == 5 ? Optional.of(defaultCoordinate) : Optional.empty() } - def weatherFactory = new CosmoTimeBasedWeatherValueFactory(TimeUtil.withDefaults) + def weatherFactory = new CosmoTimeBasedWeatherValueFactory() def source = new CsvWeatherSource(";", weatherCosmoFolderPath, new FileNamingStrategy(), coordinateSource, weatherFactory) def fieldToValues = [ "uuid" : "71a79f59-eebf-40c1-8358-ba7414077d57", @@ -200,7 +206,7 @@ class CsvWeatherSourceCosmoTest extends Specification implements CsvTestDataMeta given: def coordinateSource = Mock(IdCoordinateSource) coordinateSource.getCoordinate(_) >> Optional.empty() - def weatherFactory = new CosmoTimeBasedWeatherValueFactory(TimeUtil.withDefaults) + def weatherFactory = new CosmoTimeBasedWeatherValueFactory() def source = new CsvWeatherSource(";", weatherCosmoFolderPath, new FileNamingStrategy(), coordinateSource, weatherFactory) def fieldToValues = [ "uuid" : "71a79f59-eebf-40c1-8358-ba7414077d57", @@ -237,4 +243,4 @@ class CsvWeatherSourceCosmoTest extends Specification implements CsvTestDataMeta actual.get(CosmoWeatherTestData.COORDINATE_193187) == [CosmoWeatherTestData.TIME_16H] actual.get(CosmoWeatherTestData.COORDINATE_193188) == [] } -} \ No newline at end of file +} diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceIconTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceIconTest.groovy index 1aaa26b78..7d90727b2 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceIconTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceIconTest.groovy @@ -153,7 +153,8 @@ class CsvWeatherSourceIconTest extends Specification implements CsvTestDataMeta, def coordinateSource = new WeatherTestData.DummyIdCoordinateSource() def weatherFactory = new IconTimeBasedWeatherValueFactory() def source = new CsvWeatherSource(",", weatherIconFolderPath, new FileNamingStrategy(), coordinateSource, weatherFactory) - def fieldToValues = [ "datum" : "2019-08-01 01:00:00", + def fieldToValues = [ + "datum" : "2019-08-01 01:00:00", "albRad" : "13.015240669", "asobS" : "3.555093673828124", "aswdifdS" : "1.8088226191406245", @@ -181,7 +182,8 @@ class CsvWeatherSourceIconTest extends Specification implements CsvTestDataMeta, "p20m" : "", "p65m" : "", "sobsRad" : "", - "t131m" : ""] + "t131m" : "" + ] when: def actual = source.buildWeatherValue(fieldToValues) @@ -195,7 +197,8 @@ class CsvWeatherSourceIconTest extends Specification implements CsvTestDataMeta, def coordinateSource = new WeatherTestData.DummyIdCoordinateSource() def weatherFactory = new IconTimeBasedWeatherValueFactory() def source = new CsvWeatherSource(",", weatherIconFolderPath, new FileNamingStrategy(), coordinateSource, weatherFactory) - def fieldToValues = [ "datum" : "2019-08-01 01:00:00", + def fieldToValues = [ + "datum" : "2019-08-01 01:00:00", "albRad" : "13.015240669", "asobS" : "3.555093673828124", "aswdifdS": "1.8088226191406245", @@ -222,7 +225,8 @@ class CsvWeatherSourceIconTest extends Specification implements CsvTestDataMeta, "p20m" : "", "p65m" : "", "sobsRad" : "", - "t131m" : ""] + "t131m" : "" + ] when: def actual = source.buildWeatherValue(fieldToValues) @@ -233,12 +237,12 @@ class CsvWeatherSourceIconTest extends Specification implements CsvTestDataMeta, def "The CsvWeatherSource returns no WeatherValue, if the coordinate cannot be obtained"() { given: - def coordinateSource = Mock(IdCoordinateSource) - coordinateSource.getCoordinate(_) >> Optional.empty() + def coordinateSource = new WeatherTestData.DummyIdCoordinateSource() def weatherFactory = new IconTimeBasedWeatherValueFactory() def source = new CsvWeatherSource(",", weatherIconFolderPath, new FileNamingStrategy(), coordinateSource, weatherFactory) - def fieldToValues = [ "datum" : "2019-08-01 01:00:00", - "albRad" : "13.015240669", + def fieldToValues = [ + "datum" : "2019-08-01 01:00:00", + "albrad" : "13.015240669", "asobS" : "3.555093673828124", "aswdifdS" : "1.8088226191406245", "aswdifuS" : "0.5713421484374998", @@ -265,7 +269,8 @@ class CsvWeatherSourceIconTest extends Specification implements CsvTestDataMeta, "p20m" : "", "p65m" : "", "sobsRad" : "", - "t131m" : ""] + "t131m" : "" + ] when: def actual = source.buildWeatherValue(fieldToValues) @@ -290,4 +295,4 @@ class CsvWeatherSourceIconTest extends Specification implements CsvTestDataMeta, ] actual.get(IconWeatherTestData.COORDINATE_67776) == [IconWeatherTestData.TIME_16H] } -} \ No newline at end of file +} diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/influxdb/InfluxDbWeatherSourceCosmoIT.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/influxdb/InfluxDbWeatherSourceCosmoIT.groovy index 2994d6c00..d2b212a2a 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/influxdb/InfluxDbWeatherSourceCosmoIT.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/influxdb/InfluxDbWeatherSourceCosmoIT.groovy @@ -13,7 +13,6 @@ import edu.ie3.datamodel.models.value.WeatherValue import edu.ie3.test.common.CosmoWeatherTestData import edu.ie3.test.helper.TestContainerHelper import edu.ie3.test.helper.WeatherSourceTestHelper -import edu.ie3.util.TimeUtil import edu.ie3.util.geo.GeoUtils import edu.ie3.util.interval.ClosedInterval import org.locationtech.jts.geom.Point @@ -25,8 +24,6 @@ import org.testcontainers.utility.MountableFile import spock.lang.Shared import spock.lang.Specification -import java.time.Duration - @Testcontainers class InfluxDbWeatherSourceCosmoIT extends Specification implements TestContainerHelper, WeatherSourceTestHelper { @@ -48,7 +45,7 @@ class InfluxDbWeatherSourceCosmoIT extends Specification implements TestContaine assert res.stderr.empty def connector = new InfluxDbConnector(influxDbContainer.url, "test_weather", "test_scenario") - def weatherFactory = new CosmoTimeBasedWeatherValueFactory(TimeUtil.withDefaults) + def weatherFactory = new CosmoTimeBasedWeatherValueFactory() source = new InfluxDbWeatherSource(connector, CosmoWeatherTestData.coordinateSource, weatherFactory) } @@ -173,4 +170,4 @@ class InfluxDbWeatherSourceCosmoIT extends Specification implements TestContaine ] actual.get(CosmoWeatherTestData.COORDINATE_193187) == [CosmoWeatherTestData.TIME_16H] } -} \ No newline at end of file +} diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/influxdb/InfluxDbWeatherSourceIconIT.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/influxdb/InfluxDbWeatherSourceIconIT.groovy index 789e8c100..ce3a6dfcb 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/influxdb/InfluxDbWeatherSourceIconIT.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/influxdb/InfluxDbWeatherSourceIconIT.groovy @@ -22,12 +22,8 @@ import org.testcontainers.utility.MountableFile import spock.lang.Shared import spock.lang.Specification -import java.util.Collections -import java.util.Optional -import java.util.UUID - @Testcontainers -class InfluxDbWeatherSourceIconIT extends Specification implements TestContainerHelper, WeatherSourceTestHelper { +class InfluxDbWeatherSourceIconIT extends Specification implements WeatherSourceTestHelper, TestContainerHelper { @Shared InfluxDBContainer influxDbContainer = new InfluxDBContainer(DockerImageName.parse("influxdb").withTag("1.8.10")) @@ -167,4 +163,4 @@ class InfluxDbWeatherSourceIconIT extends Specification implements TestContainer ] actual.get(IconWeatherTestData.COORDINATE_67776) == [IconWeatherTestData.TIME_16H] } -} \ No newline at end of file +} diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/sql/SqlWeatherSourceCosmoIT.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/sql/SqlWeatherSourceCosmoIT.groovy index 212c8d90b..1a7e0a0d3 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/sql/SqlWeatherSourceCosmoIT.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/sql/SqlWeatherSourceCosmoIT.groovy @@ -13,7 +13,6 @@ import edu.ie3.datamodel.models.value.WeatherValue import edu.ie3.test.common.CosmoWeatherTestData import edu.ie3.test.helper.TestContainerHelper import edu.ie3.test.helper.WeatherSourceTestHelper -import edu.ie3.util.TimeUtil import edu.ie3.util.geo.GeoUtils import edu.ie3.util.interval.ClosedInterval import org.locationtech.jts.geom.Point @@ -45,7 +44,7 @@ class SqlWeatherSourceCosmoIT extends Specification implements TestContainerHelp assert res.stderr.empty def connector = new SqlConnector(postgreSQLContainer.jdbcUrl, postgreSQLContainer.username, postgreSQLContainer.password) - def weatherFactory = new CosmoTimeBasedWeatherValueFactory(TimeUtil.withDefaults) + def weatherFactory = new CosmoTimeBasedWeatherValueFactory() source = new SqlWeatherSource(connector, CosmoWeatherTestData.coordinateSource, schemaName, weatherTableName, weatherFactory) } @@ -156,4 +155,4 @@ class SqlWeatherSourceCosmoIT extends Specification implements TestContainerHelp ] actual.get(CosmoWeatherTestData.COORDINATE_193187) == [CosmoWeatherTestData.TIME_16H] } -} \ No newline at end of file +} diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/sql/SqlWeatherSourceIconIT.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/sql/SqlWeatherSourceIconIT.groovy index 7b98c18a7..65cdb72d9 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/sql/SqlWeatherSourceIconIT.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/sql/SqlWeatherSourceIconIT.groovy @@ -125,4 +125,4 @@ class SqlWeatherSourceIconIT extends Specification implements TestContainerHelpe ] actual.get(IconWeatherTestData.COORDINATE_67776) == [IconWeatherTestData.TIME_16H] } -} \ No newline at end of file +} diff --git a/src/test/groovy/edu/ie3/datamodel/utils/ContainerUtilsTest.groovy b/src/test/groovy/edu/ie3/datamodel/utils/ContainerUtilsTest.groovy index c07ff0d54..660603fe9 100644 --- a/src/test/groovy/edu/ie3/datamodel/utils/ContainerUtilsTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/utils/ContainerUtilsTest.groovy @@ -553,176 +553,7 @@ class ContainerUtilsTest extends Specification { * - filtering of system participants can be tested * - filtering of graphic elements can be tested */ - def "Traversing along a simple switch chain returns the correct list of traveled nodes"() { - given: - def nodeA = Mock(NodeInput) - def nodeB = Mock(NodeInput) - def nodeC = Mock(NodeInput) - def nodeD = Mock(NodeInput) - - def switchAB = Mock(SwitchInput) - switchAB.getNodeA() >> nodeA - switchAB.getNodeB() >> nodeB - switchAB.allNodes() >> List.of(nodeA, nodeB) - def switchBC = Mock(SwitchInput) - switchBC.getNodeA() >> nodeB - switchBC.getNodeB() >> nodeC - switchBC.allNodes() >> List.of(nodeB, nodeC) - def switchCD = Mock(SwitchInput) - switchCD.getNodeA() >> nodeC - switchCD.getNodeB() >> nodeD - switchCD.allNodes() >> List.of(nodeC, nodeD) - - def switches = new HashSet() - switches.add(switchAB) - switches.add(switchBC) - switches.add(switchCD) - - def possibleJunctions = new HashSet() - - def expected = new LinkedList() - expected.addFirst(nodeA) - expected.addLast(nodeB) - expected.addLast(nodeC) - expected.addLast(nodeD) - - when: - def actual = ContainerUtils.traverseAlongSwitchChain(nodeA, switches, possibleJunctions) - - then: - actual == expected - } - - def "Traversing along a switch chain with intermediate junction returns the correct list of traveled nodes"() { - given: - def nodeA = Mock(NodeInput) - def nodeB = Mock(NodeInput) - def nodeC = Mock(NodeInput) - def nodeD = Mock(NodeInput) - - def switchAB = Mock(SwitchInput) - switchAB.getNodeA() >> nodeA - switchAB.getNodeB() >> nodeB - switchAB.allNodes() >> List.of(nodeA, nodeB) - def switchBC = Mock(SwitchInput) - switchBC.getNodeA() >> nodeB - switchBC.getNodeB() >> nodeC - switchBC.allNodes() >> List.of(nodeB, nodeC) - def switchCD = Mock(SwitchInput) - switchCD.getNodeA() >> nodeC - switchCD.getNodeB() >> nodeD - switchCD.allNodes() >> List.of(nodeC, nodeD) - - def switches = new HashSet() - switches.add(switchAB) - switches.add(switchBC) - switches.add(switchCD) - - def possibleJunctions = new HashSet() - possibleJunctions.add(nodeC) - - def expected = new LinkedList() - expected.addFirst(nodeA) - expected.addLast(nodeB) - expected.addLast(nodeC) - - when: - def actual = ContainerUtils.traverseAlongSwitchChain(nodeA, switches, possibleJunctions) - - then: - actual == expected - } - - def "Traversing along a non existing switch chain returns the correct list of traveled nodes"() { - given: - def nodeA = Mock(NodeInput) - - def switches = new HashSet() - - def possibleJunctions = new HashSet() - - def expected = new LinkedList() - expected.addFirst(nodeA) - - when: - def actual = ContainerUtils.traverseAlongSwitchChain(nodeA, switches, possibleJunctions) - - then: - actual == expected - } - - def "Traversing along a cyclic switch chain throws an exception"() { - given: - def nodeA = Mock(NodeInput) - def nodeB = Mock(NodeInput) - def nodeC = Mock(NodeInput) - - def switchAB = Mock(SwitchInput) - switchAB.getNodeA() >> nodeA - switchAB.getNodeB() >> nodeB - switchAB.allNodes() >> List.of(nodeA, nodeB) - def switchBC = Mock(SwitchInput) - switchBC.getNodeA() >> nodeB - switchBC.getNodeB() >> nodeC - switchBC.allNodes() >> List.of(nodeB, nodeC) - def switchCA = Mock(SwitchInput) - switchCA.getNodeA() >> nodeC - switchCA.getNodeB() >> nodeA - switchCA.allNodes() >> List.of(nodeC, nodeA) - - def switches = new HashSet() - switches.add(switchAB) - switches.add(switchBC) - switches.add(switchCA) - - def possibleJunctions = new HashSet() - - when: - ContainerUtils.traverseAlongSwitchChain(nodeA, switches, possibleJunctions) - - then: - IllegalArgumentException ex = thrown() - ex.message == "Cannot traverse along switch chain, as there is a junction included at node Mock for type " + - "'NodeInput' named 'nodeA'" - } - - def "Traversing along a switch chain with switch junction throws an exception"() { - given: - def nodeA = Mock(NodeInput) - def nodeB = Mock(NodeInput) - def nodeC = Mock(NodeInput) - def nodeD = Mock(NodeInput) - - def switchAB = Mock(SwitchInput) - switchAB.getNodeA() >> nodeA - switchAB.getNodeB() >> nodeB - switchAB.allNodes() >> List.of(nodeA, nodeB) - def switchBC = Mock(SwitchInput) - switchBC.getNodeA() >> nodeB - switchBC.getNodeB() >> nodeC - switchBC.allNodes() >> List.of(nodeB, nodeC) - def switchBD = Mock(SwitchInput) - switchBD.getNodeA() >> nodeB - switchBD.getNodeB() >> nodeD - switchBD.allNodes() >> List.of(nodeB, nodeD) - - def switches = new HashSet() - switches.add(switchAB) - switches.add(switchBC) - switches.add(switchBD) - - def possibleJunctions = new HashSet() - - when: - ContainerUtils.traverseAlongSwitchChain(nodeA, switches, possibleJunctions) - - then: - IllegalArgumentException ex = thrown() - ex.message == "Cannot traverse along switch chain, as there is a junction included at node Mock for type " + - "'NodeInput' named 'nodeB'" - } - - def "Determining the surrounding sub grid containers of a two winding transformer w/o switchgear works fine"() { + def "Determining the surrounding sub grid containers of a two winding transformer works fine"() { given: def nodeD = Mock(NodeInput) nodeD.getUuid() >> UUID.fromString("ae4869d5-3551-4cce-a101-d61629716c4f") @@ -754,66 +585,4 @@ class ContainerUtilsTest extends Specification { then: actual == expected } - - def "Determining the surrounding sub grid containers of a two winding transformer w/ switchgear works fine"() { - given: - def nodeA = Mock(NodeInput) - nodeA.getUuid() >> UUID.fromString("a37b2501-70c5-479f-92f9-d5b0e4628b2b") - nodeA.getSubnet() >> 1 - def nodeB = Mock(NodeInput) - nodeB.getUuid() >> UUID.fromString("8361b082-9d4c-4c54-97d0-2df9ac35333c") - nodeB.getSubnet() >> 2 - def nodeC = Mock(NodeInput) - nodeC.getUuid() >> UUID.fromString("b9e4f16b-0317-4794-9f53-339db45a2092") - nodeC.getSubnet() >> 2 - def nodeD = Mock(NodeInput) - nodeD.getUuid() >> UUID.fromString("ae4869d5-3551-4cce-a101-d61629716c4f") - nodeD.getSubnet() >> 2 - def nodeE = Mock(NodeInput) - nodeE.getUuid() >> UUID.fromString("5d4107b2-385b-40fe-a668-19414bf45d9d") - nodeE.getSubnet() >> 2 - - def transformer = Mock(Transformer2WInput) - transformer.getUuid() >> UUID.fromString("ddcdd72a-5f97-4bef-913b-d32d31216e27") - transformer.getNodeA() >> nodeD - transformer.getNodeB() >> nodeE - transformer.allNodes() >> List.of(nodeD, nodeE) - - def switchAB = Mock(SwitchInput) - switchAB.getUuid() >> UUID.fromString("5fcb8705-1436-4fbe-97b3-d2dcaf6a783b") - switchAB.allNodes() >> List.of(nodeA, nodeB) - def switchBC = Mock(SwitchInput) - switchBC.getUuid() >> UUID.fromString("4ca81b0b-e06d-408e-a991-de140f4e229b") - switchBC.allNodes() >> List.of(nodeB, nodeC) - def switchCD = Mock(SwitchInput) - switchCD.getUuid() >> UUID.fromString("92ce075e-9e3b-4ee6-89b6-19e6372fba01") - switchCD.allNodes() >> List.of(nodeC, nodeD) - - def rawGridElements = new RawGridElements([ - nodeA, - nodeB, - nodeC, - nodeD, - nodeE, - transformer, - switchAB, - switchBC, - switchCD - ]) - - def subGrid1 = Mock(SubGridContainer) - def subGrid2 = Mock(SubGridContainer) - def subGridMapping = [ - 1: subGrid1, - 2: subGrid2 - ] - - def expected = new ContainerUtils.TransformerSubGridContainers(subGrid1, subGrid2) - - when: - def actual = ContainerUtils.getSubGridContainers(transformer, rawGridElements, subGridMapping) - - then: - actual == expected - } } diff --git a/src/test/groovy/edu/ie3/datamodel/utils/validation/UniquenessValidationUtilsTest.groovy b/src/test/groovy/edu/ie3/datamodel/utils/validation/UniquenessValidationUtilsTest.groovy index e1f4f754e..92169b0bf 100644 --- a/src/test/groovy/edu/ie3/datamodel/utils/validation/UniquenessValidationUtilsTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/utils/validation/UniquenessValidationUtilsTest.groovy @@ -21,7 +21,10 @@ import edu.ie3.datamodel.models.result.CongestionResult import edu.ie3.datamodel.models.result.NodeResult import edu.ie3.datamodel.models.result.ResultEntity import edu.ie3.datamodel.models.timeseries.individual.TimeBasedValue +import edu.ie3.datamodel.models.value.SolarIrradianceValue +import edu.ie3.datamodel.models.value.TemperatureValue import edu.ie3.datamodel.models.value.WeatherValue +import edu.ie3.datamodel.models.value.WindValue import edu.ie3.datamodel.utils.Try import edu.ie3.util.geo.GeoUtils import spock.lang.Specification @@ -29,7 +32,6 @@ import tech.units.indriya.quantity.Quantities import tech.units.indriya.unit.Units import java.time.ZonedDateTime -import java.util.Collections import javax.measure.Quantity import javax.measure.quantity.Angle import javax.measure.quantity.Dimensionless @@ -206,12 +208,9 @@ class UniquenessValidationUtilsTest extends Specification { ZonedDateTime time = ZonedDateTime.now() WeatherValue value = new WeatherValue( GeoUtils.buildPoint(50d, 7d), - Quantities.getQuantity(10d, StandardUnits.SOLAR_IRRADIANCE), - Quantities.getQuantity(10d, StandardUnits.SOLAR_IRRADIANCE), - Quantities.getQuantity(5d, Units.CELSIUS), - Quantities.getQuantity(5d, DEGREE_GEOM), - Quantities.getQuantity(10d, METRE_PER_SECOND), - Collections.emptyMap() + new SolarIrradianceValue(Quantities.getQuantity(10d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(10d, StandardUnits.SOLAR_IRRADIANCE)), + new TemperatureValue(Quantities.getQuantity(5d, Units.CELSIUS)), + new WindValue(Quantities.getQuantity(5d, DEGREE_GEOM), Quantities.getQuantity(10d, METRE_PER_SECOND)) ) Set> uniqueValues = [ @@ -231,12 +230,9 @@ class UniquenessValidationUtilsTest extends Specification { ZonedDateTime time = ZonedDateTime.now() WeatherValue value = new WeatherValue( GeoUtils.buildPoint(50d, 7d), - Quantities.getQuantity(10d, StandardUnits.SOLAR_IRRADIANCE), - Quantities.getQuantity(10d, StandardUnits.SOLAR_IRRADIANCE), - Quantities.getQuantity(5d, Units.CELSIUS), - Quantities.getQuantity(5d, DEGREE_GEOM), - Quantities.getQuantity(10d, METRE_PER_SECOND), - Collections.emptyMap() + new SolarIrradianceValue(Quantities.getQuantity(10d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(10d, StandardUnits.SOLAR_IRRADIANCE)), + new TemperatureValue(Quantities.getQuantity(5d, Units.CELSIUS)), + new WindValue(Quantities.getQuantity(5d, DEGREE_GEOM), Quantities.getQuantity(10d, METRE_PER_SECOND)) ) Set> notUniqueValues = [ new TimeBasedValue(time, value), @@ -250,4 +246,4 @@ class UniquenessValidationUtilsTest extends Specification { DuplicateEntitiesException de = thrown() de.message.startsWith("'TimeBasedValue' entities with duplicated") } -} \ No newline at end of file +} diff --git a/src/test/groovy/edu/ie3/test/common/CosmoWeatherTestData.groovy b/src/test/groovy/edu/ie3/test/common/CosmoWeatherTestData.groovy index f61cf27c3..ac4412c8e 100644 --- a/src/test/groovy/edu/ie3/test/common/CosmoWeatherTestData.groovy +++ b/src/test/groovy/edu/ie3/test/common/CosmoWeatherTestData.groovy @@ -10,8 +10,8 @@ import edu.ie3.datamodel.models.value.WeatherValue import edu.ie3.util.TimeUtil import tech.units.indriya.quantity.Quantities +import java.time.ZoneId import java.time.ZonedDateTime -import java.util.Collections class CosmoWeatherTestData extends WeatherTestData { public static final ZonedDateTime TIME_15H = TimeUtil.withDefaults.toZonedDateTime("2020-04-28T15:00:00+00:00") @@ -24,8 +24,7 @@ class CosmoWeatherTestData extends WeatherTestData { Quantities.getQuantity(286.872985839844d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE), Quantities.getQuantity(0d, StandardUnits.WIND_DIRECTION), - Quantities.getQuantity(1.66103506088257d, StandardUnits.WIND_VELOCITY), - Collections.emptyMap() + Quantities.getQuantity(1.66103506088257d, StandardUnits.WIND_VELOCITY) ) public static final WeatherValue WEATHER_VALUE_193186_16H = new WeatherValue( @@ -34,8 +33,7 @@ class CosmoWeatherTestData extends WeatherTestData { Quantities.getQuantity(286.872d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(278.012d, StandardUnits.TEMPERATURE), Quantities.getQuantity(0d, StandardUnits.WIND_DIRECTION), - Quantities.getQuantity(1.662d, StandardUnits.WIND_VELOCITY), - Collections.emptyMap() + Quantities.getQuantity(1.662d, StandardUnits.WIND_VELOCITY) ) public static final WeatherValue WEATHER_VALUE_193186_17H = new WeatherValue( @@ -44,8 +42,7 @@ class CosmoWeatherTestData extends WeatherTestData { Quantities.getQuantity(286.873d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(278.013d, StandardUnits.TEMPERATURE), Quantities.getQuantity(0d, StandardUnits.WIND_DIRECTION), - Quantities.getQuantity(1.663d, StandardUnits.WIND_VELOCITY), - Collections.emptyMap() + Quantities.getQuantity(1.663d, StandardUnits.WIND_VELOCITY) ) public static final WeatherValue WEATHER_VALUE_193187_15H = new WeatherValue( @@ -54,8 +51,7 @@ class CosmoWeatherTestData extends WeatherTestData { Quantities.getQuantity(287.872985839844d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(279.019012451172d, StandardUnits.TEMPERATURE), Quantities.getQuantity(0d, StandardUnits.WIND_DIRECTION), - Quantities.getQuantity(1.76103506088257d, StandardUnits.WIND_VELOCITY), - Collections.emptyMap() + Quantities.getQuantity(1.76103506088257d, StandardUnits.WIND_VELOCITY) ) public static final WeatherValue WEATHER_VALUE_193187_16H = new WeatherValue( @@ -64,8 +60,7 @@ class CosmoWeatherTestData extends WeatherTestData { Quantities.getQuantity(287.872d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(279.012d, StandardUnits.TEMPERATURE), Quantities.getQuantity(0d, StandardUnits.WIND_DIRECTION), - Quantities.getQuantity(1.762d, StandardUnits.WIND_VELOCITY), - Collections.emptyMap() + Quantities.getQuantity(1.762d, StandardUnits.WIND_VELOCITY) ) public static final WeatherValue WEATHER_VALUE_193188_15H = new WeatherValue( @@ -74,7 +69,6 @@ class CosmoWeatherTestData extends WeatherTestData { Quantities.getQuantity(288.872985839844d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(280.019012451172d, StandardUnits.TEMPERATURE), Quantities.getQuantity(0d, StandardUnits.WIND_DIRECTION), - Quantities.getQuantity(1.86103506088257d, StandardUnits.WIND_VELOCITY), - Collections.emptyMap() + Quantities.getQuantity(1.86103506088257d, StandardUnits.WIND_VELOCITY) ) -} \ No newline at end of file +} diff --git a/src/test/groovy/edu/ie3/test/common/IconWeatherTestData.groovy b/src/test/groovy/edu/ie3/test/common/IconWeatherTestData.groovy index 265cb03b2..0a251f9d3 100644 --- a/src/test/groovy/edu/ie3/test/common/IconWeatherTestData.groovy +++ b/src/test/groovy/edu/ie3/test/common/IconWeatherTestData.groovy @@ -6,14 +6,12 @@ package edu.ie3.test.common import edu.ie3.datamodel.models.StandardUnits -import edu.ie3.datamodel.models.value.TemperatureValue import edu.ie3.datamodel.models.value.WeatherValue import edu.ie3.util.TimeUtil import tech.units.indriya.quantity.Quantities -import tech.units.indriya.unit.Units +import java.time.ZoneId import java.time.ZonedDateTime -import java.util.Collections class IconWeatherTestData extends WeatherTestData { public static final ZonedDateTime TIME_15H = TimeUtil.withDefaults.toZonedDateTime("2019-08-01T15:00:00+00:00") @@ -26,10 +24,7 @@ class IconWeatherTestData extends WeatherTestData { Quantities.getQuantity(228.021339757131, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(24.4741992659816, StandardUnits.TEMPERATURE), Quantities.getQuantity(270.45278309919627, StandardUnits.WIND_DIRECTION), - Quantities.getQuantity(3.76601470961371, StandardUnits.WIND_VELOCITY), - [ - (Quantities.getQuantity(0, Units.METRE)): new TemperatureValue(Quantities.getQuantity(27.5132065668998, Units.CELSIUS)) - ] + Quantities.getQuantity(3.76601470961371, StandardUnits.WIND_VELOCITY) ) public static final WeatherValue WEATHER_VALUE_67775_16H = new WeatherValue( @@ -38,10 +33,7 @@ class IconWeatherTestData extends WeatherTestData { Quantities.getQuantity(200.46049098038043, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(24.1700023473353, StandardUnits.TEMPERATURE), Quantities.getQuantity(278.144331776102, StandardUnits.WIND_DIRECTION), - Quantities.getQuantity(4.05744164637287, StandardUnits.WIND_VELOCITY), - [ - (Quantities.getQuantity(0, Units.METRE)): new TemperatureValue(Quantities.getQuantity(25.6947737622156, Units.CELSIUS)) - ] + Quantities.getQuantity(4.05744164637287, StandardUnits.WIND_VELOCITY) ) public static final WeatherValue WEATHER_VALUE_67775_17H = new WeatherValue( @@ -50,10 +42,7 @@ class IconWeatherTestData extends WeatherTestData { Quantities.getQuantity(180.73429610400223, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(23.6787403584074, StandardUnits.TEMPERATURE), Quantities.getQuantity(286.891007103442, StandardUnits.WIND_DIRECTION), - Quantities.getQuantity(3.81526300455393, StandardUnits.WIND_VELOCITY), - [ - (Quantities.getQuantity(0, Units.METRE)): new TemperatureValue(Quantities.getQuantity(24.5096017457568, Units.CELSIUS)) - ] + Quantities.getQuantity(3.81526300455393, StandardUnits.WIND_VELOCITY) ) public static final WeatherValue WEATHER_VALUE_67776_15H = new WeatherValue( @@ -62,21 +51,15 @@ class IconWeatherTestData extends WeatherTestData { Quantities.getQuantity(245.24079037841295, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(22.365335568404, StandardUnits.TEMPERATURE), Quantities.getQuantity(245.604554131632, StandardUnits.WIND_DIRECTION), - Quantities.getQuantity(4.39390441381814, StandardUnits.WIND_VELOCITY), - [ - (Quantities.getQuantity(0, Units.METRE)): new TemperatureValue(Quantities.getQuantity(24.28684351873816, Units.CELSIUS)) - ] + Quantities.getQuantity(4.39390441381814, StandardUnits.WIND_VELOCITY) ) public static final WeatherValue WEATHER_VALUE_67776_16H = new WeatherValue( COORDINATE_67776, - Quantities.getQuantity(91.70939132297, StandardUnits.SOLAR_IRRADIANCE), + Quantities.getQuantity(091.70939132297, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(241.641483540946, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(20.305111314491, StandardUnits.TEMPERATURE), Quantities.getQuantity(252.810224701109, StandardUnits.WIND_DIRECTION), - Quantities.getQuantity(3.44242472583919, StandardUnits.WIND_VELOCITY), - [ - (Quantities.getQuantity(0, Units.METRE)): new TemperatureValue(Quantities.getQuantity(21.8376832274387, Units.CELSIUS)) - ] + Quantities.getQuantity(3.44242472583919, StandardUnits.WIND_VELOCITY) ) -} \ No newline at end of file +} diff --git a/src/test/groovy/edu/ie3/test/common/TimeSeriesTestData.groovy b/src/test/groovy/edu/ie3/test/common/TimeSeriesTestData.groovy index 9f2195309..99925e5ab 100644 --- a/src/test/groovy/edu/ie3/test/common/TimeSeriesTestData.groovy +++ b/src/test/groovy/edu/ie3/test/common/TimeSeriesTestData.groovy @@ -29,7 +29,6 @@ import tech.units.indriya.quantity.Quantities import java.time.ZoneId import java.time.ZonedDateTime -import java.util.Collections trait TimeSeriesTestData { GeometryFactory geometryFactory = new GeometryFactory(new PrecisionModel(), 4326) @@ -59,16 +58,16 @@ trait TimeSeriesTestData { Set> individualEnergyPriceTimeSeriesProcessed = [ [ - "time" : "2020-04-02T10:00:00Z", - "price" : "5.0" + "time" : "2020-04-02T10:00:00Z", + "price" : "5.0" ] as LinkedHashMap, [ - "time" : "2020-04-02T10:15:00Z", - "price" : "15.0" + "time" : "2020-04-02T10:15:00Z", + "price" : "15.0" ] as LinkedHashMap, [ - "time" : "2020-04-02T10:30:00Z", - "price" : "10.0" + "time" : "2020-04-02T10:30:00Z", + "price" : "10.0" ] as LinkedHashMap ] as Set @@ -98,16 +97,16 @@ trait TimeSeriesTestData { Set> individualTemperatureTimeSeriesProcessed = [ [ - "time" : "2020-04-02T10:00:00Z", - "temperature" : "5.0" + "time" : "2020-04-02T10:00:00Z", + "temperature" : "5.0" ] as LinkedHashMap, [ - "time" : "2020-04-02T10:15:00Z", - "temperature" : "15.0" + "time" : "2020-04-02T10:15:00Z", + "temperature" : "15.0" ] as LinkedHashMap, [ - "time" : "2020-04-02T10:30:00Z", - "temperature" : "10.0" + "time" : "2020-04-02T10:30:00Z", + "temperature" : "10.0" ] as LinkedHashMap ] as Set @@ -128,19 +127,19 @@ trait TimeSeriesTestData { Set> individualWindTimeSeriesProcessed = [ [ - "direction" : "5.0", - "time" : "2020-04-02T10:00:00Z", - "velocity" : "10.0" + "direction" : "5.0", + "time" : "2020-04-02T10:00:00Z", + "velocity" : "10.0" ] as LinkedHashMap, [ - "direction" : "15.0", - "time" : "2020-04-02T10:15:00Z", - "velocity" : "20.0" + "direction" : "15.0", + "time" : "2020-04-02T10:15:00Z", + "velocity" : "20.0" ] as LinkedHashMap, [ - "direction" : "10.0", - "time" : "2020-04-02T10:30:00Z", - "velocity" : "15.0" + "direction" : "10.0", + "time" : "2020-04-02T10:30:00Z", + "velocity" : "15.0" ] as LinkedHashMap ] as Set @@ -161,19 +160,19 @@ trait TimeSeriesTestData { Set> individualIrradianceTimeSeriesProcessed = [ [ - "directIrradiance" : "5.0", - "diffuseIrradiance" : "10.0", - "time" : "2020-04-02T10:00:00Z" + "directIrradiance" : "5.0", + "diffuseIrradiance" : "10.0", + "time" : "2020-04-02T10:00:00Z" ] as LinkedHashMap, [ - "directIrradiance" : "15.0", - "diffuseIrradiance" : "20.0", - "time" : "2020-04-02T10:15:00Z" + "directIrradiance" : "15.0", + "diffuseIrradiance" : "20.0", + "time" : "2020-04-02T10:15:00Z" ] as LinkedHashMap, [ - "directIrradiance" : "10.0", - "diffuseIrradiance" : "15.0", - "time" : "2020-04-02T10:30:00Z" + "directIrradiance" : "10.0", + "diffuseIrradiance" : "15.0", + "time" : "2020-04-02T10:30:00Z" ] as LinkedHashMap ] as Set @@ -184,36 +183,27 @@ trait TimeSeriesTestData { ZonedDateTime.of(2020, 4, 2, 10, 0, 0, 0, ZoneId.of("UTC")), new WeatherValue( defaultLocation, - Quantities.getQuantity(5d, StandardUnits.SOLAR_IRRADIANCE), - Quantities.getQuantity(10d, StandardUnits.SOLAR_IRRADIANCE), - Quantities.getQuantity(5d, CELSIUS), - Quantities.getQuantity(5d, DEGREE_GEOM), - Quantities.getQuantity(10d, METRE_PER_SECOND), - Collections.emptyMap() + new SolarIrradianceValue(Quantities.getQuantity(5d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(10d, StandardUnits.SOLAR_IRRADIANCE)), + new TemperatureValue(Quantities.getQuantity(5d, CELSIUS)), + new WindValue(Quantities.getQuantity(5d, DEGREE_GEOM), Quantities.getQuantity(10d, METRE_PER_SECOND)) ) ), new TimeBasedValue<>( ZonedDateTime.of(2020, 4, 2, 10, 15, 0, 0, ZoneId.of("UTC")), new WeatherValue( defaultLocation, - Quantities.getQuantity(15d, StandardUnits.SOLAR_IRRADIANCE), - Quantities.getQuantity(20d, StandardUnits.SOLAR_IRRADIANCE), - Quantities.getQuantity(15d, CELSIUS), - Quantities.getQuantity(15d, DEGREE_GEOM), - Quantities.getQuantity(20d, METRE_PER_SECOND), - Collections.emptyMap() + new SolarIrradianceValue(Quantities.getQuantity(15d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(20d, StandardUnits.SOLAR_IRRADIANCE)), + new TemperatureValue(Quantities.getQuantity(15d, CELSIUS)), + new WindValue(Quantities.getQuantity(15d, DEGREE_GEOM), Quantities.getQuantity(20d, METRE_PER_SECOND)) ) ), new TimeBasedValue<>( ZonedDateTime.of(2020, 4, 2, 10, 30, 0, 0, ZoneId.of("UTC")), new WeatherValue( defaultLocation, - Quantities.getQuantity(10d, StandardUnits.SOLAR_IRRADIANCE), - Quantities.getQuantity(15d, StandardUnits.SOLAR_IRRADIANCE), - Quantities.getQuantity(10d, CELSIUS), - Quantities.getQuantity(10d, DEGREE_GEOM), - Quantities.getQuantity(15d, METRE_PER_SECOND), - Collections.emptyMap() + new SolarIrradianceValue(Quantities.getQuantity(10d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(15d, StandardUnits.SOLAR_IRRADIANCE)), + new TemperatureValue(Quantities.getQuantity(10d, CELSIUS)), + new WindValue(Quantities.getQuantity(10d, DEGREE_GEOM), Quantities.getQuantity(15d, METRE_PER_SECOND)) ) ), ] as Set @@ -221,31 +211,31 @@ trait TimeSeriesTestData { Set> individualWeatherTimeSeriesProcessed = [ [ - "coordinate" : "{\"type\":\"Point\",\"coordinates\":[7.412152,51.492758],\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}}}", - "diffSolar" : "10.0", - "directSolar" : "5.0", - "windDir" : "5.0", - "temperature" : "5.0", - "time" : "2020-04-02T10:00:00Z", - "windVel" : "10.0" + "coordinate" : "{\"type\":\"Point\",\"coordinates\":[7.412152,51.492758],\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}}}", + "diffuseIrradiance" : "10.0", + "directIrradiance" : "5.0", + "direction" : "5.0", + "temperature" : "5.0", + "time" : "2020-04-02T10:00:00Z", + "velocity" : "10.0" ] as LinkedHashMap, [ - "coordinate" : "{\"type\":\"Point\",\"coordinates\":[7.412152,51.492758],\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}}}", - "diffSolar" : "20.0", - "directSolar" : "15.0", - "windDir" : "15.0", - "temperature" : "15.0", - "time" : "2020-04-02T10:15:00Z", - "windVel" : "20.0" + "coordinate" : "{\"type\":\"Point\",\"coordinates\":[7.412152,51.492758],\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}}}", + "diffuseIrradiance" : "20.0", + "directIrradiance" : "15.0", + "direction" : "15.0", + "temperature" : "15.0", + "time" : "2020-04-02T10:15:00Z", + "velocity" : "20.0" ] as LinkedHashMap, [ - "coordinate" : "{\"type\":\"Point\",\"coordinates\":[7.412152,51.492758],\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}}}", - "diffSolar" : "15.0", - "directSolar" : "10.0", - "windDir" : "10.0", - "temperature" : "10.0", - "time" : "2020-04-02T10:30:00Z", - "windVel" : "15.0" + "coordinate" : "{\"type\":\"Point\",\"coordinates\":[7.412152,51.492758],\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}}}", + "diffuseIrradiance" : "15.0", + "directIrradiance" : "10.0", + "direction" : "10.0", + "temperature" : "10.0", + "time" : "2020-04-02T10:30:00Z", + "velocity" : "15.0" ] as LinkedHashMap ] as Set @@ -266,16 +256,16 @@ trait TimeSeriesTestData { Set> individualHeatDemandTimeSeriesProcessed = [ [ - "heatDemand" : "5.0", - "time" : "2020-04-02T10:00:00Z" + "heatDemand" : "5.0", + "time" : "2020-04-02T10:00:00Z" ] as LinkedHashMap, [ - "heatDemand" : "15.0", - "time" : "2020-04-02T10:15:00Z" + "heatDemand" : "15.0", + "time" : "2020-04-02T10:15:00Z" ] as LinkedHashMap, [ - "heatDemand" : "10.0", - "time" : "2020-04-02T10:30:00Z" + "heatDemand" : "10.0", + "time" : "2020-04-02T10:30:00Z" ] as LinkedHashMap ] as Set @@ -296,16 +286,16 @@ trait TimeSeriesTestData { Set> individualPTimeSeriesProcessed = [ [ - "p" : "5.0", - "time" : "2020-04-02T10:00:00Z" + "p" : "5.0", + "time" : "2020-04-02T10:00:00Z" ] as LinkedHashMap, [ - "p" : "15.0", - "time" : "2020-04-02T10:15:00Z" + "p" : "15.0", + "time" : "2020-04-02T10:15:00Z" ] as LinkedHashMap, [ - "p" : "10.0", - "time" : "2020-04-02T10:30:00Z" + "p" : "10.0", + "time" : "2020-04-02T10:30:00Z" ] as LinkedHashMap ] as Set @@ -326,19 +316,19 @@ trait TimeSeriesTestData { Set> individualHeatAndPTimeSeriesProcessed = [ [ - "heatDemand" : "10.0", - "p" : "5.0", - "time" : "2020-04-02T10:00:00Z" + "heatDemand" : "10.0", + "p" : "5.0", + "time" : "2020-04-02T10:00:00Z" ] as LinkedHashMap, [ - "heatDemand" : "20.0", - "p" : "15.0", - "time" : "2020-04-02T10:15:00Z" + "heatDemand" : "20.0", + "p" : "15.0", + "time" : "2020-04-02T10:15:00Z" ] as LinkedHashMap, [ - "heatDemand" : "15.0", - "p" : "10.0", - "time" : "2020-04-02T10:30:00Z" + "heatDemand" : "15.0", + "p" : "10.0", + "time" : "2020-04-02T10:30:00Z" ] as LinkedHashMap ] as Set @@ -359,19 +349,19 @@ trait TimeSeriesTestData { Set> individualSTimeSeriesProcessed = [ [ - "p" : "5.0", - "q" : "10.0", - "time" : "2020-04-02T10:00:00Z" + "p" : "5.0", + "q" : "10.0", + "time" : "2020-04-02T10:00:00Z" ] as LinkedHashMap, [ - "p" : "15.0", - "q" : "20.0", - "time" : "2020-04-02T10:15:00Z" + "p" : "15.0", + "q" : "20.0", + "time" : "2020-04-02T10:15:00Z" ] as LinkedHashMap, [ - "p" : "10.0", - "q" : "15.0", - "time" : "2020-04-02T10:30:00Z" + "p" : "10.0", + "q" : "15.0", + "time" : "2020-04-02T10:30:00Z" ] as LinkedHashMap ] as Set @@ -392,22 +382,22 @@ trait TimeSeriesTestData { Set> individualHeatAndSTimeSeriesProcessed = [ [ - "heatDemand" : "15.0", - "p" : "5.0", - "q" : "10.0", - "time" : "2020-04-02T10:00:00Z" + "heatDemand" : "15.0", + "p" : "5.0", + "q" : "10.0", + "time" : "2020-04-02T10:00:00Z" ] as LinkedHashMap, [ - "heatDemand" : "25.0", - "p" : "15.0", - "q" : "20.0", - "time" : "2020-04-02T10:15:00Z" + "heatDemand" : "25.0", + "p" : "15.0", + "q" : "20.0", + "time" : "2020-04-02T10:15:00Z" ] as LinkedHashMap, [ - "heatDemand" : "20.0", - "p" : "10.0", - "q" : "15.0", - "time" : "2020-04-02T10:30:00Z" + "heatDemand" : "20.0", + "p" : "10.0", + "q" : "15.0", + "time" : "2020-04-02T10:30:00Z" ] as LinkedHashMap ] as Set diff --git a/src/test/groovy/edu/ie3/test/helper/WeatherSourceTestHelper.groovy b/src/test/groovy/edu/ie3/test/helper/WeatherSourceTestHelper.groovy index f6ea29054..3f5c48458 100644 --- a/src/test/groovy/edu/ie3/test/helper/WeatherSourceTestHelper.groovy +++ b/src/test/groovy/edu/ie3/test/helper/WeatherSourceTestHelper.groovy @@ -13,16 +13,16 @@ import edu.ie3.util.quantities.QuantityUtil trait WeatherSourceTestHelper { static boolean equalsIgnoreUUID(IndividualTimeSeries ts1, - IndividualTimeSeries ts2) { - return WeatherSourceTestHelper.equalsIgnoreUUID(ts1.entries, ts2.entries) + IndividualTimeSeries ts2) { + return equalsIgnoreUUID(ts1.entries, ts2.entries) } static boolean equalsIgnoreUUID(Collection> c1, - Collection> c2) { + Collection> c2) { if (c1 == null || c2 == null) return (c1 == null && c2 == null) if (c1.size() != c2.size()) return false for (TimeBasedValue value1 : c1) { - if (!c2.stream().anyMatch({ value2 -> WeatherSourceTestHelper.equalsIgnoreUUID(value1, value2) })) return false + if (!c2.stream().anyMatch({ value2 -> equalsIgnoreUUID(value1, value2) })) return false } return true } @@ -33,11 +33,10 @@ trait WeatherSourceTestHelper { def weatherValue1 = val1.value def weatherValue2 = val2.value - return QuantityUtil.isEquivalentAbs(weatherValue1.directSolar, weatherValue2.directSolar, 1E-10) && - QuantityUtil.isEquivalentAbs(weatherValue1.diffSolar, weatherValue2.diffSolar, 1E-10) && - QuantityUtil.isEquivalentAbs(weatherValue1.temperature, weatherValue2.temperature, 1E-10) && - QuantityUtil.isEquivalentAbs(weatherValue1.windVel, weatherValue2.windVel, 1E-10) && - QuantityUtil.isEquivalentAbs(weatherValue1.windDir, weatherValue2.windDir, 1E-10) && - weatherValue1.groundTemperatures == weatherValue2.groundTemperatures + return weatherValue1.solarIrradiance.directIrradiance.present == weatherValue2.solarIrradiance.directIrradiance.present && QuantityUtil.isEquivalentAbs(weatherValue1.solarIrradiance.directIrradiance.get(), weatherValue2.solarIrradiance.directIrradiance.get(), 1E-10) && + weatherValue1.solarIrradiance.diffuseIrradiance.present == weatherValue2.solarIrradiance.diffuseIrradiance.present && QuantityUtil.isEquivalentAbs(weatherValue1.solarIrradiance.diffuseIrradiance.get(), weatherValue2.solarIrradiance.diffuseIrradiance.get(), 1E-10) && + weatherValue1.temperature.temperature.present == weatherValue2.temperature.temperature.present && QuantityUtil.isEquivalentAbs(weatherValue1.temperature.temperature.get(), weatherValue2.temperature.temperature.get(), 1E-10) && + weatherValue1.wind.velocity.present == weatherValue2.wind.velocity.present && QuantityUtil.isEquivalentAbs(weatherValue1.wind.velocity.get(), weatherValue2.wind.velocity.get(), 1E-10) && + weatherValue1.wind.direction.present == weatherValue2.wind.direction.present && QuantityUtil.isEquivalentAbs(weatherValue1.wind.direction.get(), weatherValue2.wind.direction.get(), 1E-10) } } \ No newline at end of file From b0d87d938afeef656c6d85f3900370bedcc794c4 Mon Sep 17 00:00:00 2001 From: pierrepetersmeier <155652256+pierrepetersmeier@users.noreply.github.com> Date: Mon, 28 Jul 2025 11:16:41 +0200 Subject: [PATCH 07/36] Remove logger.warn --- .../factory/timeseries/CosmoTimeBasedWeatherValueFactory.java | 3 +-- .../factory/timeseries/IconTimeBasedWeatherValueFactory.java | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactory.java index 048c76c14..d2af58a7a 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactory.java @@ -85,9 +85,8 @@ protected TimeBasedValue buildModel(TimeBasedWeatherValueData data ComparableQuantity groundTemperature = null; try { groundTemperature = data.getQuantity(GROUND_TEMPERATURE, StandardUnits.TEMPERATURE); - } catch (IllegalArgumentException e) { + } catch (IllegalArgumentException ignored) { - logger.warn("Field '{}' not found in data, proceeding without it.", GROUND_TEMPERATURE); } WeatherValue weatherValue = diff --git a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java index 2b2bf808a..9e17780b5 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java @@ -100,9 +100,8 @@ protected TimeBasedValue buildModel(TimeBasedWeatherValueData data try { groundTemperature = data.getQuantity(GROUND_TEMPERATURE, Units.KELVIN).to(StandardUnits.TEMPERATURE); - } catch (IllegalArgumentException e) { + } catch (IllegalArgumentException ignored) { - logger.warn("Field '{}' not found in data, proceeding without it.", GROUND_TEMPERATURE); } WeatherValue weatherValue = From 0399aa3f7923c6e90ec80f6e8f49b89eea2c1e53 Mon Sep 17 00:00:00 2001 From: pierrepetersmeier <155652256+pierrepetersmeier@users.noreply.github.com> Date: Tue, 12 Aug 2025 14:21:00 +0200 Subject: [PATCH 08/36] fmt --- .../IconTimeBasedWeatherValueFactory.java | 4 ++-- .../ie3/datamodel/models/value/WeatherValue.java | 1 + .../ie3/test/helper/WeatherSourceTestHelper.groovy | 14 ++++++-------- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java index 9e17780b5..fa04f4ddc 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java @@ -30,7 +30,8 @@ */ public class IconTimeBasedWeatherValueFactory extends TimeBasedWeatherValueFactory { - private static final Logger logger = LoggerFactory.getLogger(IconTimeBasedWeatherValueFactory.class); + private static final Logger logger = + LoggerFactory.getLogger(IconTimeBasedWeatherValueFactory.class); /* Redefine the column names to meet the icon specifications */ private static final String DIFFUSE_IRRADIANCE = "aswdifdS"; @@ -101,7 +102,6 @@ protected TimeBasedValue buildModel(TimeBasedWeatherValueData data groundTemperature = data.getQuantity(GROUND_TEMPERATURE, Units.KELVIN).to(StandardUnits.TEMPERATURE); } catch (IllegalArgumentException ignored) { - } WeatherValue weatherValue = diff --git a/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java b/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java index 7adc67ffc..46b2338c4 100644 --- a/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java +++ b/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java @@ -28,6 +28,7 @@ public class WeatherValue implements Value { private final TemperatureValue temperature; /** Wind values for this coordinate */ private final WindValue wind; + /** GroundTemeperature value */ private final GroundTemperatureValue groundTemperature; /** diff --git a/src/test/groovy/edu/ie3/test/helper/WeatherSourceTestHelper.groovy b/src/test/groovy/edu/ie3/test/helper/WeatherSourceTestHelper.groovy index 3f5c48458..2c7a8402b 100644 --- a/src/test/groovy/edu/ie3/test/helper/WeatherSourceTestHelper.groovy +++ b/src/test/groovy/edu/ie3/test/helper/WeatherSourceTestHelper.groovy @@ -12,13 +12,11 @@ import edu.ie3.util.quantities.QuantityUtil trait WeatherSourceTestHelper { - static boolean equalsIgnoreUUID(IndividualTimeSeries ts1, - IndividualTimeSeries ts2) { + static boolean equalsIgnoreUUID(IndividualTimeSeries ts1, IndividualTimeSeries ts2) { return equalsIgnoreUUID(ts1.entries, ts2.entries) } - static boolean equalsIgnoreUUID(Collection> c1, - Collection> c2) { + static boolean equalsIgnoreUUID(Collection> c1, Collection> c2) { if (c1 == null || c2 == null) return (c1 == null && c2 == null) if (c1.size() != c2.size()) return false for (TimeBasedValue value1 : c1) { @@ -34,9 +32,9 @@ trait WeatherSourceTestHelper { def weatherValue2 = val2.value return weatherValue1.solarIrradiance.directIrradiance.present == weatherValue2.solarIrradiance.directIrradiance.present && QuantityUtil.isEquivalentAbs(weatherValue1.solarIrradiance.directIrradiance.get(), weatherValue2.solarIrradiance.directIrradiance.get(), 1E-10) && - weatherValue1.solarIrradiance.diffuseIrradiance.present == weatherValue2.solarIrradiance.diffuseIrradiance.present && QuantityUtil.isEquivalentAbs(weatherValue1.solarIrradiance.diffuseIrradiance.get(), weatherValue2.solarIrradiance.diffuseIrradiance.get(), 1E-10) && - weatherValue1.temperature.temperature.present == weatherValue2.temperature.temperature.present && QuantityUtil.isEquivalentAbs(weatherValue1.temperature.temperature.get(), weatherValue2.temperature.temperature.get(), 1E-10) && - weatherValue1.wind.velocity.present == weatherValue2.wind.velocity.present && QuantityUtil.isEquivalentAbs(weatherValue1.wind.velocity.get(), weatherValue2.wind.velocity.get(), 1E-10) && - weatherValue1.wind.direction.present == weatherValue2.wind.direction.present && QuantityUtil.isEquivalentAbs(weatherValue1.wind.direction.get(), weatherValue2.wind.direction.get(), 1E-10) + weatherValue1.solarIrradiance.diffuseIrradiance.present == weatherValue2.solarIrradiance.diffuseIrradiance.present && QuantityUtil.isEquivalentAbs(weatherValue1.solarIrradiance.diffuseIrradiance.get(), weatherValue2.solarIrradiance.diffuseIrradiance.get(), 1E-10) && + weatherValue1.temperature.temperature.present == weatherValue2.temperature.temperature.present && QuantityUtil.isEquivalentAbs(weatherValue1.temperature.temperature.get(), weatherValue2.temperature.temperature.get(), 1E-10) && + weatherValue1.wind.velocity.present == weatherValue2.wind.velocity.present && QuantityUtil.isEquivalentAbs(weatherValue1.wind.velocity.get(), weatherValue2.wind.velocity.get(), 1E-10) && + weatherValue1.wind.direction.present == weatherValue2.wind.direction.present && QuantityUtil.isEquivalentAbs(weatherValue1.wind.direction.get(), weatherValue2.wind.direction.get(), 1E-10) } } \ No newline at end of file From 88191d1adc55e321d8d61ed63df0af1084d85416 Mon Sep 17 00:00:00 2001 From: pierrepetersmeier <155652256+pierrepetersmeier@users.noreply.github.com> Date: Tue, 12 Aug 2025 14:40:14 +0200 Subject: [PATCH 09/36] fmt --- .../ie3/datamodel/models/value/GroundTemperatureValue.java | 4 +++- .../java/edu/ie3/datamodel/models/value/WeatherValue.java | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/edu/ie3/datamodel/models/value/GroundTemperatureValue.java b/src/main/java/edu/ie3/datamodel/models/value/GroundTemperatureValue.java index ba1bbfb0b..6ac1c7233 100644 --- a/src/main/java/edu/ie3/datamodel/models/value/GroundTemperatureValue.java +++ b/src/main/java/edu/ie3/datamodel/models/value/GroundTemperatureValue.java @@ -17,7 +17,9 @@ public class GroundTemperatureValue implements Value { /** Ground temperature (typically in K) */ private final ComparableQuantity temperature; - /** @param temperature Ground temperature (typically in K) */ + /** + * @param temperature Ground temperature (typically in K) + */ public GroundTemperatureValue(ComparableQuantity temperature) { this.temperature = temperature == null ? null : temperature.to(StandardUnits.TEMPERATURE); } diff --git a/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java b/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java index 4e513b871..be6ccf491 100644 --- a/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java +++ b/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java @@ -30,6 +30,7 @@ public class WeatherValue implements Value { /** Wind values for this coordinate */ private final WindValue wind; + /** GroundTemeperature value */ private final GroundTemperatureValue groundTemperature; From 41302fe923e6d429a9cee226167cf9428e3e6677 Mon Sep 17 00:00:00 2001 From: pierrepetersmeier <155652256+pierrepetersmeier@users.noreply.github.com> Date: Mon, 25 Aug 2025 12:51:44 +0200 Subject: [PATCH 10/36] fmt --- .../IconTimeBasedWeatherValueFactory.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java index fa04f4ddc..ea154bf82 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java @@ -115,7 +115,19 @@ protected TimeBasedValue buildModel(TimeBasedWeatherValueData data groundTemperature); return new TimeBasedValue<>(time, weatherValue); } - + /** + * Determines the wind direction. In ICON the wind velocity is given in three dimensional + * Cartesian coordinates. Here, the upward component is neglected. 0° or 0 rad are defined to + * point northwards. The angle increases clockwise. Please note, that the wind direction is the + * direction, the wind comes from and not goes to. We choose to use the wind velocity + * calculations at 131 m above ground, as this is a height that pretty good matches the common hub + * height of today's onshore wind generators, that are commonly connected to the voltage levels of + * interest. + * + * @param data Collective information to convert + * @return A {@link ComparableQuantity} of type {@link Speed}, that is converted to {@link + * StandardUnits#WIND_VELOCITY} + */ private static ComparableQuantity getWindDirection(TimeBasedWeatherValueData data) { /* Get the three dimensional parts of the wind velocity vector in cartesian coordinates */ double u = From 55a7c15f1649cb0242fa1cfc9fd535bbe1e03d3d Mon Sep 17 00:00:00 2001 From: pierrepetersmeier <155652256+pierrepetersmeier@users.noreply.github.com> Date: Fri, 17 Oct 2025 17:51:36 +0200 Subject: [PATCH 11/36] Add GroundTemperatureValue 0cm and 80cm. --- .../ie3/datamodel/io/factory/EntityData.java | 10 + .../CosmoTimeBasedWeatherValueFactory.java | 29 ++- .../IconTimeBasedWeatherValueFactory.java | 58 +++-- .../models/value/GroundTemperatureValue.java | 40 +--- .../datamodel/models/value/WeatherValue.java | 101 +++++++-- .../ie3/test/common/TimeSeriesTestData.groovy | 204 +++++++++--------- ...r_8bc9120d-fb9b-4484-b4e3-0cdadf0feea9.csv | 14 +- ...r_513606bc-539e-445b-9675-2f98be3d9231.csv | 12 +- 8 files changed, 259 insertions(+), 209 deletions(-) diff --git a/src/main/java/edu/ie3/datamodel/io/factory/EntityData.java b/src/main/java/edu/ie3/datamodel/io/factory/EntityData.java index 6a5a51f3e..d7dfec458 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/EntityData.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/EntityData.java @@ -60,6 +60,16 @@ public Class getTargetClass() { return (Class) super.getTargetClass(); } + /** + * Checks if the entity data contains the given field. + * + * @param field field name + * @return true if the field is present, false otherwise + */ + public boolean hasField(String field) { + return getFieldsToValues().containsKey(field); + } + /** * Returns boolean value for given field name. Throws {@link FactoryException} if field does not * exist, or field value is null or empty. diff --git a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactory.java index d2af58a7a..3cefca5eb 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactory.java @@ -13,14 +13,13 @@ import edu.ie3.util.quantities.interfaces.Irradiance; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; +import java.util.Arrays; import java.util.List; import java.util.Set; import javax.measure.quantity.Angle; import javax.measure.quantity.Speed; import javax.measure.quantity.Temperature; import org.locationtech.jts.geom.Point; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import tech.units.indriya.ComparableQuantity; /** @@ -28,16 +27,13 @@ * value mapping in the typical PowerSystemDataModel (PSDM) column scheme */ public class CosmoTimeBasedWeatherValueFactory extends TimeBasedWeatherValueFactory { - - private static final Logger logger = - LoggerFactory.getLogger(CosmoTimeBasedWeatherValueFactory.class); - private static final String DIFFUSE_IRRADIANCE = "diffuseIrradiance"; private static final String DIRECT_IRRADIANCE = "directIrradiance"; private static final String TEMPERATURE = "temperature"; - private static final String GROUND_TEMPERATURE = "groundTemperature"; private static final String WIND_DIRECTION = "windDirection"; private static final String WIND_VELOCITY = "windVelocity"; + private static final String GROUND_TEMPERATURE_0CM = "groundTemperature0cm"; + private static final String GROUND_TEMPERATURE_80CM = "groundTemperature80cm"; public CosmoTimeBasedWeatherValueFactory(TimeUtil timeUtil) { super(timeUtil); @@ -62,9 +58,10 @@ protected List> getFields(Class entityClass) { WIND_DIRECTION, WIND_VELOCITY); - Set withGroundTemp = expandSet(minConstructorParams, GROUND_TEMPERATURE); + Set withGroundTemp = + expandSet(minConstructorParams, GROUND_TEMPERATURE_0CM, GROUND_TEMPERATURE_80CM); - return List.of(minConstructorParams, withGroundTemp); + return Arrays.asList(minConstructorParams, withGroundTemp); } @Override @@ -81,13 +78,10 @@ protected TimeBasedValue buildModel(TimeBasedWeatherValueData data data.getQuantity(WIND_DIRECTION, StandardUnits.WIND_DIRECTION); ComparableQuantity windVelocity = data.getQuantity(WIND_VELOCITY, StandardUnits.WIND_VELOCITY); - - ComparableQuantity groundTemperature = null; - try { - groundTemperature = data.getQuantity(GROUND_TEMPERATURE, StandardUnits.TEMPERATURE); - } catch (IllegalArgumentException ignored) { - - } + ComparableQuantity groundTemp0cm = + data.getQuantityOptional(GROUND_TEMPERATURE_0CM, StandardUnits.TEMPERATURE).orElse(null); + ComparableQuantity groundTemp80cm = + data.getQuantityOptional(GROUND_TEMPERATURE_80CM, StandardUnits.TEMPERATURE).orElse(null); WeatherValue weatherValue = new WeatherValue( @@ -97,7 +91,8 @@ protected TimeBasedValue buildModel(TimeBasedWeatherValueData data temperature, windDirection, windVelocity, - groundTemperature); + groundTemp0cm, + groundTemp80cm); return new TimeBasedValue<>(time, weatherValue); } diff --git a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java index ea154bf82..774854fab 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java @@ -17,29 +17,24 @@ import javax.measure.quantity.Speed; import javax.measure.quantity.Temperature; import org.locationtech.jts.geom.Point; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import tech.units.indriya.ComparableQuantity; import tech.units.indriya.quantity.Quantities; import tech.units.indriya.unit.Units; /** * Factory implementation of {@link TimeBasedWeatherValueFactory}, that is able to handle field to - * value mapping in the column scheme, ie3 uses to store its data from German Federal - * Weather Service's ICON-EU model + * value mapping in the column scheme, ie³ uses to store its data from German Federal Weather + * Service's ICON-EU model */ public class IconTimeBasedWeatherValueFactory extends TimeBasedWeatherValueFactory { - - private static final Logger logger = - LoggerFactory.getLogger(IconTimeBasedWeatherValueFactory.class); - /* Redefine the column names to meet the icon specifications */ private static final String DIFFUSE_IRRADIANCE = "aswdifdS"; private static final String DIRECT_IRRADIANCE = "aswdirS"; private static final String TEMPERATURE = "t2m"; - private static final String GROUND_TEMPERATURE = "tG"; private static final String WIND_VELOCITY_U = "u131m"; private static final String WIND_VELOCITY_V = "v131m"; + private static final String GROUND_TEMPERATURE_0CM = "tG"; + private static final String GROUND_TEMPERATURE_80CM = "t80cm"; public IconTimeBasedWeatherValueFactory() { super(); @@ -54,14 +49,14 @@ protected List> getFields(Class entityClass) { Set minParameters = newSet( DIFFUSE_IRRADIANCE, DIRECT_IRRADIANCE, TEMPERATURE, WIND_VELOCITY_U, WIND_VELOCITY_V); - Set allParameters = expandSet( minParameters, "albrad", "asobs", "aswdifuS", - "tG", + GROUND_TEMPERATURE_0CM, // Already present in ICON data + GROUND_TEMPERATURE_80CM, // New optional field "u10m", "u20m", "u216m", @@ -96,13 +91,10 @@ protected TimeBasedValue buildModel(TimeBasedWeatherValueData data data.getQuantity(TEMPERATURE, Units.KELVIN).to(StandardUnits.TEMPERATURE); ComparableQuantity windDirection = getWindDirection(data); ComparableQuantity windVelocity = getWindVelocity(data); - - ComparableQuantity groundTemperature = null; - try { - groundTemperature = - data.getQuantity(GROUND_TEMPERATURE, Units.KELVIN).to(StandardUnits.TEMPERATURE); - } catch (IllegalArgumentException ignored) { - } + ComparableQuantity groundTemp0cm = + data.getQuantityOptional(GROUND_TEMPERATURE_0CM, StandardUnits.TEMPERATURE).orElse(null); + ComparableQuantity groundTemp80cm = + data.getQuantityOptional(GROUND_TEMPERATURE_80CM, StandardUnits.TEMPERATURE).orElse(null); WeatherValue weatherValue = new WeatherValue( @@ -112,22 +104,24 @@ protected TimeBasedValue buildModel(TimeBasedWeatherValueData data temperature, windDirection, windVelocity, - groundTemperature); + groundTemp0cm, + groundTemp80cm); return new TimeBasedValue<>(time, weatherValue); } - /** - * Determines the wind direction. In ICON the wind velocity is given in three dimensional - * Cartesian coordinates. Here, the upward component is neglected. 0° or 0 rad are defined to - * point northwards. The angle increases clockwise. Please note, that the wind direction is the - * direction, the wind comes from and not goes to. We choose to use the wind velocity - * calculations at 131 m above ground, as this is a height that pretty good matches the common hub - * height of today's onshore wind generators, that are commonly connected to the voltage levels of - * interest. - * - * @param data Collective information to convert - * @return A {@link ComparableQuantity} of type {@link Speed}, that is converted to {@link - * StandardUnits#WIND_VELOCITY} - */ + + /** + * Determines the wind direction. In ICON the wind velocity is given in three dimensional + * Cartesian coordinates. Here, the upward component is neglected. 0° or 0 rad are defined to + * point northwards. The angle increases clockwise. Please note, that the wind direction is the + * direction, the wind comes from and not goes to. We choose to use the wind velocity + * calculations at 131 m above ground, as this is a height that pretty good matches the common hub + * height of today's onshore wind generators, that are commonly connected to the voltage levels of + * interest. + * + * @param data Collective information to convert + * @return A {@link ComparableQuantity} of type {@link Speed}, that is converted to {@link + * StandardUnits#WIND_VELOCITY} + */ private static ComparableQuantity getWindDirection(TimeBasedWeatherValueData data) { /* Get the three dimensional parts of the wind velocity vector in cartesian coordinates */ double u = diff --git a/src/main/java/edu/ie3/datamodel/models/value/GroundTemperatureValue.java b/src/main/java/edu/ie3/datamodel/models/value/GroundTemperatureValue.java index 6ac1c7233..fdc15c196 100644 --- a/src/main/java/edu/ie3/datamodel/models/value/GroundTemperatureValue.java +++ b/src/main/java/edu/ie3/datamodel/models/value/GroundTemperatureValue.java @@ -1,48 +1,30 @@ /* - * © 2025. TU Dortmund University, + * © 2021. TU Dortmund University, * Institute of Energy Systems, Energy Efficiency and Energy Economics, * Research group Distribution grid planning and operation */ package edu.ie3.datamodel.models.value; -import edu.ie3.datamodel.models.StandardUnits; -import java.util.Objects; -import java.util.Optional; import javax.measure.quantity.Temperature; import tech.units.indriya.ComparableQuantity; -/** Describes a ground temperature value. */ -public class GroundTemperatureValue implements Value { - - /** Ground temperature (typically in K) */ - private final ComparableQuantity temperature; +/** + * Describes a ground temperature value. This class extends {@link TemperatureValue} to represent + * temperature at a specific depth in the ground. + */ +public class GroundTemperatureValue extends TemperatureValue { /** - * @param temperature Ground temperature (typically in K) + * Constructs a new GroundTemperatureValue. + * + * @param temperature The temperature quantity (typically in K) */ public GroundTemperatureValue(ComparableQuantity temperature) { - this.temperature = temperature == null ? null : temperature.to(StandardUnits.TEMPERATURE); - } - - public Optional> getTemperature() { - return Optional.ofNullable(temperature); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - GroundTemperatureValue that = (GroundTemperatureValue) o; - return Objects.equals(temperature, that.temperature); - } - - @Override - public int hashCode() { - return Objects.hash(temperature); + super(temperature); } @Override public String toString() { - return "GroundTemperatureValue{" + "temperature=" + temperature + '}'; + return "GroundTemperatureValue{" + "temperature=" + getTemperature().orElse(null) + '}'; } } diff --git a/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java b/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java index be6ccf491..6d6ef284a 100644 --- a/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java +++ b/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java @@ -14,10 +14,7 @@ import org.locationtech.jts.geom.Point; import tech.units.indriya.ComparableQuantity; -/** - * Describes weather as a combination of solar irradiance, temperature, wind, and ground temperature - * values. - */ +/** Describes weather as a combination of solar irradiance, temperature and wind values */ public class WeatherValue implements Value { /** The coordinate of this weather value set */ private final Point coordinate; @@ -31,30 +28,38 @@ public class WeatherValue implements Value { /** Wind values for this coordinate */ private final WindValue wind; - /** GroundTemeperature value */ - private final GroundTemperatureValue groundTemperature; + /** Ground temperature value at 0cm depth for this coordinate */ + private final GroundTemperatureValue groundTemperature0cm; + + /** Ground temperature value at 80cm depth for this coordinate */ + private final GroundTemperatureValue groundTemperature80cm; /** * @param coordinate of this weather value set * @param solarIrradiance values for this coordinate * @param temperature values for this coordinate * @param wind values for this coordinate - * @param groundTemperature values for this coordinate (can be null) + * @param groundTemperature0cm values for this coordinate (can be null) + * @param groundTemperature80cm values for this coordinate (can be null) */ public WeatherValue( Point coordinate, SolarIrradianceValue solarIrradiance, TemperatureValue temperature, WindValue wind, - GroundTemperatureValue groundTemperature) { + GroundTemperatureValue groundTemperature0cm, + GroundTemperatureValue groundTemperature80cm) { this.coordinate = coordinate; this.solarIrradiance = solarIrradiance; this.temperature = temperature; this.wind = wind; - this.groundTemperature = groundTemperature; + this.groundTemperature0cm = groundTemperature0cm; + this.groundTemperature80cm = groundTemperature80cm; } /** + * Constructor with all parameters as quantities. + * * @param coordinate of this weather value set * @param directSolarIrradiance Direct sun irradiance for this coordinate (typically in W/m²) * @param diffuseSolarIrradiance Diffuse sun irradiance for this coordinate (typically in W/m²) @@ -62,7 +67,10 @@ public WeatherValue( * @param direction Direction, the wind comes from as an angle from north increasing clockwise * (typically in rad) * @param velocity Wind velocity for this coordinate (typically in m/s) - * @param groundTemperature Ground temperature (typically in K) + * @param groundTemp0cm Ground temperature at 0cm for this coordinate (typically in K, can be + * null) + * @param groundTemp80cm Ground temperature at 80cm for this coordinate (typically in K, can be + * null) */ public WeatherValue( Point coordinate, @@ -71,13 +79,49 @@ public WeatherValue( ComparableQuantity temperature, ComparableQuantity direction, ComparableQuantity velocity, - ComparableQuantity groundTemperature) { + ComparableQuantity groundTemp0cm, + ComparableQuantity groundTemp80cm) { this( coordinate, new SolarIrradianceValue(directSolarIrradiance, diffuseSolarIrradiance), new TemperatureValue(temperature), new WindValue(direction, velocity), - new GroundTemperatureValue(groundTemperature)); + groundTemp0cm == null ? null : new GroundTemperatureValue(groundTemp0cm), + groundTemp80cm == null ? null : new GroundTemperatureValue(groundTemp80cm)); + } + + /** + * @deprecated Use the constructor that includes ground temperatures instead + */ + @Deprecated(since = "3.0", forRemoval = true) + public WeatherValue( + Point coordinate, + SolarIrradianceValue solarIrradiance, + TemperatureValue temperature, + WindValue wind) { + this(coordinate, solarIrradiance, temperature, wind, null, null); + } + + /** + * @deprecated Use the constructor that includes ground temperatures instead + */ + @Deprecated(since = "3.0", forRemoval = true) + public WeatherValue( + Point coordinate, + ComparableQuantity directSolarIrradiance, + ComparableQuantity diffuseSolarIrradiance, + ComparableQuantity temperature, + ComparableQuantity direction, + ComparableQuantity velocity) { + this( + coordinate, + directSolarIrradiance, + diffuseSolarIrradiance, + temperature, + direction, + velocity, + null, + null); } public Point getCoordinate() { @@ -96,8 +140,12 @@ public WindValue getWind() { return wind; } - public Optional getGroundTemperature() { - return Optional.ofNullable(groundTemperature); + public Optional getGroundTemperature0cm() { + return Optional.ofNullable(groundTemperature0cm); + } + + public Optional getGroundTemperature80cm() { + return Optional.ofNullable(groundTemperature80cm); } @Override @@ -105,16 +153,23 @@ public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; WeatherValue that = (WeatherValue) o; - return Objects.equals(coordinate, that.coordinate) - && Objects.equals(solarIrradiance, that.solarIrradiance) - && Objects.equals(temperature, that.temperature) - && Objects.equals(wind, that.wind) - && Objects.equals(groundTemperature, that.groundTemperature); + return coordinate.equals(that.coordinate) + && solarIrradiance.equals(that.solarIrradiance) + && temperature.equals(that.temperature) + && wind.equals(that.wind) + && Objects.equals(groundTemperature0cm, that.groundTemperature0cm) + && Objects.equals(groundTemperature80cm, that.groundTemperature80cm); } @Override public int hashCode() { - return Objects.hash(coordinate, solarIrradiance, temperature, wind, groundTemperature); + return Objects.hash( + coordinate, + solarIrradiance, + temperature, + wind, + groundTemperature0cm, + groundTemperature80cm); } @Override @@ -128,8 +183,10 @@ public String toString() { + temperature + ", wind=" + wind - + ", groundTemperature=" - + groundTemperature + + ", groundTemperature0cm=" + + groundTemperature0cm + + ", groundTemperature80cm=" + + groundTemperature80cm + '}'; } } diff --git a/src/test/groovy/edu/ie3/test/common/TimeSeriesTestData.groovy b/src/test/groovy/edu/ie3/test/common/TimeSeriesTestData.groovy index eb25d08fa..53893169c 100644 --- a/src/test/groovy/edu/ie3/test/common/TimeSeriesTestData.groovy +++ b/src/test/groovy/edu/ie3/test/common/TimeSeriesTestData.groovy @@ -57,16 +57,16 @@ trait TimeSeriesTestData { Set> individualEnergyPriceTimeSeriesProcessed = [ [ - "time" : "2020-04-02T10:00:00Z", - "price" : "5.0" + "time" : "2020-04-02T10:00:00Z", + "price" : "5.0" ] as LinkedHashMap, [ - "time" : "2020-04-02T10:15:00Z", - "price" : "15.0" + "time" : "2020-04-02T10:15:00Z", + "price" : "15.0" ] as LinkedHashMap, [ - "time" : "2020-04-02T10:30:00Z", - "price" : "10.0" + "time" : "2020-04-02T10:30:00Z", + "price" : "10.0" ] as LinkedHashMap ] as Set @@ -96,16 +96,16 @@ trait TimeSeriesTestData { Set> individualTemperatureTimeSeriesProcessed = [ [ - "time" : "2020-04-02T10:00:00Z", - "temperature" : "5.0" + "time" : "2020-04-02T10:00:00Z", + "temperature" : "5.0" ] as LinkedHashMap, [ - "time" : "2020-04-02T10:15:00Z", - "temperature" : "15.0" + "time" : "2020-04-02T10:15:00Z", + "temperature" : "15.0" ] as LinkedHashMap, [ - "time" : "2020-04-02T10:30:00Z", - "temperature" : "10.0" + "time" : "2020-04-02T10:30:00Z", + "temperature" : "10.0" ] as LinkedHashMap ] as Set @@ -126,19 +126,19 @@ trait TimeSeriesTestData { Set> individualWindTimeSeriesProcessed = [ [ - "direction" : "5.0", - "time" : "2020-04-02T10:00:00Z", - "velocity" : "10.0" + "direction" : "5.0", + "time" : "2020-04-02T10:00:00Z", + "velocity" : "10.0" ] as LinkedHashMap, [ - "direction" : "15.0", - "time" : "2020-04-02T10:15:00Z", - "velocity" : "20.0" + "direction" : "15.0", + "time" : "2020-04-02T10:15:00Z", + "velocity" : "20.0" ] as LinkedHashMap, [ - "direction" : "10.0", - "time" : "2020-04-02T10:30:00Z", - "velocity" : "15.0" + "direction" : "10.0", + "time" : "2020-04-02T10:30:00Z", + "velocity" : "15.0" ] as LinkedHashMap ] as Set @@ -159,19 +159,19 @@ trait TimeSeriesTestData { Set> individualIrradianceTimeSeriesProcessed = [ [ - "directIrradiance" : "5.0", - "diffuseIrradiance" : "10.0", - "time" : "2020-04-02T10:00:00Z" + "directIrradiance" : "5.0", + "diffuseIrradiance" : "10.0", + "time" : "2020-04-02T10:00:00Z" ] as LinkedHashMap, [ - "directIrradiance" : "15.0", - "diffuseIrradiance" : "20.0", - "time" : "2020-04-02T10:15:00Z" + "directIrradiance" : "15.0", + "diffuseIrradiance" : "20.0", + "time" : "2020-04-02T10:15:00Z" ] as LinkedHashMap, [ - "directIrradiance" : "10.0", - "diffuseIrradiance" : "15.0", - "time" : "2020-04-02T10:30:00Z" + "directIrradiance" : "10.0", + "diffuseIrradiance" : "15.0", + "time" : "2020-04-02T10:30:00Z" ] as LinkedHashMap ] as Set @@ -184,7 +184,9 @@ trait TimeSeriesTestData { defaultLocation, new SolarIrradianceValue(Quantities.getQuantity(5d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(10d, StandardUnits.SOLAR_IRRADIANCE)), new TemperatureValue(Quantities.getQuantity(5d, CELSIUS)), - new WindValue(Quantities.getQuantity(5d, DEGREE_GEOM), Quantities.getQuantity(10d, METRE_PER_SECOND)) + new WindValue(Quantities.getQuantity(5d, DEGREE_GEOM), Quantities.getQuantity(10d, METRE_PER_SECOND)), + null, + null ) ), new TimeBasedValue<>( @@ -193,7 +195,9 @@ trait TimeSeriesTestData { defaultLocation, new SolarIrradianceValue(Quantities.getQuantity(15d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(20d, StandardUnits.SOLAR_IRRADIANCE)), new TemperatureValue(Quantities.getQuantity(15d, CELSIUS)), - new WindValue(Quantities.getQuantity(15d, DEGREE_GEOM), Quantities.getQuantity(20d, METRE_PER_SECOND)) + new WindValue(Quantities.getQuantity(15d, DEGREE_GEOM), Quantities.getQuantity(20d, METRE_PER_SECOND)), + null, + null ) ), new TimeBasedValue<>( @@ -202,7 +206,9 @@ trait TimeSeriesTestData { defaultLocation, new SolarIrradianceValue(Quantities.getQuantity(10d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(15d, StandardUnits.SOLAR_IRRADIANCE)), new TemperatureValue(Quantities.getQuantity(10d, CELSIUS)), - new WindValue(Quantities.getQuantity(10d, DEGREE_GEOM), Quantities.getQuantity(15d, METRE_PER_SECOND)) + new WindValue(Quantities.getQuantity(10d, DEGREE_GEOM), Quantities.getQuantity(15d, METRE_PER_SECOND)), + null, + null ) ), ] as Set @@ -210,31 +216,37 @@ trait TimeSeriesTestData { Set> individualWeatherTimeSeriesProcessed = [ [ - "coordinate" : "{\"type\":\"Point\",\"coordinates\":[7.412152,51.492758],\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}}}", - "diffuseIrradiance" : "10.0", - "directIrradiance" : "5.0", - "direction" : "5.0", - "temperature" : "5.0", - "time" : "2020-04-02T10:00:00Z", - "velocity" : "10.0" + "coordinate" : "{\"type\":\"Point\",\"coordinates\":[7.412152,51.492758],\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}}}", + "diffuseIrradiance" : "10.0", + "directIrradiance" : "5.0", + "direction" : "5.0", + "temperature" : "5.0", + "time" : "2020-04-02T10:00:00Z", + "velocity" : "10.0", + "groundTemperature0cm" : "", + "groundTemperature80cm" : "" ] as LinkedHashMap, [ - "coordinate" : "{\"type\":\"Point\",\"coordinates\":[7.412152,51.492758],\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}}}", - "diffuseIrradiance" : "20.0", - "directIrradiance" : "15.0", - "direction" : "15.0", - "temperature" : "15.0", - "time" : "2020-04-02T10:15:00Z", - "velocity" : "20.0" + "coordinate" : "{\"type\":\"Point\",\"coordinates\":[7.412152,51.492758],\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}}}", + "diffuseIrradiance" : "20.0", + "directIrradiance" : "15.0", + "direction" : "15.0", + "temperature" : "15.0", + "time" : "2020-04-02T10:15:00Z", + "velocity" : "20.0", + "groundTemperature0cm" : "", + "groundTemperature80cm" : "" ] as LinkedHashMap, [ - "coordinate" : "{\"type\":\"Point\",\"coordinates\":[7.412152,51.492758],\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}}}", - "diffuseIrradiance" : "15.0", - "directIrradiance" : "10.0", - "direction" : "10.0", - "temperature" : "10.0", - "time" : "2020-04-02T10:30:00Z", - "velocity" : "15.0" + "coordinate" : "{\"type\":\"Point\",\"coordinates\":[7.412152,51.492758],\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}}}", + "diffuseIrradiance" : "15.0", + "directIrradiance" : "10.0", + "direction" : "10.0", + "temperature" : "10.0", + "time" : "2020-04-02T10:30:00Z", + "velocity" : "15.0", + "groundTemperature0cm" : "", + "groundTemperature80cm" : "" ] as LinkedHashMap ] as Set @@ -255,16 +267,16 @@ trait TimeSeriesTestData { Set> individualHeatDemandTimeSeriesProcessed = [ [ - "heatDemand" : "5.0", - "time" : "2020-04-02T10:00:00Z" + "heatDemand" : "5.0", + "time" : "2020-04-02T10:00:00Z" ] as LinkedHashMap, [ - "heatDemand" : "15.0", - "time" : "2020-04-02T10:15:00Z" + "heatDemand" : "15.0", + "time" : "2020-04-02T10:15:00Z" ] as LinkedHashMap, [ - "heatDemand" : "10.0", - "time" : "2020-04-02T10:30:00Z" + "heatDemand" : "10.0", + "time" : "2020-04-02T10:30:00Z" ] as LinkedHashMap ] as Set @@ -285,16 +297,16 @@ trait TimeSeriesTestData { Set> individualPTimeSeriesProcessed = [ [ - "p" : "5.0", - "time" : "2020-04-02T10:00:00Z" + "p" : "5.0", + "time" : "2020-04-02T10:00:00Z" ] as LinkedHashMap, [ - "p" : "15.0", - "time" : "2020-04-02T10:15:00Z" + "p" : "15.0", + "time" : "2020-04-02T10:15:00Z" ] as LinkedHashMap, [ - "p" : "10.0", - "time" : "2020-04-02T10:30:00Z" + "p" : "10.0", + "time" : "2020-04-02T10:30:00Z" ] as LinkedHashMap ] as Set @@ -315,19 +327,19 @@ trait TimeSeriesTestData { Set> individualHeatAndPTimeSeriesProcessed = [ [ - "heatDemand" : "10.0", - "p" : "5.0", - "time" : "2020-04-02T10:00:00Z" + "heatDemand" : "10.0", + "p" : "5.0", + "time" : "2020-04-02T10:00:00Z" ] as LinkedHashMap, [ - "heatDemand" : "20.0", - "p" : "15.0", - "time" : "2020-04-02T10:15:00Z" + "heatDemand" : "20.0", + "p" : "15.0", + "time" : "2020-04-02T10:15:00Z" ] as LinkedHashMap, [ - "heatDemand" : "15.0", - "p" : "10.0", - "time" : "2020-04-02T10:30:00Z" + "heatDemand" : "15.0", + "p" : "10.0", + "time" : "2020-04-02T10:30:00Z" ] as LinkedHashMap ] as Set @@ -348,19 +360,19 @@ trait TimeSeriesTestData { Set> individualSTimeSeriesProcessed = [ [ - "p" : "5.0", - "q" : "10.0", - "time" : "2020-04-02T10:00:00Z" + "p" : "5.0", + "q" : "10.0", + "time" : "2020-04-02T10:00:00Z" ] as LinkedHashMap, [ - "p" : "15.0", - "q" : "20.0", - "time" : "2020-04-02T10:15:00Z" + "p" : "15.0", + "q" : "20.0", + "time" : "2020-04-02T10:15:00Z" ] as LinkedHashMap, [ - "p" : "10.0", - "q" : "15.0", - "time" : "2020-04-02T10:30:00Z" + "p" : "10.0", + "q" : "15.0", + "time" : "2020-04-02T10:30:00Z" ] as LinkedHashMap ] as Set @@ -381,22 +393,22 @@ trait TimeSeriesTestData { Set> individualHeatAndSTimeSeriesProcessed = [ [ - "heatDemand" : "15.0", - "p" : "5.0", - "q" : "10.0", - "time" : "2020-04-02T10:00:00Z" + "heatDemand" : "15.0", + "p" : "5.0", + "q" : "10.0", + "time" : "2020-04-02T10:00:00Z" ] as LinkedHashMap, [ - "heatDemand" : "25.0", - "p" : "15.0", - "q" : "20.0", - "time" : "2020-04-02T10:15:00Z" + "heatDemand" : "25.0", + "p" : "15.0", + "q" : "20.0", + "time" : "2020-04-02T10:15:00Z" ] as LinkedHashMap, [ - "heatDemand" : "20.0", - "p" : "10.0", - "q" : "15.0", - "time" : "2020-04-02T10:30:00Z" + "heatDemand" : "20.0", + "p" : "10.0", + "q" : "15.0", + "time" : "2020-04-02T10:30:00Z" ] as LinkedHashMap ] as Set diff --git a/src/test/resources/edu/ie3/datamodel/io/source/csv/_weather/cosmo/its_weather_8bc9120d-fb9b-4484-b4e3-0cdadf0feea9.csv b/src/test/resources/edu/ie3/datamodel/io/source/csv/_weather/cosmo/its_weather_8bc9120d-fb9b-4484-b4e3-0cdadf0feea9.csv index d73cac992..dc0379a97 100644 --- a/src/test/resources/edu/ie3/datamodel/io/source/csv/_weather/cosmo/its_weather_8bc9120d-fb9b-4484-b4e3-0cdadf0feea9.csv +++ b/src/test/resources/edu/ie3/datamodel/io/source/csv/_weather/cosmo/its_weather_8bc9120d-fb9b-4484-b4e3-0cdadf0feea9.csv @@ -1,7 +1,7 @@ -"uuid";"coordinate_id";"time";"diffuse_irradiance";"direct_irradiance";"temperature";"wind_direction";"wind_velocity" -"3cee46d5-1fe7-419e-a652-32f9be6703be";193186;2020-04-28T15:00:00Z;286.872985839844;282.671997070312;278.019012451172;0;1.66103506088257 -"1fbc6f7e-52fe-4668-93c8-33454d7feb6c";193187;2020-04-28T15:00:00Z;287.872985839844;283.671997070312;279.019012451172;0;1.76103506088257 -"78c7a057-ad6c-4ea1-bb74-7e28fbb08957";193188;2020-04-28T15:00:00Z;288.872985839844;284.671997070312;280.019012451172;0;1.86103506088257 -"b146fbff-ddd5-45b4-9d30-dd2a8550f7ba";193186;2020-04-28T16:00:00Z;286.872;282.672;278.012;0;1.662 -"7bdfb687-aa20-43af-8bbe-c23d9cc448ed";193187;2020-04-28T16:00:00Z;287.872;283.672;279.012;0;1.762 -"4d233e6a-9e01-4a46-bef6-88172ab366f4";193186;2020-04-28T17:00:00Z;286.873;282.673;278.013;0;1.663 \ No newline at end of file +"uuid";"coordinate_id";"time";"diffuse_irradiance";"direct_irradiance";"temperature";"wind_direction";"wind_velocity";"groundTemperature0cm";"groundTemperature80cm" +"3cee46d5-1fe7-419e-a652-32f9be6703be";193186;"2020-04-28T15:00:00Z";286.872985839844;282.671997070312;278.019012451172;0;1.66103506088257;279.5;281.0 +"1fbc6f7e-52fe-4668-93c8-33454d7feb6c";193187;"2020-04-28T15:00:00Z";287.872985839844;283.671997070312;279.019012451172;0;1.76103506088257;280.5;281.1 +"78c7a057-ad6c-4ea1-bb74-7e28fbb08957";193188;"2020-04-28T15:00:00Z";288.872985839844;284.671997070312;280.019012451172;0;1.86103506088257;281.5;281.2 +"b146fbff-ddd5-45b4-9d30-dd2a8550f7ba";193186;"2020-04-28T16:00:00Z";286.872;282.672;278.012;0;1.662;279.2;281.0 +"7bdfb687-aa20-43af-8bbe-c23d9cc448ed";193187;"2020-04-28T16:00:00Z";287.872;283.672;279.012;0;1.762;280.2;281.1 +"4d233e6a-9e01-4a46-bef6-88172ab366f4";193186;"2020-04-28T17:00:00Z";286.873;282.673;278.013;0;1.663;278.8;281.0 \ No newline at end of file diff --git a/src/test/resources/edu/ie3/datamodel/io/source/csv/_weather/icon/its_weather_513606bc-539e-445b-9675-2f98be3d9231.csv b/src/test/resources/edu/ie3/datamodel/io/source/csv/_weather/icon/its_weather_513606bc-539e-445b-9675-2f98be3d9231.csv index 7890a6d8a..03a87a39b 100644 --- a/src/test/resources/edu/ie3/datamodel/io/source/csv/_weather/icon/its_weather_513606bc-539e-445b-9675-2f98be3d9231.csv +++ b/src/test/resources/edu/ie3/datamodel/io/source/csv/_weather/icon/its_weather_513606bc-539e-445b-9675-2f98be3d9231.csv @@ -1,6 +1,6 @@ -"time","alb_rad","asob_s","aswdifd_s","aswdifu_s","aswdir_s","t_2m","t_g","u_10m","u_131m","u_20m","u_216m","u_65m","v_10m","v_131m","v_20m","v_216m","v_65m","w_131m","w_20m","w_216m","w_65m","z0","coordinate_id","p_131m","p_20m","p_65m","sobs_rad","t_131m" -2019-08-01T15:00:00Z,13.015240669,503.46974264373205,228.021339757131,80.8246124780934,356.2648859375,297.6241992659816,300.6632065668998,2.594603775363224,3.7658971156831287,2.5812495613105044,3.941521213236469,3.4740205817325034,-0.024078646721241395,-0.029760831916596106,-0.052967885304510534,-0.009698125518755707,-0.04996610799324721,0.004091443774095653,0.0015809058504647026,0.005954484657501378,0.002666343696204668,0.9553221665631989,67775,,,,, -2019-08-01T15:00:00Z,13.013334274000002,498.219742300774,245.24079037841295,80.0782271098217,333.0547140625,295.515335568404,297.43684351873816,2.6907481330116054,4.001601219938975,2.6888332994845783,4.140469437423411,3.714032263672762,1.2097386659833593,1.8148233176685413,1.1963736417917374,1.8944592514336933,1.667063608988315,-0.010735134459808796,-0.006350491263316599,-0.012234044440804974,-0.009044908476315713,0.955336762972383,67776,,,,, -2019-08-01T16:00:00Z,13.015240669,348.84439309613776,200.46049098038043,56.00436431107297,204.38963365625,297.3200023473353,298.8447737622156,2.557259341952788,4.0165196739267675,2.5543417132442308,4.204610497390883,3.6709121158156393,-0.38463576259530396,-0.5748064219197632,-0.4001297004267148,-0.574231301551345,-0.5484601012731134,0.008420781588303635,0.004028919955548831,0.0103738560877878,0.0064212084500956355,0.9553236526118866,67775,,,,, -2019-08-01T16:00:00Z,13.013334274000002,287.1635211775765,241.641483540946,46.18262289142059,91.70939132296976,293.455111314491,294.9876832274387,2.2429257128168105,3.288655459909278,2.2469304566362895,3.456196177795884,3.063505298416552,0.7052856075394569,1.0173658432825086,0.6940309956521304,1.0831645239762804,0.9402700184046242,-0.009609051331189665,-0.0037207462780739073,-0.01264290152206423,-0.006439463432156433,0.9553365723370035,67776,,,,, -2019-08-01T17:00:00Z,13.015240669,306.57139450950467,180.73429610400223,49.19860365549343,175.039569078125,296.8287403584074,297.6596017457568,2.2517126616190337,3.650669504895637,2.2438962003705027,3.7980736030429303,3.339152911211416,-0.6950893529619305,-1.1085323450143223,-0.7122478653505989,-1.1293057574368208,-1.0352309009257914,0.012464921655326946,0.0059655751175761145,0.015265360298047703,0.009632113129412919,0.9553227603369525,67775,,,,, +"time","alb_rad","asob_s","aswdifd_s","aswdifu_s","aswdir_s","t_2m","t_g","t80cm","u_10m","u_131m","u_20m","u_216m","u_65m","v_10m","v_131m","v_20m","v_216m","v_65m","w_131m","w_20m","w_216m","w_65m","z0","coordinate_id","p_131m","p_20m","p_65m","sobs_rad","t_131m" +"2019-08-01T15:00:00Z",13.015240669,503.46974264373205,228.021339757131,80.8246124780934,356.2648859375,297.6241992659816,300.6632065668998,289.5,2.594603775363224,3.7658971156831287,2.5812495613105044,3.941521213236469,3.4740205817325034,-0.024078646721241395,-0.029760831916596106,-0.052967885304510534,-0.009698125518755707,-0.04996610799324721,0.004091443774095653,0.0015809058504647026,0.005954484657501378,0.002666343696204668,0.9553221665631989,67775,,,,, +"2019-08-01T15:00:00Z",13.013334274000002,498.219742300774,245.24079037841295,80.0782271098217,333.0547140625,295.515335568404,297.43684351873816,289.2,2.6907481330116054,4.001601219938975,2.6888332994845783,4.140469437423411,3.714032263672762,1.2097386659833593,1.8148233176685413,1.1963736417917374,1.8944592514336933,1.667063608988315,-0.010735134459808796,-0.006350491263316599,-0.012234044440804974,-0.009044908476315713,0.955336762972383,67776,,,,, +"2019-08-01T16:00:00Z",13.015240669,348.84439309613776,200.46049098038043,56.00436431107297,204.38963365625,297.3200023473353,298.8447737622156,289.5,2.557259341952788,4.0165196739267675,2.5543417132442308,4.204610497390883,3.6709121158156393,-0.38463576259530396,-0.5748064219197632,-0.4001297004267148,-0.574231301551345,-0.5484601012731134,0.008420781588303635,0.004028919955548831,0.0103738560877878,0.0064212084500956355,0.9553236526118866,67775,,,,, +"2019-08-01T16:00:00Z",13.013334274000002,287.1635211775765,241.641483540946,46.18262289142059,91.70939132296976,293.455111314491,294.9876832274387,289.2,2.2429257128168105,3.288655459909278,2.2469304566362895,3.456196177795884,3.063505298416552,0.7052856075394569,1.0173658432825086,0.6940309956521304,1.0831645239762804,0.9402700184046242,-0.009609051331189665,-0.0037207462780739073,-0.01264290152206423,-0.006439463432156433,0.9553365723370035,67776,,,,, +"2019-08-01T17:00:00Z",13.015240669,306.57139450950467,180.73429610400223,49.19860365549343,175.039569078125,296.8287403584074,297.6596017457568,289.5,2.2517126616190337,3.650669504895637,2.2438962003705027,3.7980736030429303,3.339152911211416,-0.6950893529619305,-1.1085323450143223,-0.7122478653505989,-1.1293057574368208,-1.0352309009257914,0.012464921655326946,0.0059655751175761145,0.015265360298047703,0.009632113129412919,0.9553227603369525,67775,,,,, \ No newline at end of file From f0698b4fe4ab8c44d6ff53666c02d05bf9c3e26e Mon Sep 17 00:00:00 2001 From: pierrepetersmeier <155652256+pierrepetersmeier@users.noreply.github.com> Date: Sun, 19 Oct 2025 21:52:41 +0200 Subject: [PATCH 12/36] Fix SqlSinkTest --- .../resources/edu/ie3/datamodel/io/sink/_sql/time_series.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/resources/edu/ie3/datamodel/io/sink/_sql/time_series.sql b/src/test/resources/edu/ie3/datamodel/io/sink/_sql/time_series.sql index cdceb0e52..d2c2b12cf 100644 --- a/src/test/resources/edu/ie3/datamodel/io/sink/_sql/time_series.sql +++ b/src/test/resources/edu/ie3/datamodel/io/sink/_sql/time_series.sql @@ -99,6 +99,8 @@ CREATE TABLE public.time_series_weather direction DOUBLE PRECISION, temperature DOUBLE PRECISION, velocity DOUBLE PRECISION, + ground_temperature_0cm DOUBLE PRECISION, + ground_temperature_80cm DOUBLE PRECISION, grid_uuid UUID NOT NULL REFERENCES grids(uuid) ) WITHOUT OIDS From 1d9ff094b0284c4c7a100146fb3c1ee94561a6fe Mon Sep 17 00:00:00 2001 From: pierrepetersmeier <155652256+pierrepetersmeier@users.noreply.github.com> Date: Sun, 19 Oct 2025 21:58:27 +0200 Subject: [PATCH 13/36] fmt --- .../resources/edu/ie3/datamodel/io/sink/_sql/time_series.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/resources/edu/ie3/datamodel/io/sink/_sql/time_series.sql b/src/test/resources/edu/ie3/datamodel/io/sink/_sql/time_series.sql index d2c2b12cf..a96033649 100644 --- a/src/test/resources/edu/ie3/datamodel/io/sink/_sql/time_series.sql +++ b/src/test/resources/edu/ie3/datamodel/io/sink/_sql/time_series.sql @@ -100,7 +100,7 @@ CREATE TABLE public.time_series_weather temperature DOUBLE PRECISION, velocity DOUBLE PRECISION, ground_temperature_0cm DOUBLE PRECISION, - ground_temperature_80cm DOUBLE PRECISION, + ground_temperature_8_0cm DOUBLE PRECISION, grid_uuid UUID NOT NULL REFERENCES grids(uuid) ) WITHOUT OIDS From 4ec2c681ac30549bb3c57099619964d37eb9de5d Mon Sep 17 00:00:00 2001 From: pierrepetersmeier <155652256+pierrepetersmeier@users.noreply.github.com> Date: Sun, 19 Oct 2025 22:25:21 +0200 Subject: [PATCH 14/36] fmt --- .../timeseries/IconTimeBasedWeatherValueFactory.java | 8 ++++---- .../datamodel/models/value/GroundTemperatureValue.java | 1 + .../java/edu/ie3/datamodel/models/value/WeatherValue.java | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java index 774854fab..f0d949ea0 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java @@ -23,8 +23,8 @@ /** * Factory implementation of {@link TimeBasedWeatherValueFactory}, that is able to handle field to - * value mapping in the column scheme, ie³ uses to store its data from German Federal Weather - * Service's ICON-EU model + * value mapping in the column scheme, ie3 uses to store its data from German Federal + * Weather Service's ICON-EU model */ public class IconTimeBasedWeatherValueFactory extends TimeBasedWeatherValueFactory { /* Redefine the column names to meet the icon specifications */ @@ -55,8 +55,8 @@ protected List> getFields(Class entityClass) { "albrad", "asobs", "aswdifuS", - GROUND_TEMPERATURE_0CM, // Already present in ICON data - GROUND_TEMPERATURE_80CM, // New optional field + GROUND_TEMPERATURE_0CM, + GROUND_TEMPERATURE_80CM, "u10m", "u20m", "u216m", diff --git a/src/main/java/edu/ie3/datamodel/models/value/GroundTemperatureValue.java b/src/main/java/edu/ie3/datamodel/models/value/GroundTemperatureValue.java index fdc15c196..0ccdf34b2 100644 --- a/src/main/java/edu/ie3/datamodel/models/value/GroundTemperatureValue.java +++ b/src/main/java/edu/ie3/datamodel/models/value/GroundTemperatureValue.java @@ -3,6 +3,7 @@ * Institute of Energy Systems, Energy Efficiency and Energy Economics, * Research group Distribution grid planning and operation */ + package edu.ie3.datamodel.models.value; import javax.measure.quantity.Temperature; diff --git a/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java b/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java index 6d6ef284a..3b0c1b91c 100644 --- a/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java +++ b/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java @@ -189,4 +189,4 @@ public String toString() { + groundTemperature80cm + '}'; } -} +} \ No newline at end of file From f939e57bf26a9021b15de28e4e1a2ca0ff4b8484 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Mon, 20 Oct 2025 10:56:48 +0200 Subject: [PATCH 15/36] fmt --- .../edu/ie3/datamodel/models/value/GroundTemperatureValue.java | 1 - src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/edu/ie3/datamodel/models/value/GroundTemperatureValue.java b/src/main/java/edu/ie3/datamodel/models/value/GroundTemperatureValue.java index 0ccdf34b2..fdc15c196 100644 --- a/src/main/java/edu/ie3/datamodel/models/value/GroundTemperatureValue.java +++ b/src/main/java/edu/ie3/datamodel/models/value/GroundTemperatureValue.java @@ -3,7 +3,6 @@ * Institute of Energy Systems, Energy Efficiency and Energy Economics, * Research group Distribution grid planning and operation */ - package edu.ie3.datamodel.models.value; import javax.measure.quantity.Temperature; diff --git a/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java b/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java index 3b0c1b91c..6d6ef284a 100644 --- a/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java +++ b/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java @@ -189,4 +189,4 @@ public String toString() { + groundTemperature80cm + '}'; } -} \ No newline at end of file +} From 71ab33a0ed7fbca394a553629be95f4eaabbe2b4 Mon Sep 17 00:00:00 2001 From: Pierre <155652256+pierrepetersmeier@users.noreply.github.com> Date: Wed, 22 Oct 2025 21:28:46 +0200 Subject: [PATCH 16/36] Apply suggestion from @danielfeismann Co-authored-by: Daniel Feismann <98817556+danielfeismann@users.noreply.github.com> --- .../edu/ie3/datamodel/models/value/GroundTemperatureValue.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/edu/ie3/datamodel/models/value/GroundTemperatureValue.java b/src/main/java/edu/ie3/datamodel/models/value/GroundTemperatureValue.java index fdc15c196..021c79fd6 100644 --- a/src/main/java/edu/ie3/datamodel/models/value/GroundTemperatureValue.java +++ b/src/main/java/edu/ie3/datamodel/models/value/GroundTemperatureValue.java @@ -1,5 +1,5 @@ /* - * © 2021. TU Dortmund University, + * © 2025. TU Dortmund University, * Institute of Energy Systems, Energy Efficiency and Energy Economics, * Research group Distribution grid planning and operation */ From 224aa307ae192eec2cde72e71397aae696508b4b Mon Sep 17 00:00:00 2001 From: Pierre <155652256+pierrepetersmeier@users.noreply.github.com> Date: Wed, 22 Oct 2025 21:37:00 +0200 Subject: [PATCH 17/36] Update src/test/resources/edu/ie3/datamodel/io/source/csv/_weather/cosmo/its_weather_8bc9120d-fb9b-4484-b4e3-0cdadf0feea9.csv Co-authored-by: Daniel Feismann <98817556+danielfeismann@users.noreply.github.com> --- .../cosmo/its_weather_8bc9120d-fb9b-4484-b4e3-0cdadf0feea9.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/resources/edu/ie3/datamodel/io/source/csv/_weather/cosmo/its_weather_8bc9120d-fb9b-4484-b4e3-0cdadf0feea9.csv b/src/test/resources/edu/ie3/datamodel/io/source/csv/_weather/cosmo/its_weather_8bc9120d-fb9b-4484-b4e3-0cdadf0feea9.csv index dc0379a97..052b88e40 100644 --- a/src/test/resources/edu/ie3/datamodel/io/source/csv/_weather/cosmo/its_weather_8bc9120d-fb9b-4484-b4e3-0cdadf0feea9.csv +++ b/src/test/resources/edu/ie3/datamodel/io/source/csv/_weather/cosmo/its_weather_8bc9120d-fb9b-4484-b4e3-0cdadf0feea9.csv @@ -1,4 +1,4 @@ -"uuid";"coordinate_id";"time";"diffuse_irradiance";"direct_irradiance";"temperature";"wind_direction";"wind_velocity";"groundTemperature0cm";"groundTemperature80cm" +"uuid";"coordinate_id";"time";"diffuse_irradiance";"direct_irradiance";"temperature";"wind_direction";"wind_velocity";"groundTemperature_0cm";"groundTemperature_80cm" "3cee46d5-1fe7-419e-a652-32f9be6703be";193186;"2020-04-28T15:00:00Z";286.872985839844;282.671997070312;278.019012451172;0;1.66103506088257;279.5;281.0 "1fbc6f7e-52fe-4668-93c8-33454d7feb6c";193187;"2020-04-28T15:00:00Z";287.872985839844;283.671997070312;279.019012451172;0;1.76103506088257;280.5;281.1 "78c7a057-ad6c-4ea1-bb74-7e28fbb08957";193188;"2020-04-28T15:00:00Z";288.872985839844;284.671997070312;280.019012451172;0;1.86103506088257;281.5;281.2 From 6039cc2679367932afba6540ff422196f1f43b8a Mon Sep 17 00:00:00 2001 From: Pierre <155652256+pierrepetersmeier@users.noreply.github.com> Date: Wed, 22 Oct 2025 21:37:10 +0200 Subject: [PATCH 18/36] Update src/test/resources/edu/ie3/datamodel/io/sink/_sql/time_series.sql Co-authored-by: Daniel Feismann <98817556+danielfeismann@users.noreply.github.com> --- .../resources/edu/ie3/datamodel/io/sink/_sql/time_series.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/resources/edu/ie3/datamodel/io/sink/_sql/time_series.sql b/src/test/resources/edu/ie3/datamodel/io/sink/_sql/time_series.sql index a96033649..d2c2b12cf 100644 --- a/src/test/resources/edu/ie3/datamodel/io/sink/_sql/time_series.sql +++ b/src/test/resources/edu/ie3/datamodel/io/sink/_sql/time_series.sql @@ -100,7 +100,7 @@ CREATE TABLE public.time_series_weather temperature DOUBLE PRECISION, velocity DOUBLE PRECISION, ground_temperature_0cm DOUBLE PRECISION, - ground_temperature_8_0cm DOUBLE PRECISION, + ground_temperature_80cm DOUBLE PRECISION, grid_uuid UUID NOT NULL REFERENCES grids(uuid) ) WITHOUT OIDS From 46fb11ff6e648a2f801dd4ae077a99d5851f6ad9 Mon Sep 17 00:00:00 2001 From: pierrepetersmeier <155652256+pierrepetersmeier@users.noreply.github.com> Date: Wed, 22 Oct 2025 22:19:32 +0200 Subject: [PATCH 19/36] remove unused function --- .../java/edu/ie3/datamodel/io/factory/EntityData.java | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/main/java/edu/ie3/datamodel/io/factory/EntityData.java b/src/main/java/edu/ie3/datamodel/io/factory/EntityData.java index d7dfec458..6a5a51f3e 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/EntityData.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/EntityData.java @@ -60,16 +60,6 @@ public Class getTargetClass() { return (Class) super.getTargetClass(); } - /** - * Checks if the entity data contains the given field. - * - * @param field field name - * @return true if the field is present, false otherwise - */ - public boolean hasField(String field) { - return getFieldsToValues().containsKey(field); - } - /** * Returns boolean value for given field name. Throws {@link FactoryException} if field does not * exist, or field value is null or empty. From 3a0e1e9327fce95a983c9062350eb8d6ac79c978 Mon Sep 17 00:00:00 2001 From: pierrepetersmeier <155652256+pierrepetersmeier@users.noreply.github.com> Date: Fri, 31 Oct 2025 11:22:51 +0100 Subject: [PATCH 20/36] remove unused function and refactoring tests --- .../input/additionaldata/weathersource.md | 11 ++- .../IconTimeBasedWeatherValueFactory.java | 6 +- .../datamodel/models/value/WeatherValue.java | 86 ++++++------------- ...smoTimeBasedWeatherValueFactoryTest.groovy | 16 +++- ...conTimeBasedWeatherValueFactoryTest.groovy | 6 ++ .../datamodel/io/sink/_sql/time_series.sql | 4 +- ...r_8bc9120d-fb9b-4484-b4e3-0cdadf0feea9.csv | 2 +- ...r_513606bc-539e-445b-9675-2f98be3d9231.csv | 12 +-- 8 files changed, 66 insertions(+), 77 deletions(-) diff --git a/docs/readthedocs/models/input/additionaldata/weathersource.md b/docs/readthedocs/models/input/additionaldata/weathersource.md index b06322076..f3d2cb6ab 100644 --- a/docs/readthedocs/models/input/additionaldata/weathersource.md +++ b/docs/readthedocs/models/input/additionaldata/weathersource.md @@ -62,5 +62,14 @@ Weather data is comprised of five key components: * - **`windDirection`** - Wind direction, where 0° is North, 90° is East, etc. - ° (degrees) + + * - **`groundTemperatureValueOne`** + - Ground temperature at 0cm for this coordinate. + - K (Kelvin) + + * - **`groundTemperatureValueTwo`** + - Ground temperature at 0cm for this coordinate. + - K (Kelvin) ``` -Weather data in COSMO and ICON formats is supported. Additional optional weather data can also be provided. \ No newline at end of file +Weather data in COSMO and ICON formats is supported. Additional optional weather data can also be provided. +The ground temperature measurements at 0 cm and 80 cm depth are used because underground cables are typically laid at around 80 cm depth. \ No newline at end of file diff --git a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java index f0d949ea0..0ea90e126 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java @@ -33,7 +33,7 @@ public class IconTimeBasedWeatherValueFactory extends TimeBasedWeatherValueFacto private static final String TEMPERATURE = "t2m"; private static final String WIND_VELOCITY_U = "u131m"; private static final String WIND_VELOCITY_V = "v131m"; - private static final String GROUND_TEMPERATURE_0CM = "tG"; + private static final String GROUND_TEMPERATURE_0CM = "t0cm"; private static final String GROUND_TEMPERATURE_80CM = "t80cm"; public IconTimeBasedWeatherValueFactory() { @@ -92,9 +92,9 @@ protected TimeBasedValue buildModel(TimeBasedWeatherValueData data ComparableQuantity windDirection = getWindDirection(data); ComparableQuantity windVelocity = getWindVelocity(data); ComparableQuantity groundTemp0cm = - data.getQuantityOptional(GROUND_TEMPERATURE_0CM, StandardUnits.TEMPERATURE).orElse(null); + data.getQuantityOptional(GROUND_TEMPERATURE_0CM, Units.KELVIN).orElse(null); ComparableQuantity groundTemp80cm = - data.getQuantityOptional(GROUND_TEMPERATURE_80CM, StandardUnits.TEMPERATURE).orElse(null); + data.getQuantityOptional(GROUND_TEMPERATURE_80CM, Units.KELVIN).orElse(null); WeatherValue weatherValue = new WeatherValue( diff --git a/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java b/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java index 6d6ef284a..0b80e9af5 100644 --- a/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java +++ b/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java @@ -29,32 +29,32 @@ public class WeatherValue implements Value { private final WindValue wind; /** Ground temperature value at 0cm depth for this coordinate */ - private final GroundTemperatureValue groundTemperature0cm; + private final GroundTemperatureValue groundTemperatureValueOne; /** Ground temperature value at 80cm depth for this coordinate */ - private final GroundTemperatureValue groundTemperature80cm; + private final GroundTemperatureValue groundTemperatureValueTwo; /** * @param coordinate of this weather value set * @param solarIrradiance values for this coordinate * @param temperature values for this coordinate * @param wind values for this coordinate - * @param groundTemperature0cm values for this coordinate (can be null) - * @param groundTemperature80cm values for this coordinate (can be null) + * @param groundTemperatureValueOne values for this coordinate (can be null) + * @param groundTemperatureValueTwo values for this coordinate (can be null) */ public WeatherValue( Point coordinate, SolarIrradianceValue solarIrradiance, TemperatureValue temperature, WindValue wind, - GroundTemperatureValue groundTemperature0cm, - GroundTemperatureValue groundTemperature80cm) { + GroundTemperatureValue groundTemperatureValueOne, + GroundTemperatureValue groundTemperatureValueTwo) { this.coordinate = coordinate; this.solarIrradiance = solarIrradiance; this.temperature = temperature; this.wind = wind; - this.groundTemperature0cm = groundTemperature0cm; - this.groundTemperature80cm = groundTemperature80cm; + this.groundTemperatureValueOne = groundTemperatureValueOne; + this.groundTemperatureValueTwo = groundTemperatureValueTwo; } /** @@ -67,9 +67,9 @@ public WeatherValue( * @param direction Direction, the wind comes from as an angle from north increasing clockwise * (typically in rad) * @param velocity Wind velocity for this coordinate (typically in m/s) - * @param groundTemp0cm Ground temperature at 0cm for this coordinate (typically in K, can be + * @param groundTempValOne Ground temperature at 0cm for this coordinate (typically in K, can be * null) - * @param groundTemp80cm Ground temperature at 80cm for this coordinate (typically in K, can be + * @param groundTempValTwo Ground temperature at 80cm for this coordinate (typically in K, can be * null) */ public WeatherValue( @@ -79,49 +79,15 @@ public WeatherValue( ComparableQuantity temperature, ComparableQuantity direction, ComparableQuantity velocity, - ComparableQuantity groundTemp0cm, - ComparableQuantity groundTemp80cm) { + ComparableQuantity groundTempValOne, + ComparableQuantity groundTempValTwo) { this( coordinate, new SolarIrradianceValue(directSolarIrradiance, diffuseSolarIrradiance), new TemperatureValue(temperature), new WindValue(direction, velocity), - groundTemp0cm == null ? null : new GroundTemperatureValue(groundTemp0cm), - groundTemp80cm == null ? null : new GroundTemperatureValue(groundTemp80cm)); - } - - /** - * @deprecated Use the constructor that includes ground temperatures instead - */ - @Deprecated(since = "3.0", forRemoval = true) - public WeatherValue( - Point coordinate, - SolarIrradianceValue solarIrradiance, - TemperatureValue temperature, - WindValue wind) { - this(coordinate, solarIrradiance, temperature, wind, null, null); - } - - /** - * @deprecated Use the constructor that includes ground temperatures instead - */ - @Deprecated(since = "3.0", forRemoval = true) - public WeatherValue( - Point coordinate, - ComparableQuantity directSolarIrradiance, - ComparableQuantity diffuseSolarIrradiance, - ComparableQuantity temperature, - ComparableQuantity direction, - ComparableQuantity velocity) { - this( - coordinate, - directSolarIrradiance, - diffuseSolarIrradiance, - temperature, - direction, - velocity, - null, - null); + groundTempValOne == null ? null : new GroundTemperatureValue(groundTempValOne), + groundTempValTwo == null ? null : new GroundTemperatureValue(groundTempValTwo)); } public Point getCoordinate() { @@ -140,12 +106,12 @@ public WindValue getWind() { return wind; } - public Optional getGroundTemperature0cm() { - return Optional.ofNullable(groundTemperature0cm); + public Optional getGroundTemperatureValueOne() { + return Optional.ofNullable(groundTemperatureValueOne); } - public Optional getGroundTemperature80cm() { - return Optional.ofNullable(groundTemperature80cm); + public Optional getGroundTemperatureValueTwo() { + return Optional.ofNullable(groundTemperatureValueTwo); } @Override @@ -157,8 +123,8 @@ public boolean equals(Object o) { && solarIrradiance.equals(that.solarIrradiance) && temperature.equals(that.temperature) && wind.equals(that.wind) - && Objects.equals(groundTemperature0cm, that.groundTemperature0cm) - && Objects.equals(groundTemperature80cm, that.groundTemperature80cm); + && Objects.equals(groundTemperatureValueOne, that.groundTemperatureValueOne) + && Objects.equals(groundTemperatureValueTwo, that.groundTemperatureValueTwo); } @Override @@ -168,8 +134,8 @@ public int hashCode() { solarIrradiance, temperature, wind, - groundTemperature0cm, - groundTemperature80cm); + groundTemperatureValueOne, + groundTemperatureValueTwo); } @Override @@ -183,10 +149,10 @@ public String toString() { + temperature + ", wind=" + wind - + ", groundTemperature0cm=" - + groundTemperature0cm - + ", groundTemperature80cm=" - + groundTemperature80cm + + ", groundTemperatureValueOne=" + + groundTemperatureValueOne + + ", groundTemperatureValueTwo=" + + groundTemperatureValueOne + '}'; } } diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy index e85aebf3b..339c52cce 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy @@ -28,7 +28,9 @@ class CosmoTimeBasedWeatherValueFactoryTest extends Specification { "directIrradiance" : "286.872985839844", "temperature" : "", "windDirection" : "0", - "windVelocity" : "1.66103506088257" + "windVelocity" : "1.66103506088257", + "groundTemperatureValueOne" : "", + "groundTemperatureValueTwo" : "" ] def data = new TimeBasedWeatherValueData(parameter, coordinate) @@ -39,7 +41,9 @@ class CosmoTimeBasedWeatherValueFactoryTest extends Specification { Quantities.getQuantity(282.671997070312d, StandardUnits.SOLAR_IRRADIANCE), null, Quantities.getQuantity(0d, StandardUnits.WIND_DIRECTION), - Quantities.getQuantity(1.66103506088257d, StandardUnits.WIND_VELOCITY))) + Quantities.getQuantity(1.66103506088257d, StandardUnits.WIND_VELOCITY), + null, + null)) when: def model = factory.buildModel(data) @@ -61,7 +65,9 @@ class CosmoTimeBasedWeatherValueFactoryTest extends Specification { "directIrradiance" : "286.872985839844", "temperature" : "278.019012451172", "windDirection" : "0", - "windVelocity" : "1.66103506088257" + "windVelocity" : "1.66103506088257", + "groundTemperatureValueOne" : "", + "groundTemperatureValueTwo" : "" ] def data = new TimeBasedWeatherValueData(parameter, coordinate) @@ -72,7 +78,9 @@ class CosmoTimeBasedWeatherValueFactoryTest extends Specification { Quantities.getQuantity(282.671997070312d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE), Quantities.getQuantity(0d, StandardUnits.WIND_DIRECTION), - Quantities.getQuantity(1.66103506088257d, StandardUnits.WIND_VELOCITY))) + Quantities.getQuantity(1.66103506088257d, StandardUnits.WIND_VELOCITY), + Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE), + Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE))) when: def model = factory.buildModel(data) diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactoryTest.groovy index cac18982c..4b085b70a 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactoryTest.groovy @@ -84,6 +84,8 @@ class IconTimeBasedWeatherValueFactoryTest extends Specification { "aswdirS" : "2.317613203124999", "t2m" : "289.1179319051744", "tg" : "288.4101691197649", + "t_v1":"288.4101691197649", + "t_v2":"288.4101691197649", "u10m" : "0.3021732864307963", "u131m" : "2.6058700426057797", "u20m" : "0.32384365019387784", @@ -125,6 +127,10 @@ class IconTimeBasedWeatherValueFactoryTest extends Specification { assert QuantityUtil.isEquivalentAbs(it.value.wind.direction.get(), Quantities.getQuantity(214.16711674907722, PowerSystemUnits.DEGREE_GEOM)) assert it.value.wind.velocity.present assert QuantityUtil.isEquivalentAbs(it.value.wind.velocity.get(), Quantities.getQuantity(4.640010877529081, PowerSystemUnits.METRE_PER_SECOND)) + assert it.value.groundTemperatureValueOne.present + assert QuantityUtil.isEquivalentAbs(it.value.groundTemperatureValueOne.get().temperature.get(), Quantities.getQuantity(15.9679319051744, Units.CELSIUS)) + assert it.value.groundTemperatureValueTwo.present + assert QuantityUtil.isEquivalentAbs(it.value.groundTemperatureValueTwo.get().temperature.get(), Quantities.getQuantity(15.9679319051744, Units.CELSIUS)) } } } diff --git a/src/test/resources/edu/ie3/datamodel/io/sink/_sql/time_series.sql b/src/test/resources/edu/ie3/datamodel/io/sink/_sql/time_series.sql index d2c2b12cf..cfe9ddb46 100644 --- a/src/test/resources/edu/ie3/datamodel/io/sink/_sql/time_series.sql +++ b/src/test/resources/edu/ie3/datamodel/io/sink/_sql/time_series.sql @@ -99,8 +99,8 @@ CREATE TABLE public.time_series_weather direction DOUBLE PRECISION, temperature DOUBLE PRECISION, velocity DOUBLE PRECISION, - ground_temperature_0cm DOUBLE PRECISION, - ground_temperature_80cm DOUBLE PRECISION, + ground_temperature_value_one DOUBLE PRECISION, + ground_temperature_value_two DOUBLE PRECISION, grid_uuid UUID NOT NULL REFERENCES grids(uuid) ) WITHOUT OIDS diff --git a/src/test/resources/edu/ie3/datamodel/io/source/csv/_weather/cosmo/its_weather_8bc9120d-fb9b-4484-b4e3-0cdadf0feea9.csv b/src/test/resources/edu/ie3/datamodel/io/source/csv/_weather/cosmo/its_weather_8bc9120d-fb9b-4484-b4e3-0cdadf0feea9.csv index 052b88e40..78140a740 100644 --- a/src/test/resources/edu/ie3/datamodel/io/source/csv/_weather/cosmo/its_weather_8bc9120d-fb9b-4484-b4e3-0cdadf0feea9.csv +++ b/src/test/resources/edu/ie3/datamodel/io/source/csv/_weather/cosmo/its_weather_8bc9120d-fb9b-4484-b4e3-0cdadf0feea9.csv @@ -1,4 +1,4 @@ -"uuid";"coordinate_id";"time";"diffuse_irradiance";"direct_irradiance";"temperature";"wind_direction";"wind_velocity";"groundTemperature_0cm";"groundTemperature_80cm" +"uuid";"coordinate_id";"time";"diffuse_irradiance";"direct_irradiance";"temperature";"wind_direction";"wind_velocity";"ground_temperature_value_one";"ground_temperature_value_two" "3cee46d5-1fe7-419e-a652-32f9be6703be";193186;"2020-04-28T15:00:00Z";286.872985839844;282.671997070312;278.019012451172;0;1.66103506088257;279.5;281.0 "1fbc6f7e-52fe-4668-93c8-33454d7feb6c";193187;"2020-04-28T15:00:00Z";287.872985839844;283.671997070312;279.019012451172;0;1.76103506088257;280.5;281.1 "78c7a057-ad6c-4ea1-bb74-7e28fbb08957";193188;"2020-04-28T15:00:00Z";288.872985839844;284.671997070312;280.019012451172;0;1.86103506088257;281.5;281.2 diff --git a/src/test/resources/edu/ie3/datamodel/io/source/csv/_weather/icon/its_weather_513606bc-539e-445b-9675-2f98be3d9231.csv b/src/test/resources/edu/ie3/datamodel/io/source/csv/_weather/icon/its_weather_513606bc-539e-445b-9675-2f98be3d9231.csv index 03a87a39b..0eecd99d4 100644 --- a/src/test/resources/edu/ie3/datamodel/io/source/csv/_weather/icon/its_weather_513606bc-539e-445b-9675-2f98be3d9231.csv +++ b/src/test/resources/edu/ie3/datamodel/io/source/csv/_weather/icon/its_weather_513606bc-539e-445b-9675-2f98be3d9231.csv @@ -1,6 +1,6 @@ -"time","alb_rad","asob_s","aswdifd_s","aswdifu_s","aswdir_s","t_2m","t_g","t80cm","u_10m","u_131m","u_20m","u_216m","u_65m","v_10m","v_131m","v_20m","v_216m","v_65m","w_131m","w_20m","w_216m","w_65m","z0","coordinate_id","p_131m","p_20m","p_65m","sobs_rad","t_131m" -"2019-08-01T15:00:00Z",13.015240669,503.46974264373205,228.021339757131,80.8246124780934,356.2648859375,297.6241992659816,300.6632065668998,289.5,2.594603775363224,3.7658971156831287,2.5812495613105044,3.941521213236469,3.4740205817325034,-0.024078646721241395,-0.029760831916596106,-0.052967885304510534,-0.009698125518755707,-0.04996610799324721,0.004091443774095653,0.0015809058504647026,0.005954484657501378,0.002666343696204668,0.9553221665631989,67775,,,,, -"2019-08-01T15:00:00Z",13.013334274000002,498.219742300774,245.24079037841295,80.0782271098217,333.0547140625,295.515335568404,297.43684351873816,289.2,2.6907481330116054,4.001601219938975,2.6888332994845783,4.140469437423411,3.714032263672762,1.2097386659833593,1.8148233176685413,1.1963736417917374,1.8944592514336933,1.667063608988315,-0.010735134459808796,-0.006350491263316599,-0.012234044440804974,-0.009044908476315713,0.955336762972383,67776,,,,, -"2019-08-01T16:00:00Z",13.015240669,348.84439309613776,200.46049098038043,56.00436431107297,204.38963365625,297.3200023473353,298.8447737622156,289.5,2.557259341952788,4.0165196739267675,2.5543417132442308,4.204610497390883,3.6709121158156393,-0.38463576259530396,-0.5748064219197632,-0.4001297004267148,-0.574231301551345,-0.5484601012731134,0.008420781588303635,0.004028919955548831,0.0103738560877878,0.0064212084500956355,0.9553236526118866,67775,,,,, -"2019-08-01T16:00:00Z",13.013334274000002,287.1635211775765,241.641483540946,46.18262289142059,91.70939132296976,293.455111314491,294.9876832274387,289.2,2.2429257128168105,3.288655459909278,2.2469304566362895,3.456196177795884,3.063505298416552,0.7052856075394569,1.0173658432825086,0.6940309956521304,1.0831645239762804,0.9402700184046242,-0.009609051331189665,-0.0037207462780739073,-0.01264290152206423,-0.006439463432156433,0.9553365723370035,67776,,,,, -"2019-08-01T17:00:00Z",13.015240669,306.57139450950467,180.73429610400223,49.19860365549343,175.039569078125,296.8287403584074,297.6596017457568,289.5,2.2517126616190337,3.650669504895637,2.2438962003705027,3.7980736030429303,3.339152911211416,-0.6950893529619305,-1.1085323450143223,-0.7122478653505989,-1.1293057574368208,-1.0352309009257914,0.012464921655326946,0.0059655751175761145,0.015265360298047703,0.009632113129412919,0.9553227603369525,67775,,,,, \ No newline at end of file +"time","alb_rad","asob_s","aswdifd_s","aswdifu_s","aswdir_s","t_2m","t_g","t_v1","t_v2","u_10m","u_131m","u_20m","u_216m","u_65m","v_10m","v_131m","v_20m","v_216m","v_65m","w_131m","w_20m","w_216m","w_65m","z0","coordinate_id","p_131m","p_20m","p_65m","sobs_rad","t_131m" +"2019-08-01T15:00:00Z",13.015240669,503.46974264373205,228.021339757131,80.8246124780934,356.2648859375,297.6241992659816,300.6632065668998,300.6632065668998,289.5,2.594603775363224,3.7658971156831287,2.5812495613105044,3.941521213236469,3.4740205817325034,-0.024078646721241395,-0.029760831916596106,-0.052967885304510534,-0.009698125518755707,-0.04996610799324721,0.004091443774095653,0.0015809058504647026,0.005954484657501378,0.002666343696204668,0.9553221665631989,67775,,,,, +"2019-08-01T15:00:00Z",13.013334274000002,498.219742300774,245.24079037841295,80.0782271098217,333.0547140625,295.515335568404,297.43684351873816,300.6632065668998,289.2,2.6907481330116054,4.001601219938975,2.6888332994845783,4.140469437423411,3.714032263672762,1.2097386659833593,1.8148233176685413,1.1963736417917374,1.8944592514336933,1.667063608988315,-0.010735134459808796,-0.006350491263316599,-0.012234044440804974,-0.009044908476315713,0.955336762972383,67776,,,,, +"2019-08-01T16:00:00Z",13.015240669,348.84439309613776,200.46049098038043,56.00436431107297,204.38963365625,297.3200023473353,298.8447737622156,300.6632065668998,289.5,2.557259341952788,4.0165196739267675,2.5543417132442308,4.204610497390883,3.6709121158156393,-0.38463576259530396,-0.5748064219197632,-0.4001297004267148,-0.574231301551345,-0.5484601012731134,0.008420781588303635,0.004028919955548831,0.0103738560877878,0.0064212084500956355,0.9553236526118866,67775,,,,, +"2019-08-01T16:00:00Z",13.013334274000002,287.1635211775765,241.641483540946,46.18262289142059,91.70939132296976,293.455111314491,294.9876832274387,300.6632065668998,289.2,2.2429257128168105,3.288655459909278,2.2469304566362895,3.456196177795884,3.063505298416552,0.7052856075394569,1.0173658432825086,0.6940309956521304,1.0831645239762804,0.9402700184046242,-0.009609051331189665,-0.0037207462780739073,-0.01264290152206423,-0.006439463432156433,0.9553365723370035,67776,,,,, +"2019-08-01T17:00:00Z",13.015240669,306.57139450950467,180.73429610400223,49.19860365549343,175.039569078125,296.8287403584074,297.6596017457568,300.6632065668998,289.5,2.2517126616190337,3.650669504895637,2.2438962003705027,3.7980736030429303,3.339152911211416,-0.6950893529619305,-1.1085323450143223,-0.7122478653505989,-1.1293057574368208,-1.0352309009257914,0.012464921655326946,0.0059655751175761145,0.015265360298047703,0.009632113129412919,0.9553227603369525,67775,,,,, \ No newline at end of file From 57640e2d437d11a46280cb5b7bc581f1b8e48135 Mon Sep 17 00:00:00 2001 From: pierrepetersmeier <155652256+pierrepetersmeier@users.noreply.github.com> Date: Sun, 2 Nov 2025 18:35:39 +0100 Subject: [PATCH 21/36] fmt --- .../CosmoTimeBasedWeatherValueFactoryTest.groovy | 4 ++-- .../IconTimeBasedWeatherValueFactoryTest.groovy | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy index 339c52cce..4c33c2e48 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy @@ -79,8 +79,8 @@ class CosmoTimeBasedWeatherValueFactoryTest extends Specification { Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE), Quantities.getQuantity(0d, StandardUnits.WIND_DIRECTION), Quantities.getQuantity(1.66103506088257d, StandardUnits.WIND_VELOCITY), - Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE), - Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE))) + Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE), + Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE))) when: def model = factory.buildModel(data) diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactoryTest.groovy index 4b085b70a..81909c630 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactoryTest.groovy @@ -84,7 +84,7 @@ class IconTimeBasedWeatherValueFactoryTest extends Specification { "aswdirS" : "2.317613203124999", "t2m" : "289.1179319051744", "tg" : "288.4101691197649", - "t_v1":"288.4101691197649", + "t_v1":"288.4101691197649", "t_v2":"288.4101691197649", "u10m" : "0.3021732864307963", "u131m" : "2.6058700426057797", @@ -127,10 +127,10 @@ class IconTimeBasedWeatherValueFactoryTest extends Specification { assert QuantityUtil.isEquivalentAbs(it.value.wind.direction.get(), Quantities.getQuantity(214.16711674907722, PowerSystemUnits.DEGREE_GEOM)) assert it.value.wind.velocity.present assert QuantityUtil.isEquivalentAbs(it.value.wind.velocity.get(), Quantities.getQuantity(4.640010877529081, PowerSystemUnits.METRE_PER_SECOND)) - assert it.value.groundTemperatureValueOne.present - assert QuantityUtil.isEquivalentAbs(it.value.groundTemperatureValueOne.get().temperature.get(), Quantities.getQuantity(15.9679319051744, Units.CELSIUS)) - assert it.value.groundTemperatureValueTwo.present - assert QuantityUtil.isEquivalentAbs(it.value.groundTemperatureValueTwo.get().temperature.get(), Quantities.getQuantity(15.9679319051744, Units.CELSIUS)) + assert it.value.groundTemperatureValueOne.present + assert QuantityUtil.isEquivalentAbs(it.value.groundTemperatureValueOne.get().temperature.get(), Quantities.getQuantity(15.9679319051744, Units.CELSIUS)) + assert it.value.groundTemperatureValueTwo.present + assert QuantityUtil.isEquivalentAbs(it.value.groundTemperatureValueTwo.get().temperature.get(), Quantities.getQuantity(15.9679319051744, Units.CELSIUS)) } } } From 1c5c4ba67f192a2636d65c0c2b4735a9f6196b67 Mon Sep 17 00:00:00 2001 From: pierrepetersmeier <155652256+pierrepetersmeier@users.noreply.github.com> Date: Sun, 2 Nov 2025 21:31:28 +0100 Subject: [PATCH 22/36] InfluxDB --- .../edu/ie3/datamodel/models/value/WeatherValue.java | 2 +- .../io/source/influxdb/_weather/cosmo/weather.txt | 12 ++++++------ .../io/source/influxdb/_weather/icon/weather.txt | 10 +++++----- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java b/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java index 0b80e9af5..6065cd7b9 100644 --- a/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java +++ b/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java @@ -152,7 +152,7 @@ public String toString() { + ", groundTemperatureValueOne=" + groundTemperatureValueOne + ", groundTemperatureValueTwo=" - + groundTemperatureValueOne + + groundTemperatureValueTwo + '}'; } } diff --git a/src/test/resources/edu/ie3/datamodel/io/source/influxdb/_weather/cosmo/weather.txt b/src/test/resources/edu/ie3/datamodel/io/source/influxdb/_weather/cosmo/weather.txt index 982e7ea5b..5b7ec9400 100644 --- a/src/test/resources/edu/ie3/datamodel/io/source/influxdb/_weather/cosmo/weather.txt +++ b/src/test/resources/edu/ie3/datamodel/io/source/influxdb/_weather/cosmo/weather.txt @@ -5,9 +5,9 @@ CREATE DATABASE test_weather # CONTEXT-DATABASE: test_weather -weather,coordinate_id=193186 diffuse_irradiance=286.872985839844,direct_irradiance=282.671997070312,temperature=278.019012451172,wind_direction=0,wind_velocity=1.66103506088257 1588086000000 -weather,coordinate_id=193187 diffuse_irradiance=287.872985839844,direct_irradiance=283.671997070312,temperature=279.019012451172,wind_direction=0,wind_velocity=1.76103506088257 1588086000000 -weather,coordinate_id=193188 diffuse_irradiance=288.872985839844,direct_irradiance=284.671997070312,temperature=280.019012451172,wind_direction=0,wind_velocity=1.86103506088257 1588086000000 -weather,coordinate_id=193186 diffuse_irradiance=286.872,direct_irradiance=282.672,temperature=278.012,wind_direction=0,wind_velocity=1.662 1588089600000 -weather,coordinate_id=193187 diffuse_irradiance=287.872,direct_irradiance=283.672,temperature=279.012,wind_direction=0,wind_velocity=1.762 1588089600000 -weather,coordinate_id=193186 diffuse_irradiance=286.873,direct_irradiance=282.673,temperature=278.013,wind_direction=0,wind_velocity=1.663 1588093200000 +weather,coordinate_id=193186 diffuse_irradiance=286.872985839844,direct_irradiance=282.671997070312,temperature=278.019012451172,wind_direction=0,wind_velocity=1.66103506088257, groundtemperature_value_one=278.019012451172, groundtemperature_value_two=278.019012451172 1588086000000 +weather,coordinate_id=193187 diffuse_irradiance=287.872985839844,direct_irradiance=283.671997070312,temperature=279.019012451172,wind_direction=0,wind_velocity=1.76103506088257, groundtemperature_value_one=278.019012451172, groundtemperature_value_two=278.019012451172 1588086000000 +weather,coordinate_id=193188 diffuse_irradiance=288.872985839844,direct_irradiance=284.671997070312,temperature=280.019012451172,wind_direction=0,wind_velocity=1.86103506088257, groundtemperature_value_one=278.019012451172, groundtemperature_value_two=278.019012451172 1588086000000 +weather,coordinate_id=193186 diffuse_irradiance=286.872,direct_irradiance=282.672,temperature=278.012,wind_direction=0,wind_velocity=1.662, groundtemperature_value_one=278.019012451172, groundtemperature_value_two=278.019012451172 1588089600000 +weather,coordinate_id=193187 diffuse_irradiance=287.872,direct_irradiance=283.672,temperature=279.012,wind_direction=0,wind_velocity=1.762, groundtemperature_value_one=278.019012451172, groundtemperature_value_two=278.019012451172 1588089600000 +weather,coordinate_id=193186 diffuse_irradiance=286.873,direct_irradiance=282.673,temperature=278.013,wind_direction=0,wind_velocity=1.663, groundtemperature_value_one=278.019012451172, groundtemperature_value_two=278.019012451172 1588093200000 diff --git a/src/test/resources/edu/ie3/datamodel/io/source/influxdb/_weather/icon/weather.txt b/src/test/resources/edu/ie3/datamodel/io/source/influxdb/_weather/icon/weather.txt index 1057060a2..043676904 100644 --- a/src/test/resources/edu/ie3/datamodel/io/source/influxdb/_weather/icon/weather.txt +++ b/src/test/resources/edu/ie3/datamodel/io/source/influxdb/_weather/icon/weather.txt @@ -5,8 +5,8 @@ CREATE DATABASE test_weather # CONTEXT-DATABASE: test_weather -weather,coordinate_id=67775 alb_rad=13.0152406690000007,asob_s=503.46974264373199,aswdifd_s=228.021339757130988,aswdifu_s=80.8246124780933997,aswdir_s=356.264885937500026,t_2m=297.624199265981986,t_g=300.663206566899987,u_10m=2.59460377536322007,u_131m=3.76589711568313001,u_20m=2.58124956131049998,u_216m=3.94152121323647009,u_65m=3.47402058173249983,v_10m=-0.0240786467212413986,v_131m=-0.0297608319165960991,v_20m=-0.0529678853045104994,v_216m=-0.00969812551875571041,v_65m=-0.0499661079932472024,w_131m=0.00409144377409564972,w_20m=0.00158090585046470004,w_216m=0.00595448465750138007,w_65m=0.00266634369620467014,z_0=0.955322166563199016,p_131m=42.0,p_20m=42.0,p_65m=42.0,sobsrad=42.0,t_131m=42.0 1564671600000 -weather,coordinate_id=67775 alb_rad=13.0152406690000007,asob_s=348.844393096137992,aswdifd_s=200.460490980380001,aswdifu_s=56.0043643110729974,aswdir_s=204.389633656249998,t_2m=297.320002347334992,t_g=298.844773762215993,u_10m=2.55725934195278981,u_131m=4.01651967392677012,u_20m=2.55434171324422987,u_216m=4.20461049739088022,u_65m=3.67091211581564014,v_10m=-0.38463576259530402,v_131m=-0.574806421919763055,v_20m=-0.400129700426714974,v_216m=-0.574231301551345052,v_65m=-0.548460101273112954,w_131m=0.00842078158830364062,w_20m=0.0040289199555488299,w_216m=0.0103738560877878003,w_65m=0.00642120845009563988,z_0=0.955323652611887009,p_131m=42.0,p_20m=42.0,p_65m=42.0,sobsrad=42.0,t_131m=42.0 1564675200000 -weather,coordinate_id=67775 alb_rad=13.0152406690000007,asob_s=306.571394509505012,aswdifd_s=180.734296104001999,aswdifu_s=49.1986036554934003,aswdir_s=175.039569078124998,t_2m=296.828740358407003,t_g=297.659601745757016,u_10m=2.25171266161903016,u_131m=3.65066950489564013,u_20m=2.24389620037050008,u_216m=3.79807360304292985,u_65m=3.33915291121141999,v_10m=-0.695089352961929974,v_131m=-1.10853234501432008,v_20m=-0.71224786535059903,v_216m=-1.12930575743681993,v_65m=-1.03523090092579007,w_131m=0.0124649216553269007,w_20m=0.00596557511757611018,w_216m=0.0152653602980476998,w_65m=0.00963211312941292079,z_0=0.955322760336951959,p_131m=42.0,p_20m=42.0,p_65m=42.0,sobsrad=42.0,t_131m=42.0 1564678800000 -weather,coordinate_id=67776 alb_rad=13.013334274,asob_s=498.219742300773987,aswdifd_s=245.24079037841301,aswdifu_s=80.0782271098216967,aswdir_s=333.054714062500011,t_2m=295.515335568403998,t_g=297.436843518737987,u_10m=2.69074813301160987,u_131m=4.00160121993897988,u_20m=2.68883329948458005,u_216m=4.14046943742340989,u_65m=3.71403226367276007,v_10m=1.20973866598336,v_131m=1.81482331766853999,v_20m=1.19637364179174011,v_216m=1.89445925143368998,v_65m=1.66706360898831996,w_131m=-0.0107351344598088008,w_20m=-0.00635049126331660007,w_216m=-0.0122340444408049996,w_65m=-0.00904490847631570991,z_0=0.955336762972383013,p_131m=42.0,p_20m=42.0,p_65m=42.0,sobsrad=42.0,t_131m=42.0 1564671600000 -weather,coordinate_id=67776 alb_rad=13.013334274,asob_s=287.163521177577024,aswdifd_s=241.641483540946012,aswdifu_s=46.1826228914205998,aswdir_s=91.7093913229697932,t_2m=293.455111314490978,t_g=294.987683227438993,u_10m=2.24292571281681008,u_131m=3.28865545990927988,u_20m=2.24693045663628999,u_216m=3.45619617779588006,u_65m=3.06350529841654984,v_10m=0.705285607539457016,v_131m=1.0173658432825099,v_20m=0.694030995652130001,v_216m=1.08316452397627994,v_65m=0.940270018404623986,w_131m=-0.00960905133118966984,w_20m=-0.00372074627807390985,w_216m=-0.0126429015220642007,w_65m=-0.00643946343215642987,z_0=0.955336572337003975,p_131m=42.0,p_20m=42.0,p_65m=42.0,sobsrad=42.0,t_131m=42.0 1564675200000 +weather,coordinate_id=67775 alb_rad=13.0152406690000007,asob_s=503.46974264373199,aswdifd_s=228.021339757130988,aswdifu_s=80.8246124780933997,aswdir_s=356.264885937500026,t_2m=297.624199265981986,t_g=300.663206566899987,t_v1=300.663206566899987,t_v2=300.663206566899987,u_10m=2.59460377536322007,u_131m=3.76589711568313001,u_20m=2.58124956131049998,u_216m=3.94152121323647009,u_65m=3.47402058173249983,v_10m=-0.0240786467212413986,v_131m=-0.0297608319165960991,v_20m=-0.0529678853045104994,v_216m=-0.00969812551875571041,v_65m=-0.0499661079932472024,w_131m=0.00409144377409564972,w_20m=0.00158090585046470004,w_216m=0.00595448465750138007,w_65m=0.00266634369620467014,z_0=0.955322166563199016,p_131m=42.0,p_20m=42.0,p_65m=42.0,sobsrad=42.0,t_131m=42.0 1564671600000 +weather,coordinate_id=67775 alb_rad=13.0152406690000007,asob_s=348.844393096137992,aswdifd_s=200.460490980380001,aswdifu_s=56.0043643110729974,aswdir_s=204.389633656249998,t_2m=297.320002347334992,t_g=298.844773762215993,t_v1=300.663206566899987,t_v2=300.663206566899987,u_10m=2.55725934195278981,u_131m=4.01651967392677012,u_20m=2.55434171324422987,u_216m=4.20461049739088022,u_65m=3.67091211581564014,v_10m=-0.38463576259530402,v_131m=-0.574806421919763055,v_20m=-0.400129700426714974,v_216m=-0.574231301551345052,v_65m=-0.548460101273112954,w_131m=0.00842078158830364062,w_20m=0.0040289199555488299,w_216m=0.0103738560877878003,w_65m=0.00642120845009563988,z_0=0.955323652611887009,p_131m=42.0,p_20m=42.0,p_65m=42.0,sobsrad=42.0,t_131m=42.0 1564675200000 +weather,coordinate_id=67775 alb_rad=13.0152406690000007,asob_s=306.571394509505012,aswdifd_s=180.734296104001999,aswdifu_s=49.1986036554934003,aswdir_s=175.039569078124998,t_2m=296.828740358407003,t_g=297.659601745757016,t_v1=300.663206566899987,t_v2=300.663206566899987,u_10m=2.25171266161903016,u_131m=3.65066950489564013,u_20m=2.24389620037050008,u_216m=3.79807360304292985,u_65m=3.33915291121141999,v_10m=-0.695089352961929974,v_131m=-1.10853234501432008,v_20m=-0.71224786535059903,v_216m=-1.12930575743681993,v_65m=-1.03523090092579007,w_131m=0.0124649216553269007,w_20m=0.00596557511757611018,w_216m=0.0152653602980476998,w_65m=0.00963211312941292079,z_0=0.955322760336951959,p_131m=42.0,p_20m=42.0,p_65m=42.0,sobsrad=42.0,t_131m=42.0 1564678800000 +weather,coordinate_id=67776 alb_rad=13.013334274,asob_s=498.219742300773987,aswdifd_s=245.24079037841301,aswdifu_s=80.0782271098216967,aswdir_s=333.054714062500011,t_2m=295.515335568403998,t_g=297.436843518737987,t_v1=300.663206566899987,t_v2=300.663206566899987,u_10m=2.69074813301160987,u_131m=4.00160121993897988,u_20m=2.68883329948458005,u_216m=4.14046943742340989,u_65m=3.71403226367276007,v_10m=1.20973866598336,v_131m=1.81482331766853999,v_20m=1.19637364179174011,v_216m=1.89445925143368998,v_65m=1.66706360898831996,w_131m=-0.0107351344598088008,w_20m=-0.00635049126331660007,w_216m=-0.0122340444408049996,w_65m=-0.00904490847631570991,z_0=0.955336762972383013,p_131m=42.0,p_20m=42.0,p_65m=42.0,sobsrad=42.0,t_131m=42.0 1564671600000 +weather,coordinate_id=67776 alb_rad=13.013334274,asob_s=287.163521177577024,aswdifd_s=241.641483540946012,aswdifu_s=46.1826228914205998,aswdir_s=91.7093913229697932,t_2m=293.455111314490978,t_g=294.987683227438993,t_v1=300.663206566899987,t_v2=300.663206566899987,u_10m=2.24292571281681008,u_131m=3.28865545990927988,u_20m=2.24693045663628999,u_216m=3.45619617779588006,u_65m=3.06350529841654984,v_10m=0.705285607539457016,v_131m=1.0173658432825099,v_20m=0.694030995652130001,v_216m=1.08316452397627994,v_65m=0.940270018404623986,w_131m=-0.00960905133118966984,w_20m=-0.00372074627807390985,w_216m=-0.0126429015220642007,w_65m=-0.00643946343215642987,z_0=0.955336572337003975,p_131m=42.0,p_20m=42.0,p_65m=42.0,sobsrad=42.0,t_131m=42.0 1564675200000 From 3be844f06e6d75d9ca690595f2b7880c1e10ddd9 Mon Sep 17 00:00:00 2001 From: pierrepetersmeier <155652256+pierrepetersmeier@users.noreply.github.com> Date: Sun, 2 Nov 2025 21:59:28 +0100 Subject: [PATCH 23/36] TestData --- .../csv/CsvWeatherSourceCosmoTest.groovy | 20 ++++++++++++++----- .../UniquenessValidationUtilsTest.groovy | 9 +++++++-- .../test/common/CosmoWeatherTestData.groovy | 12 +++++++++++ .../test/common/IconWeatherTestData.groovy | 10 ++++++++++ 4 files changed, 44 insertions(+), 7 deletions(-) diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceCosmoTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceCosmoTest.groovy index cc5e709f2..16a0320ee 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceCosmoTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceCosmoTest.groovy @@ -125,7 +125,9 @@ class CsvWeatherSourceCosmoTest extends Specification implements CsvTestDataMeta "diffuseIrradiance": "5.678", "temperature" : "9.1011", "windVelocity" : "12.1314", - "windDirection" : "15.1617" + "windDirection" : "15.1617", + "groundtemperatureone": "8.0", + "groundtemperaturetwo": "9.5" ] def expectedValue = new TimeBasedValue( TimeUtil.withDefaults.toZonedDateTime("2020-10-16T12:40:42Z"), @@ -140,7 +142,9 @@ class CsvWeatherSourceCosmoTest extends Specification implements CsvTestDataMeta ), new WindValue( Quantities.getQuantity(12.1314, WIND_DIRECTION), - Quantities.getQuantity(15.1617, WIND_VELOCITY) + Quantities.getQuantity(15.1617, WIND_VELOCITY), + Quantities.getQuantity(9.1011, TEMPERATURE) + ) ) ) @@ -168,7 +172,9 @@ class CsvWeatherSourceCosmoTest extends Specification implements CsvTestDataMeta "diffuseirradiance": "5.678", "temperature" : "9.1011", "windvelocity" : "12.1314", - "winddirection" : "15.1617" + "winddirection" : "15.1617", + "groundtemperatureone": "8.0", + "groundtemperaturetwo": "9.5" ] when: @@ -192,7 +198,9 @@ class CsvWeatherSourceCosmoTest extends Specification implements CsvTestDataMeta "diffuseirradiance": "5.678", "temperature" : "9.1011", "windvelocity" : "12.1314", - "winddirection" : "15.1617" + "winddirection" : "15.1617", + "groundtemperatureone": "8.0", + "groundtemperaturetwo": "9.5" ] when: @@ -216,7 +224,9 @@ class CsvWeatherSourceCosmoTest extends Specification implements CsvTestDataMeta "diffuseirradiance": "5.678", "temperature" : "9.1011", "windvelocity" : "12.1314", - "winddirection" : "15.1617" + "winddirection" : "15.1617", + "groundtemperatureone": "8.0", + "groundtemperaturetwo": "9.5" ] when: diff --git a/src/test/groovy/edu/ie3/datamodel/utils/validation/UniquenessValidationUtilsTest.groovy b/src/test/groovy/edu/ie3/datamodel/utils/validation/UniquenessValidationUtilsTest.groovy index 92169b0bf..474416e9b 100644 --- a/src/test/groovy/edu/ie3/datamodel/utils/validation/UniquenessValidationUtilsTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/utils/validation/UniquenessValidationUtilsTest.groovy @@ -21,6 +21,7 @@ import edu.ie3.datamodel.models.result.CongestionResult import edu.ie3.datamodel.models.result.NodeResult import edu.ie3.datamodel.models.result.ResultEntity import edu.ie3.datamodel.models.timeseries.individual.TimeBasedValue +import edu.ie3.datamodel.models.value.GroundTemperatureValue import edu.ie3.datamodel.models.value.SolarIrradianceValue import edu.ie3.datamodel.models.value.TemperatureValue import edu.ie3.datamodel.models.value.WeatherValue @@ -210,7 +211,9 @@ class UniquenessValidationUtilsTest extends Specification { GeoUtils.buildPoint(50d, 7d), new SolarIrradianceValue(Quantities.getQuantity(10d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(10d, StandardUnits.SOLAR_IRRADIANCE)), new TemperatureValue(Quantities.getQuantity(5d, Units.CELSIUS)), - new WindValue(Quantities.getQuantity(5d, DEGREE_GEOM), Quantities.getQuantity(10d, METRE_PER_SECOND)) + new WindValue(Quantities.getQuantity(5d, DEGREE_GEOM), Quantities.getQuantity(10d, METRE_PER_SECOND)), + new GroundTemperatureValue(Quantities.getQuantity(5d, Units.CELSIUS)), + new GroundTemperatureValue(Quantities.getQuantity(5d, Units.CELSIUS)) ) Set> uniqueValues = [ @@ -232,7 +235,9 @@ class UniquenessValidationUtilsTest extends Specification { GeoUtils.buildPoint(50d, 7d), new SolarIrradianceValue(Quantities.getQuantity(10d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(10d, StandardUnits.SOLAR_IRRADIANCE)), new TemperatureValue(Quantities.getQuantity(5d, Units.CELSIUS)), - new WindValue(Quantities.getQuantity(5d, DEGREE_GEOM), Quantities.getQuantity(10d, METRE_PER_SECOND)) + new WindValue(Quantities.getQuantity(5d, DEGREE_GEOM), Quantities.getQuantity(10d, METRE_PER_SECOND)), + new GroundTemperatureValue(Quantities.getQuantity(5d, Units.CELSIUS)), + new GroundTemperatureValue(Quantities.getQuantity(5d, Units.CELSIUS)) ) Set> notUniqueValues = [ new TimeBasedValue(time, value), diff --git a/src/test/groovy/edu/ie3/test/common/CosmoWeatherTestData.groovy b/src/test/groovy/edu/ie3/test/common/CosmoWeatherTestData.groovy index ac4412c8e..152c6c7ff 100644 --- a/src/test/groovy/edu/ie3/test/common/CosmoWeatherTestData.groovy +++ b/src/test/groovy/edu/ie3/test/common/CosmoWeatherTestData.groovy @@ -24,6 +24,8 @@ class CosmoWeatherTestData extends WeatherTestData { Quantities.getQuantity(286.872985839844d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE), Quantities.getQuantity(0d, StandardUnits.WIND_DIRECTION), + Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE), + Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE), Quantities.getQuantity(1.66103506088257d, StandardUnits.WIND_VELOCITY) ) @@ -33,6 +35,8 @@ class CosmoWeatherTestData extends WeatherTestData { Quantities.getQuantity(286.872d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(278.012d, StandardUnits.TEMPERATURE), Quantities.getQuantity(0d, StandardUnits.WIND_DIRECTION), + Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE), + Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE), Quantities.getQuantity(1.662d, StandardUnits.WIND_VELOCITY) ) @@ -42,6 +46,8 @@ class CosmoWeatherTestData extends WeatherTestData { Quantities.getQuantity(286.873d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(278.013d, StandardUnits.TEMPERATURE), Quantities.getQuantity(0d, StandardUnits.WIND_DIRECTION), + Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE), + Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE), Quantities.getQuantity(1.663d, StandardUnits.WIND_VELOCITY) ) @@ -51,6 +57,8 @@ class CosmoWeatherTestData extends WeatherTestData { Quantities.getQuantity(287.872985839844d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(279.019012451172d, StandardUnits.TEMPERATURE), Quantities.getQuantity(0d, StandardUnits.WIND_DIRECTION), + Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE), + Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE), Quantities.getQuantity(1.76103506088257d, StandardUnits.WIND_VELOCITY) ) @@ -60,6 +68,8 @@ class CosmoWeatherTestData extends WeatherTestData { Quantities.getQuantity(287.872d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(279.012d, StandardUnits.TEMPERATURE), Quantities.getQuantity(0d, StandardUnits.WIND_DIRECTION), + Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE), + Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE), Quantities.getQuantity(1.762d, StandardUnits.WIND_VELOCITY) ) @@ -69,6 +79,8 @@ class CosmoWeatherTestData extends WeatherTestData { Quantities.getQuantity(288.872985839844d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(280.019012451172d, StandardUnits.TEMPERATURE), Quantities.getQuantity(0d, StandardUnits.WIND_DIRECTION), + Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE), + Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE), Quantities.getQuantity(1.86103506088257d, StandardUnits.WIND_VELOCITY) ) } diff --git a/src/test/groovy/edu/ie3/test/common/IconWeatherTestData.groovy b/src/test/groovy/edu/ie3/test/common/IconWeatherTestData.groovy index 0a251f9d3..16ef4202a 100644 --- a/src/test/groovy/edu/ie3/test/common/IconWeatherTestData.groovy +++ b/src/test/groovy/edu/ie3/test/common/IconWeatherTestData.groovy @@ -24,6 +24,8 @@ class IconWeatherTestData extends WeatherTestData { Quantities.getQuantity(228.021339757131, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(24.4741992659816, StandardUnits.TEMPERATURE), Quantities.getQuantity(270.45278309919627, StandardUnits.WIND_DIRECTION), + Quantities.getQuantity(24.4741992659816, StandardUnits.TEMPERATURE), + Quantities.getQuantity(24.4741992659816, StandardUnits.TEMPERATURE), Quantities.getQuantity(3.76601470961371, StandardUnits.WIND_VELOCITY) ) @@ -33,6 +35,8 @@ class IconWeatherTestData extends WeatherTestData { Quantities.getQuantity(200.46049098038043, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(24.1700023473353, StandardUnits.TEMPERATURE), Quantities.getQuantity(278.144331776102, StandardUnits.WIND_DIRECTION), + Quantities.getQuantity(24.4741992659816, StandardUnits.TEMPERATURE), + Quantities.getQuantity(24.4741992659816, StandardUnits.TEMPERATURE), Quantities.getQuantity(4.05744164637287, StandardUnits.WIND_VELOCITY) ) @@ -42,6 +46,8 @@ class IconWeatherTestData extends WeatherTestData { Quantities.getQuantity(180.73429610400223, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(23.6787403584074, StandardUnits.TEMPERATURE), Quantities.getQuantity(286.891007103442, StandardUnits.WIND_DIRECTION), + Quantities.getQuantity(24.4741992659816, StandardUnits.TEMPERATURE), + Quantities.getQuantity(24.4741992659816, StandardUnits.TEMPERATURE), Quantities.getQuantity(3.81526300455393, StandardUnits.WIND_VELOCITY) ) @@ -51,6 +57,8 @@ class IconWeatherTestData extends WeatherTestData { Quantities.getQuantity(245.24079037841295, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(22.365335568404, StandardUnits.TEMPERATURE), Quantities.getQuantity(245.604554131632, StandardUnits.WIND_DIRECTION), + Quantities.getQuantity(24.4741992659816, StandardUnits.TEMPERATURE), + Quantities.getQuantity(24.4741992659816, StandardUnits.TEMPERATURE), Quantities.getQuantity(4.39390441381814, StandardUnits.WIND_VELOCITY) ) @@ -60,6 +68,8 @@ class IconWeatherTestData extends WeatherTestData { Quantities.getQuantity(241.641483540946, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(20.305111314491, StandardUnits.TEMPERATURE), Quantities.getQuantity(252.810224701109, StandardUnits.WIND_DIRECTION), + Quantities.getQuantity(24.4741992659816, StandardUnits.TEMPERATURE), + Quantities.getQuantity(24.4741992659816, StandardUnits.TEMPERATURE), Quantities.getQuantity(3.44242472583919, StandardUnits.WIND_VELOCITY) ) } From 3f04286309a6a5b29147e248588b8dac55292bed Mon Sep 17 00:00:00 2001 From: pierrepetersmeier <155652256+pierrepetersmeier@users.noreply.github.com> Date: Sun, 2 Nov 2025 22:11:46 +0100 Subject: [PATCH 24/36] fmt --- .../test/common/CosmoWeatherTestData.groovy | 24 +++++++++---------- .../test/common/IconWeatherTestData.groovy | 20 ++++++++-------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/test/groovy/edu/ie3/test/common/CosmoWeatherTestData.groovy b/src/test/groovy/edu/ie3/test/common/CosmoWeatherTestData.groovy index 152c6c7ff..948887023 100644 --- a/src/test/groovy/edu/ie3/test/common/CosmoWeatherTestData.groovy +++ b/src/test/groovy/edu/ie3/test/common/CosmoWeatherTestData.groovy @@ -24,9 +24,9 @@ class CosmoWeatherTestData extends WeatherTestData { Quantities.getQuantity(286.872985839844d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE), Quantities.getQuantity(0d, StandardUnits.WIND_DIRECTION), + Quantities.getQuantity(1.66103506088257d, StandardUnits.WIND_VELOCITY), Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE), - Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE), - Quantities.getQuantity(1.66103506088257d, StandardUnits.WIND_VELOCITY) + Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE) ) public static final WeatherValue WEATHER_VALUE_193186_16H = new WeatherValue( @@ -35,9 +35,9 @@ class CosmoWeatherTestData extends WeatherTestData { Quantities.getQuantity(286.872d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(278.012d, StandardUnits.TEMPERATURE), Quantities.getQuantity(0d, StandardUnits.WIND_DIRECTION), + Quantities.getQuantity(1.662d, StandardUnits.WIND_VELOCITY), Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE), - Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE), - Quantities.getQuantity(1.662d, StandardUnits.WIND_VELOCITY) + Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE) ) public static final WeatherValue WEATHER_VALUE_193186_17H = new WeatherValue( @@ -46,9 +46,9 @@ class CosmoWeatherTestData extends WeatherTestData { Quantities.getQuantity(286.873d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(278.013d, StandardUnits.TEMPERATURE), Quantities.getQuantity(0d, StandardUnits.WIND_DIRECTION), + Quantities.getQuantity(1.663d, StandardUnits.WIND_VELOCITY), Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE), - Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE), - Quantities.getQuantity(1.663d, StandardUnits.WIND_VELOCITY) + Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE) ) public static final WeatherValue WEATHER_VALUE_193187_15H = new WeatherValue( @@ -57,9 +57,9 @@ class CosmoWeatherTestData extends WeatherTestData { Quantities.getQuantity(287.872985839844d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(279.019012451172d, StandardUnits.TEMPERATURE), Quantities.getQuantity(0d, StandardUnits.WIND_DIRECTION), + Quantities.getQuantity(1.76103506088257d, StandardUnits.WIND_VELOCITY), Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE), - Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE), - Quantities.getQuantity(1.76103506088257d, StandardUnits.WIND_VELOCITY) + Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE) ) public static final WeatherValue WEATHER_VALUE_193187_16H = new WeatherValue( @@ -68,9 +68,9 @@ class CosmoWeatherTestData extends WeatherTestData { Quantities.getQuantity(287.872d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(279.012d, StandardUnits.TEMPERATURE), Quantities.getQuantity(0d, StandardUnits.WIND_DIRECTION), + Quantities.getQuantity(1.762d, StandardUnits.WIND_VELOCITY), Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE), - Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE), - Quantities.getQuantity(1.762d, StandardUnits.WIND_VELOCITY) + Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE) ) public static final WeatherValue WEATHER_VALUE_193188_15H = new WeatherValue( @@ -79,8 +79,8 @@ class CosmoWeatherTestData extends WeatherTestData { Quantities.getQuantity(288.872985839844d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(280.019012451172d, StandardUnits.TEMPERATURE), Quantities.getQuantity(0d, StandardUnits.WIND_DIRECTION), + Quantities.getQuantity(1.86103506088257d, StandardUnits.WIND_VELOCITY), Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE), - Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE), - Quantities.getQuantity(1.86103506088257d, StandardUnits.WIND_VELOCITY) + Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE) ) } diff --git a/src/test/groovy/edu/ie3/test/common/IconWeatherTestData.groovy b/src/test/groovy/edu/ie3/test/common/IconWeatherTestData.groovy index 16ef4202a..be04a77de 100644 --- a/src/test/groovy/edu/ie3/test/common/IconWeatherTestData.groovy +++ b/src/test/groovy/edu/ie3/test/common/IconWeatherTestData.groovy @@ -24,9 +24,9 @@ class IconWeatherTestData extends WeatherTestData { Quantities.getQuantity(228.021339757131, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(24.4741992659816, StandardUnits.TEMPERATURE), Quantities.getQuantity(270.45278309919627, StandardUnits.WIND_DIRECTION), + Quantities.getQuantity(3.76601470961371, StandardUnits.WIND_VELOCITY), Quantities.getQuantity(24.4741992659816, StandardUnits.TEMPERATURE), - Quantities.getQuantity(24.4741992659816, StandardUnits.TEMPERATURE), - Quantities.getQuantity(3.76601470961371, StandardUnits.WIND_VELOCITY) + Quantities.getQuantity(24.4741992659816, StandardUnits.TEMPERATURE) ) public static final WeatherValue WEATHER_VALUE_67775_16H = new WeatherValue( @@ -35,9 +35,9 @@ class IconWeatherTestData extends WeatherTestData { Quantities.getQuantity(200.46049098038043, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(24.1700023473353, StandardUnits.TEMPERATURE), Quantities.getQuantity(278.144331776102, StandardUnits.WIND_DIRECTION), + Quantities.getQuantity(4.05744164637287, StandardUnits.WIND_VELOCITY), Quantities.getQuantity(24.4741992659816, StandardUnits.TEMPERATURE), - Quantities.getQuantity(24.4741992659816, StandardUnits.TEMPERATURE), - Quantities.getQuantity(4.05744164637287, StandardUnits.WIND_VELOCITY) + Quantities.getQuantity(24.4741992659816, StandardUnits.TEMPERATURE) ) public static final WeatherValue WEATHER_VALUE_67775_17H = new WeatherValue( @@ -46,9 +46,9 @@ class IconWeatherTestData extends WeatherTestData { Quantities.getQuantity(180.73429610400223, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(23.6787403584074, StandardUnits.TEMPERATURE), Quantities.getQuantity(286.891007103442, StandardUnits.WIND_DIRECTION), + Quantities.getQuantity(3.81526300455393, StandardUnits.WIND_VELOCITY), Quantities.getQuantity(24.4741992659816, StandardUnits.TEMPERATURE), - Quantities.getQuantity(24.4741992659816, StandardUnits.TEMPERATURE), - Quantities.getQuantity(3.81526300455393, StandardUnits.WIND_VELOCITY) + Quantities.getQuantity(24.4741992659816, StandardUnits.TEMPERATURE) ) public static final WeatherValue WEATHER_VALUE_67776_15H = new WeatherValue( @@ -57,9 +57,9 @@ class IconWeatherTestData extends WeatherTestData { Quantities.getQuantity(245.24079037841295, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(22.365335568404, StandardUnits.TEMPERATURE), Quantities.getQuantity(245.604554131632, StandardUnits.WIND_DIRECTION), + Quantities.getQuantity(4.39390441381814, StandardUnits.WIND_VELOCITY), Quantities.getQuantity(24.4741992659816, StandardUnits.TEMPERATURE), - Quantities.getQuantity(24.4741992659816, StandardUnits.TEMPERATURE), - Quantities.getQuantity(4.39390441381814, StandardUnits.WIND_VELOCITY) + Quantities.getQuantity(24.4741992659816, StandardUnits.TEMPERATURE) ) public static final WeatherValue WEATHER_VALUE_67776_16H = new WeatherValue( @@ -68,8 +68,8 @@ class IconWeatherTestData extends WeatherTestData { Quantities.getQuantity(241.641483540946, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(20.305111314491, StandardUnits.TEMPERATURE), Quantities.getQuantity(252.810224701109, StandardUnits.WIND_DIRECTION), + Quantities.getQuantity(3.44242472583919, StandardUnits.WIND_VELOCITY), Quantities.getQuantity(24.4741992659816, StandardUnits.TEMPERATURE), - Quantities.getQuantity(24.4741992659816, StandardUnits.TEMPERATURE), - Quantities.getQuantity(3.44242472583919, StandardUnits.WIND_VELOCITY) + Quantities.getQuantity(24.4741992659816, StandardUnits.TEMPERATURE) ) } From c8f0d184460d6a3aec96a38c5873c7f42535e2cd Mon Sep 17 00:00:00 2001 From: pierrepetersmeier <155652256+pierrepetersmeier@users.noreply.github.com> Date: Sun, 2 Nov 2025 22:49:57 +0100 Subject: [PATCH 25/36] fmt --- .../IconTimeBasedWeatherValueFactory.java | 21 ++++++++++--------- .../csv/CsvWeatherSourceCosmoTest.groovy | 4 ++-- .../ie3/test/common/TimeSeriesTestData.groovy | 12 +++++------ .../influxdb/_weather/cosmo/weather.txt | 12 +++++------ 4 files changed, 25 insertions(+), 24 deletions(-) diff --git a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java index 0ea90e126..29e8dda3c 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java @@ -33,8 +33,8 @@ public class IconTimeBasedWeatherValueFactory extends TimeBasedWeatherValueFacto private static final String TEMPERATURE = "t2m"; private static final String WIND_VELOCITY_U = "u131m"; private static final String WIND_VELOCITY_V = "v131m"; - private static final String GROUND_TEMPERATURE_0CM = "t0cm"; - private static final String GROUND_TEMPERATURE_80CM = "t80cm"; + private static final String GROUND_TEMPERATURE_VALUE_ONE = "groundtemperatureone"; + private static final String GROUND_TEMPERATURE_VALUE_TWO = "groundtemperaturetwo"; public IconTimeBasedWeatherValueFactory() { super(); @@ -55,8 +55,9 @@ protected List> getFields(Class entityClass) { "albrad", "asobs", "aswdifuS", - GROUND_TEMPERATURE_0CM, - GROUND_TEMPERATURE_80CM, + "t_g", + "t_v1", + "t_v2", "u10m", "u20m", "u216m", @@ -91,10 +92,10 @@ protected TimeBasedValue buildModel(TimeBasedWeatherValueData data data.getQuantity(TEMPERATURE, Units.KELVIN).to(StandardUnits.TEMPERATURE); ComparableQuantity windDirection = getWindDirection(data); ComparableQuantity windVelocity = getWindVelocity(data); - ComparableQuantity groundTemp0cm = - data.getQuantityOptional(GROUND_TEMPERATURE_0CM, Units.KELVIN).orElse(null); - ComparableQuantity groundTemp80cm = - data.getQuantityOptional(GROUND_TEMPERATURE_80CM, Units.KELVIN).orElse(null); + ComparableQuantity groundTemperatureValueOne = + data.getQuantityOptional(GROUND_TEMPERATURE_VALUE_ONE, Units.KELVIN).orElse(null); + ComparableQuantity groundTemperatureValueTwo = + data.getQuantityOptional(GROUND_TEMPERATURE_VALUE_TWO, Units.KELVIN).orElse(null); WeatherValue weatherValue = new WeatherValue( @@ -104,8 +105,8 @@ protected TimeBasedValue buildModel(TimeBasedWeatherValueData data temperature, windDirection, windVelocity, - groundTemp0cm, - groundTemp80cm); + groundTemperatureValueOne, + groundTemperatureValueTwo); return new TimeBasedValue<>(time, weatherValue); } diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceCosmoTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceCosmoTest.groovy index 16a0320ee..62e9fd27c 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceCosmoTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceCosmoTest.groovy @@ -143,8 +143,8 @@ class CsvWeatherSourceCosmoTest extends Specification implements CsvTestDataMeta new WindValue( Quantities.getQuantity(12.1314, WIND_DIRECTION), Quantities.getQuantity(15.1617, WIND_VELOCITY), - Quantities.getQuantity(9.1011, TEMPERATURE) - + Quantities.getQuantity(8, TEMPERATURE), + Quantities.getQuantity(9.5, TEMPERATURE) ) ) ) diff --git a/src/test/groovy/edu/ie3/test/common/TimeSeriesTestData.groovy b/src/test/groovy/edu/ie3/test/common/TimeSeriesTestData.groovy index 53893169c..ccef99eb0 100644 --- a/src/test/groovy/edu/ie3/test/common/TimeSeriesTestData.groovy +++ b/src/test/groovy/edu/ie3/test/common/TimeSeriesTestData.groovy @@ -223,8 +223,8 @@ trait TimeSeriesTestData { "temperature" : "5.0", "time" : "2020-04-02T10:00:00Z", "velocity" : "10.0", - "groundTemperature0cm" : "", - "groundTemperature80cm" : "" + "groundTemperatureValueOne" : "", + "groundTemperatureValueTwo" : "" ] as LinkedHashMap, [ "coordinate" : "{\"type\":\"Point\",\"coordinates\":[7.412152,51.492758],\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}}}", @@ -234,8 +234,8 @@ trait TimeSeriesTestData { "temperature" : "15.0", "time" : "2020-04-02T10:15:00Z", "velocity" : "20.0", - "groundTemperature0cm" : "", - "groundTemperature80cm" : "" + "groundTemperatureValueOne" : "", + "groundTemperatureValueTwo" : "" ] as LinkedHashMap, [ "coordinate" : "{\"type\":\"Point\",\"coordinates\":[7.412152,51.492758],\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}}}", @@ -245,8 +245,8 @@ trait TimeSeriesTestData { "temperature" : "10.0", "time" : "2020-04-02T10:30:00Z", "velocity" : "15.0", - "groundTemperature0cm" : "", - "groundTemperature80cm" : "" + "groundTemperatureValueOne" : "", + "groundTemperatureValueTwo" : "" ] as LinkedHashMap ] as Set diff --git a/src/test/resources/edu/ie3/datamodel/io/source/influxdb/_weather/cosmo/weather.txt b/src/test/resources/edu/ie3/datamodel/io/source/influxdb/_weather/cosmo/weather.txt index 5b7ec9400..c5b35c5c8 100644 --- a/src/test/resources/edu/ie3/datamodel/io/source/influxdb/_weather/cosmo/weather.txt +++ b/src/test/resources/edu/ie3/datamodel/io/source/influxdb/_weather/cosmo/weather.txt @@ -5,9 +5,9 @@ CREATE DATABASE test_weather # CONTEXT-DATABASE: test_weather -weather,coordinate_id=193186 diffuse_irradiance=286.872985839844,direct_irradiance=282.671997070312,temperature=278.019012451172,wind_direction=0,wind_velocity=1.66103506088257, groundtemperature_value_one=278.019012451172, groundtemperature_value_two=278.019012451172 1588086000000 -weather,coordinate_id=193187 diffuse_irradiance=287.872985839844,direct_irradiance=283.671997070312,temperature=279.019012451172,wind_direction=0,wind_velocity=1.76103506088257, groundtemperature_value_one=278.019012451172, groundtemperature_value_two=278.019012451172 1588086000000 -weather,coordinate_id=193188 diffuse_irradiance=288.872985839844,direct_irradiance=284.671997070312,temperature=280.019012451172,wind_direction=0,wind_velocity=1.86103506088257, groundtemperature_value_one=278.019012451172, groundtemperature_value_two=278.019012451172 1588086000000 -weather,coordinate_id=193186 diffuse_irradiance=286.872,direct_irradiance=282.672,temperature=278.012,wind_direction=0,wind_velocity=1.662, groundtemperature_value_one=278.019012451172, groundtemperature_value_two=278.019012451172 1588089600000 -weather,coordinate_id=193187 diffuse_irradiance=287.872,direct_irradiance=283.672,temperature=279.012,wind_direction=0,wind_velocity=1.762, groundtemperature_value_one=278.019012451172, groundtemperature_value_two=278.019012451172 1588089600000 -weather,coordinate_id=193186 diffuse_irradiance=286.873,direct_irradiance=282.673,temperature=278.013,wind_direction=0,wind_velocity=1.663, groundtemperature_value_one=278.019012451172, groundtemperature_value_two=278.019012451172 1588093200000 +weather,coordinate_id=193186 diffuse_irradiance=286.872985839844,direct_irradiance=282.671997070312,temperature=278.019012451172,wind_direction=0,wind_velocity=1.66103506088257,groundtemperature_value_one=278.019012451172,groundtemperature_value_two=278.019012451172 1588086000000 +weather,coordinate_id=193187 diffuse_irradiance=287.872985839844,direct_irradiance=283.671997070312,temperature=279.019012451172,wind_direction=0,wind_velocity=1.76103506088257,groundtemperature_value_one=278.019012451172,groundtemperature_value_two=278.019012451172 1588086000000 +weather,coordinate_id=193188 diffuse_irradiance=288.872985839844,direct_irradiance=284.671997070312,temperature=280.019012451172,wind_direction=0,wind_velocity=1.86103506088257,groundtemperature_value_one=278.019012451172,groundtemperature_value_two=278.019012451172 1588086000000 +weather,coordinate_id=193186 diffuse_irradiance=286.872,direct_irradiance=282.672,temperature=278.012,wind_direction=0,wind_velocity=1.662,groundtemperature_value_one=278.019012451172,groundtemperature_value_two=278.019012451172 1588089600000 +weather,coordinate_id=193187 diffuse_irradiance=287.872,direct_irradiance=283.672,temperature=279.012,wind_direction=0,wind_velocity=1.762,groundtemperature_value_one=278.019012451172,groundtemperature_value_two=278.019012451172 1588089600000 +weather,coordinate_id=193186 diffuse_irradiance=286.873,direct_irradiance=282.673,temperature=278.013,wind_direction=0,wind_velocity=1.663,groundtemperature_value_one=278.019012451172,groundtemperature_value_two=278.019012451172 1588093200000 From c067c0be0f77cd299cf7209d8abe6d1f9267b8b3 Mon Sep 17 00:00:00 2001 From: pierrepetersmeier <155652256+pierrepetersmeier@users.noreply.github.com> Date: Sun, 2 Nov 2025 23:08:58 +0100 Subject: [PATCH 26/36] fmt --- .../timeseries/IconTimeBasedWeatherValueFactory.java | 4 ++-- .../IconTimeBasedWeatherValueFactoryTest.groovy | 4 ++-- .../io/source/csv/CsvWeatherSourceCosmoTest.groovy | 8 ++++++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java index 29e8dda3c..3f9ad5709 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java @@ -33,8 +33,8 @@ public class IconTimeBasedWeatherValueFactory extends TimeBasedWeatherValueFacto private static final String TEMPERATURE = "t2m"; private static final String WIND_VELOCITY_U = "u131m"; private static final String WIND_VELOCITY_V = "v131m"; - private static final String GROUND_TEMPERATURE_VALUE_ONE = "groundtemperatureone"; - private static final String GROUND_TEMPERATURE_VALUE_TWO = "groundtemperaturetwo"; + private static final String GROUND_TEMPERATURE_VALUE_ONE = "t_v1"; + private static final String GROUND_TEMPERATURE_VALUE_TWO = "t_v2"; public IconTimeBasedWeatherValueFactory() { super(); diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactoryTest.groovy index 81909c630..9750f3cc3 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactoryTest.groovy @@ -128,9 +128,9 @@ class IconTimeBasedWeatherValueFactoryTest extends Specification { assert it.value.wind.velocity.present assert QuantityUtil.isEquivalentAbs(it.value.wind.velocity.get(), Quantities.getQuantity(4.640010877529081, PowerSystemUnits.METRE_PER_SECOND)) assert it.value.groundTemperatureValueOne.present - assert QuantityUtil.isEquivalentAbs(it.value.groundTemperatureValueOne.get().temperature.get(), Quantities.getQuantity(15.9679319051744, Units.CELSIUS)) + assert QuantityUtil.isEquivalentAbs(it.value.groundTemperatureValueOne.get().temperature.get(), Quantities.getQuantity(15.2601691197649, Units.CELSIUS)) assert it.value.groundTemperatureValueTwo.present - assert QuantityUtil.isEquivalentAbs(it.value.groundTemperatureValueTwo.get().temperature.get(), Quantities.getQuantity(15.9679319051744, Units.CELSIUS)) + assert QuantityUtil.isEquivalentAbs(it.value.groundTemperatureValueTwo.get().temperature.get(), Quantities.getQuantity(15.2601691197649, Units.CELSIUS)) } } } diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceCosmoTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceCosmoTest.groovy index 62e9fd27c..13a764c62 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceCosmoTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceCosmoTest.groovy @@ -12,6 +12,7 @@ import edu.ie3.datamodel.io.naming.FileNamingStrategy import edu.ie3.datamodel.io.source.IdCoordinateSource import edu.ie3.datamodel.models.timeseries.individual.IndividualTimeSeries import edu.ie3.datamodel.models.timeseries.individual.TimeBasedValue +import edu.ie3.datamodel.models.value.GroundTemperatureValue import edu.ie3.datamodel.models.value.SolarIrradianceValue import edu.ie3.datamodel.models.value.TemperatureValue import edu.ie3.datamodel.models.value.WeatherValue @@ -142,8 +143,11 @@ class CsvWeatherSourceCosmoTest extends Specification implements CsvTestDataMeta ), new WindValue( Quantities.getQuantity(12.1314, WIND_DIRECTION), - Quantities.getQuantity(15.1617, WIND_VELOCITY), - Quantities.getQuantity(8, TEMPERATURE), + Quantities.getQuantity(15.1617, WIND_VELOCITY)), + new GroundTemperatureValue( + Quantities.getQuantity(8.0, TEMPERATURE) + ), + new GroundTemperatureValue( Quantities.getQuantity(9.5, TEMPERATURE) ) ) From 64c0172588669bd51c0f0037afa9c4868ef128f8 Mon Sep 17 00:00:00 2001 From: pierrepetersmeier <155652256+pierrepetersmeier@users.noreply.github.com> Date: Sun, 2 Nov 2025 23:10:17 +0100 Subject: [PATCH 27/36] fmt --- docs/readthedocs/models/input/additionaldata/weathersource.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/readthedocs/models/input/additionaldata/weathersource.md b/docs/readthedocs/models/input/additionaldata/weathersource.md index f3d2cb6ab..354001d1c 100644 --- a/docs/readthedocs/models/input/additionaldata/weathersource.md +++ b/docs/readthedocs/models/input/additionaldata/weathersource.md @@ -63,11 +63,11 @@ Weather data is comprised of five key components: - Wind direction, where 0° is North, 90° is East, etc. - ° (degrees) - * - **`groundTemperatureValueOne`** + * - **`groundTemperatureValueOne`** - Ground temperature at 0cm for this coordinate. - K (Kelvin) - * - **`groundTemperatureValueTwo`** + * - **`groundTemperatureValueTwo`** - Ground temperature at 0cm for this coordinate. - K (Kelvin) ``` From d691a2c7a51eb2c6c4391b422ca325e90f9e4e1e Mon Sep 17 00:00:00 2001 From: Pierre <155652256+pierrepetersmeier@users.noreply.github.com> Date: Tue, 4 Nov 2025 11:12:38 +0100 Subject: [PATCH 28/36] Update src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java Co-authored-by: Daniel Feismann <98817556+danielfeismann@users.noreply.github.com> --- .../java/edu/ie3/datamodel/models/value/WeatherValue.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java b/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java index 6065cd7b9..9547e69e5 100644 --- a/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java +++ b/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java @@ -86,8 +86,8 @@ public WeatherValue( new SolarIrradianceValue(directSolarIrradiance, diffuseSolarIrradiance), new TemperatureValue(temperature), new WindValue(direction, velocity), - groundTempValOne == null ? null : new GroundTemperatureValue(groundTempValOne), - groundTempValTwo == null ? null : new GroundTemperatureValue(groundTempValTwo)); + groundTempValOne.map(GroundTemperatureValue::new), + groundTempValTwo.map(GroundTemperatureValue::new)); } public Point getCoordinate() { From 42e859941645637733f98a096bfe46ce113e1502 Mon Sep 17 00:00:00 2001 From: pierrepetersmeier <155652256+pierrepetersmeier@users.noreply.github.com> Date: Tue, 4 Nov 2025 12:27:46 +0100 Subject: [PATCH 29/36] Optional --- .../CosmoTimeBasedWeatherValueFactory.java | 20 ++++++------- .../IconTimeBasedWeatherValueFactory.java | 9 +++--- .../datamodel/models/value/WeatherValue.java | 30 +++++++++---------- .../ie3/test/common/TimeSeriesTestData.groovy | 16 +++++----- 4 files changed, 36 insertions(+), 39 deletions(-) diff --git a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactory.java index 3cefca5eb..13dc1e207 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactory.java @@ -15,6 +15,7 @@ import java.time.format.DateTimeFormatter; import java.util.Arrays; import java.util.List; +import java.util.Optional; import java.util.Set; import javax.measure.quantity.Angle; import javax.measure.quantity.Speed; @@ -32,8 +33,8 @@ public class CosmoTimeBasedWeatherValueFactory extends TimeBasedWeatherValueFact private static final String TEMPERATURE = "temperature"; private static final String WIND_DIRECTION = "windDirection"; private static final String WIND_VELOCITY = "windVelocity"; - private static final String GROUND_TEMPERATURE_0CM = "groundTemperature0cm"; - private static final String GROUND_TEMPERATURE_80CM = "groundTemperature80cm"; + private static final String GROUND_TEMPERATURE_VALUE_ONE = "groundTemperature0cm"; + private static final String GROUND_TEMPERATURE_VALUE_TWO = "groundTemperature80cm"; public CosmoTimeBasedWeatherValueFactory(TimeUtil timeUtil) { super(timeUtil); @@ -59,7 +60,7 @@ protected List> getFields(Class entityClass) { WIND_VELOCITY); Set withGroundTemp = - expandSet(minConstructorParams, GROUND_TEMPERATURE_0CM, GROUND_TEMPERATURE_80CM); + expandSet(minConstructorParams, GROUND_TEMPERATURE_VALUE_ONE, GROUND_TEMPERATURE_VALUE_TWO); return Arrays.asList(minConstructorParams, withGroundTemp); } @@ -78,11 +79,10 @@ protected TimeBasedValue buildModel(TimeBasedWeatherValueData data data.getQuantity(WIND_DIRECTION, StandardUnits.WIND_DIRECTION); ComparableQuantity windVelocity = data.getQuantity(WIND_VELOCITY, StandardUnits.WIND_VELOCITY); - ComparableQuantity groundTemp0cm = - data.getQuantityOptional(GROUND_TEMPERATURE_0CM, StandardUnits.TEMPERATURE).orElse(null); - ComparableQuantity groundTemp80cm = - data.getQuantityOptional(GROUND_TEMPERATURE_80CM, StandardUnits.TEMPERATURE).orElse(null); - + Optional> groundTempValOne = + data.getQuantityOptional(GROUND_TEMPERATURE_VALUE_ONE, StandardUnits.TEMPERATURE); + Optional> groundTempValTwo = + data.getQuantityOptional(GROUND_TEMPERATURE_VALUE_TWO, StandardUnits.TEMPERATURE); WeatherValue weatherValue = new WeatherValue( coordinate, @@ -91,8 +91,8 @@ protected TimeBasedValue buildModel(TimeBasedWeatherValueData data temperature, windDirection, windVelocity, - groundTemp0cm, - groundTemp80cm); + groundTempValOne, + groundTempValTwo); return new TimeBasedValue<>(time, weatherValue); } diff --git a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java index 3f9ad5709..0cbf30aac 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java @@ -55,7 +55,6 @@ protected List> getFields(Class entityClass) { "albrad", "asobs", "aswdifuS", - "t_g", "t_v1", "t_v2", "u10m", @@ -92,10 +91,10 @@ protected TimeBasedValue buildModel(TimeBasedWeatherValueData data data.getQuantity(TEMPERATURE, Units.KELVIN).to(StandardUnits.TEMPERATURE); ComparableQuantity windDirection = getWindDirection(data); ComparableQuantity windVelocity = getWindVelocity(data); - ComparableQuantity groundTemperatureValueOne = - data.getQuantityOptional(GROUND_TEMPERATURE_VALUE_ONE, Units.KELVIN).orElse(null); - ComparableQuantity groundTemperatureValueTwo = - data.getQuantityOptional(GROUND_TEMPERATURE_VALUE_TWO, Units.KELVIN).orElse(null); + Optional> groundTemperatureValueOne = + data.getQuantityOptional(GROUND_TEMPERATURE_VALUE_ONE, Units.KELVIN); + Optional> groundTemperatureValueTwo = + data.getQuantityOptional(GROUND_TEMPERATURE_VALUE_TWO, Units.KELVIN); WeatherValue weatherValue = new WeatherValue( diff --git a/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java b/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java index 9547e69e5..1f3f9fee8 100644 --- a/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java +++ b/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java @@ -28,11 +28,11 @@ public class WeatherValue implements Value { /** Wind values for this coordinate */ private final WindValue wind; - /** Ground temperature value at 0cm depth for this coordinate */ - private final GroundTemperatureValue groundTemperatureValueOne; + /** Ground temperature value for this coordinate */ + private final Optional groundTemperatureValueOne; - /** Ground temperature value at 80cm depth for this coordinate */ - private final GroundTemperatureValue groundTemperatureValueTwo; + /** Ground temperature value for this coordinate */ + private final Optional groundTemperatureValueTwo; /** * @param coordinate of this weather value set @@ -47,8 +47,8 @@ public WeatherValue( SolarIrradianceValue solarIrradiance, TemperatureValue temperature, WindValue wind, - GroundTemperatureValue groundTemperatureValueOne, - GroundTemperatureValue groundTemperatureValueTwo) { + Optional groundTemperatureValueOne, + Optional groundTemperatureValueTwo) { this.coordinate = coordinate; this.solarIrradiance = solarIrradiance; this.temperature = temperature; @@ -67,10 +67,8 @@ public WeatherValue( * @param direction Direction, the wind comes from as an angle from north increasing clockwise * (typically in rad) * @param velocity Wind velocity for this coordinate (typically in m/s) - * @param groundTempValOne Ground temperature at 0cm for this coordinate (typically in K, can be - * null) - * @param groundTempValTwo Ground temperature at 80cm for this coordinate (typically in K, can be - * null) + * @param groundTempValOne Ground temperature for this coordinate (typically in K, can be null) + * @param groundTempValTwo Ground temperature for this coordinate (typically in K, can be null) */ public WeatherValue( Point coordinate, @@ -79,15 +77,15 @@ public WeatherValue( ComparableQuantity temperature, ComparableQuantity direction, ComparableQuantity velocity, - ComparableQuantity groundTempValOne, - ComparableQuantity groundTempValTwo) { + Optional> groundTempValOne, + Optional> groundTempValTwo) { this( coordinate, new SolarIrradianceValue(directSolarIrradiance, diffuseSolarIrradiance), new TemperatureValue(temperature), new WindValue(direction, velocity), - groundTempValOne.map(GroundTemperatureValue::new), - groundTempValTwo.map(GroundTemperatureValue::new)); + groundTempValOne.map(GroundTemperatureValue::new), + groundTempValTwo.map(GroundTemperatureValue::new)); } public Point getCoordinate() { @@ -107,11 +105,11 @@ public WindValue getWind() { } public Optional getGroundTemperatureValueOne() { - return Optional.ofNullable(groundTemperatureValueOne); + return groundTemperatureValueOne; } public Optional getGroundTemperatureValueTwo() { - return Optional.ofNullable(groundTemperatureValueTwo); + return groundTemperatureValueTwo; } @Override diff --git a/src/test/groovy/edu/ie3/test/common/TimeSeriesTestData.groovy b/src/test/groovy/edu/ie3/test/common/TimeSeriesTestData.groovy index ccef99eb0..60ddf1c19 100644 --- a/src/test/groovy/edu/ie3/test/common/TimeSeriesTestData.groovy +++ b/src/test/groovy/edu/ie3/test/common/TimeSeriesTestData.groovy @@ -207,8 +207,8 @@ trait TimeSeriesTestData { new SolarIrradianceValue(Quantities.getQuantity(10d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(15d, StandardUnits.SOLAR_IRRADIANCE)), new TemperatureValue(Quantities.getQuantity(10d, CELSIUS)), new WindValue(Quantities.getQuantity(10d, DEGREE_GEOM), Quantities.getQuantity(15d, METRE_PER_SECOND)), - null, - null + new GroundTemperatureValue(Quantities.getQuantity(10d, CELSIUS)), + new GroundTemperatureValue(Quantities.getQuantity(10d, CELSIUS)) ) ), ] as Set @@ -223,8 +223,8 @@ trait TimeSeriesTestData { "temperature" : "5.0", "time" : "2020-04-02T10:00:00Z", "velocity" : "10.0", - "groundTemperatureValueOne" : "", - "groundTemperatureValueTwo" : "" + "groundTemperatureValueOne" : "10.0", + "groundTemperatureValueTwo" : "10.0" ] as LinkedHashMap, [ "coordinate" : "{\"type\":\"Point\",\"coordinates\":[7.412152,51.492758],\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}}}", @@ -234,8 +234,8 @@ trait TimeSeriesTestData { "temperature" : "15.0", "time" : "2020-04-02T10:15:00Z", "velocity" : "20.0", - "groundTemperatureValueOne" : "", - "groundTemperatureValueTwo" : "" + "groundTemperatureValueOne" : "10.0", + "groundTemperatureValueTwo" : "10.0" ] as LinkedHashMap, [ "coordinate" : "{\"type\":\"Point\",\"coordinates\":[7.412152,51.492758],\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}}}", @@ -245,8 +245,8 @@ trait TimeSeriesTestData { "temperature" : "10.0", "time" : "2020-04-02T10:30:00Z", "velocity" : "15.0", - "groundTemperatureValueOne" : "", - "groundTemperatureValueTwo" : "" + "groundTemperatureValueOne" : "10.0", + "groundTemperatureValueTwo" : "10.0" ] as LinkedHashMap ] as Set From ae9da09fbf72dd99fbdc8f6bd930557a134010ec Mon Sep 17 00:00:00 2001 From: pierrepetersmeier <155652256+pierrepetersmeier@users.noreply.github.com> Date: Tue, 4 Nov 2025 13:00:21 +0100 Subject: [PATCH 30/36] FlatMap instead of Map. Optional in Tests. --- .../datamodel/models/value/WeatherValue.java | 6 +++-- ...smoTimeBasedWeatherValueFactoryTest.groovy | 4 ++-- .../csv/CsvWeatherSourceCosmoTest.groovy | 9 ++++--- .../UniquenessValidationUtilsTest.groovy | 8 +++---- .../test/common/CosmoWeatherTestData.groovy | 24 +++++++++---------- .../test/common/IconWeatherTestData.groovy | 20 ++++++++-------- .../ie3/test/common/TimeSeriesTestData.groovy | 4 ++-- 7 files changed, 38 insertions(+), 37 deletions(-) diff --git a/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java b/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java index 1f3f9fee8..8c4bccd0f 100644 --- a/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java +++ b/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java @@ -84,8 +84,10 @@ public WeatherValue( new SolarIrradianceValue(directSolarIrradiance, diffuseSolarIrradiance), new TemperatureValue(temperature), new WindValue(direction, velocity), - groundTempValOne.map(GroundTemperatureValue::new), - groundTempValTwo.map(GroundTemperatureValue::new)); + Optional.ofNullable(groundTempValOne) + .flatMap(optional -> optional.map(GroundTemperatureValue::new)), + Optional.ofNullable(groundTempValTwo) + .flatMap(optional -> optional.map(GroundTemperatureValue::new))); } public Point getCoordinate() { diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy index 4c33c2e48..b8d7af16d 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy @@ -79,8 +79,8 @@ class CosmoTimeBasedWeatherValueFactoryTest extends Specification { Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE), Quantities.getQuantity(0d, StandardUnits.WIND_DIRECTION), Quantities.getQuantity(1.66103506088257d, StandardUnits.WIND_VELOCITY), - Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE), - Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE))) + Optional.of(Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE)), + Optional.of(Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE)))) when: def model = factory.buildModel(data) diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceCosmoTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceCosmoTest.groovy index 13a764c62..ebaf0b1cd 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceCosmoTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceCosmoTest.groovy @@ -144,13 +144,12 @@ class CsvWeatherSourceCosmoTest extends Specification implements CsvTestDataMeta new WindValue( Quantities.getQuantity(12.1314, WIND_DIRECTION), Quantities.getQuantity(15.1617, WIND_VELOCITY)), - new GroundTemperatureValue( + Optional.of(new GroundTemperatureValue( Quantities.getQuantity(8.0, TEMPERATURE) - ), - new GroundTemperatureValue( + )), + Optional.of(new GroundTemperatureValue( Quantities.getQuantity(9.5, TEMPERATURE) - ) - ) + ))) ) when: diff --git a/src/test/groovy/edu/ie3/datamodel/utils/validation/UniquenessValidationUtilsTest.groovy b/src/test/groovy/edu/ie3/datamodel/utils/validation/UniquenessValidationUtilsTest.groovy index 474416e9b..80b4be3db 100644 --- a/src/test/groovy/edu/ie3/datamodel/utils/validation/UniquenessValidationUtilsTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/utils/validation/UniquenessValidationUtilsTest.groovy @@ -212,8 +212,8 @@ class UniquenessValidationUtilsTest extends Specification { new SolarIrradianceValue(Quantities.getQuantity(10d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(10d, StandardUnits.SOLAR_IRRADIANCE)), new TemperatureValue(Quantities.getQuantity(5d, Units.CELSIUS)), new WindValue(Quantities.getQuantity(5d, DEGREE_GEOM), Quantities.getQuantity(10d, METRE_PER_SECOND)), - new GroundTemperatureValue(Quantities.getQuantity(5d, Units.CELSIUS)), - new GroundTemperatureValue(Quantities.getQuantity(5d, Units.CELSIUS)) + Optional.of(new GroundTemperatureValue(Quantities.getQuantity(5d, Units.CELSIUS))), + Optional.of(new GroundTemperatureValue(Quantities.getQuantity(5d, Units.CELSIUS))) ) Set> uniqueValues = [ @@ -236,8 +236,8 @@ class UniquenessValidationUtilsTest extends Specification { new SolarIrradianceValue(Quantities.getQuantity(10d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(10d, StandardUnits.SOLAR_IRRADIANCE)), new TemperatureValue(Quantities.getQuantity(5d, Units.CELSIUS)), new WindValue(Quantities.getQuantity(5d, DEGREE_GEOM), Quantities.getQuantity(10d, METRE_PER_SECOND)), - new GroundTemperatureValue(Quantities.getQuantity(5d, Units.CELSIUS)), - new GroundTemperatureValue(Quantities.getQuantity(5d, Units.CELSIUS)) + Optional.of(new GroundTemperatureValue(Quantities.getQuantity(5d, Units.CELSIUS))), + Optional.of(new GroundTemperatureValue(Quantities.getQuantity(5d, Units.CELSIUS))) ) Set> notUniqueValues = [ new TimeBasedValue(time, value), diff --git a/src/test/groovy/edu/ie3/test/common/CosmoWeatherTestData.groovy b/src/test/groovy/edu/ie3/test/common/CosmoWeatherTestData.groovy index 948887023..dc60a38cd 100644 --- a/src/test/groovy/edu/ie3/test/common/CosmoWeatherTestData.groovy +++ b/src/test/groovy/edu/ie3/test/common/CosmoWeatherTestData.groovy @@ -25,8 +25,8 @@ class CosmoWeatherTestData extends WeatherTestData { Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE), Quantities.getQuantity(0d, StandardUnits.WIND_DIRECTION), Quantities.getQuantity(1.66103506088257d, StandardUnits.WIND_VELOCITY), - Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE), - Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE) + Optional.of(Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE)), + Optional.of(Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE)) ) public static final WeatherValue WEATHER_VALUE_193186_16H = new WeatherValue( @@ -36,8 +36,8 @@ class CosmoWeatherTestData extends WeatherTestData { Quantities.getQuantity(278.012d, StandardUnits.TEMPERATURE), Quantities.getQuantity(0d, StandardUnits.WIND_DIRECTION), Quantities.getQuantity(1.662d, StandardUnits.WIND_VELOCITY), - Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE), - Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE) + Optional.of(Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE)), + Optional.of(Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE)) ) public static final WeatherValue WEATHER_VALUE_193186_17H = new WeatherValue( @@ -47,8 +47,8 @@ class CosmoWeatherTestData extends WeatherTestData { Quantities.getQuantity(278.013d, StandardUnits.TEMPERATURE), Quantities.getQuantity(0d, StandardUnits.WIND_DIRECTION), Quantities.getQuantity(1.663d, StandardUnits.WIND_VELOCITY), - Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE), - Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE) + Optional.of(Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE)), + Optional.of(Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE)) ) public static final WeatherValue WEATHER_VALUE_193187_15H = new WeatherValue( @@ -58,8 +58,8 @@ class CosmoWeatherTestData extends WeatherTestData { Quantities.getQuantity(279.019012451172d, StandardUnits.TEMPERATURE), Quantities.getQuantity(0d, StandardUnits.WIND_DIRECTION), Quantities.getQuantity(1.76103506088257d, StandardUnits.WIND_VELOCITY), - Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE), - Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE) + Optional.of(Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE)), + Optional.of(Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE)) ) public static final WeatherValue WEATHER_VALUE_193187_16H = new WeatherValue( @@ -69,8 +69,8 @@ class CosmoWeatherTestData extends WeatherTestData { Quantities.getQuantity(279.012d, StandardUnits.TEMPERATURE), Quantities.getQuantity(0d, StandardUnits.WIND_DIRECTION), Quantities.getQuantity(1.762d, StandardUnits.WIND_VELOCITY), - Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE), - Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE) + Optional.of(Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE)), + Optional.of(Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE)) ) public static final WeatherValue WEATHER_VALUE_193188_15H = new WeatherValue( @@ -80,7 +80,7 @@ class CosmoWeatherTestData extends WeatherTestData { Quantities.getQuantity(280.019012451172d, StandardUnits.TEMPERATURE), Quantities.getQuantity(0d, StandardUnits.WIND_DIRECTION), Quantities.getQuantity(1.86103506088257d, StandardUnits.WIND_VELOCITY), - Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE), - Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE) + Optional.of(Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE)), + Optional.of(Quantities.getQuantity(278.019012451172d, StandardUnits.TEMPERATURE)) ) } diff --git a/src/test/groovy/edu/ie3/test/common/IconWeatherTestData.groovy b/src/test/groovy/edu/ie3/test/common/IconWeatherTestData.groovy index be04a77de..4022311d5 100644 --- a/src/test/groovy/edu/ie3/test/common/IconWeatherTestData.groovy +++ b/src/test/groovy/edu/ie3/test/common/IconWeatherTestData.groovy @@ -25,8 +25,8 @@ class IconWeatherTestData extends WeatherTestData { Quantities.getQuantity(24.4741992659816, StandardUnits.TEMPERATURE), Quantities.getQuantity(270.45278309919627, StandardUnits.WIND_DIRECTION), Quantities.getQuantity(3.76601470961371, StandardUnits.WIND_VELOCITY), - Quantities.getQuantity(24.4741992659816, StandardUnits.TEMPERATURE), - Quantities.getQuantity(24.4741992659816, StandardUnits.TEMPERATURE) + Optional.of(Quantities.getQuantity(24.4741992659816, StandardUnits.TEMPERATURE)), + Optional.of(Quantities.getQuantity(24.4741992659816, StandardUnits.TEMPERATURE)) ) public static final WeatherValue WEATHER_VALUE_67775_16H = new WeatherValue( @@ -36,8 +36,8 @@ class IconWeatherTestData extends WeatherTestData { Quantities.getQuantity(24.1700023473353, StandardUnits.TEMPERATURE), Quantities.getQuantity(278.144331776102, StandardUnits.WIND_DIRECTION), Quantities.getQuantity(4.05744164637287, StandardUnits.WIND_VELOCITY), - Quantities.getQuantity(24.4741992659816, StandardUnits.TEMPERATURE), - Quantities.getQuantity(24.4741992659816, StandardUnits.TEMPERATURE) + Optional.of(Quantities.getQuantity(24.4741992659816, StandardUnits.TEMPERATURE)), + Optional.of(Quantities.getQuantity(24.4741992659816, StandardUnits.TEMPERATURE)) ) public static final WeatherValue WEATHER_VALUE_67775_17H = new WeatherValue( @@ -47,8 +47,8 @@ class IconWeatherTestData extends WeatherTestData { Quantities.getQuantity(23.6787403584074, StandardUnits.TEMPERATURE), Quantities.getQuantity(286.891007103442, StandardUnits.WIND_DIRECTION), Quantities.getQuantity(3.81526300455393, StandardUnits.WIND_VELOCITY), - Quantities.getQuantity(24.4741992659816, StandardUnits.TEMPERATURE), - Quantities.getQuantity(24.4741992659816, StandardUnits.TEMPERATURE) + Optional.of(Quantities.getQuantity(24.4741992659816, StandardUnits.TEMPERATURE)), + Optional.of(Quantities.getQuantity(24.4741992659816, StandardUnits.TEMPERATURE)) ) public static final WeatherValue WEATHER_VALUE_67776_15H = new WeatherValue( @@ -58,8 +58,8 @@ class IconWeatherTestData extends WeatherTestData { Quantities.getQuantity(22.365335568404, StandardUnits.TEMPERATURE), Quantities.getQuantity(245.604554131632, StandardUnits.WIND_DIRECTION), Quantities.getQuantity(4.39390441381814, StandardUnits.WIND_VELOCITY), - Quantities.getQuantity(24.4741992659816, StandardUnits.TEMPERATURE), - Quantities.getQuantity(24.4741992659816, StandardUnits.TEMPERATURE) + Optional.of(Quantities.getQuantity(24.4741992659816, StandardUnits.TEMPERATURE)), + Optional.of(Quantities.getQuantity(24.4741992659816, StandardUnits.TEMPERATURE)) ) public static final WeatherValue WEATHER_VALUE_67776_16H = new WeatherValue( @@ -69,7 +69,7 @@ class IconWeatherTestData extends WeatherTestData { Quantities.getQuantity(20.305111314491, StandardUnits.TEMPERATURE), Quantities.getQuantity(252.810224701109, StandardUnits.WIND_DIRECTION), Quantities.getQuantity(3.44242472583919, StandardUnits.WIND_VELOCITY), - Quantities.getQuantity(24.4741992659816, StandardUnits.TEMPERATURE), - Quantities.getQuantity(24.4741992659816, StandardUnits.TEMPERATURE) + Optional.of(Quantities.getQuantity(24.4741992659816, StandardUnits.TEMPERATURE)), + Optional.of(Quantities.getQuantity(24.4741992659816, StandardUnits.TEMPERATURE)) ) } diff --git a/src/test/groovy/edu/ie3/test/common/TimeSeriesTestData.groovy b/src/test/groovy/edu/ie3/test/common/TimeSeriesTestData.groovy index 60ddf1c19..d39ae61de 100644 --- a/src/test/groovy/edu/ie3/test/common/TimeSeriesTestData.groovy +++ b/src/test/groovy/edu/ie3/test/common/TimeSeriesTestData.groovy @@ -207,8 +207,8 @@ trait TimeSeriesTestData { new SolarIrradianceValue(Quantities.getQuantity(10d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(15d, StandardUnits.SOLAR_IRRADIANCE)), new TemperatureValue(Quantities.getQuantity(10d, CELSIUS)), new WindValue(Quantities.getQuantity(10d, DEGREE_GEOM), Quantities.getQuantity(15d, METRE_PER_SECOND)), - new GroundTemperatureValue(Quantities.getQuantity(10d, CELSIUS)), - new GroundTemperatureValue(Quantities.getQuantity(10d, CELSIUS)) + Optional.of(new GroundTemperatureValue(Quantities.getQuantity(10d, CELSIUS))), + Optional.of(new GroundTemperatureValue(Quantities.getQuantity(10d, CELSIUS))) ) ), ] as Set From 481ab1247843e67e115bfb179f0175cb1a7c57d9 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Tue, 4 Nov 2025 13:56:02 +0100 Subject: [PATCH 31/36] enhancing TimeSeriesProcessor --- .../timeseries/FieldSourceToMethod.java | 2 ++ .../timeseries/TimeSeriesProcessor.java | 27 +++++++++++++++++++ .../ie3/test/common/TimeSeriesTestData.groovy | 12 +++------ 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/src/main/java/edu/ie3/datamodel/io/processor/timeseries/FieldSourceToMethod.java b/src/main/java/edu/ie3/datamodel/io/processor/timeseries/FieldSourceToMethod.java index ac2977d72..3f0aedaca 100644 --- a/src/main/java/edu/ie3/datamodel/io/processor/timeseries/FieldSourceToMethod.java +++ b/src/main/java/edu/ie3/datamodel/io/processor/timeseries/FieldSourceToMethod.java @@ -25,5 +25,7 @@ public enum FieldSource { WEATHER_IRRADIANCE, WEATHER_TEMPERATURE, WEATHER_WIND, + GROUND_TEMPERATURE_ONE, + GROUND_TEMPERATURE_TWO, } } diff --git a/src/main/java/edu/ie3/datamodel/io/processor/timeseries/TimeSeriesProcessor.java b/src/main/java/edu/ie3/datamodel/io/processor/timeseries/TimeSeriesProcessor.java index 430746a34..a0e3e307f 100644 --- a/src/main/java/edu/ie3/datamodel/io/processor/timeseries/TimeSeriesProcessor.java +++ b/src/main/java/edu/ie3/datamodel/io/processor/timeseries/TimeSeriesProcessor.java @@ -172,6 +172,17 @@ private SortedMap buildFieldToSource( .forEach(addFunction.apply(WEATHER_IRRADIANCE)); mapFieldNameToGetter(TemperatureValue.class).forEach(addFunction.apply(WEATHER_TEMPERATURE)); mapFieldNameToGetter(WindValue.class).forEach(addFunction.apply(WEATHER_WIND)); + Map groundTempMap = mapFieldNameToGetter(GroundTemperatureValue.class); + groundTempMap.forEach( + (fieldName, getter) -> + addFunction + .apply(GROUND_TEMPERATURE_ONE) + .accept("groundTemperatureValueOne", getter)); + groundTempMap.forEach( + (fieldName, getter) -> + addFunction + .apply(GROUND_TEMPERATURE_TWO) + .accept("groundTemperatureValueTwo", getter)); } else if (valueClass.equals(BdewLoadValues.class)) { @@ -272,6 +283,22 @@ private Map handleEntry(T timeSeries, E entry) throws EntityProc Map windFieldToMethod = extractFieldToMethod(WEATHER_WIND); valueResult.putAll(processObject(weatherValue.getWind(), windFieldToMethod)); + + Map groundTempOneFieldToMethod = + extractFieldToMethod(GROUND_TEMPERATURE_ONE); + if (weatherValue.getGroundTemperatureValueOne().isPresent()) { + valueResult.putAll( + processObject( + weatherValue.getGroundTemperatureValueOne().get(), groundTempOneFieldToMethod)); + } + + Map groundTempTwoFieldToMethod = + extractFieldToMethod(GROUND_TEMPERATURE_TWO); + if (weatherValue.getGroundTemperatureValueTwo().isPresent()) { + valueResult.putAll( + processObject( + weatherValue.getGroundTemperatureValueTwo().get(), groundTempTwoFieldToMethod)); + } } /* Join all information and sort them */ diff --git a/src/test/groovy/edu/ie3/test/common/TimeSeriesTestData.groovy b/src/test/groovy/edu/ie3/test/common/TimeSeriesTestData.groovy index d39ae61de..0d9121492 100644 --- a/src/test/groovy/edu/ie3/test/common/TimeSeriesTestData.groovy +++ b/src/test/groovy/edu/ie3/test/common/TimeSeriesTestData.groovy @@ -185,8 +185,8 @@ trait TimeSeriesTestData { new SolarIrradianceValue(Quantities.getQuantity(5d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(10d, StandardUnits.SOLAR_IRRADIANCE)), new TemperatureValue(Quantities.getQuantity(5d, CELSIUS)), new WindValue(Quantities.getQuantity(5d, DEGREE_GEOM), Quantities.getQuantity(10d, METRE_PER_SECOND)), - null, - null + Optional.empty(), + Optional.empty() ) ), new TimeBasedValue<>( @@ -196,8 +196,8 @@ trait TimeSeriesTestData { new SolarIrradianceValue(Quantities.getQuantity(15d, StandardUnits.SOLAR_IRRADIANCE), Quantities.getQuantity(20d, StandardUnits.SOLAR_IRRADIANCE)), new TemperatureValue(Quantities.getQuantity(15d, CELSIUS)), new WindValue(Quantities.getQuantity(15d, DEGREE_GEOM), Quantities.getQuantity(20d, METRE_PER_SECOND)), - null, - null + Optional.empty(), + Optional.empty() ) ), new TimeBasedValue<>( @@ -223,8 +223,6 @@ trait TimeSeriesTestData { "temperature" : "5.0", "time" : "2020-04-02T10:00:00Z", "velocity" : "10.0", - "groundTemperatureValueOne" : "10.0", - "groundTemperatureValueTwo" : "10.0" ] as LinkedHashMap, [ "coordinate" : "{\"type\":\"Point\",\"coordinates\":[7.412152,51.492758],\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}}}", @@ -234,8 +232,6 @@ trait TimeSeriesTestData { "temperature" : "15.0", "time" : "2020-04-02T10:15:00Z", "velocity" : "20.0", - "groundTemperatureValueOne" : "10.0", - "groundTemperatureValueTwo" : "10.0" ] as LinkedHashMap, [ "coordinate" : "{\"type\":\"Point\",\"coordinates\":[7.412152,51.492758],\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}}}", From 5efc4d2e0947c93264d0021bf22f966a92b7495b Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Tue, 4 Nov 2025 14:10:26 +0100 Subject: [PATCH 32/36] sonar --- .../processor/timeseries/TimeSeriesProcessor.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/main/java/edu/ie3/datamodel/io/processor/timeseries/TimeSeriesProcessor.java b/src/main/java/edu/ie3/datamodel/io/processor/timeseries/TimeSeriesProcessor.java index a0e3e307f..3d911e2c4 100644 --- a/src/main/java/edu/ie3/datamodel/io/processor/timeseries/TimeSeriesProcessor.java +++ b/src/main/java/edu/ie3/datamodel/io/processor/timeseries/TimeSeriesProcessor.java @@ -286,18 +286,16 @@ private Map handleEntry(T timeSeries, E entry) throws EntityProc Map groundTempOneFieldToMethod = extractFieldToMethod(GROUND_TEMPERATURE_ONE); - if (weatherValue.getGroundTemperatureValueOne().isPresent()) { - valueResult.putAll( - processObject( - weatherValue.getGroundTemperatureValueOne().get(), groundTempOneFieldToMethod)); + Optional gtOneOpt = weatherValue.getGroundTemperatureValueOne(); + if (gtOneOpt.isPresent()) { + valueResult.putAll(processObject(gtOneOpt.get(), groundTempOneFieldToMethod)); } Map groundTempTwoFieldToMethod = extractFieldToMethod(GROUND_TEMPERATURE_TWO); - if (weatherValue.getGroundTemperatureValueTwo().isPresent()) { - valueResult.putAll( - processObject( - weatherValue.getGroundTemperatureValueTwo().get(), groundTempTwoFieldToMethod)); + Optional gtTwoOpt = weatherValue.getGroundTemperatureValueTwo(); + if (gtTwoOpt.isPresent()) { + valueResult.putAll(processObject(gtTwoOpt.get(), groundTempTwoFieldToMethod)); } } From 41d031e0f756edbb50be53e82fb11c50e51985d6 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Tue, 4 Nov 2025 14:38:11 +0100 Subject: [PATCH 33/36] optinal empty --- .../timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy | 4 ++-- src/test/groovy/edu/ie3/test/common/TimeSeriesTestData.groovy | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy index b8d7af16d..5f3b4c98f 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy @@ -42,8 +42,8 @@ class CosmoTimeBasedWeatherValueFactoryTest extends Specification { null, Quantities.getQuantity(0d, StandardUnits.WIND_DIRECTION), Quantities.getQuantity(1.66103506088257d, StandardUnits.WIND_VELOCITY), - null, - null)) + Optional.empty(), + Optional.empty())) when: def model = factory.buildModel(data) diff --git a/src/test/groovy/edu/ie3/test/common/TimeSeriesTestData.groovy b/src/test/groovy/edu/ie3/test/common/TimeSeriesTestData.groovy index 0d9121492..b4c8e4948 100644 --- a/src/test/groovy/edu/ie3/test/common/TimeSeriesTestData.groovy +++ b/src/test/groovy/edu/ie3/test/common/TimeSeriesTestData.groovy @@ -186,7 +186,7 @@ trait TimeSeriesTestData { new TemperatureValue(Quantities.getQuantity(5d, CELSIUS)), new WindValue(Quantities.getQuantity(5d, DEGREE_GEOM), Quantities.getQuantity(10d, METRE_PER_SECOND)), Optional.empty(), - Optional.empty() + Optional.empty(), ) ), new TimeBasedValue<>( From a1967ea8cb96caa4f75f7900e82d509d60b57936 Mon Sep 17 00:00:00 2001 From: Pierre <155652256+pierrepetersmeier@users.noreply.github.com> Date: Thu, 6 Nov 2025 13:15:00 +0100 Subject: [PATCH 34/36] Rename ground temperature columns in SQL schema --- .../edu/ie3/datamodel/io/sink/_sql/time_series.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/resources/edu/ie3/datamodel/io/sink/_sql/time_series.sql b/src/test/resources/edu/ie3/datamodel/io/sink/_sql/time_series.sql index cfe9ddb46..1f3ffd33e 100644 --- a/src/test/resources/edu/ie3/datamodel/io/sink/_sql/time_series.sql +++ b/src/test/resources/edu/ie3/datamodel/io/sink/_sql/time_series.sql @@ -99,8 +99,8 @@ CREATE TABLE public.time_series_weather direction DOUBLE PRECISION, temperature DOUBLE PRECISION, velocity DOUBLE PRECISION, - ground_temperature_value_one DOUBLE PRECISION, - ground_temperature_value_two DOUBLE PRECISION, + ground_temperature_level_1 DOUBLE PRECISION, + ground_temperature_level_2 DOUBLE PRECISION, grid_uuid UUID NOT NULL REFERENCES grids(uuid) ) WITHOUT OIDS @@ -108,4 +108,4 @@ CREATE TABLE public.time_series_weather CREATE INDEX time_series_weather_series_id ON time_series_weather USING hash (time_series); -CREATE UNIQUE INDEX time_series_weather_series_time ON time_series_weather USING btree (time_series, time); \ No newline at end of file +CREATE UNIQUE INDEX time_series_weather_series_time ON time_series_weather USING btree (time_series, time); From aa481ca05e6afc607374d0cef5e6c66ea3126193 Mon Sep 17 00:00:00 2001 From: pierrepetersmeier <155652256+pierrepetersmeier@users.noreply.github.com> Date: Thu, 6 Nov 2025 13:32:02 +0100 Subject: [PATCH 35/36] Rename GroundTemperature variable --- CHANGELOG.md | 2 +- .../input/additionaldata/weathersource.md | 10 +++--- .../CosmoTimeBasedWeatherValueFactory.java | 10 +++--- .../IconTimeBasedWeatherValueFactory.java | 20 ++++++------ .../timeseries/FieldSourceToMethod.java | 4 +-- .../timeseries/TimeSeriesProcessor.java | 12 +++---- .../datamodel/models/value/WeatherValue.java | 32 +++++++++---------- ...smoTimeBasedWeatherValueFactoryTest.groovy | 8 ++--- ...conTimeBasedWeatherValueFactoryTest.groovy | 12 +++---- .../csv/CsvWeatherSourceCosmoTest.groovy | 16 +++++----- .../ie3/test/common/TimeSeriesTestData.groovy | 4 +-- ...r_8bc9120d-fb9b-4484-b4e3-0cdadf0feea9.csv | 2 +- ...r_513606bc-539e-445b-9675-2f98be3d9231.csv | 2 +- .../influxdb/_weather/cosmo/weather.txt | 12 +++---- .../source/influxdb/_weather/icon/weather.txt | 10 +++--- .../io/source/sql/_weather/cosmo/weather.sql | 8 ++--- .../io/source/sql/_weather/icon/weather.sql | 12 +++---- 17 files changed, 88 insertions(+), 88 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 07c43469e..78d1495eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added getter sRated for SystemParticipant inputs and updated them in tests in src[#1412](https://github.com/ie3-institute/PowerSystemDataModel/issues/1412) - Added converters documentation [#1139](https://github.com/ie3-institute/PowerSystemDataModel/issues/1139) - Added abstraction for power value sources [#1438](https://github.com/ie3-institute/PowerSystemDataModel/issues/1438) +- Add ground temperatures level 1 and 2 as option to weather data. [#1343](https://github.com/ie3-institute/PowerSystemDataModel/issues/1343) ### Fixed - Fixed small issues in tests [#1400](https://github.com/ie3-institute/PowerSystemDataModel/issues/1400) @@ -46,7 +47,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Extend Validation to EnergyManagement Systems. [#1356](https://github.com/ie3-institute/PowerSystemDataModel/issues/1356) -- Add ground temperature (1m) as option to weather data. [#1343](https://github.com/ie3-institute/PowerSystemDataModel/issues/1343) ### Fixed - Fixed handling of `CongestionResult.InputModelType` in `EntityProcessor` [#1325](https://github.com/ie3-institute/PowerSystemDataModel/issues/1325) diff --git a/docs/readthedocs/models/input/additionaldata/weathersource.md b/docs/readthedocs/models/input/additionaldata/weathersource.md index 354001d1c..cd508d790 100644 --- a/docs/readthedocs/models/input/additionaldata/weathersource.md +++ b/docs/readthedocs/models/input/additionaldata/weathersource.md @@ -63,13 +63,13 @@ Weather data is comprised of five key components: - Wind direction, where 0° is North, 90° is East, etc. - ° (degrees) - * - **`groundTemperatureValueOne`** - - Ground temperature at 0cm for this coordinate. + * - **`groundTemperatureLevel1`** + - Ground temperature at level 2 for this coordinate. - K (Kelvin) - * - **`groundTemperatureValueTwo`** - - Ground temperature at 0cm for this coordinate. + * - **`groundTemperatureLevel2`** + - Ground temperature at level 2 for this coordinate. - K (Kelvin) ``` Weather data in COSMO and ICON formats is supported. Additional optional weather data can also be provided. -The ground temperature measurements at 0 cm and 80 cm depth are used because underground cables are typically laid at around 80 cm depth. \ No newline at end of file +The ground temperature measurements at level 1 and level 2 depth are used. Underground cables are typically laid at around 80 cm depth. \ No newline at end of file diff --git a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactory.java index 13dc1e207..e3003c7f3 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactory.java @@ -33,8 +33,8 @@ public class CosmoTimeBasedWeatherValueFactory extends TimeBasedWeatherValueFact private static final String TEMPERATURE = "temperature"; private static final String WIND_DIRECTION = "windDirection"; private static final String WIND_VELOCITY = "windVelocity"; - private static final String GROUND_TEMPERATURE_VALUE_ONE = "groundTemperature0cm"; - private static final String GROUND_TEMPERATURE_VALUE_TWO = "groundTemperature80cm"; + private static final String GROUND_TEMPERATURE_LEVEL_1 = "groundTemperatureLevel1"; + private static final String GROUND_TEMPERATURE_LEVEL_2 = "groundTemperatureLevel2"; public CosmoTimeBasedWeatherValueFactory(TimeUtil timeUtil) { super(timeUtil); @@ -60,7 +60,7 @@ protected List> getFields(Class entityClass) { WIND_VELOCITY); Set withGroundTemp = - expandSet(minConstructorParams, GROUND_TEMPERATURE_VALUE_ONE, GROUND_TEMPERATURE_VALUE_TWO); + expandSet(minConstructorParams, GROUND_TEMPERATURE_LEVEL_1, GROUND_TEMPERATURE_LEVEL_2); return Arrays.asList(minConstructorParams, withGroundTemp); } @@ -80,9 +80,9 @@ protected TimeBasedValue buildModel(TimeBasedWeatherValueData data ComparableQuantity windVelocity = data.getQuantity(WIND_VELOCITY, StandardUnits.WIND_VELOCITY); Optional> groundTempValOne = - data.getQuantityOptional(GROUND_TEMPERATURE_VALUE_ONE, StandardUnits.TEMPERATURE); + data.getQuantityOptional(GROUND_TEMPERATURE_LEVEL_1, StandardUnits.TEMPERATURE); Optional> groundTempValTwo = - data.getQuantityOptional(GROUND_TEMPERATURE_VALUE_TWO, StandardUnits.TEMPERATURE); + data.getQuantityOptional(GROUND_TEMPERATURE_LEVEL_2, StandardUnits.TEMPERATURE); WeatherValue weatherValue = new WeatherValue( coordinate, diff --git a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java index 0cbf30aac..f6118c54d 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java @@ -33,8 +33,8 @@ public class IconTimeBasedWeatherValueFactory extends TimeBasedWeatherValueFacto private static final String TEMPERATURE = "t2m"; private static final String WIND_VELOCITY_U = "u131m"; private static final String WIND_VELOCITY_V = "v131m"; - private static final String GROUND_TEMPERATURE_VALUE_ONE = "t_v1"; - private static final String GROUND_TEMPERATURE_VALUE_TWO = "t_v2"; + private static final String GROUND_TEMPERATURE_LEVEL_1 = "tg_1"; + private static final String GROUND_TEMPERATURE_LEVEL_2 = "tg_2"; public IconTimeBasedWeatherValueFactory() { super(); @@ -55,8 +55,8 @@ protected List> getFields(Class entityClass) { "albrad", "asobs", "aswdifuS", - "t_v1", - "t_v2", + "tg_1", + "tg_2", "u10m", "u20m", "u216m", @@ -91,10 +91,10 @@ protected TimeBasedValue buildModel(TimeBasedWeatherValueData data data.getQuantity(TEMPERATURE, Units.KELVIN).to(StandardUnits.TEMPERATURE); ComparableQuantity windDirection = getWindDirection(data); ComparableQuantity windVelocity = getWindVelocity(data); - Optional> groundTemperatureValueOne = - data.getQuantityOptional(GROUND_TEMPERATURE_VALUE_ONE, Units.KELVIN); - Optional> groundTemperatureValueTwo = - data.getQuantityOptional(GROUND_TEMPERATURE_VALUE_TWO, Units.KELVIN); + Optional> groundTemperatureLevel1 = + data.getQuantityOptional(GROUND_TEMPERATURE_LEVEL_1, Units.KELVIN); + Optional> groundTemperatureLevl2 = + data.getQuantityOptional(GROUND_TEMPERATURE_LEVEL_2, Units.KELVIN); WeatherValue weatherValue = new WeatherValue( @@ -104,8 +104,8 @@ protected TimeBasedValue buildModel(TimeBasedWeatherValueData data temperature, windDirection, windVelocity, - groundTemperatureValueOne, - groundTemperatureValueTwo); + groundTemperatureLevel1, + groundTemperatureLevl2); return new TimeBasedValue<>(time, weatherValue); } diff --git a/src/main/java/edu/ie3/datamodel/io/processor/timeseries/FieldSourceToMethod.java b/src/main/java/edu/ie3/datamodel/io/processor/timeseries/FieldSourceToMethod.java index 3f0aedaca..594832388 100644 --- a/src/main/java/edu/ie3/datamodel/io/processor/timeseries/FieldSourceToMethod.java +++ b/src/main/java/edu/ie3/datamodel/io/processor/timeseries/FieldSourceToMethod.java @@ -25,7 +25,7 @@ public enum FieldSource { WEATHER_IRRADIANCE, WEATHER_TEMPERATURE, WEATHER_WIND, - GROUND_TEMPERATURE_ONE, - GROUND_TEMPERATURE_TWO, + GROUND_TEMPERATURE_LEVEL_1, + GROUND_TEMPERATURE_LEVEL_2, } } diff --git a/src/main/java/edu/ie3/datamodel/io/processor/timeseries/TimeSeriesProcessor.java b/src/main/java/edu/ie3/datamodel/io/processor/timeseries/TimeSeriesProcessor.java index 3d911e2c4..dd9b74988 100644 --- a/src/main/java/edu/ie3/datamodel/io/processor/timeseries/TimeSeriesProcessor.java +++ b/src/main/java/edu/ie3/datamodel/io/processor/timeseries/TimeSeriesProcessor.java @@ -176,12 +176,12 @@ private SortedMap buildFieldToSource( groundTempMap.forEach( (fieldName, getter) -> addFunction - .apply(GROUND_TEMPERATURE_ONE) + .apply(GROUND_TEMPERATURE_LEVEL_1) .accept("groundTemperatureValueOne", getter)); groundTempMap.forEach( (fieldName, getter) -> addFunction - .apply(GROUND_TEMPERATURE_TWO) + .apply(GROUND_TEMPERATURE_LEVEL_2) .accept("groundTemperatureValueTwo", getter)); } else if (valueClass.equals(BdewLoadValues.class)) { @@ -285,15 +285,15 @@ private Map handleEntry(T timeSeries, E entry) throws EntityProc valueResult.putAll(processObject(weatherValue.getWind(), windFieldToMethod)); Map groundTempOneFieldToMethod = - extractFieldToMethod(GROUND_TEMPERATURE_ONE); - Optional gtOneOpt = weatherValue.getGroundTemperatureValueOne(); + extractFieldToMethod(GROUND_TEMPERATURE_LEVEL_1); + Optional gtOneOpt = weatherValue.getGroundTemperatureLevel1(); if (gtOneOpt.isPresent()) { valueResult.putAll(processObject(gtOneOpt.get(), groundTempOneFieldToMethod)); } Map groundTempTwoFieldToMethod = - extractFieldToMethod(GROUND_TEMPERATURE_TWO); - Optional gtTwoOpt = weatherValue.getGroundTemperatureValueTwo(); + extractFieldToMethod(GROUND_TEMPERATURE_LEVEL_2); + Optional gtTwoOpt = weatherValue.getGroundTemperatureLevel2(); if (gtTwoOpt.isPresent()) { valueResult.putAll(processObject(gtTwoOpt.get(), groundTempTwoFieldToMethod)); } diff --git a/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java b/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java index 8c4bccd0f..582295469 100644 --- a/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java +++ b/src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java @@ -29,10 +29,10 @@ public class WeatherValue implements Value { private final WindValue wind; /** Ground temperature value for this coordinate */ - private final Optional groundTemperatureValueOne; + private final Optional groundTemperatureLevel1; /** Ground temperature value for this coordinate */ - private final Optional groundTemperatureValueTwo; + private final Optional groundTemperatureLevel2; /** * @param coordinate of this weather value set @@ -53,8 +53,8 @@ public WeatherValue( this.solarIrradiance = solarIrradiance; this.temperature = temperature; this.wind = wind; - this.groundTemperatureValueOne = groundTemperatureValueOne; - this.groundTemperatureValueTwo = groundTemperatureValueTwo; + this.groundTemperatureLevel1 = groundTemperatureValueOne; + this.groundTemperatureLevel2 = groundTemperatureValueTwo; } /** @@ -106,12 +106,12 @@ public WindValue getWind() { return wind; } - public Optional getGroundTemperatureValueOne() { - return groundTemperatureValueOne; + public Optional getGroundTemperatureLevel1() { + return groundTemperatureLevel1; } - public Optional getGroundTemperatureValueTwo() { - return groundTemperatureValueTwo; + public Optional getGroundTemperatureLevel2() { + return groundTemperatureLevel2; } @Override @@ -123,8 +123,8 @@ public boolean equals(Object o) { && solarIrradiance.equals(that.solarIrradiance) && temperature.equals(that.temperature) && wind.equals(that.wind) - && Objects.equals(groundTemperatureValueOne, that.groundTemperatureValueOne) - && Objects.equals(groundTemperatureValueTwo, that.groundTemperatureValueTwo); + && Objects.equals(groundTemperatureLevel1, that.groundTemperatureLevel1) + && Objects.equals(groundTemperatureLevel2, that.groundTemperatureLevel2); } @Override @@ -134,8 +134,8 @@ public int hashCode() { solarIrradiance, temperature, wind, - groundTemperatureValueOne, - groundTemperatureValueTwo); + groundTemperatureLevel1, + groundTemperatureLevel2); } @Override @@ -149,10 +149,10 @@ public String toString() { + temperature + ", wind=" + wind - + ", groundTemperatureValueOne=" - + groundTemperatureValueOne - + ", groundTemperatureValueTwo=" - + groundTemperatureValueTwo + + ", groundTemperatureLevel1=" + + groundTemperatureLevel1 + + ", groundTemperatureLevel2=" + + groundTemperatureLevel2 + '}'; } } diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy index 5f3b4c98f..6e8fa2df3 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy @@ -29,8 +29,8 @@ class CosmoTimeBasedWeatherValueFactoryTest extends Specification { "temperature" : "", "windDirection" : "0", "windVelocity" : "1.66103506088257", - "groundTemperatureValueOne" : "", - "groundTemperatureValueTwo" : "" + "groundTemperatureLevel1" : "", + "groundTemperatureLevel2" : "" ] def data = new TimeBasedWeatherValueData(parameter, coordinate) @@ -66,8 +66,8 @@ class CosmoTimeBasedWeatherValueFactoryTest extends Specification { "temperature" : "278.019012451172", "windDirection" : "0", "windVelocity" : "1.66103506088257", - "groundTemperatureValueOne" : "", - "groundTemperatureValueTwo" : "" + "groundTemperatureLevel1" : "", + "groundTemperatureLevel2" : "" ] def data = new TimeBasedWeatherValueData(parameter, coordinate) diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactoryTest.groovy index 9750f3cc3..29e4a9884 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactoryTest.groovy @@ -84,8 +84,8 @@ class IconTimeBasedWeatherValueFactoryTest extends Specification { "aswdirS" : "2.317613203124999", "t2m" : "289.1179319051744", "tg" : "288.4101691197649", - "t_v1":"288.4101691197649", - "t_v2":"288.4101691197649", + "tg_1":"288.4101691197649", + "tg_2":"288.4101691197649", "u10m" : "0.3021732864307963", "u131m" : "2.6058700426057797", "u20m" : "0.32384365019387784", @@ -127,10 +127,10 @@ class IconTimeBasedWeatherValueFactoryTest extends Specification { assert QuantityUtil.isEquivalentAbs(it.value.wind.direction.get(), Quantities.getQuantity(214.16711674907722, PowerSystemUnits.DEGREE_GEOM)) assert it.value.wind.velocity.present assert QuantityUtil.isEquivalentAbs(it.value.wind.velocity.get(), Quantities.getQuantity(4.640010877529081, PowerSystemUnits.METRE_PER_SECOND)) - assert it.value.groundTemperatureValueOne.present - assert QuantityUtil.isEquivalentAbs(it.value.groundTemperatureValueOne.get().temperature.get(), Quantities.getQuantity(15.2601691197649, Units.CELSIUS)) - assert it.value.groundTemperatureValueTwo.present - assert QuantityUtil.isEquivalentAbs(it.value.groundTemperatureValueTwo.get().temperature.get(), Quantities.getQuantity(15.2601691197649, Units.CELSIUS)) + assert it.value.groundTemperatureLevel1.present + assert QuantityUtil.isEquivalentAbs(it.value.groundTemperatureLevel1.get().temperature.get(), Quantities.getQuantity(15.2601691197649, Units.CELSIUS)) + assert it.value.groundTemperatureLevel2.present + assert QuantityUtil.isEquivalentAbs(it.value.groundTemperatureLevel2.get().temperature.get(), Quantities.getQuantity(15.2601691197649, Units.CELSIUS)) } } } diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceCosmoTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceCosmoTest.groovy index ebaf0b1cd..7f42e9205 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceCosmoTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceCosmoTest.groovy @@ -127,8 +127,8 @@ class CsvWeatherSourceCosmoTest extends Specification implements CsvTestDataMeta "temperature" : "9.1011", "windVelocity" : "12.1314", "windDirection" : "15.1617", - "groundtemperatureone": "8.0", - "groundtemperaturetwo": "9.5" + "groundTemperaturLevel1": "8.0", + "groundTemperatureLevel2": "9.5" ] def expectedValue = new TimeBasedValue( TimeUtil.withDefaults.toZonedDateTime("2020-10-16T12:40:42Z"), @@ -176,8 +176,8 @@ class CsvWeatherSourceCosmoTest extends Specification implements CsvTestDataMeta "temperature" : "9.1011", "windvelocity" : "12.1314", "winddirection" : "15.1617", - "groundtemperatureone": "8.0", - "groundtemperaturetwo": "9.5" + "groundTemperaturLevel1": "8.0", + "groundTemperatureLevel2": "9.5" ] when: @@ -202,8 +202,8 @@ class CsvWeatherSourceCosmoTest extends Specification implements CsvTestDataMeta "temperature" : "9.1011", "windvelocity" : "12.1314", "winddirection" : "15.1617", - "groundtemperatureone": "8.0", - "groundtemperaturetwo": "9.5" + "groundTemperaturLevel1": "8.0", + "groundTemperatureLevel2": "9.5" ] when: @@ -228,8 +228,8 @@ class CsvWeatherSourceCosmoTest extends Specification implements CsvTestDataMeta "temperature" : "9.1011", "windvelocity" : "12.1314", "winddirection" : "15.1617", - "groundtemperatureone": "8.0", - "groundtemperaturetwo": "9.5" + "groundTemperaturLevel1": "8.0", + "groundTemperatureLevel2": "9.5" ] when: diff --git a/src/test/groovy/edu/ie3/test/common/TimeSeriesTestData.groovy b/src/test/groovy/edu/ie3/test/common/TimeSeriesTestData.groovy index b4c8e4948..7f95921f3 100644 --- a/src/test/groovy/edu/ie3/test/common/TimeSeriesTestData.groovy +++ b/src/test/groovy/edu/ie3/test/common/TimeSeriesTestData.groovy @@ -241,8 +241,8 @@ trait TimeSeriesTestData { "temperature" : "10.0", "time" : "2020-04-02T10:30:00Z", "velocity" : "15.0", - "groundTemperatureValueOne" : "10.0", - "groundTemperatureValueTwo" : "10.0" + "groundTemperatureLevel1" : "10.0", + "groundTemperatureLevel2" : "10.0" ] as LinkedHashMap ] as Set diff --git a/src/test/resources/edu/ie3/datamodel/io/source/csv/_weather/cosmo/its_weather_8bc9120d-fb9b-4484-b4e3-0cdadf0feea9.csv b/src/test/resources/edu/ie3/datamodel/io/source/csv/_weather/cosmo/its_weather_8bc9120d-fb9b-4484-b4e3-0cdadf0feea9.csv index 78140a740..0d60c0480 100644 --- a/src/test/resources/edu/ie3/datamodel/io/source/csv/_weather/cosmo/its_weather_8bc9120d-fb9b-4484-b4e3-0cdadf0feea9.csv +++ b/src/test/resources/edu/ie3/datamodel/io/source/csv/_weather/cosmo/its_weather_8bc9120d-fb9b-4484-b4e3-0cdadf0feea9.csv @@ -1,4 +1,4 @@ -"uuid";"coordinate_id";"time";"diffuse_irradiance";"direct_irradiance";"temperature";"wind_direction";"wind_velocity";"ground_temperature_value_one";"ground_temperature_value_two" +"uuid";"coordinate_id";"time";"diffuse_irradiance";"direct_irradiance";"temperature";"wind_direction";"wind_velocity";"ground_temperature_level_1";"ground_temperature_level_2" "3cee46d5-1fe7-419e-a652-32f9be6703be";193186;"2020-04-28T15:00:00Z";286.872985839844;282.671997070312;278.019012451172;0;1.66103506088257;279.5;281.0 "1fbc6f7e-52fe-4668-93c8-33454d7feb6c";193187;"2020-04-28T15:00:00Z";287.872985839844;283.671997070312;279.019012451172;0;1.76103506088257;280.5;281.1 "78c7a057-ad6c-4ea1-bb74-7e28fbb08957";193188;"2020-04-28T15:00:00Z";288.872985839844;284.671997070312;280.019012451172;0;1.86103506088257;281.5;281.2 diff --git a/src/test/resources/edu/ie3/datamodel/io/source/csv/_weather/icon/its_weather_513606bc-539e-445b-9675-2f98be3d9231.csv b/src/test/resources/edu/ie3/datamodel/io/source/csv/_weather/icon/its_weather_513606bc-539e-445b-9675-2f98be3d9231.csv index 0eecd99d4..81e688308 100644 --- a/src/test/resources/edu/ie3/datamodel/io/source/csv/_weather/icon/its_weather_513606bc-539e-445b-9675-2f98be3d9231.csv +++ b/src/test/resources/edu/ie3/datamodel/io/source/csv/_weather/icon/its_weather_513606bc-539e-445b-9675-2f98be3d9231.csv @@ -1,4 +1,4 @@ -"time","alb_rad","asob_s","aswdifd_s","aswdifu_s","aswdir_s","t_2m","t_g","t_v1","t_v2","u_10m","u_131m","u_20m","u_216m","u_65m","v_10m","v_131m","v_20m","v_216m","v_65m","w_131m","w_20m","w_216m","w_65m","z0","coordinate_id","p_131m","p_20m","p_65m","sobs_rad","t_131m" +"time","alb_rad","asob_s","aswdifd_s","aswdifu_s","aswdir_s","t_2m","t_g","tg_1","tg_2","u_10m","u_131m","u_20m","u_216m","u_65m","v_10m","v_131m","v_20m","v_216m","v_65m","w_131m","w_20m","w_216m","w_65m","z0","coordinate_id","p_131m","p_20m","p_65m","sobs_rad","t_131m" "2019-08-01T15:00:00Z",13.015240669,503.46974264373205,228.021339757131,80.8246124780934,356.2648859375,297.6241992659816,300.6632065668998,300.6632065668998,289.5,2.594603775363224,3.7658971156831287,2.5812495613105044,3.941521213236469,3.4740205817325034,-0.024078646721241395,-0.029760831916596106,-0.052967885304510534,-0.009698125518755707,-0.04996610799324721,0.004091443774095653,0.0015809058504647026,0.005954484657501378,0.002666343696204668,0.9553221665631989,67775,,,,, "2019-08-01T15:00:00Z",13.013334274000002,498.219742300774,245.24079037841295,80.0782271098217,333.0547140625,295.515335568404,297.43684351873816,300.6632065668998,289.2,2.6907481330116054,4.001601219938975,2.6888332994845783,4.140469437423411,3.714032263672762,1.2097386659833593,1.8148233176685413,1.1963736417917374,1.8944592514336933,1.667063608988315,-0.010735134459808796,-0.006350491263316599,-0.012234044440804974,-0.009044908476315713,0.955336762972383,67776,,,,, "2019-08-01T16:00:00Z",13.015240669,348.84439309613776,200.46049098038043,56.00436431107297,204.38963365625,297.3200023473353,298.8447737622156,300.6632065668998,289.5,2.557259341952788,4.0165196739267675,2.5543417132442308,4.204610497390883,3.6709121158156393,-0.38463576259530396,-0.5748064219197632,-0.4001297004267148,-0.574231301551345,-0.5484601012731134,0.008420781588303635,0.004028919955548831,0.0103738560877878,0.0064212084500956355,0.9553236526118866,67775,,,,, diff --git a/src/test/resources/edu/ie3/datamodel/io/source/influxdb/_weather/cosmo/weather.txt b/src/test/resources/edu/ie3/datamodel/io/source/influxdb/_weather/cosmo/weather.txt index c5b35c5c8..8d62e9867 100644 --- a/src/test/resources/edu/ie3/datamodel/io/source/influxdb/_weather/cosmo/weather.txt +++ b/src/test/resources/edu/ie3/datamodel/io/source/influxdb/_weather/cosmo/weather.txt @@ -5,9 +5,9 @@ CREATE DATABASE test_weather # CONTEXT-DATABASE: test_weather -weather,coordinate_id=193186 diffuse_irradiance=286.872985839844,direct_irradiance=282.671997070312,temperature=278.019012451172,wind_direction=0,wind_velocity=1.66103506088257,groundtemperature_value_one=278.019012451172,groundtemperature_value_two=278.019012451172 1588086000000 -weather,coordinate_id=193187 diffuse_irradiance=287.872985839844,direct_irradiance=283.671997070312,temperature=279.019012451172,wind_direction=0,wind_velocity=1.76103506088257,groundtemperature_value_one=278.019012451172,groundtemperature_value_two=278.019012451172 1588086000000 -weather,coordinate_id=193188 diffuse_irradiance=288.872985839844,direct_irradiance=284.671997070312,temperature=280.019012451172,wind_direction=0,wind_velocity=1.86103506088257,groundtemperature_value_one=278.019012451172,groundtemperature_value_two=278.019012451172 1588086000000 -weather,coordinate_id=193186 diffuse_irradiance=286.872,direct_irradiance=282.672,temperature=278.012,wind_direction=0,wind_velocity=1.662,groundtemperature_value_one=278.019012451172,groundtemperature_value_two=278.019012451172 1588089600000 -weather,coordinate_id=193187 diffuse_irradiance=287.872,direct_irradiance=283.672,temperature=279.012,wind_direction=0,wind_velocity=1.762,groundtemperature_value_one=278.019012451172,groundtemperature_value_two=278.019012451172 1588089600000 -weather,coordinate_id=193186 diffuse_irradiance=286.873,direct_irradiance=282.673,temperature=278.013,wind_direction=0,wind_velocity=1.663,groundtemperature_value_one=278.019012451172,groundtemperature_value_two=278.019012451172 1588093200000 +weather,coordinate_id=193186 diffuse_irradiance=286.872985839844,direct_irradiance=282.671997070312,temperature=278.019012451172,wind_direction=0,wind_velocity=1.66103506088257,ground_temperature_level_1=278.019012451172,ground_temperature_level_2=278.019012451172 1588086000000 +weather,coordinate_id=193187 diffuse_irradiance=287.872985839844,direct_irradiance=283.671997070312,temperature=279.019012451172,wind_direction=0,wind_velocity=1.76103506088257,ground_temperature_level_1=278.019012451172,ground_temperature_level_2=278.019012451172 1588086000000 +weather,coordinate_id=193188 diffuse_irradiance=288.872985839844,direct_irradiance=284.671997070312,temperature=280.019012451172,wind_direction=0,wind_velocity=1.86103506088257,ground_temperature_level_1=278.019012451172,ground_temperature_level_2=278.019012451172 1588086000000 +weather,coordinate_id=193186 diffuse_irradiance=286.872,direct_irradiance=282.672,temperature=278.012,wind_direction=0,wind_velocity=1.662,ground_temperature_level_1=278.019012451172,ground_temperature_level_2=278.019012451172 1588089600000 +weather,coordinate_id=193187 diffuse_irradiance=287.872,direct_irradiance=283.672,temperature=279.012,wind_direction=0,wind_velocity=1.762,ground_temperature_level_1=278.019012451172,ground_temperature_level_2=278.019012451172 1588089600000 +weather,coordinate_id=193186 diffuse_irradiance=286.873,direct_irradiance=282.673,temperature=278.013,wind_direction=0,wind_velocity=1.663,ground_temperature_level_1=278.019012451172,ground_temperature_level_2=278.019012451172 1588093200000 diff --git a/src/test/resources/edu/ie3/datamodel/io/source/influxdb/_weather/icon/weather.txt b/src/test/resources/edu/ie3/datamodel/io/source/influxdb/_weather/icon/weather.txt index 043676904..a7d536858 100644 --- a/src/test/resources/edu/ie3/datamodel/io/source/influxdb/_weather/icon/weather.txt +++ b/src/test/resources/edu/ie3/datamodel/io/source/influxdb/_weather/icon/weather.txt @@ -5,8 +5,8 @@ CREATE DATABASE test_weather # CONTEXT-DATABASE: test_weather -weather,coordinate_id=67775 alb_rad=13.0152406690000007,asob_s=503.46974264373199,aswdifd_s=228.021339757130988,aswdifu_s=80.8246124780933997,aswdir_s=356.264885937500026,t_2m=297.624199265981986,t_g=300.663206566899987,t_v1=300.663206566899987,t_v2=300.663206566899987,u_10m=2.59460377536322007,u_131m=3.76589711568313001,u_20m=2.58124956131049998,u_216m=3.94152121323647009,u_65m=3.47402058173249983,v_10m=-0.0240786467212413986,v_131m=-0.0297608319165960991,v_20m=-0.0529678853045104994,v_216m=-0.00969812551875571041,v_65m=-0.0499661079932472024,w_131m=0.00409144377409564972,w_20m=0.00158090585046470004,w_216m=0.00595448465750138007,w_65m=0.00266634369620467014,z_0=0.955322166563199016,p_131m=42.0,p_20m=42.0,p_65m=42.0,sobsrad=42.0,t_131m=42.0 1564671600000 -weather,coordinate_id=67775 alb_rad=13.0152406690000007,asob_s=348.844393096137992,aswdifd_s=200.460490980380001,aswdifu_s=56.0043643110729974,aswdir_s=204.389633656249998,t_2m=297.320002347334992,t_g=298.844773762215993,t_v1=300.663206566899987,t_v2=300.663206566899987,u_10m=2.55725934195278981,u_131m=4.01651967392677012,u_20m=2.55434171324422987,u_216m=4.20461049739088022,u_65m=3.67091211581564014,v_10m=-0.38463576259530402,v_131m=-0.574806421919763055,v_20m=-0.400129700426714974,v_216m=-0.574231301551345052,v_65m=-0.548460101273112954,w_131m=0.00842078158830364062,w_20m=0.0040289199555488299,w_216m=0.0103738560877878003,w_65m=0.00642120845009563988,z_0=0.955323652611887009,p_131m=42.0,p_20m=42.0,p_65m=42.0,sobsrad=42.0,t_131m=42.0 1564675200000 -weather,coordinate_id=67775 alb_rad=13.0152406690000007,asob_s=306.571394509505012,aswdifd_s=180.734296104001999,aswdifu_s=49.1986036554934003,aswdir_s=175.039569078124998,t_2m=296.828740358407003,t_g=297.659601745757016,t_v1=300.663206566899987,t_v2=300.663206566899987,u_10m=2.25171266161903016,u_131m=3.65066950489564013,u_20m=2.24389620037050008,u_216m=3.79807360304292985,u_65m=3.33915291121141999,v_10m=-0.695089352961929974,v_131m=-1.10853234501432008,v_20m=-0.71224786535059903,v_216m=-1.12930575743681993,v_65m=-1.03523090092579007,w_131m=0.0124649216553269007,w_20m=0.00596557511757611018,w_216m=0.0152653602980476998,w_65m=0.00963211312941292079,z_0=0.955322760336951959,p_131m=42.0,p_20m=42.0,p_65m=42.0,sobsrad=42.0,t_131m=42.0 1564678800000 -weather,coordinate_id=67776 alb_rad=13.013334274,asob_s=498.219742300773987,aswdifd_s=245.24079037841301,aswdifu_s=80.0782271098216967,aswdir_s=333.054714062500011,t_2m=295.515335568403998,t_g=297.436843518737987,t_v1=300.663206566899987,t_v2=300.663206566899987,u_10m=2.69074813301160987,u_131m=4.00160121993897988,u_20m=2.68883329948458005,u_216m=4.14046943742340989,u_65m=3.71403226367276007,v_10m=1.20973866598336,v_131m=1.81482331766853999,v_20m=1.19637364179174011,v_216m=1.89445925143368998,v_65m=1.66706360898831996,w_131m=-0.0107351344598088008,w_20m=-0.00635049126331660007,w_216m=-0.0122340444408049996,w_65m=-0.00904490847631570991,z_0=0.955336762972383013,p_131m=42.0,p_20m=42.0,p_65m=42.0,sobsrad=42.0,t_131m=42.0 1564671600000 -weather,coordinate_id=67776 alb_rad=13.013334274,asob_s=287.163521177577024,aswdifd_s=241.641483540946012,aswdifu_s=46.1826228914205998,aswdir_s=91.7093913229697932,t_2m=293.455111314490978,t_g=294.987683227438993,t_v1=300.663206566899987,t_v2=300.663206566899987,u_10m=2.24292571281681008,u_131m=3.28865545990927988,u_20m=2.24693045663628999,u_216m=3.45619617779588006,u_65m=3.06350529841654984,v_10m=0.705285607539457016,v_131m=1.0173658432825099,v_20m=0.694030995652130001,v_216m=1.08316452397627994,v_65m=0.940270018404623986,w_131m=-0.00960905133118966984,w_20m=-0.00372074627807390985,w_216m=-0.0126429015220642007,w_65m=-0.00643946343215642987,z_0=0.955336572337003975,p_131m=42.0,p_20m=42.0,p_65m=42.0,sobsrad=42.0,t_131m=42.0 1564675200000 +weather,coordinate_id=67775 alb_rad=13.0152406690000007,asob_s=503.46974264373199,aswdifd_s=228.021339757130988,aswdifu_s=80.8246124780933997,aswdir_s=356.264885937500026,t_2m=297.624199265981986,t_g=300.663206566899987,tg_1=300.663206566899987,tg_2=300.663206566899987,u_10m=2.59460377536322007,u_131m=3.76589711568313001,u_20m=2.58124956131049998,u_216m=3.94152121323647009,u_65m=3.47402058173249983,v_10m=-0.0240786467212413986,v_131m=-0.0297608319165960991,v_20m=-0.0529678853045104994,v_216m=-0.00969812551875571041,v_65m=-0.0499661079932472024,w_131m=0.00409144377409564972,w_20m=0.00158090585046470004,w_216m=0.00595448465750138007,w_65m=0.00266634369620467014,z_0=0.955322166563199016,p_131m=42.0,p_20m=42.0,p_65m=42.0,sobsrad=42.0,t_131m=42.0 1564671600000 +weather,coordinate_id=67775 alb_rad=13.0152406690000007,asob_s=348.844393096137992,aswdifd_s=200.460490980380001,aswdifu_s=56.0043643110729974,aswdir_s=204.389633656249998,t_2m=297.320002347334992,t_g=298.844773762215993,tg_1=300.663206566899987,tg_2=300.663206566899987,u_10m=2.55725934195278981,u_131m=4.01651967392677012,u_20m=2.55434171324422987,u_216m=4.20461049739088022,u_65m=3.67091211581564014,v_10m=-0.38463576259530402,v_131m=-0.574806421919763055,v_20m=-0.400129700426714974,v_216m=-0.574231301551345052,v_65m=-0.548460101273112954,w_131m=0.00842078158830364062,w_20m=0.0040289199555488299,w_216m=0.0103738560877878003,w_65m=0.00642120845009563988,z_0=0.955323652611887009,p_131m=42.0,p_20m=42.0,p_65m=42.0,sobsrad=42.0,t_131m=42.0 1564675200000 +weather,coordinate_id=67775 alb_rad=13.0152406690000007,asob_s=306.571394509505012,aswdifd_s=180.734296104001999,aswdifu_s=49.1986036554934003,aswdir_s=175.039569078124998,t_2m=296.828740358407003,t_g=297.659601745757016,tg_1=300.663206566899987,tg_2=300.663206566899987,u_10m=2.25171266161903016,u_131m=3.65066950489564013,u_20m=2.24389620037050008,u_216m=3.79807360304292985,u_65m=3.33915291121141999,v_10m=-0.695089352961929974,v_131m=-1.10853234501432008,v_20m=-0.71224786535059903,v_216m=-1.12930575743681993,v_65m=-1.03523090092579007,w_131m=0.0124649216553269007,w_20m=0.00596557511757611018,w_216m=0.0152653602980476998,w_65m=0.00963211312941292079,z_0=0.955322760336951959,p_131m=42.0,p_20m=42.0,p_65m=42.0,sobsrad=42.0,t_131m=42.0 1564678800000 +weather,coordinate_id=67776 alb_rad=13.013334274,asob_s=498.219742300773987,aswdifd_s=245.24079037841301,aswdifu_s=80.0782271098216967,aswdir_s=333.054714062500011,t_2m=295.515335568403998,t_g=297.436843518737987,tg_1=300.663206566899987,tg_2=300.663206566899987,u_10m=2.69074813301160987,u_131m=4.00160121993897988,u_20m=2.68883329948458005,u_216m=4.14046943742340989,u_65m=3.71403226367276007,v_10m=1.20973866598336,v_131m=1.81482331766853999,v_20m=1.19637364179174011,v_216m=1.89445925143368998,v_65m=1.66706360898831996,w_131m=-0.0107351344598088008,w_20m=-0.00635049126331660007,w_216m=-0.0122340444408049996,w_65m=-0.00904490847631570991,z_0=0.955336762972383013,p_131m=42.0,p_20m=42.0,p_65m=42.0,sobsrad=42.0,t_131m=42.0 1564671600000 +weather,coordinate_id=67776 alb_rad=13.013334274,asob_s=287.163521177577024,aswdifd_s=241.641483540946012,aswdifu_s=46.1826228914205998,aswdir_s=91.7093913229697932,t_2m=293.455111314490978,t_g=294.987683227438993,tg_1=300.663206566899987,tg_2=300.663206566899987,u_10m=2.24292571281681008,u_131m=3.28865545990927988,u_20m=2.24693045663628999,u_216m=3.45619617779588006,u_65m=3.06350529841654984,v_10m=0.705285607539457016,v_131m=1.0173658432825099,v_20m=0.694030995652130001,v_216m=1.08316452397627994,v_65m=0.940270018404623986,w_131m=-0.00960905133118966984,w_20m=-0.00372074627807390985,w_216m=-0.0126429015220642007,w_65m=-0.00643946343215642987,z_0=0.955336572337003975,p_131m=42.0,p_20m=42.0,p_65m=42.0,sobsrad=42.0,t_131m=42.0 1564675200000 diff --git a/src/test/resources/edu/ie3/datamodel/io/source/sql/_weather/cosmo/weather.sql b/src/test/resources/edu/ie3/datamodel/io/source/sql/_weather/cosmo/weather.sql index 055698ba1..23480853f 100644 --- a/src/test/resources/edu/ie3/datamodel/io/source/sql/_weather/cosmo/weather.sql +++ b/src/test/resources/edu/ie3/datamodel/io/source/sql/_weather/cosmo/weather.sql @@ -27,11 +27,11 @@ CREATE INDEX weather_coordinate_id_time_idx TABLESPACE pg_default; INSERT INTO - public.weather (time, coordinate_id, diffuse_irradiance, direct_irradiance, wind_direction, wind_velocity, temperature) + public.weather (time, coordinate_id, diffuse_irradiance, direct_irradiance, wind_direction, wind_velocity, temperature, ground_temperature_level_1, ground_temperature_level_2) VALUES -('2020-04-28 15:00:00+0', 193186, 286.872985839844, 282.671997070312, 0, 1.66103506088257, 278.019012451172), -('2020-04-28 15:00:00+0', 193187, 287.872985839844, 283.671997070312, 0, 1.76103506088257, 279.019012451172), -('2020-04-28 15:00:00+0', 193188, 288.872985839844, 284.671997070312, 0, 1.86103506088257, 280.019012451172), +('2020-04-28 15:00:00+0', 193186, 286.872985839844, 282.671997070312, 0, 1.66103506088257, 278.019012451172, 278.019012451172, 278.019012451172), +('2020-04-28 15:00:00+0', 193187, 287.872985839844, 283.671997070312, 0, 1.76103506088257, 279.019012451172, 278.019012451172, 278.019012451172), +('2020-04-28 15:00:00+0', 193188, 288.872985839844, 284.671997070312, 0, 1.86103506088257, 280.019012451172, 278.019012451172, 278.019012451172), ('2020-04-28 16:00:00+0', 193186, 286.872, 282.672, 0, 1.662, 278.012), ('2020-04-28 16:00:00+0', 193187, 287.872, 283.672, 0, 1.762, 279.012), ('2020-04-28 17:00:00+0', 193186, 286.873, 282.673, 0, 1.663, 278.013); diff --git a/src/test/resources/edu/ie3/datamodel/io/source/sql/_weather/icon/weather.sql b/src/test/resources/edu/ie3/datamodel/io/source/sql/_weather/icon/weather.sql index e88d77c0f..e553ea39f 100644 --- a/src/test/resources/edu/ie3/datamodel/io/source/sql/_weather/icon/weather.sql +++ b/src/test/resources/edu/ie3/datamodel/io/source/sql/_weather/icon/weather.sql @@ -48,10 +48,10 @@ CREATE INDEX weather_coordinate_time_idx TABLESPACE pg_default; INSERT INTO - public.weather (time, alb_rad, asob_s, aswdifd_s, aswdifu_s, aswdir_s, t_2m, t_g, u_10m, u_131m, u_20m, u_216m, u_65m, v_10m, v_131m, v_20m, v_216m, v_65m, w_131m, w_20m, w_216m, w_65m, z0, coordinate_id, p_131m, p_20m, p_65m, sobs_rad, t_131m) + public.weather (time, alb_rad, asob_s, aswdifd_s, aswdifu_s, aswdir_s, t_2m, t_g, tg_1, tg_2, u_10m, u_131m, u_20m, u_216m, u_65m, v_10m, v_131m, v_20m, v_216m, v_65m, w_131m, w_20m, w_216m, w_65m, z0, coordinate_id, p_131m, p_20m, p_65m, sobs_rad, t_131m) VALUES -('2019-08-01 15:00:00+0', 13.015240669, 503.469742643732, 228.021339757131, 80.8246124780934, 356.2648859375, 297.624199265982, 300.6632065669, 2.59460377536322, 3.76589711568313, 2.5812495613105, 3.94152121323647, 3.4740205817325, -0.0240786467212414, -0.0297608319165961, -0.0529678853045105, -0.00969812551875571, -0.0499661079932472, 0.00409144377409565, 0.0015809058504647, 0.00595448465750138, 0.00266634369620467, 0.955322166563199, 67775, NULL, NULL, NULL, NULL, NULL), -('2019-08-01 16:00:00+0', 13.015240669, 348.844393096138, 200.46049098038, 56.004364311073, 204.38963365625, 297.320002347335, 298.844773762216, 2.55725934195279, 4.01651967392677, 2.55434171324423, 4.20461049739088, 3.67091211581564, -0.384635762595304, -0.574806421919763, -0.400129700426715, -0.574231301551345, -0.548460101273113, 0.00842078158830364, 0.00402891995554883, 0.0103738560877878, 0.00642120845009564, 0.955323652611887, 67775, NULL, NULL, NULL, NULL, NULL), -('2019-08-01 17:00:00+0', 13.015240669, 306.571394509505, 180.734296104002, 49.1986036554934, 175.039569078125, 296.828740358407, 297.659601745757, 2.25171266161903, 3.65066950489564, 2.2438962003705, 3.79807360304293, 3.33915291121142, -0.69508935296193, -1.10853234501432, -0.712247865350599, -1.12930575743682, -1.03523090092579, 0.0124649216553269, 0.00596557511757611, 0.0152653602980477, 0.00963211312941292, 0.955322760336952, 67775, NULL, NULL, NULL, NULL, NULL), -('2019-08-01 15:00:00+0', 13.013334274, 498.219742300774, 245.240790378413, 80.0782271098217, 333.0547140625, 295.515335568404, 297.436843518738, 2.69074813301161, 4.00160121993898, 2.68883329948458, 4.14046943742341, 3.71403226367276, 1.20973866598336, 1.81482331766854, 1.19637364179174, 1.89445925143369, 1.66706360898832, -0.0107351344598088, -0.0063504912633166, -0.012234044440805, -0.00904490847631571, 0.955336762972383, 67776, NULL, NULL, NULL, NULL, NULL), -('2019-08-01 16:00:00+0', 13.013334274, 287.163521177577, 241.641483540946, 46.1826228914206, 91.7093913229698, 293.455111314491, 294.987683227439, 2.24292571281681, 3.28865545990928, 2.24693045663629, 3.45619617779588, 3.06350529841655, 0.705285607539457, 1.01736584328251, 0.69403099565213, 1.08316452397628, 0.940270018404624, -0.00960905133118967, -0.00372074627807391, -0.0126429015220642, -0.00643946343215643, 0.955336572337004, 67776, NULL, NULL, NULL, NULL, NULL); +('2019-08-01 15:00:00+0', 13.015240669, 503.469742643732, 228.021339757131, 80.8246124780934, 356.2648859375, 297.624199265982, 300.6632065669, 278.019012451172, 278.019012451172, 2.59460377536322, 3.76589711568313, 2.5812495613105, 3.94152121323647, 3.4740205817325, -0.0240786467212414, -0.0297608319165961, -0.0529678853045105, -0.00969812551875571, -0.0499661079932472, 0.00409144377409565, 0.0015809058504647, 0.00595448465750138, 0.00266634369620467, 0.955322166563199, 67775, NULL, NULL, NULL, NULL, NULL), +('2019-08-01 16:00:00+0', 13.015240669, 348.844393096138, 200.46049098038, 56.004364311073, 204.38963365625, 297.320002347335, 298.844773762216, 278.019012451172, 278.019012451172, 2.55725934195279, 4.01651967392677, 2.55434171324423, 4.20461049739088, 3.67091211581564, -0.384635762595304, -0.574806421919763, -0.400129700426715, -0.574231301551345, -0.548460101273113, 0.00842078158830364, 0.00402891995554883, 0.0103738560877878, 0.00642120845009564, 0.955323652611887, 67775, NULL, NULL, NULL, NULL, NULL), +('2019-08-01 17:00:00+0', 13.015240669, 306.571394509505, 180.734296104002, 49.1986036554934, 175.039569078125, 296.828740358407, 297.659601745757, 278.019012451172, 278.019012451172, 2.25171266161903, 3.65066950489564, 2.2438962003705, 3.79807360304293, 3.33915291121142, -0.69508935296193, -1.10853234501432, -0.712247865350599, -1.12930575743682, -1.03523090092579, 0.0124649216553269, 0.00596557511757611, 0.0152653602980477, 0.00963211312941292, 0.955322760336952, 67775, NULL, NULL, NULL, NULL, NULL), +('2019-08-01 15:00:00+0', 13.013334274, 498.219742300774, 245.240790378413, 80.0782271098217, 333.0547140625, 295.515335568404, 297.436843518738, 278.019012451172, 278.019012451172, 2.69074813301161, 4.00160121993898, 2.68883329948458, 4.14046943742341, 3.71403226367276, 1.20973866598336, 1.81482331766854, 1.19637364179174, 1.89445925143369, 1.66706360898832, -0.0107351344598088, -0.0063504912633166, -0.012234044440805, -0.00904490847631571, 0.955336762972383, 67776, NULL, NULL, NULL, NULL, NULL), +('2019-08-01 16:00:00+0', 13.013334274, 287.163521177577, 241.641483540946, 46.1826228914206, 91.7093913229698, 293.455111314491, 294.987683227439, 278.019012451172, 278.019012451172, 2.24292571281681, 3.28865545990928, 2.24693045663629, 3.45619617779588, 3.06350529841655, 0.705285607539457, 1.01736584328251, 0.69403099565213, 1.08316452397628, 0.940270018404624, -0.00960905133118967, -0.00372074627807391, -0.0126429015220642, -0.00643946343215643, 0.955336572337004, 67776, NULL, NULL, NULL, NULL, NULL); From 9d7215c23b5215e84e0c0d376b5d333533ffeb76 Mon Sep 17 00:00:00 2001 From: pierrepetersmeier <155652256+pierrepetersmeier@users.noreply.github.com> Date: Thu, 6 Nov 2025 15:15:25 +0100 Subject: [PATCH 36/36] Fix tests --- .../processor/timeseries/TimeSeriesProcessor.java | 13 ++++++++++--- .../io/source/sql/_weather/cosmo/weather.sql | 2 ++ .../io/source/sql/_weather/icon/weather.sql | 4 ++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/main/java/edu/ie3/datamodel/io/processor/timeseries/TimeSeriesProcessor.java b/src/main/java/edu/ie3/datamodel/io/processor/timeseries/TimeSeriesProcessor.java index dd9b74988..030253967 100644 --- a/src/main/java/edu/ie3/datamodel/io/processor/timeseries/TimeSeriesProcessor.java +++ b/src/main/java/edu/ie3/datamodel/io/processor/timeseries/TimeSeriesProcessor.java @@ -165,7 +165,14 @@ private SortedMap buildFieldToSource( if (valueClass.equals(WeatherValue.class)) { /* Treat the nested weather values specially. */ /* Flatten the nested structure of Weather value */ - mapFieldNameToGetter(valueClass, Arrays.asList("solarIrradiance", "temperature", "wind")) + mapFieldNameToGetter( + valueClass, + Arrays.asList( + "solarIrradiance", + "temperature", + "wind", + "groundTemperatureLevel1", + "groundTemperatureLevel2")) .forEach(addFunction.apply(VALUE)); mapFieldNameToGetter(SolarIrradianceValue.class) @@ -177,12 +184,12 @@ private SortedMap buildFieldToSource( (fieldName, getter) -> addFunction .apply(GROUND_TEMPERATURE_LEVEL_1) - .accept("groundTemperatureValueOne", getter)); + .accept("groundTemperatureLevel1", getter)); groundTempMap.forEach( (fieldName, getter) -> addFunction .apply(GROUND_TEMPERATURE_LEVEL_2) - .accept("groundTemperatureValueTwo", getter)); + .accept("groundTemperatureLevel2", getter)); } else if (valueClass.equals(BdewLoadValues.class)) { diff --git a/src/test/resources/edu/ie3/datamodel/io/source/sql/_weather/cosmo/weather.sql b/src/test/resources/edu/ie3/datamodel/io/source/sql/_weather/cosmo/weather.sql index 23480853f..329eea708 100644 --- a/src/test/resources/edu/ie3/datamodel/io/source/sql/_weather/cosmo/weather.sql +++ b/src/test/resources/edu/ie3/datamodel/io/source/sql/_weather/cosmo/weather.sql @@ -8,6 +8,8 @@ CREATE TABLE public.weather wind_velocity double precision, temperature double precision, tid serial, + ground_temperature_level_1 double precision, + ground_temperature_level_2 double precision, CONSTRAINT weather_pkey PRIMARY KEY (tid), CONSTRAINT "weather_datum_coordinate_id_unique" UNIQUE (time, coordinate_id) ) diff --git a/src/test/resources/edu/ie3/datamodel/io/source/sql/_weather/icon/weather.sql b/src/test/resources/edu/ie3/datamodel/io/source/sql/_weather/icon/weather.sql index e553ea39f..e0e830a5b 100644 --- a/src/test/resources/edu/ie3/datamodel/io/source/sql/_weather/icon/weather.sql +++ b/src/test/resources/edu/ie3/datamodel/io/source/sql/_weather/icon/weather.sql @@ -6,8 +6,8 @@ CREATE TABLE public.weather aswdifd_s double precision, aswdifu_s double precision, aswdir_s double precision, - t_2m double precision, - t_g double precision, + tg_1 double precision, + tg_2 double precision, u_10m double precision, u_131m double precision, u_20m double precision,