.streamlit Loading last commit info...
app
assets
test
.dockerignore
.gitignore
Dockerfile
LICENSE
README.md
docker-compose.yaml
main.py
mqtt_process.py
pytest.ini
requirements.txt
run.sh
README.md

🌦️ Weather data visualizer

wakatime

A web application for visualizing weather data from multiple sources with customizable parameters.

See demo here.

✨ Features

Visualization Options

  • Metrics:
    • 🌡️ Average/Min/Max temperature
    • 🌧️ Precipitation
    • ❄️ Snow height
  • Parameters:
    • 📅 Date range
    • 📍 Station selection
    • 🔍 Data smoothing

Data Sources

  • CHMI (Czech Hydrometeorological Institute) ❗❗SEE THIS❗❗
  • AERIS (French meteorological data) (Météo-France)
  • OpenWeatherMap (Weather data API)
  • Custom Data Input:
    • 📡 MQTT/Mosquitto broker integration
    • 📄 CSV file upload (single temperature datapoint per datetime only)

Available Pages

PageDescription
VisualizeView data from automatic imports (AERIS/CHMI)
OpenWeatherMapView Forecast from OpenWeatherMap API
(API Key needed)
Visualize MQTTView data from MQTT streams
CompareCompare data from different sources
AggregateShow combined metrics across stations
Precipitation/SnowSpecialized precipitation views

Admin Features (when logged in under admin email)

  • Import - Add data from sources or CSV
  • Delete - Remove station data

Dependencies

If you want to use docker, you need to install it.
Otherwise, you need to install the following dependencies:

  • Python and pip and install the requirements from requirements.txt:
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

Usage

Configuration

  • Configure .streamlit/secrets.template.toml -> rename to secrets.toml.
  • MQTT: Configure app/mosquitto_handler/config_template.py -> rename to config.py.
  • For production: Use reverse proxy (nginx/traefik recommended) for https.

Docker

  • Run:
docker-compose up
  • Open the browser and go to http://localhost:8502/.

Without Docker

  • You need to change credentials in app/db_config.py to your own database, app is tested with PostgreSQL.

  • Run:

./run.sh

Tests

  • If you have a database running, you can run the tests with:
  • You may have to change the database connection in app/db_config.py to your own database.
  • One test will fail. To pass it, see this.
pytest
  • In the opposite case, you can run the tests with:
pytest -v -m "not real_database_connection"

PIP8

Code is written in accordance with a PEP8 style guide, without C0301 (line length) and C0103 (variable name) checks.

  • You can check the code with:
pylint --disable=C0301,C0103 -sn app main.py mqtt_process.py

Exceptions

FileExceptionReason
app/mosquitto_handler/connection.py:56unexpected-keyword-argPylint doesnt see the correct constructor.
app/mosquitto_handler/connection.py:56no-memberPylint doesnt see the correct constructor.
app/importer/import_data_openweather.py:74too-many-instance-attributesNo way of making this smaller without losing readability
app/importer/import_data_openweather.py:123too-many-localsWe need all these variables, making class would be less readable.
app/streamlit_pages/aggregate.py:22-27R0801Making one function for everything would lose readability.
app/streamlit_pages/town_visualize.py:20too-many-localsWe need all these variables, making class would be less readable.
app/streamlit_pages/town_visualize.py:27-38R0801Making one function for everything would lose readability.
app/streamlit_pages/town_visualize.py:72too-many-arguments, too-many-positional-argumentsWe need all these variables, making class would be less readable.
app/streamlit_pages/town_visualize.py:93R0801No need making a function when its just a graph config of few lines used on two places.

CHMI discontinued source

CHMI discontinued this service and is now offering a new one here.
The import process is not compatible with this.

Fortunately, I have all the files saved. You can get them here. All you need to do now is create data/downloaded directories in the project root and paste the unzipped files there. Then you can click the import button and it should import successfully.
When using docker, you need to remove the data directory from .dockerignore and rebuild.

Screenshots

Main Page

Main

Visualization

Visualize

Visualization

OpenWeatherMap

OpenWeatherMap

Visualize MQTT

Visualization MQTT

Compare

Compare

Aggregate

Aggregate

Precipitation/Snow

Precipitation/Snow

Import

Import

Attributions

Rain icons created by KP Arts - Flaticon

Please wait...
Connection lost or session expired, reload to recover
Page is in error, reload to recover