IRBEM.jl

DOI

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 position
  • landi2lstar: Fast empirical L* for locally mirroring particles
  • get_mlt: Get Magnetic Local Time from GEO position and date
  • get_hemi: Get magnetic hemisphere of input location

Points of interest on the field line

Magnetic field computation

  • get_field_multi: Compute GEO vector of magnetic field at input location
  • get_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 position
  • drift_shell: Trace a full drift shell for particles with mirror point at input location
  • drift_bounce_orbit: Trace a full bounce orbit for particles with mirror point at input location

Coordinates transformations

  • coord_trans: Transform coordinates from one system to another

Library information

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

source

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.MF75 — Constant

1: Mead & Fairfield [1975], uses 0 ≤ Kp ≤ 9, valid for rGEO ≤17 Re

source
IRBEM.TS87 — Constant

2: Tsyganenko short [1987], uses 0 ≤ Kp ≤ 9, valid for rGEO ≤30 Re

source
IRBEM.TL87 — Constant

3: Tsyganenko long [1987], uses 0 ≤ Kp ≤ 9, valid for rGEO ≤70 Re

source
IRBEM.T89 — Constant

4: Tsyganenko [1989], uses 0 ≤ Kp ≤ 9, valid for rGEO ≤70 Re

source
IRBEM.OPQ77 — Constant

5: Olson & Pfitzer quiet [1977], valid for rGEO ≤15 Re

source
IRBEM.T01 — Constant

9: Tsyganenko [2001], uses -50 ≤ Dst ≤ 20, 0.5 ≤ Pdyn ≤ 5, |By| ≤ 5, |Bz| ≤ 5, 0 ≤ G1 ≤ 10, 0 ≤ G2 ≤ 10, valid for xGSM ≥-15 Re

source
IRBEM.T01S — Constant

10: Tsyganenko [2001], storm time, uses Dst, Pdyn, By, Bz, G2, G3, valid for xGSM ≥-15 Re

source
IRBEM.T04 — Constant

11: Tsyganenko [2004], uses Dst, Pdyn, By, Bz, W1, W2, W3, W4, W5, W6, valid for xGSM ≥-15 Re

source
IRBEM.A00 — Constant

12: Alexeev [2000], also known as Paraboloid model, uses Dsw, Vsw, Dst, Bz, AL

source
IRBEM.MT — Constant

14: Mead-Tsyganenko, uses Kp, onera model where the Tsyganenko 89 model is best fitted by a Mead model

source

Coordinate systems

See the README.

Computing magnetic field coordinates

IRBEM.make_lstar — Function
make_lstar(time, x, maginput=(; ); coord="GDZ", kext=OPQ77, options=(0, 0, 0, 0, 0))

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

  • 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 or 3-tuples (one per time)
  • coord (optional): IRBEM name of the coordinate system of raw x (default: "GDZ"); not allowed for a CoordinateVector
  • kext (optional): External field model (default: OPQ77)
  • options (optional): IRBEM model options, 5 integers (default: all 0)
  • maginput: Named tuple, dictionary or MagInput with 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", [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

source
IRBEM.landi2lstar — Function
landi2lstar(time, x, maginput=(; ); coord="GDZ", kext=OPQ77, options=(0, 0, 0, 0, 0))

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

  • 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 or 3-tuples (one per time)
  • coord (optional): IRBEM name of the coordinate system of raw x (default: "GDZ"); not allowed for a CoordinateVector
  • kext (optional): External field model (default: OPQ77)
  • options (optional): IRBEM model options, 5 integers (default: all 0)
  • maginput: Named tuple, dictionary or MagInput with 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

source
IRBEM.get_mlt — Function
get_mlt(time, 𝐫)
get_mlt(A; dim = nothing)

Get Magnetic Local Time (MLT) from a GEO position 𝐫 (Cartesian, or a CoordinateVector in any system) and time. A is a time series of GEO positions (e.g. DimArray, KeyedArray, or Timed(A, times; dim), see TimeseriesUtilities.jl); returns MLT per time in the same container.

source
IRBEM.get_hemi — Function
get_hemi(time, x, maginput=(; ); coord="GDZ", kext=OPQ77, options=(0, 0, 0, 0, 0))

Magnetic hemisphere of the input location: +1 northern, -1 southern, 0 invalid magnetic field.

Arguments

  • 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 or 3-tuples (one per time)
  • coord (optional): IRBEM name of the coordinate system of raw x (default: "GDZ"); not allowed for a CoordinateVector
  • kext (optional): External field model (default: OPQ77)
  • options (optional): IRBEM model options, 5 integers (default: all 0)
  • maginput: Named tuple, dictionary or MagInput with 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

source

Points of interest on the field line

IRBEM.find_mirror_point — Function
find_mirror_point(time, x, alpha, maginput=(; ); coord="GDZ", kext=OPQ77, options=(0, 0, 0, 0, 0))

Find the magnitude and location of the mirror point along a field line traced from any given location and local pitch-angle.

Arguments

  • 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 or 3-tuples (one per time)

  • coord (optional): IRBEM name of the coordinate system of raw x (default: "GDZ"); not allowed for a CoordinateVector

  • kext (optional): External field model (default: OPQ77)

  • options (optional): IRBEM model options, 5 integers (default: all 0)

  • maginput: Named tuple, dictionary or MagInput with 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

source
IRBEM.find_magequator — Function
find_magequator(time, x, maginput=(; ); coord="GDZ", kext=OPQ77, options=(0, 0, 0, 0, 0))

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

  • 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 or 3-tuples (one per time)
  • coord (optional): IRBEM name of the coordinate system of raw x (default: "GDZ"); not allowed for a CoordinateVector
  • kext (optional): External field model (default: OPQ77)
  • options (optional): IRBEM model options, 5 integers (default: all 0)
  • maginput: Named tuple, dictionary or MagInput with magnetic field model inputs (optional). Values are scalars (shared by all times) or vectors (one per time); unset inputs are missing (-9999).
source
IRBEM.find_foot_point — Function
find_foot_point(time, x, stop_alt, hemi_flag, maginput=(; ); coord="GDZ", kext=OPQ77, options=(0, 0, 0, 0, 0))

Find the footprint of a field line that passes through location X in a given hemisphere.

Arguments

  • 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 or 3-tuples (one per time)

  • coord (optional): IRBEM name of the coordinate system of raw x (default: "GDZ"); not allowed for a CoordinateVector

  • kext (optional): External field model (default: OPQ77)

  • options (optional): IRBEM model options, 5 integers (default: all 0)

  • maginput: Named tuple, dictionary or MagInput with 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 tracing

  • hemi_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

source

Magnetic field computation

IRBEM.get_field_multi — Function
get_field_multi(time, x, maginput=(; ); coord="GDZ", kext=OPQ77, options=(0, 0, 0, 0, 0))

Compute the GEO vector of the magnetic field at input location for a set of internal/external magnetic field.

Arguments

  • 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 or 3-tuples (one per time)
  • coord (optional): IRBEM name of the coordinate system of raw x (default: "GDZ"); not allowed for a CoordinateVector
  • kext (optional): External field model (default: OPQ77)
  • options (optional): IRBEM model options, 5 integers (default: all 0)
  • maginput: Named tuple, dictionary or MagInput with 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)
source
IRBEM.get_bderivs — Function
get_bderivs(time, x, maginput=(; ); coord="GDZ", kext=OPQ77, options=(0, 0, 0, 0, 0))

Compute the magnetic field and its 1st-order derivatives at each input location.

Arguments

  • 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 or 3-tuples (one per time)

  • coord (optional): IRBEM name of the coordinate system of raw x (default: "GDZ"); not allowed for a CoordinateVector

  • kext (optional): External field model (default: OPQ77)

  • options (optional): IRBEM model options, 5 integers (default: all 0)

  • maginput: Named tuple, dictionary or MagInput with 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 fields Bgeo (GEO components of B field), Bmag (magnitude of B field), gradBmag (gradients of Bmag in GEO), and diffB (derivatives of the magnetic field vector).

Examples

julia> get_bderivs("2015-02-02T06:12:43", [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])
source

Field tracing

IRBEM.trace_field_line — Function
trace_field_line(time, x, maginput=(; ); coord="GDZ", kext=OPQ77, options=(0, 0, 0, 0, 0), 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

source
IRBEM.drift_shell — Function
drift_shell(time, x, maginput=(; ); coord="GDZ", kext=OPQ77, options=(0, 0, 0, 0, 0))

Trace a full drift shell for particles that have their mirror point at the input location.

Outputs

  • Lm: L McIlwain
  • Lstar: L Roederer or Φ=2π Bo/L* (nT Re2), depending on the options value
  • Blocal (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 shell
  • Nposit (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

source
IRBEM.drift_bounce_orbit — Function
drift_bounce_orbit(time, x, alpha, maginput=(; ); R0=1.0, coord="GDZ", kext=OPQ77, options=(0, 0, 0, 0, 0))

Trace a full drift-bounce orbit for particles with local pitch angle alpha (degrees) at the input location until radial distance R0 (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

source

Coordinates transformations

IRBEM.coord_trans — Function
coord_trans(in, out, time, pos)

Transform pos (shape (3,) or (3, n), one time per point) between IRBEM coordinate systems named in and out.

source

Library information