Metadata-Version: 2.2
Name: frequenz-client-weather
Version: 0.1.0
Summary: Weather API Client for Python
Author-email: Frequenz Energy-as-a-Service GmbH <floss@frequenz.com>
License: MIT
Project-URL: Documentation, https://frequenz-floss.github.io/frequenz-client-weather-python/
Project-URL: Changelog, https://github.com/frequenz-floss/frequenz-client-weather-python/releases
Project-URL: Issues, https://github.com/frequenz-floss/frequenz-client-weather-python/issues
Project-URL: Repository, https://github.com/frequenz-floss/frequenz-client-weather-python
Project-URL: Support, https://github.com/frequenz-floss/frequenz-client-weather-python/discussions/categories/support
Keywords: frequenz,python,lib,library,client-weather
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Software Development :: Libraries
Classifier: Typing :: Typed
Requires-Python: <4,>=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: typing-extensions<5,>=4.12.2
Requires-Dist: numpy<2,>=1.24.2
Requires-Dist: frequenz-api-common<0.7.0,>=0.6.0
Requires-Dist: googleapis-common-protos<2,>=1.56.4
Requires-Dist: frequenz-channels<2,>=1.6.1
Requires-Dist: frequenz-client-base<0.10,>=0.9.0
Requires-Dist: frequenz-api-weather<0.13.0,>=0.12.0
Provides-Extra: dev-flake8
Requires-Dist: flake8==7.1.1; extra == "dev-flake8"
Requires-Dist: flake8-docstrings==1.7.0; extra == "dev-flake8"
Requires-Dist: flake8-pyproject==1.2.3; extra == "dev-flake8"
Requires-Dist: pydoclint==0.6.0; extra == "dev-flake8"
Requires-Dist: pydocstyle==6.3.0; extra == "dev-flake8"
Provides-Extra: dev-formatting
Requires-Dist: black==25.1.0; extra == "dev-formatting"
Requires-Dist: isort==6.0.0; extra == "dev-formatting"
Provides-Extra: dev-mkdocs
Requires-Dist: Markdown==3.7; extra == "dev-mkdocs"
Requires-Dist: black==25.1.0; extra == "dev-mkdocs"
Requires-Dist: mike==2.1.3; extra == "dev-mkdocs"
Requires-Dist: mkdocs-gen-files==0.5.0; extra == "dev-mkdocs"
Requires-Dist: mkdocs-literate-nav==0.6.1; extra == "dev-mkdocs"
Requires-Dist: mkdocs-macros-plugin==1.3.7; extra == "dev-mkdocs"
Requires-Dist: mkdocs-material==9.6.2; extra == "dev-mkdocs"
Requires-Dist: mkdocstrings[python]==0.28.0; extra == "dev-mkdocs"
Requires-Dist: mkdocstrings-python==1.14.6; extra == "dev-mkdocs"
Requires-Dist: frequenz-repo-config[lib]==0.12.3; extra == "dev-mkdocs"
Provides-Extra: dev-mypy
Requires-Dist: mypy==1.9.0; extra == "dev-mypy"
Requires-Dist: types-Markdown==3.7.0.20241204; extra == "dev-mypy"
Requires-Dist: types-protobuf==5.29.1.20250208; extra == "dev-mypy"
Requires-Dist: frequenz-client-weather[dev-mkdocs,dev-noxfile,dev-pytest]; extra == "dev-mypy"
Provides-Extra: dev-noxfile
Requires-Dist: nox==2025.2.9; extra == "dev-noxfile"
Requires-Dist: frequenz-repo-config[lib]==0.12.3; extra == "dev-noxfile"
Provides-Extra: dev-pylint
Requires-Dist: frequenz-client-weather[dev-mkdocs,dev-noxfile,dev-pytest]; extra == "dev-pylint"
Provides-Extra: dev-pytest
Requires-Dist: pytest==8.3.4; extra == "dev-pytest"
Requires-Dist: pylint==3.3.4; extra == "dev-pytest"
Requires-Dist: frequenz-repo-config[extra-lint-examples]==0.12.3; extra == "dev-pytest"
Requires-Dist: pytest-mock==3.14.0; extra == "dev-pytest"
Requires-Dist: pytest-asyncio==0.25.3; extra == "dev-pytest"
Requires-Dist: async-solipsism==0.7; extra == "dev-pytest"
Provides-Extra: dev
Requires-Dist: frequenz-client-weather[dev-flake8,dev-formatting,dev-mkdocs,dev-mypy,dev-noxfile,dev-pylint,dev-pytest]; extra == "dev"

# Frequenz Weather API Client

[![Build Status](https://github.com/frequenz-floss/frequenz-client-weather-python/actions/workflows/ci.yaml/badge.svg)](https://github.com/frequenz-floss/frequenz-client-weather-python/actions/workflows/ci.yaml)
[![PyPI Package](https://img.shields.io/pypi/v/frequenz-client-weather)](https://pypi.org/project/frequenz-client-weather/)
[![Docs](https://img.shields.io/badge/docs-latest-informational)](https://frequenz-floss.github.io/frequenz-client-weather-python/)

## Introduction

Weather API Client for Python providing access to historical and live weather forecast data.

## Supported Platforms

The following platforms are officially supported (tested):

- **Python:** 3.11
- **Operating System:** Ubuntu Linux 20.04
- **Architectures:** amd64, arm64

## Contributing

If you want to know how to build this project and contribute to it, please
check out the [Contributing Guide](CONTRIBUTING.md).

## Usage

### Installation

```bash
pip install frequenz-client-weather
```

### Initialize the client

The Client can optionally be initialized with keep alive options.

```python
from frequenz.client.weather import Client
from frequenz.client.base.channel import ChannelOptions, KeepAliveOptions, SslOptions
from datetime import timedelta

client = Client(
    service_address,
    channel_defaults=ChannelOptions(
        ssl=SslOptions(
            enabled=False,
        ),
        keep_alive=KeepAliveOptions(
            enabled=True,
            timeout=timedelta(minutes=5),
            interval=timedelta(seconds=20),
        ),
    ),
)
```

### Get historical weather forecast

```python
from datetime import datetime
from frequenz.client.weather._types import ForecastFeature, Location

location = [Location(latitude=46.2276, longitude=15.2137, country_code="DE")]
features = [ForecastFeature.TEMPERATURE_2_METRE, ForecastFeature.V_WIND_COMPONENT_10_METRE]
start = datetime(2024, 1, 1)
end = datetime(2024, 1, 31)

location_forecast_iterator = client.hist_forecast_iterator(
    features=features, locations=locations, start=start, end=end
)

async for forecasts in location_forecast_iterator:
    print(forecasts)
```

### Get live weather forecast

```python
from datetime import datetime
from frequenz.client.weather._types import ForecastFeature, Location

location = [Location(latitude=46.2276, longitude=15.2137, country_code="DE")]
features = [ForecastFeature.TEMPERATURE_2_METRE, ForecastFeature.V_WIND_COMPONENT_10_METRE]

rx = await client.stream_live_forecast(
    locations=[location],
    features=feature_names,
)

while True:
    forecast = await rx.__anext__()
    print(forecasts)
```

## Command Line Interface

The package also provides a command line interface to get weather forecast data.
Use `-h` to see the available options.

### Get historical weather forecast

```bash
weather-cli \
    --url <service-address> \
    --location <latitude,longitude> \       # e.g. "40, 15"
    --feature <feature-name> \              # e.g. TEMPERATURE_2_METRE
    --start <start-datetime> \              # e.g. 2024-03-14
    --end <end-datetime>                    # e.g. 2024-03-15
```

### Get live weather forecast

```bash
weather-cli \
    --url <service-address> \
    --location <latitude,longitude> \       # e.g. "40, 15"
    --feature <feature-name> \              # e.g. TEMPERATURE_2_METRE
```

