Skip to content

Commit

Permalink
Add bbox and station name filter functions for stations
Browse files Browse the repository at this point in the history
Add units for distance filter
  • Loading branch information
gutzbenj committed Apr 5, 2021
1 parent 9ec696e commit 7bf489a
Show file tree
Hide file tree
Showing 17 changed files with 4,603 additions and 7,655 deletions.
6 changes: 5 additions & 1 deletion .github/release/full/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@ FROM python:3.8.8-slim as build-step
ENV DEBIAN_FRONTEND noninteractive
ENV TERM linux

# Install GDAL.
RUN apt-get update

# Install gcc compiler for python-levenstein
RUN apt-get install gcc --yes

# Install GDAL.
RUN apt-get --yes install build-essential libgdal-dev libmariadbclient-dev

# Make sure you have numpy installed before you attempt to install the GDAL Python bindings.
Expand Down
5 changes: 5 additions & 0 deletions .github/release/standard/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ FROM python:3.8.8-slim
ENV DEBIAN_FRONTEND noninteractive
ENV TERM linux

RUN apt-get update

# Install gcc compiler for python-levenstein
RUN apt-get install gcc --yes

# Use "poetry build --format=wheel" to build wheel packages.
COPY dist/wetterdienst-*.whl /tmp/

Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Development
- Add capability to export data to Zarr format
- Add Wetterdienst UI. Thanks, @meteoDaniel!
- Add MAC ARM64 supoort with dependency restrictions
- Add support for stations filtering via bbox and name
- Add support for units in distance filtering

0.16.1 (31.03.2021)
*******************
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Overview
.. image:: https://img.shields.io/pypi/status/wetterdienst.svg
:target: https://pypi.python.org/pypi/wetterdienst/
.. image:: https://pepy.tech/badge/wetterdienst/month
:target: https://pepy.tech/project/wetterdienst/month
:target: https://pepy.tech/project/wetterdienst
.. image:: https://img.shields.io/github/license/earthobservations/wetterdienst
:target: https://github.com/earthobservations/wetterdienst/blob/main/LICENSE
.. image:: https://zenodo.org/badge/160953150.svg
Expand Down
11,482 changes: 4,024 additions & 7,458 deletions THIRD_PARTY_NOTICES

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/library/core.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Download
Enumerations
============

.. automodule:: wetterdienst.provider.dwd.metadata.column_names
.. automodule:: wetterdienst.metadata.columns
:members:

.. automodule:: wetterdienst.provider.dwd.metadata.datetime
Expand Down
110 changes: 105 additions & 5 deletions docs/usage/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,38 @@ Get station information for a given *parameter/parameter_set*, *resolution* and
The function returns a Pandas DataFrame with information about the available stations.

Filter for specific station ids:

.. ipython:: python
from wetterdienst.provider.dwd.observation import DwdObservationRequest, DwdObservationDataset, DwdObservationPeriod, DwdObservationResolution
stations = DwdObservationRequest(
parameter=DwdObservationDataset.PRECIPITATION_MORE,
resolution=DwdObservationResolution.DAILY,
period=DwdObservationPeriod.HISTORICAL
).filter(station_id=("01048", ))
df = stations.df
print(df.head())
Filter for specific station name:

.. ipython:: python
from wetterdienst.provider.dwd.observation import DwdObservationRequest, DwdObservationDataset, DwdObservationPeriod, DwdObservationResolution
stations = DwdObservationRequest(
parameter=DwdObservationDataset.PRECIPITATION_MORE,
resolution=DwdObservationResolution.DAILY,
period=DwdObservationPeriod.HISTORICAL
).filter_name(name="Dresden-Klotzsche")
df = stations.df
print(df.head())
Values
------

Expand Down Expand Up @@ -187,7 +219,12 @@ Geospatial support
Inquire the list of stations by geographic coordinates.

- Calculate weather stations close to the given coordinates and set of parameters.
- Either select by rank (n stations) or by distance in km.
- Select stations by
- rank (n stations)
- distance (km, mi,...)
- bbox

Distance with default (kilometers)

.. ipython:: python
Expand All @@ -202,14 +239,53 @@ Inquire the list of stations by geographic coordinates.
end_date=datetime(2020, 1, 20)
)
df = stations.nearby_radius(
df = stations.nearby_distance(
latitude=50.0,
longitude=8.9,
max_distance_in_km=30
distance=30
).df
print(df.head())
Distance with miles

.. ipython:: python
from datetime import datetime
from wetterdienst.provider.dwd.observation import DwdObservationRequest, DwdObservationDataset, DwdObservationPeriod, DwdObservationResolution
stations = DwdObservationRequest(
parameter=DwdObservationDataset.TEMPERATURE_AIR,
resolution=DwdObservationResolution.HOURLY,
period=DwdObservationPeriod.RECENT,
start_date=datetime(2020, 1, 1),
end_date=datetime(2020, 1, 20)
)
df = stations.nearby_distance(
latitude=50.0,
longitude=8.9,
distance=30,
unit="mi"
).df
print(df.head())
Rank selection

.. ipython:: python
from datetime import datetime
from wetterdienst.provider.dwd.observation import DwdObservationRequest, DwdObservationDataset, DwdObservationPeriod, DwdObservationResolution
stations = DwdObservationRequest(
parameter=DwdObservationDataset.TEMPERATURE_AIR,
resolution=DwdObservationResolution.HOURLY,
period=DwdObservationPeriod.RECENT,
start_date=datetime(2020, 1, 1),
end_date=datetime(2020, 1, 20)
)
df = stations.nearby_number(
latitude=50.0,
longitude=8.9,
Expand All @@ -218,6 +294,30 @@ Inquire the list of stations by geographic coordinates.
print(df.head())
Bbox selection

.. ipython:: python
from datetime import datetime
from wetterdienst.provider.dwd.observation import DwdObservationRequest, DwdObservationDataset, DwdObservationPeriod, DwdObservationResolution
stations = DwdObservationRequest(
parameter=DwdObservationDataset.TEMPERATURE_AIR,
resolution=DwdObservationResolution.HOURLY,
period=DwdObservationPeriod.RECENT,
start_date=datetime(2020, 1, 1),
end_date=datetime(2020, 1, 20)
)
df = stations.bbox(
bottom=50.0,
left=8.9,
top=50.01,
right=8.91,
).df
print(df.head())
The function returns a StationsResult with the list of stations being filtered for
distances [in km] to the given coordinates.
Expand All @@ -232,10 +332,10 @@ Again from here we can jump to the corresponding data:
period=DwdObservationPeriod.RECENT,
start_date=datetime(2020, 1, 1),
end_date=datetime(2020, 1, 20)
).nearby_radius(
).nearby_distance(
latitude=50.0,
longitude=8.9,
max_distance_in_km=30
distance=30
)
for result in stations.values.query():
Expand Down
2 changes: 1 addition & 1 deletion example/observations_stations.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def station_example():
humanize=True,
)

df = stations.nearby_radius(latitude=50.0, longitude=8.9, max_distance_in_km=30).df
df = stations.nearby_distance(latitude=50.0, longitude=8.9, distance=30).df

print(df)

Expand Down
73 changes: 72 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,18 @@ importlib_metadata = { version = "^1.7.0", python = "<3.8" }

# Optional dependencies aka. "extras"
openpyxl = { version = "^3.0.7", optional = true }
pyarrow = { version = "^3.0.0", optional = true , markers = "sys_platform != 'darwin' or (sys_platform == 'darwin' and platform_machine != 'arm64')"} # not supported through h5py
duckdb = { version = "^0.2.3", optional = true , allow-prereleases = true }
pyarrow = { version = "^3.0.0", optional = true, markers = "sys_platform != 'darwin' or (sys_platform == 'darwin' and platform_machine != 'arm64')"} # not supported through h5py
duckdb = { version = "^0.2.3", optional = true, allow-prereleases = true }
influxdb = { version = "^5.3.0", optional = true }
sqlalchemy = { version = "^1.3", optional = true }
crate = { version = "^0.25.0", optional = true, extras = ["sqlalchemy"] }
mysqlclient = { version = "^2.0.1", optional = true , markers = "sys_platform != 'darwin' or (sys_platform == 'darwin' and platform_machine != 'arm64')"} # not supported through h5py
mysqlclient = { version = "^2.0.1", optional = true, markers = "sys_platform != 'darwin' or (sys_platform == 'darwin' and platform_machine != 'arm64')"} # not supported through h5py
psycopg2-binary = { version = "^2.8.6", optional = true }

# HTTP service
fastapi = { version = "^0.61.1", optional = true }
uvicorn = { version = "^0.13.3", optional = true }
wradlib = { version = "^1.9.0", optional = true , markers = "sys_platform != 'darwin' or (sys_platform == 'darwin' and platform_machine != 'arm64')"} # not supported through h5py
wradlib = { version = "^1.9.0", optional = true, markers = "sys_platform != 'darwin' or (sys_platform == 'darwin' and platform_machine != 'arm64')"} # not supported through h5py

# UI
plotly = { version = "^4.14.3", optional = true }
Expand All @@ -130,6 +130,9 @@ ipython-genutils = { version = "^0.2.0", optional = true }
requests-ftp = "^0.3.1"
zarr = {version = "^2.7.0", optional = true, markers = "sys_platform != 'darwin' or (sys_platform == 'darwin' and platform_machine != 'arm64')"} # not supported through numcodecs
xarray = {version = "^0.17.0", optional = true}
measurement = "^3.2.0"
fuzzywuzzy = "^0.18.0"
python-Levenshtein = "^0.12.2"


[tool.poetry.dev-dependencies]
Expand Down

0 comments on commit 7bf489a

Please sign in to comment.