OpenSTEF / openstef-dbc

Provides (company specific) database connector for the OpenSTEF package
Mozilla Public License 2.0
1 stars 7 forks source link

Extract multiple nearest weather locationS instead of only 1 #145

Open maxi-fort opened 2 months ago

maxi-fort commented 2 months ago

One user could be interested in using multiple nearest weather forecasts (e.g 4 surrounding input_city weather forecast) for prediction.

  1. Adding a new argument k representing the number of weather locations desired (default = 1) FROM : https://github.com/OpenSTEF/openstef-dbc/blob/2fb4fb58414cbe3f6d13e430ecdb6f946c19ba53/openstef_dbc/services/weather.py#L53-L58 TO :

    def _get_nearest_weather_location(
        self,
        location: Union[Tuple[float, float], str],
        country: str = "NL",
        threshold: float = 150.0,
        k: int = 1,
    
    ) -> str:
  2. Sorting distances instead of taking the min FROM : https://github.com/OpenSTEF/openstef-dbc/blob/2fb4fb58414cbe3f6d13e430ecdb6f946c19ba53/openstef_dbc/services/weather.py#L106 TO : nearest_location = distances["input_city"].sort_index()[0:k]

  3. Allowing multiple locations return by removing [0] FROM : https://github.com/OpenSTEF/openstef-dbc/blob/2fb4fb58414cbe3f6d13e430ecdb6f946c19ba53/openstef_dbc/services/weather.py#L111 TO : return nearest_location.reset_index(drop=True)