-
Notifications
You must be signed in to change notification settings - Fork 5
add ground temperature 1m as option to weather data #1351
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
base: dev
Are you sure you want to change the base?
Changes from 14 commits
6bb6984
0342ae2
920be80
e259bee
1b8dd09
6a77ffc
d46b0d1
9f767ed
b015b66
8e33409
b0d87d9
0399aa3
813cdbe
88191d1
47ac942
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 |
---|---|---|
|
@@ -13,23 +13,29 @@ | |
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 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; | ||
|
||
/** | ||
* 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"; | ||
|
||
|
@@ -55,7 +61,10 @@ protected List<Set<String>> getFields(Class<?> entityClass) { | |
TEMPERATURE, | ||
WIND_DIRECTION, | ||
WIND_VELOCITY); | ||
return Collections.singletonList(minConstructorParams); | ||
|
||
Set<String> withGroundTemp = expandSet(minConstructorParams, GROUND_TEMPERATURE); | ||
|
||
return List.of(minConstructorParams, withGroundTemp); | ||
Comment on lines
+65
to
+67
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 will happen if there are no ground temperatures and one calls this method? |
||
} | ||
|
||
@Override | ||
|
@@ -72,14 +81,24 @@ protected TimeBasedValue<WeatherValue> buildModel(TimeBasedWeatherValueData data | |
data.getQuantity(WIND_DIRECTION, StandardUnits.WIND_DIRECTION); | ||
ComparableQuantity<Speed> windVelocity = | ||
data.getQuantity(WIND_VELOCITY, StandardUnits.WIND_VELOCITY); | ||
|
||
ComparableQuantity<Temperature> groundTemperature = null; | ||
try { | ||
groundTemperature = data.getQuantity(GROUND_TEMPERATURE, StandardUnits.TEMPERATURE); | ||
} catch (IllegalArgumentException ignored) { | ||
|
||
} | ||
Comment on lines
+85
to
+90
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. In my opinion this is a bit counterintuitive. The advantage of try is that one get's a result of the try. But we ignore this. But first, please change to |
||
|
||
WeatherValue weatherValue = | ||
new WeatherValue( | ||
coordinate, | ||
directIrradiance, | ||
diffuseIrradiance, | ||
temperature, | ||
windDirection, | ||
windVelocity); | ||
windVelocity, | ||
groundTemperature); | ||
|
||
return new TimeBasedValue<>(time, weatherValue); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,8 @@ | |
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; | ||
|
@@ -27,10 +29,15 @@ | |
* Weather Service's ICON-EU model | ||
*/ | ||
public class IconTimeBasedWeatherValueFactory extends TimeBasedWeatherValueFactory { | ||
|
||
private static final Logger logger = | ||
LoggerFactory.getLogger(IconTimeBasedWeatherValueFactory.class); | ||
Comment on lines
+33
to
+34
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. Same for logger here |
||
|
||
/* 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"; | ||
|
||
|
@@ -47,6 +54,7 @@ protected List<Set<String>> getFields(Class<?> entityClass) { | |
Set<String> minParameters = | ||
newSet( | ||
DIFFUSE_IRRADIANCE, DIRECT_IRRADIANCE, TEMPERATURE, WIND_VELOCITY_U, WIND_VELOCITY_V); | ||
|
||
Set<String> allParameters = | ||
expandSet( | ||
minParameters, | ||
|
@@ -88,30 +96,26 @@ protected TimeBasedValue<WeatherValue> buildModel(TimeBasedWeatherValueData data | |
data.getQuantity(TEMPERATURE, Units.KELVIN).to(StandardUnits.TEMPERATURE); | ||
ComparableQuantity<Angle> windDirection = getWindDirection(data); | ||
ComparableQuantity<Speed> windVelocity = getWindVelocity(data); | ||
|
||
ComparableQuantity<Temperature> groundTemperature = null; | ||
try { | ||
groundTemperature = | ||
data.getQuantity(GROUND_TEMPERATURE, Units.KELVIN).to(StandardUnits.TEMPERATURE); | ||
} catch (IllegalArgumentException ignored) { | ||
} | ||
|
||
Comment on lines
+100
to
+106
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. same as for cosmo |
||
WeatherValue weatherValue = | ||
new WeatherValue( | ||
coordinate, | ||
directIrradiance, | ||
diffuseIrradiance, | ||
temperature, | ||
windDirection, | ||
windVelocity); | ||
windVelocity, | ||
groundTemperature); | ||
return new TimeBasedValue<>(time, weatherValue); | ||
} | ||
|
||
/** | ||
pierrepetersmeier marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* 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 <b>comes</b> 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<Angle> getWindDirection(TimeBasedWeatherValueData data) { | ||
/* Get the three dimensional parts of the wind velocity vector in cartesian coordinates */ | ||
double u = | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* © 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 { | ||
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. I think you can reuse many parts from |
||
|
||
/** Ground temperature (typically in K) */ | ||
private final ComparableQuantity<Temperature> temperature; | ||
|
||
/** | ||
* @param temperature Ground temperature (typically in K) | ||
*/ | ||
public GroundTemperatureValue(ComparableQuantity<Temperature> temperature) { | ||
this.temperature = temperature == null ? null : temperature.to(StandardUnits.TEMPERATURE); | ||
} | ||
|
||
public Optional<ComparableQuantity<Temperature>> 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 + '}'; | ||
} | ||
} |
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.
What does logger log in this class?