earthobservations / wetterdienst

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

Pulling data hourly does not work #206

Closed DaemonNet closed 3 years ago

DaemonNet commented 3 years ago

When executing this code:

request = DWDStationRequest(
                station_ids=[5335],
                parameter=[Parameter.CLIMATE_SUMMARY, Parameter.SOLAR],
                time_resolution=TimeResolution.MINUTES_10,
                start_date=str(startBA),
                end_date=str(endBA),
                tidy_data=True,
                humanize_column_names=True,
                write_file=True,
                prefer_local=True
            )
            weather_df = pd.DataFrame()
            listOfElements = []
            for df in request.collect_data():
                 print(df)

I get the error:

    for df in request.collect_data():
  File "C:\Program Files\Python37\lib\site-packages\wetterdienst\api.py", line 223, in collect_data
    (df_station[DWDMetaColumns.DATE.value] >= self.start_date)
  File "C:\Program Files\Python37\lib\site-packages\pandas\core\frame.py", line 2902, in __getitem__
    indexer = self.columns.get_loc(key)
  File "C:\Program Files\Python37\lib\site-packages\pandas\core\indexes\base.py", line 2893, in get_loc
    raise KeyError(key) from err
KeyError: 'DATE'

It seems to me that getting data in any resolution smaller than DAILY is not supported. On the older package dwdweather2 this worked.

gutzbenj commented 3 years ago

Dear @DaemonNet , thanks for coming back to us! First of all please include all necessary information in your issue so that we can fully understand what might have caused the problem (in this case also start_date and end_date would be nice to have).

I had a look into the parameters and encountered several problems:

Thanks again for the issue and we'll pick this up as soon as possible!

DaemonNet commented 3 years ago

Thank you so much for your fast answer. The issue with the parameter solved it! Maybe you can add a hint to the documentation (at least I didn't find it).

gutzbenj commented 3 years ago

Dear @DaemonNet , we have recently added a "discover_parameter" function to the newly created class DWDObservationMetadata (https://github.com/earthobservations/wetterdienst/blob/342e0f2eb68b928706fe6593ab53622d53b63c7d/wetterdienst/dwd/observations/api.py#L423), which returns a json with all available combinations. You can freely define parameter, time_resolution and period_type there to filter it.

This is not yet available via PyPi though as we are still waiting to release the next version.