Skip to content

Commit

Permalink
refactor: Refer to docs for examples in docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeroWave022 committed Oct 11, 2023
1 parent 638fdbe commit 52ed0cd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 56 deletions.
21 changes: 4 additions & 17 deletions yr_weather/__init__.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
"""A Python module for interaction with the Yr API.
"""A Python module for interaction with the MET API.
To get started, initialize a Locationforecast client like so:
.. code-block:: python
import yr_weather
headers = {
"User-Agent": "Your User-Agent"
}
my_client = yr_weather.Locationforecast(headers=headers)
For valid user agents, please see:
https://api.met.no/doc/TermsOfService
Using ``my_client``, you can receive forecasts for specified locations, get the air temperature, and more.
yr_weather supports multiple MET API products.
Please visit the docs to learn more:
https://yr-weather.readthedocs.io/en/latest/
"""

from .locationforecast import Locationforecast
Expand Down
42 changes: 3 additions & 39 deletions yr_weather/radar.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ def get_radar(
) -> requests.Response:
"""Get a radar image (png) or animation (gif).
For examples of usage, please see the docs:
https://yr-weather.readthedocs.io/
For more information about what arguments are valid, please see:
https://api.met.no/weatherapi/radar/2.0/documentation
Expand All @@ -53,45 +56,6 @@ def get_radar(
-------
:class:`requests.Response`
A Response class, enabling for further saving or managing of the data received from the open stream.
Examples
--------
Example 1: Basic usage:
.. code-block:: python
import yr_weather
radar = yr_weather.Radar()
result = radar.get_radar("central_norway", "5level_reflectivity", "image")
with open("image.png", "wb") as f:
for chunk in result:
f.write(chunk)
Example 2. Getting a radar image from a few hours back:
.. code-block:: python
import yr_weather
from datetime import datetime
radar = yr_weather.Radar()
# Replace with your time
time_now = datetime(2023, 1, 20, 12, 00, 00)
time_str = time_now.isoformat(timespec="seconds") + "Z"
result = radar.get_radar("central_norway", "5level_reflectivity", "image", time_str)
if result.status_code != 404:
with open("image.png", "wb") as f:
for chunk in result:
f.write(chunk)
else:
print("Couldn't get this radar image/animation!")
"""
area_args = list(get_args(RadarArea))
type_args = list(get_args(RadarType))
Expand Down

0 comments on commit 52ed0cd

Please sign in to comment.