Igrf
International Geomagnetic Reference Field IGRF13 in Python and Matlab
Install / Use
/learn @space-physics/IgrfREADME
IGRF 13 in Python
International Geomagnetic Reference Field: IGRF13 in object-oriented Python or Matlab.


Install
A Fortran compiler is required, such as gfortran:
- Linux:
apt install gfortran - Mac:
brew install gcc - gfortran for Windows (MinGW)
To get the IGRF Python development version, git clone and then:
python -m pip install -e .
Otherwise, for the latest release from PyPI:
python -m pip install igrf
The first time you install IGRF, do once from Python:
import igrf
igrf.build()
Optionally, test the install with:
pytest
Example
To make the plots in this readme:
igrf
using as a Python module at geodetic coordinates 65N, 148W:
import igrf
mag = igrf.igrf('2010-07-12', glat=65, glon=-148, alt_km=100)
returns an xarray.Dataset:
<xarray.Dataset>
Dimensions: (alt_km: 1)
Coordinates:
* alt_km (alt_km) int64 100
Data variables:
north (alt_km) float64 1.122e+04
east (alt_km) float64 4.148e+03
down (alt_km) float64 5.302e+04
total (alt_km) float64 5.436e+04
incl (alt_km) float64 77.29
decl (alt_km) float64 20.29
Matlab
Matlab can seamlessly call Python modules, as used in igrf.m. Instead of the $1000 Aerospace Toolbox, use this free IGRF for Matlab like:
igrf.igrf(datetime(2020,1,3,5,4,22), 20, 60, 0)
You may find it helpful to run "setup.m" first to setup the library paths.
References
Related Skills
node-connect
337.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
claude-opus-4-5-migration
83.2kMigrate prompts and code from Claude Sonnet 4.0, Sonnet 4.5, or Opus 4.1 to Opus 4.5
frontend-design
83.2kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
model-usage
337.4kUse CodexBar CLI local cost usage to summarize per-model usage for Codex or Claude, including the current (most recent) model or a full model breakdown. Trigger when asked for model-level usage/cost data from codexbar, or when you need a scriptable per-model summary from codexbar cost JSON.
