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.

Spectral Preprocessing for Machine Learning: Forecasting Subseasonal Zonal Wind from OLR

Authors
Affiliations
University at Albany (SUNY)
Florida Institute of Technology
University at Albany (SUNY)
Texas A&M University
University at Albany (SUNY)
Duke University
University of Georgia
University at Albany (SUNY)

Overview

Spectral preprocessing can shape what a machine-learning model learns from geophysical fields. This notebook applies a simple neural network (NN) to predict 850-hPa zonal wind near Nairobi, Kenya from outgoing longwave radiation (OLR) Lee & others, 2014 over the Indian Ocean, using a 14-day lead time.

The planned workflow is:

  1. Load and preprocess OLR and zonal-wind fields.

  2. Align predictors and predictand in time and inspect their power spectra.

  3. Apply a Fourier bandpass filter to isolate intraseasonal variability.

  4. Train and evaluate NN models on raw and bandpass-filtered OLR, with and without removing the seasonal cycle.

The goal is to compare how spectral filtering and anomaly calculation affect predictive skill, not to build a production forecast system.

Prerequisites

ConceptsImportanceNotes
Fourier Power Spectrum and Spectral FilteringNecessaryBandpass filtering in the frequency domain
Remove the seasonal cycle using harmonic regressionHelpfulHarmonic anomaly approach (in progress below)
Removing the Seasonal Cycle: Daily Climatology vs. Harmonic RegressionHelpfulDaily-climatology anomalies used in the current workflow
Mapping Modes of Variability: Regressing Fields onto a Pair of Indices (MJO/RMM Example)HelpfulOLR preprocessing context for tropical variability
  • Time to learn: TBD (notebook under construction)

  • System requirements: TensorFlow and scikit-learn (see Imports below)


Imports

Visualization, array, and cloud I/O libraries match other application notebooks in this cookbook. TensorFlow/Keras and scikit-learn support the simple feed-forward NN and feature scaling.

WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
I0000 00:00:1791951476.171722    4666 port.cc:153] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
I0000 00:00:1791951476.199888    4666 cpu_feature_guard.cc:227] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX512F AVX512_VNNI AVX512_BF16 AVX_VNNI, in other operations, rebuild TensorFlow with the appropriate compiler flags.

Set Up

Experiment parameters define the analysis window, a chronological train/test split, the predictor–predictand lead time, and the target location near Nairobi.

Data Acquisition

We combine several gridded reanalysis products: OLR and zonal wind are loaded from the public Pythia Zarr stores on Jetstream2; 2-meter temperature from GDEX is planned but not yet wired in.

2-Meter Temperature (planned)

Hourly 2-meter temperature from ERA5 (GDEX Zarr) will be resampled to daily means at Nairobi. The loading cells below are commented out pending integration.

Outgoing Longwave Radiation

Daily mean OLR comes from the NCEP–NCAR Reanalysis Zarr store on the Pythia Jetstream2 bucket.

Loading...

Interpolation

Missing values along time are filled with linear interpolation before the fields are aligned with the wind target.

Zonal Wind

Daily 850-hPa zonal wind is read from the preprocessed NCEP–NCAR Zarr dataset used elsewhere in this cookbook.

Loading...

Interpolation

As for OLR, gaps along time are filled with linear interpolation.

Loading...

Target Definition

The predictand is 850-hPa zonal wind at the grid point nearest Nairobi (NAIROBI_COORDS).

Alignment

Predictor and predictand are floored to daily timestamps, OLR is shifted back by the lead time, and the two datasets are aligned on their common time index.

Loading...

Spectral Analysis

Before filtering the full OLR field, we inspect the power spectrum of the Nairobi zonal-wind time series and mark common periodicities (annual harmonics and the 14-day lead time).

/tmp/ipykernel_4666/159285440.py:22: RuntimeWarning: divide by zero encountered in divide
  periods = 1 / freqs
<Figure size 640x480 with 1 Axes>
/tmp/ipykernel_4666/987448014.py:21: RuntimeWarning: divide by zero encountered in divide
  periods = np.where(freqs != 0, 1 / np.abs(freqs), np.inf)
/tmp/ipykernel_4666/159285440.py:22: RuntimeWarning: divide by zero encountered in divide
  periods = 1 / freqs
<Figure size 640x480 with 1 Axes>

Filtering

A Fourier bandpass filter (20–90 days) is applied to the gridded OLR field in parallel with Dask, isolating intraseasonal variability relevant to the MJO band Zhang, 2013.

/tmp/ipykernel_4666/1914965674.py:33: RuntimeWarning: divide by zero encountered in divide
  periods = np.where(freqs != 0, 1 / np.abs(freqs), np.inf)
/tmp/ipykernel_4666/159285440.py:22: RuntimeWarning: divide by zero encountered in divide
  periods = 1 / freqs
<Figure size 640x480 with 1 Axes>

Unfiltered Model

A simple feed-forward NN is trained on the full OLR field (after removing the seasonal cycle with a daily climatology computed from the training period).

Train-Test Split

Predictor and predictand are split chronologically: 1981–2010 for training and 2011–2024 for testing.

Shape of predictor (X): (16788, 25, 144)
Shape of target (y): (16788,)

Anomaly Calculation

Harmonic approach (planned)

The cells below sketch harmonic-regression anomalies following Remove the seasonal cycle using harmonic regression. This path is not yet connected to the model training cells.

Standard Climatology Approach

Daily climatology is computed from the training period only and subtracted from both training and test predictors to avoid leakage.

Reshaping and Scaling

Spatial dimensions are flattened and features are standardized with StandardScaler fit on the training set.

Flattened X_train shape: (10957, 3600)
Flattened y_train shape: (10957,)

Modelling

A two-hidden-layer NN (ReLU activations) is trained with mean absolute error as the loss function.

Loading...
Loading...
Loading...
Loading...
Loading...
Starting training...
Test MAE: 1.4968

Analysis

Training and validation loss curves, test-set MAE, and a scatter plot of predicted versus observed zonal wind summarize model performance.

<Figure size 800x500 with 1 Axes>
  1/160 ━━━━━━━━━━━━━━━━━━━━ 3s 20ms/step
140/160 ━━━━━━━━━━━━━━━━━━━━ 0s 361us/step
160/160 ━━━━━━━━━━━━━━━━━━━━ 0s 503us/step
<Figure size 600x600 with 1 Axes>

Filtered Model

The same NN architecture and preprocessing steps are repeated using bandpass-filtered OLR as the predictor, allowing a direct comparison with the unfiltered case.

Train-Test Split

Predictor and predictand are split chronologically: 1981–2010 for training and 2011–2024 for testing.

Shape of predictor (X): (16788, 25, 144)
Shape of target (y): (16788,)

Standard Climatology Approach

Daily climatology is computed from the training period only and subtracted from both training and test predictors to avoid leakage.

Reshaping and Scaling

Spatial dimensions are flattened and features are standardized with StandardScaler fit on the training set.

Flattened X_train shape: (10957, 3600)
Flattened y_train shape: (10957,)

Modelling

A two-hidden-layer NN (ReLU activations) is trained with mean absolute error as the loss function.

Loading...
Loading...
Loading...
Loading...
Loading...
Starting training...
Test MAE: 1.4414

Analysis

Training and validation loss curves, test-set MAE, and a scatter plot of predicted versus observed zonal wind summarize model performance.

<Figure size 800x500 with 1 Axes>
  1/160 ━━━━━━━━━━━━━━━━━━━━ 2s 18ms/step
160/160 ━━━━━━━━━━━━━━━━━━━━ 0s 355us/step
<Figure size 600x600 with 1 Axes>

Summary

This notebook connects spectral preprocessing to a simple machine-learning forecast of local zonal wind from large-scale OLR. The full comparison between unfiltered and bandpass-filtered predictors, and between climatological and harmonic anomalies, is still being completed.

What’s next?

When this chapter is finished, readers will be able to judge whether intraseasonal filtering improves NN skill for this lead time and location.

Until then, see Mapping Modes of Variability: Regressing Fields onto a Pair of Indices (MJO/RMM Example) for a complete OLR-based diagnostic workflow.

References
  1. Lee, H.-T., & others. (2014). NOAA climate data record (CDR) of daily outgoing longwave radiation (OLR), version 1.2. (No Title).
  2. Zhang, C. (2013). Madden–Julian oscillation: Bridging weather and climate. Bulletin of the American Meteorological Society, 94(12), 1849–1870.