import_DWD

A collection of functions to import data from the DWD-CDC Server.

weatherDB.lib.max_fun.import_DWD.dwd_id_to_str(id)[source]

Convert a station id to normal DWD format as str.

Parameters:

id (int or str) – The id of the station.

Returns:

string of normal DWD Station id.

Return type:

str

weatherDB.lib.max_fun.import_DWD.get_dwd_data(station_id, ftp_folder)[source]

Get the weather data for one station from the DWD server.

Parameters:
  • station_id (str or int) – Number of the station to get the weather data from.

  • ftp_folder (str) – the base folder where to look for the stations_id file. e.g. ftp_folder = “climate_environment/CDC/observations_germany/climate/hourly/precipitation/historical/”. If the parent folder, where “recent”/”historical” folder is inside, both the historical and recent data gets merged.

Returns:

The DataFrame of the selected file in the zip folder.

Return type:

pandas.DataFrame

weatherDB.lib.max_fun.import_DWD.get_dwd_file(zip_filepath)[source]

Get a DataFrame from one single (zip-)file from the DWD FTP server.

Parameters:

zip_filepath (str) –

Path to the file on the server. e.g.

  • ”/climate_environment/CDC/observations_germany/climate/10_minutes/air_temperature/recent/10minutenwerte_TU_00044_akt.zip”

  • ”/climate_environment/CDC/derived_germany/soil/daily/historical/derived_germany_soil_daily_historical_73.txt.gz”

Returns:

The DataFrame of the selected file in the zip folder.

Return type:

pandas.DataFrame

weatherDB.lib.max_fun.import_DWD.get_dwd_meta(ftp_folder, min_years=0, max_hole_d=9999)[source]

Get the meta file from the ftp_folder on the DWD server.

Downloads the meta file of a given folder. Corrects the meta file of missing files. So if no file for the station is in the folder the meta entry gets deleted. Reset “von_datum” in meta file if there is a biger gap than max_hole_d. Delets entries with less years than min_years.

Parameters:
  • ftp_folder (str) – The path to the directory where to search for the meta file. e.g. “climate_environment/CDC/observations_germany/climate/hourly/precipitation/recent/”.

  • min_years (int, optional) – filter the list of stations by a minimum amount of years, that they have data for. 0 if the data should not get filtered. Only works if the meta file has a timerange defined, e.g. in “observations”. The default is 0.

  • max_hole_d (int) – The maximum amount of days missing in the data allowed. If there are several files for one station and the time hole is bigger than this value, the older “von_datum” is overwritten in the meta GeoDataFrame. The default is 2.

Returns:

a GeoDataFrame of the meta file

Return type:

geopandas.GeoDataFrame