IRBEM.jl
Julia wrapper for the IRBEM (International Radiation Belt Environment Modeling) Fortran library.
IRBEM — Module
A wrapper for International Radiation Belt Environment Modeling (IRBEM) library
See the Documentation for more information.
Functions
Computing magnetic field coordinates
make_lstar: Compute magnetic coordinates at a spacecraft positionlandi2lstar: Fast empirical L* for locally mirroring particlesget_mlt: Get Magnetic Local Time from GEO position and dateget_hemi: Get magnetic hemisphere of input location
Points of interest on the field line
find_mirror_point: Find magnitude and location of mirror point along field linefind_foot_point: Find footprint of field line in a given hemispherefind_magequator: Find coordinates of magnetic equator from field line tracing
Magnetic field computation
get_field_multi: Compute GEO vector of magnetic field at input locationget_bderivs: Compute the magnetic field and its 1st-order derivatives at each input location
Field tracing
trace_field_line: Trace a full field line crossing the input positiondrift_shell: Trace a full drift shell for particles with mirror point at input locationdrift_bounce_orbit: Trace a full bounce orbit for particles with mirror point at input location
Coordinates transformations
transform: Transform coordinates from one system to another
Library information
get_igrf_version: Returns the version number of the IGRF modelirbem_fortran_version: Provides the repository version number of the fortran source codeirbem_fortran_release: Provides the repository release tag of the fortran source code
Outputs that IRBEM could not compute (its -1e31 fill value) are NaN. Only one IRBEM routine runs at a time: calls from multiple threads are serialized.
References
API Reference
External Magnetic Field Models and Model Inputs
See IRBEM Documentation for more details. Most routines accept a kext keyword argument (of integer-like type) which allows the selection of the external magnetic field model.
IRBEM.ExternalFieldModel — Type
External Magnetic Field Model
See IRBEM Documentation for more details.
IRBEM.MagInput — Type
Magnetic field inputs. Unset fields are -9999, which IRBEM treats as missing.
IRBEM.MF75 — Constant
1: Mead & Fairfield [1975], uses 0 ≤ Kp ≤ 9, valid for rGEO ≤17 Re
IRBEM.TS87 — Constant
2: Tsyganenko short [1987], uses 0 ≤ Kp ≤ 9, valid for rGEO ≤30 Re
IRBEM.TL87 — Constant
3: Tsyganenko long [1987], uses 0 ≤ Kp ≤ 9, valid for rGEO ≤70 Re
IRBEM.OPQ77 — Constant
5: Olson & Pfitzer quiet [1977], valid for rGEO ≤15 Re
IRBEM.OPD88 — Constant
6: Olson & Pfitzer dynamic [1988]
IRBEM.OM97 — Constant
8: Ostapenko & Maltsev [1997]
IRBEM.T01S — Constant
10: Tsyganenko [2001], storm time, uses Dst, Pdyn, By, Bz, G2, G3, valid for xGSM ≥-15 Re
Coordinate systems
See IRBEM Documentation for more details.
IRBEM.HEEQ — Type
Heliocentric Earth Equatorial (HEEQ) (Earth radii)
IRBEM.J2000 — Type
GEI at J2000: mean equator and mean equinox of J2000 (Earth radii)
IRBEM.TEME — Type
True Equator Mean Equinox (TEME), the inertial system of SGP4 (Earth radii)
Computing magnetic field coordinates
IRBEM.make_lstar — Function
make_lstar(time, x, [coord="GDZ",] maginput=(; ); kext=KEXT[], options=OPTIONS[])
make_lstar(model::MagneticField, X::AbstractDict, maginput=(; ))Compute magnetic coordinates at a spacecraft position. Returns a named tuple with fields Lm, Lstar, Blocal, Bmin, XJ, and MLT. Lstar is only computed when options[1] > 0 (NaN otherwise).
Arguments
Signature 1 (preferred):
time: Date and time (DateTime, Vector{DateTime}, or String)x: Position as a 3-vector, a 3×n array, or a vector of 3-vectors (one per time). Ifxis aCoordinateVector(e.g.GDZ(...)) or a vector of them, omitcoord.coord(optional): Coordinate system name,Symbolor type (default: "GDZ")kext(optional): External field model selection (default: KEXT[])options(optional): Model options (default: OPTIONS[])
Signature 2:
model::MagneticField: The magnetic field modelX: Dictionary with keys:dateTimeorTime: Date and time (DateTime or String)x1,x2,x3: Position coordinates in the system specified bysysaxes
Common arguments:
maginput: Named tuple, dictionary orMagInputwith magnetic field model inputs (optional). Values are scalars (shared by all times) or vectors (one per time); unset inputs are missing (-9999).
Examples
julia> make_lstar("2015-02-02T06:12:43", GDZ(600.0, 60.0, 50.0), (; Kp = 40.0); kext = "T89")
(Lm = 3.5597242229067536, Lstar = NaN, Blocal = 42271.43059990003, Bmin = 626.2258295723121, XJ = 7.020585390925573, MLT = 10.170297893176182)Reference: IRBEM API
IRBEM.landi2lstar — Function
landi2lstar(time, x, [coord="GDZ",] maginput=(; ); kext=KEXT[], options=OPTIONS[])
landi2lstar(model::MagneticField, X::AbstractDict, maginput=(; ))Like make_lstar, but L* is deduced empirically from Lm, I and day of year, which is much faster. Errors in L* are below 2%. Valid for locally mirroring particles only. IRBEM forces IGRF + Olson-Pfitzer quiet (OPQ77), whatever kext and options[5] are.
Arguments
Signature 1 (preferred):
time: Date and time (DateTime, Vector{DateTime}, or String)x: Position as a 3-vector, a 3×n array, or a vector of 3-vectors (one per time). Ifxis aCoordinateVector(e.g.GDZ(...)) or a vector of them, omitcoord.coord(optional): Coordinate system name,Symbolor type (default: "GDZ")kext(optional): External field model selection (default: KEXT[])options(optional): Model options (default: OPTIONS[])
Signature 2:
model::MagneticField: The magnetic field modelX: Dictionary with keys:dateTimeorTime: Date and time (DateTime or String)x1,x2,x3: Position coordinates in the system specified bysysaxes
Common arguments:
maginput: Named tuple, dictionary orMagInputwith magnetic field model inputs (optional). Values are scalars (shared by all times) or vectors (one per time); unset inputs are missing (-9999).
Reference: IRBEM API
IRBEM.get_mlt — Function
get_mlt(𝐫, time)
get_mlt(time, 𝐫::AbstractVector)
get_mlt(x, y, z, time)
get_mlt(X::AbstractDict)Get Magnetic Local Time (MLT) from a Cartesian GEO position 𝐫 and time. X is a dictionary with keys x1, x2, x3 (GEO position) and dateTime or Time.
IRBEM.get_hemi — Function
get_hemi(time, x, [coord="GDZ",] maginput=(; ); kext=KEXT[], options=OPTIONS[])
get_hemi(model::MagneticField, X::AbstractDict, maginput=(; ))Magnetic hemisphere of the input location: +1 northern, -1 southern, 0 invalid magnetic field.
Arguments
Signature 1 (preferred):
time: Date and time (DateTime, Vector{DateTime}, or String)x: Position as a 3-vector, a 3×n array, or a vector of 3-vectors (one per time). Ifxis aCoordinateVector(e.g.GDZ(...)) or a vector of them, omitcoord.coord(optional): Coordinate system name,Symbolor type (default: "GDZ")kext(optional): External field model selection (default: KEXT[])options(optional): Model options (default: OPTIONS[])
Signature 2:
model::MagneticField: The magnetic field modelX: Dictionary with keys:dateTimeorTime: Date and time (DateTime or String)x1,x2,x3: Position coordinates in the system specified bysysaxes
Common arguments:
maginput: Named tuple, dictionary orMagInputwith magnetic field model inputs (optional). Values are scalars (shared by all times) or vectors (one per time); unset inputs are missing (-9999).
Reference: IRBEM API
Points of interest on the field line
IRBEM.find_mirror_point — Function
find_mirror_point(time, x, alpha, [coord="GDZ",] maginput=(; ); kext=KEXT[], options=OPTIONS[])
find_mirror_point(model::MagneticField, X, alpha, maginput=(; ))Find the magnitude and location of the mirror point along a field line traced from any given location and local pitch-angle.
Arguments
Signature 1 (preferred):
time: Date and time (DateTime, Vector{DateTime}, or String)x: Position as a 3-vector, a 3×n array, or a vector of 3-vectors (one per time). Ifxis aCoordinateVector(e.g.GDZ(...)) or a vector of them, omitcoord.coord(optional): Coordinate system name,Symbolor type (default: "GDZ")kext(optional): External field model selection (default: KEXT[])options(optional): Model options (default: OPTIONS[])
Signature 2:
model::MagneticField: The magnetic field modelX: Dictionary with keys:dateTimeorTime: Date and time (DateTime or String)x1,x2,x3: Position coordinates in the system specified bysysaxes
Common arguments:
maginput: Named tuple, dictionary orMagInputwith magnetic field model inputs (optional). Values are scalars (shared by all times) or vectors (one per time); unset inputs are missing (-9999).alpha: Local pitch angle in degrees
Outputs
- Blocal: magnitude of magnetic field at point (nT)
- Bmirr: magnitude of the magnetic field at the mirror point (nT)
- posit (array of 3 double): GEO coordinates of the mirror point (Re)
References: IRBEM API
IRBEM.find_magequator — Function
find_magequator(time, x, [coord="GDZ",] maginput=(; ); kext=KEXT[], options=OPTIONS[])
find_magequator(model::MagneticField, X::AbstractDict, maginput=(; ))Find the coordinates of the magnetic equator from tracing the magnetic field line from the input location. Returns a named tuple with fields Bmin and XGEO (location of magnetic equator).
Arguments
Signature 1 (preferred):
time: Date and time (DateTime, Vector{DateTime}, or String)x: Position as a 3-vector, a 3×n array, or a vector of 3-vectors (one per time). Ifxis aCoordinateVector(e.g.GDZ(...)) or a vector of them, omitcoord.coord(optional): Coordinate system name,Symbolor type (default: "GDZ")kext(optional): External field model selection (default: KEXT[])options(optional): Model options (default: OPTIONS[])
Signature 2:
model::MagneticField: The magnetic field modelX: Dictionary with keys:dateTimeorTime: Date and time (DateTime or String)x1,x2,x3: Position coordinates in the system specified bysysaxes
Common arguments:
maginput: Named tuple, dictionary orMagInputwith magnetic field model inputs (optional). Values are scalars (shared by all times) or vectors (one per time); unset inputs are missing (-9999).
IRBEM.find_foot_point — Function
find_foot_point(time, x, stop_alt, hemi_flag, [coord="GDZ",] maginput=(; ); kext=KEXT[], options=OPTIONS[])
find_foot_point(model::MagneticField, X, stop_alt, hemi_flag, maginput=(; ))Find the footprint of a field line that passes through location X in a given hemisphere.
Arguments
Signature 1 (preferred):
time: Date and time (DateTime, Vector{DateTime}, or String)x: Position as a 3-vector, a 3×n array, or a vector of 3-vectors (one per time). Ifxis aCoordinateVector(e.g.GDZ(...)) or a vector of them, omitcoord.coord(optional): Coordinate system name,Symbolor type (default: "GDZ")kext(optional): External field model selection (default: KEXT[])options(optional): Model options (default: OPTIONS[])
Signature 2:
model::MagneticField: The magnetic field modelX: Dictionary with keys:dateTimeorTime: Date and time (DateTime or String)x1,x2,x3: Position coordinates in the system specified bysysaxes
Common arguments:
maginput: Named tuple, dictionary orMagInputwith magnetic field model inputs (optional). Values are scalars (shared by all times) or vectors (one per time); unset inputs are missing (-9999).stop_alt: Altitude in km where to stop field line tracinghemi_flag: Hemisphere flag (0: same as SM z, +1: northern, -1: southern)
Outputs
- XFOOT: GDZ coordinates of the foot point (km, deg, deg)
- BFOOT: magnetic field vector (GEO) at the foot point (nT)
- BFOOTMAG: magnitude of the magnetic field at the foot point (nT)
References: IRBEM API
Magnetic field computation
IRBEM.get_field_multi — Function
get_field_multi(time, x, [coord="GDZ",] maginput=(; ); kext=KEXT[], options=OPTIONS[])
get_field_multi(model::MagneticField, X::AbstractDict, maginput=(; ))Compute the GEO vector of the magnetic field at input location for a set of internal/external magnetic field.
Arguments
Signature 1 (preferred):
time: Date and time (DateTime, Vector{DateTime}, or String)x: Position as a 3-vector, a 3×n array, or a vector of 3-vectors (one per time). Ifxis aCoordinateVector(e.g.GDZ(...)) or a vector of them, omitcoord.coord(optional): Coordinate system name,Symbolor type (default: "GDZ")kext(optional): External field model selection (default: KEXT[])options(optional): Model options (default: OPTIONS[])
Signature 2:
model::MagneticField: The magnetic field modelX: Dictionary with keys:dateTimeorTime: Date and time (DateTime or String)x1,x2,x3: Position coordinates in the system specified bysysaxes
Common arguments:
maginput: Named tuple, dictionary orMagInputwith magnetic field model inputs (optional). Values are scalars (shared by all times) or vectors (one per time); unset inputs are missing (-9999).
Returns
NamedTuple: Contains fields Bgeo (GEO components of B field) and Bmag (magnitude of B field)
IRBEM.get_bderivs — Function
get_bderivs(time, x, [coord="GDZ",] maginput=(; ); kext=KEXT[], options=OPTIONS[])
get_bderivs(model::MagneticField, X::AbstractDict, maginput=(; ))Compute the magnetic field and its 1st-order derivatives at each input location.
Arguments
Signature 1 (preferred):
time: Date and time (DateTime, Vector{DateTime}, or String)x: Position as a 3-vector, a 3×n array, or a vector of 3-vectors (one per time). Ifxis aCoordinateVector(e.g.GDZ(...)) or a vector of them, omitcoord.coord(optional): Coordinate system name,Symbolor type (default: "GDZ")kext(optional): External field model selection (default: KEXT[])options(optional): Model options (default: OPTIONS[])
Signature 2:
model::MagneticField: The magnetic field modelX: Dictionary with keys:dateTimeorTime: Date and time (DateTime or String)x1,x2,x3: Position coordinates in the system specified bysysaxes
Common arguments:
maginput: Named tuple, dictionary orMagInputwith magnetic field model inputs (optional). Values are scalars (shared by all times) or vectors (one per time); unset inputs are missing (-9999).dX: step size (Re) for the finite differences, placed right after the position
Returns
NamedTuple: Contains fieldsBgeo(GEO components of B field),Bmag(magnitude of B field),gradBmag(gradients of Bmag in GEO), anddiffB(derivatives of the magnetic field vector).
Examples
julia> get_bderivs("2015-02-02T06:12:43", GDZ(600.0, 60.0, 50.0), 0.1, (; Kp = 40.0); kext = "T89") |> pprint
(Bgeo = [-21079.764883133903, -21504.21460705096, -29666.24532305791],
Bmag = 42271.43059990003,
gradBmag = [-49644.37271032293, -46030.37495428827, -83024.03530787815],
diffB =
[-13530.079906431165 31460.805163291334 53890.73134176735; 30427.464243221693 -16715.08632269888 50326.93737340687; 62620.43884602288 59981.93936448166 44395.53254933224])Field tracing
IRBEM.trace_field_line — Function
trace_field_line(time, x, [coord="GDZ",] maginput=(; ); kext=KEXT[], options=OPTIONS[], R0=1.0)
trace_field_line(model::MagneticField, X::AbstractDict, maginput=(; ); R0=1.0)Trace a full field line which crosses the input position until radial distance R0=1.0 (Re).
Outputs
- Lm: L McIlwain
- Blocal (array of Nposit double): magnitude of magnetic field at point (nT)
- Bmin: magnitude of magnetic field at equator (nT)
- XJ: I, related to second adiabatic invariant (Re)
- posit (array of (3, Nposit) double): Cartesian coordinates in GEO along the field line
- Nposit: number of points in posit
Reference: IRBEM API
IRBEM.drift_shell — Function
drift_shell(time, x, [coord="GDZ",] maginput=(; ); kext=KEXT[], options=OPTIONS[])
drift_shell(model::MagneticField, X::AbstractDict, maginput=(; ))Trace a full drift shell for particles that have their mirror point at the input location.
Outputs
Lm: L McIlwainLstar: L Roederer or Φ=2π Bo/L* (nT Re2), depending on the options valueBlocal(array of (1000, 48)): magnitude of magnetic field at point (nT)Bmin: magnitude of magnetic field at equator (nT)XJ: I, related to second adiabatic invariant (Re)posit(array of (3, 1000, 48)): Cartesian coordinates in GEO along the drift shellNposit(array of 48 integer): number of points in posit along each traced field line
Entries of posit and Blocal beyond Nposit are NaN.
Reference: IRBEM API
IRBEM.drift_bounce_orbit — Function
drift_bounce_orbit(time, x, [coord="GDZ",] maginput=(; ); kext=KEXT[], options=OPTIONS[], alpha=90, R0=1)
drift_bounce_orbit(model::MagneticField, X::AbstractDict, maginput=(; ); alpha=90, R0=1)Trace a full drift-bounce orbit for particles with a specified pitch angle alpha=90 at the input location until radial distance R0=1.0 (Re). Returns only positions between mirror points, with 25 azimuths.
Outputs:
- Lm: L McIlwain
- Lstar: L Roederer or Φ=2π Bo/L* (nT Re2), depending on the options value
- Blocal (array of (1000, 25) double): magnitude of magnetic field at point (nT)
- Bmin: magnitude of magnetic field at equator (nT)
- Bmirr: magnitude of magnetic field at mirror point (nT)
- XJ: I, related to second adiabatic invariant (Re)
- posit (array of (3, 1000, 25) double): Cartesian coordinates in GEO along the drift shell
- Nposit (array of 25 integer): number of points in posit along each traced field line
- hmin, hmin_lon: GDZ altitude (km) and longitude (deg) of the lowest point of the drift shell, among all traced points
Entries of posit and Blocal beyond Nposit are NaN.
Reference: IRBEM API
Coordinates transformations
IRBEM.transform — Function
transform(time, pos, in, out)
transform(time, pos, in => out)
transform(time, pos, "in2out")Transform coordinates from in coordinate system to out coordinate system.
pos is of shape (3,) for a single point or (3, n) for n points, with one time per point.
Example
using Dates
using IRBEM
time = DateTime(2020, 1, 1)
pos = [6.90274, -1.63624, 1.91669]
GSM(time, GEO(pos))
transform(time, pos, "GEO", "GSM")
transform(time, pos, "GEO" => "GSM")
transform(time, pos, "geo2gsm")Library information
IRBEM.get_igrf_version — Function
Returns the version number of the IGRF model.
IRBEM.irbem_fortran_version — Function
Provides the repository version number of the fortran source code.
IRBEM.irbem_fortran_release — Function
Provides the repository release tag of the fortran source code.