Package: dwdGribExtractor
dwdGribExtractor: A tiny Python interface to request and extract NWP grib file data from opendata.dwd.dedwdGribExtractor is a smart package to easely extract data fromnumerical weather predictiongrib files provided by DWD.
The difference to other packages is the location flexibility. So every point
on the 2.2km x 2.2km grid (ICON-D2) can be retrieved for the next X forecast hours.At the moment only ICON_D2 is supported.Supported weather variablesFor currently available weather variabels see:ICON User ManualChapter 6.1.4 table 6.4InstallationInstall with pip:$ pip install dwdGrilbExtractorDependenciesTo read the grib2 filesxarraywithcfgribengine is used.
The easiest way to installcfgriband all its binary dependencies is viaConda:$ conda install -c conda-forge cfgribalternatively, if you install the binary dependencies yourself, you can install the
Python package fromPyPIwith:$ pip install cfgribBinary dependenciescfgribdepends on theeccodes python packageto access the ECMWFecCodesbinary library,
when not usingcondaplease follow theSystem dependenciessection there.WindowsIt is strongly recommended to use Unix enironment runningdwdGrib2location. For
windows several issues may appear. At the momentdwdGrib2locationis tested
with Windows10 and works if following requirements are satiesfied.
To build eccodes on windows by your own should be avoided. The easiest way to
use eccodes on windows is to install it in anMSYSenvironment.Install MSYSInstalleccodes. Depending on your system run in the MSYS cli:$ pacman -S mingw-w64-ucrt-x86_64-eccodesSet environment variables:ECCODES_DIR = <path_to_ecccodes_install_dir> e.g (C:\msys64\ucrt64)
ECCODES_DEFINITION_PATH = <path_to_eccodes_definitions> (e.g C:\msys64\ucrt64\share\eccodes\definitions)Add eccodes to path. This is the folder inside the MSYS environment where the .exe files are located:e.g. C:\msys64\ucrt64\binInstall ecCodes:$ pip install eccodesInstall cfgrib:$ pip install cfgribCheck if cfgrib is working:$ python -m cfgrib selfcheck
Found: ecCodes v2.20.0.
Your system is ready.Linux1. Install eccodes with apt orbuild it by your ownTODOExamplelocationList={"Vienna":{"lat":48.20,"lon":16.37},"Graz":{"lat":47.07,"lon":15.43}}variables=["aswdir_s","aswdifd_s","t_2m"]forecast=ICON_D2(locations=locationList,forecastHours=3)data=forecast.collectData(varList=variables,cores=None)# Disable multiprocessing#data = forecast.collectData(varList = variables, cores = 4)#### Indexing one locationloc="Graz"result=data.loc[loc]result=data.loc[loc,"2021-09-06 06:15:00"]#### Indexing multiple locationsloc=["Graz","Vienna"]result=data.loc[loc]#### Indexing one location with datetime conditionloc="Graz"mask=data.loc[loc].index.get_level_values(0)>np.datetime64('2021-09-06T06:15:00')mask=data.loc[loc].index.get_level_values(0).hour==8result=data.loc[loc][mask]#### Indexing multiple locations with datetime conditionloc=["Graz","Vienna"]mask=data.loc[loc].index.get_level_values(1)>np.datetime64('2021-09-06 06:15:00')mask=data.loc[loc].index.get_level_values(1).hour==8result=data.loc[loc][mask]Knwon IssuesWindowsMultiprocessing on some windows machines may not work. Disable it by settingforecast.collectData(varList = variables, cores = None)Spyder IDEdoes not produce print outputs if multiprocessing is enabled.Dont run the code in Spyder with F5 or debug mode. This calls runfile() and sometimes crashes memory.AuthorManuel StrohmaierLicenseCode licenseLicensed under the MIT license. SeeLICENSEfor details.Data licenseThe DWD has information about their terms of use policy inGermanandEnglish.