Add your description here
Project description
CML Wet-Dry PyTorch
A PyTorch re-implementation and improvement of commercial microwave link (CML) wet-dry detection based on Polz et al. 2020.
๐ฌ Overview
This project provides machine learning tools for rainfall detection and estimation using commercial microwave link (CML) data combined with weather radar observations. Commercial microwave links are telecommunication infrastructure that can be used as opportunistic sensors for precipitation monitoring, offering valuable insights for meteorological applications.
The package implements deep learning approaches to:
- Detect precipitation events (wet/dry classification)
- Estimate rainfall rates from CML signal attenuation
- Process and analyze large meteorological datasets efficiently
โจ Features
- ๐ง Deep Learning Models: Custom CNN architecture for CML time series analysis
- ๐ Efficient Data Processing: Zarr-based dataset handling for large meteorological data
- ๐ง Configurable Training: YAML-based experiment configuration
- ๐ Comprehensive Evaluation: Multiple metrics including accuracy, TPR, TNR, and correlation
- ๐ Production Ready: Inference pipeline for integration in operational deployment
๐ ๏ธ Installation
Requirements
- Python โฅ 3.12
- CUDA-capable GPU (recommended for training)
Install from source
git clone https://github.com/jpolz/cml_wd_pytorch.git
cd cml_wd_pytorch
pip install -e .
Dependencies
The project automatically installs:
- PyTorch
- XArray
- Zarr
- NumPy
- Matplotlib
- NetCDF4
- Einops
- scikit-learn
- TQDM
- PyYAML
๐ Quick Start
1. Configuration
Edit the configuration file to match your data paths:
# src/cml_wd_pytorch/config/config.yml
data:
path_train: "/path/to/training/data.zarr"
path_val: "/path/to/validation/data.zarr"
reflength: 60
training:
batch_size: 100
epochs: 500
learning_rate: 0.0001
2. [WIP] Training a Model
Wet/Dry Classification
from cml_wd_pytorch.train.training_wet_dry import main
# Run training with configuration
main()
Rain Rate Estimation
from cml_wd_pytorch.train.training_rain_rate import main
# Run training with configuration
main()
3. Running Inference
from cml_wd_pytorch.inference.run_inference import cnn_wd
import xarray as xr
# Load your CML data
data = xr.open_dataset("your_cml_data.nc")
# Ensure data is in the expected format
# Example: data should be an xarray DataArray of total loss (TL) with dimensions [time, channel_id, cml_id]
data = data["tl"].transpose("time", "channel_id", "cml_id")
# Run inference using either a model path or a run_id:
# Option 1: Provide the path to a trained model (.pth)
results = cnn_wd("path/to/trained/model.pth", data)
# Option 2: Provide a run_id (will automatically locate model and config in results/{run_id}/)
results = cnn_wd(run_id, data)
# Optionally, you can specify a custom config path:
# results = cnn_wd("path/to/trained/model.pth", data, config_path="path/to/config.yml")
๐ Data Format for training
The package expects data in Zarr format with the following structure:
dataset.zarr/
โโโ sample_number/ # Sample dimension
โโโ channel_id/ # CML channel dimension
โโโ timestep/ # Time dimension
โโโ tl/ # CML signal attenuation [sample_number, channel_id, timestep]
โโโ radar/ # Radar rainfall [sample_number, timestep]
โโโ wet_radar/ # Wet/dry labels [sample_number]
โโโ cml_rain/ # CML-derived rain rates [sample_number, timestep, channel_id]
๐๏ธ Project Structure
cml_wd_pytorch/
โโโ src/cml_wd_pytorch/
โ โโโ models/
โ โ โโโ cnn.py # CNN model architecture
โ โโโ train/
โ โ โโโ training_wet_dry.py # Wet/dry classification training
โ โ โโโ training_rain_rate.py # Rain rate estimation training
โ โโโ dataloader/
โ โ โโโ dataloaderzarr.py # Zarr dataset loader
โ โโโ inference/
โ โ โโโ run_inference.py # Inference pipeline
โ โโโ evaluation/
โ โ โโโ summarize_scores.py # Evaluation utilities
โ โ โโโ summarize_scores_wet_dry.py
โ โโโ config/
โ โโโ config.yml # Configuration file
โโโ preprocessing/
โ โโโ create_dataset.py # Dataset creation pipeline
โ โโโ cml_radklim_to_zarr.py # Data format conversion
โโโ data/
โ โโโ dummy_data.zarr # Example dataset
โ โโโ dummy_model # Example models
โ โโโ gen_dummy_data.py # Dummy data generator
โโโ results/ # Training outputs and models
โโโ pyproject.toml # Project configuration
โโโ environment.yml # Conda environment [outdated]
โโโ LICENSE # BSD 3-Clause License
๐ฏ Model Architecture
The CNN model features:
- Input: 2-channel time series (180 timesteps)
- Convolutional blocks: Multi-layer 1D convolutions with ReLU
- Max pooling: Temporal dimensionality reduction
- Fully connected layers: Dense layers with dropout (40% default)
- Configurable output: Sigmoid (classification) or ReLU (regression)
Default architecture:
- Filters: [48, 96, 96, 192, 192]
- Kernel size: 3
- FC neurons: 128
- Dropout: 0.4
๐ Performance Metrics
The package provides comprehensive evaluation:
Classification Metrics
- Accuracy
- True Positive Rate (TPR)
- True Negative Rate (TNR)
- Binary Cross Entropy (BCE) loss
Regression Metrics
- Mean Squared Error (MSE)
- Root Mean Squared Error (RMSE)
- Pearson correlation coefficient
๐ฌ Scientific Background
This implementation is based on the methodology described in:
Polz, J., et al. (2020). "Rainfall event detection in commercial microwave link attenuation data using convolutional neural networks." Atmospheric Measurement Techniques, 13, 3835โ3853. DOI: 10.5194/amt-13-3835-2020
Commercial microwave links (CMLs) are point-to-point radio connections used in cellular networks. Rain causes signal attenuation that can be exploited for precipitation estimation, making CML networks valuable for meteorological applications.
๐ Examples
Example data and preprocessing scripts are available in the data/ and preprocessing/ directories:
- Data preprocessing workflows
- Model evaluation and analysis tools
- Dummy data generation for testing
๐ค Contributing
Contributions are welcome! Please feel free to submit issues and pull requests.
Development Setup
git clone https://github.com/jpolz/cml_wd_pytorch.git
cd cml_wd_pytorch
pip install -e .[dev]
๐ฅ Contributors
- Julius Polz (@jpolz) - Main Author - Karlsruhe Institute of Technology
- @waggerle - Contributor
- @cchwala - Contributor
๐ License
This project is licensed under the BSD 3-Clause License. See LICENSE for details.
๐ฌ Contact
- Julius Polz - julius.polz@kit.edu
- Karlsruhe Institute of Technology (KIT)
- Institute of Meteorology and Climate Research
๐ Related Publications
If you use this software in your research, please cite:
@article{polz_rain_2020,
title = {Rain event detection in commercial microwave link attenuation data using convolutional neural networks},
volume = {13},
issn = {1867-1381},
doi = {https://doi.org/10.5194/amt-13-3835-2020},
number = {7},
urldate = {2020-12-04},
journal = {Atmospheric Measurement Techniques},
author = {Polz, Julius and Chwala, Christian and Graf, Maximilian and Kunstmann, Harald},
month = jul,
year = {2020},
note = {Publisher: Copernicus GmbH},
pages = {3835--3853},
Project details
Release history Release notifications | RSS feed
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 cml_wd_pytorch-0.1.4.tar.gz.
File metadata
- Download URL: cml_wd_pytorch-0.1.4.tar.gz
- Upload date:
- Size: 5.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d9d65d9ea7279cd14621f01212db5da1bb4647d898cb56d5b7c380be807e27a
|
|
| MD5 |
3d4b8820a0ef0df57c692d652db25d6b
|
|
| BLAKE2b-256 |
c466fe671d6b6c602c45db081acd63e241e6d068925dc5cad8bf8cd04c8ed9a9
|
Provenance
The following attestation bundles were made for cml_wd_pytorch-0.1.4.tar.gz:
Publisher:
cd.yml on jpolz/cml_wd_pytorch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cml_wd_pytorch-0.1.4.tar.gz -
Subject digest:
5d9d65d9ea7279cd14621f01212db5da1bb4647d898cb56d5b7c380be807e27a - Sigstore transparency entry: 380350326
- Sigstore integration time:
-
Permalink:
jpolz/cml_wd_pytorch@ee30a597e64d1762bdb92b4d1ec281059d6228cf -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/jpolz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@ee30a597e64d1762bdb92b4d1ec281059d6228cf -
Trigger Event:
release
-
Statement type:
File details
Details for the file cml_wd_pytorch-0.1.4-py3-none-any.whl.
File metadata
- Download URL: cml_wd_pytorch-0.1.4-py3-none-any.whl
- Upload date:
- Size: 22.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
58fd3887733019fc33346b5f391408a4de188aa278ec8e0e1c6d7ca2fa5457c1
|
|
| MD5 |
1c18b9febf9373f87d9e58e74d00b11a
|
|
| BLAKE2b-256 |
f90a9fc6c5af2f4e307dc692cbbc8ef5bb638faece5406dee398ed6ed1ca2987
|
Provenance
The following attestation bundles were made for cml_wd_pytorch-0.1.4-py3-none-any.whl:
Publisher:
cd.yml on jpolz/cml_wd_pytorch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cml_wd_pytorch-0.1.4-py3-none-any.whl -
Subject digest:
58fd3887733019fc33346b5f391408a4de188aa278ec8e0e1c6d7ca2fa5457c1 - Sigstore transparency entry: 380350364
- Sigstore integration time:
-
Permalink:
jpolz/cml_wd_pytorch@ee30a597e64d1762bdb92b4d1ec281059d6228cf -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/jpolz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@ee30a597e64d1762bdb92b4d1ec281059d6228cf -
Trigger Event:
release
-
Statement type: