MATLAB accesses the IRBEM Fortran library through a shared library file (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.
.so on Unix, .dll on Windows) together with a C-style header file (.h) that declares every subroutine in C calling syntax. MATLAB’s built-in loadlibrary / calllib mechanism (often called a “mex file” interface) bridges the two. For historical reasons, every MATLAB wrapper file and function name in IRBEM carries the prefix onera_desp_lib_ rather than irbem_.
Installation
- Windows 32-bit
- Windows 64-bit
- Linux / macOS (from source)
Download and unpack the MATLAB wrappers
Download the matlab folder tarball and untar its contents into
irbem\matlab.Download and unpack the data files
Download the data folder tarball and untar its contents into
irbem\data.Add paths in MATLAB
Open MATLAB, go to File → Set Path, add
irbem\matlab and irbem\data, then click Save.Place the 32-bit DLL
Download the 32-bit Windows DLL and save it as
irbem\matlab\onera_desp_lib.dll.MATLAB usage patterns
The MATLAB wrappers are designed to feel like native MATLAB functions:- Auto-loading — each
.mwrapper checks whether the shared library is already loaded, and if not, loads it from the default location (anywhere on the MATLAB path) automatically. - Vectorised inputs — although the underlying Fortran library limits array sizes, the wrappers split large input arrays into multiple library calls and stitch the results together transparently.
- Scalar expansion — when an array of inputs is expected, scalar arguments are automatically expanded with
repmatto match the size of the other inputs. - Keyword arguments — integer codes for
kext,options,sysaxes, and other enum-style parameters can be replaced with human-readable strings (see below). - Date numbers — all date/time arguments use MATLAB’s
datenumformat. Usedatenum(...)to construct them. - Inline help — every
.mfile includes a full MATLAB-style help block; runhelp <function_name>from the MATLAB command window to see parameter descriptions and examples.
Helper functions
The library ships several utility functions that convert human-readable inputs into the integer constants expected by the Fortran library.Keyword arguments for kext and sysaxes
In most wrapper functions you can pass either the integer code or the string keyword shown in the table. Theonera_desp_lib_kext and onera_desp_lib_sysaxes converters implement these look-up tables internally.
kext integer | String keyword | Model |
|---|---|---|
| 0 | 'None' | No external field |
| 1 | 'MF75' | Mead–Fairfield 1975 |
| 4 | 'T89' | Tsyganenko 1989 |
| 5 | 'OPQ77' | Olson–Pfitzer Quiet 1977 |
| 7 | 'T96' | Tsyganenko 1996 |
| 9 | 'T01' | Tsyganenko 2001 |
sysaxes integer | String keyword | Coordinate system |
|---|---|---|
| 0 | 'GDZ' | Geodetic: altitude (km), latitude (°), East longitude (°) |
| 1 | 'GEO' | Geographic Cartesian (Re) |
| 2 | 'GSM' | Geocentric Solar Magnetospheric (Re) |
| 3 | 'GSE' | Geocentric Solar Ecliptic (Re) |
| 4 | 'SM' | Solar Magnetic (Re) |
| 5 | 'GEI' | Geocentric Equatorial Inertial (Re) |
| 6 | 'MAG' | Geomagnetic (Re) |
Example: calling make_lstar
The example below computes magnetic coordinates for a single spacecraft position over Tromsø, Norway.
The
onera_desp_lib_make_lstar wrapper accepts arrays for matlabd, x1, x2, and x3. Pass column vectors of equal length to compute magnetic coordinates for multiple spacecraft positions in a single call.Note on fly_in_afrl_crres
The wrapper function fly_in_afrl_crres requires a set of text data files, most notably crrespro_quiet.txt. If the path to these files is not supplied explicitly, the wrapper searches for crrespro_quiet.txt in the MATLAB search path. Add the IRBEM data/ directory to the path (as described in the installation section) to ensure the file is found automatically.