SwarmDF is a Python tool designed to automate the full workflow for analysing high-latitude ionospheric electrodynamics using multi-instrument observations.
SwarmDF uses the Lompe technique to combine measurements from Swarm satellites with complementary datasets (SuperMAG, SuperDARN, Iridium/AMPERE, DMSP/SSIES) and reconstruct two-dimensional maps of ionospheric electrodynamics along and around a user-defined Swarm trajectory.
- End-to-end automated workflow
- Multi-instrument data fusion
- Electrodynamics reconstruction using Lompe
- Built-in validation tool (LompeOSSE, under development)
- User-friendly graphical interface
git clone https://github.com/Margot-D/SwarmDF.git
cd SwarmDF
pip install .SwarmDF requires several external Python packages.
If Lompe is already installed, the following dependencies may still be needed:
pip install customtkinter tkcalendar imageio pillow
Once installed, the commands swarmdf-gui and swarmdf are available from any terminal within the active Python environment.
swarmdf-guiThe GUI can also generate a standalone Python script reproducing the configured SwarmDF workflow. This allows users to inspect, modify, and rerun the analysis outside the GUI.
For a quick start, run the built-in demo using sample datasets:
swarmdf --demoRun a full SwarmDF analysis using a configuration file:
swarmdf --config path/to/config.yamlAn example configuration files is provided in the examples/ directory.
Optional advanced plotting settings can be provided through a separate configuration file. If omitted, default plotting settings are used.
swarmdf --config path/to/config.yaml --plot-config path/to/plot_settings.yamlSwarmDF can also be used directly from Python, which allows full control over the workflow and direct access to results and plots.
from swarmdf.config import SwarmDFConfig, SwarmDFPlotSettings
from swarmdf.pipeline import *
config = SwarmDFConfig.default()
plot_settings = SwarmDFPlotSettings.default()
results = run_swarmdf_pipeline(config=config, plot_settings=plot_settings, use_sample_data=True)To run a custom analysis, set use_sample_data=False and configure the desired analysis and plotting parameters through SwarmDFConfig and SwarmDFPlotSettings.
import matplotlib
matplotlib.use("TkAgg")
import matplotlib.pyplot as plt
from PIL import Image
# %matplotlib inline
for input_fig in results.plots.input_frames:
plt.figure(figsize=(8, 6))
plt.imshow(Image.open(input_fig))
plt.axis("off")
plt.show()
if config.run_lompe_flag:
# %matplotlib inline
for output_fig in results.plots.output_frames:
plt.figure(figsize=(8, 6))
plt.imshow(Image.open(output_fig))
plt.axis("off")
plt.show()The pipeline returns a results object containing analysis outputs and generated figures.
For example, the Lompe model corresponding to the first analysis frame can be accessed as follows:
lompe_model = results.output.lompe_models[0]["model"]
# Example: compute the ground magnetic perturbations
Bground = lompe_model.B_ground()The repository also includes examples to help users get started:
- Jupyter demo notebook:
SwarmDF_demo.ipynb - Python script:
SwarmDF_example_script.py.
Both examples provide a step-by-step walkthrough of the complete SwarmDF workflow, from data retrieval and preprocessing to electrodynamic reconstruction and validation.
Data retrieval and preprocessing
Multi-instrument data integration
Electrodynamics reconstruction (Lompe)
Demo script and notebook (/example folder)
Graphical user interface (/gui folder)
Validation tool (LompeOSSE)
Extended documentation
Data product descriptions