Skip to content

paul-florentin-charles/bcn-rainfall-core

Repository files navigation

bcn-rainfall-core

PyPI version License: MIT coverage badge Ruff uv mypy

Tools to load and manipulate rainfall data from the city of Barcelona, Catalunya; it is the core of the Barcelona Rainfall project and is exposed through the Barcelona Rainfall API.

Requirements

  • Python 3.12
  • Pip

Usage

from bcn_rainfall_core import Rainfall
from bcn_rainfall_core.utils import DataSettings

# With configuration file in default path `config.yml`
rainfall = Rainfall.from_config()

# With configuration file in other path
rainfall_with_path = Rainfall.from_config(path="new/path/to/config.yml")

# With your own configuration
rainfall_with_cfg = Rainfall.from_config(
    cfg=DataSettings(file_url="http://...", start_year=1955, rainfall_precision=2)
)

# With your own configuration from local file
rainfall_with_cfg_from_file = Rainfall.from_config(
    cfg=DataSettings(local_file_path="/dir/my_rainfall_data.csv", start_year=1955, rainfall_precision=2),
    from_file=True,
)


# Have fun with class!
from bcn_rainfall_core.utils import TimeMode, Season

rainfall_avg = rainfall.get_rainfall_average(
    TimeMode.SEASONAL,
    begin_year=1975, 
    end_year=1998, 
    season=Season.WINTER
)
print(rainfall_avg)
...

Tests & Coverage

uv run coverage run -m pytest
uv run coverage report

Code quality

uv tool run mypy --check-untyped-defs .
uv tool run ruff check
uv tool run ruff format

About

Tools to load and manipulate rainfall data from the city of Barcelona, Catalunya; it is the core of the Barcelona Rainfall project and is exposed through the Barcelona Rainfall API.

Topics

Resources

License

Stars

1 star

Watchers

1 watching

Forks

Packages

 
 
 

Contributors

Languages