Tags: climate-data, etl, locations, python, geoserver, historical, orm, data-processing
Python package for processing historical climate data for locations with a complete ETL pipeline that includes:
- Data extraction from GeoServer, CSV files, or database
- Monthly aggregation and climatology calculations
- ORM integration for database operations
- Structured logging and OpenTelemetry monitoring
Key Features:
- Automated processing of temperature, precipitation, and solar radiation data
- Flexible configuration for multiple countries and locations
- End-to-end pipeline from raw data to database
- Database-backed configuration management
- Multiple data sources: GeoServer or CSV import
For complete documentation, visit the Project Wiki
- Modular ETL pipeline for climate data
- Integration with
aclimate_v3_ormfor database operations - Typed schemas for all data
- OpenTelemetry monitoring (SigNoz ready)
- CI/CD pipeline (GitHub Actions)
- Structured logging for debugging and monitoring
- Flexible configuration via environment and .env files
- Python >= 3.10
- GeoServer
- PostgreSQL database for configuration storage
- Dependencies: see
pyproject.tomlorrequirements.txt
pip install git+https://github.com/CIAT-DAPA/aclimate_v3_orm
pip install git+https://github.com/CIAT-DAPA/aclimate_v3_historical_location_etl.gitTo install a specific version:
pip install git+https://github.com/CIAT-DAPA/aclimate_v3_historical_location_etl.git@v0.1.0For development (editable mode):
pip install -e .[dev]requirements.txt(all dependencies)pyproject.toml(project metadata and dependencies)dev.py(utility script for setup, test, build, etc.).env.example(example environment variables)
You can configure the ETL by creating a .env file or setting environment variables:
GEOSERVER_URL=http://localhost:8080/geoserver/rest/
GEOSERVER_USER=admin
GEOSERVER_PASSWORD=admin
ENABLE_SIGNOZ=false
OTLP_ENDPOINT=localhost:4317
LOG_FILE_PATH=application.log
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/databaseNote
Options:
GEOSERVER_URL: Geoserver URLGEOSERVER_USER: Geoserver userGEOSERVER_PASSWORD: Geoserver passwordOTLP_ENDPOINT: Signoz endpoint to send logsENABLE_SIGNOZ: Flag to send logs to signozLOG_FILE_PATH: Path to save logsDATABASE_URL: Connection string to database
python -m aclimate_v3_historical_location_etl.aclimate_run_etl \
--country HONDURAS \
--start_date 2025-04 \
--end_date 2025-04 \
--all_locations \
--source geoserver# Path to directory containing multiple CSV files (tmax_daily_data.csv, tmin_daily_data.csv, etc.)
python -m aclimate_v3_historical_location_etl.aclimate_run_etl \
--country HONDURAS \
--start_date 2025-04 \
--end_date 2025-04 \
--all_locations \
--source csv \
--csv_path /path/to/csv_directory/
# Or path to a single CSV file
python -m aclimate_v3_historical_location_etl.aclimate_run_etl \
--country HONDURAS \
--start_date 2025-04 \
--end_date 2025-04 \
--all_locations \
--source csv \
--csv_path /path/to/single_file.csv# GeoServer mode
python -m aclimate_v3_historical_location_etl.aclimate_run_etl \
--country HONDURAS \
--start_date 2025-04 \
--end_date 2025-04 \
--location_ids 1,2,3,4 \
--source geoserver
# CSV mode (directory with multiple variable CSVs)
python -m aclimate_v3_historical_location_etl.aclimate_run_etl \
--country HONDURAS \
--start_date 2025-04 \
--end_date 2025-04 \
--location_ids 1,2,3,4 \
--source csv \
--csv_path /path/to/csv_directory/Note
Options:
--source: Data source (geoserverorcsv, default:geoserver)--csv_path: Path to CSV file (required when--source csv)--location_ids: Comma-separated list of location IDs--all_locations: Process all locations (from database for geoserver, from CSV for csv)--climatology: Calculate monthly climatology
[!IMPORTANT] > Location Selection Behavior:
- GeoServer mode with
--all_locations: Processes all locations from database- CSV mode with
--all_locations: Processes all locations found in the CSV file- CSV mode with
--location_ids: Validates IDs exist in database, then filters CSV dataCSV Format: Files should be named
(variable)_daily_data.csv(e.g.,tmax_daily_data.csv,prec_daily_data.csv) with columns:ext_id(orid),day,month,year,value. Uses PyArrow engine for fast reading.
from aclimate_v3_historical_location_etl.aclimate_run_etl import main as run_etl_pipeline
run_etl_pipeline()# Install test requirements
pip install pytest pytest-mock
# Run tests
pytest tests/Our GitHub Actions pipeline implements a three-stage deployment process:
Code Push β Test Stage β Merge Stage β Release Stage- Linting with flake8
- Formatting with black
- Type checking with mypy
- Tests with pytest + coverage
- Upload to Codecov
- Auto-merges
stageβmainafter successful tests
- Creates versioned release and uploads artifacts
aclimate_v3_historical_location_etl/
β
βββ .github/
β βββ workflows/
βββ src/
β βββ aclimate_v3_historical_location_etl/
β βββ climate_processing/
β β βββ climatology_calculator.py
β β βββ data_aggregator.py
β βββ data_managment/
β β βββ csv_client.py # NEW: CSV import functionality
β β βββ data_validator.py
β β βββ database_manager.py
β β βββ geoserver_client.py
β βββ tools/
β β βββ logging_manager.py
β β βββ tools.py
β βββ aclimate_run_etl.py
β βββ __init__.py
βββ tests/
βββ requirements.txt
βββ pyproject.toml
βββ dev.py
βββ .env.example
βββ README.md