Python client for the Ghana Flood Warning System API
Project description
ghana-flood-predictor
Python client for the Accra Flood Warning System — predict flood risk from hourly weather data.
Installation
pip install ghana-flood-predictor
Quick Start
from ghana_flood_predictor import FloodClient
client = FloodClient()
# Option 1 — one-liner using historical data
result = client.predict_from_datetime("2023-06-15T14:00:00")
print(f"Flood probability: {result['probability']:.1%}")
print(f"Flood warning: {result['flood_warning']}")
# Option 2 — supply your own weather data
meta = client.metadata()
seq_len = meta["seq_len"]
sequence = [
{
"rainfall": 12.5,
"temperature": 28.0,
"humidity": 85.0,
"wind_speed": 3.2,
"hour": 14,
"month": 6,
}
for _ in range(seq_len)
]
result = client.predict(sequence)
print(f"Flood probability: {result['probability']:.1%}")
print(f"Flood warning: {result['flood_warning']}")
Methods
client.metadata()
Returns model info including seq_len, threshold, and latest_datetime.
client.weather(target_datetime, hours=None)
Fetch historical weather sequence ending at target_datetime.
data = client.weather("2023-06-15T14:00:00")
# data["sequence"] → list of hourly weather dicts
client.predict(sequence, horizon_hours=1)
Predict flood risk from hourly weather sequence.
Each item in sequence:
| Field | Type | Description |
|---|---|---|
rainfall |
float | Rainfall in mm |
temperature |
float | Temperature in °C |
humidity |
float | Humidity in % |
wind_speed |
float | Wind speed in m/s |
hour |
int | Hour of day (0–23) |
month |
int | Month (1–12) |
Returns:
| Field | Type | Description |
|---|---|---|
probability |
float | Flood probability (0–1) |
flood_warning |
bool | True if flood predicted |
threshold_used |
float | Decision threshold |
horizon_hours |
float | Forecast horizon |
client.predict_from_datetime(target_datetime, horizon_hours=1)
Convenience method — fetches weather history and predicts in one call.
result = client.predict_from_datetime("2023-06-15T14:00:00")
print(result["probability"]) # 0.87
print(result["flood_warning"]) # True
Full Example
from ghana_flood_predictor import FloodClient
client = FloodClient()
# Check model info
meta = client.metadata()
print(f"Sequence length needed: {meta['seq_len']} hours")
print(f"Alert threshold: {meta['threshold']}")
# Predict using historical data
result = client.predict_from_datetime("2023-06-15T14:00:00")
print(f"Probability : {result['probability']:.1%}")
print(f"Flood warning: {result['flood_warning']}")
License
MIT
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ghana_flood_predictor-0.2.0.tar.gz.
File metadata
- Download URL: ghana_flood_predictor-0.2.0.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
83e69b194df61359e00836e8b83637d627970e755da9d2068883d56fcc2f5be1
|
|
| MD5 |
9a754e8ff04dacc4f012829f23be5d8b
|
|
| BLAKE2b-256 |
f513c1f3ad9a5da2b978a997d1e5054bd02b6e3ac48322093351896cd5f093f6
|
File details
Details for the file ghana_flood_predictor-0.2.0-py3-none-any.whl.
File metadata
- Download URL: ghana_flood_predictor-0.2.0-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cb542a8c5ba62e8a510c21d07ed6dd938db080cac697823ca6a29b686a9b0f30
|
|
| MD5 |
d5b0aa888b5a73d0ef7520315cc3b601
|
|
| BLAKE2b-256 |
3b1418fdad83d76a8631f96e3d603bd5cfcff732a15cfe425457977a79fb3797
|