earthobservations / wetterdienst

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

MetaFileNotFoundError at /get-temperature-data/ No meta file was found amongst the files at https://opendata.dwd.de/climate_environment/CDC/observations_germany/climate//10_minutes/air_temperature/recent/. #1272

Closed dpakprajul closed 3 months ago

dpakprajul commented 5 months ago

Describe the Bug I wanted to get the data from wetterdienst Germany, but couldn't get the data. I need to send the temperature data, and the weather condition (rain, no rain, sunny) etc. to the client side from the backend. I am using django for this. I tried to get the data directly from https://opendata.dwd.de/climate_environment/CDC/observations_germany/climate//10_minutes/air_temperature/recent/, but extracting zip, calculating the data and sending again to client takes longer than 5 seconds. Hence I wanted to implement this as a alternative.

To Reproduce

from django.http import JsonResponse
from wetterdienst import Wetterdienst
from wetterdienst.provider.dwd.observation import DwdObservationRequest, DwdObservationDataset, DwdObservationPeriod, DwdObservationResolution

def get_temperature_data(request):
    API = Wetterdienst(provider="dwd", network="observation")
    try:
        request = DwdObservationRequest(
            parameter=DwdObservationDataset.TEMPERATURE_AIR,
            resolution=DwdObservationResolution.MINUTE_10,
            period=DwdObservationPeriod.RECENT,
        )
        print("Requesting data from DWD...", request)
        stations = request.filter_by_station_id(station_id=("03404"))

        df = stations.df

        # Convert DataFrame to dictionary and return as JSON
        return JsonResponse(df.to_dict(), safe=False)
    except Exception as e:
        return JsonResponse({"error": str(e)}, status=500)

It gives the error: MetaFileNotFoundError at /get-temperature-data/ No meta file was found amongst the files at https://opendata.dwd.de/climate_environment/CDC/observations_germany/climate//10_minutes/air_temperature/recent/.

print(request) gives DwdObservationRequest(parameter=[(air_temperature/air_temperature)], resolution=10_minutes, period=[recent], start_date=None, end_date=None, humanize=True, format=long, si_units=True)

The error in the terminal, Internal Server Error: /get-temperature-data/ Traceback (most recent call last): File "/data/projects/weather_try/myenv/lib/python3.9/site-packages/django/core/handlers/exception.py", line 55, in inner response = get_response(request) File "/data/projects/weather_try/myenv/lib/python3.9/site-packages/django/core/handlers/base.py", line 197, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/data/projects/weather_try/my_weather/weather_app/views.py", line 14, in get_temperature_data stations = request.filter_by_station_id(station_id=("03404")) File "/data/projects/weather_try/myenv/lib/python3.9/site-packages/wetterdienst/provider/dwd/observation/api.py", line 501, in filter_by_station_id return super().filter_by_station_id( File "/data/projects/weather_try/myenv/lib/python3.9/site-packages/wetterdienst/core/timeseries/request.py", line 656, in filter_by_station_id df = self.all().df File "/data/projects/weather_try/myenv/lib/python3.9/site-packages/wetterdienst/core/timeseries/request.py", line 634, in all df = self._all() File "/data/projects/weather_try/myenv/lib/python3.9/site-packages/wetterdienst/provider/dwd/observation/api.py", line 564, in _all df = create_meta_index_for_climate_observations(dataset, self.resolution, period, self.settings) File "/data/projects/weather_try/myenv/lib/python3.9/site-packages/wetterdienst/provider/dwd/observation/metaindex.py", line 92, in create_meta_index_for_climate_observations meta_index = _create_meta_index_for_climate_observations(dataset, resolution, period, settings) File "/data/projects/weather_try/myenv/lib/python3.9/site-packages/wetterdienst/provider/dwd/observation/metaindex.py", line 148, in _create_meta_index_for_climate_observations meta_file = _find_meta_file(remote_files, url, ["beschreibung", "txt"]) File "/data/projects/weather_try/myenv/lib/python3.9/site-packages/wetterdienst/provider/dwd/observation/metaindex.py", line 172, in _find_meta_file raise MetaFileNotFoundError(f"No meta file was found amongst the files at {url}.") wetterdienst.exceptions.MetaFileNotFoundError: No meta file was found amongst the files at https://opendata.dwd.de/climate_environment/CDC/observations_germany/climate//10_minutes/air_temperature/recent/. [10/Apr/2024 08:59:18] "GET /get-temperature-data/ HTTP/1.1" 500 102963 Not Found: /favicon.ico [10/Apr/2024 08:59:19] "GET /favicon.ico HTTP/1.1" 404 2264 Requesting data from DWD... DwdObservationRequest(parameter=[(air_temperature/air_temperature)], resolution=10_minutes, period=[recent], start_date=None, end_date=None, humanize=True, format=long, si_units=True) Internal Server Error: /get-temperature-data/ Traceback (most recent call last): File "/data/projects/weather_try/myenv/lib/python3.9/site-packages/django/core/handlers/exception.py", line 55, in inner response = get_response(request) File "/data/projects/weather_try/myenv/lib/python3.9/site-packages/django/core/handlers/base.py", line 197, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/data/projects/weather_try/my_weather/weather_app/views.py", line 14, in get_temperature_data stations = request.filter_by_station_id(station_id=("03404")) File "/data/projects/weather_try/myenv/lib/python3.9/site-packages/wetterdienst/provider/dwd/observation/api.py", line 501, in filter_by_station_id return super().filter_by_station_id( File "/data/projects/weather_try/myenv/lib/python3.9/site-packages/wetterdienst/core/timeseries/request.py", line 656, in filter_by_station_id df = self.all().df File "/data/projects/weather_try/myenv/lib/python3.9/site-packages/wetterdienst/core/timeseries/request.py", line 634, in all df = self._all() File "/data/projects/weather_try/myenv/lib/python3.9/site-packages/wetterdienst/provider/dwd/observation/api.py", line 564, in _all df = create_meta_index_for_climate_observations(dataset, self.resolution, period, self.settings) File "/data/projects/weather_try/myenv/lib/python3.9/site-packages/wetterdienst/provider/dwd/observation/metaindex.py", line 92, in create_meta_index_for_climate_observations meta_index = _create_meta_index_for_climate_observations(dataset, resolution, period, settings) File "/data/projects/weather_try/myenv/lib/python3.9/site-packages/wetterdienst/provider/dwd/observation/metaindex.py", line 148, in _create_meta_index_for_climate_observations meta_file = _find_meta_file(remote_files, url, ["beschreibung", "txt"]) File "/data/projects/weather_try/myenv/lib/python3.9/site-packages/wetterdienst/provider/dwd/observation/metaindex.py", line 172, in _find_meta_file raise MetaFileNotFoundError(f"No meta file was found amongst the files at {url}.") wetterdienst.exceptions.MetaFileNotFoundError: No meta file was found amongst the files at https://opendata.dwd.de/climate_environment/CDC/observations_germany/climate//10_minutes/air_temperature/recent/. [10/Apr/2024 08:59:29] "GET /get-temperature-data/ HTTP/1.1" 500 102573

Expected behavior I wanted some data in stations = request.filter_by_station_id(station_id=("03404"))

Screenshots I wanted to make the output like this, where I got the data from dwd, unzipped the folder and get the data. It is laggy, hence I wanted a faster solution

image

Desktop (please complete the following information):

gutzbenj commented 5 months ago

Dear @dpakprajul ,

does the issue still exist? I can't reproduce it.

dpakprajul commented 5 months ago

Hi @gutzbenj I am still having the same problem in my Working machine stating no meta file was found amongst the files at Webaddress: . I thought there might be the issue of the server that is not letting the request to proceed (since I am Notebook and the internet connection from Work). Don't know what is happening exactly.

I couldn't reproduce this problem in my personal Notebook but got this problem instead:

error | "conversion from str to f64 failed in column 'height' for 519 out of 519 values: [\"30429 20110331\", \"70209 20240423\", … \"30401 20240424\"]"

Would you please give me a hint how to solve this problem?

gutzbenj commented 5 months ago

This new issue should be fixed now! The problem with your workstation could actually be the SSL certificate. Can you confirm that you are using a custom SSL certificate?

gutzbenj commented 3 months ago

Closing this for now.