This guide walks you through two of IRBEM’s most common operations: computing L* (the Roederer drift-shell parameter) for a spacecraft location, and transforming a position vector between geographic and magnetospheric coordinate systems. Both examples use the Python wrapper that ships with IRBEM. By the end you will have confirmed your installation is working and produced physically meaningful output.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/PRBEM/IRBEM/llms.txt
Use this file to discover all available pages before exploring further.
Install IRBEM
Follow the Installation guide for your platform. You need:
- A compiled IRBEM shared library (
libirbem.so,libirbem.dll, or the macOS equivalent) produced by runningmake OS=<platform> ENV=gfortran64 allandmake OS=<platform> ENV=gfortran64 install. - The Python wrapper installed from the
python/directory:
Compute L* with MagFields
The
MagFields class wraps IRBEM’s magnetic coordinate routines. Instantiate it once with your chosen external field model and input coordinate system, then call make_lstar with a position dictionary and magnetic field driver inputs.The
kext string 'OPQ77' maps to integer 5 in IRBEM’s external model table. Other commonly used models are 'T89' (kext=4), 'T96' (kext=7), and 'T01' (kext=9). Each model requires different entries in maginput; see the general information reference for the full maginput key table.Interpret the make_lstar output
make_lstar returns a dictionary with six keys. Each value is a list with one entry per input time point:| Key | Units | Description |
|---|---|---|
Lm | — | McIlwain L parameter. Encodes whether the particle is trapped, in the drift loss cone, or outside a closed shell. |
Lstar | — | Roederer L* (or Φ = 2π B₀/L* in nT Re² if options[0]=2). The primary adiabatic drift-shell invariant. |
blocal | nT | Magnetic field magnitude at the input spacecraft position. |
bmin | nT | Magnetic field magnitude at the magnetic equator along the field line (equatorial mirror field). |
xj | Re | Second adiabatic invariant I, related to the bounce motion of trapped particles. |
MLT | hours | Magnetic Local Time (0–24 h), indicating the magnetic longitude relative to the Sun. |
Transform coordinates with Coords
The The
Coords class wraps IRBEM’s coord_trans_vec1 Fortran routine. Pass a datetime object (or list of them), a position (or array of positions), and the source and destination coordinate system names.transform method accepts coordinate system names as either three-letter strings ('GEO', 'GSM', 'GSE', 'SM', 'GEI', 'MAG', 'GDZ', 'RLL') or as the corresponding integer keys (0–8). In Fortran, pass the integer key directly.Available coordinate systems:| Key | Name | Units |
|---|---|---|
| 0 | GDZ | altitude (km), latitude (°), East longitude (°) |
| 1 | GEO | Cartesian geographic (Re) |
| 2 | GSM | Geocentric Solar Magnetospheric Cartesian (Re) |
| 3 | GSE | Geocentric Solar Ecliptic Cartesian (Re) |
| 4 | SM | Solar Magnetic Cartesian (Re) |
| 5 | GEI | Geocentric Equatorial Inertial Cartesian (Re) |
| 6 | MAG | Geomagnetic Cartesian (Re) |
| 7 | SPH | Spherical geographic (Re, °, °) |
| 8 | RLL | Radial-Lat-Long (Re, °, °) — preferred over SPH |
Next Steps
Drift Shell Tracing
Use
MagFields.drift_shell() to trace a complete drift shell and obtain the full set of field-line positions in GEO coordinates — useful for visualisation and drift-averaged quantities.Field-Line Tracing
Use
MagFields.trace_field_line() to trace the field line through a spacecraft position and recover its GEO coordinates as a (3 × 3000) array.Mirror Point & Footpoint
find_mirror_point() returns the GEO position and field magnitude of the conjugate mirror point; find_foot_point() maps to the ionospheric footprint at a specified altitude.Radiation Models
Call
FLY_IN_NASA_AEAP (via the Fortran or IDL/MATLAB interface) to fly a spacecraft trajectory through the AE8/AP8 electron and proton flux models and retrieve differential or integral fluxes.python/IRBEM/.