earthobservations / wetterdienst

Open weather data for humans.
https://wetterdienst.readthedocs.io/
MIT License
342 stars 52 forks source link

Error fetching nearest stations data: could not convert string to float: '42 54' #1287

Closed Abdi-Arslene closed 2 months ago

Abdi-Arslene commented 2 months ago

Describe the bug I was trying to get the nearest stations that provides "SOLAR" parameter in hour resolution with recent period based on coordinates and a given rank. When i run that it generates an error saying: could not convert string to float: '42 54'

To Reproduce In order to reproduce that error i ran this code:

def get_nearest_stations(lat=49.59, lon=8.16, rank=5):
    logger.info(
        f"getting nearest stations from latitude:{lat} and longitude: {lon}"
    )
    try:
        stations = (
            wetterdienst.provider.dwd.observation.DwdObservationRequest(
                parameter=["SOLAR"],
                resolution="hourly",
                period="recent",
                start_date="2017-01-01",  # if not given timezone defaulted to UTC
            )
            .filter_by_rank(latlon=(lat, lon), rank=rank)
            .df
        )[["station_id", "distance"]]
    except Exception as e:
        raise ValueError(f"Error fetching nearest stations data: {e}")
    logger.info(f"Nearest stations are: {stations.to_dict(orient='records')}")
    return stations

get_nearest_stations(lat=49.96, lon=8.25, rank=10)

Expected behavior It should return a DataFrame containing the 10 nearest stationIds and their distance from the given coordinates.

Screenshots image

Desktop (please complete the following information):

gutzbenj commented 2 months ago

Dear @Abdi-Arslene ,

could you please install the latest version of wetterdienst (v0.83.0)? It requires Python 3.9.

Abdi-Arslene commented 2 months ago

Yes i works thanks !