Abai-Mag is a small collection of Python scripts for training a neural network to predict magnetopause location. It learns from magnetopause crossing data and solar wind parameters (taken from the OMNI database). The resulting model can be used to predict the radial distance or 3‑D location of the magnetopause from simple input parameters.
Abai-Mag provides a novel take on magnetopause modeling in reference to solar wind interactions. Most models reference theories, formulas, and assumptions of solar wind interaction and how they affect magnetopause behavior. Abai-mag has no presupposed formulas, rather the model uses a large dataset and neural networks to test theories. Does this model match or disprove current magnetopause assumptions?
The project demonstrates my process in designing a modular, maintainable pipeline where data processing, experimentation, and visualization are clearly separated and reproducible.
Abai-Mag serves as a foundation for building research prototypes that can realistically evolve into production-ready systems.
- Clone this repository.
- Create a Python 3.10 environment and install the required packages:
pip install numpy pandas matplotlib seaborn scikit-learn tensorflow joblib
- Place
omni_data.h5(OMNI solar wind data in HDF5 format) in the project directory. The training and prediction scripts expect this file to be available when callingmakedata.
- Visit https://omniweb.gsfc.nasa.gov/ and open the OMNIWeb Data Explorer.
- Select the High Resolution OMNI 1-Minute dataset.
- Set the output format to HDF5 and submit the request.
- Save the resulting file as
omni_data.h5in the repository root.
Along with the OMNI file, you will need a CSV of magnetopause crossings. Its
location is configured in model2.py via the mag_data_path variable. The
makedata helper combines the crossing data with values from omni_data.h5 to
produce the training set used by the neural network.
The repository does not include the crossing data used for training. Magnetometer observations from missions such as THEMIS, Cluster or MMS can be downloaded from NASA CDAWeb. Compile a CSV with the columns expected by model2.py and set mag_data_path to its location or use other data with columns expected by model2.py.
Edit model2.py and set mag_data_path to the path of your magnetopause crossing CSV file. Then run
python model2.pyThis trains the neural network and saves the model as my_model2.keras together with the input and output scalers (input_xscaler.pkl and input_yscaler.pkl).
To obtain predictions for new input values you can use the helper in predict.py:
from predict import abaimp
# example values (lat, lon, bz, pdyn, tilt, Bx, By, Bz, Vx, Vy, Vz)
result = abaimp(1.0, 1.0, -0.8, 1.9, -0.2, -3, -0.2, -0.8, -400, 3, -8.5)
print(result)The utilities in xyz_predict.py and valtest.py offer additional ways to visualise or validate model output.
Use xyz_predict.py to explore the magnetopause crossings in your dataset by plotting the predicted magnetopause points in three dimensions to check how they cluster in space.
- Simple histograms of
r_hist.py,bz_hist.pyand dynamic pressure (pdyn_hist.py) reveal their most common values.
These plots show that most radii fall between 0 and 5 RE while Bz usually lies within roughly ±10 nT, and pdyn concentrates around 3 nPa. With more labelled crossings the model can be trained on a larger set and the validation loss (about 2.8 RE with the sample data) generally improves.
The script synth_mp.py is the final product of this project. It loads a saved
model and generates a synthetic magnetopause surface for any set of solar wind
conditions. The routine sweeps through latitude and longitude angles, predicts
the corresponding radial distance and then plots the boundary as 3‑D and planar
scatter plots. This provides an immediate visual impression of the magnetopause
shape under the specified conditions.
from synth_mp import synth_mp
# Example solar wind parameters
synth_mp(pdyn=2.5, bx=0.0, by=0.0, bz=-5.0, vx=-400, vy=0.0, vz=0.0, tilt=0.0)
print(result)A short demonstration notebook is available in analysis.ipynb.
To explore the synthetic magnetopause interactively, install JupyterLab and
launch it from the repository root:
pip install jupyterlab
jupyter labOpen the analysis.ipynb notebook and run the provided cell to display the
magnetopause surface under example solar wind conditions.
The uniqueness of this research lies in the dynamic nature of the magnetopause. Unlike most existing models that rely heavily on theoretical formulations, this study introduces a data-driven approach trained exclusively on empirical observations focused on the radial distance (in Earth radii) influenced by solar wind conditions. While it focuses specifically on the dayside magnetopause, the model offers a fresh perspective by capturing variability and interactions, contributing a novel and practical viewpoint to magnetopause modeling.
I would like to extend my sincere thanks to Connor O'Brien (connor-obrien888) for his mentorship and support throughout the development of this project.
Connor's guidance helped shape both the structure and logic of the codebase, and his contributions were instrumental in my learning process. Special thanks for providing the sw_loader.py module, and magnetopause crossing data which played a key role in development.
His work: https://github.com/connor-obrien888
This project is distributed under the terms of the MIT License.