Package edu.ie3.datamodel.io.source.csv
Class CsvWeatherSource
java.lang.Object
edu.ie3.datamodel.io.source.csv.CsvDataSource
edu.ie3.datamodel.io.source.csv.CsvWeatherSource
- All Implemented Interfaces:
DataSource
,WeatherSource
Implements a WeatherSource for CSV files by using the CsvTimeSeriesSource as a base
-
Field Summary
Fields inherited from class edu.ie3.datamodel.io.source.csv.CsvDataSource
connector, csvSep, FIELDS_TO_VALUES_MAP, log, NODE, NODE_A, NODE_B, OPERATOR, TYPE
-
Constructor Summary
ConstructorDescriptionCsvWeatherSource
(String csvSep, String folderPath, FileNamingStrategy fileNamingStrategy, TimeBasedWeatherValueFactory weatherFactory, IdCoordinateFactory coordinateFactory) Initializes a CsvWeatherSource with aCsvIdCoordinateSource
instance and immediately imports weather data, which will be kept for the lifetime of this sourceCsvWeatherSource
(String csvSep, String folderPath, FileNamingStrategy fileNamingStrategy, IdCoordinateSource coordinateSource, TimeBasedWeatherValueFactory weatherFactory) Initializes a CsvWeatherSource and immediately imports weather data, which will be kept for the lifetime of this source -
Method Summary
Modifier and TypeMethodDescriptionbuildStreamWithFieldsToAttributesMap
(Class<? extends UniqueEntity> entityClass, BufferedReader bufferedReader) Reads the first line (considered to be the headline with headline fields) and returns a stream of (fieldName to fieldValue) mapping where each map represents one row of the .csv file.Map<org.locationtech.jts.geom.Point,
IndividualTimeSeries<WeatherValue>> getWeather
(edu.ie3.util.interval.ClosedInterval<ZonedDateTime> timeInterval) Return the weather for the given time intervalMap<org.locationtech.jts.geom.Point,
IndividualTimeSeries<WeatherValue>> getWeather
(edu.ie3.util.interval.ClosedInterval<ZonedDateTime> timeInterval, Collection<org.locationtech.jts.geom.Point> coordinates) Return the weather for the given time interval AND coordinatesgetWeather
(ZonedDateTime date, org.locationtech.jts.geom.Point coordinate) Return the weather for the given time date AND coordinateMethods inherited from class edu.ie3.datamodel.io.source.csv.CsvDataSource
assetInputEntityDataStream, assetInputEntityDataStream, buildStreamWithFieldsToAttributesMap, csvRowFieldValueMapping, distinctRowsWithLog, findFirstEntityByUuid, getAssetType, isPresentCollectIfNot, logSkippingWarning, nodeAssetEntityStream, nodeAssetInputEntityDataStream, parseCsvRow, printInvalidElementInformation, saveMapGet, simpleEntityDataStream
-
Constructor Details
-
CsvWeatherSource
public CsvWeatherSource(String csvSep, String folderPath, FileNamingStrategy fileNamingStrategy, TimeBasedWeatherValueFactory weatherFactory, IdCoordinateFactory coordinateFactory) Initializes a CsvWeatherSource with aCsvIdCoordinateSource
instance and immediately imports weather data, which will be kept for the lifetime of this source- Parameters:
csvSep
- the separator string for csv columnsfolderPath
- path to the folder holding the time series filesfileNamingStrategy
- strategy for the file naming of time series files / data sinksweatherFactory
- factory to transfer field to value mapping into actual java object instancescoordinateFactory
- factory to build coordinate id to coordinate mapping
-
CsvWeatherSource
public CsvWeatherSource(String csvSep, String folderPath, FileNamingStrategy fileNamingStrategy, IdCoordinateSource coordinateSource, TimeBasedWeatherValueFactory weatherFactory) Initializes a CsvWeatherSource and immediately imports weather data, which will be kept for the lifetime of this source- Parameters:
csvSep
- the separator string for csv columnsfolderPath
- path to the folder holding the time series filesfileNamingStrategy
- strategy for the file naming of time series files / data sinkscoordinateSource
- a coordinate source to map ids to pointsweatherFactory
- factory to transfer field to value mapping into actual java object instances
-
-
Method Details
-
getWeather
public Map<org.locationtech.jts.geom.Point,IndividualTimeSeries<WeatherValue>> getWeather(edu.ie3.util.interval.ClosedInterval<ZonedDateTime> timeInterval) Description copied from interface:WeatherSource
Return the weather for the given time interval- Specified by:
getWeather
in interfaceWeatherSource
- Parameters:
timeInterval
- Queried time interval- Returns:
- weather data for the specified time range, sorted by coordinate
-
getWeather
public Map<org.locationtech.jts.geom.Point,IndividualTimeSeries<WeatherValue>> getWeather(edu.ie3.util.interval.ClosedInterval<ZonedDateTime> timeInterval, Collection<org.locationtech.jts.geom.Point> coordinates) Description copied from interface:WeatherSource
Return the weather for the given time interval AND coordinates- Specified by:
getWeather
in interfaceWeatherSource
- Parameters:
timeInterval
- Queried time intervalcoordinates
- Queried coordinates- Returns:
- weather data for the specified time range and coordinates, sorted by coordinate
-
getWeather
public Optional<TimeBasedValue<WeatherValue>> getWeather(ZonedDateTime date, org.locationtech.jts.geom.Point coordinate) Description copied from interface:WeatherSource
Return the weather for the given time date AND coordinate- Specified by:
getWeather
in interfaceWeatherSource
- Parameters:
date
- Queried date timecoordinate
- Queried coordinate- Returns:
- weather data for the specified time and coordinate
-
buildStreamWithFieldsToAttributesMap
protected Stream<Map<String,String>> buildStreamWithFieldsToAttributesMap(Class<? extends UniqueEntity> entityClass, BufferedReader bufferedReader) Reads the first line (considered to be the headline with headline fields) and returns a stream of (fieldName to fieldValue) mapping where each map represents one row of the .csv file. Since the returning stream is a parallel stream, the order of the elements cannot be guaranteed.This method overrides
CsvDataSource.buildStreamWithFieldsToAttributesMap(Class, BufferedReader)
to not do sanity check for available UUID. This is because the weather source might make use of ICON weather data, which don't have a UUID. For weather it is indeed not necessary, to have one unique UUID.- Overrides:
buildStreamWithFieldsToAttributesMap
in classCsvDataSource
- Parameters:
entityClass
- the entity class that should be buildbufferedReader
- the reader to use- Returns:
- a parallel stream of maps, where each map represents one row of the csv file with the mapping (fieldName to fieldValue)
-