diff --git a/docs/pages/api.rst b/docs/pages/api.rst index 85f8f1880..5cc14f693 100644 --- a/docs/pages/api.rst +++ b/docs/pages/api.rst @@ -245,31 +245,40 @@ Other variants:: response = mosmix.read_mosmix_s_latest() -******* -RADOLAN -******* +***** +RADAR +***** -To use ``DWDRadolanRequest``, you have to provide a time resolution (either hourly or daily) +To use ``DWDRadarRequest``, you have to provide a time resolution (either hourly or daily) and ``date_times`` (list of datetimes or strings) or a start date and end date. Datetimes are rounded to HH:50min as the data is packaged for this minute step. Additionally, you can provide a folder to store/restore RADOLAN data to/from the local filesystem. This is a short snippet which should give you an idea -how to use ``DWDRadolanRequest`` together with ``wradlib``. +how to use ``DWDRadarRequest`` together with ``wradlib``. For a more thorough example, please have a look at `example/radolan.py`_. +The subsystem implements access to various radar data like: + +- https://opendata.dwd.de/climate_environment/CDC/grids_germany/5_minutes/radolan/ +- https://opendata.dwd.de/climate_environment/CDC/grids_germany/daily/radolan/ +- https://opendata.dwd.de/climate_environment/CDC/grids_germany/hourly/radolan/ +- https://opendata.dwd.de/weather/radar/radolan/ +- https://opendata.dwd.de/weather/radar/composit/ +- https://opendata.dwd.de/weather/radar/sites/ + .. code-block:: python - from wetterdienst import DWDRadolanRequest, TimeResolution + from wetterdienst import DWDRadarRequest, TimeResolution import wradlib as wrl - radolan = DWDRadolanRequest( + radar = DWDRadarRequest( TimeResolution.DAILY, start_date="2020-09-04T12:00:00", end_date="2020-09-04T12:00:00" ) - for item in radolan.collect_data(): + for item in radar.collect_data(): # Decode item. timestamp, buffer = item diff --git a/example/radolan.py b/example/radolan.py index f659fcd43..aef948623 100644 --- a/example/radolan.py +++ b/example/radolan.py @@ -29,7 +29,7 @@ logging.basicConfig(level=logging.INFO) log = logging.getLogger() -from wetterdienst import DWDRadolanRequest, TimeResolution +from wetterdienst import DWDRadarRequest, TimeResolution def plot(data: np.ndarray, attributes: dict, label: str): @@ -122,7 +122,7 @@ def radolan_example(): """ log.info("Acquiring RADOLAN data") - radolan = DWDRadolanRequest( + radolan = DWDRadarRequest( TimeResolution.DAILY, start_date="2020-09-04T12:00:00", end_date="2020-09-04T12:00:00", diff --git a/tests/dwd/radolan/__init__.py b/tests/dwd/radar/__init__.py similarity index 100% rename from tests/dwd/radolan/__init__.py rename to tests/dwd/radar/__init__.py diff --git a/tests/dwd/radolan/radolan_daily_201908080050 b/tests/dwd/radar/radolan_daily_201908080050 similarity index 100% rename from tests/dwd/radolan/radolan_daily_201908080050 rename to tests/dwd/radar/radolan_daily_201908080050 diff --git a/tests/dwd/radolan/radolan_hourly_201908080050 b/tests/dwd/radar/radolan_hourly_201908080050 similarity index 100% rename from tests/dwd/radolan/radolan_hourly_201908080050 rename to tests/dwd/radar/radolan_hourly_201908080050 diff --git a/tests/dwd/radolan/test_access.py b/tests/dwd/radar/test_access.py similarity index 93% rename from tests/dwd/radolan/test_access.py rename to tests/dwd/radar/test_access.py index f68d7da90..024a68a29 100644 --- a/tests/dwd/radolan/test_access.py +++ b/tests/dwd/radar/test_access.py @@ -4,7 +4,7 @@ from pathlib import Path from wetterdienst.dwd.metadata.time_resolution import TimeResolution -from wetterdienst.dwd.radolan.access import _collect_radolan_data +from wetterdienst.dwd.radar.access import _collect_radolan_data HERE = Path(__file__).parent diff --git a/tests/dwd/radolan/test_api.py b/tests/dwd/radar/test_api.py similarity index 82% rename from tests/dwd/radolan/test_api.py rename to tests/dwd/radar/test_api.py index 3c8c04921..7958c8b5c 100644 --- a/tests/dwd/radolan/test_api.py +++ b/tests/dwd/radar/test_api.py @@ -3,23 +3,24 @@ from io import BytesIO from pathlib import Path -from wetterdienst import DWDRadolanRequest, TimeResolution +from wetterdienst import DWDRadarRequest, TimeResolution HERE = Path(__file__).parent @pytest.mark.remote def test_dwd_radolan_request(): + with pytest.raises(ValueError): - DWDRadolanRequest( + DWDRadarRequest( time_resolution=TimeResolution.MINUTE_1, date_times=["2019-08-08 00:50:00"] ) - request = DWDRadolanRequest( + request = DWDRadarRequest( time_resolution=TimeResolution.HOURLY, date_times=["2019-08-08 00:50:00"] ) - assert request == DWDRadolanRequest( + assert request == DWDRadarRequest( TimeResolution.HOURLY, [datetime(year=2019, month=8, day=8, hour=0, minute=50, second=0)], ) diff --git a/tests/dwd/radar/test_index.py b/tests/dwd/radar/test_index.py new file mode 100644 index 000000000..4e7ed2729 --- /dev/null +++ b/tests/dwd/radar/test_index.py @@ -0,0 +1,26 @@ +from wetterdienst import Parameter, TimeResolution +from wetterdienst.dwd.radar.metadata import RadarDataTypes +from wetterdienst.dwd.radar.sites import RadarSites +from wetterdienst.dwd.radar.index import _create_fileindex_radar + + +def test_radar_fileindex_sweep(): + + file_index = _create_fileindex_radar( + parameter=Parameter.SWEEP_VOL_VELOCITY_V, + time_resolution=TimeResolution.MINUTE_5, + radar_site=RadarSites.BOO, + radar_data_type=RadarDataTypes.HDF5 + ) + + assert "sweep_vol_v/boo/hdf5" in file_index.iloc[0]["FILENAME"] + + +def test_radar_fileindex_reflectivity(): + + file_index = _create_fileindex_radar( + parameter=Parameter.PX250_REFLECTIVITY, + time_resolution=TimeResolution.MINUTE_5, + radar_site=RadarSites.BOO) + + assert "px250/boo" in file_index.iloc[0]["FILENAME"] diff --git a/tests/dwd/radar/test_store.py b/tests/dwd/radar/test_store.py new file mode 100644 index 000000000..b8595c599 --- /dev/null +++ b/tests/dwd/radar/test_store.py @@ -0,0 +1,15 @@ +from datetime import datetime +from wetterdienst import Parameter, TimeResolution +from wetterdienst.dwd.metadata.constants import DWD_FOLDER_MAIN +from wetterdienst.dwd.radar.store import _build_local_filepath + + +def test_build_local_filepath_for_radar(): + + radar_filepath = _build_local_filepath( + Parameter.DX_REFLECTIVITY, + datetime(2020, 1, 1, 12, 15), + DWD_FOLDER_MAIN, + TimeResolution.MINUTE_5) + + assert "dx/5_minutes/dx_5_minutes_202001011215" in str(radar_filepath) diff --git a/tests/dwd/radolan/test_index.py b/tests/dwd/radolan/test_index.py deleted file mode 100644 index 3266d639a..000000000 --- a/tests/dwd/radolan/test_index.py +++ /dev/null @@ -1,29 +0,0 @@ -from wetterdienst import Parameter, TimeResolution, PeriodType -from wetterdienst.dwd.metadata.constants import DWDWeatherBase, DWDCDCBase -from wetterdienst.dwd.metadata.radar_data_types import RadarDataTypes -from wetterdienst.dwd.metadata.radar_sites import RadarSites -from wetterdienst.dwd.radolan.index import _create_file_index_radolan - - -def test_radolan_fileindex(): - - file_index = _create_file_index_radolan( - Parameter.SWEEP_VOL_VELOCITY_V, - TimeResolution.MINUTE_5, - DWDWeatherBase.RADAR_SITES, - radar_site=RadarSites.BOO, - radar_data_type=RadarDataTypes.HDF5 - ) - test_split = file_index.iat[0, 0].split('/') - assert test_split[0] == 'sweep_vol_v' - assert test_split[1] == 'boo' - assert test_split[2] == 'hdf5' - - file_index = _create_file_index_radolan( - Parameter.PX250_REFLECTIVITY, - TimeResolution.MINUTE_5, - DWDWeatherBase.RADAR_SITES, - radar_site=RadarSites.BOO) - test_split = file_index.iat[0, 0].split('/') - assert test_split[0] == 'px250' - assert test_split[1] == 'boo' diff --git a/tests/dwd/radolan/test_store.py b/tests/dwd/radolan/test_store.py deleted file mode 100644 index ec7fcfd58..000000000 --- a/tests/dwd/radolan/test_store.py +++ /dev/null @@ -1,16 +0,0 @@ -from datetime import datetime -from pathlib import PosixPath - -from wetterdienst import Parameter, TimeResolution -from wetterdienst.dwd.metadata.constants import DWD_FOLDER_MAIN -from wetterdienst.dwd.radolan.store import build_local_filepath_for_radar - - -def test_build_local_filepath_for_radar(): - assert PosixPath('/home/dlassahn/projects/forecast-system/wetterdienst/' - 'dwd_data/dx/5_minutes/dx_5_minutes_202001011215') == \ - build_local_filepath_for_radar( - Parameter.DX_REFLECTIVITY, - datetime(2020, 1, 1, 12, 15), - DWD_FOLDER_MAIN, - TimeResolution.MINUTE_5) diff --git a/tests/dwd/test_index.py b/tests/dwd/test_index.py index 32408c4de..295c6efc2 100644 --- a/tests/dwd/test_index.py +++ b/tests/dwd/test_index.py @@ -44,10 +44,8 @@ def test_fileindex(): file_index = _create_file_index_for_dwd_server( Parameter.CLIMATE_SUMMARY, TimeResolution.DAILY, + PeriodType.RECENT, DWDCDCBase.CLIMATE_OBSERVATIONS, - period_type=PeriodType.RECENT) + ) - test_split = file_index.iat[0, 0].split('/') - assert test_split[0] == 'daily' - assert test_split[1] == 'kl' - assert test_split[2] == 'recent' + assert "daily/kl/recent" in file_index.iloc[0]["FILENAME"] diff --git a/tests/test_cli.py b/tests/test_cli.py index 2e0667aba..49ee7c715 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -30,6 +30,9 @@ def test_cli_about_parameters(capsys): assert "air_temperature" in response assert "weather_phenomena" in response assert "radolan" in response + assert "wx" in response + assert "rx" in response + assert "sweep_vol_z" in response def test_cli_about_resolutions(capsys): diff --git a/wetterdienst/__init__.py b/wetterdienst/__init__.py index a43a21faa..2a1890942 100644 --- a/wetterdienst/__init__.py +++ b/wetterdienst/__init__.py @@ -11,7 +11,7 @@ get_nearby_stations_by_number, get_nearby_stations_by_distance, ) -from wetterdienst.dwd.radolan.api import DWDRadolanRequest +from wetterdienst.dwd.radar.api import DWDRadarRequest # Single-sourcing the package version # https://cjolowicz.github.io/posts/hypermodern-python-06-ci-cd/ diff --git a/wetterdienst/dwd/metadata/constants.py b/wetterdienst/dwd/metadata/constants.py index 1903363ab..94320521f 100644 --- a/wetterdienst/dwd/metadata/constants.py +++ b/wetterdienst/dwd/metadata/constants.py @@ -11,13 +11,6 @@ class DWDCDCBase(Enum): CLIMATE_OBSERVATIONS = "observations_germany/climate/" - GRIDS_GERMANY = "grids_germany/" - - -class DWDWeatherBase(Enum): - PATH = "weather" - RADAR_COMPOSITE = "radar/composite" - RADAR_SITES = "radar/sites" DWD_FOLDER_MAIN = "./dwd_data" diff --git a/wetterdienst/dwd/metadata/radar_data_types.py b/wetterdienst/dwd/metadata/radar_data_types.py deleted file mode 100644 index ca654a3b9..000000000 --- a/wetterdienst/dwd/metadata/radar_data_types.py +++ /dev/null @@ -1,8 +0,0 @@ -from enum import Enum - - -class RadarDataTypes(Enum): - """ Enumeration for different Radar Data Types""" - BUFR = "bufr" - HDF5 = "hdf5" - BINARY = "binary" diff --git a/wetterdienst/dwd/observations/store.py b/wetterdienst/dwd/observations/store.py index 504aef404..69a31656b 100644 --- a/wetterdienst/dwd/observations/store.py +++ b/wetterdienst/dwd/observations/store.py @@ -8,6 +8,7 @@ DWD_FOLDER_STATION_DATA, DWD_FILE_STATION_DATA, DataFormat, +) def store_climate_observations( diff --git a/wetterdienst/dwd/radolan/__init__.py b/wetterdienst/dwd/radar/__init__.py similarity index 100% rename from wetterdienst/dwd/radolan/__init__.py rename to wetterdienst/dwd/radar/__init__.py diff --git a/wetterdienst/dwd/radolan/access.py b/wetterdienst/dwd/radar/access.py similarity index 95% rename from wetterdienst/dwd/radolan/access.py rename to wetterdienst/dwd/radar/access.py index 612239296..eb560a2fe 100644 --- a/wetterdienst/dwd/radolan/access.py +++ b/wetterdienst/dwd/radar/access.py @@ -10,8 +10,8 @@ from wetterdienst.dwd.metadata.constants import DWD_FOLDER_MAIN from wetterdienst.dwd.network import download_file_from_dwd -from wetterdienst.dwd.radolan.index import create_file_index_for_radolan -from wetterdienst.dwd.radolan.store import restore_radolan_data, store_radolan_data +from wetterdienst.dwd.radar.index import create_file_index_for_radolan +from wetterdienst.dwd.radar.store import restore_radar_data, store_radar_data from wetterdienst.dwd.metadata.column_names import DWDMetaColumns from wetterdienst.dwd.metadata.datetime import DatetimeFormat from wetterdienst.util.cache import payload_cache_twelve_hours @@ -85,7 +85,7 @@ def _collect_radolan_data( data.append( ( date_time, - restore_radolan_data(Parameter.RADOLAN, date_time, time_resolution, folder), + restore_radar_data(Parameter.RADOLAN, date_time, time_resolution, folder), ) ) @@ -100,6 +100,7 @@ def _collect_radolan_data( remote_radolan_file_path = create_filepath_for_radolan( date_time, time_resolution ) + print("remote_radolan_file_path:", remote_radolan_file_path) if remote_radolan_file_path == "": log.warning(f"RADOLAN not found for {str(date_time)}, will be skipped.") @@ -110,7 +111,7 @@ def _collect_radolan_data( data.append(date_time_and_file) if write_file: - store_radolan_data(Parameter.RADOLAN, date_time_and_file, time_resolution, folder) + store_radar_data(Parameter.RADOLAN, date_time_and_file, time_resolution, folder) return data diff --git a/wetterdienst/dwd/radolan/api.py b/wetterdienst/dwd/radar/api.py similarity index 88% rename from wetterdienst/dwd/radolan/api.py rename to wetterdienst/dwd/radar/api.py index 4ec21ce7a..018c37f3c 100644 --- a/wetterdienst/dwd/radolan/api.py +++ b/wetterdienst/dwd/radar/api.py @@ -5,15 +5,15 @@ import pandas as pd -from wetterdienst import TimeResolution +from wetterdienst import TimeResolution, Parameter from wetterdienst.dwd.metadata.constants import DWD_FOLDER_MAIN -from wetterdienst.dwd.radolan.access import collect_radar_data +from wetterdienst.dwd.radar.access import collect_radar_data from wetterdienst.dwd.metadata.column_names import DWDMetaColumns -from wetterdienst.dwd.radolan.index import create_file_index_for_radolan +from wetterdienst.dwd.radar.index import create_file_index_for_radolan from wetterdienst.dwd.util import parse_enumeration_from_template -class DWDRadolanRequest: +class DWDRadarRequest: """ API for DWD RADOLAN data requests. """ @@ -31,15 +31,15 @@ def __init__( """ :param time_resolution: Time resolution enumeration, either hourly or daily - :param date_times: List of datetimes for which RADOLAN is requested. + :param date_times: List of datetimes for which radar data is requested. Minutes have o be defined (HOUR:50), otherwise rounded to 50 minutes as of its provision. :param start_date: Alternative to datetimes, giving a start and end date :param end_date: Alternative to datetimes, giving a start and end date - :param prefer_local: RADOLAN should rather be loaded from disk, for + :param prefer_local: Radar data should rather be loaded from disk, for processing purposes :param write_file: File should be stored on drive - :param folder: Folder where to store RADOLAN data + :param folder: Folder where to store radar data :return: Nothing for now. """ @@ -100,6 +100,7 @@ def collect_data(self) -> Generator[Tuple[datetime, BytesIO], None, None]: """ for date_time in self.date_times: _, file_in_bytes = collect_radar_data( + parameter=Parameter.RADOLAN, time_resolution=self.time_resolution, date_times=[date_time], write_file=self.write_file, diff --git a/wetterdienst/dwd/radolan/index.py b/wetterdienst/dwd/radar/index.py similarity index 71% rename from wetterdienst/dwd/radolan/index.py rename to wetterdienst/dwd/radar/index.py index 1aec6bd47..74e3e9ebe 100644 --- a/wetterdienst/dwd/radolan/index.py +++ b/wetterdienst/dwd/radar/index.py @@ -1,19 +1,17 @@ import re -from pathlib import PurePosixPath -from typing import Optional, Union +from typing import Optional +from urllib.parse import urljoin import pandas as pd from dateparser import parse from wetterdienst import TimeResolution, Parameter, PeriodType -from wetterdienst.dwd.metadata.constants import DWDCDCBase, ArchiveFormat, DWDWeatherBase +from wetterdienst.dwd.metadata.constants import ArchiveFormat, DWD_SERVER, DWD_CDC_PATH from wetterdienst.dwd.metadata.column_names import DWDMetaColumns from wetterdienst.dwd.metadata.datetime import DatetimeFormat -from wetterdienst.dwd.index import _create_file_index_for_dwd_server -from wetterdienst.dwd.metadata.radar_data_types import RadarDataTypes -from wetterdienst.dwd.metadata.radar_sites import RadarSites -from wetterdienst.file_path_handling.path_handling import RADAR_PARAMETERS_COMPOSITES, RADAR_PARAMETERS_SITES, \ - RADAR_PARAMETERS_WITH_HDF5 +from wetterdienst.dwd.radar.sites import RadarSites +from wetterdienst.dwd.radar.metadata import RADAR_PARAMETERS_COMPOSITES, RADAR_PARAMETERS_SITES, \ + RADAR_PARAMETERS_WITH_HDF5, RadarDataTypes from wetterdienst.util.cache import fileindex_cache_five_minutes from wetterdienst.util.network import list_remote_files @@ -38,11 +36,10 @@ def create_file_index_for_radolan(time_resolution: TimeResolution) -> pd.DataFra """ file_index = pd.concat( [ - _create_file_index_radolan( + _create_fileindex_radar( Parameter.RADOLAN, time_resolution, period_type, - DWDCDCBase.GRIDS_GERMANY, ) for period_type in (PeriodType.HISTORICAL, PeriodType.RECENT) ] @@ -70,10 +67,9 @@ def create_file_index_for_radolan(time_resolution: TimeResolution) -> pd.DataFra return file_index -def _create_file_index_radolan( +def _create_fileindex_radar( parameter: Parameter, - time_resolution: TimeResolution, - dwd_base: Union[DWDCDCBase, DWDWeatherBase], + time_resolution: Optional[TimeResolution] = None, period_type: Optional[PeriodType] = None, radar_site: Optional[RadarSites] = None, radar_data_type: Optional[RadarDataTypes] = None @@ -97,27 +93,24 @@ def _create_file_index_radolan( radar_site, radar_data_type) - files_server = list_remote_files(parameter_path, dwd_base, recursive=True) + url = urljoin(DWD_SERVER, parameter_path) + + files_server = list_remote_files(url, recursive=True) files_server = pd.DataFrame( files_server, columns=[DWDMetaColumns.FILENAME.value], dtype="str" ) - data_directory = DWDCDCBase.PATH.value \ - if isinstance(dwd_base, DWDCDCBase) else DWDWeatherBase.PATH.value - - files_server[DWDMetaColumns.FILENAME.value] = files_server[ - DWDMetaColumns.FILENAME.value - ].str.replace(f"{data_directory}/{dwd_base.value}/", "") - return files_server def build_path_to_parameter( parameter: Parameter, + time_resolution: Optional[TimeResolution] = None, + period_type: Optional[PeriodType] = None, radar_site: Optional[RadarSites] = None, radar_data_type: Optional[RadarDataTypes] = None -) -> PurePosixPath: +) -> str: """ Function to build a indexing file path Args: @@ -130,23 +123,24 @@ def build_path_to_parameter( Returns: indexing file path relative to climate observations path """ - if parameter in RADAR_PARAMETERS_COMPOSITES: - parameter_path = PurePosixPath(parameter.value) + if parameter == Parameter.RADOLAN: + parameter_path = f"{DWD_CDC_PATH}/grids_germany/{time_resolution.value}/{parameter.value}/{period_type.value}" + + elif parameter in RADAR_PARAMETERS_COMPOSITES: + parameter_path = f"weather/radar/composite/{parameter.value}" elif parameter in RADAR_PARAMETERS_SITES: if radar_site is None: - raise ValueError("You have choosen radar site data which " - "requires to pass a RadarSite") + raise ValueError("Acquiring radar site data requires a RadarSite") else: - parameter_path = PurePosixPath(parameter.value, - radar_site.value) + parameter_path = f"weather/radar/sites/{parameter.value}/{radar_site.value}" if parameter in RADAR_PARAMETERS_WITH_HDF5: if radar_data_type is None: - raise ValueError("You have to define a RadarDataType [hdf5 or binary]") + raise ValueError("RadarDataType missing [hdf5 or binary]") elif radar_data_type is RadarDataTypes.HDF5: - parameter_path = PurePosixPath.joinpath(parameter_path, radar_data_type.value) + parameter_path = f"{parameter_path}/{radar_data_type.value}" else: - raise KeyError("Unknown parameter for RADAR") + raise KeyError("Failed to compute path to RADAR data") return parameter_path diff --git a/wetterdienst/dwd/radar/metadata.py b/wetterdienst/dwd/radar/metadata.py new file mode 100644 index 000000000..37795a73f --- /dev/null +++ b/wetterdienst/dwd/radar/metadata.py @@ -0,0 +1,25 @@ +from enum import Enum +from wetterdienst import Parameter + + +class RadarDataTypes(Enum): + """ Enumeration for different Radar Data Types""" + BUFR = "bufr" + HDF5 = "hdf5" + BINARY = "binary" + + +RADAR_PARAMETERS_SITES = \ + [Parameter.DX_REFLECTIVITY, Parameter.LMAX_VOLUME_SCAN, + Parameter.PE_ECHO_TOP, Parameter.PF_REFLECTIVITY, + Parameter.PX_REFLECTIVITY, Parameter.PL_VOLUME_SCAN, + Parameter.PR_VELOCITY, Parameter.PX250_REFLECTIVITY, + Parameter.PZ_CAPPI, Parameter.SWEEP_VOL_PRECIPITATION_V, + Parameter.SWEEP_VOL_PRECIPITATION_Z, + Parameter.SWEEP_VOL_VELOCITY_V, Parameter.SWEEP_VOL_VELOCITY_Z] +RADAR_PARAMETERS_COMPOSITES = [Parameter.PP_REFLECTIVITY, Parameter.PG_REFLECTIVITY, + Parameter.WX_REFLECTIVITY, Parameter.WN_REFLECTIVITY, + Parameter.RX_REFLECTIVITY] +RADAR_PARAMETERS_WITH_HDF5 = [Parameter.SWEEP_VOL_PRECIPITATION_V, + Parameter.SWEEP_VOL_PRECIPITATION_Z, + Parameter.SWEEP_VOL_VELOCITY_V, Parameter.SWEEP_VOL_VELOCITY_Z] diff --git a/wetterdienst/dwd/metadata/radar_sites.py b/wetterdienst/dwd/radar/sites.py similarity index 100% rename from wetterdienst/dwd/metadata/radar_sites.py rename to wetterdienst/dwd/radar/sites.py diff --git a/wetterdienst/dwd/radolan/store.py b/wetterdienst/dwd/radar/store.py similarity index 78% rename from wetterdienst/dwd/radolan/store.py rename to wetterdienst/dwd/radar/store.py index 163464a92..68abdc6e6 100644 --- a/wetterdienst/dwd/radolan/store.py +++ b/wetterdienst/dwd/radar/store.py @@ -7,19 +7,19 @@ from wetterdienst.dwd.metadata.datetime import DatetimeFormat -def store_radolan_data( +def store_radar_data( parameter: Parameter, date_time_and_file: Tuple[datetime, BytesIO], time_resolution: TimeResolution, folder: Union[str, Path], ) -> None: """ - Stores a binary file of radolan data locally + Stores a binary file of radar data locally. """ date_time, file = date_time_and_file - filepath = build_local_filepath_for_radar(parameter, date_time, folder, time_resolution) + filepath = _build_local_filepath(parameter, date_time, folder, time_resolution) filepath.parent.mkdir(parents=True, exist_ok=True) @@ -27,14 +27,14 @@ def store_radolan_data( f.write(file.read()) -def restore_radolan_data( +def restore_radar_data( parameter: Parameter, date_time: datetime, time_resolution: TimeResolution, folder: Union[str, Path] ) -> BytesIO: - """ Opens downloaded radolan data into a binary object""" - filepath = build_local_filepath_for_radar(parameter, date_time, folder, time_resolution) + """ Opens downloaded radar data into a binary object""" + filepath = _build_local_filepath(parameter, date_time, folder, time_resolution) with filepath.open("rb") as f: file_in_bytes = BytesIO(f.read()) @@ -42,7 +42,7 @@ def restore_radolan_data( return file_in_bytes -def build_local_filepath_for_radar( +def _build_local_filepath( parameter: Parameter, date_time: datetime, folder: Union[str, Path],