Package: wetterdienst
Wetterdienst - Open weather data for humans“What do we want? Climate Justice! When do we want it? Now!” - FFFWARNINGThis library is a work in progress!Breaking changes should be expected until a 1.0 release, so version pinning is recommended.CIMetaDownloadsCitationIntroductionOverviewWelcome to Wetterdienst, your friendly weather service library for Python.We are a group of like-minded people trying to make access to weather data in
Python feel like a warm summer breeze, similar to other projects likerdwdfor the R language, which originally drew our interest in this project.
Our long-term goal is to provide access to multiple weather services as well as other
related agencies such as river measurements. Withwetterdienstwe try to use modern
Python technologies all over the place. The library is based onpolars(we <3pandas, it is still part of some
IO processes) across the board, usesPoetryfor package administration and GitHub Actions for all things CI.
Our users are an important part of the development as we are not currently using the
data we are providing and only implement what we think would be the best. Therefore
contributions and feedback whether it be data related or library related are very
welcome! Just hand in a PR or Issue if you think we should include a new feature or data
source.DataFor an overview of the data we have currently made available and under which
license it is published take a look at thedatasection. Detailed information
on datasets and parameters is given at thecoveragesubsection. Licenses and
usage requirements may differ for each provider so check this out before including
the data in your project to be sure that you fulfill copyright requirements!FeaturesAPIs for stations and valuesGet stations nearby a selected locationDefine your request by arguments such asparameter,period,resolution,start date,end dateDefine general settings in Settings contextCommand line interfaceWeb-API via FastAPIRich UI features like wetterdienst explorer andstreamlit appRun SQL queries on the resultsExport results to databases and other data sinksPublic Docker imageInterpolation and Summary of station valuesSetupNativeVia PyPi (standard):pipinstallwetterdienstVia Github (most recent):pipinstallgit+https://github.com/earthobservations/wetterdienstThere are some extras available forwetterdienst. Use them like:pipinstallwetterdienst[http,sql]docs: Install the Sphinx documentation generator.ipython: Install iPython stack.export: Install openpyxl for Excel export and pyarrow for writing files in Feather- and Parquet-format.http: Install HTTP API prerequisites.sql: Install DuckDB for querying data using SQL.duckdb: Install support for DuckDB.influxdb: Install support for InfluxDB.cratedb: Install support for CrateDB.mysql: Install support for MySQL.postgresql: Install support for PostgreSQL.interpolation: Install support for station interpolation.In order to check the installation, invoke:wetterdienst--helpDockerDocker images for each stable release will get pushed to GitHub Container Registry.wetterdienstserves a full environment, includingallof the optional dependencies of Wetterdienst.Pull the Docker image:dockerpullghcr.io/earthobservations/wetterdienstLibraryUse the latest stable version ofwetterdienst:$dockerrun-tighcr.io/earthobservations/wetterdienstPython3.8.5(default,Sep102020,16:58:22)[GCC8.3.0]onlinuximportwetterdienstwetterdienst.__version__Command line scriptThewetterdienstcommand is also available:# Make an alias to use it conveniently from your shell.aliaswetterdienst='docker run -ti ghcr.io/earthobservations/wetterdienst wetterdienst'wetterdienst--helpwetterdienst--versionwetterdienstinfoRaspberry Pi / LINUX ARMRunning wetterdienst on Raspberry Pi, you need to installnumpyandlxmlprior to installing wetterdienst by running the following
lines:# not all installations may be required to get lxml runningsudoapt-getinstallgfortransudoapt-getinstalllibopenblas-basesudoapt-getinstalllibopenblas-devsudoapt-getinstalllibatlas-base-devsudoapt-getinstallpython3-lxmlAdditionally expanding the Swap to 2048 mb may be required and can be done via swap-file:sudonano/etc/dphys-swapfileThankschr-stofor reporting back to us!ExampleTask: Get historical climate summary for two German stations between 1990 and 2020Library>>>importpolarsaspl>>>_=pl.Config.set_tbl_hide_dataframe_shape(True)>>>fromwetterdienstimportSettings>>>fromwetterdienst.provider.dwd.observationimportDwdObservationRequest>>>settings=Settings(# default...ts_shape="long",# tidy data...ts_humanize=True,# humanized parameters...ts_si_units=True# convert values to SI units...)>>>request=DwdObservationRequest(...parameter=["climate_summary"],...resolution="daily",...start_date="1990-01-01",# if not given timezone defaulted to UTC...end_date="2020-01-01",# if not given timezone defaulted to UTC...settings=settings...).filter_by_station_id(station_id=(1048,4411))>>>stations=request.df>>>stations.head()┌────────────┬──────────────┬──────────────┬──────────┬───────────┬────────┬─────────────┬─────────┐│station_id┆start_date┆end_date┆latitude┆longitude┆height┆name┆state││---┆---┆---┆---┆---┆---┆---┆---││str┆datetime[μs,┆datetime[μs,┆f64┆f64┆f64┆str┆str││┆UTC]┆UTC]┆┆┆┆┆│╞════════════╪══════════════╪══════════════╪══════════╪═══════════╪════════╪═════════════╪═════════╡│01048┆1934-01-01┆...┆51.1278┆13.7543┆228.0┆Dresden-Klo┆Sachsen││┆00:00:00UTC┆00:00:00UTC┆┆┆┆tzsche┆││04411┆1979-12-01┆...┆49.9195┆8.9672┆155.0┆Schaafheim-┆Hessen││┆00:00:00UTC┆00:00:00UTC┆┆┆┆Schlierbach┆│└────────────┴──────────────┴──────────────┴──────────┴───────────┴────────┴─────────────┴─────────┘>>>values=request.values.all().df>>>values.head()┌────────────┬─────────────────┬───────────────────┬─────────────────────────┬───────┬─────────┐│station_id┆dataset┆parameter┆date┆value┆quality││---┆---┆---┆---┆---┆---││str┆str┆str┆datetime[μs,UTC]┆f64┆f64│╞════════════╪═════════════════╪═══════════════════╪═════════════════════════╪═══════╪═════════╡│01048┆climate_summary┆cloud_cover_total┆1990-01-0100:00:00UTC┆100.0┆10.0││01048┆climate_summary┆cloud_cover_total┆1990-01-0200:00:00UTC┆100.0┆10.0││01048┆climate_summary┆cloud_cover_total┆1990-01-0300:00:00UTC┆91.25┆10.0││01048┆climate_summary┆cloud_cover_total┆1990-01-0400:00:00UTC┆28.75┆10.0││01048┆climate_summary┆cloud_cover_total┆1990-01-0500:00:00UTC┆91.25┆10.0│└────────────┴─────────────────┴───────────────────┴─────────────────────────┴───────┴─────────┘values.to_pandas()# to get a pandas DataFrame and e.g. create some matplotlib plotsClient# Get list of all stations for daily climate summary data in JSON formatwetterdienststations--provider=dwd--network=observation--parameter=kl--resolution=daily--all# Get daily climate summary data for specific stationswetterdienstvalues--provider=dwd--network=observation--station=1048,4411--parameter=kl--resolution=dailyFurther examples (code samples) can be found in theexamplesfolder.AcknowledgementsWe want to acknowledge all environmental agencies which provide their data open and free
of charge first and foremost for the sake of endless research possibilities.We want to acknowledgeJetbrainsand theJetbrains OSS Teamfor providing us with
licenses for Pycharm Pro, which we are using for the development.We want to acknowledge all contributors for being part of the improvements to this
library that make it better and better every day.Important LinksFull documentation:https://wetterdienst.readthedocs.io/Usage:https://wetterdienst.readthedocs.io/en/latest/usage/Contribution:https://wetterdienst.readthedocs.io/en/latest/contribution/Known Issues:https://wetterdienst.readthedocs.io/en/latest/known_issues/Changelog:https://wetterdienst.readthedocs.io/en/latest/changelog.htmlExamples (runnable scripts):https://github.com/earthobservations/wetterdienst/tree/main/examplesBenchmarks:https://github.com/earthobservations/wetterdienst/tree/main/benchmarks