Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Quantitative Precipitation Estimation Model

Project Pythia Logo

Quantitative Precipitation Estimation Model

This notebook builds and trains a flexible MLP regression model for radar-based quantitative precipitation estimation. It introduces a reusable FlexMLP class with configurable activations and bundled defaults (Adam, MSE, ReduceLROnPlateau) for easy reuse. Training uses T-matrix estimated C‑band radar parameters from ARM ldquants product during Feb 01 2025 to Mar 06 2025 with early stopping. Validation and inference load the saved weights to predict on the VDISQuants dataset from Nov 20 2024 to Feb 08 2025, rescale targets, and compare against rain_rate. Because training spans only a few months, adding more historical data should improve heavy-rain performance.

Prerequisites

ConceptsImportanceNotes
Multilayer PerceptronNecessaryConcept of the MLP and ANN
Polarimetric Radar DataNecessaryKDP, ZDR, and Reflectvity factor
Disdrometer DataHelpfulFamiliarity with DSD based estimation of radar parameters
  • Time to learn: 60 min.

  • System requirements: Use following environment.yml to create the environment for this notebook.

name: torch_env
channels:
  - pytorch
  - conda-forge
dependencies:
  - python=3.10
  - pytorch
  - numpy
  - pandas
  - matplotlib
  - netcdf4
  - xarray
  - dask
  - h5netcdf
  - ipykernel
  - scikit-learn

conda env create -f environment.yml

Building a Flexible MLP for Regression

Set up PyTorch, NumPy, data utilities, and netCDF reader. import xarray as xr

FlexMLP

Flexible MLP with internal activation resolution and built-in optimizer/loss/scheduler defaults (Adam + MSE + ReduceLROnPlateau). Provide activation as a class or a string such as ‘ReLU’/‘relu’.

Load ldquants data

Read C-band radar variables, filter by Zh/ZDR/Kdp thresholds to avoid very low values, standardize, and build DataLoaders.

Instantiate model for ldquants

Build the MLP and initialize its optimizer/loss/scheduler using default names.

Using device: mps

Train and validate

Run epochs with early stopping, using the model-owned optimizer/loss/scheduler.

Epoch 01 | Train Loss: 0.4880 | Val Loss: 1.4439
Epoch 02 | Train Loss: 0.3501 | Val Loss: 0.1299
Epoch 03 | Train Loss: 0.2805 | Val Loss: 0.1436
Epoch 04 | Train Loss: 0.2441 | Val Loss: 0.1181
Epoch 05 | Train Loss: 0.2341 | Val Loss: 0.9753
Epoch 06 | Train Loss: 0.2325 | Val Loss: 0.3878
Epoch 07 | Train Loss: 0.2040 | Val Loss: 0.1040
Epoch 08 | Train Loss: 0.1712 | Val Loss: 0.1469
Epoch 09 | Train Loss: 0.1551 | Val Loss: 0.1380
Epoch 10 | Train Loss: 0.1420 | Val Loss: 0.5140
Epoch 11 | Train Loss: 0.1150 | Val Loss: 0.1221
Epoch 12 | Train Loss: 0.1186 | Val Loss: 0.2025
Early stopping triggered.

Saving only the model weights

We store just the state_dict (mlp_radar_qpe_weights.pt) instead of the full object. This avoids unpickling issues across PyTorch versions and devices; later we recreate the model and load these weights for inference.

Predict on VDISQuants data using saved model

Load the trained weights, run inference on the VDISQuants dataset, and invert the target scaling.

Using device: mps
MAE: 0.421 | RMSE: 1.443 | R^2: 0.940
<Figure size 1200x500 with 2 Axes>

Note: This notebook trained on only a couple of months of data. With more historical files, the model should generalize better and improve prediction quality for heavy rainfall.