Skip to content

Commit

Permalink
docs: Update sunrise after rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeroWave022 committed Oct 10, 2023
1 parent 65303e4 commit bfb82ae
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 107 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Supported products are:
- Locationforecast (v2.0)
- Radar (v2.0)
- Textforecast (v2.0)
- Sunrise (v2.0)
- Sunrise (v3.0)
- Geosatellite (v1.4)

# Requirements
Expand Down
2 changes: 1 addition & 1 deletion docs/gettingstarted.rst
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ Sunrise
-------

The Sunrise submodule allows you to calculate various events, such as sunrises, sunsets, low moons, high moons and so on.
For more information about the API itself, check `MET's documentation <https://api.met.no/weatherapi/sunrise/2.0/documentation>`__.
For more information about the API itself, check `MET's documentation <https://api.met.no/weatherapi/sunrise/3.0/documentation>`__.

In the example below, we use the :meth:`Sunrise.get_detail` function to get data about the sunset.

Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Supported products are:
* Locationforecast (v2.0)
* Radar (v2.0)
* Textforecast (v2.0)
* Sunrise (v2.0)
* Sunrise (v3.0)
* Geosatellite (v1.4)

Requirements
Expand Down
2 changes: 0 additions & 2 deletions docs/locationforecast/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ Locationforecast: API Reference

.. autoclass:: yr_weather.locationforecast.ForecastTime
:members:
:undoc-members:

.. autoclass:: yr_weather.locationforecast.ForecastFuture
:members:
:undoc-members:

Dataclasses
-----------
Expand Down
2 changes: 1 addition & 1 deletion docs/locationforecast/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The examples assume you have set up a :class:`Locationforecast` client with a va
import yr_weather
# Replace with your own User-Agent. See MET API Terms of Service for correct User-Agents.
# Replace with your own User-Agent. See MET API Terms of Service for correct user agents.
headers = {
"User-Agent": "Your User-Agent"
}
Expand Down
115 changes: 14 additions & 101 deletions docs/sunrise/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,116 +11,29 @@ The examples assume you have set up a :class:`Sunrise` client like so:
import yr_weather
my_client = yr_weather.Sunrise()
# Replace with your own User-Agent. See MET API Terms of Service for correct user agents.
headers = {
"User-Agent": "Your User-Agent"
}
my_client = yr_weather.Sunrise(headers=headers)
.. admonition:: Important
:class: attention

All of the next examples will use ``my_client`` as a reference to your client.

Getting one detail from Sunrise data
Getting one event from Sunrise data
------------------------------------

.. code-block:: python
# Get sunset for Oslo, Norway
sunset = my_client.get_detail("sunset", "2023-01-20", 59.91, 10.75, "+01:00")
print(sunset)
# Example output:
# {
# 'desc': 'LOCAL DIURNAL SUN SET',
# 'time': '2023-01-20T16:00:36+01:00'}
# }
# Get sun and moon events data for Oslo, Norway
sun_events = client.get_sun_events("2023-10-10", 59.91, 10.75)
moon_events = client.get_moon_events("2020-10-10", 59.91, 10.75)
Getting all data from Sunrise
-----------------------------
sunrise_time = sun_events.sunrise.time
moonrise_time = moon_events.moonrise.time
.. code-block:: python
# Get sunrise data for Oslo, Norway
sr_data = my_client.get_sunrise("2023-01-20", 59.91, 10.75, "+01:00")
print(sr_data)
# Example output:
# {
# "location": {
# "height": "0",
# "latitude": "59.9",
# "longitude": "10.7",
# "time": [
# {
# "date": "2023-01-20",
# "high_moon": {
# "desc": "LOCAL DIURNAL MAXIMUM MOON ELEVATION (Max= 1.94192)",
# "elevation": "1.941923918",
# "time": "2023-01-20T11:01:37+01:00"
# },
# "low_moon": {
# "desc": "LOCAL DIURNAL MINIMUM MOON ELEVATION (Min= -57.28220)",
# "elevation": "-57.282202638",
# "time": "2023-01-20T23:33:17+01:00"
# },
# "moonphase": {
# "desc": "LOCAL MOON STATE * MOON PHASE= 92.4 (waning crescent)",
# "time": "2023-01-20T00:00:00+01:00",
# "value": "92.421478765"
# },
# "moonposition": {
# "azimuth": "34.784350684",
# "desc": "LOCAL MOON POSITION Elv: -54.742 deg, Azi: 34.784, Rng: 365364.7 km",
# "elevation": "-54.741908062",
# "phase": "92.421478765",
# "range": "365364.745236254",
# "time": "2023-01-20T00:00:00+01:00"
# },
# "moonrise": {
# "desc": "LOCAL DIURNAL MOON RISE",
# "time": "2023-01-20T09:14:14+01:00"
# },
# "moonset": {
# "desc": "LOCAL DIURNAL MOON SET",
# "time": "2023-01-20T12:48:59+01:00"
# },
# "moonshadow": {
# "azimuth": "261.058146106",
# "desc": "LOCAL MOON STATE * SHADOW ANGLES (azi=261.1,ele=-62.5)",
# "elevation": "-62.546205058",
# "time": "2023-01-20T00:00:00+01:00"
# },
# "solarmidnight": {
# "desc": "LOCAL DIURNAL MINIMUM SOLAR ELEVATION (Min= -50.33184)",
# "elevation": "-50.331839434",
# "time": "2023-01-20T00:27:46+01:00"
# },
# "solarnoon": {
# "desc": "LOCAL DIURNAL MAXIMUM SOLAR ELEVATION (Max= 9.97480)",
# "elevation": "9.974802331",
# "time": "2023-01-20T12:28:23+01:00"
# },
# "sunrise": {
# "desc": "LOCAL DIURNAL SUN RISE",
# "time": "2023-01-20T08:56:14+01:00"
# },
# "sunset": {
# "desc": "LOCAL DIURNAL SUN SET",
# "time": "2023-01-20T16:00:36+01:00"
# }
# },
# {
# "date": "2023-01-21",
# "moonposition": {
# "azimuth": "9.904412311",
# "desc": "LOCAL MOON POSITION Elv: -57.270 deg, Azi: 9.904, Rng: 362762.3 km",
# "elevation": "-57.27009424",
# "phase": "96.365027217",
# "range": "362762.2610191",
# "time": "2023-01-21T00:00:00+01:00"
# }
# }
# ]
# },
# "meta": {
# "licenseurl": "https://api.met.no/license_data.html"
# }
# }
print(f"Sunrise will happen at {sunrise_time}")
print(f"Moonrise will happen at {moonrise_time}")

0 comments on commit bfb82ae

Please sign in to comment.