7
7
8
8
import edu .ie3 .datamodel .models .StandardUnits ;
9
9
import edu .ie3 .datamodel .models .timeseries .individual .TimeBasedValue ;
10
+ import edu .ie3 .datamodel .models .value .SolarIrradianceValue ;
11
+ import edu .ie3 .datamodel .models .value .TemperatureValue ;
10
12
import edu .ie3 .datamodel .models .value .WeatherValue ;
13
+ import edu .ie3 .datamodel .models .value .WindValue ;
11
14
import edu .ie3 .util .TimeUtil ;
12
15
import edu .ie3 .util .quantities .PowerSystemUnits ;
13
16
import edu .ie3 .util .quantities .interfaces .Irradiance ;
14
17
import java .time .ZonedDateTime ;
15
18
import java .time .format .DateTimeFormatter ;
16
- import java .util .Collections ;
17
- import java .util .List ;
18
- import java .util .Set ;
19
+ import java .util .*;
19
20
import javax .measure .quantity .Angle ;
21
+ import javax .measure .quantity .Length ;
20
22
import javax .measure .quantity .Speed ;
21
23
import javax .measure .quantity .Temperature ;
22
24
import org .locationtech .jts .geom .Point ;
23
25
import tech .units .indriya .ComparableQuantity ;
26
+ import tech .units .indriya .quantity .Quantities ;
24
27
25
28
/**
26
29
* Factory implementation of {@link TimeBasedWeatherValueFactory}, that is able to handle field to
@@ -33,6 +36,9 @@ public class CosmoTimeBasedWeatherValueFactory extends TimeBasedWeatherValueFact
33
36
private static final String WIND_DIRECTION = "windDirection" ;
34
37
private static final String WIND_VELOCITY = "windVelocity" ;
35
38
39
+ private static final String GROUND_TEMPERATURE_SURFACE = "groundTemperatureSurface" ;
40
+ private static final String GROUND_TEMPERATURE_1M = "groundTemperature1m" ;
41
+
36
42
public CosmoTimeBasedWeatherValueFactory (TimeUtil timeUtil ) {
37
43
super (timeUtil );
38
44
}
@@ -55,31 +61,58 @@ protected List<Set<String>> getFields(Class<?> entityClass) {
55
61
TEMPERATURE ,
56
62
WIND_DIRECTION ,
57
63
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 );
58
69
return Collections .singletonList (minConstructorParams );
59
70
}
60
71
61
72
@ Override
62
73
protected TimeBasedValue <WeatherValue > buildModel (TimeBasedWeatherValueData data ) {
63
74
Point coordinate = data .getCoordinate ();
64
75
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
+
75
107
WeatherValue weatherValue =
76
108
new WeatherValue (
77
109
coordinate ,
78
110
directIrradiance ,
79
111
diffuseIrradiance ,
80
112
temperature ,
81
113
windDirection ,
82
- windVelocity );
114
+ windVelocity ,
115
+ groundTemperatures );
83
116
return new TimeBasedValue <>(time , weatherValue );
84
117
}
85
118
}
0 commit comments