Skip to content

Releases: ZeroWave022/yr-weather

v0.4.0

13 Oct 21:15
713d080
Compare
Choose a tag to compare

Rewrite to more developer-friendly usage

Multiple parts of the package have been rewritten to use classes and dataclasses instead of dicts. This results in easier usage and requires less code for the same effect(s).

Locationforecast

Data is easier to access.

Old usage example in v0.3.0:

# Full weather data for Oslo, Norway.
forecast = my_client.get_forecast(59.91, 10.75, "compact")

now = forecast["properties"]["timeseries"][0]["data"]

next_6_hours = now["next_6_hours"]["details"]

print("Air temperature next 6 hours is predicted to be between:")
print(f"{next_6_hours['air_temperature_min']} °C and {next_6_hours['air_temperature_max']} °C")

In v0.4.0:

# Full weather data for Oslo, Norway.
forecast = my_client.get_forecast(59.91, 10.75, "compact")

now = forecast.now()

air_temp_min = now.next_6_hours.details.air_temperature_min
air_temp_max = now.next_6_hours.details.air_temperature_max

print("Air temperature next 6 hours is predicted to be between:")
print(f"{air_temp_min} °C and {air_temp_max} °C")

Other shortcuts, such as getting the current air temperature for a location, are still available (see Locationforecast.get_air_temperature)

See other examples in the docs

Textforecast

Data is easier to access, the structure has been flattened.

Old usage example in v0.3.0:

land_overview = my_client.get_forecasts("landoverview")

newest_forecast = land_overview["time"][0]["forecasttype"]

first_location = newest_forecast["location"][0]

print(f"The forecast for the first location is: {first_location.text}")

In v0.4.0:

land_overview = my_client.get_forecasts("landoverview")

forecast_now = land_overview.now()

# Not really that useful to get the first location, so why not get a specific one?
forecast_east = forecast_now.locations.get("Østlandet")

if forecast_east:
    print(f"The forecast for Østlandet is: {forecast_east.text}")
else:
    print("Sorry, couldn't get the forecast for Østlandet!")

# Not sure which locations are available in the forecast you received? Use TextForecastLocations.names
locations = forecast_now.locations.names

print(f"Available locations are {', '.join(locations)}")

See other examples in the docs

Radar, Sunrise and Geosatellite

These MET API products have also received improvements when using yr-weather.
For details, check the examples in the documentation for the respective product.

Other changes

  • The project status has developed: alpha -> beta
  • Testing using pytest added
  • Added support for mypy

Available on PyPi.

Full Changelog: v0.3.0...v0.4.0

v0.3.0

02 Feb 18:15
a71e38a
Compare
Choose a tag to compare

Changelog

  • Support for Geosatellite (v1.4)
  • Even better docs
  • License changed to Apache 2.0

Available on PyPi.

All commits: v0.2.0...v0.3.0

Release v0.2.0

27 Jan 21:41
15dc9dc
Compare
Choose a tag to compare

Changelog

  • Added Read the Docs documentation
  • Rewritten docstrings in reStructuredText
  • Added support for Sunrise (v2.0)
  • Some less significant code refactoring

Available on PyPi.

All commits: v0.1.1...v0.2.0

Release v0.1.1

24 Jan 18:40
76d23a1
Compare
Choose a tag to compare

Changelog

  • Textforecast: It's possible to get areas (their polygons, names, etc.)
  • Some warnings added, in case XML can't be parsed
  • Typing files moved to own module

Available on PyPI.

Release v0.1.0

23 Jan 17:06
29b7c1a
Compare
Choose a tag to compare

First release of yr-weather.
The project is still in early Alpha. Feedback and contributions are greatly appreciated!

Added support for products:

  • Locationforecast (v2.0)
  • Radar (v2.0)
  • Textforecast (v2.0)