Skip to content

Commit 6bb6984

Browse files
Add ground temperature (1m) as option to weather data.
1 parent 571f498 commit 6bb6984

File tree

3 files changed

+75
-16
lines changed

3 files changed

+75
-16
lines changed

src/main/java/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactory.java

Lines changed: 47 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,23 @@
77

88
import edu.ie3.datamodel.models.StandardUnits;
99
import edu.ie3.datamodel.models.timeseries.individual.TimeBasedValue;
10+
import edu.ie3.datamodel.models.value.SolarIrradianceValue;
11+
import edu.ie3.datamodel.models.value.TemperatureValue;
1012
import edu.ie3.datamodel.models.value.WeatherValue;
13+
import edu.ie3.datamodel.models.value.WindValue;
1114
import edu.ie3.util.TimeUtil;
1215
import edu.ie3.util.quantities.PowerSystemUnits;
1316
import edu.ie3.util.quantities.interfaces.Irradiance;
1417
import java.time.ZonedDateTime;
1518
import java.time.format.DateTimeFormatter;
16-
import java.util.Collections;
17-
import java.util.List;
18-
import java.util.Set;
19+
import java.util.*;
1920
import javax.measure.quantity.Angle;
21+
import javax.measure.quantity.Length;
2022
import javax.measure.quantity.Speed;
2123
import javax.measure.quantity.Temperature;
2224
import org.locationtech.jts.geom.Point;
2325
import tech.units.indriya.ComparableQuantity;
26+
import tech.units.indriya.quantity.Quantities;
2427

2528
/**
2629
* Factory implementation of {@link TimeBasedWeatherValueFactory}, that is able to handle field to
@@ -33,6 +36,9 @@ public class CosmoTimeBasedWeatherValueFactory extends TimeBasedWeatherValueFact
3336
private static final String WIND_DIRECTION = "windDirection";
3437
private static final String WIND_VELOCITY = "windVelocity";
3538

39+
private static final String GROUND_TEMPERATURE_SURFACE = "groundTemperatureSurface";
40+
private static final String GROUND_TEMPERATURE_1M = "groundTemperature1m";
41+
3642
public CosmoTimeBasedWeatherValueFactory(TimeUtil timeUtil) {
3743
super(timeUtil);
3844
}
@@ -55,31 +61,58 @@ protected List<Set<String>> getFields(Class<?> entityClass) {
5561
TEMPERATURE,
5662
WIND_DIRECTION,
5763
WIND_VELOCITY);
64+
65+
Set<String> allParameters =
66+
expandSet(minConstructorParams, GROUND_TEMPERATURE_SURFACE, GROUND_TEMPERATURE_1M);
67+
minConstructorParams.remove(COORDINATE_ID);
68+
allParameters.remove(COORDINATE_ID);
5869
return Collections.singletonList(minConstructorParams);
5970
}
6071

6172
@Override
6273
protected TimeBasedValue<WeatherValue> buildModel(TimeBasedWeatherValueData data) {
6374
Point coordinate = data.getCoordinate();
6475
ZonedDateTime time = timeUtil.toZonedDateTime(data.getField(TIME));
65-
ComparableQuantity<Irradiance> directIrradiance =
66-
data.getQuantity(DIRECT_IRRADIANCE, PowerSystemUnits.WATT_PER_SQUAREMETRE);
67-
ComparableQuantity<Irradiance> diffuseIrradiance =
68-
data.getQuantity(DIFFUSE_IRRADIANCE, PowerSystemUnits.WATT_PER_SQUAREMETRE);
69-
ComparableQuantity<Temperature> temperature =
70-
data.getQuantity(TEMPERATURE, StandardUnits.TEMPERATURE);
71-
ComparableQuantity<Angle> windDirection =
72-
data.getQuantity(WIND_DIRECTION, StandardUnits.WIND_DIRECTION);
73-
ComparableQuantity<Speed> windVelocity =
74-
data.getQuantity(WIND_VELOCITY, StandardUnits.WIND_VELOCITY);
76+
SolarIrradianceValue solarIrradiance = new SolarIrradianceValue(
77+
data.getQuantity(DIRECT_IRRADIANCE, PowerSystemUnits.WATT_PER_SQUAREMETRE),
78+
data.getQuantity(DIFFUSE_IRRADIANCE, PowerSystemUnits.WATT_PER_SQUAREMETRE)
79+
);
80+
TemperatureValue temperature = new TemperatureValue(
81+
data.getQuantity(TEMPERATURE, StandardUnits.TEMPERATURE)
82+
);
83+
WindValue wind = new WindValue(
84+
data.getQuantity(WIND_DIRECTION, StandardUnits.WIND_DIRECTION),
85+
data.getQuantity(WIND_VELOCITY, StandardUnits.WIND_VELOCITY)
86+
);
87+
88+
Map<ComparableQuantity<Length>, TemperatureValue> groundTemperatures = new HashMap<>();
89+
90+
91+
data.getField(GROUND_TEMPERATURE_SURFACE).ifPresent(value -> {
92+
ComparableQuantity<Length> depth = Quantities.getQuantity(0, StandardUnits.DEPTH);
93+
TemperatureValue tempValue = new TemperatureValue(
94+
data.getQuantity(GROUND_TEMPERATURE_SURFACE, StandardUnits.TEMPERATURE)
95+
);
96+
groundTemperatures.put(depth, tempValue);
97+
});
98+
99+
data.getField(GROUND_TEMPERATURE_1M).ifPresent(value -> {
100+
ComparableQuantity<Length> depth = Quantities.getQuantity(1, StandardUnits.DEPTH);
101+
TemperatureValue tempValue = new TemperatureValue(
102+
data.getQuantity(GROUND_TEMPERATURE_1M, StandardUnits.TEMPERATURE)
103+
);
104+
groundTemperatures.put(depth, tempValue);
105+
});
106+
75107
WeatherValue weatherValue =
76108
new WeatherValue(
77109
coordinate,
78110
directIrradiance,
79111
diffuseIrradiance,
80112
temperature,
81113
windDirection,
82-
windVelocity);
114+
windVelocity,
115+
groundTemperatures);
83116
return new TimeBasedValue<>(time, weatherValue);
84117
}
85118
}

src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ public class IconTimeBasedWeatherValueFactory extends TimeBasedWeatherValueFacto
3434
private static final String WIND_VELOCITY_U = "u131m";
3535
private static final String WIND_VELOCITY_V = "v131m";
3636

37+
/** Ground-/Skin-Temperature at surface (0m) */
38+
private static final String GROUND_TEMP_SURFACE = "tG";
39+
/** Soil-Temperature at 100cm depth (example parameter name) */
40+
private static final String SOIL_TEMP_100CM = "tso100cm";
41+
3742
public IconTimeBasedWeatherValueFactory() {
3843
super();
3944
}

src/main/java/edu/ie3/datamodel/models/value/WeatherValue.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@
66
package edu.ie3.datamodel.models.value;
77

88
import edu.ie3.util.quantities.interfaces.Irradiance;
9+
import java.util.Collections;
10+
import java.util.HashMap;
11+
import java.util.Map;
912
import java.util.Objects;
1013
import javax.measure.quantity.Angle;
14+
import javax.measure.quantity.Length;
1115
import javax.measure.quantity.Speed;
1216
import javax.measure.quantity.Temperature;
1317
import org.locationtech.jts.geom.Point;
@@ -25,11 +29,14 @@ public class WeatherValue implements Value {
2529
/** Wind values for this coordinate */
2630
private final WindValue wind;
2731

32+
/** Optional: A map of ground temperatures at different depths. The key represents the depth. */
33+
private Map<ComparableQuantity<Length>, TemperatureValue> groundTemperatures = Map.of();
2834
/**
2935
* @param coordinate of this weather value set
3036
* @param solarIrradiance values for this coordinate
3137
* @param temperature values for this coordinate
3238
* @param wind values for this coordinate
39+
* @param groundTemperatures A map of ground temperatures at different depths
3340
*/
3441
public WeatherValue(
3542
Point coordinate,
@@ -40,6 +47,7 @@ public WeatherValue(
4047
this.solarIrradiance = solarIrradiance;
4148
this.temperature = temperature;
4249
this.wind = wind;
50+
this.groundTemperatures = Collections.unmodifiableMap(new HashMap<>(groundTemperatures));
4351
}
4452

4553
/**
@@ -81,6 +89,16 @@ public WindValue getWind() {
8189
return wind;
8290
}
8391

92+
/**
93+
* Returns a map of ground temperatures, with the depth as key. The map is unmodifiable. Returns
94+
* an empty map if no values are available.
95+
*
96+
* @return A map of ground temperatures.
97+
*/
98+
public Map<ComparableQuantity<Length>, TemperatureValue> getGroundTemperatures() {
99+
return groundTemperatures;
100+
}
101+
84102
@Override
85103
public boolean equals(Object o) {
86104
if (this == o) return true;
@@ -89,12 +107,13 @@ public boolean equals(Object o) {
89107
return coordinate.equals(that.coordinate)
90108
&& solarIrradiance.equals(that.solarIrradiance)
91109
&& temperature.equals(that.temperature)
92-
&& wind.equals(that.wind);
110+
&& wind.equals(that.wind)
111+
&& groundTemperatures.equals(that.groundTemperatures);
93112
}
94113

95114
@Override
96115
public int hashCode() {
97-
return Objects.hash(coordinate, solarIrradiance, temperature, wind);
116+
return Objects.hash(coordinate, solarIrradiance, temperature, wind, groundTemperatures);
98117
}
99118

100119
@Override
@@ -108,6 +127,8 @@ public String toString() {
108127
+ temperature
109128
+ ", wind="
110129
+ wind
130+
+ groundTemperatures
131+
+ ", groundTemperatures="
111132
+ '}';
112133
}
113134
}

0 commit comments

Comments
 (0)