polar-cap-saturation

Demonstrating Regression to the Mean of Extreme Geomagnetic Storms

This repository contains code that is associated with the paper titled “Regression to the Mean can Explain Saturation of Geomagnetic Storms”. The paper is published in Nature.

Last updated on 19 Jan 2026

View the Code

Four of the main codes used to calculate all the results in the paper are available as .html files, so that the logic and results can be followed by anyone without having to use MATLAB or Python.

Code used for the different results presented in the paper

  1. Code 1: Monte Carlo Simulation of the Solar Wind Error Model. Here, we solve the solar wind driver error model using a Monte Carlo simulation, compare and validate the model results with data, and also correct the data using ‘regression calibration’ to reveal that the geomagnetic response to solar wind driving is linear.
  2. Code 2: Analytical derivation of non-linear bias from uncertainty in time. Here, we use the analytical formula for regression bias stemming from uncertainty in the time of the measurement of a stochastic process, derived in the paper. It is in the form of an integral; hence, in the code, we numerically integrate the formula to show the non-linear regression bias it creates. Furthermore, we validate this analytical solution independently by creating an error model of time uncertainty and using a Monte Carlo simulation to solve it. The analytical and Monte Carlo solutions match very well, confirming that the analytical derivation is correct.
  3. Code 3: Calculating the magnitude uncertainty. Here, we use data from simultaneous magnetosheath satellite measurements and spacecraft at L1 to calculate the variance of the L1 solar wind driver estimates for a given value of the same driver close to the magnetopause subsolar point. The resulting variance is the magnitude uncertainty used in Code 1, as part of the error model. This magnitude uncertainty varies with the strength of the shocked solar wind driver, and hence is a heteroskedastic error, unlike what is normally assumed.
  4. Code 4: Regression to the mean. Here, we demonstrate that regression to the mean is a fundamental property of the relation between measurement and the true value corresponding to it. We also show how linear regression bias and non-linear regression bias are created due to this property. Part of this code was first published by Sivadas & Sibeck, 2022.
  5. Code 5: Increasing trend of the saturation limit with year of study. Here, we show that previous polar cap potential saturation studies and their saturation limits follow an increasing trend with the year of their publication.
  6. Code 6: Sensitivity analysis of magnitude uncertainty. Here, we show that the saturation effect increases with increasing value of the minimum magnitude uncertainty.

Run the Code

If you wish to run the MATLAB and Python Code,

The Data files used by the code are stored in this zenodo repository, and can be downloaded from there.

For running Code 1: Monte Carlo Simulation of the Solar Wind Error Model and Code 6: Sensitivity analysis of magnitude uncertainty

  1. Download Data.zip from Zenodo-record and unzip into this gitrepo on your local machine, and point MATLAB Code 1 variable DataDir to a corresponding folder in the gitrepo: Data. Example DataDir = ~\polar-cap-saturation\Data\';

For running Code 3: Calculating the magnitude uncertainty

  1. The data used for this script is the minimal necessary data to reproduce the uncertainty calculations. This is available within Data.zip folder in the Zenodo-record. Once unzipped into the local machine, replace ‘/data/’ with the location of the unzipped Data.zip folder. The python notebook Code3_Calculating_magnitude_uncertainty.ipynb uses this folder for its input data. So the code should be able to access this folder in lieu of /data/. The result of this script, is ultimately saved as bayanne_uncertainty_stats.mat in the Data.zip directory, for use as input for Code 1. As a result, all the other codes can be run independently of Code 3.

Code 2, Code 4 and Code 5: Increasing trend of the saturation limit with year of study do not require any data files to run.

If there are any issues running the code, you can contact me at nithinsivadas90@gmail.com