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=" + '}'; } }