Class CsvWeatherSource

java.lang.Object
edu.ie3.datamodel.io.source.csv.CsvDataSource
edu.ie3.datamodel.io.source.csv.CsvWeatherSource
All Implemented Interfaces:
DataSource, WeatherSource

public class CsvWeatherSource extends CsvDataSource implements WeatherSource
Implements a WeatherSource for CSV files by using the CsvTimeSeriesSource as a base
  • Constructor Details

    • CsvWeatherSource

      public CsvWeatherSource(String csvSep, String folderPath, FileNamingStrategy fileNamingStrategy, TimeBasedWeatherValueFactory weatherFactory, IdCoordinateFactory coordinateFactory)
      Initializes a CsvWeatherSource with a CsvIdCoordinateSource instance and immediately imports weather data, which will be kept for the lifetime of this source
      Parameters:
      csvSep - the separator string for csv columns
      folderPath - path to the folder holding the time series files
      fileNamingStrategy - strategy for the file naming of time series files / data sinks
      weatherFactory - factory to transfer field to value mapping into actual java object instances
      coordinateFactory - 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 columns
      folderPath - path to the folder holding the time series files
      fileNamingStrategy - strategy for the file naming of time series files / data sinks
      coordinateSource - a coordinate source to map ids to points
      weatherFactory - 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 interface WeatherSource
      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 interface WeatherSource
      Parameters:
      timeInterval - Queried time interval
      coordinates - 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 interface WeatherSource
      Parameters:
      date - Queried date time
      coordinate - 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 class CsvDataSource
      Parameters:
      entityClass - the entity class that should be build
      bufferedReader - 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)