Skip to main content

A Python library for accessing MeteoAlarm weather warnings

Project description

MeteoAlarm Python package

DOI PyPI - Downloads

A Python package for accessing and filtering weather warnings from MeteoAlarm's CAP (Common Alerting Protocol) feeds. This package provides easy access to weather warnings across European countries through MeteoAlarm's official feeds.

Features

  • Access weather warnings for multiple European countries
  • Filter warnings based on various attributes (severity, type, description, etc.)
  • Support for multiple languages per warning
  • Automatic parsing of CAP format warnings
  • GeoJSON geometry support for warning areas
  • Timezone-aware datetime handling

Installation

Install the package using pip:

pip install meteoalarm

Quickstart

from meteoalarm import MeteoAlarm

# Initialize with one or more countries
warnings = MeteoAlarm(["estonia", "denmark"])

# Print all warnings
for warning in warnings:
    print(f"""\nWarning for {warning.area["areaDesc"]} ({warning.country}):""")
    print(f"""Headline: {warning.get_headline("en-EN")}""")
    print(f"Severity: {warning.severity}")
    print(f"Valid until: {warning.expires}")

Filtering Warnings

The package provides flexible filtering capabilities:

# Filter by severity
severe_warnings = warnings.filter(severity="Severe")

# Filter by description content (searches in all languages)
wind_warnings = warnings.filter(description="wind")

# Filter by multiple criteria
specific_warnings = warnings.filter(
    country="estonia",
    severity="Moderate",
    awareness_type="2"
)

# Filter with meteoalarm.Regex
from meteoalarm import Regex
regex_warnings = warnings.filter(area=Regex(r"^Orange.*"))

# Filter with datetime.datatime objects
from datetime import datetime
active_warnings = warnings.filter(onset=datetime.now())

# Filter with ISO 8601 date strings
active_warnings_iso = warnings.filter(onset="2024-12-31T23:59:59Z")

# Chain filters
critical_wind = warnings.filter(awareness_type="Wind").filter(severity="Severe")

Multilingual Support

Warnings are available in multiple languages:

# Get available languages for a warning
languages = warning.get_available_languages()

# Get warning information in specific language
english_headline = warning.get_headline("en-EN")
estonian_desc = warning.get_description("et-ET")

Plotting the Warning Area

from shapely.geometry import shape
import geopandas as gpd
import matplotlib.pyplot as plt
import contextily as ctx
import json

# Parse the GeoJSON string
geojson_dict = json.loads(warnings[0].geometry)

# Create geometry object
geometry = shape(geojson_dict)

# Create GeoDataFrame directly
gdf = gpd.GeoDataFrame(geometry=[geometry], crs="EPSG:4326")

# Convert to Web Mercator projection for contextily
gdf_web = gdf.to_crs(epsg=3857)

# Create plot
fig, ax = plt.subplots(figsize=(10, 10))
gdf_web.plot(ax=ax, alpha=0.5, color='red')

# Add background map
ctx.add_basemap(ax)

plt.axis('off')
plt.show()

Warning Attributes

Each warning object contains the following attributes:

  • category: Warning category
  • event: Event type
  • urgency: Urgency level
  • severity: Severity level
  • certainty: Certainty level
  • onset: Start time (datetime object)
  • effective: Effective time (datetime object)
  • expires: Expiration time (datetime object)
  • sender: Dictionary containing sender information
  • headline: Dictionary of headlines in available languages
  • description: Dictionary of descriptions in available languages
  • awareness_level: Awareness level
  • awareness_type: Type of weather warning
  • area: Dictionary containing area description and EMMA_ID
  • geometry: GeoJSON geometry of the warning area

Requirements

  • Python 3.7+
  • requests
  • pytz
  • pyyaml

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Acknowledgments

  • Data provided by MeteoAlarm
  • Based on the CAP (Common Alerting Protocol) standard

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

meteoalarm-0.3.0.tar.gz (12.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

meteoalarm-0.3.0-py3-none-any.whl (12.4 MB view details)

Uploaded Python 3

File details

Details for the file meteoalarm-0.3.0.tar.gz.

File metadata

  • Download URL: meteoalarm-0.3.0.tar.gz
  • Upload date:
  • Size: 12.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for meteoalarm-0.3.0.tar.gz
Algorithm Hash digest
SHA256 d6b3f112f086589360c9d613c39fc540661c77e7192b37556aca91ec25b6e8c6
MD5 df5c111bb0d56203c2f3eac0059807f3
BLAKE2b-256 f27d609328fa98c815f3f1f7481584fcd4bf7f717af3631789894d78ca9874b2

See more details on using hashes here.

Provenance

The following attestation bundles were made for meteoalarm-0.3.0.tar.gz:

Publisher: python-publish.yml on NiklasJordan/meteoalarm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file meteoalarm-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: meteoalarm-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 12.4 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for meteoalarm-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8f02c764bb86cdd265e5ee92e0cc04be3ea7eeb621be83fbde6102cbd815f8c9
MD5 f4963d28629b9f59cdaaf56541ed006d
BLAKE2b-256 e569267abfa8033212f7efa02fd0c3ea6f276fb9c3515ed66977cc0080eec4b2

See more details on using hashes here.

Provenance

The following attestation bundles were made for meteoalarm-0.3.0-py3-none-any.whl:

Publisher: python-publish.yml on NiklasJordan/meteoalarm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page