A skillful and interpretable seasonal forecasting approach by combining deep learning and model-analog forecasting. This technique, called optimized model-analog, leverages U-Net to identify important areas for selecting analog members.
This repository contains the code for the paper titled "Using Deep Learning to Identify Initial Error Sensitivity for Interpretable ENSO Forecasts" by Toride et al. A preprint is available at https://arxiv.org/abs/2404.15419.
The figure below illustrates the concept of this approach. Subpanel (a) shows a sample condition we aim to forecast. In subpanel (b), without the use of machine learning, some analogs may evolve into the opposite phase of ENSO. Subpanel (c) demonstrates that with this approach, the ensemble forecasts of the El Niño event are significantly improved.
The U-Net predicts weights for the corresponding input variables. These weights highlight sensitive (important) regions for target growth. The predicted weights determine the weighted initial distances for every sample within the library. The top 2% of samples (dark blue circles) are then used to calculate the loss function. This loss function updates the U-Net parameters so that samples with smaller forecast errors have smaller weighted initial distances (indicated by dark blue arrows in the scatter plot).
To set up the environment, run the following command:
conda env create -f condaenv.yml
To use the plotting modules in plot
, a seperate environment needs to be installed. This environment includes proplot.
conda env create -f plotenv.yml
Download the required data and place it in the data
directory. The data can be found at https://doi.org/10.5281/zenodo.11048404.
The data/cesm2
directory contains the Community Earth System Model Version 2 Large Ensemble (CESM2-LE), while the data/real
directory contains the Ocean Reanalysis System 5 (ORAS5) datasets. These datasets have been processed to provide detrended monthly anomalies and have been interpolated to two different resolutions: 2° × 2° and 5° × 5°. The 5°×5° files are used as input, while the 2°×2° files are used for analog forecasting.
├── cesm2
│ ├── sst_anomaly_5x5.nc
│ ├── ssh_anomaly_5x5.nc
│ ├── sst_anomaly_2x2.nc
│ ├── ssh_anomaly_2x2.nc
│ ...
│
└── real
├── sst_anomaly_5x5.nc
...
Navigate to the DLMA
directory to find the .ipynb
files for running the model. By default, the model runs from an initialization in January with a single ensemble.
-
Calculate all combinations of distances between samples over the target region and variable
0-1_target_distance.ipynb
: Calculate the distances0-2_target_distance_shadow.ipynb
: Calculate averaged target distances over mutiple lags0-3_target_distance_real.ipynb
: For a reanalysis dataset
-
Train
1_train.ipynb
: Train the model
-
Test
2-1_test.ipynb
: Generate model analog indices and weights2-2_eval_stat.ipynb
: Evaluates forecast skill
-
Test using a reanalysis dataset
3-1_test.ipynb
: Test the model using reanalysis dataset3-2_eval_stat.ipynb
: Evaluate forecast skill using reanalysis dataset
For comparison, the traditional model-analog forecasting method is provided in the MA
directory. In addition, an equivalent deep learning only approach is provided in the DL_only
directory.
Navigate to the MA
directory for the traditional model-analog forecasting.
1_MA.ipynb
: Find model-analog indices2_MA_stats.ipynb
: Evaluates forecast skill3_MA_real.ipynb
: Find model-analog indices using reanalysis dataset4_MA_real_stats.ipynb
: Evaluate forecast skill using reanalysis dataset
Navigate to the DL_only
directory for the deep learning only approach.
1_train.ipynb
: Train the ML only model2_test.ipynb
: Test the ML only model
Navigate to the plot
directory and use the plotting environment.
skill.ipynb
: Plot skill.
weight
: Plot weights estimated by DLMA. These weights show important regions for selecting analogs.