-
Notifications
You must be signed in to change notification settings - Fork 5
pp/#1343 Add ground temperature (1m) as option to weather data. #1348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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,31 +61,58 @@ protected List<Set<String>> getFields(Class<?> entityClass) { | |
TEMPERATURE, | ||
WIND_DIRECTION, | ||
WIND_VELOCITY); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't it possible to simply add the additonal values here when creating the set? so the removal of the coordinate_id would be obsolete, right? |
||
Set<String> allParameters = | ||
expandSet(minConstructorParams, GROUND_TEMPERATURE_SURFACE, GROUND_TEMPERATURE_1M); | ||
minConstructorParams.remove(COORDINATE_ID); | ||
allParameters.remove(COORDINATE_ID); | ||
return Collections.singletonList(minConstructorParams); | ||
} | ||
|
||
@Override | ||
protected TimeBasedValue<WeatherValue> buildModel(TimeBasedWeatherValueData data) { | ||
Point coordinate = data.getCoordinate(); | ||
ZonedDateTime time = timeUtil.toZonedDateTime(data.getField(TIME)); | ||
ComparableQuantity<Irradiance> directIrradiance = | ||
data.getQuantity(DIRECT_IRRADIANCE, PowerSystemUnits.WATT_PER_SQUAREMETRE); | ||
ComparableQuantity<Irradiance> diffuseIrradiance = | ||
data.getQuantity(DIFFUSE_IRRADIANCE, PowerSystemUnits.WATT_PER_SQUAREMETRE); | ||
ComparableQuantity<Temperature> temperature = | ||
data.getQuantity(TEMPERATURE, StandardUnits.TEMPERATURE); | ||
ComparableQuantity<Angle> windDirection = | ||
data.getQuantity(WIND_DIRECTION, StandardUnits.WIND_DIRECTION); | ||
ComparableQuantity<Speed> windVelocity = | ||
data.getQuantity(WIND_VELOCITY, StandardUnits.WIND_VELOCITY); | ||
SolarIrradianceValue solarIrradiance = new SolarIrradianceValue( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please rollback this. Within Simona we expect these values to be ComparableQuantity and not SolarIrradianceValue (at least this is my understanding). Second, I would like to keep the changes in this PR limited to adding the new values and not refactoring existing code. |
||
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<ComparableQuantity<Length>, TemperatureValue> groundTemperatures = new HashMap<>(); | ||
|
||
|
||
data.getField(GROUND_TEMPERATURE_SURFACE).ifPresent(value -> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What happens in the case NotPresent? |
||
ComparableQuantity<Length> 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<Length> 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, | ||
directIrradiance, | ||
diffuseIrradiance, | ||
temperature, | ||
windDirection, | ||
windVelocity); | ||
windVelocity, | ||
groundTemperatures); | ||
return new TimeBasedValue<>(time, weatherValue); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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"; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please also remove the line here. Please add also a getter for the new data and add them to the existing ones (where it is expected to apply). Also the buildModel seem to have it, right? |
||
/** 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(); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this empty line